/* ==========================================================
   Xultr - newspaper style
   Sections: colors, base, header, front page, story, comments,
   forms, account, admin, footer, small screens.
   ========================================================== */

/* ---------- Colors (light and dark) ---------- */
:root {
    --paper: #f8f5ee;
    --paper-deep: #efe9dc;
    --card: #fffdf8;
    --ink: #151515;
    --ink-soft: #3b3833;
    --muted: #6b655b;
    --rule: #d8d0c0;
    --rule-strong: #151515;
    --accent: #b3001b;
    --accent-soft: #fbe9ea;
    --good: #1f7a4a;
    --highlight: #fff1b8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 6px 20px rgba(0, 0, 0, .06);

    --font-mast: "UnifrakturMaguntia", "Old English Text MT", Georgia, serif;
    --font-head: "Playfair Display", Georgia, "Times New Roman", serif;
    --font-body: "Source Serif 4", Georgia, serif;
    --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

    --page-width: 1240px;
    --gap: 28px;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --paper: #121110;
    --paper-deep: #1a1917;
    --card: #1b1a18;
    --ink: #ece7de;
    --ink-soft: #cfc9bf;
    --muted: #a39d93;
    --rule: #34312c;
    --rule-strong: #ece7de;
    --accent: #ff5364;
    --accent-soft: #3a1a1e;
    --good: #5cc98e;
    --highlight: #4a3f12;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
    color-scheme: dark;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --paper: #121110;
        --paper-deep: #1a1917;
        --card: #1b1a18;
        --ink: #ece7de;
        --ink-soft: #cfc9bf;
        --muted: #a39d93;
        --rule: #34312c;
        --rule-strong: #ece7de;
        --accent: #ff5364;
        --accent-soft: #3a1a1e;
        --good: #5cc98e;
        --highlight: #4a3f12;
        --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 20px rgba(0, 0, 0, .35);
        color-scheme: dark;
    }
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-body);
    font-size: 18px;
    line-height: 1.55;
    overflow-x: hidden;
}

img { max-width: 100%; height: auto; display: block; }

a { color: inherit; text-decoration: none; }
a:hover { color: var(--accent); }
p a, .prose a { text-decoration: underline; text-underline-offset: 2px; }

h1, h2, h3, h4 { font-family: var(--font-head); line-height: 1.15; margin: 0 0 .4em; font-weight: 800; }

.wrap { max-width: var(--page-width); margin: 0 auto; padding: 0 16px; }

.skip-link { position: absolute; left: -9999px; }
.skip-link:focus { left: 16px; top: 8px; z-index: 100; background: var(--ink); color: var(--paper); padding: 8px 12px; }

.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.ui { font-family: var(--font-ui); }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

/* Small uppercase label above headlines, like "TECH". */
.kicker {
    font-family: var(--font-ui);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    color: var(--accent);
}

.meta {
    font-family: var(--font-ui);
    font-size: .76rem;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
}
.meta .dot::before { content: "·"; margin-right: 10px; }
.meta img.favicon { width: 14px; height: 14px; border-radius: 3px; display: inline-block; vertical-align: -2px; }

.rule { border: 0; border-top: 1px solid var(--rule); margin: 18px 0; }
.rule-double { border: 0; border-top: 3px double var(--rule-strong); margin: 0; }

/* ---------- Top bar ---------- */
.topbar {
    font-family: var(--font-ui);
    font-size: .78rem;
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
}
.topbar .wrap { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 42px; }
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 14px; white-space: nowrap; }
.topbar-date { font-weight: 600; white-space: nowrap; }
.top-search { width: 170px !important; padding: 6px 10px !important; font-size: .8rem !important; }
.show-sm { display: none !important; }

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 50%;
    background: none; border: 1px solid transparent; color: var(--ink); cursor: pointer;
}
.icon-btn:hover { border-color: var(--rule); color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }

.badge-count {
    display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--accent); color: #fff; font-size: .68rem; font-weight: 700; text-align: center; line-height: 18px;
}

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    font-family: var(--font-ui); font-size: .85rem; font-weight: 600;
    padding: 9px 16px; border-radius: 4px; cursor: pointer;
    border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
    text-decoration: none; transition: transform .08s ease, background .15s ease;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }
.btn:hover { color: var(--paper); background: var(--accent); border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--rule); }
.btn-ghost:hover { background: var(--paper-deep); color: var(--ink); border-color: var(--ink); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--ink); border-color: var(--ink); }
.btn-small { padding: 6px 11px; font-size: .78rem; }
.btn-danger { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-danger:hover { background: var(--accent); color: #fff; }
.btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; cursor: pointer; }
.btn-link:hover { color: var(--accent); }

/* Account menu */
.menu { position: relative; }
.menu > button { display: flex; align-items: center; gap: 8px; background: none; border: 0; cursor: pointer; font: inherit; color: var(--ink); padding: 4px; }
.menu-list {
    display: none; position: absolute; right: 0; top: calc(100% + 6px); z-index: 50;
    min-width: 220px; background: var(--card); border: 1px solid var(--rule); border-radius: 6px;
    box-shadow: var(--shadow); padding: 6px;
}
.menu.open .menu-list { display: block; }
.menu-list a, .menu-list button {
    display: block; width: 100%; text-align: left; padding: 8px 10px; border-radius: 4px;
    background: none; border: 0; font: inherit; color: var(--ink); cursor: pointer;
}
.menu-list a:hover, .menu-list button:hover { background: var(--paper-deep); color: var(--accent); }
.menu-list hr { border: 0; border-top: 1px solid var(--rule); margin: 6px 0; }

.avatar {
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    width: 30px; height: 30px; border-radius: 50%;
    color: #fff; font-family: var(--font-ui); font-weight: 700; font-size: .75rem;
}
.avatar-lg { width: 72px; height: 72px; font-size: 1.6rem; }

/* ---------- Masthead ---------- */
.masthead { padding: 22px 0 14px; text-align: center; }
.masthead .wrap { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.masthead-name {
    font-family: var(--font-mast); font-weight: 400;
    font-size: clamp(2.8rem, 7.5vw, 5.4rem); line-height: 1; margin: 0; letter-spacing: .01em;
}
.masthead-name a:hover { color: var(--ink); }
.masthead-tagline { font-family: var(--font-body); font-style: italic; color: var(--muted); font-size: .95rem; margin-top: 6px; }
.ear { font-family: var(--font-ui); font-size: .72rem; color: var(--muted); line-height: 1.5; max-width: 190px; }
.ear-left { justify-self: start; text-align: left; border: 1px solid var(--rule); padding: 8px 10px; }
.ear-right { justify-self: end; text-align: right; border: 1px solid var(--rule); padding: 8px 10px; }
.ear strong { display: block; color: var(--ink); font-size: .78rem; letter-spacing: .04em; text-transform: uppercase; }

/* Section menu under the masthead */
.section-nav { border-top: 1px solid var(--rule-strong); border-bottom: 3px double var(--rule-strong); }
.section-nav ul {
    list-style: none; margin: 0 auto; padding: 0; display: flex;
    gap: 2px; overflow-x: auto; scrollbar-width: none;
}
.section-nav ul::-webkit-scrollbar { display: none; }
/* Auto margins center the menu when it fits, and let it scroll from the start when it does not. */
.section-nav li:first-child { margin-left: auto; }
.section-nav li:last-child { margin-right: auto; }
.section-nav a {
    display: block; padding: 11px 14px; white-space: nowrap;
    font-family: var(--font-ui); font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
}
.section-nav a.active { color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); }

/* Scrolling "Latest" ticker */
.ticker { display: flex; align-items: stretch; border-bottom: 1px solid var(--rule); font-family: var(--font-ui); font-size: .82rem; background: var(--card); overflow: hidden; }
.ticker-label {
    flex-shrink: 0; position: relative; z-index: 2; background: var(--accent); color: #fff; font-weight: 700; letter-spacing: .1em;
    text-transform: uppercase; font-size: .7rem; padding: 10px 14px; display: flex; align-items: center; gap: 6px;
}
.ticker-label .pulse { width: 7px; height: 7px; border-radius: 50%; background: #fff; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.ticker-track { display: flex; gap: 42px; padding: 10px 0 10px 24px; white-space: nowrap; animation: ticker 80s linear infinite; }
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-track a { display: inline-flex; gap: 8px; }
.ticker-track time { color: var(--accent); font-weight: 600; }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@media (prefers-reduced-motion: reduce) { .ticker-track { animation: none; overflow-x: auto; } }

/* Flash messages */
.flashes { margin: 16px auto 0; }
.flash { font-family: var(--font-ui); font-size: .9rem; padding: 12px 16px; border-left: 4px solid var(--good); background: var(--card); margin-bottom: 8px; box-shadow: var(--shadow); }
.flash-error { border-left-color: var(--accent); }

main { padding: 26px 0 60px; min-height: 50vh; }

/* ---------- Pictures ---------- */
.pic { display: block; position: relative; overflow: hidden; background: var(--paper-deep); aspect-ratio: 16 / 9; }
.pic img { width: 100%; height: 100%; object-fit: cover; transition: transform .5s ease; }
a:hover .pic img { transform: scale(1.03); }
.pic-square { aspect-ratio: 1 / 1; }
.pic-43 { aspect-ratio: 4 / 3; }

/* ---------- Front page ---------- */
.front-top {
    display: grid;
    grid-template-columns: minmax(0, 2.1fr) minmax(0, 1fr) minmax(0, .95fr);
    gap: 0;
    border-bottom: 3px double var(--rule-strong);
    padding-bottom: 26px;
}
.front-top > * { padding: 0 var(--gap); border-left: 1px solid var(--rule); }
.front-top > *:first-child { padding-left: 0; border-left: 0; }
.front-top > *:last-child { padding-right: 0; }

.lead .pic { aspect-ratio: 3 / 2; margin-bottom: 14px; }
.lead h2 { font-size: clamp(1.8rem, 3.4vw, 2.75rem); font-weight: 900; letter-spacing: -.01em; margin: 6px 0 10px; }
.lead .summary { font-size: 1.08rem; color: var(--ink-soft); margin: 0 0 12px; }

.col-title {
    font-family: var(--font-ui); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase;
    border-top: 3px solid var(--rule-strong); padding-top: 8px; margin: 0 0 14px; display: flex; justify-content: space-between; align-items: baseline;
}
.col-title a { color: var(--accent); font-weight: 700; letter-spacing: .06em; }

.stack > * + * { border-top: 1px solid var(--rule); margin-top: 14px; padding-top: 14px; }

.card h3 { font-size: 1.12rem; font-weight: 700; margin: 4px 0 6px; }
.card .summary { font-size: .93rem; color: var(--ink-soft); margin: 0 0 8px; }
.card-feature .pic { margin-bottom: 10px; }
.card-feature h3 { font-size: 1.3rem; }

.card-thumb { display: grid; grid-template-columns: minmax(0, 1fr) 92px; gap: 12px; align-items: start; }
.card-thumb .pic { aspect-ratio: 1 / 1; grid-column: 2; grid-row: 1; }
.card-thumb > div { grid-column: 1; grid-row: 1; }
.card-thumb h3 { font-size: 1rem; }

.card-text h3 { font-size: 1rem; font-weight: 700; }

.is-read h3 { color: var(--muted); }
.is-read h3::after { content: " ✓"; font-family: var(--font-ui); font-size: .7rem; color: var(--good); }

.latest-list { list-style: none; margin: 0; padding: 0; }
.latest-list li { padding: 10px 0; border-bottom: 1px dotted var(--rule); }
.latest-list li:last-child { border-bottom: 0; }
.latest-list time { font-family: var(--font-ui); font-size: .7rem; font-weight: 700; color: var(--accent); display: block; }
.latest-list a { display: block; font-family: var(--font-head); font-weight: 700; font-size: .98rem; line-height: 1.3; margin: 2px 0; }

.under-lead { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 24px; margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--rule); }
.under-lead h3 { font-size: 1.05rem; }

.front-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 0; margin-top: 30px; }
.front-body > .sections-area { padding-right: var(--gap); }
.front-body > aside { padding-left: var(--gap); border-left: 1px solid var(--rule); }

.section-block { margin-bottom: 34px; }
.section-block-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1fr); gap: 0; }
.section-block-grid > * { padding: 0 20px; border-left: 1px solid var(--rule); }
.section-block-grid > *:first-child { padding-left: 0; border-left: 0; }
.section-block-grid > *:last-child { padding-right: 0; }
.section-block .col-title { font-size: .95rem; font-family: var(--font-head); letter-spacing: .02em; text-transform: none; font-weight: 900; }
.section-block-main { background: var(--card); border: 1px solid var(--rule); padding: 18px 20px 20px; }
.section-block-main .col-title { font-size: 1.5rem; border-top-color: var(--accent); }
.section-block .col-title a.follow-mini { font-family: var(--font-ui); font-size: .7rem; text-transform: uppercase; }

/* Most read list with big numbers */
.ranked { list-style: none; margin: 0 0 30px; padding: 0; counter-reset: rank; }
.ranked li { counter-increment: rank; display: grid; grid-template-columns: 38px 1fr; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--rule); }
.ranked li::before { content: counter(rank); font-family: var(--font-head); font-size: 2rem; font-weight: 900; line-height: 1; color: var(--accent); }
.ranked a { font-family: var(--font-head); font-weight: 700; font-size: .98rem; line-height: 1.25; }
.ranked .meta { margin-top: 4px; }

.quote-list { list-style: none; margin: 0 0 30px; padding: 0; }
.quote-list li { padding: 12px 0; border-bottom: 1px solid var(--rule); }
.quote-list blockquote { margin: 0 0 6px; font-style: italic; font-size: .95rem; color: var(--ink-soft); }
.quote-list blockquote::before { content: "“"; font-family: var(--font-head); font-size: 1.6rem; color: var(--accent); line-height: 0; vertical-align: -.35em; margin-right: 2px; }

.promo {
    border: 2px solid var(--ink); padding: 20px; margin-bottom: 30px; background: var(--card); text-align: center;
}
.promo h3 { font-size: 1.35rem; margin-bottom: 6px; }
.promo p { font-size: .95rem; color: var(--ink-soft); margin: 0 0 14px; }
.promo .btn { width: 100%; }

.empty-state { text-align: center; padding: 60px 16px; border: 1px dashed var(--rule); }
.empty-state h2 { font-size: 1.6rem; }

/* ---------- Lists (section, source, search) ---------- */
.page-head { border-bottom: 3px double var(--rule-strong); padding-bottom: 16px; margin-bottom: 22px; display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 14px; }
.page-head h1 { font-size: clamp(2rem, 4vw, 3.1rem); font-weight: 900; margin: 0; }
.page-head p { margin: 6px 0 0; color: var(--muted); font-style: italic; }
.page-head-actions { display: flex; gap: 8px; align-items: center; font-family: var(--font-ui); font-size: .8rem; }

.breadcrumb { font-family: var(--font-ui); font-size: .75rem; color: var(--muted); margin-bottom: 10px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--accent); }
.breadcrumb span::before { content: "›"; margin: 0 6px; }

.list-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 0; }
.list-layout > .list-main { padding-right: var(--gap); }
.list-layout > aside { padding-left: var(--gap); border-left: 1px solid var(--rule); }

.row-card { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--rule); }
.row-card:first-child { padding-top: 0; }
.row-card h2 { font-size: 1.35rem; margin: 4px 0 6px; }
.row-card .summary { font-size: .95rem; color: var(--ink-soft); margin: 0 0 8px; }

.pagination { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 26px; font-family: var(--font-ui); font-size: .85rem; }

.search-box { display: flex; gap: 8px; margin-bottom: 22px; }
.search-box input { flex: 1; }

/* ---------- Story page ---------- */
.reading-progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--accent); z-index: 90; transition: width .1s linear; }

.story-head { max-width: 860px; margin: 0 auto 22px; text-align: center; }
.story-head h1 { font-size: clamp(2rem, 4.6vw, 3.4rem); font-weight: 900; letter-spacing: -.015em; margin: 10px 0 14px; }
.story-head .meta { justify-content: center; font-size: .8rem; }
.story-head .byline-source { font-weight: 700; color: var(--ink); }

.story-figure { margin: 0 auto 26px; max-width: 1040px; }
.story-figure .pic { aspect-ratio: 16 / 9; }
.story-figure figcaption { font-family: var(--font-ui); font-size: .72rem; color: var(--muted); margin-top: 6px; }

.story-layout { display: grid; grid-template-columns: 64px minmax(0, 680px) 300px; justify-content: center; gap: 0 var(--gap); }

.share-rail { position: sticky; top: 20px; align-self: start; display: flex; flex-direction: column; gap: 8px; }

.share-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--rule);
    background: var(--card); color: var(--ink); cursor: pointer; font-family: var(--font-ui); font-size: .8rem;
}
.share-btn svg { width: 18px; height: 18px; }
.share-btn:hover { border-color: var(--ink); color: var(--accent); }
.share-btn.facebook:hover { color: #1877f2; }
.share-btn.instagram:hover { color: #d62976; }

.share-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 22px 0; align-items: center; }
.share-row .label { font-family: var(--font-ui); font-size: .72rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin-right: 4px; }

.story-body { font-size: 1.14rem; line-height: 1.7; }
.story-body p { margin: 0 0 1.1em; }
.story-body.drop-cap > p:first-of-type::first-letter {
    float: left; font-family: var(--font-head); font-weight: 900; font-size: 4.2em; line-height: .82; padding: 6px 10px 0 0; color: var(--accent);
}
.story-body .no-summary { font-style: italic; color: var(--muted); }

.source-box {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px;
    border-top: 3px solid var(--rule-strong); border-bottom: 1px solid var(--rule); padding: 16px 0; margin: 26px 0;
}
.source-box .who { display: flex; align-items: center; gap: 12px; font-family: var(--font-ui); }
.source-box .who img { width: 32px; height: 32px; border-radius: 6px; }
.source-box .who strong { display: block; font-size: .95rem; }
.source-box .who span { font-size: .75rem; color: var(--muted); }

.reactions { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.reaction {
    display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px;
    border: 1px solid var(--rule); background: var(--card); cursor: pointer; font-family: var(--font-ui); font-size: .85rem; color: var(--ink);
    transition: transform .1s ease;
}
.reaction:hover { border-color: var(--ink); transform: translateY(-1px); }
.reaction .emoji { font-size: 1.1rem; line-height: 1; }
.reaction .count { font-weight: 600; min-width: 8px; }
.reaction[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.reaction.pop .emoji { animation: pop .35s ease; }
@keyframes pop { 50% { transform: scale(1.5); } }

.section-label { font-family: var(--font-ui); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; margin: 30px 0 10px; }

.tools { border: 1px solid var(--rule); background: var(--card); padding: 16px; margin: 22px 0; }
.tools-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tag-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 8px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 3px 4px 3px 10px; border-radius: 999px;
    background: var(--highlight); font-family: var(--font-ui); font-size: .78rem; font-weight: 600;
}
.chip button { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: .9rem; padding: 0 5px; line-height: 1; }
.chip button:hover { color: var(--accent); }
.chip-link { padding: 3px 10px; }
.chip-link.active { background: var(--ink); color: var(--paper); }
.tag-form { display: flex; gap: 6px; }
.tag-form input { max-width: 220px; }
.note-form textarea { min-height: 90px; }
.note-status { font-family: var(--font-ui); font-size: .75rem; color: var(--good); margin-left: 8px; }

.login-nudge {
    border: 1px dashed var(--rule); padding: 16px; margin: 22px 0; text-align: center; font-family: var(--font-ui); font-size: .9rem;
}

.side-card { border-top: 3px solid var(--rule-strong); padding-top: 10px; margin-bottom: 28px; }
.side-card > h3 { font-family: var(--font-ui); font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 12px; }
.follow-card { background: var(--card); border: 1px solid var(--rule); padding: 16px; margin-bottom: 28px; font-family: var(--font-ui); font-size: .85rem; }
.follow-card .row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; }
.follow-card .row + .row { border-top: 1px solid var(--rule); }
.follow-card img { width: 20px; height: 20px; border-radius: 4px; display: inline-block; vertical-align: middle; margin-right: 6px; }

.related-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 26px; }
.more-stories { border-top: 3px double var(--rule-strong); margin-top: 40px; padding-top: 18px; }

/* ---------- Comments ---------- */
.comments-head { display: flex; justify-content: space-between; align-items: baseline; border-top: 3px solid var(--rule-strong); padding-top: 10px; margin-top: 34px; }
.comments-head h2 { font-size: 1.5rem; margin: 0; }
.sort-links { font-family: var(--font-ui); font-size: .8rem; display: flex; gap: 12px; }
.sort-links a.active { color: var(--accent); font-weight: 700; }

.comment-form { margin: 16px 0 24px; }
.comment-form textarea { min-height: 96px; }
.comment-form .form-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-family: var(--font-ui); font-size: .75rem; color: var(--muted); gap: 10px; }

.comment-list { list-style: none; margin: 0; padding: 0; }
.comment { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 12px; padding: 16px 0; border-bottom: 1px solid var(--rule); }
.comment .avatar { width: 36px; height: 36px; }
.comment-head { font-family: var(--font-ui); font-size: .8rem; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; }
.comment-head .name { font-weight: 700; color: var(--ink); }
.role-badge { font-size: .62rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; background: var(--ink); color: var(--paper); padding: 2px 6px; border-radius: 3px; }
.comment-body { font-size: 1rem; margin: 6px 0 8px; overflow-wrap: anywhere; }
.comment-actions { display: flex; flex-wrap: wrap; gap: 14px; font-family: var(--font-ui); font-size: .76rem; }
.comment-actions button { background: none; border: 0; padding: 0; cursor: pointer; color: var(--muted); font: inherit; }
.comment-actions button:hover { color: var(--accent); }
.comment-actions .liked { color: var(--accent); font-weight: 700; }
.replies { list-style: none; margin: 8px 0 0; padding: 0 0 0 16px; border-left: 2px solid var(--rule); grid-column: 2; }
.replies .comment { border-bottom: 0; padding: 10px 0; }
.reply-form { grid-column: 2; margin-top: 8px; }
.comment:target { background: var(--highlight); }
.comment.flash-in { animation: flash-in 1.6s ease; }
@keyframes flash-in { from { background: var(--highlight); } to { background: transparent; } }

/* ---------- Forms ---------- */
label { display: block; font-family: var(--font-ui); font-size: .82rem; font-weight: 600; margin: 0 0 6px; }
.field { margin-bottom: 16px; }
.field small { display: block; font-family: var(--font-ui); font-size: .74rem; color: var(--muted); margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=url], input[type=search], input[type=number], select, textarea {
    width: 100%; font: inherit; font-family: var(--font-ui); font-size: .95rem;
    padding: 10px 12px; border: 1px solid var(--rule); border-radius: 4px; background: var(--card); color: var(--ink);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; line-height: 1.5; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 3px; width: 16px; height: 16px; accent-color: var(--accent); }

.code-input { font-size: 2rem !important; letter-spacing: .5em; text-align: center; font-weight: 700; font-family: var(--font-ui); }

.auth-card {
    max-width: 460px; margin: 10px auto; background: var(--card); border: 1px solid var(--rule); box-shadow: var(--shadow);
    padding: 34px 30px;
}
.auth-card h1 { font-size: 2rem; text-align: center; }
.auth-card .intro { text-align: center; color: var(--muted); font-size: .98rem; margin: 0 0 22px; }
.auth-card .btn { width: 100%; padding: 12px; }
.auth-foot { text-align: center; font-family: var(--font-ui); font-size: .85rem; margin-top: 18px; color: var(--muted); }
.auth-foot a { color: var(--accent); font-weight: 600; }
.perks { list-style: none; padding: 0; margin: 0 0 20px; font-family: var(--font-ui); font-size: .82rem; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.perks li::before { content: "✓ "; color: var(--good); font-weight: 700; }
.g-recaptcha { margin-bottom: 16px; }

/* ---------- Account ---------- */
.account-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 0; }
.account-nav { padding-right: var(--gap); border-right: 1px solid var(--rule); font-family: var(--font-ui); font-size: .88rem; }
.account-nav a { display: flex; justify-content: space-between; padding: 9px 10px; border-radius: 4px; }
.account-nav a.active { background: var(--ink); color: var(--paper); }
.account-main { padding-left: var(--gap); min-width: 0; }
.account-main h1 { font-size: 2rem; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin: 16px 0 26px; }
.stat { border: 1px solid var(--rule); background: var(--card); padding: 14px; text-align: center; }
.stat strong { display: block; font-family: var(--font-head); font-size: 1.9rem; font-weight: 900; }
.stat span { font-family: var(--font-ui); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.panel { border: 1px solid var(--rule); background: var(--card); padding: 20px; margin-bottom: 22px; }
.panel h2 { font-size: 1.25rem; }
.note-card { border-left: 3px solid var(--accent); padding: 4px 0 4px 14px; margin: 8px 0 0; font-style: italic; color: var(--ink-soft); white-space: pre-wrap; }

.section-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; margin: 18px 0; }
.section-picker label {
    display: flex; flex-direction: column; gap: 4px; border: 2px solid var(--rule); background: var(--card); padding: 16px; cursor: pointer; margin: 0;
    font-family: var(--font-head); font-size: 1.2rem; font-weight: 800;
}
.section-picker small { font-family: var(--font-ui); font-weight: 400; font-size: .75rem; color: var(--muted); }
.section-picker input { position: absolute; opacity: 0; }
.section-picker label:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.section-picker label:has(input:checked)::after { content: "✓ Following"; font-family: var(--font-ui); font-size: .72rem; color: var(--accent); font-weight: 700; }

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-family: var(--font-ui); font-size: .84rem; }
table.data th { text-align: left; font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-bottom: 2px solid var(--rule-strong); padding: 8px; }
table.data td { border-bottom: 1px solid var(--rule); padding: 9px 8px; vertical-align: top; }
table.data tr:hover td { background: var(--paper-deep); }

.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; font-family: var(--font-ui); font-size: .7rem; font-weight: 700; background: var(--paper-deep); }
.pill-good { background: #dff3e7; color: #17603a; }
.pill-bad { background: var(--accent-soft); color: var(--accent); }
.pill-warn { background: #fff1c9; color: #7a5600; }
:root[data-theme="dark"] .pill-good { background: #173826; color: #7fe0a8; }
:root[data-theme="dark"] .pill-warn { background: #3a2e0c; color: #f2c75c; }

/* ---------- Static pages ---------- */
.prose { max-width: 720px; margin: 0 auto; }
.prose h1 { font-size: 2.6rem; text-align: center; }
.prose h2 { font-size: 1.4rem; margin-top: 1.6em; }
.prose p, .prose li { font-size: 1.08rem; }

.sources-grid { columns: 3 260px; column-gap: var(--gap); }
.sources-group { break-inside: avoid; margin-bottom: 26px; }
.sources-group ul { list-style: none; margin: 0; padding: 0; }
.sources-group li { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-bottom: 1px dotted var(--rule); font-family: var(--font-ui); font-size: .9rem; }
.sources-group li img { width: 16px; height: 16px; border-radius: 3px; }
.sources-group li span { margin-left: auto; color: var(--muted); font-size: .75rem; }

.error-page { text-align: center; padding: 40px 16px; }
.error-page .code { font-family: var(--font-mast); font-size: 7rem; line-height: 1; color: var(--accent); }

/* ---------- Footer ---------- */
.site-footer { border-top: 3px double var(--rule-strong); background: var(--paper-deep); padding: 36px 0 24px; font-family: var(--font-ui); font-size: .85rem; }
.footer-grid { display: grid; grid-template-columns: 1.5fr 1fr 1fr 1fr; gap: var(--gap); }
.footer-brand .masthead-name { font-size: 2.6rem; text-align: left; }
.footer-brand p { color: var(--muted); font-family: var(--font-body); font-size: .95rem; }
.site-footer h4 { font-family: var(--font-ui); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; margin-bottom: 10px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { padding: 4px 0; }
.footer-bottom { border-top: 1px solid var(--rule); margin-top: 26px; padding-top: 16px; color: var(--muted); display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; font-size: .78rem; }
.social { display: flex; gap: 8px; margin-top: 12px; }

/* Toast message at the bottom */
.toast {
    position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 120px); z-index: 200;
    background: var(--ink); color: var(--paper); font-family: var(--font-ui); font-size: .88rem;
    padding: 12px 18px; border-radius: 6px; box-shadow: var(--shadow); max-width: calc(100vw - 32px);
    transition: transform .25s ease; pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); }
.toast.error { background: var(--accent); color: #fff; }

/* ---------- Admin ---------- */
.admin-body { background: var(--paper-deep); }
.admin-shell { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.admin-side { background: #151515; color: #e8e3d9; padding: 20px 14px; font-family: var(--font-ui); font-size: .88rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.admin-side .masthead-name { font-size: 2rem; color: #fff; margin-bottom: 4px; }
.admin-side .role { font-size: .7rem; text-transform: uppercase; letter-spacing: .12em; color: #a39d93; margin-bottom: 20px; }
.admin-side a { display: flex; justify-content: space-between; align-items: center; padding: 9px 10px; border-radius: 4px; color: #e8e3d9; }
.admin-side a:hover { background: #2a2825; color: #fff; }
.admin-side a.active { background: var(--accent); color: #fff; }
.admin-side hr { border: 0; border-top: 1px solid #333; margin: 14px 0; }
.admin-main { padding: 26px 30px 60px; min-width: 0; }
.admin-main h1 { font-size: 1.9rem; margin-bottom: 18px; display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.admin-cards .stat { text-align: left; }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 140px; padding-top: 10px; }
.bars div { flex: 1; background: var(--accent); min-height: 2px; position: relative; border-radius: 2px 2px 0 0; }
.bars div span { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-family: var(--font-ui); font-size: .6rem; color: var(--muted); white-space: nowrap; }
.inline-form { display: inline; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; align-items: center; }
.filters input, .filters select { width: auto; }
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--rule-strong); margin-bottom: 16px; font-family: var(--font-ui); font-size: .85rem; }
.tabs a { padding: 8px 14px; border-radius: 4px 4px 0 0; }
.tabs a.active { background: var(--ink); color: var(--paper); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- Smaller screens ---------- */
@media (max-width: 1100px) {
    .front-top { grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); }
    .front-top > .latest-col { grid-column: 1 / -1; border-left: 0; padding: 22px 0 0; border-top: 1px solid var(--rule); margin-top: 22px; }
    .front-top > .latest-col .latest-list { columns: 2; column-gap: var(--gap); }
    .latest-list li { break-inside: avoid; }
    .story-layout { grid-template-columns: minmax(0, 680px) 280px; }
    .share-rail { display: none; }
    .admin-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 900px) {
    body { font-size: 17px; }
    :root { --gap: 20px; }
    .masthead .wrap { grid-template-columns: 1fr; }
    .ear { display: none; }
    .front-top, .front-body, .list-layout, .story-layout, .section-block-grid, .account-layout, .admin-grid { grid-template-columns: minmax(0, 1fr); }
    .front-top > *, .section-block-grid > * { border-left: 0; padding: 0; }
    .front-top > * + * { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--rule); }
    .section-block-grid > * + * { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--rule); }
    .front-body > .sections-area, .list-layout > .list-main { padding-right: 0; }
    .front-body > aside, .list-layout > aside { padding-left: 0; border-left: 0; border-top: 3px double var(--rule-strong); padding-top: 22px; }
    .front-top > .latest-col .latest-list { columns: 1; }
    .related-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
    .row-card { grid-template-columns: 130px minmax(0, 1fr); gap: 14px; }
    .row-card h2 { font-size: 1.1rem; }
    .row-card .summary { display: none; }
    .account-nav { border-right: 0; padding: 0 0 16px; display: flex; overflow-x: auto; gap: 4px; border-bottom: 1px solid var(--rule); margin-bottom: 20px; }
    .account-nav a { white-space: nowrap; }
    .account-main { padding-left: 0; }
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .admin-shell { grid-template-columns: minmax(0, 1fr); }
    .admin-side { position: static; height: auto; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
    .admin-side .masthead-name, .admin-side .role, .admin-side hr { display: none; }
    .admin-main { padding: 20px 16px 60px; }
    .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
    .topbar-date .long { display: none; }
    .topbar .hide-sm { display: none; }
    .show-sm { display: inline-flex !important; }
    .related-grid { grid-template-columns: minmax(0, 1fr); }
    .under-lead { grid-template-columns: 1fr; }
    .footer-grid { grid-template-columns: 1fr; }
    .perks { grid-template-columns: 1fr; }
    .auth-card { padding: 24px 18px; border-left: 0; border-right: 0; }
    .story-body.drop-cap > p:first-of-type::first-letter { font-size: 3.4em; }
    .admin-cards { grid-template-columns: minmax(0, 1fr); }
}
