/* Nova — StudyForClasses.space */
:root {
  --bg: #090b15;
  --bg-2: #0e1122;
  --panel: #13172e;
  --panel-2: #1a1f3d;
  --panel-3: #222852;
  --line: rgba(255, 255, 255, 0.08);
  --line-2: rgba(255, 255, 255, 0.14);
  --text: #eceefa;
  --muted: #9aa0c6;
  --faint: #8a90b8;
  --accent: #8b7bff;
  --accent-2: #4cc3ff;
  --accent-ink: #0b0d1a;
  --good: #3ddc97;
  --warn: #ffb547;
  --bad: #ff6b81;
  --user-bubble: #262c58;
  --code-bg: #0b0e1d;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --radius-sm: 10px;
  --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
  --grad: linear-gradient(135deg, var(--accent), var(--accent-2));
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #f5f6fb;
  --bg-2: #ffffff;
  --panel: #ffffff;
  --panel-2: #f1f3fb;
  --panel-3: #e6e9f7;
  --line: rgba(15, 25, 70, 0.1);
  --line-2: rgba(15, 25, 70, 0.18);
  --text: #151933;
  --muted: #5b6290;
  --faint: #62688e;
  --accent: #6a54ff;
  --accent-2: #0a74b4;
  --accent-ink: #ffffff;
  --good: #0e7f52;
  --warn: #9a5700;
  --bad: #c4243f;
  --user-bubble: #e9ecff;
  --code-bg: #f6f8fc;
  --shadow: 0 10px 40px rgba(20, 30, 80, 0.15);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
:root:not([data-theme="light"]) body {
  background:
    radial-gradient(1px 1px at 12% 18%, rgba(255,255,255,.55), transparent 60%),
    radial-gradient(1px 1px at 72% 12%, rgba(255,255,255,.4), transparent 60%),
    radial-gradient(1.5px 1.5px at 88% 64%, rgba(255,255,255,.35), transparent 60%),
    radial-gradient(1px 1px at 33% 82%, rgba(255,255,255,.35), transparent 60%),
    radial-gradient(1px 1px at 55% 46%, rgba(255,255,255,.25), transparent 60%),
    radial-gradient(900px 500px at 85% -10%, rgba(139,123,255,.14), transparent 70%),
    radial-gradient(800px 500px at -10% 110%, rgba(76,195,255,.10), transparent 70%),
    var(--bg);
}
a { color: var(--accent-2); }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- app shell ---------- */
.app { display: grid; grid-template-columns: 276px 1fr; height: var(--app-h, 100dvh); }
.sidebar {
  display: flex; flex-direction: column; gap: 6px;
  padding: 14px 12px; min-height: 0;
  background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 6px 10px; text-decoration: none; color: var(--text); }
.brand-logo { width: 34px; height: 34px; flex: none; }
.brand-name { font-weight: 800; font-size: 19px; letter-spacing: -.01em; line-height: 1.1; }
.brand-sub { display: block; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--text); text-decoration: none; font-size: 14.5px;
  border: 0; background: none; text-align: left; width: 100%;
}
.side-link:hover { background: var(--panel-2); }
.side-link.active { background: var(--panel-3); }
.side-link svg { width: 18px; height: 18px; flex: none; opacity: .85; }
.side-label { font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 12px 10px 4px; }
.chat-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 1px; min-height: 60px; margin: 0 -4px; padding: 0 4px; }
.chat-item { display: flex; align-items: center; border-radius: var(--radius-sm); }
.chat-item a { flex: 1; min-width: 0; padding: 7px 10px; color: var(--text); text-decoration: none; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item:hover, .chat-item.active { background: var(--panel-2); }
.chat-item .del { opacity: 0; border: 0; background: none; color: var(--muted); padding: 4px 8px; border-radius: 8px; }
.chat-item:hover .del, .chat-item.active .del { opacity: 1; }
.chat-item .del:hover { color: var(--bad); }
.chat-empty { color: var(--faint); font-size: 13.5px; padding: 6px 10px; }
.side-foot { border-top: 1px solid var(--line); padding-top: 8px; display: flex; flex-direction: column; gap: 2px; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; min-height: 56px;
  border-bottom: 1px solid var(--line);
}
.topbar .spacer { flex: 1; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.menu-btn { display: none; }
.model-pill {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 7px 14px 7px 12px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text);
  font-size: 14px; font-weight: 600; max-width: min(460px, 70vw); position: relative; overflow: hidden;
}
.model-pill .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex: none; }
.model-pill[data-state="ready"] .dot { background: var(--good); box-shadow: 0 0 10px var(--good); }
.model-pill[data-state="loading"] .dot { background: var(--warn); animation: pulse 1s infinite; }
.model-pill[data-state="error"] .dot { background: var(--bad); }
.model-pill .pill-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.model-pill .caret { opacity: .6; }
.model-pill .fill { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--grad); width: 0; transition: width .3s; }
@keyframes pulse { 50% { opacity: .35; } }
.view { flex: 1; min-height: 0; overflow-y: auto; position: relative; }
.view.no-scroll { overflow: hidden; display: flex; flex-direction: column; }

.scrim { display: none; }

/* ---------- buttons, fields, cards (shared by every tool) ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 11px; border: 1px solid var(--line-2);
  background: var(--panel-2); color: var(--text); font-weight: 600; font-size: 14.5px;
  text-decoration: none; transition: transform .08s, background .15s, border-color .15s; white-space: nowrap;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn.primary { background: var(--grad); color: var(--accent-ink); border-color: transparent; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 6px 11px; font-size: 13.5px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn svg { width: 17px; height: 17px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .label { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.input, .textarea, .select {
  width: 100%; padding: 10px 12px; border-radius: 11px;
  border: 1px solid var(--line-2); background: var(--bg-2); color: var(--text); outline: 2px solid transparent; outline-offset: 2px;
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent); }
.textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
.hint { font-size: 12.5px; color: var(--faint); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; }
.card + .card { margin-top: 14px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--panel); font-size: 13px; font-weight: 600; color: var(--muted); }
button.chip:hover { color: var(--text); border-color: var(--accent); }
.chip.on { color: var(--text); border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--panel)); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 700; background: var(--panel-3); color: var(--muted); }
.badge.good { background: color-mix(in srgb, var(--good) 18%, transparent); color: var(--good); }
.badge.accent { background: color-mix(in srgb, var(--accent) 22%, transparent); color: var(--accent); }
.badge.warn { background: color-mix(in srgb, var(--warn) 20%, transparent); color: var(--warn); }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--panel-2); border: 1px solid var(--line); }
.seg button { border: 0; background: none; padding: 5px 12px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--muted); }
.seg button.on { background: var(--panel); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.progress { height: 8px; border-radius: 999px; background: var(--panel-3); overflow: hidden; }
.progress > i { display: block; height: 100%; width: 0; background: var(--grad); border-radius: inherit; transition: width .3s; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty .big { font-size: 40px; line-height: 1; margin-bottom: 8px; }
.spinner { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid var(--line-2); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.working { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 14px; }

/* ---------- tool pages ---------- */
.tool { max-width: 880px; margin: 0 auto; padding: 26px 20px 60px; }
.tool-head { margin-bottom: 20px; }
.tool-head h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.02em; display: flex; align-items: center; gap: 10px; }
.tool-head .sub { margin: 0; color: var(--muted); }
.tool :is(h1, h2, h3, h4) > svg { width: 1em; height: 1em; flex: none; color: var(--accent); }
.tool h2 { font-size: 18px; margin: 0 0 10px; }
.tool h3 { font-size: 16px; margin: 0 0 8px; }

/* ---------- chat ---------- */
.chat { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.thread { flex: 1; overflow-y: auto; padding: 24px 16px 12px; scroll-behavior: auto; }
.thread-inner { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.msg { display: flex; gap: 12px; min-width: 0; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
  max-width: min(620px, 85%); padding: 10px 15px; border-radius: 18px 18px 6px 18px;
  background: var(--user-bubble); white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.msg.user .msg-col { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; min-width: 0; max-width: 100%; }
.msg.user .edit-box { width: min(620px, 92vw); display: flex; flex-direction: column; gap: 8px; }
.avatar { width: 30px; height: 30px; border-radius: 9px; flex: none; display: grid; place-items: center; background: var(--grad); margin-top: 2px; }
.avatar svg { width: 18px; height: 18px; }
.msg.ai .body { flex: 1; min-width: 0; }
.msg-actions { display: flex; gap: 2px; opacity: 0; transition: opacity .15s; }
.msg:hover .msg-actions, .msg.last .msg-actions { opacity: 1; }
.msg.live .msg-actions { display: none; }
.msg-actions button { border: 0; background: none; color: var(--faint); font-size: 12.5px; padding: 4px 8px; border-radius: 7px; display: inline-flex; align-items: center; gap: 5px; }
.msg-actions button:hover { color: var(--text); background: var(--panel-2); }
.msg-actions svg { width: 14px; height: 14px; }
.msg-meta { font-size: 12px; color: var(--faint); margin-top: 6px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.msg-error { color: var(--bad); background: color-mix(in srgb, var(--bad) 10%, transparent); border: 1px solid color-mix(in srgb, var(--bad) 35%, transparent); padding: 10px 12px; border-radius: 10px; font-size: 14px; }
.typing { display: inline-flex; gap: 4px; padding: 8px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: bob 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes bob { 0%, 80%, 100% { transform: translateY(0); opacity: .4; } 40% { transform: translateY(-5px); opacity: 1; } }

details.thinking { margin-bottom: 10px; border-left: 2px solid var(--line-2); padding-left: 12px; }
details.thinking summary { cursor: pointer; color: var(--muted); font-size: 13.5px; font-weight: 600; list-style: none; display: inline-flex; align-items: center; gap: 6px; }
details.thinking summary::-webkit-details-marker { display: none; }
details.thinking summary::before { content: "›"; display: inline-block; transition: transform .15s; font-size: 16px; }
details.thinking[open] summary::before { transform: rotate(90deg); }
.think-text { color: var(--faint); font-size: 13.5px; white-space: pre-wrap; margin-top: 6px; max-height: 320px; overflow-y: auto; }

.composer { padding: 8px 16px 14px; }
.composer-box {
  max-width: 780px; margin: 0 auto; background: var(--panel); border: 1px solid var(--line-2);
  border-radius: 20px; padding: 10px 10px 8px 14px; box-shadow: var(--shadow);
}
.composer-box:focus-within { border-color: color-mix(in srgb, var(--accent) 60%, var(--line-2)); }
.composer textarea {
  width: 100%; border: 0; outline: 2px solid transparent; background: none; resize: none; padding: 4px 2px;
  max-height: 260px; min-height: 28px; line-height: 1.5; font-size: 15.5px;
}
.composer-bar { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.composer-bar .left { display: flex; align-items: center; gap: 8px; flex: 1; flex-wrap: wrap; min-width: 0; }
.send-btn { width: 38px; height: 38px; border-radius: 12px; border: 0; background: var(--grad); color: var(--accent-ink); display: grid; place-items: center; flex: none; }
.send-btn:disabled { opacity: .35; cursor: not-allowed; }
.send-btn svg { width: 19px; height: 19px; }
.send-btn.stop { background: var(--panel-3); color: var(--text); }
.fine { text-align: center; font-size: 12px; color: var(--faint); margin: 8px 0 0; }

.welcome { max-width: 780px; margin: 0 auto; padding: 6vh 0 10px; text-align: center; }
.welcome .orb { width: 64px; height: 64px; margin: 0 auto 14px; }
.welcome h1 { font-size: 30px; letter-spacing: -.02em; margin: 0 0 6px; }
.welcome p { color: var(--muted); margin: 0 auto 22px; max-width: 520px; }
.suggestions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; text-align: left; }
.suggestion { border: 1px solid var(--line); background: var(--panel); border-radius: 14px; padding: 12px 14px; color: var(--text); font-size: 14px; }
.suggestion:hover { border-color: var(--accent); }
.suggestion b { display: block; font-size: 13px; color: var(--muted); margin-bottom: 2px; font-weight: 600; }

/* ---------- rendered markdown ---------- */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md table { margin: 0 0 12px; }
.md ul, .md ol { padding-left: 24px; }
.md li { margin: 3px 0; }
.md h1, .md h2, .md h3, .md h4 { margin: 18px 0 8px; line-height: 1.3; letter-spacing: -.01em; }
.md h1 { font-size: 1.45em; } .md h2 { font-size: 1.25em; } .md h3 { font-size: 1.1em; } .md h4 { font-size: 1em; }
.md blockquote { border-left: 3px solid var(--accent); padding: 2px 0 2px 14px; color: var(--muted); }
.md hr { border: 0; border-top: 1px solid var(--line-2); margin: 18px 0; }
.md table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; font-size: 14.5px; }
.md th, .md td { border: 1px solid var(--line-2); padding: 7px 11px; text-align: left; }
.md th { background: var(--panel-2); }
.md :not(pre) > code { font-family: var(--mono); font-size: .88em; background: var(--panel-2); border: 1px solid var(--line); padding: 1px 6px; border-radius: 6px; }
.md a { word-break: break-word; }
.code-block { margin: 0 0 14px; border: 1px solid var(--line-2); border-radius: 12px; overflow: hidden; background: var(--code-bg); }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 5px 8px 5px 14px; background: var(--panel-2); border-bottom: 1px solid var(--line); }
.code-lang { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.code-acts { display: flex; gap: 4px; }
.code-btn { border: 0; background: none; color: var(--muted); font-size: 12.5px; font-weight: 600; padding: 4px 9px; border-radius: 7px; }
.code-btn:hover { color: var(--text); background: var(--panel-3); }
.code-block pre { margin: 0; padding: 14px; overflow-x: auto; }
.code-block code { font-family: var(--mono); font-size: 13.5px; line-height: 1.55; background: none !important; padding: 0 !important; }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.katex { font-size: 1.08em; }
details.answer-reveal { margin: 12px 0; border: 1px dashed var(--accent); border-radius: 12px; padding: 10px 14px; background: color-mix(in srgb, var(--accent) 7%, transparent); }
details.answer-reveal summary { cursor: pointer; font-weight: 700; color: var(--accent); }
details.answer-reveal[open] summary { margin-bottom: 8px; }
.answer-pending { color: var(--faint); font-style: italic; font-size: 14px; }

/* ---------- modal + toast ---------- */
.modal-wrap { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(4, 6, 16, .62); backdrop-filter: blur(3px); animation: fade .15s; }
.modal { width: min(720px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--bg-2); border: 1px solid var(--line-2); border-radius: 18px; box-shadow: var(--shadow); }
.modal.wide { width: min(1100px, 100%); height: calc(100dvh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg-2); z-index: 1; }
.modal-head h2 { margin: 0; font-size: 18px; flex: 1; }
.modal-body { padding: 16px 18px 20px; }
.modal.wide .modal-body { flex: 1; padding: 0; min-height: 0; }
.preview-frame { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
@keyframes fade { from { opacity: 0; } }
#toasts { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(480px, calc(100vw - 32px)); }
.toast { background: var(--panel-3); color: var(--text); border: 1px solid var(--line-2); padding: 10px 16px; border-radius: 12px; box-shadow: var(--shadow); font-size: 14px; animation: fade .2s; pointer-events: auto; }
.toast.warn { border-color: var(--warn); }
.toast.bad { border-color: var(--bad); }
.toast.good { border-color: var(--good); }

/* model picker */
.gpu-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; font-size: 13.5px; color: var(--muted); margin-bottom: 14px; }
.gpu-line svg, .chip svg, .code-btn svg { width: 16px; height: 16px; flex: none; }
.brand-logo svg, .orb svg { width: 100%; height: 100%; display: block; }
.model-list { display: flex; flex-direction: column; gap: 10px; }
.model-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px; background: var(--panel); display: grid; grid-template-columns: 1fr auto; gap: 6px 14px; align-items: center; }
.model-card.current { border-color: var(--good); }
.model-card.rec { border-color: color-mix(in srgb, var(--accent) 70%, var(--line)); }
.model-card h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.model-card .base { font-size: 12.5px; color: var(--faint); font-weight: 500; }
.model-card p { margin: 0; font-size: 13.5px; color: var(--muted); }
.model-card .specs { font-size: 12.5px; color: var(--faint); }
.model-card .acts { display: flex; gap: 6px; grid-row: span 3; align-items: center; }
.model-card .prog { grid-column: 1 / -1; display: none; }
.model-card.loading .prog { display: block; }
.prog-text { font-size: 12px; color: var(--faint); margin-top: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notice { border: 1px solid var(--line-2); background: var(--panel); border-radius: 12px; padding: 12px 14px; font-size: 14px; color: var(--muted); }
.notice.warn { border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.notice.bad { border-color: color-mix(in srgb, var(--bad) 55%, transparent); color: var(--text); }
.notice b { color: var(--text); }

/* games */
.games-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; }
.game-card { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; background: var(--panel); color: var(--text); text-decoration: none; transition: transform .15s, border-color .15s, box-shadow .15s; }
.game-card:hover { transform: translateY(-2px); border-color: var(--accent); box-shadow: var(--shadow); }
.game-art svg { display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; }
.game-info { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.game-info h2 { margin: 0; font-size: 18px; }
.game-info p { margin: 0; color: var(--muted); font-size: 14px; flex: 1; }
.game-play { align-self: flex-start; }
.game-player { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.game-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.game-title { flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 10px; }
.game-title b { white-space: nowrap; }
.game-controls { font-size: 12.5px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-stage { flex: 1; min-height: 0; background: #000; }
.game-stage iframe { width: 100%; height: 100%; border: 0; display: block; }
@media (max-width: 560px) { .game-controls { display: none; } }

/* about page */
.prose { max-width: 720px; }
.prose h2 { margin-top: 26px; }
.prose li { margin: 4px 0; }

/* ---------- mobile ---------- */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: min(300px, 86vw); z-index: 40; transform: translateX(-102%); transition: transform .22s ease; background: var(--bg-2); }
  .app.nav-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .app.nav-open .scrim { display: block; position: fixed; inset: 0; z-index: 39; background: rgba(0,0,0,.45); }
  .menu-btn { display: inline-grid; }
  .topbar { padding: 8px 12px; }
  .suggestions { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .tool { padding: 18px 14px 50px; }
  .thread { padding: 16px 12px 8px; }
  .composer { padding: 6px 10px 10px; }
  .msg.user .bubble { max-width: 90%; }
  .avatar { display: none; }
  .model-card { grid-template-columns: 1fr; }
  .model-card .acts { grid-row: auto; order: 5; }
  .welcome { padding-top: 3vh; }
  .welcome h1 { font-size: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- touch, keyboard & small-screen polish ---------- */
html, body { overscroll-behavior: none; }
.thread, .chat-list, .view, .modal, .think-text { overscroll-behavior: contain; }
.msg:focus-within .msg-actions { opacity: 1; }
.chat-item .del { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; flex: none; }
.chat-item .del svg { width: 16px; height: 16px; }
.chat-item:focus-within .del { opacity: 1; }
.md table { overflow-wrap: normal; word-break: normal; }
.md th, .md td { min-width: 6ch; }
.composer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
.topbar { padding-top: max(10px, env(safe-area-inset-top)); }
.sidebar { padding-top: max(14px, env(safe-area-inset-top)); padding-bottom: max(14px, env(safe-area-inset-bottom)); }
:root[data-theme="light"] .badge.good { color: var(--good); }
:root[data-theme="light"] .badge.warn { color: var(--warn); }

@media (hover: none) {
  .msg-actions { opacity: 1; }
  .chat-item .del { opacity: 1; }
  button.chip:hover { color: var(--muted); border-color: var(--line-2); }
  button.chip.on:hover { color: var(--text); border-color: var(--accent); }
  .suggestion:hover { border-color: var(--line); }
  .btn:hover { background: var(--panel-2); }
  .btn.primary:hover { background: var(--grad); filter: none; }
  .btn.ghost:hover { background: transparent; }
  .side-link:hover { background: none; }
  .side-link.active:hover { background: var(--panel-3); }
  .game-card:hover { transform: none; box-shadow: none; border-color: var(--line); }
}

@media (pointer: coarse) {
  .composer textarea, .input, .textarea, .select { font-size: 16px; }
  .msg-actions button, .code-btn { min-height: 40px; min-width: 40px; justify-content: center; }
  .seg button, .chip { min-height: 40px; }
  details.thinking summary, details.answer-reveal summary { min-height: 40px; display: flex; align-items: center; }
  .chat-item a { padding-top: 11px; padding-bottom: 11px; }
  .chat-item .del { width: 44px; height: 44px; }
}

@media (max-width: 860px) {
  .sidebar { visibility: hidden; transition: transform .22s ease, visibility 0s linear .22s; }
  .app.nav-open .sidebar { visibility: visible; transition: transform .22s ease; }
  .composer { padding-bottom: calc(10px + env(safe-area-inset-bottom)); padding-left: max(10px, env(safe-area-inset-left)); padding-right: max(10px, env(safe-area-inset-right)); }
}

@media (max-width: 560px) {
  .fine { font-size: 11px; margin-top: 4px; }
  .composer:focus-within .fine { display: none; }
}
