/* Dark is the default look; [data-theme="light"] below swaps the palette.
   Both follow digg.com's design: a near-black or near-white page, card
   surfaces only a step off it, hairline borders, one blue accent, no glows. */
:root {
    --bg: #0f0f10;
    --bg-glow: #0f0f10;
    --text: #fdfdff;
    --muted: rgba(253, 253, 255, 0.7);
    --faint: rgba(253, 253, 255, 0.45);
    --panel: #151517;
    --panel-hover: #262629;
    --border: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.15);
    --accent: #6ba4ff;
    /* Fallback for a column whose category sets no `accent`. */
    --accent-default: #6ba4ff;
    /* Surfaces that are a lighter grey in dark and a soft grey in light. */
    --surface: #1e1e20;
    --surface-strong: #262629;
    --wash: #2c2c2c;
    --track: rgba(255, 255, 255, 0.15);
    --knob: #fdfdff;
    --header-bg: rgba(15, 15, 16, 0.86);
    --head-bg: rgba(21, 21, 23, 0.92);
    --panel-solid: #27272c;
    --ghost-bg: rgba(28, 28, 31, 0.97);
    --scrim: rgba(15, 15, 16, 0.55);
    --shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
    --shadow-ghost:
        0 24px 56px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.08);
    --up: #3aa267;
    --down: #cc434d;
    /* Mixed into a category colour so it stays legible on the page colour. */
    --tone: #ffffff;
    /* How much of a category colour survives the mix into --tone. Kept as a
       weight (not a finished colour) so each column's own accent still
       resolves on the column. */
    --icon-mix: 82%;
    --outlet-mix: 70%;
    --scroll: rgba(255, 255, 255, 0.14);
    --scroll-hover: rgba(255, 255, 255, 0.24);
    --shimmer-a: rgba(255, 255, 255, 0.03);
    --shimmer-b: rgba(255, 255, 255, 0.07);
    /* The page is flat, so the corner glows have nothing to light. */
    --glow-a: transparent;
    --glow-b: transparent;
    --header-h: 4rem;
    --radius: 1.125rem;
    color-scheme: dark;
}

[data-theme="light"] {
    --bg: #f5f5f9;
    --bg-glow: #f5f5f9;
    --text: #161617;
    --muted: rgba(22, 22, 23, 0.7);
    --faint: rgba(22, 22, 23, 0.45);
    --panel: #ffffff;
    --panel-hover: #f4f4f6;
    --border: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.15);
    --accent: #1c66eb;
    --accent-default: #1c66eb;
    --surface: #fcfcfe;
    --surface-strong: #f2f2f6;
    --wash: #f0f0f3;
    --track: rgba(22, 22, 23, 0.2);
    --knob: #ffffff;
    --header-bg: rgba(253, 253, 255, 0.86);
    --head-bg: rgba(255, 255, 255, 0.94);
    --panel-solid: #ffffff;
    --ghost-bg: #ffffff;
    --scrim: rgba(253, 253, 255, 0.6);
    --shadow: 0 10px 28px rgba(22, 22, 23, 0.1);
    --shadow-ghost:
        0 24px 56px rgba(22, 22, 23, 0.14),
        0 0 0 1px rgba(22, 22, 23, 0.08);
    --up: #1b9055;
    --down: #cc434d;
    --tone: #161617;
    /* Vivid category colours need more ink behind them to read on white. */
    --icon-mix: 60%;
    --outlet-mix: 50%;
    --scroll: rgba(22, 22, 23, 0.16);
    --scroll-hover: rgba(22, 22, 23, 0.28);
    --shimmer-a: rgba(22, 22, 23, 0.04);
    --shimmer-b: rgba(22, 22, 23, 0.08);
    --glow-a: transparent;
    --glow-b: transparent;
    color-scheme: light;
}

*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

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

body {
    /* Stable, not dynamic: dvh changes height while mobile browser chrome
       slides away, which re-flows the page mid-scroll and drags the sticky
       header up under the URL bar. */
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    background:
        radial-gradient(
            70rem 32rem at 15% -15%,
            var(--glow-a),
            transparent 60%
        ),
        radial-gradient(
            55rem 28rem at 85% -10%,
            var(--glow-b),
            transparent 60%
        ),
        linear-gradient(160deg, var(--bg), var(--bg-glow));
    background-attachment: fixed;
    color: var(--text);
    font-family:
        "Inter",
        "Segoe UI",
        system-ui,
        -apple-system,
        sans-serif;
    font-size: 16px;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

/* ---------------------------------------------------------------- header */

.site-header {
    position: sticky;
    top: 0;
    z-index: 20;
    height: var(--header-h);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0 clamp(1rem, 2.5vw, 2rem);
    background: var(--header-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.back-link {
    text-decoration: none;
}

/* Pinned to the middle of the header rather than to the space between the back
   link and the controls, which aren't the same width. The wrapper holds the
   wordmark and the set menu that drops out of it. */
.brand-set {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

@media (max-width: 60rem) {
    .brand-set {
        position: relative;
        /* The desktop centering is an offset from the flow position now, so it
           has to go with the absolute positioning. */
        left: auto;
        transform: none;
    }

    /* The base menu rule comes later in this file, so this needs to be the
       more specific selector, not just the later one. */
    .brand-set .set-menu {
        left: 0;
        transform: none;
    }

    /* A set name replaces NEWS, so on a narrow header the LENZ prefix steps
       aside to keep the wordmark clear of the buttons. */
    .brand-set.is-set .brand-prefix {
        display: none;
    }
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 1.15rem;
    font-weight: 300;
    letter-spacing: 0.02em;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
    /* The wordmark is a button now, so strip the button chrome. */
    padding: 0;
    border: 0;
    background: transparent;
    font-family: inherit;
    cursor: pointer;
}

.brand:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: 0.3rem;
}

.brand-name {
    /* Digg's wordmark is one colour, so the set name sits in the text tone
       and the dot beside it carries the accent. */
    color: var(--text);
    font-weight: 600;
    text-transform: uppercase;
}

.brand-caret {
    width: 0.7rem;
    height: 0.7rem;
    color: var(--faint);
    transition:
        transform 0.18s ease,
        color 0.18s ease;
}

.brand:hover .brand-caret {
    color: var(--text);
}

.brand-set.open .brand-caret {
    transform: rotate(180deg);
}

/* Sets drop out of the wordmark: each one switches a group of categories on
   and the rest off. */
.set-menu {
    display: none;
    position: absolute;
    top: calc(100% + 0.5rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 40;
    min-width: 12.5rem;
    padding: 0.35rem;
    background: var(--panel-solid);
    border: 1px solid var(--border);
    border-radius: 0.7rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.brand-set.open .set-menu {
    display: block;
}

.set-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.45rem 0.5rem;
    border: 0;
    border-radius: 0.45rem;
    background: transparent;
    color: var(--text);
    font: inherit;
    font-size: 0.78rem;
    text-align: left;
    cursor: pointer;
}

.set-option:hover {
    background: var(--wash);
}

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

.set-check {
    width: 0.8rem;
    color: var(--accent);
    opacity: 0;
}

.set-option[aria-checked="true"] .set-check {
    opacity: 1;
}

.set-option[aria-checked="true"] .set-name {
    color: var(--accent);
}

.brand-mark {
    width: 0.55rem;
    height: 0.55rem;
    border-radius: 50%;
    background: var(--accent);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.9rem;
}

.updated {
    font-size: 0.72rem;
    color: var(--muted);
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.refresh {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.85rem;
    font: inherit;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 2rem;
    cursor: pointer;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.refresh:hover {
    background: var(--surface-strong);
    border-color: var(--border-strong);
}

.refresh:active {
    transform: scale(0.97);
}

.refresh svg {
    transition: transform 0.5s ease;
}

.refresh.busy svg {
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ----------------------------------------------------------------- board */

.board {
    /* Safety floor only: applyLayout() decides the actual column count. */
    --col-min: 14rem;
    position: relative;
    flex: 1;
    display: grid;
    gap: 1rem;
    padding: 1rem;
    min-height: 0;
    align-content: start;
    /* Narrow screens stack; the wide-screen rules below set the real count. */
    grid-template-columns: 1fr;
    grid-auto-rows: auto;
}

/* Pane dividers: grab the gap between two columns or two rows and drag it,
   the way a window edge behaves. Double-click evens that pair back out. */
.resizer {
    position: absolute;
    z-index: 3;
    border-radius: 0.5rem;
    background: transparent;
    touch-action: none;
    transition: background 0.15s ease;
}

.resizer.col {
    width: 12px;
    cursor: col-resize;
}

.resizer.row {
    height: 12px;
    cursor: row-resize;
}

.resizer:hover,
.resizer.is-active {
    background: color-mix(in srgb, var(--accent) 45%, transparent);
}

/* Keep the resize cursor while dragging, even over a column header. */
body.resizing-col,
body.resizing-col * {
    cursor: col-resize !important;
    user-select: none;
}

body.resizing-row,
body.resizing-row * {
    cursor: row-resize !important;
    user-select: none;
}

.board-noscript {
    padding: 2rem;
    color: var(--muted);
    text-align: center;
    width: 100%;
}

/* One vertical stack of categories per screen column. */
.stack {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
    min-height: 0;
}

.column {
    --accent: var(--accent-default);
    min-width: 0;
    display: flex;
    flex-direction: column;
    flex: 0 0 auto;
    min-height: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

/* Entrance animation only on first paint, so reordering or dragging a
   column later doesn't fade it out again. */
.column.fresh {
    animation: fade-up 0.4s ease both;
}

@keyframes fade-up {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: none;
    }
}

.column-head {
    position: sticky;
    top: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: grab;
    user-select: none;
    padding: 0.85rem 1rem;
    background: var(--head-bg);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--border);
}

/* The header is also a button (click folds the column), so show focus. */
.column-head:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* The category's own icon, in its accent colour. */
.column-icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    color: color-mix(in srgb, var(--accent) var(--icon-mix), var(--tone));
}

.column-icon svg {
    width: 0.95rem;
    height: 0.95rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.column-title {
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--text);
}

/* Chevron that hints the header folds the column, and turns as it does. */
.column-caret {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: -0.25rem;
    color: var(--faint);
    transition: transform 0.2s ease;
}

.column-caret svg {
    width: 0.8rem;
    height: 0.8rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.column.collapsed .column-caret {
    transform: rotate(-90deg);
}

/* Folded: just the title bar, with no body or index strip underneath. */
.column.collapsed .column-body,
.column.collapsed .market-ticker {
    display: none;
}

.column.collapsed .column-head {
    border-bottom: none;
}

.column-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.1rem;
}

.column-count {
    margin-right: 0.2rem;
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
    color: var(--faint);
    padding: 0.15rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 2rem;
}

/* Day-change strip above a column's stories (Markets). */
.market-ticker {
    padding: 0.55rem 0.75rem 0.6rem;
    border-bottom: 1px solid var(--border);
}

.tick-row {
    position: relative;
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.tick {
    /* Wraps onto a second row in narrow columns instead of squeezing the
       numbers until they overlap. */
    flex: 1 1 5.4rem;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    padding: 0.35rem 0.45rem 0.4rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.55rem;
}

.tick-name {
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The day's move is the headline; the index level is the supporting line. */
.tick-value {
    font-size: 0.68rem;
    font-variant-numeric: tabular-nums;
    color: var(--muted);
}

.tick-change {
    font-size: 0.92rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    color: var(--muted);
}

/* Points and percentage, one per line. */
.tick-pct {
    font-size: 0.84rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1.15;
    color: var(--muted);
}

.tick-change.up,
.tick-pct.up {
    color: var(--up);
}

.tick-change.down,
.tick-pct.down {
    color: var(--down);
}

.market-ticker.is-stale {
    opacity: 0.55;
}

/* Hover sheet over the three quotes: blurred, with one centred refresh
   button. It floats above the row, so the tiles keep the full width and stay
   aligned with the cards below. */
.tick-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 0.55rem;
    background: var(--scrim);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
    color: var(--muted);
    cursor: pointer;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.15s ease,
        color 0.15s ease;
}

.tick-row:hover .tick-overlay,
.tick-overlay:focus-visible,
.tick-overlay.busy {
    opacity: 1;
    pointer-events: auto;
}

.tick-overlay:hover {
    color: var(--text);
}

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

.tick-overlay[disabled] {
    cursor: default;
}

.tick-overlay svg {
    width: 1.05rem;
    height: 1.05rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tick-overlay.busy svg {
    animation: spin 0.9s linear infinite;
}

/* No hover on touch screens, so the sheet stays faintly visible to be tapped. */
@media (hover: none) {
    .tick-overlay {
        opacity: 0.55;
        pointer-events: auto;
    }
}

.column-body {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    padding: 0.75rem;
}

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 50%;
    background: transparent;
    color: var(--faint);
    cursor: pointer;
    transition:
        background 0.2s ease,
        color 0.2s ease;
}

.icon-btn:hover,
.settings.open .icon-btn {
    background: var(--wash);
    color: var(--text);
}

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

.icon-btn svg {
    width: 0.95rem;
    height: 0.95rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-btn.busy svg {
    animation: spin 0.9s linear infinite;
}

.settings {
    position: relative;
    display: flex;
}

.settings-panel {
    display: none;
    position: absolute;
    top: calc(100% + 0.45rem);
    right: 0;
    z-index: 30;
    width: 13.5rem;
    padding: 0.5rem;
    background: var(--panel-solid);
    border: 1px solid var(--border);
    border-radius: 0.7rem;
    box-shadow: var(--shadow);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.settings.open .settings-panel {
    display: block;
}

/* A column with a long source list gets a wider panel, still inside the
   column so nothing is clipped. */
.settings-panel.wide {
    /* Anchored to the right of the header buttons, so the width has to leave
       room on the left for the column's own edge — overflow is hidden there. */
    width: min(21rem, calc(100vw - 5rem));
}

/* Sources read in two columns: the list fills the first column, then the
   second, instead of growing the dropdown downwards. The header's category
   list, which holds about the same number of rows, is split the same way. */
.settings-sources.is-multi,
.category-rows.is-multi {
    column-count: 2;
    column-gap: 0.4rem;
}

.settings-sources.is-multi .switch-row,
.category-rows.is-multi .switch-row {
    break-inside: avoid;
}

.header-settings {
    align-items: center;
}

.header-panel {
    width: 13.5rem;
    /* Keeps the dropdown inside a narrow phone screen whichever header
       button it hangs from. */
    max-width: calc(100vw - 2.5rem);
    max-height: 70vh;
    overflow-y: auto;
}

.settings.open > .refresh {
    background: var(--surface-strong);
    border-color: var(--border-strong);
}

.board-empty {
    margin: auto;
    padding: 3rem 1rem;
    font-size: 0.85rem;
    color: var(--muted);
    text-align: center;
}

.column.dragging {
    opacity: 0.16;
    background: transparent;
    border-style: dashed;
    box-shadow: none;
}

.column.dragging .column-head {
    cursor: grabbing;
}

/* The column preview that follows the cursor while dragging. */
.drag-ghost {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 999;
    overflow: hidden;
    pointer-events: none;
    background: var(--ghost-bg);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-ghost);
    transform: rotate(-1.2deg);
    opacity: 0.97;
    will-change: left, top;
}

.drag-ghost .column-head {
    position: static;
    cursor: grabbing;
}

.drag-ghost .column-body {
    overflow: hidden;
}

.settings-move {
    display: flex;
    align-items: center;
    gap: 0.1rem;
    margin-top: 0.3rem;
    padding-top: 0.35rem;
    border-top: 1px solid var(--border);
}

.settings-move .settings-label {
    margin-right: auto;
}

.move-btn:disabled {
    opacity: 0.3;
    cursor: default;
    background: transparent;
    color: var(--faint);
}

.settings-label {
    font-size: 0.62rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--faint);
    padding: 0.25rem 0.4rem 0.4rem;
}

.settings-label-split {
    margin-top: 0.45rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--border);
}

.settings-field {
    padding: 0 0.4rem 0.25rem;
}

/* Light/dark switch in the header Settings panel. */
.theme-toggle {
    display: flex;
    gap: 0.25rem;
}

.theme-option {
    flex: 1;
    padding: 0.42rem 0.35rem;
    font: inherit;
    font-size: 0.75rem;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    cursor: pointer;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease;
}

.theme-option:hover {
    color: var(--text);
    background: var(--wash);
}

.theme-option[aria-pressed="true"] {
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    border-color: var(--accent);
}

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

.settings-field select {
    width: 100%;
    padding: 0.42rem 0.5rem;
    font: inherit;
    font-size: 0.78rem;
    color: var(--text);
    background: var(--surface-strong);
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    cursor: pointer;
    /* The open list follows the page theme through `color-scheme` on :root;
       painting the options from the panel colour keeps their text readable. */
}

.settings-field select option {
    color: var(--text);
    background-color: var(--panel-solid);
}

.settings-field select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.settings-empty {
    font-size: 0.75rem;
    line-height: 1.5;
    color: var(--muted);
    padding: 0.2rem 0.4rem 0.35rem;
}

.switch-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem;
    border-radius: 0.45rem;
    cursor: pointer;
}

.switch-row:hover {
    background: var(--wash);
}

.switch-row input {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    flex-shrink: 0;
    width: 1.9rem;
    height: 1.05rem;
    margin: 0;
    border-radius: 1rem;
    background: var(--track);
    cursor: pointer;
    transition: background 0.2s ease;
}

.switch-row input::after {
    content: "";
    position: absolute;
    top: 0.16rem;
    left: 0.16rem;
    width: 0.73rem;
    height: 0.73rem;
    border-radius: 50%;
    background: var(--knob);
    transition: transform 0.2s ease;
}

.switch-row input:checked {
    background: var(--accent);
}

.switch-row input:checked::after {
    transform: translateX(0.85rem);
}

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

.switch-name {
    font-size: 0.78rem;
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.column-sentinel {
    width: 100%;
    height: 1px;
    flex-shrink: 0;
}

.column-note {
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--faint);
    padding: 0.5rem 0.25rem;
}

.column-note strong {
    color: var(--muted);
    font-weight: 600;
}

/* ----------------------------------------------------------------- cards */

.card {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    padding: 0.9rem 0.95rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.7rem;
    color: inherit;
    text-decoration: none;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.2s ease;
}

.card:hover {
    background: var(--surface-strong);
    border-color: color-mix(in srgb, var(--accent) 45%, transparent);
    transform: translateY(-2px);
}

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

.card-main {
    flex: 1;
    min-width: 0;
}

.card-thumb {
    width: 5rem;
    aspect-ratio: 1 / 1;
    flex-shrink: 0;
    object-fit: cover;
    border-radius: 0.5rem;
    background: var(--surface-strong);
}

.card-thumb-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.7rem;
    background: #f6f6fa;
    border: 1px solid var(--border-strong);
}

.card-thumb-logo-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.card-thumb-initial {
    font-size: 1.3rem;
    font-weight: 600;
    line-height: 1;
    color: color-mix(in srgb, var(--accent) 70%, #12101c);
}

.card-headline {
    font-size: 0.93rem;
    font-weight: 600;
    line-height: 1.35;
    letter-spacing: -0.01em;
    color: var(--text);
}

.card-blurb {
    margin-top: 0.4rem;
    font-size: 0.79rem;
    line-height: 1.55;
    color: var(--muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Story excerpts switched off in the header Settings panel. */
.no-blurbs .card-blurb {
    display: none;
}

.card-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.65rem;
    font-size: 0.65rem;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--faint);
}

.card-outlet {
    color: color-mix(in srgb, var(--accent) var(--outlet-mix), var(--tone));
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/*
   Top-stories cards open in place instead of navigating: the card keeps its
   headline, picture and meta, and unfolds the other outlets plus the reason it
   made the list. The whole card is one button; links live in the panel below.
*/
.card-top {
    display: block;
    padding: 0;
}

.card-top:hover {
    transform: none;
}

.card-top .card-toggle {
    display: flex;
    align-items: flex-start;
    gap: 0.7rem;
    width: 100%;
    padding: 0.9rem 0.95rem;
    background: none;
    border: 0;
    border-radius: inherit;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

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

/* The caret that says the card can be opened in place. */
.card-more {
    flex-shrink: 0;
    font-size: 0.72rem;
    line-height: 1;
    color: var(--faint);
    transition: transform 0.2s ease;
}

.card-top.expanded .card-more {
    transform: rotate(180deg);
    color: color-mix(in srgb, var(--accent) 65%, var(--text));
}

.card-expand {
    margin: 0 0.95rem;
    padding: 0.7rem 0 0.9rem;
    border-top: 1px solid var(--border);
}

.card-why {
    font-size: 0.72rem;
    line-height: 1.5;
    color: var(--muted);
}

.card-why strong {
    color: var(--text);
}

.card-sources-label {
    margin-top: 0.7rem;
    font-size: 0.6rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--faint);
}

.card-sources {
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
    margin: 0.3rem 0 0;
    padding: 0;
    list-style: none;
}

.card-sources a {
    display: flex;
    align-items: baseline;
    gap: 0.6rem;
    margin: 0 -0.4rem;
    padding: 0.3rem 0.4rem;
    border-radius: 0.35rem;
    font-size: 0.74rem;
    color: var(--text);
    text-decoration: none;
}

.card-sources a:hover {
    background: var(--panel-hover);
}

.card-source-outlet {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.card-source-time {
    flex-shrink: 0;
    color: var(--faint);
    font-variant-numeric: tabular-nums;
}

.card-sources-empty {
    margin-top: 0.5rem;
    font-size: 0.72rem;
    color: var(--faint);
}

.card-open {
    display: inline-block;
    margin-top: 0.75rem;
    font-size: 0.74rem;
    font-weight: 600;
    color: color-mix(in srgb, var(--accent) 65%, var(--text));
    text-decoration: none;
}

.card-open:hover {
    text-decoration: underline;
}

/* The absolute Central time sits above the relative "10m ago" label. */
.card-time-col {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.15rem;
    margin-left: auto;
    flex-shrink: 0;
    line-height: 1.25;
}

.card-clock {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.card-time {
    flex-shrink: 0;
    font-variant-numeric: tabular-nums;
}

/* A card that just arrived stays lit for 45 seconds (NEW_CARD_MS in app.js
   drops the class at the same time), then eases back to the normal card. */
.card.is-new {
    animation: card-arrive 45s ease-out both;
}

@keyframes card-arrive {
    0% {
        background: color-mix(in srgb, var(--accent) 26%, transparent);
        border-color: var(--accent);
    }
    4%,
    92% {
        background: color-mix(in srgb, var(--accent) 16%, transparent);
        border-color: color-mix(in srgb, var(--accent) 55%, transparent);
    }
    100% {
        background: var(--surface);
        border-color: var(--border);
    }
}

.card.is-loading {
    height: 6rem;
    background: linear-gradient(
        100deg,
        var(--shimmer-a) 30%,
        var(--shimmer-b) 50%,
        var(--shimmer-a) 70%
    );
    background-size: 250% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    border-color: transparent;
}

@keyframes shimmer {
    from {
        background-position: 180% 0;
    }
    to {
        background-position: -80% 0;
    }
}

/* ------------------------------------------------------------- responsive */

/* On wide screens columns sit side by side and each scrolls on its own,
   TweetDeck style. More columns than fit scroll the board sideways. */
@media (min-width: 61rem) {
    body {
        height: 100dvh;
        overflow: hidden;
    }

    .board {
        flex: 0 0 auto;
        height: calc(100dvh - var(--header-h));
        overflow-x: auto;
        overflow-y: auto;
        overscroll-behavior: contain;
        /* Column count comes from applyLayout(); each row shares its width
           between its own columns. */
        grid-template-columns: repeat(var(--tracks, 4), minmax(var(--col-min), 1fr));
        /* Rows share the window between them, so every category stays on
           screen however many rows there are. */
        grid-auto-rows: minmax(0, 1fr);
        align-content: stretch;
    }

    .stack {
        height: 100%;
    }

    /* Categories share their column's height; the dividers between them only
       change those shares. */
    .stack > .column {
        flex: 1 1 0;
    }

    /* Shrinks to its header instead of leaving an empty full-height shell. */
    .column.collapsed {
        flex: 0 0 auto;
        height: auto;
    }

    .column-body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
    }
}

/* Narrow screens: columns stack and the whole page scrolls. */
@media (max-width: 60.99rem) {
    /* The glow backdrop becomes its own fixed layer. A fixed-attachment body
       background is one of the reliable ways to make a sticky header drift on
       phones, and here the page itself scrolls. */
    html {
        background: linear-gradient(160deg, var(--bg), var(--bg-glow));
    }

    body {
        background: none;
        /* The header leaves the flow, so reserve its height. */
        padding-top: var(--header-h);
    }

    /* Phones scroll the document while their browser chrome hides and shows,
       which moves the visible viewport. A sticky header is pinned to the
       layout viewport and gets its top clipped; fixed follows what's visible. */
    .site-header {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
    }

    html::before {
        content: "";
        position: fixed;
        inset: 0;
        z-index: -1;
        pointer-events: none;
        background:
            radial-gradient(
                70rem 32rem at 15% -15%,
                var(--glow-a),
                transparent 60%
            ),
            radial-gradient(
                55rem 28rem at 85% -10%,
                var(--glow-b),
                transparent 60%
            );
    }

    .board {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
    }

    .stack > .column {
        flex: 0 0 auto;
    }

    .column {
        min-width: 0;
    }

    .column-head {
        position: static;
    }
}

@media (max-width: 30rem) {
    .updated {
        display: none;
    }

    .back-label {
        display: none;
    }

    /* Room for the wordmark and both buttons: the button labels are the first
       thing to go, and the header tightens its own spacing. */
    .refresh-label,
    .settings-button-label {
        display: none;
    }

    /* Three round buttons share the row with the wordmark, so the actions sit
       closer together. */
    .header-actions {
        gap: 0.4rem;
    }

    .header-actions .refresh {
        padding: 0.45rem 0.6rem;
    }

    /* Two columns of switches are too cramped to read on a phone, so the
       category list goes back to a single column. */
    .category-rows.is-multi {
        column-count: 1;
    }

    .site-header {
        gap: 0.5rem;
        padding: 0 0.75rem;
    }

    .brand {
        font-size: 1rem;
    }

    .back-link {
        padding: 0.45rem 0.6rem;
    }
}

/* ------------------------------------------------------------- scrollbars */

.column-body {
    scrollbar-width: thin;
    scrollbar-color: var(--scroll) transparent;
}

.column-body::-webkit-scrollbar {
    width: 8px;
}

.column-body::-webkit-scrollbar-thumb {
    background: var(--scroll);
    border-radius: 1rem;
}

.column-body::-webkit-scrollbar-thumb:hover {
    background: var(--scroll-hover);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        transition-duration: 0.001ms !important;
    }
}
