/* ASK NOVA — the staff door. Same keynote-glass law as the founder's console, cut down to
   what a person on a phone at a till, a gate, or a showroom floor needs: one thread,
   one search box, the numbers that matter today. System fonts carry Khmer natively. */
:root {
  color-scheme: dark;
  --bg: #000; --ink: #F5F5F7; --muted: #A1A1A6; --faint: #7D7D82;
  --line: rgba(255,255,255,.10); --line-2: rgba(255,255,255,.16);
  --panel: rgba(28,28,30,.72); --glass: rgba(28,28,30,.55); --glass-2: rgba(255,255,255,.05);
  --accent: #0A84FF; --live: #30D158; --gold: #FF9F0A; --rose: #FF453A; --violet: #BF5AF2;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', 'Khmer OS', 'Noto Sans Khmer', 'Inter', sans-serif;
  --mono: ui-monospace, 'SF Mono', Menlo, monospace;
  --ease: cubic-bezier(.32,.72,0,1); --r: 16px; --r-sm: 11px;
  --shadow: 0 1px 1px rgba(0,0,0,.3), 0 18px 50px -20px rgba(0,0,0,.85);
  --safe-b: env(safe-area-inset-bottom, 0px); --safe-t: env(safe-area-inset-top, 0px);
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: var(--font); color: var(--ink); background: var(--bg); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; overflow: hidden; }
.bg { position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background: radial-gradient(900px 560px at 20% -10%, rgba(10,132,255,.12), transparent 60%),
              radial-gradient(800px 520px at 85% -8%, rgba(191,90,242,.07), transparent 58%), var(--bg); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
input, select, textarea { width: 100%; background: rgba(255,255,255,.06); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 12px 14px; outline: none; transition: border-color .2s var(--ease), background .2s; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); background: rgba(255,255,255,.08); }
textarea { resize: none; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.primary { background: var(--accent); color: #fff; border-radius: 999px; padding: 13px 20px; font-weight: 600; transition: transform .2s var(--ease), filter .2s; }
.primary:active { transform: scale(.97); } .primary:hover { filter: brightness(1.08); }
.primary.sm, .ghost.sm { padding: 9px 16px; font-size: 14px; }
.ghost { border: 1px solid var(--line-2); border-radius: 999px; padding: 12px 18px; color: var(--ink); background: var(--glass-2); }
.ghost.danger { color: var(--rose); border-color: rgba(255,69,58,.35); }
.icon { width: 40px; height: 40px; border-radius: 50%; background: var(--glass-2); border: 1px solid var(--line); font-size: 20px; line-height: 1; }
.fine { font-size: 12.5px; color: var(--faint); }
.err { color: var(--rose); font-size: 13.5px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: rgba(10,132,255,.16); color: #8ec2ff; font-size: 12px; font-weight: 600; }

/* screens */
.screen { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; padding: 20px; }
.card { background: var(--panel); backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.login { width: 100%; max-width: 380px; padding: 28px 24px 22px; display: flex; flex-direction: column; gap: 14px; animation: rise .5s var(--ease); }
@keyframes rise { from { opacity: 0; transform: translateY(14px) } to { opacity: 1; transform: none } }
.mark { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .14em; font-size: 12px; color: var(--muted); }
.mark .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 14px var(--accent); }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.02em; line-height: 1.15; }
.sub { color: var(--muted); font-size: 14px; margin-top: -6px; }

/* app frame */
.app { flex-direction: column; align-items: stretch; justify-content: flex-start; padding: 0; }
.top { display: flex; align-items: center; gap: 12px; padding: calc(10px + var(--safe-t)) 16px 8px; }
.who { flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; font-weight: 600; }
.who span:first-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabs { display: flex; gap: 4px; padding: 0 12px 8px; }
.tab { flex: 1; padding: 9px 8px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: 14px; transition: background .2s, color .2s; }
.tab.on { background: var(--glass-2); color: var(--ink); border: 1px solid var(--line); }
.pane { display: none; flex: 1; min-height: 0; flex-direction: column; }
.pane.on { display: flex; }

/* thread */
.thread { flex: 1; overflow-y: auto; padding: 8px 14px 12px; display: flex; flex-direction: column; gap: 10px; -webkit-overflow-scrolling: touch; }
.hello { margin: auto 0; text-align: center; padding: 24px 8px; color: var(--muted); }
.hello h2 { color: var(--ink); font-size: 24px; margin-bottom: 6px; }
.starters { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin-top: 16px; }
.starters button { border: 1px solid var(--line-2); background: var(--glass-2); border-radius: 999px; padding: 8px 14px; font-size: 13.5px; color: var(--ink); }
.msg { max-width: 86%; padding: 11px 14px; border-radius: 18px; white-space: pre-wrap; word-wrap: break-word; animation: rise .35s var(--ease); }
.msg.user { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 6px; }
.msg.nova { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.nova.thinking { color: var(--muted); }
.msg.nova.thinking::after { content: '…'; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .3 } }
.sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.sources span { font-size: 11.5px; padding: 3px 9px; border-radius: 999px; background: rgba(191,90,242,.14); color: #d7a7ff; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 8px 12px calc(10px + var(--safe-b)); border-top: 1px solid var(--line); background: rgba(0,0,0,.6); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.composer textarea { max-height: 140px; border-radius: 20px; padding: 11px 14px; line-height: 1.4; }
.send { width: 42px; height: 42px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 20px; font-weight: 700; flex: none; }
.send:disabled { opacity: .4; }

/* search */
.searchbar { display: flex; gap: 8px; padding: 6px 14px 10px; }
.results { flex: 1; overflow-y: auto; padding: 0 14px calc(14px + var(--safe-b)); display: flex; flex-direction: column; gap: 10px; }
.result { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.result h3 { font-size: 15px; margin-bottom: 4px; }
.result .kind { font-size: 11px; color: var(--violet); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.result p { color: var(--muted); font-size: 13.5px; white-space: pre-wrap; max-height: 9.5em; overflow: hidden; }
.result.open p { max-height: none; }

/* live */
.livehead { display: flex; align-items: center; justify-content: space-between; padding: 6px 16px 10px; }
.livehead h2 { font-size: 20px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 0 14px; overflow-y: auto; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.tile .k { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile .v { font-size: 24px; font-weight: 700; letter-spacing: -.02em; font-family: var(--mono); margin-top: 2px; }
.tile .v.stale { color: var(--faint); }
.tile .co { font-size: 11px; color: var(--faint); text-transform: uppercase; letter-spacing: .08em; margin-top: 4px; }
.pane[data-pane="live"] .fine { padding: 10px 16px calc(14px + var(--safe-b)); }

/* admin */
.admin { flex: 1; overflow-y: auto; padding: 4px 14px calc(20px + var(--safe-b)); display: flex; flex-direction: column; gap: 12px; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.stats div { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 10px; text-align: center; }
.stats b { display: block; font-size: 20px; font-family: var(--mono); }
.stats span { font-size: 11px; color: var(--muted); }
.block { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 12px 14px; }
.block summary { font-weight: 700; cursor: pointer; padding: 2px 0 8px; list-style: none; }
.block summary::before { content: '▸ '; color: var(--faint); } .block[open] summary::before { content: '▾ '; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.grid textarea, .grid .check, .grid button { grid-column: 1 / -1; }
.check { flex-direction: row; align-items: center; gap: 8px; } .check input { width: auto; }
.temp { background: rgba(48,209,88,.12); border: 1px solid rgba(48,209,88,.35); border-radius: var(--r-sm); padding: 10px 12px; font-family: var(--mono); font-size: 13.5px; word-break: break-all; margin-bottom: 10px; }
.list { display: flex; flex-direction: column; gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--glass-2); font-size: 14px; }
.row .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row small { color: var(--faint); }
.row .off { color: var(--rose); }
.row button { font-size: 12.5px; color: var(--accent); }
.row button.danger { color: var(--rose); }

/* sheet */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheetcard { width: 100%; max-width: 480px; background: var(--panel); backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px); border: 1px solid var(--line); border-radius: 22px 22px 0 0; padding: 18px 16px calc(18px + var(--safe-b)); display: flex; flex-direction: column; gap: 8px; animation: up .35s var(--ease); }
@keyframes up { from { transform: translateY(40px); opacity: 0 } to { transform: none; opacity: 1 } }
@media (min-width: 720px) {
  .app { max-width: 820px; margin: 0 auto; }
  .msg { max-width: 72%; }
  .stats { grid-template-columns: repeat(4, 1fr); }
}
