/* ============================================================
   RateMyWorkplace — responsive stylesheet (mobile-first)
   ============================================================ */
:root {
    --bg: #f4f6fb;
    --surface: #ffffff;
    --surface-2: #f9fafc;
    --text: #1d2433;
    --muted: #5b6577;
    --border: #e3e8f0;
    --primary: #2f6bff;
    --primary-dark: #1f4fd0;
    --primary-soft: #e8eeff;
    --star: #ffb020;
    --success: #1f9d57;
    --danger: #d9405a;
    --warn: #c9871f;
    --radius: 14px;
    --shadow: 0 6px 20px rgba(20, 35, 70, 0.08);
    --shadow-sm: 0 2px 8px rgba(20, 35, 70, 0.06);
    --maxw: 1180px;
    --header-bg: rgba(255, 255, 255, 0.92);
    color-scheme: light;
}

/* ---------------- Dark theme ---------------- */
:root[data-theme="dark"] {
    --bg: #0f1420;
    --surface: #171d2b;
    --surface-2: #1f2636;
    --text: #e6eaf2;
    --muted: #9aa6bd;
    --border: #2a3346;
    --primary: #5a86ff;
    --primary-dark: #3f6cf0;
    --primary-soft: #1e2942;
    --star: #ffc24d;
    --success: #34c277;
    --danger: #f06a82;
    --warn: #e0a64a;
    --shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.35);
    --header-bg: rgba(23, 29, 43, 0.92);
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.55;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

img { max-width: 100%; }

.container {
    width: 100%;
    max-width: var(--maxw);
    margin: 0 auto;
    padding: 0 18px;
}

/* ---------------- Header / nav ---------------- */
.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--header-bg);
    backdrop-filter: saturate(180%) blur(8px);
    border-bottom: 1px solid var(--border);
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0 14px 0 4px;
    height: 38px;
    font-size: .86rem;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
}
.theme-toggle:hover { background: var(--primary-soft); border-color: var(--primary); }
.theme-toggle .tt-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 50%;
    background: var(--surface); font-size: 1rem; flex: none;
}

.nav {
    display: flex;
    align-items: center;
    gap: 14px;
    height: 64px;
}
.brand {
    font-weight: 800;
    font-size: 1.25rem;
    color: var(--text);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 8px;
}
.brand .dot { color: var(--primary); }
.nav-links {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-wrap: wrap;
}
.nav-links a {
    color: var(--text);
    padding: 8px 12px;
    border-radius: 9px;
    font-weight: 600;
    font-size: 0.94rem;
}
.nav-links a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav-toggle {
    display: none;
    margin-left: auto;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 9px;
    width: 42px; height: 42px;
    font-size: 1.3rem; cursor: pointer;
}

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    background: var(--primary);
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background .15s, transform .05s;
}
.btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: var(--surface); color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: var(--surface-2); }
.btn.ghost { background: transparent; color: var(--primary); }
.btn.danger { background: var(--danger); }
.btn.success { background: var(--success); }
.btn.small { padding: 6px 12px; font-size: 0.85rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.loading { cursor: progress; opacity: .85; }
.spinner-circle {
    display: inline-block;
    width: 1em; height: 1em;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: rmw-spin 0.6s linear infinite;
    vertical-align: -2px;
}
.btn.secondary .spinner-circle, .btn.ghost .spinner-circle {
    border-color: rgba(47, 107, 255, 0.3);
    border-top-color: var(--primary);
}
@keyframes rmw-spin { to { transform: rotate(360deg); } }

/* ---------------- Hero ---------------- */
.hero {
    background: radial-gradient(1200px 400px at 70% -10%, #d9e3ff 0%, transparent 60%),
    linear-gradient(180deg, #ffffff 0%, var(--bg) 100%);
    padding: 56px 0 40px;
    border-bottom: 1px solid var(--border);
}
/* The light-mode gradient above is hardcoded white/pale-blue, so it stays light even in
   dark mode — leaving h1 (var(--text)) and p.lead (var(--muted)) almost unreadable
   against it since those variables flip to light colors for dark mode. Give dark mode
   its own theme-aware version of the same radial-highlight-fading-to-bg effect. */
:root[data-theme="dark"] .hero {
    background: radial-gradient(1200px 400px at 70% -10%, rgba(90, 134, 255, 0.16) 0%, transparent 60%),
    linear-gradient(180deg, var(--surface) 0%, var(--bg) 100%);
}
.hero h1 {
    font-size: clamp(1.9rem, 4vw, 3rem);
    line-height: 1.1;
    margin: 0 0 12px;
    letter-spacing: -0.03em;
}
.hero p.lead { font-size: 1.1rem; color: var(--muted); max-width: 640px; margin: 0 0 26px; }

.search-bar {
    display: flex;
    gap: 10px;
    background: var(--surface);
    padding: 10px;
    border-radius: 16px;
    box-shadow: var(--shadow);
    max-width: 720px;
}
.search-bar input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    padding: 12px 14px;
    background: transparent;
    color: var(--text);
}
.search-hints { margin-top: 12px; color: var(--muted); font-size: .9rem; }
.search-hints a { margin-right: 12px; }

/* ---------------- Layout helpers ---------------- */
.section { padding: 40px 0; }
.section h2 { font-size: 1.5rem; margin: 0 0 6px; letter-spacing: -0.02em; }
.section .subtitle { color: var(--muted); margin: 0 0 22px; }
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
}
.stat-row { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 18px; }
.stat-pill {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 14px 18px;
    box-shadow: var(--shadow-sm);
    flex: 1;
    min-width: 150px;
}
.stat-pill .num { font-size: 1.7rem; font-weight: 800; }
.stat-pill .label { color: var(--muted); font-size: .85rem; }

/* ---------------- Cards ---------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 18px;
}
.company-card { display: flex; flex-direction: column; gap: 10px; transition: transform .12s, box-shadow .12s; }
.company-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.company-card .title { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.company-card .meta { color: var(--muted); font-size: .88rem; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: .76rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
}
.tag.muted { background: var(--surface-2); color: var(--muted); }
/* Selectable department tags (submit-workplace.html) — a label wrapping a checkbox. */
label.tag:has(input:checked) { background: var(--primary-soft); color: var(--primary-dark); }

/* ---------------- Stars ---------------- */
.stars { color: var(--star); letter-spacing: 1px; font-size: 1rem; }
.stars .empty { color: #d7dce6; }
.rating-line { display: flex; align-items: center; gap: 8px; }
.rating-line .score { font-weight: 800; }
.rating-line .count { color: var(--muted); font-size: .85rem; }

/* star input */
.star-input { display: inline-flex; flex-direction: row-reverse; gap: 6px; font-size: 2.8rem; }
.star-input input { display: none; }
.star-input label { color: #d7dce6; cursor: pointer; }
.star-input input:checked ~ label,
.star-input label:hover,
.star-input label:hover ~ label { color: var(--star); }

/* ---------------- Forms ---------------- */
.form-card { max-width: 560px; margin: 0 auto; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; margin-bottom: 6px; font-size: .92rem; }
.field input, .field select, .field textarea {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: .96rem;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
.field .hint { color: var(--muted); font-size: .82rem; margin-top: 4px; }
.field-row { display: flex; gap: 14px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 180px; }

.field-check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    font-size: .9rem;
    font-weight: 400;
    color: var(--text);
    cursor: pointer;
}
.field-check input[type="checkbox"] {
    width: 18px; height: 18px; margin-top: 2px; flex: none;
    accent-color: var(--primary); cursor: pointer;
}

/* ---------------- Alerts ---------------- */
.alert { padding: 12px 14px; border-radius: 10px; margin: 12px 0; font-size: .92rem; display: none; }
.alert.show { display: block; }
.alert.error { background: #fdecef; color: var(--danger); border: 1px solid #f6c9d2; }
.alert.success { background: #e8f8ef; color: var(--success); border: 1px solid #bfe8cf; }
.alert.info { background: var(--primary-soft); color: var(--primary-dark); border: 1px solid #cdd9ff; }
.alert.warn { background: #fdf4e3; color: var(--warn); border: 1px solid #f4e0b8; }

/* ---------------- Toasts (floating, auto-dismissing) ---------------- */
.toast-stack {
    position: fixed;
    top: 80px;
    right: 16px;
    z-index: 500;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: min(360px, calc(100vw - 32px));
}
.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    border-radius: 10px;
    box-shadow: var(--shadow);
    padding: 12px 14px;
    font-size: .88rem;
    color: var(--text);
    animation: rmw-toast-in .2s ease;
}
.toast.error { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
.toast.info { border-left-color: var(--primary); }
.toast.warn { border-left-color: var(--warn); }
.toast.closing { animation: rmw-toast-out .18s ease forwards; }
@keyframes rmw-toast-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
@keyframes rmw-toast-out { to { opacity: 0; transform: translateY(-8px); } }
@media (max-width: 480px) { .toast-stack { left: 16px; right: 16px; max-width: none; } }

/* ---------------- Filters / toolbar ---------------- */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; margin-bottom: 18px; }

.toolbar .spacer { margin-left: auto; }

/* Polished, theme-aware select control (custom caret, matches inputs/buttons) */
select, .field select, .toolbar select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    font-family: inherit;
    font-size: .92rem;
    font-weight: 600;
    color: var(--text);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 38px 10px 14px;
    line-height: 1.3;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background-color .15s;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%238791a5' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
    background-repeat: no-repeat;
    background-position: right 13px center;
    background-size: 14px;
}
.toolbar select { font-size: .88rem; padding-top: 9px; padding-bottom: 9px; }
select:hover, .toolbar select:hover { border-color: var(--primary); }
select:focus, .field select:focus, .toolbar select:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft);
}
select option { background: var(--surface); color: var(--text); }
.toolbar input {
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--surface); color: var(--text); font-size: .9rem; font-family: inherit;
}
.toolbar input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }

/* ---------------- Pagination ---------------- */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 26px; flex-wrap: wrap; }
.pagination button {
    min-width: 38px; padding: 8px 12px; border: 1px solid var(--border);
    background: var(--surface); border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--text);
}
.pagination button.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination button[disabled] { opacity: .5; cursor: not-allowed; }

/* ---------------- Company detail ---------------- */
.detail-head { display: flex; gap: 18px; flex-wrap: wrap; align-items: flex-start; }
.detail-head .info { flex: 1; min-width: 260px; }
.layout-2col { display: grid; grid-template-columns: 1fr 300px; gap: 26px; align-items: start; }
.ad-slot {
    background: repeating-linear-gradient(45deg, #f3f5fa, #f3f5fa 12px, #eef1f7 12px, #eef1f7 24px);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    min-height: 260px;
    display: flex; align-items: center; justify-content: center;
    color: var(--muted); font-size: .85rem; text-align: center; padding: 16px;
}

:root[data-theme="dark"] .ad-slot {
    background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 12px, var(--surface) 12px, var(--surface) 24px);
}
.ad-banner { min-height: 100px; margin: 18px 0; }
.ad-native { min-height: 0; }
.detail-aside { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 18px; }
@media (max-width: 900px) { .detail-aside { position: static; } }

.feedback-item { border-bottom: 1px solid var(--border); padding: 16px 0; }
.feedback-item:last-child { border-bottom: none; }
.feedback-item .head { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.feedback-item .author { display: inline-flex; align-items: baseline; gap: 6px; min-width: 0; flex: 1 1 auto; font-weight: 700; }
.feedback-item .author-depts {
    font-weight: 400;
    color: var(--muted);
    font-size: .82rem;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (max-width: 480px) { .feedback-item .author-depts { max-width: 110px; } }
.feedback-item .date { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.feedback-item .loc { color: var(--muted); font-size: .82rem; }
.feedback-item .rating-line strong { min-width: 0; overflow-wrap: anywhere; }
.feedback-item p { margin: 6px 0 0; overflow-wrap: anywhere; word-break: break-word; }

/* ---------------- Admin ---------------- */
.admin-layout { display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start; }
.admin-nav { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 4px; }
.admin-nav button {
    text-align: left; background: transparent; border: none; padding: 10px 12px;
    border-radius: 9px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: .92rem;
}
.admin-nav button:hover { background: var(--surface-2); color: var(--text); }
.admin-nav button.active { background: var(--primary-soft); color: var(--primary-dark); }
.admin-panel { display: none; }
.admin-panel.active { display: block; }

.flag-reason {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: bottom;
    font-size: .82rem;
}

table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { color: var(--muted); font-weight: 700; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
table.data tr:hover td { background: var(--surface-2); }
.badge { font-size: .74rem; font-weight: 700; padding: 2px 9px; border-radius: 999px; }
.badge.pending { background: #fdf4e3; color: var(--warn); }
.badge.approved { background: #e8f8ef; color: var(--success); }
.badge.rejected { background: #fdecef; color: var(--danger); }

/* ---------------- Moderator access ---------------- */
.mod-permissions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    margin: 4px 0 20px;
}
.mod-permission-card {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: var(--surface);
    cursor: pointer;
    transition: border-color .15s, background .15s, box-shadow .15s;
}
.mod-permission-card:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }
.mod-permission-card:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
}
.mod-permission-card input[type="checkbox"] {
    width: 18px; height: 18px; margin-top: 2px; flex: none; accent-color: var(--primary); cursor: pointer;
}
.mod-permission-card .icon {
    font-size: 1.3rem; line-height: 1; flex: none;
    width: 34px; height: 34px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    background: var(--surface-2);
}
.mod-permission-card:has(input:checked) .icon { background: var(--surface); }
.mod-permission-card .title { font-weight: 700; font-size: .92rem; }
.mod-permission-card .desc { color: var(--muted); font-size: .8rem; margin-top: 2px; }

.mod-list { display: flex; flex-direction: column; gap: 10px; }
.mod-list-item {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface);
}
.mod-list-item .who { font-weight: 700; }
.mod-list-item .perms { display: flex; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.mod-list-item .revoke { margin-left: 10px; }

/* ---------------- Avatars ---------------- */
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-weight: 800;
    object-fit: cover;
    overflow: hidden;
    flex: none;
    text-transform: uppercase;
    user-select: none;
}
.avatar.sm { width: 30px; height: 30px; font-size: .78rem; }
.avatar.lg { width: 96px; height: 96px; font-size: 2rem; border: 2px solid var(--border); }
.user-menu { position: relative; }
.user-menu-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 4px 8px 4px 4px;
    background: transparent;
    border: none;
    border-radius: 999px;
    color: var(--text);
    font: inherit;
    font-weight: 600;
    font-size: 0.94rem;
    cursor: pointer;
}
.user-menu-trigger:hover, .user-menu.open .user-menu-trigger { background: var(--surface-2); }
.user-menu-trigger .caret { color: var(--muted); font-size: .65rem; transition: transform .15s; }
.user-menu.open .user-menu-trigger .caret { transform: rotate(180deg); }
.user-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 170px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 6px;
    z-index: 60;
}
.user-menu.open .user-menu-dropdown { display: block; }
.user-menu-dropdown a {
    display: block;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text);
    font-weight: 600;
    font-size: 0.92rem;
}
.user-menu-dropdown a:hover { background: var(--surface-2); text-decoration: none; }
.avatar-editor { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar-editor .avatar-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.bars { display: flex; align-items: flex-end; gap: 3px; height: 160px; padding-top: 10px; }
.bars .bar { flex: 1; background: var(--primary); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.bars .bar:hover { opacity: 1; }

/* ---------------- Footer ---------------- */
.site-footer { background: #11182a; color: #c4cdde; margin-top: 50px; padding: 40px 0 24px; }
.site-footer h3 { color: #fff; margin-top: 0; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr; gap: 30px; }
.site-footer a { color: #9fb3e0; }
.footer-bottom { border-top: 1px solid #243049; margin-top: 26px; padding-top: 16px; font-size: .85rem; color: #8a96ab; text-align: center; }
.footer-legal { margin-bottom: 6px; }
.footer-legal a { color: #9fb3e0; font-weight: 600; }
.footer-legal .sep { margin: 0 8px; color: #4a5771; }
.news-item { border-bottom: 1px solid #243049; padding: 8px 0; }
.news-item:last-child { border-bottom: none; }
.news-item .t { color: #fff; font-weight: 600; }
.news-item .d { font-size: .78rem; color: #8a96ab; }

.muted { color: var(--muted); }
.center { text-align: center; }
.hidden { display: none !important; }
.spinner { text-align: center; color: var(--muted); padding: 30px; }
.pill-link { display:inline-block; padding:6px 12px; border:1px solid var(--border); border-radius:999px; color:var(--muted); font-size:.85rem; }

/* ---------------- Responsive ---------------- */
@media (max-width: 900px) {
    .layout-2col { grid-template-columns: 1fr; }
    .admin-layout { grid-template-columns: 1fr; }
    .admin-nav { position: static; flex-direction: row; flex-wrap: wrap; }
    .footer-grid { grid-template-columns: 1fr; }
}
/* A logged-in admin/moderator's nav (extra links + avatar + display name) no longer
   fits inline below ~1180px even with the widened header container above, so switch
   to the dropdown menu there instead of at the old, much narrower 680px — the wider
   threshold only decides when the hamburger appears, the dropdown itself is unchanged. */
@media (max-width: 1180px) {
    .nav-links {
        display: none;
        position: absolute; top: 64px; left: 0; right: 0;
        background: var(--surface); border-bottom: 1px solid var(--border);
        flex-direction: column; align-items: stretch; padding: 10px 18px 16px; gap: 2px;
        box-shadow: var(--shadow);
        max-height: calc(100vh - 64px);
        overflow-y: auto;
    }
    .nav-links.open { display: flex; }
    .nav-links a { padding: 12px; }
    .nav-toggle { display: inline-block; }

    .nav-links #authArea {
        display: block;
        margin-top: 8px;
        padding-top: 10px;
        border-top: 1px solid var(--border);
    }
    .nav-links #authArea .btn { width: 100%; }
    .nav-links .user-menu { width: 100%; }
    .nav-links .user-menu-trigger {
        width: 100%;
        justify-content: space-between;
        padding: 10px 12px;
    }
    .nav-links .user-menu .user-menu-dropdown {
        position: static;
        display: block;
        box-shadow: none;
        border: none;
        padding: 0 0 0 14px;
        margin-top: 2px;
    }
    .nav-links .theme-toggle {
        width: 100%;
        justify-content: flex-start;
        margin-top: 8px;
        height: 44px;
    }
}
@media (max-width: 680px) {
    .search-bar { flex-direction: column; }
    .search-bar .btn { width: 100%; }
    table.data { display: block; overflow-x: auto; white-space: nowrap; }
}

/* ---------------- Markdown content (admin updates) ---------------- */
.markdown { line-height: 1.7; color: var(--text); word-wrap: break-word; }
.markdown h1, .markdown h2, .markdown h3 { letter-spacing: -0.02em; margin: 1.2em 0 0.5em; }
.markdown h1 { font-size: 1.7rem; }
.markdown h2 { font-size: 1.35rem; }
.markdown h3 { font-size: 1.12rem; }
.markdown p { margin: 0.7em 0; }
.markdown ul, .markdown ol { margin: 0.7em 0; padding-left: 1.4em; }
.markdown li { margin: 0.25em 0; }
.markdown a { color: var(--primary); }
.markdown code {
    background: var(--surface-2); border: 1px solid var(--border);
    padding: 1px 6px; border-radius: 6px; font-size: .9em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.markdown pre {
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 10px; padding: 14px 16px; overflow-x: auto;
}
.markdown pre code { background: none; border: none; padding: 0; }
.markdown blockquote {
    margin: 0.8em 0; padding: 4px 16px; border-left: 4px solid var(--primary);
    color: var(--muted); background: var(--surface-2); border-radius: 0 8px 8px 0;
}
.markdown hr { border: none; border-top: 1px solid var(--border); margin: 1.4em 0; }
.markdown img { border-radius: 10px; }
.markdown table { border-collapse: collapse; margin: 0.8em 0; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 10px; }

/* ---------------- Update post (ads on both sides) ---------------- */
.layout-3col { display: grid; grid-template-columns: 160px 1fr 160px; gap: 26px; align-items: start; }
.layout-3col .ad-rail { position: sticky; top: 84px; display: flex; flex-direction: column; gap: 16px; }
.layout-3col .ad-rail .ad-slot { min-height: 320px; }

.update-list-item {
    display: flex; justify-content: space-between; align-items: center; gap: 14px;
    padding: 14px 16px; border: 1px solid var(--border); border-radius: 12px;
    background: var(--surface); margin-bottom: 10px; transition: transform .12s, box-shadow .12s;
}
.update-list-item:hover { transform: translateY(-2px); box-shadow: var(--shadow); text-decoration: none; }
.update-list-item .t { font-weight: 700; color: var(--text); }
.update-list-item .d { color: var(--muted); font-size: .82rem; white-space: nowrap; }

@media (max-width: 980px) {
    .layout-3col { grid-template-columns: 1fr; }
    .layout-3col .ad-rail { position: static; flex-direction: row; flex-wrap: wrap; }
    .layout-3col .ad-rail .ad-slot { flex: 1; min-width: 240px; min-height: 120px; }
}