/* NativeOS: dark, muted, calm. Status is shown with tiny dots only. */

:root {
  --bg: #111315;
  --surface: #16191c;
  --surface-2: #1b1f23;
  --border: #252a2f;
  --text: #c8ccd1;
  --text-strong: #e1e4e8;
  --muted: #7b828a;
  --accent: #8ea3b6;
  --accent-soft: #24303a;
  --dot-idle: #59616a;
  --dot-ok: #7fa294;
  --dot-busy: #8ea3b6;
  --dot-warn: #b2a07a;
  --radius: 8px;
  --topbar-h: 48px;
  --panel-w: 400px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 18px; font-weight: 500; color: var(--text-strong); margin: 0 0 16px; }
h2 { font-size: 14px; font-weight: 500; color: var(--text-strong); margin: 0 0 12px; }
code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }
.inline { display: inline-flex; gap: 6px; align-items: center; margin: 0; }
.grow { flex: 1; }

/* ---- controls ---- */
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 7px 9px;
  outline: none;
}
input:focus, select:focus, textarea:focus, button:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); outline: none; }
button { cursor: pointer; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); padding: 6px 12px; }
button:hover { border-color: #323840; }
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent-soft); border-color: #33424f; color: var(--text-strong); }
button.primary:hover { border-color: var(--accent); }
button.ghost { background: transparent; border-color: transparent; color: var(--muted); }
button.ghost:hover { color: var(--text); border-color: var(--border); }
button.wide { width: 100%; padding: 9px; margin-top: 8px; }
.small-btn { padding: 4px 9px; font-size: 12.5px; }
.link-btn { background: none; border: none; padding: 0; color: var(--muted); font-size: 12.5px; text-decoration: underline; }
.link-btn:hover { color: var(--text); }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; background: transparent; border-color: transparent; color: var(--muted); }
.icon-btn:hover { color: var(--text); border-color: var(--border); }
.icon-btn.active { color: var(--text-strong); border-color: var(--border); }

/* ---- dots ---- */
.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--dot-idle); flex: none; vertical-align: middle; }
.dot-ok { background: var(--dot-ok); }
.dot-off { background: var(--dot-idle); }
.dot-warn { background: var(--dot-warn); }
.dot-busy, .dot.busy { background: var(--dot-busy); animation: breathe 1.8s ease-in-out infinite; }
.dot-rec { background: var(--dot-warn); animation: breathe 1.2s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .dot-busy, .dot.busy, .dot-rec { animation: none; } }

/* ---- layout ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 20px;
  padding: 0 16px;
  background: rgba(17, 19, 21, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}
.brand { font-weight: 600; letter-spacing: 0.02em; color: var(--text-strong); }
.brand:hover { text-decoration: none; }
.nav { display: flex; gap: 14px; }
.nav a { color: var(--muted); }
.nav a[aria-current="page"], .nav a:hover { color: var(--text-strong); text-decoration: none; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; min-width: 0; }
.who { color: var(--muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
#panel-toggle { display: inline-flex; align-items: center; gap: 7px; }
#panel-toggle .toggle-icon { display: none; }
#panel-toggle[aria-expanded="true"] { color: var(--text); border-color: var(--border); }

.shell { min-height: calc(100vh - var(--topbar-h)); }
.main { padding: 28px 24px; max-width: 980px; margin: 0 auto; transition: margin 0.2s ease; }
body.panel-open .main { margin-right: calc(var(--panel-w) + 24px); }
@media (min-width: 1500px) { body.panel-open .main { margin-right: auto; } }
.page-content:empty { min-height: 40vh; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; }
.notice-page { max-width: 520px; }

/* ---- login ---- */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login { width: 100%; padding: 16px; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 6px; padding: 26px; }
.login-card .brand { font-size: 17px; margin-bottom: 12px; }
.login-card label { color: var(--muted); font-size: 12.5px; margin-top: 6px; }
.form-error { display: flex; gap: 8px; align-items: center; color: var(--text); font-size: 13px; margin: 8px 0 0; }

/* ---- admin users ---- */
.admin { display: flex; flex-direction: column; gap: 18px; }
.flash { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.flash .secret { flex-basis: 100%; color: var(--muted); }
code.wrap { word-break: break-all; }
table.audit td.audit-msg { white-space: normal; min-width: 240px; }
.create-user .row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.create-user label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12.5px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table.users { width: 100%; border-collapse: collapse; }
table.users th, table.users td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.users th { color: var(--muted); font-weight: 500; font-size: 12.5px; background: var(--surface); }
table.users tr:last-child td { border-bottom: none; }
table.users tr.is-disabled td:first-child { color: var(--muted); }
table.users input, table.users select { padding: 4px 7px; font-size: 12.5px; }

/* ---- coordinator panel ---- */
.panel {
  position: fixed; z-index: 15;
  top: var(--topbar-h); right: 0; bottom: 0;
  width: var(--panel-w);
  display: flex; flex-direction: column;
  background: var(--surface);
  border-left: 1px solid var(--border);
}
.panel-head { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-bottom: 1px solid var(--border); }
.panel-title { color: var(--text-strong); font-weight: 500; }
.panel-status { display: inline-flex; gap: 6px; align-items: center; color: var(--muted); font-size: 12px; margin-right: auto; }
.chat-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; overscroll-behavior: contain; }
.chat-log .empty { color: var(--muted); font-size: 13px; margin: auto 0; text-align: center; }
.msg { max-width: 100%; overflow-wrap: anywhere; }
.msg-user-wrap { align-self: flex-end; max-width: 88%; }
.msg-user { background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px 10px 2px 10px; padding: 7px 11px; white-space: pre-wrap; }
.msg-meta { display: flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--muted); margin-top: 4px; justify-content: flex-end; }
.msg-assistant { color: var(--text); }
.msg-assistant .md > :first-child { margin-top: 0; }
.msg-assistant .md > :last-child { margin-bottom: 0; }
.msg-assistant .md p { margin: 0 0 8px; }
.msg-assistant .md pre { background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 8px 10px; overflow-x: auto; }
.msg-assistant .md pre code { background: none; padding: 0; }
.msg-assistant .md ul, .msg-assistant .md ol { padding-left: 20px; margin: 0 0 8px; }
.msg-assistant .md table { border-collapse: collapse; display: block; overflow-x: auto; }
.msg-assistant .md th, .msg-assistant .md td { border: 1px solid var(--border); padding: 3px 7px; }
.msg-assistant .md blockquote { margin: 0 0 8px; padding-left: 10px; border-left: 2px solid var(--border); color: var(--muted); }
.msg-assistant .md h1, .msg-assistant .md h2, .msg-assistant .md h3 { font-size: 14px; margin: 10px 0 6px; }
.msg-live .live-text { white-space: pre-wrap; }
.msg-note { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 12px; margin-top: 4px; }
.msg-steps { margin-top: 4px; font-size: 12px; color: var(--muted); }
.msg-steps summary { cursor: pointer; }
.msg-steps ol { margin: 4px 0 0; padding-left: 18px; }
.working { display: flex; align-items: center; gap: 8px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--muted); }
.working .activity { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.composer { border-top: 1px solid var(--border); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; margin: 0; }
.composer textarea { width: 100%; resize: vertical; min-height: 64px; max-height: 40vh; }
.composer-actions { display: flex; align-items: center; gap: 8px; }
.hint { flex: 1; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rec-bar { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text); }
.rec-timer { font-family: var(--mono); color: var(--muted); }

/* Mobile: the panel becomes a full-screen drawer. */
@media (max-width: 760px) {
  .topbar { gap: 12px; padding: 0 10px; }
  .who { display: none; }
  #panel-toggle .label { display: none; }
  #panel-toggle .toggle-icon { display: inline-block; }
  .main { padding: 20px 14px; }
  body.panel-open .main { margin-right: auto; }
  body.panel-open { overflow: hidden; }
  .panel { top: 0; left: 0; width: 100%; z-index: 30; border-left: none; padding-top: env(safe-area-inset-top); }
}

/* ---- account ---- */
.narrow { max-width: 520px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12.5px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
a.who:hover { color: var(--text); text-decoration: none; }

/* ---- pages index ---- */
.page-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.page-list .muted { font-size: 12px; margin-left: 6px; }

/* Sign-in second step, 2FA setup, recovery codes, devices */
.small { font-size: 12.5px; }
.login-card.wide-card { max-width: 440px; }
.login-card h2 { margin: 4px 0 0; }
.login-card p { margin: 4px 0; }
.stack-tight { display: flex; flex-direction: column; gap: 6px; margin: 0; }
.login-alt { margin: 10px 0 0; text-align: center; }
label.check { display: flex; flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; margin-top: 8px; }
label.check input { width: auto; margin: 0; }
.steps { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 12px; }
.steps li { color: var(--text); }
.steps label { color: var(--muted); font-size: 12.5px; display: block; margin-bottom: 4px; }
.steps input { width: 100%; max-width: 200px; letter-spacing: 0.15em; }
.qr-wrap { margin-top: 10px; }
svg.qr { display: block; width: 200px; height: 200px; border-radius: 6px; }
.manual-key { margin-top: 6px; }
.manual-key code { font-size: 13px; letter-spacing: 0.04em; }
.codes { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, max-content); gap: 8px 18px; }
.codes code { font-size: 14px; letter-spacing: 0.05em; padding: 3px 8px; }
a.button { display: inline-block; border-radius: 6px; border: 1px solid var(--border); background: var(--surface-2); padding: 6px 12px; color: var(--text); }
a.button:hover { text-decoration: none; border-color: #323840; }
a.button.primary { background: var(--accent-soft); border-color: #33424f; color: var(--text-strong); }
a.button.primary:hover { border-color: var(--accent); }
a.button.wide { display: block; text-align: center; padding: 9px; margin-top: 8px; }
table.devices td.actions { display: flex; gap: 6px; flex-wrap: wrap; }
