:root {
  --bg: #f4f2ec; --surface: #fffefb; --ink: #1b1b19; --muted: #6b6960; --faint: #9a978c;
  --line: #e7e3d9; --line-strong: #d5d0c2;
  --accent: #1f4b73; --accent-hover: #183c5c; --accent-ink: #fff; --accent-soft: #e6edf4;
  --warm: #b4572a; --danger: #a8362b; --danger-soft: #f7e8e5; --ok: #2d6a3e;
  --radius: 10px; --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(40,35,20,.05), 0 1px 1px rgba(40,35,20,.03);
  --shadow-lg: 0 10px 30px rgba(40,35,20,.12);
  --serif: Newsreader, "Iowan Old Style", Georgia, serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141412; --surface: #1d1d1a; --ink: #ecebe4; --muted: #a09d92; --faint: #77746a;
    --line: #2d2d28; --line-strong: #44443c;
    --accent: #86b4e0; --accent-hover: #a2c5ea; --accent-ink: #0f1f2d; --accent-soft: #212f3d;
    --warm: #e08a5e; --danger: #e5766b; --danger-soft: #3a2220; --ok: #6fbf84;
    --shadow: 0 1px 2px rgba(0,0,0,.3); --shadow-lg: 0 10px 30px rgba(0,0,0,.5);
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3 { margin: 0; }
h1 { font: 600 30px/1.15 var(--serif); letter-spacing: -.015em; }
h2 { font-size: 15px; font-weight: 650; letter-spacing: -.005em; margin-bottom: 12px; }
p { margin: 0 0 10px; }
.muted { color: var(--muted); } .small { font-size: 13px; }
button, input, select, textarea { font: inherit; color: inherit; }
button, .btn, nav a { touch-action: manipulation; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.i { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg.i.fill { fill: currentColor; }

/* ---------- shell ---------- */
header.top { padding-top: env(safe-area-inset-top); position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line); }
.bar { max-width: 1040px; margin: 0 auto; padding: 0 20px; height: 58px; display: flex; align-items: center; gap: 28px; }
.logo { font: 600 24px/1 var(--serif); color: var(--ink); letter-spacing: -.02em; display: flex; align-items: center; gap: 8px; }
.logo:hover { text-decoration: none; }
.logo .mark { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; }
.logo .mark svg { width: 16px; height: 16px; }
.logo em { font-style: normal; color: var(--warm); }
nav.main { display: flex; gap: 2px; flex: 1; }
nav.main a { color: var(--muted); padding: 7px 13px; border-radius: 999px; font-weight: 500; display: flex; align-items: center; gap: 7px; transition: background .12s, color .12s; }
nav.main a svg { display: none; }
nav.main a:hover { text-decoration: none; color: var(--ink); background: color-mix(in srgb, var(--ink) 5%, transparent); }
nav.main a.on { color: var(--accent); background: var(--accent-soft); }
.badge { background: var(--warm); color: #fff; border-radius: 9px; font-size: 11px; line-height: 17px; min-width: 17px; text-align: center; padding: 0 5px; font-weight: 650; }
.menu { position: relative; }
.menu-pop { position: absolute; right: 0; top: 46px; min-width: 190px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 5px; box-shadow: var(--shadow-lg); display: none; }
.menu.open .menu-pop { display: block; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 9px 11px; border: 0; background: none; color: var(--ink); border-radius: 6px; cursor: pointer; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--bg); text-decoration: none; }
.menu-pop svg { color: var(--muted); }
.menu-pop hr { border: 0; border-top: 1px solid var(--line); margin: 4px 0; }
#menu-btn { padding: 4px 8px 4px 4px; border-radius: 999px; transition: background .12s; }
#menu-btn:hover { background: color-mix(in srgb, var(--ink) 5%, transparent); text-decoration: none; }

main { max-width: 1040px; margin: 0 auto; padding: 28px 20px 90px; }
.view { animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
.narrow { max-width: 660px; margin: 0 auto; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 28px; align-items: start; }
.side { position: sticky; top: 82px; display: flex; flex-direction: column; gap: 14px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head p { margin: 6px 0 0; color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
.spread { justify-content: space-between; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 15px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer; font-weight: 550; white-space: nowrap; transition: background .12s, border-color .12s, transform .05s; }
.btn:hover { background: var(--bg); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.danger { color: var(--danger); } .btn.danger:hover { background: var(--danger-soft); }
.btn.sm { padding: 4px 11px; font-size: 13px; }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn:disabled { opacity: .45; cursor: default; pointer-events: none; }
.link { background: none; border: 0; padding: 0; color: var(--muted); cursor: pointer; font-size: 13px; }
.link:hover { color: var(--ink); text-decoration: underline; }
label { display: block; font-weight: 550; font-size: 13px; margin: 14px 0 5px; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], select, textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); transition: border-color .12s, box-shadow .12s; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 96px; }
input[type=file] { width: 100%; max-width: 100%; padding: 8px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--bg); font-size: 13px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--accent); }
.search { position: relative; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--faint); width: 16px; height: 16px; pointer-events: none; }
.search input { padding-left: 34px; }
.hint { font-size: 12.5px; color: var(--muted); margin-top: 5px; }
.err { color: var(--danger); font-size: 13.5px; margin-top: 10px; min-height: 1em; }

.avatar { width: 38px; height: 38px; border-radius: 50%; background: hsl(var(--h, 210) 38% 89%); color: hsl(var(--h, 210) 45% 28%); display: inline-flex; align-items: center; justify-content: center; font-weight: 650; flex: none; object-fit: cover; overflow: hidden; font-size: 15px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .avatar { background: hsl(var(--h, 210) 22% 24%); color: hsl(var(--h, 210) 55% 80%); } }
.avatar.lg { width: 92px; height: 92px; font-size: 34px; border: 4px solid var(--surface); }
.avatar.sm { width: 28px; height: 28px; font-size: 12px; }

.tag { display: inline-block; background: var(--bg); border: 1px solid var(--line); border-radius: 999px; padding: 1px 9px; font-size: 12px; color: var(--muted); line-height: 1.5; }
.tag.solid { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 550; }
.tabs { display: flex; gap: 4px; margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { background: none; border: 0; padding: 7px 14px; color: var(--muted); cursor: pointer; border-radius: 999px; font-weight: 550; white-space: nowrap; transition: background .12s, color .12s; }
.tabs button:hover { color: var(--ink); }
.tabs button.on { color: var(--accent); background: var(--accent-soft); }
.filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.filters .search { flex: 1; min-width: 180px; }
.filters select { width: auto; max-width: 260px; }

.banner { display: flex; gap: 12px; border: 1px solid color-mix(in srgb, var(--accent) 22%, transparent); background: var(--accent-soft); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 20px; font-size: 14px; }
.banner svg { color: var(--accent); margin-top: 2px; }
.banner.bad { background: var(--danger-soft); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.banner.bad svg { color: var(--danger); }

/* ---------- posts ---------- */
.post { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.post:hover { border-color: var(--line-strong); box-shadow: 0 2px 10px rgba(40,35,20,.07); }
.post h3 { margin: 10px 0 4px; font-size: 17.5px; line-height: 1.3; font-weight: 650; letter-spacing: -.01em; }
.post .snippet { color: var(--muted); margin: 0; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; white-space: pre-line; }
.meta { font-size: 13px; color: var(--muted); }
.meta b { color: var(--ink); font-weight: 600; }
.actions { display: flex; gap: 6px; margin-top: 12px; margin-left: -8px; }
.act { background: none; border: 0; padding: 5px 9px; border-radius: 999px; color: var(--muted); cursor: pointer; display: inline-flex; gap: 6px; align-items: center; font-size: 13.5px; font-weight: 500; transition: background .12s, color .12s; }
.act:hover { background: var(--bg); color: var(--ink); }
.act.liked { color: var(--warm); } .act.liked svg { fill: currentColor; }
.body-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.post-full h1 { margin: 14px 0 10px; font-size: 28px; }
.post-full .body-text { font-size: 16px; line-height: 1.65; }
.comment { padding: 14px 0; border-top: 1px solid var(--line); }
.comment:first-child { border-top: 0; padding-top: 0; }
.comment .body-text { margin: 6px 0 0 38px; }
.empty { color: var(--muted); text-align: center; padding: 44px 16px; }
.empty svg { width: 30px; height: 30px; color: var(--faint); margin-bottom: 8px; stroke-width: 1.4; }
.card.empty { box-shadow: none; border-style: dashed; }

.side .card { padding: 14px; }
.side h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 650; margin-bottom: 8px; }
.fac-list { display: flex; flex-direction: column; gap: 1px; max-height: 340px; overflow-y: auto; margin: 0 -6px; }
.fac-list button { text-align: left; background: none; border: 0; padding: 6px 8px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 13.5px; line-height: 1.35; }
.fac-list button:hover { background: var(--bg); color: var(--ink); }
.fac-list button.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.mini-game { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: var(--ink); }
.mini-game + .mini-game { border-top: 1px solid var(--line); }
.mini-game:hover { text-decoration: none; } .mini-game:hover b { color: var(--accent); }
.mini-game .ico { width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }

/* ---------- materials ---------- */
.mat { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 14px; padding: 16px 0; border-top: 1px solid var(--line); align-items: center; }
.mat:first-child { border-top: 0; padding-top: 4px; }
.mat h3 { font-size: 15.5px; font-weight: 650; }
.mat.plain { grid-template-columns: 1fr auto; }
.ftype { width: 44px; height: 52px; border-radius: 6px; background: var(--bg); border: 1px solid var(--line-strong); display: grid; place-items: end center; padding-bottom: 7px; font-size: 10px; font-weight: 700; letter-spacing: .04em; color: var(--muted); position: relative; }
.ftype::before { content: ""; position: absolute; top: -1px; right: -1px; width: 12px; height: 12px; background: var(--surface); border-left: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); border-bottom-left-radius: 4px; }
.ftype.pdf { color: #a8362b; } .ftype.doc, .ftype.docx { color: #1f4b9a; } .ftype.ppt, .ftype.pptx { color: #b4572a; }
.ftype.xls, .ftype.xlsx, .ftype.csv { color: #2d6a3e; } .ftype.zip, .ftype.rar { color: #7a5a1e; }

/* ---------- auth ---------- */
.welcome { display: grid; grid-template-columns: 1fr 440px; gap: 56px; align-items: center; min-height: calc(100vh - 140px); max-width: 1000px; margin: 0 auto; padding: 32px 20px; }
.pitch .logo { margin-bottom: 40px; }
.pitch h1 { font-size: 48px; line-height: 1.05; letter-spacing: -.025em; margin-bottom: 18px; }
.pitch h1 em { font-style: italic; color: var(--accent); }
.pitch p { font-size: 17px; color: var(--muted); max-width: 440px; }
.pitch ul { list-style: none; padding: 0; margin: 28px 0 0; display: grid; gap: 14px; }
.pitch li { display: flex; gap: 12px; align-items: flex-start; color: var(--ink); }
.pitch li svg { color: var(--accent); margin-top: 2px; }
.pitch li span { color: var(--muted); display: block; font-size: 14px; }
.auth h1 { font-size: 28px; margin-bottom: 4px; }
.auth > p { color: var(--muted); margin-bottom: 16px; }
.auth .card { padding: 22px; box-shadow: var(--shadow-lg); }

/* ---------- profile ---------- */
.profile { padding: 0; overflow: hidden; }
.cover { height: 92px; background: var(--accent-soft); border-bottom: 1px solid var(--line); background-image: radial-gradient(color-mix(in srgb, var(--accent) 16%, transparent) 1px, transparent 1.2px); background-size: 14px 14px; }
.profile-body { padding: 0 22px 20px; }
.profile-top { display: flex; align-items: flex-end; gap: 16px; margin-top: -46px; flex-wrap: wrap; }
.profile-top .grow { padding-bottom: 4px; }
.profile h1 { font-size: 28px; }
.stats { display: flex; gap: 26px; margin: 16px 0 4px; }
.stats button, .stats span { background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); font-size: 13.5px; text-align: left; }
.stats b { display: block; color: var(--ink); font: 600 22px/1.1 var(--serif); }
.stats span { cursor: default; }

/* ---------- chat ---------- */
.chat { display: grid; grid-template-columns: 310px 1fr; height: calc(100vh - 58px - 56px); height: calc(100dvh - 58px - 56px); min-height: 440px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.chat-list { border-right: 1px solid var(--line); overflow-y: auto; display: flex; flex-direction: column; }
.chat-list .search-box { padding: 12px; border-bottom: 1px solid var(--line); position: relative; }
.conv { display: flex; gap: 11px; padding: 12px 14px; cursor: pointer; align-items: center; border-bottom: 1px solid var(--line); color: var(--ink); border-left: 3px solid transparent; }
.conv:hover { background: var(--bg); text-decoration: none; }
.conv.on { background: var(--accent-soft); border-left-color: var(--accent); }
.conv .last { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); display: inline-block; box-shadow: 0 0 0 2px var(--surface); }
.thread { display: flex; flex-direction: column; min-width: 0; background: color-mix(in srgb, var(--bg) 55%, var(--surface)); }
.thread-head { padding: 11px 16px; border-bottom: 1px solid var(--line); background: var(--surface); display: flex; align-items: center; gap: 11px; }
.msgs { flex: 1; overflow-y: auto; padding: 18px 16px; display: flex; flex-direction: column; gap: 3px; }
.msg { max-width: 70%; padding: 8px 13px; border-radius: 16px 16px 16px 4px; background: var(--surface); border: 1px solid var(--line); overflow-wrap: anywhere; white-space: pre-wrap; align-self: flex-start; }
.msg.mine { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); border-radius: 16px 16px 4px 16px; }
.msg time { display: block; font-size: 11px; opacity: .6; margin-top: 2px; }
.composer { padding: 12px; border-top: 1px solid var(--line); background: var(--surface); display: flex; gap: 8px; }
.composer input { flex: 1; border-radius: 999px; padding-left: 16px; }
.composer .btn { border-radius: 999px; padding: 8px 18px; }
a.back { display: none; }
.dropdown { position: absolute; left: 12px; right: 12px; top: 54px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); z-index: 5; overflow: hidden; }
.dropdown .conv:last-child { border-bottom: 0; }

/* ---------- games ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.tile { display: block; color: inherit; padding: 0; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.tile:hover { text-decoration: none; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.tile .art { height: 140px; background: var(--accent-soft); display: grid; place-items: center; border-bottom: 1px solid var(--line); color: var(--accent); }
.tile .info { padding: 16px 18px 18px; }
.tile h2 { font: 600 22px/1.2 var(--serif); margin: 0 0 4px; }
.mini-sudoku { display: grid; grid-template-columns: repeat(3, 38px); border: 2px solid var(--accent); background: var(--surface); }
.mini-sudoku i { height: 38px; border: 1px solid var(--line-strong); display: grid; place-items: center; font: 600 18px var(--serif); font-style: normal; }
.mathart { font: 600 40px var(--serif); letter-spacing: -.02em; }
.game-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 28px; align-items: start; }
.sudoku { display: grid; grid-template-columns: repeat(9, 1fr); width: min(100%, 440px); aspect-ratio: 1; border: 2px solid var(--ink); background: var(--surface); border-radius: 4px; overflow: hidden; box-shadow: var(--shadow); }
.sudoku div { border: 1px solid var(--line); display: flex; align-items: center; justify-content: center; font-size: 23px; cursor: pointer; user-select: none; transition: background .08s; }
.sudoku div:nth-child(3n) { border-right: 2px solid var(--ink); }
.sudoku div:nth-child(9n) { border-right: 1px solid var(--line); }
.sudoku div:nth-child(n+19):nth-child(-n+27), .sudoku div:nth-child(n+46):nth-child(-n+54) { border-bottom: 2px solid var(--ink); }
.sudoku div.given { font-weight: 650; background: color-mix(in srgb, var(--bg) 70%, var(--surface)); cursor: default; font-family: var(--serif); font-size: 26px; }
.sudoku div:not(.given) { color: var(--accent); }
.sudoku div.rel { background: var(--accent-soft); }
.sudoku div.same { background: color-mix(in srgb, var(--accent) 22%, var(--surface)); }
.sudoku div.sel { background: var(--accent); color: var(--accent-ink); }
.sudoku div.bad { color: var(--danger); }
.sudoku div.sel.bad { color: var(--accent-ink); }
.keypad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; width: min(100%, 440px); margin-top: 14px; }
.keypad .btn { padding: 11px 0; font-size: 18px; }
.bigq { font: 600 56px/1 var(--serif); text-align: center; margin: 26px 0 18px; letter-spacing: -.02em; }
.progress { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .25s linear; }
.lb { counter-reset: r; padding: 0; margin: 0; list-style: none; }
.lb li { counter-increment: r; display: flex; gap: 10px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.lb li::before { content: counter(r); width: 18px; color: var(--faint); font: 600 15px var(--serif); }
.lb li:first-child { border-top: 0; } .lb li:first-child::before { color: var(--warm); }

/* ---------- admin ---------- */
.statgrid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { padding: 14px 16px; }
.stat b { display: block; font: 600 30px/1.1 var(--serif); } .stat span { color: var(--muted); font-size: 13px; }
.stat.hot b { color: var(--warm); }

/* ---------- misc ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20,18,10,.4); backdrop-filter: blur(2px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 16px; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 14px; padding: 22px; width: 100%; max-width: 440px; max-height: 86vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal h2 { font: 600 22px var(--serif); margin-bottom: 4px; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px; z-index: 60; font-size: 14px; box-shadow: var(--shadow-lg); }
.idimg { max-width: 100%; max-height: 420px; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-top: 12px; display: block; }
.switch { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; }
.switch:first-of-type { border-top: 0; }
.switch input { margin-top: 3px; }
.switch label { margin: 0; font-size: 15px; cursor: pointer; }
.settings-av { display: flex; gap: 18px; align-items: center; }
.settings-av .avatar.lg { border: 0; }

/* ---------- mobile ---------- */
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; }
  .welcome { grid-template-columns: 1fr; gap: 24px; min-height: 0; padding-top: 20px; }
  .pitch .logo { margin-bottom: 20px; } .pitch h1 { font-size: 36px; } .pitch ul { display: none; }
}
@media (min-width: 901px) { .only-mobile { display: none !important; } }
@media (max-width: 700px) {
  h1 { font-size: 26px; }
  .bar { padding: 0 14px; gap: 12px; height: 54px; }
  nav.main { position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line); justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 10; gap: 0; }
  nav.main a { flex: 1; flex-direction: column; gap: 2px; padding: 5px 2px; font-size: 11.5px; border-radius: 8px; }
  nav.main a svg { display: block; width: 22px; height: 22px; }
  nav.main a.on { background: none; }
  nav.main a .badge { position: absolute; margin: -4px 0 0 16px; }
  nav.main a { position: relative; }
  .bar .grow { display: none; } .logo { flex: 1; font-size: 22px; }
  main { padding: 18px 14px calc(88px + env(safe-area-inset-bottom)); }
  input[type=text], input[type=email], input[type=password], input[type=search], input[type=number], select, textarea { font-size: 16px; }
  .btn { min-height: 40px; } .btn.sm { min-height: 36px; padding: 5px 12px; }
  .link { min-height: 36px; display: inline-flex; align-items: center; padding: 0 4px; }
  .act { padding: 8px 10px; }
  .tabs button { padding: 9px 14px; }
  .menu-pop { top: 44px; } .menu-pop a, .menu-pop button { padding: 12px; }
  .card { padding: 15px; }
  .page-head { margin-bottom: 14px; }
  .filters select { width: 100%; max-width: none; }
  .modal-bg { align-items: flex-end; padding: 0; }
  .modal { max-width: none; border-radius: 16px 16px 0 0; max-height: 92vh; max-height: 92dvh; padding: 20px 16px calc(20px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(82px + env(safe-area-inset-bottom)); max-width: 90vw; text-align: center; }
  .chat { grid-template-columns: 1fr; height: calc(100vh - 54px - 106px - env(safe-area-inset-top)); height: calc(100dvh - 54px - 106px - env(safe-area-inset-top)); min-height: 0; }
  .chat.open .chat-list, .chat:not(.open) .thread { display: none; }
  a.back { display: inline; padding: 8px 10px 8px 0; font-size: 20px; }
  .msg { max-width: 86%; }
  .mat { grid-template-columns: auto 1fr; } .mat .row { grid-column: 1 / -1; flex-wrap: wrap; }
  .mat.plain { grid-template-columns: 1fr; }
  .row.spread { flex-wrap: wrap; }
  .post h3 { font-size: 16.5px; }
  .post-full h1 { font-size: 24px; }
  .cover { height: 72px; } .profile-body { padding: 0 16px 16px; }
  .profile-top { margin-top: -40px; } .avatar.lg { width: 80px; height: 80px; font-size: 30px; }
  .stats { gap: 22px; }
  .pitch h1 { font-size: 32px; }
  .bigq { font-size: 46px; }
  .sudoku div { font-size: 20px; } .sudoku div.given { font-size: 22px; }
  .keypad .btn { min-height: 48px; }
  .idimg { max-height: 300px; }
  .statgrid { grid-template-columns: repeat(2, 1fr); }
  .tile .art { height: 110px; }
}
@media (max-width: 360px) {
  .logo { font-size: 20px; }
  #menu-btn span:nth-child(2) { display: none; }
  .sudoku div { font-size: 17px; } .sudoku div.given { font-size: 19px; }
  nav.main a { font-size: 10.5px; }
}
.post .row .meta.grow, .comment .row .meta.grow { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.post .row .tag { flex: 0 1 auto; min-width: 0; max-width: 46%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 360px) { .post .row .tag { display: none; } }
.tiles > *, .statgrid > *, .game-grid > * { margin-top: 0 !important; }
.fac-list { max-height: none; }
.side { max-height: calc(100vh - 100px); overflow-y: auto; scrollbar-width: thin; }

.card.profile { padding: 0; }
main, .view, .layout > div { min-width: 0; }
@media (max-width: 700px) {
  .profile-top .grow { flex-basis: 100%; }
  .card.profile { padding: 0; }
  .page-head .btn { width: 100%; }
  .tabs { margin-left: -2px; }
}
