:root {
  --bg: #161616; --panel: #1f1f1f; --raise: #262626; --line: #2c2c2c; --line2: #3a3a3a;
  --text: #ececec; --muted: #a3a3a3; --dim: #7a7a7a;
  --green: #5bd16a; --amber: #e7b24a; --red: #ef6a5e; --blue: #7fb2ff; --gold: #e7b24a;
  --font: -apple-system, "Segoe UI", system-ui, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 16px/1.45 var(--font); }
body { overscroll-behavior: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }

.screen { display: flex; flex-direction: column; height: 100dvh; padding-top: env(safe-area-inset-top); }
.center { align-items: center; justify-content: center; text-align: center; padding: 24px 20px; gap: 6px; }
.hero-icon { width: 72px; height: 72px; border-radius: 16px; }
.center h1 { font-size: 22px; margin: 10px 0 4px; }
.center p { color: var(--muted); max-width: 340px; margin: 6px auto; }
.center input { width: 100%; max-width: 320px; margin: 14px 0 10px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line2); background: var(--panel); color: var(--text); font: inherit; }
.btn { display: inline-block; padding: 12px 22px; border-radius: 10px; background: var(--gold); color: #1a1407; font-weight: 600; }
.btn.ghost { background: var(--raise); color: var(--text); }
.err { color: var(--red); }

.offline { position: fixed; top: env(safe-area-inset-top); left: 0; right: 0; z-index: 9; background: #4a2a12; color: #ffd9a8; text-align: center; font-size: 13px; padding: 6px 12px; }

.bar { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-height: 56px; }
.bar h1 { flex: 1; font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-icon { width: 28px; height: 28px; border-radius: 7px; }
.icon { width: 40px; height: 40px; display: grid; place-items: center; margin-left: -8px; border-radius: 10px; }
.pill { padding: 7px 14px; border-radius: 99px; background: var(--raise); font-size: 14px; font-weight: 500; }
.pill.danger { background: #3b1b18; color: var(--red); }

.tabs { display: flex; gap: 4px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; padding: 8px 0; border-radius: 8px; color: var(--muted); font-size: 15px; }
.tabs button[aria-selected="true"] { background: var(--raise); color: var(--text); }
.count { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--gold); color: #1a1407; font-size: 12px; font-style: normal; font-weight: 700; line-height: 18px; }

.list { flex: 1; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }
.row { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.row:active { background: var(--panel); }
.row .main { flex: 1; min-width: 0; }
.row .t, .row .s { display: block; }
.row .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { color: var(--dim); font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .when { color: var(--dim); font-size: 12px; flex: none; }
.dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--line2); }
.dot.working { background: var(--amber); animation: pulse 1.4s ease-in-out infinite; }
.dot.error { background: var(--red); }
.dot.unread { background: var(--blue); }
.flag { color: var(--gold); font-size: 12px; font-weight: 600; flex: none; }
.empty { color: var(--dim); text-align: center; padding: 48px 24px; }
@keyframes pulse { 50% { opacity: .35; } }

.messages { flex: 1; overflow-y: auto; padding: 14px 14px 8px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 92%; border-radius: 14px; padding: 9px 13px; background: var(--panel); overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: #2d3b52; }
.msg .who { font-size: 12px; color: var(--dim); margin-bottom: 2px; }
.msg p { margin: 6px 0; }
.msg p:first-child { margin-top: 0; } .msg p:last-child { margin-bottom: 0; }
.msg pre { background: #111; padding: 8px 10px; border-radius: 8px; overflow-x: auto; font: 13px/1.4 var(--mono); }
.msg code { font: 13.5px var(--mono); background: #111; padding: 1px 4px; border-radius: 4px; }
.msg pre code { padding: 0; background: none; }
.msg a { color: var(--blue); }
.msg ul, .msg ol { padding-left: 20px; margin: 6px 0; }
.msg h1, .msg h2, .msg h3 { font-size: 16px; margin: 10px 0 4px; }
.busyline { color: var(--muted); font-size: 14px; display: flex; gap: 8px; align-items: center; }
.busyline .act { color: var(--dim); font-size: 13px; display: block; }
.files { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 6px; }
.files span { font-size: 12.5px; padding: 3px 8px; border-radius: 6px; background: var(--raise); color: var(--muted); }

.approval { border: 1px solid #5a4a20; background: #2a2414; }
.approval.full { border-color: #6a2a24; background: #2c1714; }
.approval .acts { display: flex; gap: 8px; margin-top: 10px; }
.approval .acts button { flex: 1; padding: 9px; border-radius: 9px; font-weight: 600; background: var(--raise); }
.approval .acts .yes { background: var(--gold); color: #1a1407; }
.approval .done { color: var(--muted); font-size: 13px; margin-top: 6px; }

.composer { display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--bg); }
.composer textarea { flex: 1; resize: none; max-height: 40vh; padding: 10px 14px; border-radius: 20px; border: 1px solid var(--line2); background: var(--panel); color: var(--text); font: inherit; line-height: 1.35; }
.composer button { width: 42px; height: 42px; border-radius: 50%; background: var(--gold); color: #1a1407; display: grid; place-items: center; flex: none; }
.composer button:disabled { opacity: .4; }

.task .s { white-space: normal; }
.task .main { text-align: left; padding: 0; }
.task .stop { padding: 6px 12px; border-radius: 8px; background: #3b1b18; color: var(--red); font-size: 13px; flex: none; }
