:root {
  --bg: #f4f2ec;
  --panel: #fffdf8;
  --panel-2: #ece9e0;
  --ink: #18171c;
  --ink-2: #4a4852;
  --muted: #7d7a86;
  --line: #dcd8cc;
  --accent: #e8462a;
  --accent-ink: #ffffff;
  --accent-soft: #fbe3dc;
  --down: #4b5bd6;
  --ok: #1f7a4d;
  --shadow: 0 1px 0 rgba(24, 23, 28, .04), 0 8px 24px -16px rgba(24, 23, 28, .25);
  --radius: 10px;
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121116; --panel: #1b1a21; --panel-2: #26252e; --ink: #f1efe9; --ink-2: #c4c1cc; --muted: #8d8a97;
    --line: #2f2d37; --accent: #ff6a4d; --accent-ink: #160b08; --accent-soft: #3a1d17; --down: #8b97ff; --ok: #4cc38a;
    --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 30px -18px rgba(0, 0, 0, .8); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121116; --panel: #1b1a21; --panel-2: #26252e; --ink: #f1efe9; --ink-2: #c4c1cc; --muted: #8d8a97;
  --line: #2f2d37; --accent: #ff6a4d; --accent-ink: #160b08; --accent-soft: #3a1d17; --down: #8b97ff; --ok: #4cc38a;
  --shadow: 0 1px 0 rgba(0, 0, 0, .3), 0 10px 30px -18px rgba(0, 0, 0, .8); color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--body); -webkit-font-smoothing: antialiased; }
a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
h1, h2, h3 { font-family: var(--display); letter-spacing: -.02em; line-height: 1.15; text-wrap: balance; margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.wrap { max-width: 1180px; margin: 0 auto; padding-inline: 16px; }

/* top bar */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top .wrap { display: flex; align-items: center; gap: 16px; height: 58px; }
.logo { display: flex; align-items: center; gap: 9px; font: 800 21px/1 var(--display); letter-spacing: -.04em; }
.logo:hover { color: var(--ink); }
.logo .mark { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--accent-ink);
  font: 700 14px/1 var(--mono); letter-spacing: 0; }
.logo b { color: var(--accent); font-weight: 800; }
.nav { display: flex; gap: 4px; margin-left: 8px; }
.nav a { padding: 6px 10px; border-radius: 7px; color: var(--ink-2); font-weight: 500; }
.nav a:hover, .nav a.on { background: var(--panel-2); color: var(--ink); }
.spacer { flex: 1; }
.topsearch { flex: 1; display: flex; justify-content: flex-end; min-width: 0; }
.topsearch input { width: 100%; max-width: 340px; height: 36px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel);
  padding: 0 12px 0 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%237d7a86' stroke-width='1.8'%3E%3Ccircle cx='7' cy='7' r='4.5'/%3E%3Cpath d='m10.5 10.5 3 3'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: 11px center; background-size: 15px; min-width: 0; }
.topsearch input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); border-color: var(--accent); }
.searchbig { display: flex; gap: 8px; margin-bottom: 14px; flex-wrap: wrap; }
.searchbig input { flex: 1 1 260px; height: 44px; font-size: 16px; }
.searchbig select { width: auto; height: 44px; }
.searchbig .btn { height: 44px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 36px; padding: 0 14px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--panel); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink-2); color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; }
.avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font: 700 13px/1 var(--mono);
  overflow: hidden; flex: none; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.me { display: flex; align-items: center; gap: 8px; font-weight: 600; }

/* layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; padding-block: 22px 60px; }
.side { display: flex; flex-direction: column; gap: 16px; }
.box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.box h3 { font-size: 15px; margin-bottom: 8px; }
.box p { margin: 0 0 10px; color: var(--ink-2); font-size: 14px; }
.clist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.clist a { display: flex; justify-content: space-between; padding: 6px 0; border-top: 1px solid var(--line); font-size: 14px; }
.clist li:first-child a { border-top: 0; }
.clist .n { color: var(--muted); font: 12px/1.6 var(--mono); }

/* feed header */
.feedhead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.feedhead h1 { font-size: 30px; }
.feedhead .sub { color: var(--muted); margin-top: 4px; }
.tabs { display: flex; gap: 2px; background: var(--panel-2); padding: 3px; border-radius: 9px; flex-wrap: wrap; }
.tabs a { padding: 5px 11px; border-radius: 7px; font-weight: 600; font-size: 13px; color: var(--ink-2); }
.tabs a.on { background: var(--panel); color: var(--ink); box-shadow: var(--shadow); }
.periods { display: flex; gap: 10px; font-size: 13px; margin: -4px 0 12px; }
.periods a { color: var(--muted); }
.periods a.on { color: var(--ink); font-weight: 600; text-decoration: underline; text-underline-offset: 4px; }

/* post rows */
.posts { display: flex; flex-direction: column; gap: 8px; }
.row { display: grid; grid-template-columns: 44px 64px minmax(0, 1fr); gap: 12px; align-items: center; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 14px 10px 6px; }
.row:hover { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.votes { display: flex; flex-direction: column; align-items: center; gap: 0; }
.vbtn { width: 30px; height: 26px; border: 0; background: none; border-radius: 6px; cursor: pointer; color: var(--muted); display: grid; place-items: center; }
.vbtn:hover { background: var(--panel-2); }
.vbtn svg { width: 16px; height: 16px; }
.vbtn.up.on { color: var(--accent); }
.vbtn.down.on { color: var(--down); }
.score { font: 700 13px/1.4 var(--mono); }
.score.up { color: var(--accent); }
.score.down { color: var(--down); }
.tile { width: 64px; height: 52px; border-radius: 8px; display: grid; place-items: center; font: 700 11px/1 var(--mono); letter-spacing: .06em;
  text-transform: uppercase; border: 1px solid var(--line); background: var(--panel-2); color: var(--ink-2); }
.tile.html { background: color-mix(in srgb, #e8462a 14%, var(--panel)); color: color-mix(in srgb, #e8462a 70%, var(--ink)); }
.tile.react { background: color-mix(in srgb, #1c9ab8 16%, var(--panel)); color: color-mix(in srgb, #1c9ab8 70%, var(--ink)); }
.tile.svg { background: color-mix(in srgb, #c28a00 18%, var(--panel)); color: color-mix(in srgb, #c28a00 70%, var(--ink)); }
.tile.markdown { background: color-mix(in srgb, #6b5bd6 15%, var(--panel)); color: color-mix(in srgb, #6b5bd6 70%, var(--ink)); }
.tile.mermaid { background: color-mix(in srgb, #2f9e5b 15%, var(--panel)); color: color-mix(in srgb, #2f9e5b 70%, var(--ink)); }
.ptitle { font: 650 16.5px/1.3 var(--body); display: block; margin-bottom: 4px; overflow-wrap: anywhere; }
.meta { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 13px; color: var(--muted); align-items: center; }
.meta a:hover { color: var(--accent); }
.meta .c { color: var(--ink); font-weight: 600; }
.chip { font: 600 11px/1 var(--mono); padding: 3px 6px; border-radius: 5px; background: var(--panel-2); color: var(--ink-2); text-transform: lowercase; }
.empty { text-align: center; padding: 48px 20px; color: var(--muted); background: var(--panel); border: 1px dashed var(--line); border-radius: var(--radius); }
.pager { display: flex; justify-content: center; gap: 8px; margin-top: 16px; }

/* post page */
.postpage { padding-block: 20px 60px; display: flex; flex-direction: column; gap: 16px; }
.posthead { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.posthead h1 { font-size: clamp(22px, 3.2vw, 32px); margin-bottom: 6px; overflow-wrap: anywhere; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.stage { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: #fff; box-shadow: var(--shadow); }
.stagebar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--panel); border-bottom: 1px solid var(--line); font-size: 13px; flex-wrap: wrap; }
.stagebar .dots { display: flex; gap: 6px; }
.stagebar .dots i { width: 10px; height: 10px; border-radius: 50%; background: var(--line); display: block; }
.stagebar select { background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 3px 6px; font-size: 13px; }
.stage iframe { display: block; width: 100%; height: min(78vh, 900px); border: 0; background: #fff; }
.stage.full { position: fixed; inset: 0; z-index: 50; border-radius: 0; border: 0; }
.stage.full iframe { height: calc(100vh - 46px); }
.notice { font-size: 13px; color: var(--ink-2); background: var(--accent-soft); border-radius: 8px; padding: 8px 12px; }
.desc { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 4px 18px; max-width: 820px; }
.desc p { margin: 12px 0; overflow-wrap: anywhere; }
.code { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.code pre { margin: 0; padding: 14px; max-height: 520px; overflow: auto; font: 12.5px/1.55 var(--mono); white-space: pre; }
.versions { font-size: 13px; display: flex; flex-direction: column; gap: 4px; }
.versions a.on { font-weight: 700; color: var(--accent); }

/* comments */
.comments { max-width: 820px; display: flex; flex-direction: column; gap: 10px; }
.comments h2 { font-size: 20px; }
.comment { border-left: 2px solid var(--line); padding: 2px 0 2px 12px; }
.comment .who { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.comment .who a { color: var(--ink); font-weight: 600; }
.comment .body p { margin: 4px 0; overflow-wrap: anywhere; }
.comment .tools { display: flex; gap: 10px; font-size: 12.5px; }
.comment .tools button, .linkbtn { border: 0; background: none; padding: 0; color: var(--muted); cursor: pointer; font-weight: 600; font-size: 12.5px; }
.comment .tools button:hover, .linkbtn:hover { color: var(--accent); }
.comment form { margin-top: 6px; }

/* forms */
.formpage { padding-block: 24px 60px; max-width: 820px; }
.formpage h1 { font-size: 30px; margin-bottom: 6px; }
.form { display: flex; flex-direction: column; gap: 16px; margin-top: 18px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label { font-weight: 600; font-size: 14px; }
.field .hint { font-size: 13px; color: var(--muted); }
.input, textarea.input, select.input { width: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
.input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 55%, transparent); outline-offset: 0; border-color: var(--accent); }
textarea.code-in { font: 12.5px/1.5 var(--mono); min-height: 280px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.drop { border: 1.5px dashed var(--line); border-radius: 10px; padding: 14px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap;
  background: var(--panel); font-size: 14px; color: var(--ink-2); }
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.flash { background: var(--accent-soft); color: var(--ink); border-radius: 8px; padding: 10px 14px; font-weight: 500; }
.keybox { font: 13px/1.5 var(--mono); background: var(--panel-2); border-radius: 8px; padding: 10px 12px; overflow-wrap: anywhere; display: flex;
  gap: 10px; align-items: center; justify-content: space-between; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table td, .table th { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); }
.table th { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* docs */
.doc { padding-block: 24px 60px; max-width: 820px; }
.doc h1 { font-size: 34px; margin-bottom: 8px; }
.doc h2 { font-size: 21px; margin: 30px 0 8px; }
.doc p, .doc li { color: var(--ink-2); }
.doc pre { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; overflow: auto; font: 12.5px/1.55 var(--mono); }
.doc code { font-family: var(--mono); font-size: .92em; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }
.doc pre code { background: none; padding: 0; }
.steps { counter-reset: s; list-style: none; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 28px 1fr; gap: 10px; }
.steps li::before { content: counter(s); width: 24px; height: 24px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font: 700 12px/1 var(--mono); }

/* login */
.loginpage { min-height: calc(100vh - 160px); display: grid; place-items: center; padding-block: 30px; }
.logincard { width: min(420px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 12px; }
.logincard h1 { font-size: 26px; }
.provider { height: 44px; justify-content: flex-start; padding: 0 16px; gap: 12px; }
.provider svg { width: 18px; height: 18px; }

.hero { background: var(--ink); color: var(--bg); border-radius: 14px; padding: 22px; display: flex; flex-direction: column; gap: 10px; position: relative; overflow: hidden; }
.hero h2 { font-size: 22px; color: var(--bg); }
.hero p { margin: 0; color: color-mix(in srgb, var(--bg) 75%, transparent); font-size: 14px; }
.hero .btn { align-self: flex-start; }
.hero::after { content: "</>"; position: absolute; right: -6px; bottom: -22px; font: 800 92px/1 var(--mono); color: color-mix(in srgb, var(--bg) 8%, transparent); }

footer { border-top: 1px solid var(--line); padding-block: 18px; font-size: 13px; color: var(--muted); }
footer .wrap { display: flex; gap: 14px; flex-wrap: wrap; }

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { order: 2; }
  .nav { display: none; }
}
@media (max-width: 560px) {
  .row { grid-template-columns: 40px minmax(0, 1fr); padding-right: 10px; }
  .row .tile { display: none; }
  .posthead { grid-template-columns: 40px minmax(0, 1fr); }
  .posthead .actions { grid-column: 1 / -1; justify-content: flex-start; }
  .grid2 { grid-template-columns: 1fr; }
  .feedhead h1 { font-size: 24px; }
  .top .wrap { gap: 10px; }
  .hide-sm { display: none; }
}
