/* =========================================================
   typing site — modern theme (light + dark)
   Toggle by setting data-theme="dark" on <html>.
   ========================================================= */

/* Hindi legacy font (Kruti Dev 010): typing ASCII keys renders Devanagari */
@font-face {
    font-family: "KrutiDev010";
    src: url("../fonts/KRDEV010.woff") format("woff");
    font-weight: normal; font-style: normal; font-display: swap;
}
/* apply the Hindi font to the typing surfaces + admin editor/preview */
.kruti-text,
.lang-kruti .target-panel, .lang-kruti .capture,
.editor.lang-kruti {
    font-family: "KrutiDev010", Arial, "Helvetica Neue", sans-serif !important;
}
/* language tabs on the leaderboard */
.board-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 2px; }
.board-tabs a {
    font-size: 14px; font-weight: 600; padding: 8px 16px; border-radius: 999px;
    border: 1px solid var(--border); color: var(--muted); text-decoration: none; background: var(--surface-2);
}
.board-tabs a.active { background: var(--accent); color: #fff; border-color: var(--accent); }

:root {
    --bg:        #f6f7fb;
    --surface:   #ffffff;
    --surface-2: #f1f3f9;
    --text:      #0f172a;
    --muted:     #64748b;
    --border:    #e5e8ef;
    --accent:    #4f46e5;
    --accent-2:  #4338ca;
    --accent-soft:#eef2ff;
    --success:   #16a34a;
    --success-bg:#dcfce7;
    --danger:    #dc2626;
    --danger-bg: #fee2e2;
    --warn:      #d97706;
    --warn-bg:   #fef3c7;
    --gold:      #f5b301;
    --silver:    #94a3b8;
    --bronze:    #c1793e;
    --shadow:    0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
    --shadow-sm: 0 1px 2px rgba(15,23,42,.06);
    --radius:    14px;
    --radius-sm: 9px;
    --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", "Menlo", monospace;
    --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    /* legacy aliases so older inline styles keep working */
    --ink: var(--text);
    --line: var(--border);
}

html[data-theme="dark"] {
    --bg:        #0b1120;
    --surface:   #131a2a;
    --surface-2: #1b2438;
    --text:      #e8ecf5;
    --muted:     #94a3b8;
    --border:    #263149;
    --accent:    #818cf8;
    --accent-2:  #a5b4fc;
    --accent-soft:#1e2540;
    --success:   #4ade80;
    --success-bg:#0f2e1d;
    --danger:    #f87171;
    --danger-bg: #3a1414;
    --warn:      #fbbf24;
    --warn-bg:   #3a2c0a;
    --gold:      #fbbf24;
    --silver:    #cbd5e1;
    --bronze:    #d18a54;
    --shadow:    0 1px 2px rgba(0,0,0,.3), 0 12px 30px rgba(0,0,0,.35);
    --shadow-sm: 0 1px 2px rgba(0,0,0,.35);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    transition: background .2s ease, color .2s ease;
}

.screen { max-width: 960px; margin: 0 auto; padding: 0 20px 56px; }

/* ---------- top nav ---------- */
.nav {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px; padding: 18px 0 22px;
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: var(--text); }
.brand img { width: 34px; height: 34px; border-radius: 8px; }
.brand b { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.nav-links { display: flex; align-items: center; gap: 6px; }
.nav-links a {
    color: var(--muted); text-decoration: none; font-weight: 500; font-size: 14.5px;
    padding: 8px 12px; border-radius: 8px; transition: background .15s, color .15s;
}
.nav-links a:hover { color: var(--text); background: var(--surface-2); }
.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 9px; cursor: pointer;
    border: 1px solid var(--border); background: var(--surface); color: var(--text);
    font-size: 17px; line-height: 1;
}
.theme-toggle:hover { background: var(--surface-2); }

/* ---------- cards / surfaces ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px;
}
.card + .card { margin-top: 20px; }

/* ---------- headings / text ---------- */
h1 { font-size: 26px; font-weight: 750; letter-spacing: -.02em; margin: 0 0 6px; }
h2 { font-size: 19px; font-weight: 700; letter-spacing: -.01em; margin: 26px 0 14px; }
h3 { font-size: 15px; font-weight: 650; margin: 0 0 10px; }
p  { margin: 0 0 12px; }
a  { color: var(--accent); }
.lead { color: var(--muted); font-size: 15.5px; margin-bottom: 20px; }
.muted { color: var(--muted); }
.hint  { color: var(--muted); font-size: 13.5px; }
code {
    font-family: var(--mono); font-size: .88em;
    background: var(--surface-2); padding: 2px 6px; border-radius: 6px;
}

/* ---------- leaderboard ---------- */
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 4px; flex-wrap: wrap; }
.board-wrap { overflow-x: auto; }
table.board { width: 100%; border-collapse: collapse; }
table.board thead th {
    text-align: left; font-size: 12px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .04em; color: var(--muted);
    padding: 0 16px 12px 0; white-space: nowrap; border-bottom: 1px solid var(--border);
}
table.board tbody td { padding: 14px 16px 14px 0; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.board tbody tr:last-child td { border-bottom: 0; }
table.board tbody tr { transition: background .12s; }
table.board tbody tr:hover { background: var(--surface-2); }
.name-cell { font-weight: 600; }
.wpm-cell { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent); }

.rank-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 26px; height: 26px; padding: 0 7px; border-radius: 8px;
    font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
    background: var(--surface-2); color: var(--muted);
}
tr.rank-1 .rank-badge { background: var(--gold);   color:#1a1400; }
tr.rank-2 .rank-badge { background: var(--silver); color:#0b1120; }
tr.rank-3 .rank-badge { background: var(--bronze); color:#fff; }

.empty-note { text-align: center; padding: 54px 10px; color: var(--muted); }
.empty-note .big { font-size: 42px; display:block; margin-bottom: 8px; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px; justify-content: center;
    font-family: inherit; font-size: 14.5px; font-weight: 600; line-height: 1;
    padding: 11px 18px; border-radius: 10px; cursor: pointer;
    border: 1px solid transparent; background: var(--accent); color: #fff;
    text-decoration: none; transition: transform .04s, background .15s, box-shadow .15s;
    box-shadow: var(--shadow-sm);
}
.btn:hover { background: var(--accent-2); }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: none; }
.btn.secondary:hover { background: var(--surface-2); }
.btn.danger { background: var(--danger); }
.btn.danger:hover { filter: brightness(.93); }
.btn.small { font-size: 13px; padding: 8px 12px; border-radius: 8px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
/* legacy button aliases */
.btn.btn-ghost, .btn.btn-blue { background: var(--surface); color: var(--text); border-color: var(--border); box-shadow: none; }
.btn.btn-ghost:hover, .btn.btn-blue:hover { background: var(--surface-2); }
.btn.btn-red { background: var(--danger); color: #fff; }
.btn.btn-red:hover { filter: brightness(.93); }

/* ---------- forms ---------- */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 7px; }
input[type=text], input[type=password], input[type=number], select, textarea {
    width: 100%; font-family: inherit; font-size: 15px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 11px 13px; transition: border .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus, [contenteditable]:focus {
    outline: none; border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea { line-height: 1.5; resize: vertical; }
.form-row { display: flex; gap: 14px; flex-wrap: wrap; }
.form-row .field { flex: 1 1 180px; }

/* ---------- notices ---------- */
.notice { border-radius: 10px; padding: 12px 15px; margin-bottom: 16px; font-size: 14.5px; border: 1px solid transparent; }
.notice.ok   { background: var(--success-bg); color: var(--success); border-color: color-mix(in srgb, var(--success) 25%, transparent); }
.notice.err  { background: var(--danger-bg);  color: var(--danger);  border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.notice.info { background: var(--accent-soft); color: var(--accent);  border-color: color-mix(in srgb, var(--accent) 22%, transparent); }

/* ---------- stat tiles ---------- */
.stat-bar { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
/* keep WPM / Acc / KDPH / Time pinned in view while typing scrolls the paragraph */
#step-test .stat-bar {
    position: sticky; top: 8px; z-index: 30;
    background: var(--surface); border-radius: 14px;
    padding: 10px; margin: 0 -10px 14px;
    box-shadow: 0 10px 22px -16px rgba(0,0,0,.5);
}
html[data-skin="retro"] #step-test .stat-bar { border: 2px solid var(--ink); box-shadow: var(--shadow-sm); }
.stat {
    flex: 1 1 96px; background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 12px; padding: 12px 14px; text-align: center;
}
.stat .val { font-size: 26px; font-weight: 750; font-variant-numeric: tabular-nums; display: block; line-height: 1.1; }
.stat .lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-top: 4px; }
.stat.accent .val { color: var(--accent); }

/* ---------- typing test ---------- */
.target-panel, .type-box {
    font-family: Arial, "Helvetica Neue", Helvetica, "Segoe UI", sans-serif;
    font-size: 22px; line-height: 1.9;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 20px 22px; word-break: break-word;
    white-space: pre-wrap; tab-size: 4; -moz-tab-size: 4;
}
/* newline in the target renders as an actual break; show a subtle glyph */
.target-panel .ch.nl::before { content: "\21B5"; color: var(--muted); opacity: .35; }
.target-panel .ch.tab { white-space: pre; }
.target-panel { user-select: none; margin-bottom: 14px; position: relative; }
.target-panel .ch { border-radius: 3px; transition: background .05s, color .05s; }
.target-panel .ch.correct   { color: var(--success); }
.target-panel .ch.incorrect { color: #fff; background: var(--danger); }
html[data-theme="dark"] .target-panel .ch.incorrect { color: #1a0606; }
.target-panel .ch.current   { background: var(--accent-soft); box-shadow: inset 2px 0 0 var(--accent); }
/* inline format rendering on target spans — made clearly visible so the typist
   can tell at a glance which formatting each character needs */
.target-panel .ch.b { font-weight: 800; }
.target-panel .ch.i { font-style: italic; }
.target-panel .ch.u { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.target-panel .ch.s { text-decoration: line-through; text-decoration-thickness: 2px; }
.target-panel .ch.u.s { text-decoration: underline line-through; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.target-panel .ch.sub { vertical-align: sub; font-size: .72em; }
.target-panel .ch.sup { vertical-align: super; font-size: .72em; }

.type-box { min-height: 90px; margin-bottom: 6px; }
.type-box[contenteditable]:empty::before { content: attr(data-ph); color: var(--muted); }

/* transparent capture layer sits exactly over the target panel so typing (and
   the mobile keyboard) works while the visible caret is drawn on the target. */
.type-input-wrap { position: relative; }
.type-input-wrap .target-panel { margin-bottom: 0; }
.capture {
    position: absolute; inset: 0; width: 100%; height: 100%;
    resize: none; color: transparent; background: transparent; caret-color: transparent;
    border: 0; box-shadow: none; padding: 20px 22px;
    font-family: Arial, "Helvetica Neue", Helvetica, "Segoe UI", sans-serif;
    font-size: 22px; line-height: 1.9; overflow: hidden;
    white-space: pre-wrap; tab-size: 4; -moz-tab-size: 4; word-break: break-word;
}
.capture:focus { outline: none; }
.type-input-wrap:focus-within .target-panel { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* header row above the typing box: label + full-screen button + live format hint */
.type-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 6px; }
.type-head-actions { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.fmt-hint {
    font-size: 13.5px; font-weight: 600; padding: 6px 11px; border-radius: 8px;
    background: var(--danger-bg, #fdecea); color: var(--danger); border: 1px solid var(--danger);
    white-space: nowrap; max-width: 60vw; overflow: hidden; text-overflow: ellipsis;
}

/* full-screen typing mode (JS toggles .is-fs for both native + fallback) */
#step-test.is-fs {
    position: fixed; inset: 0; z-index: 2000; margin: 0;
    background: var(--surface); overflow-y: auto; padding: 0 6vw;
}
/* WPM / Acc / KDPH / Time become a thin strip pinned to the very top — like a
   title bar — so it never sits in front of the paragraph */
#step-test.is-fs .stat-bar {
    position: sticky; top: 0; z-index: 40; margin: 0 -6vw 20px;
    display: flex; flex-wrap: nowrap; gap: 8px; align-items: center; overflow-x: auto;
    padding: 7px 6vw; border-radius: 0; border-bottom: 1px solid var(--border);
    background: var(--surface); box-shadow: 0 3px 10px -6px rgba(0,0,0,.4);
}
#step-test.is-fs .stat {
    flex: 0 0 auto; padding: 3px 12px; border-radius: 8px;
    display: flex; align-items: baseline; gap: 6px; text-align: left;
}
#step-test.is-fs .stat .val { font-size: 17px; line-height: 1.1; }
#step-test.is-fs .stat .lbl { font-size: 10px; margin-top: 0; letter-spacing: .04em; }
#step-test.is-fs .type-head { margin-top: 4px; }
#step-test.is-fs .target-panel, #step-test.is-fs .capture { font-size: 25px; line-height: 1.95; }

.panel-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 0 0 6px; }

/* active-format indicator */
.fmt-state { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin: 4px 0 12px; }
.fmt-chip {
    font-family: var(--mono); font-size: 13px; min-width: 30px; text-align: center;
    padding: 5px 8px; border-radius: 7px; border: 1px solid var(--border);
    background: var(--surface-2); color: var(--muted); user-select: none;
}
.fmt-chip.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.fmt-chip.b { font-weight: 800; }
.fmt-chip.i { font-style: italic; }
.fmt-chip.u { text-decoration: underline; }
.fmt-chip.s { text-decoration: line-through; }

/* result */
.result { text-align: center; padding: 8px 0; }
.result .score { font-size: 60px; font-weight: 800; line-height: 1; color: var(--accent); font-variant-numeric: tabular-nums; }
.result .score small { font-size: 22px; font-weight: 700; color: var(--muted); }
.result .rank-line { font-size: 18px; margin: 16px 0; }

/* ---------- editor toolbar (admin) ---------- */
.toolbar { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; padding: 6px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.toolbar button {
    font-family: var(--sans); min-width: 36px; height: 34px; padding: 0 9px;
    border: 1px solid transparent; background: transparent; color: var(--text);
    border-radius: 7px; cursor: pointer; font-size: 15px;
}
.toolbar button:hover { background: var(--surface); border-color: var(--border); }
.toolbar button.active { background: var(--accent); color: #fff; }
.toolbar .tb-b { font-weight: 800; }
.toolbar .tb-i { font-style: italic; }
.toolbar .tb-u { text-decoration: underline; }
.toolbar .tb-s { text-decoration: line-through; }
.editor {
    font-family: Arial, "Helvetica Neue", Helvetica, "Segoe UI", sans-serif;
    font-size: 17px; line-height: 1.7;
    min-height: 120px; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 14px 16px;
    white-space: pre-wrap; tab-size: 4; -moz-tab-size: 4;
}

/* ---------- admin ---------- */
.admin-nav { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 22px; border-bottom: 1px solid var(--border); padding-bottom: 14px; }
.admin-nav a { font-size: 14px; font-weight: 500; color: var(--muted); text-decoration: none; padding: 8px 12px; border-radius: 8px; }
.admin-nav a:hover { background: var(--surface-2); color: var(--text); }
.admin-nav a.active { background: var(--accent); color: #fff; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.admin-table th, .admin-table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.admin-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
.admin-table tr.is-hidden td { opacity: .5; }
.tag { display: inline-block; font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.tag.hidden-tag { background: var(--surface-2); }
.tag.flag-tag   { background: var(--danger-bg); color: var(--danger); }
.tag.ok-tag     { background: var(--success-bg); color: var(--success); }
.checkbox-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.checkbox-grid label { display: flex; align-items: center; gap: 8px; font-size: 14.5px; border: 1px solid var(--border); border-radius: 9px; padding: 8px 12px; background: var(--surface); }
.checkbox-grid input { width: auto; }
.inline-form { display: inline; }
hr.div { border: 0; border-top: 1px solid var(--border); margin: 26px 0; }

/* ---------- footer ---------- */
.site-foot { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 26px; color: var(--muted); font-size: 13.5px; }
.site-foot a { color: var(--muted); text-decoration: none; }
.site-foot a:hover { color: var(--text); }
.site-foot .sep { margin: 0 6px; opacity: .5; }

/* ---------- shortcuts help ---------- */
.sc-table { width: 100%; border-collapse: collapse; }
.sc-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.sc-table td:first-child { width: 210px; }
.kbd { font-family: var(--mono); font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 7px; padding: 4px 9px; white-space: nowrap; }
.sc-eg { font-family: var(--mono); font-size: 17px; }

/* ---------- responsive ---------- */
@media (max-width: 620px) {
    body { font-size: 15px; }
    .card { padding: 18px; }
    h1 { font-size: 22px; }
    .nav-links a { padding: 7px 9px; font-size: 13.5px; }
    .brand b { font-size: 16px; }
    .target-panel, .type-box { font-size: 18px; }
    .result .score { font-size: 46px; }
    .stat .val { font-size: 21px; }
    .sc-table td:first-child { width: auto; }
}

/* ============================================================
   RETRO / PIXEL SKIN  (admin-selectable via Settings → theme)
   The old-computer feel = thick borders + hard offset shadows +
   blocky buttons + cream/terminal palette. Text stays in the
   normal readable fonts so it's always clear.
   ============================================================ */
html[data-skin="retro"] {
    --radius: 0px; --radius-sm: 0px;
    --shadow: 4px 4px 0 var(--ink);
    --shadow-sm: 3px 3px 0 var(--ink);
}
/* retro light = cream paper + black ink */
html[data-skin="retro"]:not([data-theme="dark"]) {
    --bg:#d7d7c4; --surface:#fffdf2; --surface-2:#eeecd8;
    --text:#141414; --muted:#4c4c44; --border:#141414;
    --accent:#1f4fd8; --accent-2:#153bab; --accent-soft:#e7e2c4;
    --gold:#f2b200; --silver:#9aa0a6; --bronze:#c07a3e;
}
/* retro dark = green terminal */
html[data-skin="retro"][data-theme="dark"] {
    --bg:#0c120c; --surface:#111a10; --surface-2:#18240f;
    --text:#c9f7c9; --muted:#82ad82; --border:#3aa03a;
    --accent:#7CFC00; --accent-2:#63d400; --accent-soft:#123010;
    --gold:#ffd23f; --silver:#c8d6c8; --bronze:#d18a54;
}
html[data-skin="retro"] body {
    background-image:
        linear-gradient(rgba(0,0,0,.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,.05) 1px, transparent 1px);
    background-size: 8px 8px;
}
/* headings/logo get a monospace terminal feel but stay readable */
html[data-skin="retro"] h1,
html[data-skin="retro"] h2,
html[data-skin="retro"] h3,
html[data-skin="retro"] .brand b,
html[data-skin="retro"] .panel-label,
html[data-skin="retro"] table.board thead th { font-family: var(--mono); letter-spacing: 0; }

html[data-skin="retro"] .card { border-width: 3px; box-shadow: var(--shadow); }
html[data-skin="retro"] .brand img { border-radius: 0; }
html[data-skin="retro"] .theme-toggle { border-width: 2px; box-shadow: var(--shadow-sm); }
html[data-skin="retro"] .nav-links a:hover { background: var(--surface-2); }

html[data-skin="retro"] .btn {
    border: 3px solid var(--ink); box-shadow: var(--shadow);
    background: #ffe27a; color: #141414;
}
html[data-skin="retro"] .btn:hover { background: #ffd94d; }
html[data-skin="retro"] .btn:active { transform: translate(4px,4px); box-shadow: 0 0 0 var(--ink); }
html[data-skin="retro"] .btn.secondary,
html[data-skin="retro"] .btn.btn-ghost,
html[data-skin="retro"] .btn.btn-blue { background: var(--surface); color: var(--text); }
html[data-skin="retro"] .btn.danger,
html[data-skin="retro"] .btn.btn-red { background: #ff9d9d; color: #141414; }

html[data-skin="retro"] input[type=text],
html[data-skin="retro"] input[type=password],
html[data-skin="retro"] input[type=number],
html[data-skin="retro"] select,
html[data-skin="retro"] textarea,
html[data-skin="retro"] .editor {
    border: 2px solid var(--ink); border-radius: 0;
    box-shadow: inset 2px 2px 0 rgba(0,0,0,.12);
}
html[data-skin="retro"][data-theme="dark"] input,
html[data-skin="retro"][data-theme="dark"] textarea,
html[data-skin="retro"][data-theme="dark"] .editor { box-shadow: inset 2px 2px 0 rgba(0,0,0,.4); }

html[data-skin="retro"] .stat { border-width: 2px; box-shadow: var(--shadow-sm); }
html[data-skin="retro"] .target-panel,
html[data-skin="retro"] .type-box { border-width: 3px; box-shadow: var(--shadow); }
html[data-skin="retro"] .rank-badge { border: 2px solid var(--ink); border-radius: 0; }
html[data-skin="retro"] .fmt-chip { border-width: 2px; border-radius: 0; }
html[data-skin="retro"] .notice { border-width: 2px; box-shadow: var(--shadow-sm); }
html[data-skin="retro"] .admin-nav { border-bottom-width: 3px; }
html[data-skin="retro"] .admin-nav a { border: 2px solid var(--ink); }
html[data-skin="retro"] .admin-table th,
html[data-skin="retro"] .admin-table td { border: 2px solid var(--ink); }
html[data-skin="retro"] .tag { border: 2px solid var(--ink); border-radius: 0; }
html[data-skin="retro"] .toolbar { border-width: 2px; border-radius: 0; }
html[data-skin="retro"] .toolbar button { border-radius: 0; }
html[data-skin="retro"] .kbd { border-radius: 0; border-width: 2px; }

/* ============================================================
   ADMIN — WordPress-style sidebar layout
   ============================================================ */
.admin-shell { display: flex; min-height: 100vh; align-items: stretch; }
.admin-side {
    flex: 0 0 240px; width: 240px; background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.admin-shell.side-collapsed .admin-side { display: none; }
.side-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.admin-menu { flex: 1; padding: 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.admin-menu a {
    display: block; padding: 11px 14px; border-radius: 8px;
    color: var(--text); text-decoration: none; font-weight: 500; font-size: 14.5px;
}
.admin-menu a:hover { background: var(--surface-2); }
.admin-menu a.active { background: var(--accent); color: #fff; }
.side-foot {
    padding: 12px; border-top: 1px solid var(--border);
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
}
.side-foot a { color: var(--muted); text-decoration: none; font-size: 13.5px; }
.side-foot a:hover { color: var(--text); }
.side-foot .theme-toggle { margin-left: auto; width: 34px; height: 34px; }

.admin-main { flex: 1; min-width: 0; }
.admin-topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 20px; border-bottom: 1px solid var(--border);
    position: sticky; top: 0; background: var(--bg); z-index: 5;
}
.admin-topbar .crumb { font-weight: 600; }
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text);
    border-radius: 9px; cursor: pointer; font-size: 16px; line-height: 1;
}
.icon-btn:hover { background: var(--surface-2); }
.admin-shell:not(.side-collapsed) #side-open { display: none; }
.admin-content { padding: 22px 20px; max-width: 1000px; }

/* retro skin: blocky sidebar */
html[data-skin="retro"] .admin-side { border-right-width: 3px; }
html[data-skin="retro"] .admin-menu a.active { border: 2px solid var(--ink); }
html[data-skin="retro"] .icon-btn { border-width: 2px; box-shadow: var(--shadow-sm); }

@media (max-width: 760px) {
    .admin-side {
        position: fixed; top: 0; left: 0; z-index: 50;
        width: 250px; box-shadow: var(--shadow);
    }
    .admin-content { padding: 16px 14px; }
}

/* ---------- responsive nav (collapsible menu) ---------- */
.nav { flex-wrap: wrap; }
.nav-right { display: flex; align-items: center; gap: 8px; }
.nav-toggle { display: none; }
.nav-links { display: flex; align-items: center; gap: 6px; }
@media (max-width: 640px) {
    .nav-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 38px; height: 38px; border-radius: 9px; cursor: pointer;
        border: 1px solid var(--border); background: var(--surface); color: var(--text);
        font-size: 17px; line-height: 1;
    }
    .nav-links {
        display: none; order: 3; width: 100%;
        flex-direction: column; align-items: stretch; gap: 2px; margin-top: 10px;
    }
    .nav.open .nav-links { display: flex; }
    .nav-links a { padding: 12px 14px; border-radius: 8px; }
    .nav-links a:hover { background: var(--surface-2); }
}

/* ---------- admin menu editor ---------- */
.menu-row {
    display: flex; gap: 8px; align-items: center; margin-bottom: 8px;
}
.menu-row input { flex: 1 1 auto; }
.menu-row .mr-label { flex: 1 1 40%; }
.menu-row .mr-url { flex: 1 1 55%; }
.menu-row .mr-btn {
    flex: 0 0 auto; width: 36px; height: 40px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); border-radius: 8px; cursor: pointer; font-size: 15px;
}
.menu-row .mr-btn:hover { background: var(--surface-2); }
.menu-row .mr-del:hover { background: var(--danger-bg); color: var(--danger); }
html[data-skin="retro"] .nav-toggle,
html[data-skin="retro"] .menu-row .mr-btn { border-width: 2px; }

/* ad slots + footer credit */
.ad-slot { margin: 16px auto; text-align: center; max-width: 100%; min-height: 1px; }
.foot-credit { text-align: center; color: var(--muted); font-size: 12.5px; padding: 6px 0 2px; }

/* ---------- blog / article prose ---------- */
.post-item { padding: 16px 0; border-bottom: 1px solid var(--border); }
.post-item:last-child { border-bottom: 0; }
.post-item h2 a { color: var(--text); text-decoration: none; }
.post-item h2 a:hover { color: var(--accent); }
.prose.article-body, .prose#content-editor { line-height: 1.7; }
.prose h1 { font-size: 24px; margin: 22px 0 10px; }
.prose h2 { font-size: 21px; margin: 22px 0 10px; }
.prose h3 { font-size: 17px; margin: 18px 0 8px; }
.prose p { margin: 0 0 14px; }
.prose ul, .prose ol { margin: 0 0 14px; padding-left: 24px; }
.prose li { margin: 4px 0; }
.prose a { color: var(--accent); }
.prose img { max-width: 100%; height: auto; border-radius: 8px; margin: 10px 0; }
.prose blockquote { margin: 14px 0; padding: 8px 16px; border-left: 4px solid var(--accent); background: var(--surface-2); border-radius: 0 8px 8px 0; }
.prose pre { background: var(--surface-2); padding: 12px 14px; border-radius: 8px; overflow-x: auto; font-family: var(--mono); font-size: 13.5px; }
.prose code { font-family: var(--mono); }
.prose table { border-collapse: collapse; width: 100%; margin: 14px 0; }
.prose th, .prose td { border: 1px solid var(--border); padding: 8px 10px; text-align: left; }
.c-toolbar button { min-width: 34px; }

/* detailed result stats grid */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin: 20px 0 4px;
}
.stat-grid .stat { flex: none; }
@media (max-width: 620px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ---------- social & share (footer) ---------- */
.social-row, .share-row { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.share-row { margin-top: 8px; }
.share-label { color: var(--muted); font-size: 13px; margin-right: 2px; }
.social-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--surface); color: var(--muted);
    cursor: pointer; text-decoration: none; transition: color .15s, background .15s, transform .04s;
}
.social-btn:hover { color: #fff; background: var(--accent); border-color: var(--accent); }
.social-btn:active { transform: translateY(1px); }
.social-btn.copied { color: #fff; background: var(--success); border-color: var(--success); }
/* retro skin: blocky pixel buttons */
html[data-skin="retro"] .social-btn { border-width: 2px; border-radius: 0; box-shadow: var(--shadow-sm); }
html[data-skin="retro"] .social-btn:hover { color: #141414; }
html[data-skin="retro"] .social-btn:active { transform: translate(2px,2px); box-shadow: none; }

/* ---------- collapsible social / share widgets ---------- */
.widget-row { display: flex; gap: 10px; justify-content: center; align-items: flex-start; flex-wrap: wrap; }
.widget-row-footer { margin-top: 14px; }
.widget-row-header { margin: 4px 0 0; }
.widget { position: relative; }
.widget-toggle {
    display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
    font-family: inherit; font-size: 13.5px; font-weight: 600; color: var(--text);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 8px 13px;
}
.widget-toggle:hover { background: var(--surface-2); }
.widget .caret { font-size: 10px; transition: transform .15s; }
.widget.open .caret { transform: rotate(180deg); }
.widget-panel {
    position: absolute; left: 50%; transform: translateX(-50%); z-index: 30;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; box-shadow: var(--shadow); padding: 10px; display: none;
}
.widget-down .widget-panel { top: calc(100% + 7px); }
.widget-up   .widget-panel { bottom: calc(100% + 7px); }
.widget-panel .social-row { margin: 0; flex-wrap: nowrap; }
/* pixel/blocky reveal animation (steps() = choppy retro feel) */
.widget.open .widget-panel { display: block; animation: pixOpenDown .2s steps(5) both; }
.widget-up.open .widget-panel { animation-name: pixOpenUp; }
@keyframes pixOpenDown { from { clip-path: inset(0 0 100% 0); opacity: .2; } to { clip-path: inset(0 0 0 0); opacity: 1; } }
@keyframes pixOpenUp   { from { clip-path: inset(100% 0 0 0); opacity: .2; } to { clip-path: inset(0 0 0 0); opacity: 1; } }
/* retro pixel skin */
html[data-skin="retro"] .widget-toggle { border-width: 2px; border-radius: 0; box-shadow: var(--shadow-sm); }
html[data-skin="retro"] .widget-panel  { border-width: 3px; border-radius: 0; box-shadow: var(--shadow); }
