/* Jarvis mobile — dark, minimal, built for one thumb on an iPhone. */

:root {
  --bg: #0a0c10;
  --bg-raise: #12151c;
  --bg-input: #171b24;
  --line: #222835;
  --text: #e8ecf4;
  --muted: #8b95a7;
  --accent: #5b9cff;
  --accent-dim: #2d4f8a;
  --live: #ff4d5e;
  --ok: #38d39f;
  --warn: #ffb545;
  --bad: #ff5a68;
  --radius: 16px;
  --dock-pad: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--text);
  font: 400 16px/1.5 -apple-system, BlinkMacSystemFont, "SF Pro Text",
        system-ui, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior-y: none;
}
body { overflow: hidden; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor;
      stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.screen { height: 100%; display: flex; flex-direction: column; }
[hidden] { display: none !important; }

/* ───────────────────────── wordmark ───────────────────────── */
.wordmark {
  margin: 0; font-weight: 600; letter-spacing: .34em;
  font-size: 28px; color: var(--text);
}
.wordmark.small { font-size: 13px; letter-spacing: .26em; color: var(--muted); }

/* ───────────────────────── login ───────────────────────── */
#gate { align-items: center; justify-content: center; padding: 24px; }
.gate-inner { width: 100%; max-width: 360px; text-align: center; }
.gate-sub { color: var(--muted); margin: 10px 0 30px; font-size: 14px; }
.field-label {
  display: block; text-align: left; font-size: 12px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .08em; margin-bottom: 8px;
}
#code {
  width: 100%; padding: 16px; background: var(--bg-input);
  border: 1px solid var(--line); border-radius: var(--radius);
  text-align: center; font-size: 24px; letter-spacing: .18em;
  font-variant-numeric: tabular-nums; margin-bottom: 14px;
}
#code:focus { outline: none; border-color: var(--accent); }
.primary {
  width: 100%; padding: 16px; border-radius: var(--radius);
  background: var(--accent); color: #05080f; font-weight: 600;
}
.primary:active { background: var(--accent-dim); color: var(--text); }
.primary:disabled { opacity: .5; }
.secondary {
  width: 100%; padding: 13px; border-radius: 12px;
  background: var(--bg-input); border: 1px solid var(--line);
}
.danger {
  width: 100%; padding: 14px; border-radius: 12px; margin-top: 8px;
  background: transparent; border: 1px solid #40242a; color: var(--bad);
}
.link { display: block; width: 100%; margin-top: 14px; color: var(--muted);
        font-size: 14px; text-decoration: underline; }
.hint { color: var(--muted); font-size: 12.5px; margin-top: 16px; }
.hint code { background: var(--bg-input); padding: 2px 6px; border-radius: 6px; }
.error { color: var(--bad); font-size: 14px; margin-top: 16px; }

/* ───────────────────────── top bar ───────────────────────── */
.bar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: calc(env(safe-area-inset-top, 0px) + 12px) 14px 10px;
  border-bottom: 1px solid var(--line); background: var(--bg);
}
.bar-left, .bar-right { display: flex; align-items: center; gap: 10px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px; background: var(--bg-raise);
  border: 1px solid var(--line); font-size: 12px; color: var(--muted);
}
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.dot.ok { background: var(--ok); }
.dot.warn { background: var(--warn); }
.dot.bad { background: var(--bad); }
.icon-btn {
  display: grid; place-items: center; width: 38px; height: 38px;
  border-radius: 11px; color: var(--muted); background: var(--bg-raise);
  border: 1px solid var(--line);
}
.icon-btn:active { color: var(--text); }

/* ───────────────────────── thread ───────────────────────── */
.thread {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 18px 14px 6px; display: flex; flex-direction: column; gap: 14px;
}
.turn { max-width: 94%; }
.turn.me { align-self: flex-end; text-align: right; }
.turn .who {
  font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 5px;
}
.bubble {
  display: inline-block; padding: 12px 15px; border-radius: 18px;
  background: var(--bg-raise); border: 1px solid var(--line);
  white-space: pre-wrap; word-break: break-word; text-align: left;
}
.turn.me .bubble {
  background: var(--accent-dim); border-color: transparent; color: #eaf1ff;
}
.turn.jarvis .bubble.interim { color: var(--muted); font-style: italic; }
.meta { font-size: 11px; color: var(--muted); margin-top: 6px; }
.meta .tag {
  display: inline-block; padding: 1px 6px; border-radius: 6px;
  background: var(--bg-input); margin-right: 5px;
}
.empty { color: var(--muted); font-size: 14px; text-align: center;
         margin: auto 0; padding: 0 20px; }
.empty b { color: var(--text); font-weight: 500; }
.empty ul { list-style: none; padding: 0; margin: 14px 0 0;
            display: grid; gap: 7px; }

.thinking { display: inline-flex; gap: 5px; align-items: center; height: 20px; }
.thinking i {
  width: 6px; height: 6px; border-radius: 50%; background: var(--muted);
  animation: blink 1.3s infinite ease-in-out;
}
.thinking i:nth-child(2) { animation-delay: .18s; }
.thinking i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%,80%,100% { opacity:.25 } 40% { opacity:1 } }

.session-note {
  margin: 0 14px 8px; padding: 7px 11px; border-radius: 10px;
  background: var(--bg-raise); border: 1px solid var(--line);
  color: var(--muted); font-size: 12px; text-align: center;
}

/* ───────────────────────── dock ───────────────────────── */
.dock {
  padding: var(--dock-pad) 14px calc(env(safe-area-inset-bottom, 0px) + 12px);
  border-top: 1px solid var(--line); background: var(--bg);
}
.state-label {
  text-align: center; font-size: 12px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--muted); margin-bottom: 10px;
  min-height: 15px;
}
.state-label.live { color: var(--live); }
.state-label.busy { color: var(--accent); }

.mic-row {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  gap: 10px; margin-bottom: 12px;
}
.side-btn {
  display: inline-flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--muted); font-size: 11px; justify-self: center;
}
.side-btn:first-child { justify-self: start; }
.side-btn:last-child { justify-self: end; }
.side-btn svg { width: 19px; height: 19px; }

.mic {
  position: relative; width: 84px; height: 84px; border-radius: 50%;
  background: var(--bg-raise); border: 1px solid var(--line);
  display: grid; place-items: center; justify-self: center;
  transition: transform .12s ease, background .2s ease;
}
.mic:active { transform: scale(.94); }
.mic .mic-icon { width: 32px; height: 32px; color: var(--text); }
.mic.listening { background: #2a1116; border-color: #5c2029; }
.mic.listening .mic-icon { color: var(--live); }
.mic.busy { opacity: .55; }
.mic .pulse {
  position: absolute; inset: -5px; border-radius: 50%;
  border: 2px solid var(--live); opacity: 0; pointer-events: none;
}
.mic.listening .pulse { animation: pulse 1.5s infinite ease-out; }
@keyframes pulse {
  0% { transform: scale(.95); opacity: .7 }
  100% { transform: scale(1.3); opacity: 0 }
}

.text-row { display: flex; gap: 9px; align-items: center; }
#text-input {
  flex: 1; padding: 13px 15px; border-radius: 13px;
  background: var(--bg-input); border: 1px solid var(--line); font-size: 16px;
}
#text-input:focus { outline: none; border-color: var(--accent-dim); }
.send {
  display: grid; place-items: center; width: 46px; height: 46px;
  border-radius: 13px; background: var(--bg-input);
  border: 1px solid var(--line); color: var(--accent);
}

/* ───────────────────────── settings sheet ───────────────────────── */
.sheet {
  position: fixed; inset: 0; background: rgba(4,6,10,.72);
  display: flex; align-items: flex-end; z-index: 20;
}
.sheet-inner {
  width: 100%; max-height: 88%; overflow-y: auto;
  background: var(--bg-raise); border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  padding: 18px 18px calc(env(safe-area-inset-bottom, 0px) + 22px);
}
.sheet-head { display: flex; align-items: center; justify-content: space-between;
              margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--line);
}
.row.stack { flex-direction: column; align-items: stretch; gap: 9px; }
.row span { font-size: 14px; }
.row input[type=checkbox] { width: 50px; height: 30px; accent-color: var(--accent); }
.row input[type=range] { width: 100%; accent-color: var(--accent); }
.row select {
  padding: 11px; border-radius: 11px; background: var(--bg-input);
  border: 1px solid var(--line);
}
.muted { color: var(--muted); }
.small { font-size: 12.5px; margin: 0; }

@media (prefers-reduced-motion: reduce) {
  .mic.listening .pulse, .thinking i { animation: none; }
}
