/* OmniLLM web client. Phone first; tablets get a wider column. Colors are
   tokens; dark mode redefines them. */
:root {
  --bg: #f5f6f4; --surface: #ffffff; --ink: #17201c; --muted: #5d6b64; --line: #dde3df;
  --accent: #1f6f5c; --accent-ink: #ffffff; --user: #e3efe9; --danger: #a32d2d; --warn-soft: #fbf0df; --warn: #7a4708;
  --radius: 14px;
  --font: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1412; --surface: #171e1b; --ink: #e4ebe7; --muted: #9aaba3; --line: #2a3531;
    --accent: #5bc2a6; --accent-ink: #0b1210; --user: #1f2d28; --danger: #f08b8b; --warn-soft: #33281a; --warn: #f0b36a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 16px/1.5 var(--font); -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
#app { height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; min-height: 0; }
.center { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom)); max-width: 480px; margin: 0 auto; width: 100%; }
h1 { font-size: 22px; margin: 0; } h2 { font-size: 17px; margin: 0 0 8px; }
.muted { color: var(--muted); } .small { font-size: 14px; }
.err { color: var(--danger); min-height: 1.5em; margin: 0; }
.logo { width: 64px; height: 64px; }
.primary, .secondary { border-radius: 12px; padding: 12px 20px; min-height: 48px; border: 1px solid var(--accent); cursor: pointer; width: 100%; max-width: 320px; }
.primary { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.secondary { background: transparent; color: var(--accent); }
.link { background: none; border: 0; color: var(--accent); padding: 6px 0; cursor: pointer; text-align: left; }
.danger { color: var(--danger); }
.paste { width: 100%; max-width: 320px; text-align: left; color: var(--muted); }
.paste summary { cursor: pointer; padding: 8px 0; }
.paste textarea { width: 100%; margin: 8px 0; border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: var(--surface); font: 13px var(--mono); }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }
.host { font: 600 17px var(--mono); overflow-wrap: anywhere; margin: 0; }
.warn { background: var(--warn-soft); color: var(--warn); border-radius: 10px; padding: 10px 12px; margin: 0; }
#pair-ask { display: flex; flex-direction: column; align-items: center; gap: 12px; width: 100%; }
.sas { font: 600 44px/1.2 var(--mono); letter-spacing: 0.08em; padding: 12px 20px; border: 2px solid var(--accent); border-radius: 16px; }

/* scanner */
#scanner { position: relative; background: #000; }
#cam { width: 100%; height: 100%; object-fit: cover; }
.scan-hint { position: absolute; top: max(16px, env(safe-area-inset-top)); left: 0; right: 0; text-align: center; color: #fff; text-shadow: 0 1px 3px #000; margin: 0; padding: 0 16px; }
.floating { position: absolute; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.55); color: #fff; border-color: #fff; width: auto; }

/* chat */
.chat { display: flex; flex-direction: column; }
.bar { display: flex; align-items: center; gap: 8px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; border-bottom: 1px solid var(--line); background: var(--surface); }
.bar select { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; background: var(--bg); min-height: 40px; }
.icon { width: 40px; height: 40px; border: 0; background: none; border-radius: 10px; cursor: pointer; position: relative; flex: none; }
.icon:active { background: var(--line); }
#menu span, #menu span::before, #menu span::after { position: absolute; left: 10px; width: 20px; height: 2px; background: var(--ink); border-radius: 1px; content: ""; }
#menu span { top: 19px; } #menu span::before { top: -6px; left: 0; } #menu span::after { top: 6px; left: 0; }
.plus::before, .plus::after { content: ""; position: absolute; left: 11px; top: 19px; width: 18px; height: 2px; background: var(--ink); border-radius: 1px; }
.plus::after { transform: rotate(90deg); }
.banner { background: var(--warn-soft); color: var(--warn); padding: 8px 16px; font-size: 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between; }
.log { flex: 1; overflow-y: auto; padding: 16px 12px; display: flex; flex-direction: column; gap: 12px; -webkit-overflow-scrolling: touch; }
.log > * { max-width: 760px; width: 100%; margin-left: auto; margin-right: auto; }
.empty { color: var(--muted); text-align: center; margin-top: 30vh; }
.msg { padding: 10px 14px; border-radius: var(--radius); overflow-wrap: anywhere; position: relative; }
.msg p { margin: 0 0 8px; white-space: pre-wrap; } .msg p:last-of-type { margin-bottom: 0; }
.msg.user { background: var(--user); align-self: flex-end; max-width: min(85%, 640px); margin-right: 0; }
.msg.assistant { background: var(--surface); border: 1px solid var(--line); }
.msg pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; margin: 8px 0; }
.msg code { font: 13px/1.45 var(--mono); }
.msg .note { color: var(--muted); font-size: 13px; margin-top: 6px; }
.note.err { color: var(--danger); font-size: 14px; text-align: center; }
.copy { position: absolute; right: 8px; bottom: -22px; background: none; border: 0; color: var(--muted); font-size: 12px; cursor: pointer; }
.msg.assistant { margin-bottom: 14px; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: var(--surface); }
.composer textarea { flex: 1; resize: none; border: 1px solid var(--line); border-radius: 20px; padding: 10px 14px; background: var(--bg); max-height: 180px; font-size: 16px; }
.send { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--accent); cursor: pointer; position: relative; flex: none; }
.send::before { content: ""; position: absolute; left: 50%; top: 50%; width: 0; height: 0; border-left: 9px solid transparent; border-right: 9px solid transparent; border-bottom: 13px solid var(--accent-ink); transform: translate(-50%, -60%); }
.send.stop::before { width: 14px; height: 14px; border: 0; background: var(--accent-ink); border-radius: 2px; transform: translate(-50%, -50%); }

/* drawer */
.drawer { position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 10; }
.drawer-panel { position: absolute; top: 0; bottom: 0; left: 0; width: min(320px, 85vw); background: var(--surface); padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; }
#chat-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
#chat-list button { width: 100%; text-align: left; border: 0; background: none; padding: 10px 8px; border-radius: 8px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#chat-list button.cur { background: var(--user); }
.drawer-foot { border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 2px; }
