:root {
  --bg: #0F1115; --bg2: #12151B; --surface: #171A21; --raised: #1D212A; --term: #0A0C10;
  --line: #262B35; --line2: #2E3442; --text: #E6E8EC; --muted: #9AA3B2; --dim: #8B94A3;
  --accent: #5B9DFF; --accent-text: #8DBBFF; --on-accent: #0B1220;
  --ok: #56D364; --warn: #F5B544; --bad: #FF7B72;
  --mono: ui-monospace, "JetBrains Mono", "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-text-size-adjust: 100%; }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
code { font-family: var(--mono); font-size: .9em; background: var(--raised); padding: 1px 5px; border-radius: 4px; }
h1 { margin: 0; font-size: 24px; font-weight: 700; letter-spacing: -.02em; }
h2 { margin: 0; font-size: 18px; }
.muted { color: var(--muted); } .small { font-size: 13px; } .block { display: block; } .grow { flex: 1; min-width: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; } .between { justify-content: space-between; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 500; }
input, select, textarea { min-height: 46px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line2); background: var(--term); font-size: 16px; color: var(--text); }
textarea { resize: vertical; line-height: 1.4; }
button { cursor: pointer; }
.primary { min-height: 48px; padding: 0 18px; border: 0; border-radius: 12px; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 16px; }
.primary:disabled { opacity: .5; }
.ghost { min-height: 40px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line2); background: transparent; }
.link { background: none; border: 0; color: var(--accent-text); padding: 8px 0; text-decoration: underline; }
.msg { color: var(--bad); min-height: 1em; margin: 0; }

.screen { height: 100dvh; display: flex; flex-direction: column; }
.center { align-items: center; justify-content: center; padding: 24px 20px; }
.login-card { width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 20px; }
.logo { width: 48px; height: 48px; border-radius: 12px; background: #1B2232; color: var(--accent-text); display: flex; align-items: center; justify-content: center; }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }
#view-boxes { padding: 16px 16px 24px; gap: 14px; }
.view-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.orch-card { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; border: 1px solid #2B3A57; background: #151C2B; text-align: left; }
.orch-icon { width: 40px; height: 40px; border-radius: 10px; background: #22304A; color: var(--accent-text); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.chev { color: var(--accent-text); font-size: 22px; }
.footer-note { margin: 4px 0 0; }

.box { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.box-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 14px; border-bottom: 1px solid var(--line); }
.dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--dim); }
.dot.running { background: var(--ok); } .dot.pending, .dot.stopping { background: var(--warn); }
.box-name { font-weight: 600; }
.icon-btn { width: 44px; height: 44px; border-radius: 10px; border: 1px solid var(--line2); background: var(--raised); font-size: 20px; flex-shrink: 0; }
.item { width: 100%; display: flex; flex-direction: column; gap: 3px; padding: 11px 14px; border: 0; border-top: 1px solid #20242D; background: transparent; text-align: left; }
.item:first-child { border-top: 0; }
.item-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.item-name { font-family: var(--mono); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip { padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: rgba(154,163,178,.16); color: #B4BCC8; }
.chip.working { background: rgba(91,157,255,.16); color: var(--accent-text); }
.chip.needs-you { background: rgba(245,165,36,.18); color: var(--warn); }
.chip.sleeping, .chip.empty, .chip.starting { background: rgba(154,163,178,.10); color: var(--muted); }
.box-note { margin: 0; padding: 11px 14px; color: var(--dim); font-size: 13px; }
.box-actions { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid #20242D; flex-wrap: wrap; }

.tabs-view { background: var(--term); }
.tab-strip { display: flex; gap: 6px; padding: 10px; overflow-x: auto; border-bottom: 1px solid var(--line); background: var(--bg); flex-shrink: 0; }
.tab { flex-shrink: 0; display: flex; align-items: center; height: 36px; border-radius: 9px; border: 1px solid var(--line); background: transparent; color: var(--muted); font-family: var(--mono); font-size: 12px; white-space: nowrap; overflow: hidden; }
.tab.active { background: #232838; color: var(--text); border-color: #4A5570; }
.tab .tab-open { height: 100%; padding: 0 4px 0 11px; border: 0; background: none; }
.tab .tab-x { height: 100%; width: 32px; border: 0; background: none; color: var(--dim); font-size: 16px; }
.tab-plus { flex-shrink: 0; width: 36px; height: 36px; border-radius: 9px; border: 1px dashed #3A4255; background: transparent; font-size: 18px; }
.terms { flex: 1; min-height: 0; position: relative; }
.term { position: absolute; inset: 0; padding: 6px 4px 0 8px; }
.term .xterm { height: 100%; }
.empty { padding: 24px 16px; margin: 0; }
.keys { display: flex; gap: 6px; padding: 8px; overflow-x: auto; border-top: 1px solid var(--line); background: var(--bg2); flex-shrink: 0; }
.keys button { flex-shrink: 0; min-width: 44px; height: 38px; padding: 0 9px; border-radius: 8px; border: 1px solid var(--line2); background: var(--raised); font-family: var(--mono); font-size: 13px; }
.keys button.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }

.orch-head { padding: 14px 16px 10px; border-bottom: 1px solid var(--line); align-items: center; }
.orch-log { flex: 1; min-height: 0; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.bubble { max-width: 88%; padding: 10px 12px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.bubble.you { align-self: flex-end; background: #2A4475; color: #EEF3FF; border-bottom-right-radius: 4px; }
.bubble.claude { align-self: flex-start; background: var(--raised); border-bottom-left-radius: 4px; }
.bubble.tool { align-self: flex-start; padding: 2px 4px; color: var(--dim); font-family: var(--mono); font-size: 12px; background: none; }
.bubble.error { align-self: stretch; background: rgba(255,123,114,.12); color: var(--bad); font-size: 13px; }
.typing { align-self: flex-start; color: var(--muted); font-size: 13px; }
.proposal { align-self: stretch; border: 1px solid #2B3A57; border-radius: 14px; background: #151C2B; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.proposal .why { margin: 0; color: var(--muted); font-size: 13px; }
.proposal textarea { min-height: 120px; font-size: 14px; background: var(--bg); }
.orch-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); background: var(--bg2); align-items: flex-end; }
.orch-form textarea { flex: 1; min-height: 46px; max-height: 160px; resize: none; }

.nav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid var(--line); background: var(--bg2); padding: 4px 8px calc(8px + env(safe-area-inset-bottom)); flex-shrink: 0; }
.nav button { height: 54px; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 12px; font-weight: 500; color: var(--muted); }
.nav button.active { color: var(--accent-text); }
body.typing-term .nav { display: none; }

.sheet { position: fixed; inset: 0; background: rgba(5,6,9,.72); display: flex; flex-direction: column; justify-content: flex-end; z-index: 10; }
.sheet-card { background: var(--surface); border-radius: 18px 18px 0 0; border-top: 1px solid var(--line2); padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); max-height: 92dvh; overflow-y: auto; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { flex-direction: row; align-items: center; justify-content: center; min-height: 44px; border: 1px solid var(--line2); border-radius: 10px; color: var(--text); font-size: 15px; }
.seg input { min-height: 0; }
.seg label:has(input:checked) { border-color: var(--accent); background: rgba(91,157,255,.12); }

.toast { position: fixed; left: 16px; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); padding: 12px 14px; border-radius: 12px; background: #232838; border: 1px solid var(--line2); z-index: 20; }

@media (min-width: 900px) {
  #view-boxes { max-width: 760px; width: 100%; margin: 0 auto; }
  .orch-log, .orch-head, .orch-form { max-width: 860px; width: 100%; margin: 0 auto; }
}
