:root {
  --bg: #fbfaf8; --bg2: #f3f1ed; --bg3: #e9e6e0; --fg: #1d1c1a; --fg2: #5f5c55; --fg3: #8b887f;
  --line: #e2dfd8; --accent: #1d1c1a; --accent-fg: #fff; --brand: #d9703a; --good: #1f9d55; --warn: #b7791f; --danger: #d92d3f;
  --bar: #bcd7ea; --bar-top: #8fbfe0; --side: #f3f1ed; --card: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 8px 24px rgba(0,0,0,.06);
  --radius: 12px; --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --serif: "Newsreader", "Tiempos Headline", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme="dark"] {
  --bg: #262624; --bg2: #2c2b29; --bg3: #363532; --fg: #ece9e3; --fg2: #a9a69e; --fg3: #7b786f;
  --line: #3a3936; --accent: #ece9e3; --accent-fg: #1d1c1a; --brand: #e07b4a; --good: #3fb871; --warn: #d9a441;
  --bar: #14577f; --bar-top: #166a9c; --side: #262624; --card: #2a2927;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--fg); }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.app { display: grid; grid-template-columns: 240px 1fr; height: 100vh; height: 100dvh; }
.sidebar { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 14px 12px; gap: 6px; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; letter-spacing: -.02em; padding: 6px 8px 14px; text-decoration: none; }
.brand small { font-weight: 500; color: var(--fg3); font-size: 11px; display: block; letter-spacing: 0; margin-top: -2px; }
.nav-item { display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--fg2); font-weight: 500; }
.nav-item:hover { background: var(--bg3); color: var(--fg); }
.nav-item.active { background: var(--bg3); color: var(--fg); }
.nav-sep { height: 1px; background: var(--line); margin: 8px 6px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg3); padding: 8px 10px 4px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--fg3); }
.side-foot button { display: flex; gap: 10px; align-items: center; background: none; border: 0; padding: 8px 10px; border-radius: 10px; color: var(--fg2); text-align: left; }
.side-foot button:hover { background: var(--bg3); }
.main { overflow-y: auto; position: relative; }
.topbar-m { display: none; }

/* ---------- home / composer ---------- */
.home { max-width: 860px; margin: 0 auto; padding: 9vh 20px 60px; text-align: center; }
.home h1 { font-size: clamp(30px, 5vw, 46px); line-height: 1.1; letter-spacing: -.035em; margin: 0 0 12px; }
.home h1 em { font-style: normal; color: var(--brand); }
.home .sub { color: var(--fg2); font-size: 17px; margin: 0 auto 30px; max-width: 580px; }
.composer { background: var(--bg); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 12px 12px 10px 16px; display: flex; align-items: flex-end; gap: 10px; text-align: left; transition: border-color .15s; }
.composer:focus-within { border-color: var(--fg3); }
.composer textarea { flex: 1; resize: none; border: 0; outline: 0; background: transparent; min-height: 52px; max-height: 220px; padding: 8px 0; line-height: 1.5; }
.send { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--accent); color: var(--accent-fg); display: grid; place-items: center; flex: none; }
.send:disabled { opacity: .3; cursor: default; }
.composer-hint { color: var(--fg3); font-size: 12.5px; margin-top: 10px; }
.chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; margin-top: 30px; text-align: left; }
.chip { background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; transition: .15s; text-align: left; }
.chip:hover { border-color: var(--fg3); transform: translateY(-1px); box-shadow: var(--shadow); }
.chip .e { font-size: 22px; line-height: 1; }
.chip b { font-weight: 600; font-size: 14px; }
.chip span.c { color: var(--fg3); font-size: 12px; }
.section-title { margin: 34px 0 0; text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg3); }

/* ---------- battle ---------- */
.battle { display: flex; flex-direction: column; min-height: 100%; }
.battle-head { padding: 20px 24px 6px; display: flex; justify-content: flex-end; }
.prompt-bubble { max-width: 100%; min-width: 0; padding: 14px 18px; border: 1px solid var(--line); border-radius: 18px 18px 4px 18px; background: var(--bg2); white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.6; }
.pill { font-size: 12px; padding: 3px 9px; border-radius: 99px; background: var(--bg3); color: var(--fg2); white-space: nowrap; }
.panels { flex: 1; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 14px 24px; min-height: 0; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; background: var(--bg); min-height: 0; transition: border-color .2s, box-shadow .2s; }
.panel.winner { border-color: var(--good); box-shadow: 0 0 0 2px color-mix(in srgb, var(--good) 25%, transparent); }
.panel-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-bottom: 1px solid var(--line); background: var(--bg2); min-height: 48px; }
.panel-title { font-weight: 650; flex: 1; display: flex; align-items: center; gap: 8px; min-width: 0; }
.panel-title .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.crown { background: var(--good); color: #fff; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; }
.seg { display: inline-flex; background: var(--bg3); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 7px; display: flex; gap: 6px; align-items: center; font-size: 13px; color: var(--fg2); }
.seg button.on { background: var(--bg); color: var(--fg); box-shadow: 0 1px 2px rgba(0,0,0,.12); }
.icon-btn { border: 0; background: transparent; width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--fg2); }
.icon-btn:hover { background: var(--bg3); color: var(--fg); }
.panel-body { flex: 1; position: relative; min-height: 0; background: #fff; }
.panel-body iframe, .preview-frame { width: 100%; height: 100%; border: 0; background: #fff; display: block; }
.code-view { position: absolute; inset: 0; margin: 0; padding: 14px; overflow: auto; background: var(--bg2); font: 12.5px/1.55 var(--mono); white-space: pre-wrap; word-break: break-all; color: var(--fg); }
.gen-state { position: absolute; left: 12px; bottom: 12px; background: var(--bg); border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; font-size: 12.5px; color: var(--fg2); display: flex; align-items: center; gap: 8px; box-shadow: var(--shadow); }
.spinner { width: 13px; height: 13px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--brand); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.err-box { position: absolute; inset: 0; display: grid; place-content: center; gap: 12px; text-align: center; padding: 20px; background: var(--bg2); color: var(--fg2); }
.votebar { padding: 14px 24px 20px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.votes { display: grid; grid-template-columns: repeat(4, minmax(0, 190px)); gap: 10px; justify-content: center; width: 100%; }
.vbtn { border: 1px solid var(--line); background: var(--bg); border-radius: 12px; padding: 12px 10px; font-weight: 600; transition: .15s; }
.vbtn:hover:not(:disabled) { border-color: var(--fg); background: var(--bg2); }
.vbtn:disabled { opacity: .45; cursor: not-allowed; }
.vote-note { color: var(--fg3); font-size: 12.5px; }
.result-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; }
.btn { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 14px; font-weight: 550; display: inline-flex; gap: 8px; align-items: center; text-decoration: none; }
.btn:hover { background: var(--bg2); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.primary:hover { opacity: .88; }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--line)); }
.btn.good { color: var(--good); border-color: color-mix(in srgb, var(--good) 45%, var(--line)); }
.btn.sm { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 50; display: flex; flex-direction: column; padding: 18px; }
.overlay .bar { display: flex; justify-content: space-between; align-items: center; color: #fff; padding-bottom: 10px; font-weight: 600; }
.overlay iframe { flex: 1; border-radius: 12px; border: 0; background: #fff; }

/* ---------- pages ---------- */
.page { max-width: 1040px; margin: 0 auto; padding: 36px 24px 80px; }
.page h1 { font-size: 30px; letter-spacing: -.03em; margin: 0 0 6px; }
.page .lead { color: var(--fg2); margin: 0 0 22px; }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.input, select.input, textarea.input { border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: 8px 12px; outline: 0; width: 100%; }
.input:focus { border-color: var(--fg3); }
.toolbar .input { width: auto; min-width: 190px; }
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; background: var(--bg); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 14px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--fg3); font-weight: 600; background: var(--bg2); position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: var(--bg2); }
.rank { font-weight: 700; width: 56px; }
.rank-1 { color: #d19a00; } .rank-2 { color: #8c96a3; } .rank-3 { color: #b8743a; }
.muted { color: var(--fg3); }
.prelim { font-size: 11px; color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 40%, transparent); padding: 1px 6px; border-radius: 99px; margin-left: 8px; }
.score-bar { display: inline-block; height: 6px; border-radius: 3px; background: var(--brand); vertical-align: middle; margin-right: 8px; opacity: .85; }
.empty { padding: 50px 20px; text-align: center; color: var(--fg3); }
.posts { display: grid; gap: 14px; }
.post-card { display: block; text-decoration: none; border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; background: var(--bg); }
.post-card:hover { border-color: var(--fg3); box-shadow: var(--shadow); }
.post-card h3 { margin: 0 0 4px; font-size: 19px; letter-spacing: -.02em; }
.post-card p { margin: 6px 0 0; color: var(--fg2); }
.prose { font-size: 16.5px; line-height: 1.7; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 { letter-spacing: -.02em; margin: 1.6em 0 .4em; line-height: 1.25; }
.prose img { max-width: 100%; border-radius: 12px; }
.prose pre { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 14px; overflow: auto; font: 13px/1.5 var(--mono); }
.prose code { background: var(--bg3); padding: 1px 5px; border-radius: 5px; font: .9em var(--mono); }
.prose pre code { background: none; padding: 0; }
.prose blockquote { border-left: 3px solid var(--brand); margin: 1em 0; padding: 2px 16px; color: var(--fg2); }
.prose a { color: var(--brand); }

#toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 100; }
.toast { background: var(--fg); color: var(--bg); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow); max-width: 360px; font-size: 14px; }
.toast.err { background: var(--danger); color: #fff; }
.banned { max-width: 520px; margin: 20vh auto; text-align: center; padding: 20px; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 40; inset: 0 auto 0 0; width: 260px; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: var(--shadow); }
  .topbar-m { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--bg); z-index: 5; }
  .topbar-m button { background: none; border: 0; }
  .main { display: block; }
  .battle { height: auto; min-height: 100%; }
  .panels { flex: none; grid-template-columns: 1fr; padding: 12px; }
  .panel { height: 78vw; min-height: 340px; }
  .votes { grid-template-columns: 1fr 1fr; }
  .battle-head { padding: 12px 14px; }
  .votebar { padding: 12px; }
}

/* ======================= Arena-style overrides ======================= */
.app.collapsed { grid-template-columns: minmax(0, 1fr); }
.app.collapsed .sidebar { display: none; }
.sidebar { padding: 12px 8px 0; gap: 2px; }
.side-top { display: flex; align-items: center; justify-content: space-between; padding: 4px 8px 12px; }
.wordmark { font-family: var(--serif); font-size: 25px; letter-spacing: -.02em; display: flex; align-items: center; gap: 7px; text-decoration: none; color: var(--fg); line-height: 1; }
.wordmark svg { flex: none; }
.wordmark .chev { opacity: .6; width: 12px; }
.icon-btn.plain { color: var(--fg2); }
.nav-item { padding: 8px 8px; gap: 10px; font-size: 15px; border-radius: 8px; color: var(--fg); font-weight: 450; }
.nav-item svg { opacity: .85; }
.nav-item.active, .nav-item:hover { background: var(--bg3); }
button.nav-item { background: none; border: 0; width: 100%; text-align: left; }
.hist { flex: 1; overflow-y: auto; margin: 10px -8px 0; padding: 0 8px 8px; min-height: 80px; }
.hist-label { font-size: 12px; color: var(--fg2); padding: 14px 8px 6px; }
.hist-item { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; text-decoration: none; font-size: 14.5px; color: var(--fg); }
.hist-item:hover, .hist-item.active { background: var(--bg3); }
.hist-item i { font: 600 9px var(--mono); color: var(--fg3); flex: none; width: 14px; text-align: center; font-style: normal; }
.hist-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.promo { margin: 6px 0 8px; border: 1px solid var(--line); border-radius: 12px; padding: 8px; background: var(--card); }
.promo .cover { height: 78px; border-radius: 8px; background: linear-gradient(135deg, #5b3a29, #1f4a6b 60%, #2b6a5a); display: grid; place-items: center; font-size: 30px; }
.promo h4 { font-family: var(--serif); font-weight: 500; font-size: 18px; margin: 8px 2px 2px; line-height: 1.2; }
.promo p { font-size: 12px; color: var(--fg2); margin: 0 2px 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.promo a.go { display: block; text-align: center; background: #fff; color: #111; border-radius: 6px; padding: 7px; font-size: 12.5px; text-decoration: none; font-weight: 500; }
.promo button { width: 100%; margin-top: 6px; background: transparent; border: 1px solid var(--line); border-radius: 6px; padding: 6px; font-size: 12px; color: var(--fg2); }
.userbar { border-top: 1px solid var(--line); margin: 0 -8px; padding: 12px 16px; display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 16px; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: #4a6275; color: #fff; display: grid; place-items: center; font: 600 12px var(--font); flex: none; }
.legal { display: flex; gap: 16px; padding: 8px 16px 12px; font-size: 11px; color: var(--fg2); margin: 0 -8px; border-top: 1px solid var(--line); }
.legal span { cursor: default; }

/* home */
.home { padding-top: 24vh; max-width: 700px; }
.home h1 { text-wrap: balance; font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 5vw, 50px); letter-spacing: -.03em; color: var(--fg); margin-bottom: 26px; }
.home h1 em { font-style: italic; color: inherit; }
.composer { flex-direction: column; align-items: stretch; background: var(--bg2); border-radius: 14px; padding: 14px 14px 10px 16px; box-shadow: none; gap: 0; }
.composer textarea { min-height: 54px; padding: 0 0 8px; font-size: 15.5px; }
.composer .row { display: flex; align-items: center; gap: 6px; }
.pill-btn { display: inline-flex; align-items: center; gap: 7px; background: none; border: 0; color: var(--fg); padding: 6px 10px; border-radius: 8px; font-size: 14px; position: relative; }
.pill-btn:hover { background: var(--bg3); }
.pill-btn svg { opacity: .8; }
.send { border-radius: 8px; width: 34px; height: 34px; background: transparent; color: var(--fg2); border: 1px solid var(--line); margin-left: auto; }
.send:not(:disabled) { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.send:disabled { opacity: .7; }
.menu { position: absolute; bottom: 38px; left: 0; background: var(--card); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow); padding: 4px; min-width: 210px; z-index: 5; text-align: left; }
.menu div { padding: 8px 10px; border-radius: 6px; font-size: 14px; display: flex; justify-content: space-between; gap: 12px; }
.menu div small { color: var(--fg3); display: block; font-size: 12px; }
.menu div:hover { background: var(--bg3); }
.composer-hint { display: none; }
.started { text-align: left; font-size: 12.5px; color: var(--fg2); margin: 18px 0 8px; }
.chips { grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 0; }
.chip { flex-direction: row; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; background: transparent; }
.chip:hover { transform: none; box-shadow: none; background: var(--bg2); border-color: var(--line); }
.chip .e { width: 32px; height: 32px; border-radius: 6px; background: var(--bg3); display: grid; place-items: center; font-size: 16px; flex: none; }
.chip .t { min-width: 0; }
.chip b { display: block; font-size: 12.5px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip span.c { display: block; font-size: 10.5px; color: var(--fg2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* leaderboard top bar + layout */
.lb-top { position: sticky; top: 0; z-index: 10; background: var(--bg); border-bottom: 1px solid var(--line); display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 8px 14px; }
.lb-top .l { justify-self: start; display: flex; gap: 8px; align-items: center; }
.lb-top .r { justify-self: end; }
.lb-tabs { display: flex; gap: 6px; }
.lb-tab { padding: 6px 14px; border-radius: 8px; text-decoration: none; font-size: 14.5px; color: var(--fg); display: flex; align-items: center; gap: 6px; }
.lb-tab.on, .lb-tab:hover { background: var(--bg3); }
.lb-top .ov { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 8px; text-decoration: none; font-size: 14.5px; }
.lb-top .ov.on, .lb-top .ov:hover { background: var(--bg3); }
.btn.white { background: #fff; color: #111; border-color: #fff; font-size: 13px; padding: 7px 14px; border-radius: 6px; }
.lb-wrap { display: grid; grid-template-columns: 240px 1fr; min-height: calc(100% - 55px); }
.lb-wrap.nofilters { grid-template-columns: 0 1fr; }
.lb-wrap.nofilters .filters { display: none; }
.filters { border-right: 1px solid var(--line); padding: 14px 12px 40px; }
.f-group { border-bottom: 1px solid var(--line); padding: 8px 0 14px; margin-bottom: 8px; }
.f-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 6px; font-size: 15px; }
.f-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; text-decoration: none; font-size: 14px; }
.f-item:hover { background: var(--bg2); }
.f-item.on { background: var(--bg3); }
.f-item .ck { margin-left: auto; color: var(--good); }
.f-item small { margin-left: auto; color: var(--fg3); }
.seg2 { display: grid; grid-template-columns: 1fr; background: var(--bg2); padding: 3px; border-radius: 8px; margin: 6px 0; }
.seg2 span { text-align: center; padding: 6px; border-radius: 6px; background: var(--bg); font-size: 13.5px; }
.lb-main { padding: 28px 32px 60px; min-width: 0; }
.lb-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.lb-title h1 { font-family: var(--serif); font-weight: 400; font-size: 30px; margin: 0; letter-spacing: -.02em; }
.cat-pill { display: inline-flex; gap: 8px; align-items: center; background: var(--bg3); border-radius: 8px; padding: 6px 12px; font-size: 14px; }
.lb-desc { color: var(--fg2); margin: 12px 0 14px; font-size: 14.5px; }
.lb-meta { display: flex; gap: 18px; color: var(--fg2); font-size: 14px; flex-wrap: wrap; margin-bottom: 28px; }
.lb-bar { display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--line); padding: 14px 0 14px; }
.lb-bar .link { background: none; border: 0; color: var(--fg); display: flex; gap: 8px; align-items: center; font-size: 14px; padding: 4px 6px; border-radius: 6px; }
.lb-bar .link:hover { background: var(--bg2); }
.lb-bar input { background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; outline: 0; width: 220px; }
.lbt { border: 1px solid var(--line); border-radius: 10px; overflow: auto; background: var(--bg); }
.lbt table th { background: var(--bg2); font-size: 12px; text-transform: none; letter-spacing: 0; color: var(--fg); font-weight: 600; padding: 14px 16px; position: static; }
.lbt table td { padding: 14px 16px; border-bottom: 1px solid var(--line); }
.lbt td.c, .lbt th.c { text-align: center; }
.lbt .mname { font-family: var(--mono); font-size: 14px; }
.model-info-link { font-size: 12px; font-weight: 450; color: var(--fg2); text-decoration: none; white-space: nowrap; }
.model-info-link:hover { text-decoration: underline; color: inherit; }
.lbt .org { font-size: 12px; color: var(--fg2); margin-top: 2px; }
.lbt .spread { color: var(--fg2); font-variant-numeric: tabular-nums; }
.lbt .pm { color: var(--fg2); font-size: 12.5px; margin-left: 8px; }
.pre-pill { display: inline-flex; gap: 5px; align-items: center; border: 1px solid var(--line); background: var(--bg2); border-radius: 6px; padding: 3px 8px; font-size: 11px; margin-left: 10px; }
.lbt tbody tr:hover { background: var(--bg2); }

/* overview */
.ov-hero { display: grid; grid-template-columns: 1fr 1fr; gap: 60px; padding: 56px 40px 30px; max-width: 1280px; margin: 0 auto; }
.ov-hero h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(40px, 5vw, 64px); line-height: 1.04; letter-spacing: -.03em; margin: 0 0 22px; }
.ov-hero h1 em { font-style: italic; }
.ov-hero p { font-size: 19px; color: var(--fg); opacity: .85; max-width: 440px; line-height: 1.5; margin: 0 0 18px; }
.ov-count { display: flex; align-items: baseline; gap: 10px; }
.ov-count b { font-size: 26px; font-weight: 500; }
.ov-count span { color: var(--fg2); font-size: 14px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); display: inline-block; margin-right: 4px; }
.ov-news .lab { font-size: 11px; letter-spacing: .12em; color: var(--fg2); margin-bottom: 14px; }
.ov-news a { display: flex; align-items: center; gap: 16px; padding: 16px 0; border-bottom: 1px solid var(--line); text-decoration: none; }
.ov-news a:hover { background: var(--bg2); }
.ov-news a b { font-weight: 450; font-size: 19px; display: block; }
.ov-news a span { color: var(--fg2); font-size: 14px; }
.ov-news a .go { margin-left: auto; color: var(--fg2); }
.ov-card { max-width: 1200px; margin: 20px auto 60px; border: 1px solid var(--line); border-radius: 14px; padding: 22px 24px; }
.ov-card h3 { font-family: var(--serif); font-weight: 400; font-size: 24px; margin: 0 0 18px; display: flex; gap: 12px; align-items: center; }
.ov-card h3 .tag2 { font: 12px var(--font); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; background: var(--bg2); }
.top-row { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 8px; border-radius: 4px; background: var(--bar); overflow: hidden; font-size: 14.5px; }
.top-row .n { background: var(--bg); width: 22px; height: 22px; border-radius: 4px; display: grid; place-items: center; font-size: 12px; flex: none; position: relative; color: var(--fg); }
.top-row .fill { position: absolute; inset: 0 auto 0 0; background: var(--bar-top); }
.top-row > span, .top-row > b { position: relative; }
.top-row .v { margin-left: auto; color: #6ee7a0; font-size: 13.5px; position: relative; font-weight: 400; }
:root:not([data-theme="dark"]) .top-row .v { color: #0b6b36; }
.page h1 { font-family: var(--serif); font-weight: 400; font-size: 34px; }
.post-card h3 { font-family: var(--serif); font-weight: 500; }
.panel-head { background: var(--bg2); }
.vbtn { background: var(--bg2); }
.toast { background: var(--fg); color: var(--bg); }
.btn { background: var(--bg2); }
.btn.primary { background: var(--accent); }

@media (max-width: 1000px) {
  .ov-hero { grid-template-columns: 1fr; gap: 30px; padding: 30px 20px; }
  .chips { grid-template-columns: repeat(2, 1fr); }
  .lb-wrap { grid-template-columns: 1fr; }
  .filters { border-right: 0; border-bottom: 1px solid var(--line); }
  .lb-main { padding: 20px 16px 50px; }
  .lb-top { grid-template-columns: auto 1fr auto; }
}
@media (max-width: 1000px) {
  .lb-wrap.nofilters { grid-template-columns: 1fr; }
  .lb-wrap:not(.nofilters) .filters { display: block; }
  .lb-top { grid-template-columns: 1fr; gap: 8px; }
  .lb-top .r { justify-self: center; }
}

/* auth + limits */
.userbar { gap: 8px; }
.userbar.login { justify-content: space-between; padding: 10px 12px; font-family: var(--font); }
.userbar img.avatar { object-fit: cover; }
.ulim { font: 12px var(--font); color: var(--fg2); }
.gbtn { min-height: 40px; display: flex; align-items: center; }
.gate { margin: 18px 0 0; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; color: var(--fg2); font-size: 14.5px; }
.usage { margin-top: 10px; font-size: 13px; color: var(--fg2); }
.usage.out { color: var(--warn); }
.composer.locked { opacity: .55; }
.gbtn .muted { font: 12px var(--font); }
.form label.switch { display: flex; font-size: 14px; color: var(--fg); font-weight: 500; }

/* modal (shared) + help */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 80; display: grid; place-items: center; padding: 16px; overflow: auto; }
.modal { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: min(600px, 100%); max-height: 94vh; overflow: auto; box-shadow: var(--shadow); }
.help p { margin: 0 0 12px; line-height: 1.55; }
.help .wallet { display: inline-block; word-break: break-all; background: var(--bg3); padding: 3px 7px; border-radius: 6px; font: 12.5px var(--mono); margin: 2px 0; }
.help-form { display: grid; gap: 8px; margin: 16px 0 14px; }
.help-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--fg2); }
.btn.ghost:hover { color: var(--fg); background: var(--bg3); }
.thanks { text-align: center; }
.thanks .big { font-size: 46px; }
.thanks h2 { font-family: var(--serif); font-weight: 500; font-size: 28px; margin: 8px 0; }
.card { border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; background: var(--card); }
.lb-top .lb-tabs { justify-self: center; }

/* Text battles use full answer bubbles, not fixed-height code preview panes. */
/* Anchored composer mode menu: same controls in both modes. */
.mode-picker { position: relative; margin-right: auto; min-width: 0; }
.mode-trigger { display: flex; gap: 7px; align-items: center; padding: 7px 10px; border-radius: 8px; color: var(--fg2); background: var(--bg); border: 1px solid var(--line); font-size: 13px; }
.mode-trigger span { display: flex; }
.mode-chevron { font-size: 15px; }
.mode-menu { position: absolute; bottom: calc(100% + 8px); left: 0; width: min(300px, calc(100vw - 60px)); z-index: 30; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); box-shadow: var(--shadow); overflow: hidden; text-align: left; }
.mode-menu button { background: transparent; border: 0; border-radius: 0; width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px 12px; color: var(--fg); text-align: left; }
.mode-menu button + button { border-top: 1px solid var(--line); }
.mode-menu button:hover, .mode-menu button:focus-visible { background: var(--bg3); outline: 2px solid var(--fg3); outline-offset: -2px; }
.mode-copy { flex: 1; min-width: 0; display: grid; gap: 4px; }
.mode-copy b { font-size: 14px; font-weight: 500; }
.mode-copy small { color: var(--fg2); font-size: 12px; line-height: 1.4; }
.mode-icon { display: flex; flex-shrink: 0; }
.mode-check { min-width: 14px; }
.chips[hidden] { display: none; }

.round .panel.text-panel { height: auto; min-height: 0; overflow: visible; }
.text-answer { padding: 18px; min-width: 0; overflow-wrap: anywhere; white-space: pre-wrap; }
.text-answer[data-ready="true"] { white-space: normal; }
.text-answer > :first-child { margin-top: 0; }
.text-answer > :last-child { margin-bottom: 0; }
.text-answer pre { max-width: 100%; white-space: pre; }
.text-panel .nm { white-space: normal; overflow-wrap: anywhere; }
.round:has(.text-panel) .panels { min-height: 0; align-items: start; }
@media (max-width: 860px) { .text-answer { padding: 14px; } }

/* Chat viewport: history and dock occupy separate rows, never overlap. */
.main.chat-view { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; overflow: hidden; min-width: 0; min-height: 0; }
.chat-view > .topbar-m { grid-row: 1; }
.chat-history { grid-row: 2; min-height: 0; min-width: 0; overflow-y: auto; overscroll-behavior: contain; scroll-padding: 12px; }
.chat-dock { grid-row: 3; min-width: 0; background: var(--bg); padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.home-dock { width: 100%; max-width: 700px; margin: 0 auto; padding: 8px 20px max(16px, env(safe-area-inset-bottom)); }
.chat-history .home { padding-bottom: 24px; }
.home-dock textarea { min-width: 0; }
.chat-dock textarea, .chat-dock .revision-composer textarea { max-height: min(220px, 30dvh); }

/* Iterative revisions and optional pre-vote guesses. Keep previews usable. */
.battle .panels { min-height: 320px; }
.revision-box { padding: 8px 24px 24px; display: grid; gap: 8px; }
.revision-controls { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.revision-controls select { width: auto; min-width: 150px; justify-self: start; }
.revision-composer { display: flex; align-items: center; gap: 12px; width: 100%; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 18px; background: var(--bg2); }
.revision-composer:focus-within { border-color: var(--fg3); }
.revision-composer textarea { flex: 1; min-width: 0; min-height: 60px; max-height: 220px; resize: none; border: 0; outline: 0; background: transparent; padding: 6px 4px; line-height: 1.5; font-size: 16px; }
.revision-composer .send { width: 44px; height: 44px; margin: 0; border-radius: 12px; }
.revision-composer .send:focus-visible { outline: 2px solid var(--brand); outline-offset: 3px; }
.round { display: flex; flex-direction: column; min-width: 0; }
.round .panels { flex: none; }
@media (min-width: 861px) { .round .panel { height: 420px; } }
.panel.revealed .panel-head { flex-wrap: wrap; }
.panel.revealed .panel-title { flex: 1 1 100%; flex-wrap: wrap; }
.panel.revealed .nm { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; }
.guess-box { width: 100%; max-width: 820px; display: grid; gap: 8px; }
.guess-controls, .guess-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.guess-controls label { min-width: 0; display: grid; gap: 4px; font-size: 12px; }
.guess-controls select { width: 100%; min-width: 0; }
.guess-actions .btn { white-space: normal; min-width: 0; min-height: 44px; justify-content: center; text-align: center; }
@media (max-width: 860px) {
  .revision-box { padding: 8px 12px 20px; }
  .revision-controls { grid-template-columns: minmax(0, 1fr); }
  .guess-controls label { min-width: 0; flex-basis: 40%; }
}

/* Вложения */
.attach-btn { flex: none; }
.attach-wrap { display: inline-flex; flex: none; }
.attach-wrap[hidden] { display: none; }
.attach-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 8px; }
.attach-chips.hidden { display: none; }
.attach-chip { display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 4px 8px 4px 4px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg3); color: var(--fg); font-size: 13px; }
.attach-chip small { color: var(--fg3); white-space: nowrap; }
.attach-chip.file { cursor: pointer; padding-left: 8px; }
.attach-name { min-width: 0; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-thumb { width: 32px; height: 32px; border-radius: 6px; object-fit: cover; display: block; }
.attach-thumb.big { width: auto; height: auto; max-width: min(220px, 100%); max-height: 160px; border-radius: 10px; border: 1px solid var(--line); }
.attach-file-icon { display: inline-grid; place-items: center; min-width: 32px; height: 32px; font-size: 11px; font-weight: 600; }
.attach-x { border: 0; background: transparent; color: var(--fg3); cursor: pointer; padding: 2px 4px; border-radius: 6px; }
.attach-x:hover { color: var(--fg); background: var(--bg2); }
.attach-view { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 8px; }
/* Paperclip sits at the bottom-left edge of the composer; the mode menu stays aligned to the composer, not to the picker. */
.composer .row { position: relative; }
.composer .row .mode-picker { position: static; }
.composer .row .attach-wrap { margin-left: -6px; }
.revision-composer .attach-wrap { align-self: flex-end; margin-bottom: 8px; }
.revision-attached { padding: 0 4px; }

/* «Остановить генерацию»: the composer's send button turns into a stop square while answers stream. */
.send.stop:not(:disabled) { background: var(--fg2); border-color: var(--fg2); color: var(--bg); }
.stopped-note { margin-left: 8px; font-size: 12px; font-weight: 400; color: var(--fg3); white-space: nowrap; }
.stopped-note[hidden] { display: none; }

/* Side by Side / Direct: type picker next to the mode picker, model selects in the composer, single Direct panel */
.composer .row .pickers { display: flex; align-items: center; gap: 6px; margin-right: auto; min-width: 0; }
.composer .row .pickers .mode-picker { margin-right: 0; }
.model-picks { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 0 10px; }
.model-picks[hidden], .model-picks .model-select[hidden] { display: none; }
.model-picks .model-select { flex: 1 1 180px; width: auto; min-width: 0; max-width: 100%; padding: 6px 10px; font-size: 14px; }
.model-picks-empty { color: var(--fg3); font-size: 13px; }
.panels.single { grid-template-columns: minmax(0, 1fr); }
