:root {
  --bg: #f6f7f9; --card: #fff; --ink: #1b1f24; --muted: #656d76; --line: #d8dee4;
  --accent: #1f6feb; --accent-ink: #fff; --me: #ddeaff; --danger: #cf222e;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0f1115; --card: #171a21; --ink: #e6edf3; --muted: #8b949e; --line: #30363d;
    --accent: #2f81f7; --accent-ink: #fff; --me: #1c2b44; --danger: #f85149; color-scheme: dark; }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 16px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
body { padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left); }
#app { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; }
button, input, textarea, select { font: inherit; color: inherit; }
button { min-height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); cursor: pointer; }
button.pri { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button.link { border: 0; background: none; color: var(--accent); padding: 0 8px; }
button:disabled { opacity: .5; }
input, textarea { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); }
.pin { font-size: 28px; letter-spacing: 8px; text-align: center; }
header { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); background: var(--card); }
header h1 { flex: 1; margin: 0; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.screen { flex: 1; overflow-y: auto; padding: 16px; }
.center { display: flex; flex-direction: column; gap: 12px; justify-content: center; min-height: 100%; }
.muted { color: var(--muted); font-size: 14px; }
.err { color: var(--danger); font-size: 14px; min-height: 1.2em; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 12px 4px; border-bottom: 1px solid var(--line); }
.list li .t { flex: 1; min-width: 0; }
.list li .t b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.msgs { display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 10px 12px; border-radius: 12px; background: var(--card); border: 1px solid var(--line); overflow-wrap: anywhere; }
.msg.user { align-self: flex-end; background: var(--me); border-color: transparent; max-width: 88%; white-space: pre-wrap; }
.msg.error { border-color: var(--danger); color: var(--danger); }
.msg .steps { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.msg pre { overflow-x: auto; background: var(--bg); padding: 8px; border-radius: 8px; font-size: 13px; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.files button { min-height: 36px; font-size: 14px; }
form.ask { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
form.ask fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0; padding: 8px 10px; }
form.ask legend { font-weight: 600; padding: 0 4px; }
form.ask label { display: flex; gap: 8px; align-items: center; min-height: 36px; }
form.ask label input { width: auto; min-height: 0; }
footer { border-top: 1px solid var(--line); background: var(--card); padding: 8px 12px calc(8px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 6px; }
footer .row { display: flex; gap: 8px; align-items: flex-end; }
footer textarea { flex: 1; resize: none; max-height: 40vh; }
.toggles { display: flex; gap: 14px; flex-wrap: wrap; font-size: 14px; color: var(--muted); }
.toggles label { display: flex; gap: 6px; align-items: center; min-height: 32px; }
.toggles input { width: auto; min-height: 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; font-size: 13px; }
.chips span { background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 2px 10px; }
