:root {
  --bg: #faf9f5; --surface: #ffffff; --surface2: #f2f0e8; --surface3: #e9e6dc;
  --text: #1f1e1b; --muted: #6f6b62; --faint: #9a968c; --border: #e5e1d6;
  --accent: #c96442; --accent-strong: #b5532f; --accent-soft: #f6e3da; --on-accent: #fff;
  --ok: #2f7d4f; --ok-soft: #e1f0e6; --warn: #a86a12; --warn-soft: #f8ecd5;
  --err: #c0392b; --err-soft: #f9e2df; --info: #2b6cb0; --info-soft: #e1ecf8;
  --add: #e3f3e8; --del: #fbe6e3; --code: #f4f2eb;
  --shadow: 0 1px 2px rgba(30, 25, 15, .06), 0 4px 16px rgba(30, 25, 15, .06);
  --radius: 16px; --tab-h: 64px; --bar-h: 56px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1a1915; --surface: #23221e; --surface2: #2b2a25; --surface3: #35332d;
    --text: #eeebe3; --muted: #a8a397; --faint: #7d796f; --border: #36342e;
    --accent: #d97757; --accent-strong: #e58a6b; --accent-soft: #3a2a22; --on-accent: #fff;
    --ok: #63c08a; --ok-soft: #1f3327; --warn: #e3ad55; --warn-soft: #3a2f1c;
    --err: #ec6f62; --err-soft: #3b2220; --info: #73aaea; --info-soft: #1f2c3b;
    --add: #1d3324; --del: #3d2220; --code: #1e1d1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font: 15.5px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
svg.i { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 13px; }
.row { display: flex; gap: 8px; align-items: center; } .wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100dvh; }
.col { flex: 1; min-width: 0; display: flex; flex-direction: column; }
main { width: 100%; max-width: 820px; margin: 0 auto; padding: 8px 16px calc(var(--tab-h) + var(--safe-b) + 24px); flex: 1; }
body.no-tabs main { padding-bottom: calc(var(--safe-b) + 24px); }
body.has-composer main { padding-bottom: calc(var(--safe-b) + 150px); }

.appbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 4px;
  min-height: calc(var(--bar-h) + var(--safe-t)); padding: var(--safe-t) 8px 0 12px;
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-bottom: 1px solid transparent; transition: border-color .2s;
}
.appbar.scrolled { border-bottom-color: var(--border); }
.appbar-title { flex: 1; min-width: 0; padding-left: 4px; line-height: 1.25; }
.appbar-title .t { font-weight: 700; font-size: 20px; letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar-title .st { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 1px; }
.appbar.sub .appbar-title { padding-left: 0; }
.appbar.sub .appbar-title .t { font-size: 16px; font-weight: 650; }
.appbar-actions { display: flex; gap: 4px; align-items: center; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: none; color: var(--text); cursor: pointer; flex: none; }
.icon-btn:active { background: var(--surface2); }
.back { margin-left: -6px; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--border);
}
body.no-tabs .tabbar, body.has-composer .tabbar { display: none; }
.tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--faint); font-size: 11.5px; font-weight: 600; position: relative; }
.tab.active { color: var(--accent); }
.tab .count { position: absolute; top: 7px; left: calc(50% + 6px); min-width: 17px; height: 17px; padding: 0 5px; border-radius: 9px; background: var(--info); color: #fff; font-size: 10.5px; line-height: 17px; text-align: center; }
.tab-new { display: grid; place-items: center; }
.tab-new span { display: grid; place-items: center; width: 52px; height: 44px; border-radius: 16px; background: var(--accent); color: var(--on-accent); box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent); }
.tab-new span svg { width: 26px; height: 26px; stroke-width: 2.4; }

.side { display: none; }
@media (min-width: 900px) {
  .side { display: flex; flex-direction: column; gap: 6px; width: 240px; flex: none; padding: 18px 12px; position: sticky; top: 0; height: 100dvh; border-right: 1px solid var(--border); }
  .side-brand { display: flex; align-items: center; gap: 10px; font-weight: 750; font-size: 17px; color: var(--text); padding: 4px 8px 14px; }
  .side-new { margin-bottom: 10px; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .side-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px; color: var(--muted); font-weight: 600; }
  .side-nav a:hover { background: var(--surface2); }
  .side-nav a.active { background: var(--accent-soft); color: var(--accent); }
  .side-nav .count { margin-left: auto; background: var(--info); color: #fff; font-size: 11px; border-radius: 9px; padding: 0 7px; }
  .tabbar { display: none; }
  main { padding-bottom: 40px; }
  body.has-composer main { padding-bottom: 130px; }
  .appbar { padding-left: 24px; padding-right: 16px; }
  .appbar .back.root { display: none; }
}

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px;
  border-radius: 13px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: transform .08s, background .15s;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--err); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.lg { min-height: 52px; font-size: 16px; border-radius: 15px; }
.btn:disabled { opacity: .45; pointer-events: none; }

.field { margin-top: 20px; }
.field > .lbl { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; font-weight: 700; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: .05em; }
.field > .lbl a { text-transform: none; letter-spacing: 0; font-size: 13.5px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 8px; line-height: 1.45; }
input, select, textarea {
  width: 100%; font: inherit; font-size: 16px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 13px; padding: 12px 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 20%, transparent); }
textarea { resize: none; line-height: 1.5; }
.prompt-box { min-height: 170px; }
.search { position: relative; }
.search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { padding-left: 42px; background: var(--surface2); border-color: transparent; }
.search input:focus { background: var(--surface); }

.picker {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 58px; padding: 10px 14px; text-align: left;
  border: 1px solid var(--border); border-radius: 14px; background: var(--surface); cursor: pointer;
}
.picker .ic { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--accent-soft); color: var(--accent); flex: none; }
.picker .v { font-weight: 650; } .picker .s { font-size: 13px; color: var(--muted); }

.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 4px; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; flex: none; min-height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-weight: 600; font-size: 14px; cursor: pointer;
}
.chip.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { font-size: 12px; opacity: .65; }
.chip.off { opacity: .5; }

.options { display: grid; gap: 8px; }
.opt { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); cursor: pointer; }
.opt input { display: none; }
.opt .radio { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--faint); flex: none; margin-top: 2px; display: grid; place-items: center; }
.opt.on { border-color: var(--accent); background: var(--accent-soft); }
.opt.on .radio { border-color: var(--accent); }
.opt.on .radio::after { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.opt .t { font-weight: 650; } .opt .d { font-size: 13px; color: var(--muted); }
.opt.danger.on { border-color: var(--err); background: var(--err-soft); }
.opt.danger.on .radio { border-color: var(--err); } .opt.danger.on .radio::after { background: var(--err); }

details.more { margin-top: 8px; }
details.more > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; color: var(--muted); font-weight: 600; font-size: 14px; padding: 12px 0 0; }
details.more > summary::-webkit-details-marker { display: none; }
details.more > summary svg { transition: transform .2s; width: 18px; height: 18px; }
details.more[open] > summary svg { transform: rotate(90deg); }

.sticky-cta { position: sticky; bottom: 0; padding: 16px 0 calc(var(--safe-b) + 12px); margin-top: 10px; background: linear-gradient(transparent, var(--bg) 35%); }

/* ---------- cards & lists ---------- */
.section-h { display: flex; align-items: center; gap: 8px; margin: 22px 2px 10px; font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.section-h:first-child { margin-top: 6px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
a.card { display: block; color: var(--text); transition: transform .08s, border-color .15s; }
a.card:active { transform: scale(.99); }
a.card:hover { border-color: color-mix(in srgb, var(--accent) 35%, var(--border)); }
.item-title { font-weight: 650; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 8px; font-size: 13px; color: var(--muted); }
.item-meta > span { display: inline-flex; align-items: center; gap: 5px; }
.item-meta svg { width: 14px; height: 14px; }
.item-top { display: flex; gap: 10px; align-items: flex-start; }
.item-top .item-title { flex: 1; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 8px; background: var(--surface2); color: var(--muted); font-size: 12.5px; font-weight: 650; white-space: nowrap; }
.tag svg { width: 13px; height: 13px; }

.status { display: inline-flex; align-items: center; gap: 6px; flex: none; height: 26px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 700; background: var(--surface2); color: var(--muted); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.running { background: var(--info-soft); color: var(--info); }
.status.running::before { animation: pulse 1.2s infinite; }
.status.done { background: var(--ok-soft); color: var(--ok); }
.status.error, .status.lost { background: var(--err-soft); color: var(--err); }
.status.limited, .status.stopped { background: var(--warn-soft); color: var(--warn); }
@keyframes pulse { 50% { opacity: .25; transform: scale(.7); } }

.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--faint); flex: none; }
.dot.on { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 22%, transparent); }

.empty { text-align: center; color: var(--muted); padding: 56px 20px; }
.empty .big { display: grid; place-items: center; width: 64px; height: 64px; margin: 0 auto 14px; border-radius: 20px; background: var(--surface2); color: var(--faint); }
.empty .big svg { width: 30px; height: 30px; }
.empty h3 { margin: 0 0 6px; color: var(--text); font-size: 17px; }
.empty p { margin: 0 0 18px; }

.skel { height: 82px; border-radius: var(--radius); background: linear-gradient(90deg, var(--surface2), var(--surface3), var(--surface2)); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

.notice { display: flex; gap: 10px; padding: 12px 14px; border-radius: 14px; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; white-space: pre-wrap; }
.notice svg { margin-top: 1px; }
.notice.warn { background: var(--warn-soft); color: var(--warn); }
.notice.err { background: var(--err-soft); color: var(--err); }
.notice.info { background: var(--info-soft); color: var(--info); }
.notice > div { color: var(--text); }

/* ---------- machines ---------- */
.m-head { display: flex; align-items: center; gap: 12px; }
.m-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; background: var(--surface2); color: var(--muted); flex: none; }
.m-ic.on { background: var(--ok-soft); color: var(--ok); }
.m-name { font-weight: 700; font-size: 16px; }
.m-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 14px; }
.m-stat { background: var(--surface2); border-radius: 12px; padding: 9px 11px; min-width: 0; }
.m-stat b { display: block; font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .m-stat span { font-size: 12px; color: var(--muted); }
.proj-grid { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.proj { font-family: var(--mono); font-size: 12.5px; padding: 7px 10px; border-radius: 9px; background: var(--surface2); cursor: pointer; border: 1px dashed transparent; }
.proj.off { opacity: .5; text-decoration: line-through; border-color: var(--border); background: transparent; }
details.projs > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 6px; margin-top: 14px; color: var(--muted); font-weight: 600; font-size: 14px; }
details.projs > summary::-webkit-details-marker { display: none; }
details.projs > summary svg { width: 18px; height: 18px; transition: transform .2s; }
details.projs[open] > summary svg { transform: rotate(90deg); }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; gap: 12px; }
.meta-strip { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.msg-user { align-self: flex-end; max-width: 88%; background: var(--accent-soft); color: var(--text); border-radius: 20px 20px 6px 20px; padding: 11px 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-ai { overflow-wrap: anywhere; line-height: 1.6; }
.msg-ai p { margin: 0 0 10px; } .msg-ai p:last-child { margin-bottom: 0; }
.msg-ai ul, .msg-ai ol { margin: 4px 0 10px; padding-left: 22px; } .msg-ai li { margin: 3px 0; }
.msg-ai h4 { margin: 14px 0 6px; font-size: 15.5px; }
code { font-family: var(--mono); font-size: .86em; background: var(--code); padding: 2px 6px; border-radius: 6px; overflow-wrap: anywhere; }
pre { font-family: var(--mono); font-size: 12.5px; line-height: 1.5; background: var(--code); border: 1px solid var(--border); border-radius: 12px; padding: 11px 13px; overflow: auto; margin: 8px 0; white-space: pre; max-height: 420px; }
pre code { background: none; padding: 0; font-size: inherit; }
.tbl { overflow-x: auto; margin: 8px 0 12px; border: 1px solid var(--border); border-radius: 12px; }
.tbl table { border-collapse: collapse; font-size: 13.5px; min-width: 100%; }
.tbl th, .tbl td { border-bottom: 1px solid var(--border); padding: 8px 11px; text-align: left; vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl th { background: var(--surface2); font-weight: 650; white-space: nowrap; }

.steps { display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); overflow: hidden; }
details.tool + details.tool { border-top: 1px solid var(--border); }
details.tool > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 8px 12px; font-size: 14px; }
details.tool > summary::-webkit-details-marker { display: none; }
details.tool > summary .ti { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 8px; background: var(--surface2); color: var(--muted); flex: none; }
details.tool > summary .ti svg { width: 16px; height: 16px; }
details.tool > summary .nm { font-weight: 650; flex: none; }
details.tool > summary .arg { font-family: var(--mono); font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; flex: 1; }
details.tool > summary .st { flex: none; display: grid; place-items: center; width: 20px; color: var(--faint); }
details.tool > summary .st svg { width: 16px; height: 16px; }
details.tool.ok > summary .st { color: var(--ok); }
details.tool.err > summary .st { color: var(--err); }
details.tool.err > summary .ti { background: var(--err-soft); color: var(--err); }
.spin { width: 14px; height: 14px; border: 2px solid var(--border); border-top-color: var(--info); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
details.tool > .body { padding: 0 12px 12px; }
details.tool > .body .path { font-size: 12.5px; color: var(--muted); font-family: var(--mono); overflow-wrap: anywhere; }
.diff { font-family: var(--mono); font-size: 12.5px; border: 1px solid var(--border); border-radius: 12px; overflow: auto; margin: 6px 0; max-height: 420px; }
.diff div { white-space: pre; padding: 0 10px; line-height: 1.55; }
.diff .d { background: var(--del); } .diff .a { background: var(--add); }
.todos { list-style: none; padding: 0; margin: 0; display: grid; gap: 7px; font-size: 14px; }
.todos li { display: flex; gap: 9px; align-items: flex-start; }
.todos .box { width: 18px; height: 18px; border-radius: 6px; border: 2px solid var(--faint); flex: none; margin-top: 2px; display: grid; place-items: center; }
.todos .completed .box { background: var(--ok); border-color: var(--ok); color: #fff; }
.todos .completed span { color: var(--muted); text-decoration: line-through; }
.todos .in_progress .box { border-color: var(--info); }
.todos .in_progress .box::after { content: ""; width: 8px; height: 8px; border-radius: 2px; background: var(--info); }
.todos .box svg { width: 12px; height: 12px; stroke-width: 3; }
.todo-card { border: 1px solid var(--border); border-radius: 14px; padding: 12px 14px; background: var(--surface); }
.todo-card .h { font-size: 12.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-bottom: 8px; }

.sys { font-size: 12.5px; color: var(--faint); text-align: center; padding: 2px 0; }
.result { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); padding: 10px 14px; border-radius: 12px; background: var(--ok-soft); }
.result svg { color: var(--ok); width: 18px; height: 18px; }
.result.bad { background: var(--err-soft); } .result.bad svg { color: var(--err); }
.result.warn { background: var(--warn-soft); } .result.warn svg { color: var(--warn); }
.working { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; padding: 4px 2px; }
.dots { display: inline-flex; gap: 4px; }
.dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: bounce 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: .15s; } .dots i:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }
.divider { display: flex; align-items: center; gap: 10px; color: var(--faint); font-size: 12px; margin: 6px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; padding: 8px 12px calc(var(--safe-b) + 10px);
  background: linear-gradient(transparent, var(--bg) 30%);
}
@media (min-width: 900px) { .composer { left: 240px; } }
.composer form { max-width: 820px; margin: 0 auto; display: flex; align-items: flex-end; gap: 8px; background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 5px 5px 5px 16px; box-shadow: var(--shadow); }
.composer form:focus-within { border-color: var(--accent); }
.composer textarea { border: 0; padding: 9px 0; min-height: 42px; max-height: 40dvh; height: 42px; background: none; box-shadow: none !important; }
.composer .send { width: 42px; height: 42px; border-radius: 50%; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; flex: none; cursor: pointer; }
.composer .send:disabled { background: var(--surface3); color: var(--faint); }
.composer .stopb { background: var(--err); }
.composer .hint-line { max-width: 820px; margin: 0 auto 6px; font-size: 12.5px; color: var(--muted); text-align: center; }
.jump { position: fixed; right: 16px; bottom: calc(var(--safe-b) + 84px); z-index: 24; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); display: grid; place-items: center; cursor: pointer; color: var(--text); }

/* ---------- sheet & toast ---------- */
.sheet-bg { position: fixed; inset: 0; z-index: 50; background: rgba(15, 12, 8, .45); animation: fade .2s; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 51; max-height: 88dvh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 22px 22px 0 0; padding: 8px 16px calc(var(--safe-b) + 16px); animation: up .25s cubic-bezier(.2, .8, .2, 1);
}
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--surface3); margin: 2px auto 12px; flex: none; }
.sheet h3 { margin: 0 0 12px; font-size: 18px; }
.sheet .scroll { overflow-y: auto; margin: 10px -16px 0; padding: 0 16px; overscroll-behavior: contain; }
@media (min-width: 700px) { .sheet { left: 50%; right: auto; bottom: auto; top: 50%; transform: translate(-50%, -50%); width: 480px; border-radius: 22px; animation: fade .2s; padding-bottom: 16px; } }
@keyframes up { from { transform: translateY(100%); } }
@keyframes fade { from { opacity: 0; } }
.pick-item { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 8px 2px; border: 0; border-bottom: 1px solid var(--border); background: none; text-align: left; cursor: pointer; width: 100%; }
.pick-item:last-child { border-bottom: 0; }
.pick-item .grow b { font-weight: 600; } .pick-item .grow div { font-size: 12.5px; color: var(--muted); }
.pick-item .chk { color: var(--accent); }
.pick-group { font-size: 12px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; padding: 14px 2px 4px; }
#toasts { position: fixed; left: 0; right: 0; top: calc(var(--safe-t) + 10px); z-index: 60; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { max-width: calc(100% - 32px); padding: 11px 16px; border-radius: 14px; background: var(--text); color: var(--bg); font-size: 14px; font-weight: 550; box-shadow: var(--shadow); animation: drop .25s; }
.toast.err { background: var(--err); color: #fff; }
@keyframes drop { from { transform: translateY(-20px); opacity: 0; } }

/* ---------- login ---------- */
.login { max-width: 380px; margin: 8dvh auto 0; text-align: center; }
.login img { width: 64px; height: 64px; margin-bottom: 14px; }
.login h1 { margin: 0 0 6px; font-size: 24px; }
.login p { color: var(--muted); margin: 0 0 22px; font-size: 14px; }
.login form { display: grid; gap: 12px; }
.status.open { background: var(--surface2); color: var(--ok); }

/* ---------- M1 sign-in (theo SSO-M1.md mục 8) ---------- */
.m1-signin {
  --m1-h: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  height: var(--m1-h); padding: 0 18px 0 12px; border-radius: 10px; border: 1px solid transparent;
  font-family: inherit; font-size: 15px; font-weight: 600; line-height: 1;
  text-decoration: none; cursor: pointer; white-space: nowrap; transition: background-color .13s ease, border-color .13s ease;
}
.m1-signin svg { width: calc(var(--m1-h) * .5); height: calc(var(--m1-h) * .5); flex: none; display: block; }
.m1-signin:active { transform: translateY(1px); }
.m1-signin:focus-visible { outline: 3px solid #6E7CFF; outline-offset: 2px; }
.m1-signin.dark { background: #12151F; color: #FFF; border-color: #12151F; }
.m1-signin.dark:hover { background: #1D2233; }
.m1-signin.light { background: #FFF; color: #12151F; border-color: #D5DAE5; }
.m1-signin.light:hover { background: #F4F6FA; border-color: #B9C1D2; }
@media (prefers-reduced-motion: reduce) { .m1-signin { transition: none; } }
.token-login { text-align: left; margin-top: 18px; }
.token-login > summary { justify-content: center; }
.av { display: inline-grid; place-items: center; border-radius: 50%; object-fit: cover; flex: none; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; }
.user-chip { display: flex; align-items: center; gap: 10px; min-width: 0; }
#sideUser .user-chip { padding: 8px 12px; }

/* ---------- pins ---------- */
svg.pinned { color: #d9a400; fill: #f2c94c; width: 15px; height: 15px; }
.star { display: grid; place-items: center; width: 36px; height: 36px; border: 0; background: none; color: var(--faint); cursor: pointer; flex: none; border-radius: 10px; }
.star svg { width: 19px; height: 19px; }
.star.on { color: #d9a400; } .star.on svg { fill: #f2c94c; }
.star:active { background: var(--surface2); }
.pick-item .star { margin-left: 2px; }
.proj { display: inline-flex; align-items: center; gap: 2px; padding: 0 10px 0 0; }
.proj .star { width: 28px; height: 30px; } .proj .star svg { width: 14px; height: 14px; }
.proj [data-proj] { padding: 7px 0; }
.proj.pin { background: color-mix(in srgb, #f2c94c 18%, var(--surface2)); }

/* ---------- usage ---------- */
.usage-row { display: grid; gap: 10px; margin-bottom: 14px; }
.card.usage { padding: 12px 14px; }
.ubars { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
.ubar .row { font-size: 13px; color: var(--muted); } .ubar b { color: var(--text); font-size: 15px; }
.ubar .track { height: 7px; border-radius: 4px; background: var(--surface2); overflow: hidden; margin: 5px 0 3px; }
.ubar .track i { display: block; height: 100%; border-radius: 4px; background: var(--ok); transition: width .4s; }
.ubar.mid .track i { background: var(--warn); } .ubar.hi .track i { background: var(--err); }
.ubar.hi b { color: var(--err); }
.icon-btn.sm { width: 34px; height: 34px; color: var(--muted); }
.icon-btn.spinning svg { animation: spin .9s linear infinite; }
.tag.ctx.mid { background: var(--warn-soft); color: var(--warn); }
.tag.ctx.hi { background: var(--err-soft); color: var(--err); }

/* ---------- model chip trong ô chat ---------- */
.comp-bar { max-width: 820px; margin: 0 auto 6px; display: flex; align-items: center; gap: 8px; min-height: 0; }
.comp-bar .hint-line { margin: 0; flex: 1; text-align: right; }
.mini-chip { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 10px 0 9px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.mini-chip svg { width: 14px; height: 14px; }
.mini-chip svg:last-child { width: 12px; height: 12px; transform: rotate(90deg); }

/* ---------- thanh thông tin trên ô chat ---------- */
.comp-bar { max-width: 820px; margin: 0 auto 6px; display: flex; align-items: center; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.comp-bar::-webkit-scrollbar { display: none; }
.composer .hint-line { max-width: 820px; margin: 0 auto 6px; font-size: 12.5px; color: var(--muted); text-align: left; padding: 0 4px; }
.composer .hint-line.warn { color: var(--warn); }
.mini-chip { display: inline-flex; align-items: center; gap: 5px; flex: none; height: 30px; padding: 0 10px 0 8px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--muted); font-size: 13px; font-weight: 650; cursor: pointer; white-space: nowrap; }
.mini-chip svg { width: 15px; height: 15px; }
.mini-chip svg.caret { width: 12px; height: 12px; transform: rotate(90deg); margin-left: -1px; }
.mini-chip.mid { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 40%, var(--border)); }
.mini-chip.hi { color: var(--err); border-color: color-mix(in srgb, var(--err) 45%, var(--border)); background: var(--err-soft); }
svg.ring { width: 16px; height: 16px; transform: rotate(-90deg); }
svg.ring circle { fill: none; stroke-width: 2.6; }
svg.ring .bg { stroke: var(--surface3); }
svg.ring .fg { stroke: currentColor; stroke-linecap: round; }
.mini-chip:not(.mid):not(.hi) svg.ring .fg { stroke: var(--ok); }
.kv-list { display: flex; flex-direction: column; }
.kv { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; border-bottom: 1px solid var(--border); font-size: 14.5px; }
.kv span { color: var(--muted); } .kv b { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.copy-row { display: flex; align-items: center; gap: 8px; background: var(--code); border: 1px solid var(--border); border-radius: 12px; padding: 8px 8px 8px 12px; }
.copy-row code { flex: 1; min-width: 0; background: none; padding: 0; font-size: 12.5px; overflow-x: auto; white-space: nowrap; }
.appbar .status { height: 24px; font-size: 12px; }
