/* dark-first, no external fonts (BUILD-SPEC §1.4 / §5) */
:root {
  --bg: #0e1113; --panel: #171c1f; --panel2: #1f2529; --text: #e8e6e1;
  --muted: #8a938f; --accent: #7fb069; --bad: #d06a5f; --wait: #d8b365;
  --radius: 10px;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f4f2ed; --panel: #ffffff; --panel2: #e9e6df; --text: #22261f; --muted: #6b7268; }
}
* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body {
  background: var(--bg); color: var(--text);
  font: 16px/1.5 -apple-system, "SF Pro Text", "Helvetica Neue", sans-serif;
}
#app { display: flex; flex-direction: column; height: 100dvh; }

header {
  display: flex; gap: 8px; align-items: center; padding: 10px 12px;
  padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--panel); border-bottom: 1px solid var(--panel2);
}
header select { max-width: 34vw; }
.spacer { flex: 1; }

select, button, textarea, input {
  background: var(--panel2); color: var(--text); border: 1px solid #333a3f;
  border-radius: var(--radius); padding: 8px 10px; font: inherit;
}
button { cursor: pointer; }
button.danger { background: var(--bad); color: #fff; }

main { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.msg { display: flex; flex-direction: column; max-width: 82%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.assistant { align-self: flex-start; }
.bubble { padding: 10px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.user .bubble { background: #2c4a3e; }
.msg.assistant .bubble { background: var(--panel); }

.badge { margin-top: 4px; font-size: 12px; padding: 2px 10px; border-radius: 999px; border: none; }
.badge.ok { background: #23392a; color: var(--accent); }
.badge.bad { background: #45201c; color: #ff9d92; font-weight: 700; animation: pulse 1.2s infinite; }
.badge.wait { background: #3d321f; color: var(--wait); }
@keyframes pulse { 50% { opacity: 0.55; } }

footer {
  display: flex; gap: 8px; padding: 10px 12px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--panel); border-top: 1px solid var(--panel2);
}
footer textarea { flex: 1; resize: none; }
footer button { font-size: 20px; padding: 0 18px; }

.warnbar { background: #4a3a1c; color: #ffd88a; padding: 6px 12px; font-size: 13px; }
.alertbar {
  position: fixed; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--panel2); padding: 10px 16px; border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,.4); z-index: 50; max-width: 90vw;
}

.lock { display: grid; place-items: center; height: 100dvh; padding: 20px; }
.lock-card { background: var(--panel); border-radius: 16px; padding: 28px; max-width: 420px; width: 100%; display: flex; flex-direction: column; gap: 10px; }
.lock-logo { font-size: 40px; text-align: center; }
.lock-card h1 { font-size: 20px; text-align: center; }
.lock-card input { width: 100%; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal-card { background: var(--panel); border-radius: 16px; padding: 22px; max-width: 640px; width: 100%; max-height: 88dvh; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
.modal-card table { border-collapse: collapse; }
.modal-card td { padding: 6px 8px; vertical-align: top; border-bottom: 1px solid var(--panel2); }
.modal-card pre { background: var(--bg); padding: 10px; border-radius: 8px; overflow-x: auto; font-size: 11px; }
.kv div { display: flex; gap: 8px; font-size: 13px; word-break: break-all; }
.kv span { color: var(--muted); min-width: 110px; flex-shrink: 0; }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: #ff9d92; min-height: 1em; }
.row { display: flex; gap: 8px; align-items: center; }
label { font-size: 13px; color: var(--muted); }
hr { border: none; border-top: 1px solid var(--panel2); margin: 6px 0; }
