:root {
  --bg: #101116;
  --panel: #181a22;
  --raised: #20232d;
  --line: #2b2f3c;
  --text: #e6e9f5;
  --muted: #8a90a8;
  --claude: #d97757;
  --claude-text: #e89a7e;
  --codex: #eceef4;
  --waiting: #f2c04b;
  --done: #9ece6a;
  --error: #f7768e;
  --working: #7aa2f7;
  --radius: 12px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; overscroll-behavior: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; background: var(--raised); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 14px; cursor: pointer; touch-action: manipulation; }
button:active { filter: brightness(1.3); }
button.primary { background: var(--claude); border-color: var(--claude); color: #1a0f0b; font-weight: 600; }
button.danger { color: var(--error); }
button.icon { background: none; border: none; font-size: 22px; padding: 6px 12px; min-width: 44px; min-height: 44px; }
button.icon.small { font-size: 15px; min-width: 40px; min-height: 40px; border: 1px solid var(--line); background: var(--raised); }
input, textarea { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; width: 100%; }
input:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--claude); outline-offset: 1px; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; padding-top: var(--safe-t); }
.bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--panel); min-height: 56px; }
.bar h1 { font-size: 18px; margin: 0; flex: 1; font-weight: 650; letter-spacing: .2px; }
.conn { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.conn.on { background: var(--done); }
.conn.off { background: var(--error); }
.banner { margin: 12px 16px 0; padding: 10px 12px; border-radius: 10px; background: #3a2a14; color: var(--waiting); }

/* Pairing */
#pair { align-items: center; justify-content: center; padding: 24px; }
.pair-box { max-width: 360px; width: 100%; text-align: center; display: flex; flex-direction: column; gap: 12px; }
.pair-icon { width: 72px; height: 72px; margin: 0 auto; border-radius: 16px; }
.pair-box h1 { margin: 0; font-size: 24px; }
.pair-box p { color: var(--muted); margin: 0; }
.cmd { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  font: 15px ui-monospace, "Cascadia Mono", monospace; margin: 0; color: var(--claude-text); }
#pair-form { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.error { color: var(--error) !important; min-height: 1.4em; }

/* Session list */
.sessions { list-style: none; margin: 0; padding: 12px 12px 96px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px;
  display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; cursor: pointer; border-left: 4px solid var(--line); }
.card:active { background: var(--raised); }
.card.claude { border-left-color: var(--claude); }
.card.codex { border-left-color: var(--codex); }
.card.waiting { border-color: var(--waiting); border-left-color: var(--waiting); }
.card .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .cwd { grid-column: 1 / -1; color: var(--muted); font: 12.5px ui-monospace, monospace; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .msg { grid-column: 1 / -1; color: var(--text); opacity: .85; font-size: 13.5px; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kind { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.kind.claude { color: var(--claude-text); }
.state { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; align-self: start; }
.state:empty { display: none; }
.state.working { color: var(--working); border-color: #33415f; }
.state.waiting { color: #1b1404; background: var(--waiting); border-color: var(--waiting); font-weight: 600; }
.state.done, .state.idle { color: var(--done); border-color: #3b4a2a; }
.state.error { color: var(--error); border-color: #5a2a33; }
.empty { color: var(--muted); text-align: center; padding: 40px 24px; }
.fab { position: fixed; right: 16px; bottom: calc(16px + var(--safe-b)); background: var(--claude); color: #1a0f0b;
  border: none; border-radius: 999px; padding: 14px 20px; font-weight: 650; }

/* Terminal */
.term-bar { padding: 4px 4px; gap: 2px; }
.term-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; }
#term-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
#term-wrap { flex: 1; min-height: 0; background: #0f1017; padding: 4px 2px 0 4px; }
#term { width: 100%; height: 100%; }
/* A session that keeps the desktop's size: as wide as it is, scrolled sideways if need be. */
#term-wrap.fixed { overflow-x: auto; }
#term-wrap.fixed #term { width: max-content; }
.keys { display: flex; gap: 6px; overflow-x: auto; padding: 6px 8px; background: var(--panel); border-top: 1px solid var(--line);
  scrollbar-width: none; }
.keys::-webkit-scrollbar { display: none; }
.keys button { flex: none; min-width: 44px; min-height: 40px; padding: 6px 10px; font: 14px ui-monospace, monospace; }
.keys button[aria-pressed="true"] { background: var(--claude); color: #1a0f0b; }
.compose { display: flex; gap: 8px; padding: 6px 8px calc(8px + var(--safe-b)); background: var(--panel); align-items: flex-end; }
.compose textarea { resize: none; max-height: 120px; min-height: 44px; }
.compose button { min-height: 44px; }

/* Sheets */
.sheet { border: 1px solid var(--line); background: var(--panel); color: var(--text); border-radius: 16px 16px 0 0;
  width: 100%; max-width: 560px; margin: auto auto 0; padding: 16px 16px calc(16px + var(--safe-b)); max-height: 88vh; }
.sheet::backdrop { background: rgba(0,0,0,.55); }
.sheet h2 { margin: 0 0 12px; font-size: 17px; }
.sheet form { display: flex; flex-direction: column; gap: 12px; }
.kinds { display: flex; gap: 8px; }
.kinds label { flex: 1; }
.kinds input { position: absolute; opacity: 0; }
.kinds span { display: block; text-align: center; padding: 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--raised); }
.kinds input:checked + span { border-color: var(--claude); color: var(--claude-text); background: #2a1d18; }
.kinds input:focus-visible + span { outline: 2px solid var(--claude); }
.field { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { padding: 6px 10px; font: 12.5px ui-monospace, monospace; border-radius: 999px; }
.browse { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.browse-head { display: flex; align-items: center; gap: 8px; padding: 6px; background: var(--raised);
  font: 12.5px ui-monospace, monospace; color: var(--muted); }
.browse-head span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; flex: 1; }
.dirs { list-style: none; margin: 0; padding: 0; max-height: 32vh; overflow-y: auto; }
.dirs li { padding: 11px 12px; border-top: 1px solid var(--line); cursor: pointer; }
.dirs li:active { background: var(--raised); }
.actions { display: flex; gap: 8px; justify-content: flex-end; }
.menu-row { display: flex; align-items: center; gap: 8px; }
.menu-row span { flex: 1; }
#menu-sheet form > button { text-align: left; }
