:root {
  --bg: #0b0d12;
  --panel: #141821;
  --panel-2: #1b202c;
  --line: #262c3a;
  --text: #e8ecf5;
  --muted: #8b93a7;
  --accent: #7c9cff;
  --good: #4cc38a;
  --warn: #f5b84a;
  --bad: #ff6b6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}

button, input, textarea { font: inherit; color: inherit; }

button {
  border: 1px solid var(--line);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 9px 14px;
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #0b0d12; font-weight: 600; }
button.danger { border-color: var(--bad); color: var(--bad); background: transparent; }
button.quiet { border-color: transparent; background: transparent; color: var(--muted); padding: 6px 8px; }

input, textarea {
  width: 100%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 11px 12px;
  outline: none;
}
input:focus, textarea:focus { border-color: var(--accent); }

#app {
  height: 100dvh;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
}

/* --- pairing ------------------------------------------------------------ */
.pair { margin: auto; width: min(360px, 90%); display: grid; gap: 14px; text-align: center; }
.pair img { width: 84px; margin: 0 auto; }
.pair h1 { margin: 0; font-size: 26px; }
.pair p { margin: 0; color: var(--muted); }
.pair input.code { text-align: center; letter-spacing: 0.3em; font-size: 22px; text-transform: uppercase; }
.error { color: var(--bad); min-height: 1.4em; font-size: 14px; }

/* --- chrome ------------------------------------------------------------- */
header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}
header h1 { font-size: 18px; margin: 0; flex: 1; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.on { background: var(--good); }
.dot.off { background: var(--bad); }
.dim { color: var(--muted); font-size: 13px; }

main { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px; }
main.chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; }

nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
nav button {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 13px 4px;
  font-size: 13px;
}
nav button.active { color: var(--accent); font-weight: 600; }
.badge[hidden] { display: none; }
.badge {
  display: inline-block;
  min-width: 18px;
  margin-left: 5px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--warn);
  color: #0b0d12;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
}

/* --- chat --------------------------------------------------------------- */
.log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.empty { margin: auto; color: var(--muted); text-align: center; max-width: 300px; }
.msg { max-width: 86%; padding: 10px 13px; border-radius: 16px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--accent); color: #0b0d12; border-bottom-right-radius: 5px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 5px; }
.msg.voice::after { content: " 🎙"; font-size: 11px; opacity: 0.7; }
.msg.failed { border-color: var(--bad); color: var(--bad); }
.activity { align-self: flex-start; color: var(--muted); font-size: 13px; padding: 0 4px; }

.voicebar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 16px;
  padding: 10px 14px;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--panel);
}
.voicebar span { flex: 1; }

.composer { display: flex; gap: 8px; padding: 10px 16px 14px; align-items: flex-end; }
.composer textarea { resize: none; max-height: 140px; }
.composer button { flex: none; height: 46px; min-width: 46px; }

/* --- cards -------------------------------------------------------------- */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 12px;
}
.card.pending { border-color: var(--warn); }
.card pre {
  margin: 8px 0 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font: inherit;
}
.card img.shot {
  display: block;
  width: 100%;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.card pre.out {
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--muted);
  background: var(--bg);
  border-radius: 8px;
  padding: 9px;
  max-height: 220px;
  overflow-y: auto;
}
.row { display: flex; align-items: center; gap: 10px; }
.row > .grow { flex: 1; min-width: 0; }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.actions button { flex: 1; }
.chip {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--muted);
}
.chip.pending, .chip.queued, .chip.running { color: var(--warn); }
.chip.executed, .chip.done { color: var(--good); }
.chip.failed, .chip.rejected, .chip.cancelled { color: var(--bad); }

h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 20px 0 9px; }
h2:first-child { margin-top: 2px; }
.secret {
  font: 13px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg);
  border-radius: 8px;
  padding: 9px;
  margin-top: 8px;
  overflow-wrap: anywhere;
  user-select: all;
}
.inline { display: flex; gap: 8px; margin-top: 8px; }
.inline button { flex: none; }
