/* Better Claude RC — warm terminal palette, mono = machine, sans = conversation */

:root {
  --bg: #141210;
  --surface: #1e1b18;
  --surface2: #28241f;
  --surface3: #322d27;
  --border: #362f28;
  --text: #ede6de;
  --dim: #a2968a;
  --faint: #6e645a;
  --accent: #e8825e;          /* claude terracotta */
  --accent-soft: #3a2a22;
  --ok: #8fb573;
  --warn: #e0b054;
  --err: #e05d52;
  --user-bubble: #33261f;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --radius: 12px;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --kb: 0px;
}
@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f1ea;
    --surface: #fffdf9;
    --surface2: #f0e9e0;
    --surface3: #e7ddd1;
    --border: #ddd2c4;
    --text: #2a241e;
    --dim: #77695c;
    --faint: #a5988a;
    --accent: #c25e3a;
    --accent-soft: #f4ded3;
    --ok: #5c8a41;
    --warn: #a97a1d;
    --err: #c03d33;
    --user-bubble: #f1e2d7;
  }
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; }
body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  height: 100dvh;
  overflow: hidden;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#app { display: flex; flex-direction: column; height: 100dvh; }
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); }
::selection { background: var(--accent-soft); }

/* ---------- top bar ---------- */
#topbar {
  padding: calc(var(--sat) + 8px) 14px 8px;
  display: flex; align-items: center; gap: 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  min-height: calc(var(--sat) + 48px);
  flex: none;
}
.tb-title {
  font-family: var(--mono);
  font-size: 15px; font-weight: 600;
  display: flex; align-items: center; gap: 8px;
  min-width: 0; flex: 1;
}
.tb-title .crumb { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-title .prompt-glyph { color: var(--accent); font-weight: 700; }
.tb-sub { font-family: var(--mono); font-size: 11px; color: var(--dim); }
.tb-btn {
  font-size: 20px; padding: 6px 10px; border-radius: 9px; color: var(--dim);
  flex: none; line-height: 1;
}
.tb-btn:active { background: var(--surface2); }
.tb-btn.menu { color: var(--accent); font-family: var(--mono); font-weight: 700; font-size: 19px; padding: 8px 12px; }
.tb-chips { display: flex; gap: 6px; flex: none; align-items: center; }
.tb-spacer { flex: 1; }
.tb-btn.tb-text { font-family: var(--mono); font-size: 12px; color: var(--dim); }

/* Safari-style tab-count button */
.tabs-btn { padding: 5px 8px; }
.tabs-count {
  display: flex; align-items: center; justify-content: center;
  min-width: 25px; height: 25px; padding: 0 5px;
  border: 2px solid var(--dim); border-radius: 8px;
  font-family: var(--mono); font-size: 12.5px; font-weight: 700; color: var(--dim);
}
.tabs-btn:active .tabs-count { border-color: var(--accent); color: var(--accent); }

.chip {
  font-family: var(--mono); font-size: 11px;
  padding: 3px 8px; border-radius: 99px;
  background: var(--surface2); color: var(--dim);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.chip.accent { color: var(--accent); border-color: var(--accent-soft); }

/* ---------- main view ---------- */
#view { flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; }
.pad { padding: 14px; }

.eyebrow {
  font-family: var(--mono); font-size: 10.5px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.14em; color: var(--faint);
  margin: 18px 2px 8px;
}
.eyebrow:first-child { margin-top: 4px; }

/* ---------- session cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.s-card { display: block; width: 100%; text-align: left; padding: 14px 16px; }
.s-card:active { background: var(--surface2); }
.s-card .row1 { display: flex; align-items: center; gap: 8px; }
.s-card .title {
  font-weight: 600; font-size: 16px; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.s-card .proj { font-family: var(--mono); font-size: 12px; color: var(--dim); margin-top: 2px; }
.s-card .menu-btn { color: var(--faint); font-size: 17px; padding: 2px 6px; flex: none; }

.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--faint); }
.dot.working { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.dot.awaiting { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.dot.compacting { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.dot.starting { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }
.dot.idle { background: var(--ok); }
.dot.error { background: var(--err); }
.dot.detached { background: var(--faint); }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) {
  .dot, .caret { animation: none !important; }
}

/* the signature: live status ticker */
.ticker {
  font-family: var(--mono); font-size: 12px; color: var(--dim);
  margin-top: 6px; display: flex; gap: 7px; align-items: baseline;
  overflow: hidden; white-space: nowrap;
}
.ticker .caret { color: var(--accent); font-weight: 700; animation: blink 1.1s step-end infinite; }
.ticker.quiet .caret { animation: none; color: var(--faint); }
.ticker .t-text { overflow: hidden; text-overflow: ellipsis; }
@keyframes blink { 50% { opacity: 0.15; } }

/* last message preview (quiet cards) */
.s-card .last-msg { display: flex; gap: 8px; margin-top: 7px; align-items: baseline; }
.s-card .lm-who {
  flex: none; font-family: var(--mono); font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.1em; color: var(--faint);
}
.s-card .last-msg.user .lm-who { color: var(--accent); }
.s-card .lm-text {
  min-width: 0; font-size: 13px; line-height: 1.45; color: var(--dim);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}

.s-card .meta-row {
  display: flex; gap: 10px; margin-top: 8px;
  font-family: var(--mono); font-size: 11px; color: var(--faint);
}
.s-card .meta-row .active { color: var(--accent); font-weight: 700; }
.s-card .meta-row .error { color: var(--err); font-weight: 700; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--sab) + 20px);
  width: 54px; height: 54px; border-radius: 18px;
  background: var(--accent); color: #fff;
  font-size: 28px; line-height: 1;
  box-shadow: 0 6px 20px rgba(0,0,0,0.35);
  display: flex; align-items: center; justify-content: center;
  z-index: 20;
}
.fab:active { transform: scale(0.94); }

.empty {
  text-align: center; color: var(--dim); padding: 48px 24px;
  font-size: 14px; line-height: 1.6;
}
.empty .glyph { font-family: var(--mono); font-size: 30px; color: var(--faint); display: block; margin-bottom: 10px; }

/* ---------- tabs view (open-session switcher) ---------- */
.tabs-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tab-card {
  display: flex; flex-direction: column; gap: 6px; text-align: left;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; padding: 11px 12px;
  min-height: 128px; min-width: 0;
}
.tab-card:active { background: var(--surface2); }
.tab-card.on { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.tab-card .tc-head { display: flex; align-items: center; gap: 7px; min-width: 0; }
.tab-card .tc-title {
  flex: 1; min-width: 0; font-weight: 600; font-size: 13.5px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tab-card .tc-close {
  flex: none; width: 24px; height: 24px; margin: -3px -5px -3px 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--surface2); color: var(--dim); font-size: 11px;
}
.tab-card .tc-close:active { background: var(--surface3); color: var(--text); }
.tab-card .tc-proj {
  font-family: var(--mono); font-size: 10.5px; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tab-card .tc-body {
  flex: 1; font-size: 12.5px; line-height: 1.45; color: var(--dim);
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.tab-card .tc-body.busy { font-family: var(--mono); font-size: 11.5px; color: var(--accent); }
.tab-card .tc-meta { display: flex; gap: 8px; font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.tab-card .tc-meta .active { color: var(--accent); font-weight: 700; }

/* ---------- drawer (left navigation panel) ---------- */
#drawer-root:empty { display: none; }
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(0,0,0,0.5);
  animation: fadein 0.15s ease;
}
.drawer {
  position: absolute; top: 0; bottom: 0; left: 0;
  width: min(84vw, 320px);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: calc(var(--sat) + 14px) 12px calc(var(--sab) + 14px);
  display: flex; flex-direction: column;
  animation: slidein 0.2s ease;
}
@keyframes slidein { from { transform: translateX(-40px); opacity: 0.5; } }
@media (prefers-reduced-motion: reduce) { .drawer, .drawer-backdrop, .qo-panel, .qo-backdrop { animation: none; } }
.drawer-head {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 16px; font-weight: 700;
  padding: 6px 10px 16px;
}
.drawer-head .glyph { color: var(--accent); }
.drawer-nav { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.nav-item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  padding: 15px 12px; border-radius: 12px;
  font-size: 16.5px; font-weight: 600;
}
.nav-item:active { background: var(--surface2); }
.nav-item.on { background: var(--accent-soft); color: var(--accent); }
.nav-item .n-icon { width: 26px; text-align: center; font-size: 17px; color: var(--dim); flex: none; }
.nav-item.on .n-icon { color: var(--accent); }
.nav-item .n-label { flex: 1; }
.nav-item .n-count { font-family: var(--mono); font-size: 11.5px; color: var(--faint); }
.drawer-foot {
  border-top: 1px solid var(--border); padding: 12px 10px 0;
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--mono); font-size: 11.5px;
}
.drawer-foot .conn-ok { color: var(--ok); }
.drawer-foot .conn-bad { color: var(--warn); }
.drawer-foot .foot-btn { color: var(--dim); font-family: var(--mono); font-size: 11.5px; padding: 4px 6px; }
.drawer-foot .foot-btn:active { color: var(--text); }

/* ---------- home ---------- */
.home-h {
  font-size: 26px; font-weight: 700; letter-spacing: -0.02em;
  margin: 20px 2px 12px;
}
.home-empty { color: var(--dim); font-size: 14.5px; line-height: 1.5; }

.carousel {
  display: flex; gap: 10px;
  margin: 0 -14px; padding: 2px 14px 8px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
}
.carousel::-webkit-scrollbar { display: none; }
.carousel .s-card { flex: 0 0 min(86%, 360px); scroll-snap-align: center; margin-bottom: 2px; }

/* VS Code style recent-project rows */
.vs-list { display: flex; flex-direction: column; }
.vs-row {
  display: flex; align-items: baseline; gap: 12px;
  width: 100%; text-align: left;
  padding: 10px 2px; min-width: 0;
}
.vs-row .vs-name { color: var(--accent); font-size: 17px; font-weight: 500; white-space: nowrap; }
.vs-row .vs-path {
  color: var(--dim); font-family: var(--mono); font-size: 13px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.vs-row:active .vs-name { text-decoration: underline; }

/* ---------- big list items ---------- */
.item {
  display: flex; align-items: center; gap: 14px;
  width: 100%; text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 15px;
  margin-bottom: 10px;
}
.item:active { background: var(--surface2); }
.item-icon { flex: none; width: 28px; text-align: center; font-size: 19px; color: var(--dim); }
.item-main { flex: 1; min-width: 0; }
.item-title { font-size: 17px; font-weight: 600; display: flex; align-items: center; gap: 8px; min-width: 0; }
.item-title .item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.item-title.mono .item-name { font-family: var(--mono); font-size: 15.5px; }
.item-sub {
  font-size: 13.5px; color: var(--dim); margin-top: 4px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; word-break: break-word;
}
.item-side {
  flex: none; text-align: right;
  font-family: var(--mono); font-size: 11px; color: var(--faint); line-height: 1.6;
}
.item-list { padding-bottom: calc(var(--sab) + 20px); }

.search-input {
  width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 13px 15px;
  font-size: 16px; color: var(--text); outline: none;
  margin-bottom: 12px; -webkit-appearance: none;
}
.search-input:focus { border-color: var(--accent); }

/* ---------- quick-open (More… project search) ---------- */
.qo-backdrop {
  position: fixed; inset: 0; z-index: 70;
  background: rgba(0,0,0,0.55);
  animation: fadein 0.15s ease;
}
.qo-panel {
  margin: calc(var(--sat) + 12px) 12px 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  max-height: 72dvh;
  display: flex; flex-direction: column;
  animation: dropin 0.18s ease;
}
@keyframes dropin { from { transform: translateY(-16px); opacity: 0.5; } }
.qo-panel > div { display: flex; flex-direction: column; min-height: 0; }
.qo-panel .item-list { overflow-y: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }

/* ---------- key/value rows (sheets) ---------- */
.kv {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 9px 0; border-bottom: 1px solid var(--border);
  font-size: 13.5px;
}
.kv .kv-k { color: var(--dim); flex: none; }
.kv .kv-v { font-family: var(--mono); font-size: 12.5px; text-align: right; word-break: break-all; }
.lib-detail-desc { font-size: 14.5px; line-height: 1.55; margin-bottom: 12px; }

/* ---------- chat ---------- */
#chat-wrap { display: flex; flex-direction: column; height: 100%; }
#msgs {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 12px 12px 6px; -webkit-overflow-scrolling: touch;
}
.msg { margin-bottom: 12px; max-width: 100%; }

.m-user {
  background: var(--user-bubble);
  border-radius: 16px 16px 4px 16px;
  padding: 9px 13px;
  margin-left: 15%;
  font-size: 15px; line-height: 1.45;
  white-space: pre-wrap; word-break: break-word;
}
.m-user.external::after {
  content: "⌁ sent from terminal";
  display: block; margin-top: 5px;
  font-size: 10.5px; letter-spacing: 0.03em;
  color: var(--dim, #8a8578); opacity: 0.8;
}
.m-assist { font-size: 15px; line-height: 1.55; word-break: break-word; }
.m-assist.streaming { white-space: pre-wrap; }
.m-assist p { margin: 0 0 8px; }
.m-assist p:last-child { margin-bottom: 0; }
.m-assist h1, .m-assist h2, .m-assist h3 { margin: 14px 0 6px; font-size: 1.05em; }
.m-assist h1 { font-size: 1.15em; }
.m-assist ul, .m-assist ol { margin: 4px 0 8px 22px; }
.m-assist li { margin-bottom: 3px; }
.m-assist code {
  font-family: var(--mono); font-size: 0.86em;
  background: var(--surface2); border-radius: 4px; padding: 1px 5px;
}
.m-assist pre {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; margin: 8px 0;
  overflow-x: auto; font-size: 12.5px; line-height: 1.5;
}
.m-assist pre code { background: none; padding: 0; font-size: inherit; }
.m-assist blockquote { border-left: 3px solid var(--border); padding-left: 10px; color: var(--dim); margin: 8px 0; }
.m-assist table { border-collapse: collapse; margin: 8px 0; font-size: 13px; display: block; overflow-x: auto; }
.m-assist th, .m-assist td { border: 1px solid var(--border); padding: 5px 9px; text-align: left; }
.m-assist th { background: var(--surface2); font-weight: 600; }
.m-assist hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* thinking */
.m-think {
  border-left: 2px solid var(--border);
  padding: 2px 0 2px 10px;
  margin: 6px 0 10px;
}
.m-think summary {
  font-family: var(--mono); font-size: 11px; color: var(--faint);
  cursor: pointer; list-style: none; user-select: none;
}
.m-think summary::-webkit-details-marker { display: none; }
.m-think .think-body {
  color: var(--dim); font-size: 13px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word; margin-top: 6px;
}

/* tool cards */
.tool-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 8px 0;
  overflow: hidden;
  font-size: 13px;
}
.tool-head {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 11px;
  font-family: var(--mono); font-size: 12px;
  width: 100%; text-align: left;
}
.tool-head .t-icon { flex: none; font-size: 13px; }
.tool-head .t-name { font-weight: 600; flex: none; }
.tool-head .t-sum { color: var(--dim); flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-head .t-state { flex: none; font-size: 12px; color: var(--faint); }
.tool-head .t-state.ok { color: var(--ok); }
.tool-head .t-state.err { color: var(--err); }
.tool-head .t-state.spin { color: var(--accent); animation: pulse 1.1s infinite; }
.tool-body { border-top: 1px solid var(--border); padding: 9px 11px; display: none; }
.tool-card.open .tool-body { display: block; }
.tool-body pre {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
  max-height: 300px; overflow-y: auto;
}
.tool-body .out-label { font-family: var(--mono); font-size: 10px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.1em; margin: 8px 0 4px; }
.tool-body .out-label:first-child { margin-top: 0; }
.diff-old { color: var(--err); }
.diff-new { color: var(--ok); }
.todo-list { list-style: none; margin: 0; }
.todo-list li { padding: 2px 0; font-size: 13px; }
.todo-list .td-done { color: var(--dim); text-decoration: line-through; }
.todo-list .td-active { color: var(--accent); }
.nested-tools { margin: 4px 0 4px 14px; border-left: 2px solid var(--border); padding-left: 8px; }

/* action cards: permission / question / plan */
.action-card {
  background: var(--surface);
  border: 1px solid var(--warn);
  border-radius: 12px;
  padding: 12px 13px;
  margin: 10px 0;
}
.action-card.resolved { border-color: var(--border); opacity: 0.75; }
.action-card .a-head {
  display: flex; gap: 8px; align-items: center;
  font-family: var(--mono); font-size: 11px; color: var(--warn);
  text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 8px;
}
.action-card.resolved .a-head { color: var(--faint); }
.action-card .a-title { font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.action-card .a-desc { font-size: 13px; color: var(--dim); margin-bottom: 8px; }
.action-card pre {
  font-family: var(--mono); font-size: 11.5px; line-height: 1.5;
  background: var(--surface2); border-radius: 8px; padding: 8px 10px;
  margin: 6px 0 10px; white-space: pre-wrap; word-break: break-word;
  max-height: 220px; overflow-y: auto;
}
.a-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  padding: 9px 15px; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  background: var(--surface2); border: 1px solid var(--border);
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--err); border-color: var(--err); }
.btn.small { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; }
.a-outcome { font-family: var(--mono); font-size: 12px; color: var(--dim); }

.q-option {
  display: block; width: 100%; text-align: left;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 12px; margin-bottom: 7px;
}
.q-option:active, .q-option.sel { border-color: var(--accent); background: var(--accent-soft); }
.q-option .q-label { font-weight: 600; font-size: 14px; }
.q-option .q-desc { font-size: 12px; color: var(--dim); margin-top: 2px; }
.q-other-input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; font-size: 14px; margin-bottom: 7px;
  color: var(--text); outline: none;
}

/* dividers and notices */
.divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--faint); font-family: var(--mono); font-size: 11px;
  margin: 16px 0;
}
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.notice { font-family: var(--mono); font-size: 12px; color: var(--dim); margin: 8px 0; white-space: pre-wrap; word-break: break-word; }
.notice.error { color: var(--err); }
.notice.warn { color: var(--warn); }
.turn-result {
  font-family: var(--mono); font-size: 10.5px; color: var(--faint);
  margin: 2px 0 14px; text-align: right;
}

/* status line + composer */
#status-line {
  flex: none;
  padding: 6px 14px;
  font-family: var(--mono); font-size: 12px; color: var(--dim);
  display: flex; gap: 8px; align-items: baseline;
  border-top: 1px solid var(--border);
  background: var(--bg);
  min-height: 28px;
}
#status-line .caret { color: var(--accent); font-weight: 700; animation: blink 1.1s step-end infinite; }
#status-line.quiet .caret { animation: none; color: var(--faint); }
#status-line .s-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#status-line .s-conn { color: var(--err); }

#composer {
  flex: none;
  display: flex; gap: 8px; align-items: flex-end;
  padding: 8px 12px calc(var(--sab) + 10px);
  background: var(--bg);
  padding-bottom: calc(max(var(--sab), var(--kb)) + 10px);
}
#composer .c-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 14px;
  font-size: 15px; line-height: 1.4;
  color: var(--text);
  resize: none; outline: none;
  max-height: 132px;
  min-height: 42px;
}
#composer .c-input:focus { border-color: var(--accent); }
.c-btn {
  width: 42px; height: 42px; border-radius: 50%;
  background: var(--surface2); border: 1px solid var(--border);
  font-size: 18px; flex: none;
  display: flex; align-items: center; justify-content: center;
  color: var(--dim);
}
.c-btn.send { background: var(--accent); border-color: var(--accent); color: #fff; }
.c-btn.stop { background: var(--err); border-color: var(--err); color: #fff; }
.c-btn:active { transform: scale(0.94); }
.c-btn:disabled { opacity: 0.4; }

/* mode strip above composer */
#mode-strip {
  flex: none; display: flex; gap: 6px; align-items: center;
  padding: 6px 14px 0;
  overflow-x: auto; scrollbar-width: none;
}
#mode-strip::-webkit-scrollbar { display: none; }

/* ---------- sheets ---------- */
#sheet-root:empty { display: none; }
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.55);
  display: flex; flex-direction: column; justify-content: flex-end;
  animation: fadein 0.15s ease;
}
@keyframes fadein { from { opacity: 0; } }
.sheet {
  background: var(--surface);
  border-radius: 18px 18px 0 0;
  padding: 10px 14px calc(var(--sab) + 16px);
  max-height: 82dvh;
  display: flex; flex-direction: column;
  animation: slideup 0.2s ease;
}
@keyframes slideup { from { transform: translateY(40px); opacity: 0.6; } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-backdrop { animation: none; } }
.sheet .grab { width: 38px; height: 4px; border-radius: 2px; background: var(--border); margin: 2px auto 12px; flex: none; }
.sheet .sheet-title { font-family: var(--mono); font-size: 13px; font-weight: 600; margin-bottom: 12px; }
.sheet .sheet-body { overflow-y: auto; -webkit-overflow-scrolling: touch; }
.sheet-item {
  display: flex; gap: 11px; align-items: center;
  width: 100%; text-align: left;
  padding: 12px 8px; font-size: 15px;
  border-bottom: 1px solid var(--border);
}
.sheet-item:last-child { border-bottom: none; }
.sheet-item:active { background: var(--surface2); }
.sheet-item .si-icon { width: 24px; text-align: center; flex: none; font-size: 16px; }
.sheet-item .si-main { flex: 1; min-width: 0; }
.sheet-item .si-sub { font-family: var(--mono); font-size: 11px; color: var(--dim); margin-top: 1px; }
.sheet-item.danger { color: var(--err); }
.sheet-item .si-check { color: var(--accent); flex: none; }
.sheet input[type="search"], .sheet input[type="text"] {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 10px; padding: 9px 12px; font-size: 15px; margin-bottom: 10px;
  color: var(--text); outline: none; -webkit-appearance: none;
}

/* ---------- scope badge ---------- */
.badge {
  font-family: var(--mono); font-size: 10px; text-transform: uppercase;
  letter-spacing: 0.08em; padding: 3px 7px; border-radius: 6px;
  background: var(--surface3); color: var(--dim); flex: none;
  max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.badge.project { color: var(--accent); }
.badge.plugin { color: var(--warn); }

/* ---------- context meter ---------- */
.ctx-bar { height: 4px; background: var(--surface3); border-radius: 2px; overflow: hidden; margin-top: 6px; }
.ctx-bar .fill { height: 100%; background: var(--ok); border-radius: 2px; transition: width 0.4s ease; }
.ctx-bar .fill.mid { background: var(--warn); }
.ctx-bar .fill.high { background: var(--err); }

/* ---------- login ---------- */
.login-box { max-width: 380px; margin: 16dvh auto 0; padding: 0 22px; text-align: center; }
.login-box .glyph { font-family: var(--mono); font-size: 44px; color: var(--accent); }
.login-box h1 { font-family: var(--mono); font-size: 19px; margin: 10px 0 4px; }
.login-box p { color: var(--dim); font-size: 13.5px; margin-bottom: 22px; line-height: 1.5; }
.login-box input {
  width: 100%; background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 12px 14px; font-size: 15px;
  font-family: var(--mono); color: var(--text); outline: none;
  text-align: center; margin-bottom: 12px;
}
.login-box input:focus { border-color: var(--accent); }
.login-box .btn { width: 100%; padding: 12px; }
.login-err { color: var(--err); font-size: 13px; margin-top: 10px; font-family: var(--mono); }

/* ---------- toasts ---------- */
#toast-root {
  position: fixed; top: calc(var(--sat) + 10px); left: 0; right: 0;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  z-index: 100; pointer-events: none;
}
.toast {
  background: var(--surface3); border: 1px solid var(--border);
  color: var(--text); font-size: 13px; font-family: var(--mono);
  padding: 9px 16px; border-radius: 99px;
  max-width: 86vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  animation: fadein 0.2s ease;
}
.toast.error { border-color: var(--err); color: var(--err); }

.conn-pill {
  font-family: var(--mono); font-size: 11px; color: var(--warn);
  text-align: center; padding: 4px; background: var(--surface);
  border-bottom: 1px solid var(--border);
}

/* ---------- true view (real claude TUI) ---------- */
/* Always dark: it's a terminal, and the TUI's ANSI palette assumes one. */
#term-wrap {
  display: flex; flex-direction: column;
  height: 100%; background: #141210;
}
#term-host { position: relative; flex: 1; min-height: 0; padding: 6px 0 0 8px; }
#term { height: 100%; }
#term .xterm { height: 100%; }
#term-overlay {
  position: absolute; inset: 0; z-index: 5;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; padding: 20px; text-align: center;
  background: rgba(13, 11, 9, 0.85);
  font-family: var(--mono); font-size: 13px; color: #ede6de;
}
#term-overlay.hidden { display: none; }
#term-overlay .term-actions { display: flex; gap: 10px; }
#term-overlay button {
  font-family: var(--mono); font-size: 13px; padding: 8px 16px;
  border: 1px solid #4a4038; border-radius: 9px;
  color: #ede6de; background: #28241f;
}
#term-overlay button:active { border-color: #e8825e; color: #e8825e; }
#term-keys {
  flex: none; display: flex; gap: 6px; overflow-x: auto;
  padding: 8px 10px calc(max(var(--sab), var(--kb)) + 8px);
  background: #1e1b18; border-top: 1px solid #362f28;
}
.term-key {
  font-family: var(--mono); font-size: 13px; color: #a2968a;
  border: 1px solid #362f28; background: #28241f; border-radius: 8px;
  padding: 7px 13px; flex: none; line-height: 1;
}
.term-key:active { color: #e8825e; border-color: #e8825e; }

/* ------------------------------------------------ platform: machine picker */
.machines { max-width: 520px; margin: 0 auto; }
.enroll-box { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.enroll-cmd {
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5;
  padding: 12px 14px; border-radius: 10px; word-break: break-all;
  user-select: all; -webkit-user-select: all;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--accent);
}

/* ------------------------------------------------ platform: pairing (M4) */
.pair-video {
  width: 100%; max-width: 320px; border-radius: 12px;
  border: 1px solid var(--border); margin: 0 auto 12px; display: block;
  background: #000;
}
.login-box .btn { margin-bottom: 10px; }
.login-box input#pair-code { font-family: var(--mono); font-size: 12px; }
