@font-face { font-family: 'Playfair'; src: url('/assets/playfair-700.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --bg: #0B0F19; --bg2: #111727; --card: #151C2E; --card2: #1B2338; --line: #263049;
  --text: #E9ECF3; --muted: #9AA3B8; --faint: #6B7590;
  --gold: #D4AF62; --gold2: #F1D898; --gold-ink: #1A1408;
  --ok: #4CC38A; --warn: #E8B04A; --bad: #EF6A6A; --blue: #6EA8FE;
  --radius: 14px; --shadow: 0 10px 30px rgba(0,0,0,.35);
  --serif: 'Playfair', 'Georgia', serif;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #F6F4EF; --bg2: #EEEBE3; --card: #FFFFFF; --card2: #F8F6F1; --line: #E3DED2;
  --text: #1B2030; --muted: #5E667A; --faint: #8D93A3; --gold: #A9822F; --gold2: #C9A04E; --gold-ink: #FFF8E6;
  --shadow: 0 8px 24px rgba(30,30,50,.08); color-scheme: light;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #F6F4EF; --bg2: #EEEBE3; --card: #FFFFFF; --card2: #F8F6F1; --line: #E3DED2;
    --text: #1B2030; --muted: #5E667A; --faint: #8D93A3; --gold: #A9822F; --gold2: #C9A04E; --gold-ink: #FFF8E6;
    --shadow: 0 8px 24px rgba(30,30,50,.08); color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--sans); -webkit-font-smoothing: antialiased; }
a { color: var(--gold); text-decoration: none; }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: .2px; margin: 0 0 .4em; }
h1 { font-size: 30px; } h2 { font-size: 21px; } h3 { font-size: 16px; font-family: var(--sans); font-weight: 650; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); } .faint { color: var(--faint); } .small { font-size: 13px; } .tiny { font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack > * + * { margin-top: 12px; }
.hidden { display: none !important; }

/* layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.side { background: var(--bg2); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.brand img { width: 34px; height: 34px; border-radius: 9px; }
.brand b { font-family: var(--serif); font-size: 22px; letter-spacing: .5px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 10px; color: var(--muted); font-weight: 500; }
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.on { background: var(--card2); color: var(--text); box-shadow: inset 2px 0 0 var(--gold); }
.nav .ico { width: 20px; text-align: center; opacity: .9; }
.nav .badge { margin-left: auto; }
.nav .sep { height: 1px; background: var(--line); margin: 10px 6px; }
.side .foot { margin-top: auto; padding: 10px; font-size: 12px; color: var(--faint); }
main { padding: 28px 34px 80px; max-width: 1180px; width: 100%; }
.topbar { display: none; }

/* cards */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card.pad-lg { padding: 24px; }
.grid { display: grid; gap: 14px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.stat .v { font-family: var(--serif); font-size: 28px; line-height: 1.1; }
.stat .l { color: var(--muted); font-size: 12.5px; text-transform: uppercase; letter-spacing: .8px; }
.brief { white-space: pre-wrap; font-size: 15.5px; }
.gold-rule { height: 2px; width: 44px; background: linear-gradient(90deg, var(--gold), transparent); border-radius: 2px; margin: 6px 0 14px; }

/* chart */
.bars { display: flex; align-items: flex-end; gap: 5px; height: 90px; padding-top: 6px; }
.bars .b { flex: 1; background: linear-gradient(180deg, var(--gold2), var(--gold)); border-radius: 4px 4px 2px 2px; min-height: 2px; opacity: .9; position: relative; }
.bars .b.zero { background: var(--line); }
.bars .b:hover::after { content: attr(data-t); position: absolute; bottom: 100%; left: 50%; transform: translate(-50%, -4px); background: var(--card2); border: 1px solid var(--line); padding: 2px 7px; border-radius: 6px; font-size: 11.5px; white-space: nowrap; color: var(--text); }

/* forms */
input, textarea, select { width: 100%; background: var(--bg2); border: 1px solid var(--line); color: var(--text); border-radius: 10px; padding: 10px 12px; font: inherit; outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--gold); box-shadow: 0 0 0 3px color-mix(in srgb, var(--gold) 22%, transparent); }
textarea { resize: vertical; min-height: 80px; }
label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px; font-weight: 500; }
.field { margin-bottom: 14px; }
.hint { font-size: 12.5px; color: var(--faint); margin-top: 5px; }
input[type=checkbox] { width: auto; accent-color: var(--gold); }
input[type=range] { padding: 0; accent-color: var(--gold); background: none; border: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 8px 0; cursor: pointer; }
.check input { margin-top: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line); background: var(--card2); color: var(--text); padding: 9px 15px; border-radius: 10px; font: 600 14px var(--sans); cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--gold); }
.btn.primary { background: linear-gradient(180deg, var(--gold2), var(--gold)); color: #1A1408; border-color: transparent; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.iconbtn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 4px 6px; border-radius: 6px; font-size: 15px; }
.iconbtn:hover { color: var(--text); background: var(--card2); }

.badge { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--card2); border: 1px solid var(--line); color: var(--muted); font-weight: 600; letter-spacing: .2px; }
.badge.gold { color: var(--gold); border-color: color-mix(in srgb, var(--gold) 45%, transparent); }
.badge.ok { color: var(--ok); } .badge.warn { color: var(--warn); } .badge.bad { color: var(--bad); }
.pill-count { background: var(--gold); color: #1A1408; border-radius: 99px; font-size: 11px; padding: 1px 7px; font-weight: 700; }

/* lists */
.list { display: flex; flex-direction: column; gap: 10px; }
.item { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.item .meta { font-size: 12.5px; color: var(--faint); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.item .body { white-space: pre-wrap; margin: 6px 0 2px; word-wrap: break-word; }
.item .raw { font-size: 13px; color: var(--faint); border-left: 2px solid var(--line); padding-left: 10px; margin-top: 8px; white-space: pre-wrap; }
.item .acts { display: flex; gap: 2px; margin-left: auto; }
.empty { text-align: center; color: var(--faint); padding: 40px 10px; }
table { width: 100%; border-collapse: collapse; }
td, th { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .7px; font-weight: 600; }

/* tabs */
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; color: var(--muted); padding: 10px 12px; font: 600 14px var(--sans); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--gold); }

/* chat */
.chat { display: flex; flex-direction: column; gap: 12px; min-height: 320px; }
.msg { max-width: 78%; padding: 11px 14px; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: var(--card2); border: 1px solid var(--line); border-bottom-right-radius: 4px; }
.msg.al { align-self: flex-start; background: color-mix(in srgb, var(--gold) 10%, var(--card)); border: 1px solid color-mix(in srgb, var(--gold) 30%, var(--line)); border-bottom-left-radius: 4px; }
.msg .tools { font-size: 12px; color: var(--faint); margin-top: 6px; }
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 12px 0 4px; display: flex; gap: 8px; }

/* capture */
.capture { text-align: center; padding: 30px 10px; }
.mic { width: 116px; height: 116px; border-radius: 50%; border: 0; cursor: pointer; background: radial-gradient(circle at 35% 30%, var(--gold2), var(--gold) 60%, #8a6a27); color: #1A1408; font-size: 40px; box-shadow: 0 10px 40px color-mix(in srgb, var(--gold) 35%, transparent); transition: transform .15s; }
.mic:active { transform: scale(.96); }
.mic.rec { animation: pulse 1.3s infinite; background: radial-gradient(circle at 35% 30%, #ff9b9b, #e5484d 60%, #a2262a); color: #fff; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(229,72,77,.5); } 70% { box-shadow: 0 0 0 26px rgba(229,72,77,0); } 100% { box-shadow: 0 0 0 0 rgba(229,72,77,0); } }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 4px; gap: 4px; }
.seg button { background: none; border: 0; color: var(--muted); padding: 8px 14px; border-radius: 9px; font: 600 14px var(--sans); cursor: pointer; }
.seg button.on { background: var(--card2); color: var(--text); box-shadow: 0 1px 0 var(--line); }
.result { text-align: left; margin-top: 22px; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 600px at 50% -10%, color-mix(in srgb, var(--gold) 12%, transparent), transparent), var(--bg); }
.auth .card { width: 100%; max-width: 400px; padding: 30px; box-shadow: var(--shadow); }
.auth .logo { width: 72px; height: 72px; border-radius: 18px; display: block; margin: 0 auto 14px; box-shadow: var(--shadow); }
.auth h1 { text-align: center; font-size: 34px; margin-bottom: 4px; }
.auth .sub { text-align: center; color: var(--muted); margin-bottom: 22px; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--card2); border: 1px solid var(--line); color: var(--text); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 99; font-weight: 500; max-width: calc(100% - 32px); }
.toast.err { border-color: var(--bad); }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; vertical-align: -3px; }
@keyframes spin { to { transform: rotate(360deg); } }
.kbd { font: 600 12px ui-monospace, Menlo, monospace; background: var(--card2); border: 1px solid var(--line); border-bottom-width: 2px; padding: 1px 6px; border-radius: 5px; }
code { font: 13px ui-monospace, Menlo, monospace; background: var(--bg2); padding: 1px 5px; border-radius: 5px; }
.callout { border: 1px solid color-mix(in srgb, var(--gold) 40%, var(--line)); background: color-mix(in srgb, var(--gold) 7%, var(--card)); border-radius: 12px; padding: 14px 16px; }

@media (max-width: 900px) {
  .g4, .g5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; inset: 0 30% 0 0; z-index: 50; transform: translateX(-105%); transition: transform .2s; height: 100%; box-shadow: var(--shadow); }
  .side.open { transform: none; }
  .topbar { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 40; }
  .topbar img { width: 28px; height: 28px; border-radius: 7px; }
  .topbar b { font-family: var(--serif); font-size: 19px; }
  main { padding: 18px 16px 90px; }
  .g2 { grid-template-columns: 1fr; }
  h1 { font-size: 25px; }
  .msg { max-width: 92%; }
}
