/* Terminal flavor, phone-first (R24): 44px targets, readable without zoom, keyboard- and notch-aware.
   Tokens come from the approved sketch, option C. */
:root {
  --bg: #eef0ee; --fg: #1d221f; --muted: #66706a; --line: #c4cbc6;
  --panel: #ffffff; --soft: #e3e8e4; --accent: #2f7a4f; --run: #a8641a; --warn: #b3261e;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tap: 44px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #141816; --fg: #dfe5e1; --muted: #8d978f; --line: #343c37; --panel: #1b201d; --soft: #252c28; --accent: #6cc28f; --run: #e0a25a; --warn: #f2756b; color-scheme: dark; }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { font: 15px/1.45 var(--mono); -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: none; border: 1px solid var(--line); border-radius: 8px; min-height: var(--tap); min-width: var(--tap); padding: 0 12px; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
input, textarea { font: inherit; color: inherit; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; min-height: var(--tap); padding: 8px 12px; width: 100%; }

#app {
  display: flex; flex-direction: column; height: 100dvh; background: var(--panel);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

#top { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-bottom: 1px solid var(--line); }
.session-name { flex: 1; text-align: left; font-weight: 600; border: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.icon-btn { border: 0; font-size: 20px; }
.text-btn { font-size: 14px; border: 1px solid var(--line); color: var(--accent); }

#tabs { display: flex; border-bottom: 1px solid var(--line); }
.tab { flex: 1; border: 0; border-radius: 0; color: var(--muted); border-bottom: 2px solid transparent; }
.tab[aria-selected="true"] { color: var(--fg); font-weight: 600; border-bottom-color: var(--accent); }

.nowline { display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 4px 12px; border-bottom: 1px solid var(--line); }
.nowline .dot::before { content: "●"; margin-right: 6px; }
.nowline .state { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; background: none; border: 0; text-align: left; padding: 0; }
.nowline .conn { font-size: 12px; color: var(--muted); white-space: nowrap; }
.nowline .conn.bad { color: var(--warn); }
.nowline.stale .state { opacity: .45; }
.nowline .stale-tag { font-size: 12px; color: var(--muted); }
.tone-run { color: var(--run); } .tone-think { color: var(--accent); } .tone-idle { color: var(--muted); } .tone-stop { color: var(--warn); }
.tone-wait { color: var(--bg); background: var(--run); padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.nowline .stop { border-color: var(--warn); color: var(--warn); margin-left: auto; }

main#content { flex: 1; min-height: 0; position: relative; }
.pane { position: absolute; inset: 0; overflow-y: auto; padding: 12px; overscroll-behavior: contain; }
.empty { color: var(--muted); text-align: center; padding: 32px 0; }

.steps { display: flex; flex-direction: column; gap: 6px; list-style: none; margin: 0; padding: 0; }
.steps li { padding: 6px 0; }
.steps .done { color: var(--muted); text-decoration: line-through; }
.steps .current { color: var(--run); font-weight: 600; }
.steps .pending { color: var(--fg); }
.steps .mark { display: inline-block; width: 1.4em; }

#composer { border-top: 1px solid var(--line); padding: 8px 12px; }

.overlay { position: absolute; inset: 0; z-index: 10; background: var(--panel); overflow-y: auto; padding: max(12px, env(safe-area-inset-top)) 12px 12px; }
.overlay h2 { margin: 0 0 12px; font-size: 16px; }
.overlay .bar { display: flex; gap: 8px; align-items: center; margin-bottom: 12px; }
.overlay .bar h2 { flex: 1; margin: 0; }
.sess { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; margin-bottom: 8px; padding: 8px 12px; min-height: 56px; }
.sess .name { font-weight: 600; }
.sess .folder { color: var(--muted); font-size: 13px; word-break: break-all; }
.sess .st { font-size: 13px; }
.sess.current { border-color: var(--accent); }
.sess.highlight { border-color: var(--run); background: var(--soft); }
.tone-dim { color: var(--muted); }
.big { width: 100%; min-height: 64px; font-size: 17px; border-color: var(--accent); color: var(--accent); }
.err { color: var(--warn); margin: 8px 0; }
.note { color: var(--muted); margin: 8px 0; }
.folders { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.folders button { text-align: left; word-break: break-all; }

.mirror { position: absolute; inset: 0; z-index: 20; background: #000; color: #ddd; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

.toast { position: absolute; left: 12px; right: 12px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 30; background: var(--fg); color: var(--bg); padding: 10px 14px; border-radius: 8px; text-align: center; }

/* chat (U9) */
.msg { margin: 0 0 12px; max-width: 92%; overflow-wrap: anywhere; }
.msg.user { margin-left: auto; background: var(--soft); padding: 8px 10px; border-radius: 10px; max-width: 85%; }
.msg.user .text { white-space: pre-wrap; }
.msg.user.pending { border: 1px dashed var(--line); }
.msg.user.failed { border-color: var(--warn); }
.msg .meta, .menu .how { color: var(--muted); font-size: 12px; margin-top: 4px; }
.msg.assistant p { margin: 0 0 8px; }
.msg.assistant h1, .msg.assistant h2, .msg.assistant h3, .msg.assistant h4, .msg.assistant h5, .msg.assistant h6 { font-size: 15px; margin: 12px 0 6px; }
.msg.assistant ul, .msg.assistant ol { margin: 0 0 8px; padding-left: 22px; }
.msg.assistant blockquote { margin: 0 0 8px; padding-left: 10px; border-left: 3px solid var(--line); color: var(--muted); }
.msg.assistant code { background: var(--soft); padding: 1px 4px; border-radius: 4px; }
.msg.assistant pre { background: var(--soft); padding: 8px 10px; border-radius: 8px; overflow-x: auto; margin: 0 0 8px; }
.msg.assistant pre code { background: none; padding: 0; white-space: pre; }
.msg.assistant a { color: var(--accent); }
.notice, .edge { color: var(--muted); font-size: 12px; text-align: center; margin: 8px 0; }
.tool { margin: 0 0 8px; }
.tool-head { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--line); border-radius: 0; color: var(--muted); font-size: 13px; min-height: var(--tap); padding: 4px 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-head.err { border-left-color: var(--warn); }
.tool-out { margin: 4px 0 0 3px; padding: 8px 10px; background: var(--soft); border-radius: 8px; overflow-x: auto; font-size: 13px; white-space: pre; }
.more { font-size: 13px; margin-top: 4px; }
.menu { border: 1px dashed var(--line); border-radius: 10px; padding: 10px; margin: 0 0 12px; }
.menu .head { color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.menu .q { margin-bottom: 8px; }
.menu .opts { display: flex; flex-wrap: wrap; gap: 8px; }
.menu .opt { border-color: var(--accent); color: var(--accent); }
.menu .opt.selected { background: var(--accent); color: var(--panel); }
.menu .opt.go { background: var(--accent); color: var(--panel); }
.menu .other { display: flex; gap: 8px; margin-top: 8px; }
.menu.closed { border-style: solid; color: var(--muted); }
.menu.quick { border: 0; padding: 0; }
.menu.quick .q { color: var(--muted); font-size: 13px; }
button.small { font-size: 13px; min-height: var(--tap); margin: 6px 6px 0 0; }
.jump { position: absolute; right: 12px; bottom: 12px; z-index: 5; background: var(--accent); color: var(--panel); border: 0; }
#composer .row { display: flex; gap: 8px; align-items: flex-end; }
#composer textarea { resize: none; flex: 1; line-height: 1.4; }
#composer .send { border-color: var(--accent); color: var(--accent); }
#composer .warn { color: var(--warn); font-size: 12px; margin-bottom: 4px; }
#composer .ac { max-height: 40vh; overflow-y: auto; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 6px; background: var(--panel); }
.ac-item { display: flex; flex-direction: column; align-items: flex-start; width: 100%; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; text-align: left; padding: 6px 12px; }
.ac-name { color: var(--accent); }
.ac-desc { color: var(--muted); font-size: 12px; }
.ac-empty { color: var(--muted); padding: 10px 12px; }

/* mirror (U10) */
.mirror-bar { display: flex; align-items: center; gap: 8px; padding: 4px 8px; border-bottom: 1px solid #333; }
.mirror-title { flex: 1; color: #ddd; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mirror-close { color: #ddd; border-color: #555; }
.mirror-screen { flex: 1; min-height: 0; overflow: auto; padding: 4px 6px; font: 13px/1.25 var(--mono); white-space: pre; background: #000; color: #d4d4d4; -webkit-overflow-scrolling: touch; }
.mirror-screen .cursor { background: #d4d4d4; color: #000; }
.mirror-probe { position: absolute; visibility: hidden; }
.mirror-notice { color: var(--warn); font-size: 12px; text-align: center; padding: 2px 0; background: #111; }
.mirror-keys { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding: 8px; background: #111; }
.mirror .mkey { min-height: 48px; color: #ddd; border-color: #555; background: #1c1c1c; }
.mirror-field { display: flex; gap: 6px; padding: 0 8px 8px; background: #111; }
.mirror-field input { min-width: 0; background: #1c1c1c; color: #ddd; border-color: #555; }
