/* base.css — auto-split from style.css. */

/* ─── Murecho display font ──────────────────────────────────────────
 * Self-hosted from static/fonts/ (OFL 1.1 — see Murecho-OFL.txt).
 * Used on the brand mark, page-header h2, and series detail-title;
 * body / card / UI-chrome text stays on the Segoe UI stack. Four
 * weights × two subsets (Japanese + Latin) — browsers pick the right
 * file via unicode-range. The Japanese subset carries the full kanji
 * set (~3000 glyphs, ~290 KB per weight); the Latin subset is ~14 KB
 * per weight. Loaded `display: swap` so a slow first paint falls
 * back to the body stack rather than blocking render.
 */
@font-face {
    font-family: 'Murecho';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/fonts/murecho-latin-500.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Murecho';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/static/fonts/murecho-japanese-500.woff2') format('woff2');
    unicode-range: U+3000-30FF, U+3131-318E, U+31F0-31FF, U+3200-32FF, U+3400-4DBF, U+4E00-9FAF, U+A960-A97F, U+AC00-D7AF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF;
}
@font-face {
    font-family: 'Murecho';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/fonts/murecho-latin-600.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Murecho';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/static/fonts/murecho-japanese-600.woff2') format('woff2');
    unicode-range: U+3000-30FF, U+3131-318E, U+31F0-31FF, U+3200-32FF, U+3400-4DBF, U+4E00-9FAF, U+A960-A97F, U+AC00-D7AF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF;
}
@font-face {
    font-family: 'Murecho';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/fonts/murecho-latin-700.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Murecho';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/static/fonts/murecho-japanese-700.woff2') format('woff2');
    unicode-range: U+3000-30FF, U+3131-318E, U+31F0-31FF, U+3200-32FF, U+3400-4DBF, U+4E00-9FAF, U+A960-A97F, U+AC00-D7AF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF;
}
@font-face {
    font-family: 'Murecho';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('/static/fonts/murecho-latin-800.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Murecho';
    font-style: normal;
    font-weight: 800;
    font-display: swap;
    src: url('/static/fonts/murecho-japanese-800.woff2') format('woff2');
    unicode-range: U+3000-30FF, U+3131-318E, U+31F0-31FF, U+3200-32FF, U+3400-4DBF, U+4E00-9FAF, U+A960-A97F, U+AC00-D7AF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF;
}

/* ─── Noto Sans body font ───────────────────────────────────────────
 * Self-hosted from static/fonts/ (OFL 1.1 — see NotoSans-OFL.txt and
 * NotoSansJP-OFL.txt). Pins the body face: the old unpinned stack
 * resolved to fontconfig's default sans on Linux, Segoe UI on
 * Windows, San Francisco on macOS, and to the desktop's own UI font
 * (through `system-ui`) in any browser without fingerprinting
 * protection, so every install looked different. Latin and Latin
 * Extended are Google Fonts' own slices of the variable font (Noto
 * Sans 2.015, wght 100–900 in one file each, ~36 KB and ~168 KB); the
 * italic slices are static 400 instances (~14 KB / ~57 KB) for the
 * handful of italic hints. The Japanese file is our subset of Noto
 * Sans JP 2.004-H2 (google/fonts 295d98a7), built by
 * scripts/subset-noto-sans-jp.py: the variable font cut to the cp932
 * set (JIS X 0208 kana + kanji, half-width kana, the NEC / IBM name
 * kanji; ~7000 code points, ~2 MB), one file for every weight. Murecho's
 * ~2300-kanji display subset is too small for a body face that has to
 * render any title (it lacks 廻, 翔, 凪, 雫). Browsers pick files by
 * unicode-range, so a page with no kana or kanji never downloads the
 * Japanese file. Loaded `display: swap` like Murecho.
 *
 * Noto Sans Mono (2.014) is the same deal for `--font-mono`: Google's
 * variable Latin and Latin Extended slices (~32 KB and ~159 KB) cover
 * every tag, badge, numeric column, path, and key. No mono rule
 * renders kana or kanji, so there is no Japanese file for it.
 */
@font-face {
    font-family: 'Noto Sans';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/static/fonts/noto-sans-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Noto Sans';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/static/fonts/noto-sans-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Noto Sans';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('/static/fonts/noto-sans-latin-italic.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Noto Sans';
    font-style: italic;
    font-weight: 400;
    font-display: swap;
    src: url('/static/fonts/noto-sans-latin-ext-italic.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Noto Sans';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/static/fonts/noto-sans-jp-japanese.woff2') format('woff2');
    unicode-range: U+3000-30FF, U+3131-318E, U+31F0-31FF, U+3200-32FF, U+3400-4DBF, U+4E00-9FAF, U+A960-A97F, U+AC00-D7AF, U+F900-FAFF, U+FE30-FE4F, U+FF00-FFEF;
}
@font-face {
    font-family: 'Noto Sans Mono';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/static/fonts/noto-sans-mono-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Noto Sans Mono';
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url('/static/fonts/noto-sans-mono-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
    /* Surfaces */
    --bg: #0f0f13;
    --bg-card: #16161d;
    --bg-elevated: #1e1e28;
    --border: #2a2a3a;
    --border-accent: #3a3a4f;
    --text: #d4d4e0;
    --text-bright: #e8e8f0;
    --text-dim: #7a7a96;
    /* Palette. Every colored surface in the app derives from these;
       nothing else in static/css names a hex or rgb value except the
       black / white overlays used for scrims, shadows, and hairlines. */
    --accent: #cba6f7;
    --accent-hover: #d9bfff;
    --green: #7dd393;
    --blue: #7daed3;
    --purple: #cba6f7;
    --red: #d37d7d;
    --red-hover: #c46a6a;
    --orange: #d3b07d;
    --yellow: #e0c97d;
    --mauve: #cba6f7;
    --lavender: #b4a0ff;
    /* The same colors as bare channel triples, for tints: write
       `rgba(var(--accent-rgb), 0.12)` instead of restating the hex. */
    --bg-rgb: 15, 15, 19;
    --bg-card-rgb: 22, 22, 29;
    --border-rgb: 42, 42, 58;
    --text-bright-rgb: 232, 232, 240;
    --text-dim-rgb: 122, 122, 150;
    --accent-rgb: 203, 166, 247;
    --green-rgb: 125, 211, 147;
    --blue-rgb: 125, 174, 211;
    --red-rgb: 211, 125, 125;
    --orange-rgb: 211, 176, 125;
    --yellow-rgb: 224, 201, 125;
    --lavender-rgb: 180, 160, 255;
    /* Standard tint backgrounds for pills and badges. */
    --green-bg: rgba(var(--green-rgb), 0.1);
    --blue-bg: rgba(var(--blue-rgb), 0.1);
    --purple-bg: rgba(var(--accent-rgb), 0.1);
    --mauve-bg: rgba(var(--accent-rgb), 0.12);
    --red-bg: rgba(var(--red-rgb), 0.12);
    --orange-bg: rgba(var(--orange-rgb), 0.12);
    --yellow-bg: rgba(var(--yellow-rgb), 0.12);
    --dim-bg: rgba(var(--text-dim-rgb), 0.15);
    /* Saturated signal colors for the library card's completeness
       bar only: the pastel palette is tuned for text on dark and
       washes out as a 4px strip. Not for text or pills. */
    --signal-green: #2fce5f;
    --signal-red: #e5484d;
    --signal-accent: #a06cf5;
    --signal-accent-rgb: 160, 108, 245;
    /* Noto Sans is self-hosted (see the @font-face block above); the
       rest of the stack only covers the swap window and glyphs the
       subsets lack (Cyrillic, Greek, rare kanji). */
    --font-body: 'Noto Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    /* Murecho is used for the three display surfaces: nav-brand,
     * page-header h2, and series detail-title. See @font-face block
     * at top of this file. */
    --font-display: 'Murecho', system-ui, sans-serif;
    --font-mono: 'Noto Sans Mono', 'JetBrains Mono', 'Fira Code', monospace;
    /* Radii: sm for tags and badges, the default for inputs and
       buttons, md for tiles, lg for cards and modals, pill for pills. */
    --radius-sm: 4px;
    --radius: 6px;
    --radius-md: 8px;
    --radius-lg: 10px;
    --radius-pill: 999px;
    
    --bp-phone: 640px;
    --bp-tablet: 900px;
    --bp-desktop: 1100px;
}

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

/* Cross-document view transitions — opt every same-origin
   navigation into the browser's built-in crossfade so back/forward
   and direct link clicks stop flashing the empty page chrome
   between renders. `navigation: auto` is the entire surface;
   browsers that don't support cross-document transitions yet
   (Firefox <141, Safari <18, anything pre-Chromium-126) ignore
   the rule and get the prior hard-cut behavior. The same
   `::view-transition-old` / `::view-transition-new` pseudo-element
   tree powers htmx's `globalViewTransitions` config, so any future
   tuning here applies to boosted swaps once `hx-boost` lands. */
@view-transition {
    navigation: auto;
}

/* `[data-ts]` is the relative-timestamp idiom: server emits the raw
 * timestamp in `data-ts` AND in `textContent`, then `base.js`'s
 * refresh hook (wired to `htmx.onLoad`) replaces the textContent
 * with a humanized "4h ago" string and stamps `data-ts-rendered=1`
 * on the element. Without this rule, every page render briefly
 * showed the raw `2026-04-15 21:41:38`-style timestamp before the
 * refresh fired — visible flash of date format on every boost-nav
 * to /search, /downloads, /series, etc. `visibility: hidden`
 * preserves layout (cells keep their reserved width) so the column
 * doesn't reflow when the relative time appears. Once JS sets
 * `data-ts-rendered=1` the element flips visible. The brief empty
 * cell is much less jarring than the wrong-text flash.
 *
 * Falls back gracefully when JS doesn't run (vendor 404, etc.):
 * `<noscript>` styles in base.html could override this, but in
 * practice anyone with JS disabled deeply enough that base.js
 * never runs has bigger problems with the rest of Ryokan. */
[data-ts]:not([data-ts-rendered]) {
    visibility: hidden;
}

/* Same shape for `data-utc` (manual search results' upload-date column).
 * Server now pre-renders the trimmed `YYYY-MM-DD` string + stamps
 * `data-utc-rendered="1"`, so this rule is dormant on the happy path —
 * but a paginated-append row inserted via JS doesn't pre-stamp the
 * marker, so the CSS guard prevents the brief raw-datetime flash before
 * `renderUploadDates()` runs. */
[data-utc]:not([data-utc-rendered]) {
    visibility: hidden;
}

/* Absorb the scrollbar-width error inherent to the two viewport-
 * breakout shapes (`.detail-banner` on series pages, `.tabbed-page`
 * on Settings/System): `100vw` includes the vertical scrollbar, so
 * a full-bleed box's right edge lands ~8px past the client area and
 * mints a horizontal scrollbar on every page tall enough to scroll.
 * `clip` (not `hidden`) crops that overhang without creating a
 * scroll container, so sticky positioning inside the page keeps
 * working. Both elements need it: on `html` alone the value
 * propagates to the viewport as `hidden`, which drops the scrollbar
 * but leaves the page programmatically scrollable (focus jumps and
 * find-in-page could still shift it sideways); adding `body` clips
 * the overhang at the source so the scrollable-overflow region is
 * truly empty. The mobile media query below predates this rule and
 * keeps its stronger `hidden` form. */
html, body {
    overflow-x: clip;
}

/* Always reserve the scrollbar's column. Without it a tab short enough
   to need no scrollbar centers the page 7px further right than a tall
   one, so the sidebar hops when switching tabs. */
html {
    scrollbar-gutter: stable;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 15px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

@media (max-width: 640px) {
    html, body {
        overflow-x: hidden;
        max-width: 100vw;
    }
    body {
        font-size: 16px;
        /* Match the tabbar's zero padding-bottom (see topbar.css for
         * why env(safe-area-inset-bottom) is dropped on Android). */
        padding-bottom: 56px;
    }
    input[type="text"],
    input[type="search"],
    input[type="number"],
    input[type="password"],
    input[type="email"],
    input[type="url"],
    input[type="tel"],
    select,
    textarea {
        font-size: 16px;
    }
    .content {
        padding: 24px 14px 80px;
    }
    .rss-table-controls input,
    .rss-table-controls select {
        flex: 1 1 0;
        min-width: 0;
    }
}

.content {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px 80px;
}

/* Free-standing links (form-hint copy, alert bodies, descriptions)
   pick up the accent color so they read as actionable across every
   tab. Buttons styled as anchors (`a.btn`, `.system-tab`,
   `.cf-card-name`, etc.) keep their per-class color via higher
   specificity, so this rule only catches "naked" `<a>` elements. */
a {
    color: var(--accent);
}

a:hover {
    color: var(--accent-hover);
}

/* HTML5 [hidden] enforcement. The UA stylesheet's
   `[hidden] { display: none }` is specificity (0,1,0) and loses
   the cascade tier vs ANY author rule that explicitly sets a
   `display` value on a class selector at the same specificity —
   e.g. `.log-badge { display: inline-block }` makes a
   `<span class="log-badge" hidden>` render *visibly*, which is
   how the External Accounts "Re-link required" badge in the
   legend stayed on screen even when the server emitted the
   `hidden` attribute correctly. !important here pins the spec
   semantics so future utility classes don't have to remember
   to tack on `[hidden]`-specific rules. */
[hidden] { display: none !important; }

/* Screen-reader-only utility — keeps a label in the a11y tree
   while hiding it visually. Used by the library custom-list filter
   where the dropdown is self-evident but assistive tech still
   benefits from a label association. */
.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.page-header { margin-bottom: 28px; }

.tabbed-page-header h2,
.page-header h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 22px;
    letter-spacing: -0.005em;
    color: var(--text-bright);
    margin-bottom: 4px;
}

.page-desc { color: var(--text-dim); font-size: 14px; }

.col-score { width: 55px; text-align: center; }

.col-size { width: 90px; white-space: nowrap; }

.tag {
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: var(--radius-sm);
}

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-dim);
}

.empty-state-actions {
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 16px;
}

.page-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.series-overlay {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 6px;
    opacity: 0;
    transition: opacity 0.15s;
}

.series-card:hover .series-overlay {
    opacity: 1;
}

@keyframes ryokan-toast-enter {
    from { opacity: 0; transform: translateX(16px); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes ryokan-toast-leave {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(16px); }
}

.detail-title-row {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 4px;
}

.section-title {
    font-size: 17px;
    font-weight: 600;
    color: var(--text-bright);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-count {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    background: var(--bg-elevated);
    padding: 2px 8px;
    border-radius: var(--radius-lg);
}

.relations-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.relation-card-inert {
    cursor: default;
}

.relation-card-inert:hover {
    border-color: var(--border-accent);
    transform: none;
}

.relation-cover {
    position: relative;
    flex-shrink: 0;
    width: 56px;
    height: 80px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-elevated);
}

.relation-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.relation-type-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.75);
    color: var(--accent);
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    padding: 2px 4px;
    backdrop-filter: blur(4px);
}

.relation-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.relation-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-bright);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.relation-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-dim);
}

.relation-status-text {
    text-transform: capitalize;
}

.episodes-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 10px;
}

.episode-card {
    display: flex;
    gap: 12px;
    padding: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s;
}

.episode-card:hover {
    border-color: var(--accent);
}

.episode-thumb {
    flex-shrink: 0;
    width: 120px;
    height: 68px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--bg-elevated);
}

.episode-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.episode-thumb-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-dim);
}

.episode-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.episode-title {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-bright);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.episode-site {
    font-size: 11px;
    color: var(--text-dim);
}

.folder-select {
    padding: 6px 30px 6px 10px; /* right: chevron room, see the select rule in forms.css */
    /* Longhand `background-color` (not the `background:` shorthand)
     * so the global `select { background-image: ...chevron... }` rule
     * in forms.css survives the cascade. The shorthand resets
     * `background-image` to `initial` (none) as part of its semantics
     * — applying it here was clobbering the chevron on every
     * `.folder-select` element. */
    background-color: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 13px;
    font-family: var(--font-body);
    max-width: 260px;
}

/* Strip the default UA focus ring on every focus. The accent border
 * tint is gated on `:focus-visible` (keyboard-only) so mouse clicks
 * + option-pick don't stick the purple border until the user clicks
 * elsewhere. Same rationale + treatment as the chevron rule in
 * forms.css; see the comment there for the full story. */
.folder-select:focus { outline: none; }
.folder-select:focus-visible { border-color: var(--accent); }

.season-header-right {
    display: flex;
    align-items: center;
    gap: 6px;
}

.season-chevron {
    transition: transform 0.15s;
    color: var(--text-dim);
    flex-shrink: 0;
}

.season-subtitle {
    font-size: 12px;
    color: var(--text-dim);
    font-weight: 400;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ep-col-size { width: 80px; text-align: right; font-family: var(--font-mono); color: var(--text-dim); font-size: 12px; }

.ep-filename {
    color: var(--text);
    font-size: 12px;
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 500px;
}

.ep-title-name + .ep-filename {
    color: var(--text-dim);
    font-size: 11px;
    margin-top: 2px;
}

.ep-title-link {
    color: var(--text-bright);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
}

.ep-title-link:hover {
    color: var(--accent);
}

.help-content { max-width: 700px; }

/* A block of literal text the user copies out (a webhook body, a
   path): mono on the elevated fill with the control radius. */
.code-block {
    margin: 0;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    color: var(--text);
    overflow-x: auto;
}

@media (max-width: 640px) {
    .content { padding: 20px 16px 60px; }
    .ep-filename { max-width: 180px; }
    .ep-col-size { display: none; }
    .folder-select { max-width: none; width: 100%; }
    .ep-col-size { display: none; }
    .ep-filename { max-width: none; }
}

.settings-inline-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.text-success { color: var(--green); }

.text-error { color: var(--red); }

.title-option { display: none; }

.season-subtitle {
    color: var(--text-dim);
    font-size: 13px;
    margin-top: 2px;
}

.content {
    padding-top: 88px;
}

.title-option {
    display: none;
}

html[data-title-language="english"] .title-switcher .title-option[data-title-lang="english"],
html[data-title-language="romaji"] .title-switcher .title-option[data-title-lang="romaji"],
html[data-title-language="native"] .title-switcher .title-option[data-title-lang="native"] {
    display: inline;
}

html:not([data-title-language]) .title-switcher .title-option[data-title-lang="english"] {
    display: inline;
}

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

/* Horizontal tabs are one segmented control (Downloads, Calendar);
   the many-tab pages keep the sidebar. 32px items, same size as a
   toolbar field or a small button. */
.system-tabs,
.calendar-range-tabs,
.wanted-tabs {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
}

.system-tabs {
    margin-bottom: 20px;
}

.system-tab,
.calendar-range-tab,
.wanted-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 12px;
    border-radius: var(--radius);
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    white-space: nowrap;
    transition: color 0.15s, background 0.15s;
}

.system-tab:hover,
.calendar-range-tab:hover,
.wanted-tab:hover {
    color: var(--text);
}

.system-tab.active,
.calendar-range-tab.active,
.wanted-tab.active {
    color: var(--accent);
    background: var(--bg-card);
}

@media (max-width: 640px) {
    .system-tabs {
        flex-wrap: nowrap;
        overflow-x: auto;
        scroll-snap-type: x proximity;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .system-tabs::-webkit-scrollbar {
        display: none;
    }
    .system-tab {
        flex-shrink: 0;
        scroll-snap-align: start;
        padding: 10px 14px;
        font-size: 13px;
    }
}

.cf-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    margin-bottom: 20px;
}

.cf-section-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 16px;
    margin: 0 0 6px;
}

/* Card titles: the same 15px whether the h3 sits in a header wrapper
   (Custom Formats, Debug) or directly in the card (Backup, Misgrabs,
   Release Groups), and for the API Keys and Import page titles. */
.cf-section > h3:not(.settings-subheading),
.settings-section-title,
.import-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-bright);
    margin: 0 0 6px;
}

.cf-section-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-bright);
    text-transform: none;
    letter-spacing: normal;
    margin: 0;
}

.cf-section-desc {
    color: var(--text-dim);
    font-size: 13px;
    margin: 0 0 18px;
    line-height: 1.55;
    max-width: 820px;
}

.cf-section > *:last-child { margin-bottom: 0; }

/* A card title followed straight by a field (no description) needs
   more air than the 6px the title keeps for its description. */
.cf-section > h3 + .form-group,
.cf-section > h3 + .form-row,
.cf-section > h3 + .setting-rows,
.cf-section > h3 + form,
.cf-section > h3 + .alert,
.cf-section > h3 + .rss-table-wrap {
    margin-top: 14px;
}

/* A hint paragraph standing on its own inside a card (the intro under
   a title, a status line over a table) keeps the card's rhythm instead
   of sitting flush against whatever follows it. */
.cf-section > p.form-hint {
    margin: 0 0 14px;
}

@media (max-width: 640px) {
    .cf-section { padding: 16px; }
}

.cf-section > form:last-child > :last-child { margin-bottom: 0; }

/* A file field is the regular 41px field with the picker button
   inside it; `.form-group` gives it the same padding as here so the
   two sites (Backup, Custom Formats import) match. */
input[type="file"],
.form-group input[type="file"] {
    background: var(--bg);
    color: var(--text-dim);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 12px;
    font-size: 14px;
    max-width: 100%;
}

input[type="file"]::file-selector-button {
    background: var(--bg-card);
    color: var(--text-bright);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 5px 12px;
    margin-right: 10px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

input[type="file"]::file-selector-button:hover {
    background: var(--bg-elevated);
    border-color: var(--border-accent);
    color: var(--accent);
}

.settings-input {
    padding: 10px 12px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font-body);
    transition: border-color 0.15s;
}

.settings-input:focus {
    outline: none;
    border-color: var(--accent);
}

.settings-input[type="search"] {
    -webkit-appearance: none;
    appearance: none;
}

.settings-input[type="search"]::-webkit-search-cancel-button {
    -webkit-appearance: none;
    appearance: none;
    width: 14px;
    height: 14px;
    margin-left: 6px;
    background: var(--text-dim);
    mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M18 6L6 18M6 6l12 12' stroke='black' stroke-width='3' fill='none' stroke-linecap='round'/></svg>") center/contain no-repeat;
    -webkit-mask: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M18 6L6 18M6 6l12 12' stroke='black' stroke-width='3' fill='none' stroke-linecap='round'/></svg>") center/contain no-repeat;
    cursor: pointer;
    opacity: 0.6;
}

.settings-input[type="search"]::-webkit-search-cancel-button:hover {
    opacity: 1;
    background: var(--accent);
}

.cf-table .cf-name { font-weight: 600; color: var(--text-bright); }

.cf-origin-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.cf-origin-default { background: var(--purple-bg); color: var(--accent); }

.cf-origin-import { background: var(--blue-bg);   color: var(--blue); }

.cf-origin-manual { background: var(--bg-elevated); color: var(--text-dim); border: 1px solid var(--border); }

.cf-parse-error {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    background: rgba(var(--red-rgb), 0.12);
    color: var(--red);
}

@keyframes log-flash {
    0%   { background: rgba(var(--accent-rgb), 0.12); }
    100% { background: transparent; }
}

.logs-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 14px;
}

.rss-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* `separate` with zero spacing, not `collapse`: Firefox offsets a
   sticky header inside a collapsed-border table by the collapsed
   border, which leaves a strip above the band where scrolled rows
   show through. Cell borders are per-cell bottom lines, so the look
   is identical. */
.rss-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.rss-table-wrap {
    max-height: 680px;
    overflow: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

/* The whole header row sticks, like the Logs table, so the band spans
   every column even where a cell is empty; the inset shadow stands in
   for the collapsed bottom border, which does not travel with a sticky
   cell. */
.rss-table-wrap .rss-table thead {
    position: sticky;
    top: 0;
    z-index: 2;
}

.rss-table-wrap .rss-table th {
    background: var(--bg-elevated);
    box-shadow: inset 0 -1px 0 var(--border);
}

.rss-table th,
.rss-table td {
    text-align: left;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.rss-table td {
    background: var(--bg-card);
}

/* `:not(.btn)`: an anchor styled as a button inside a table cell
   (Backup's per-file Download) keeps its `.btn-*` colors instead of
   turning into an underlined accent link on hover. */
.rss-table td a:not(.btn) {
    color: var(--accent);
    text-decoration: none;
}

.rss-table td a:not(.btn):hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

.rss-table th {
    color: var(--text-dim);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.rss-table-controls {
    display: flex;
    gap: 12px;
    align-items: center;
    margin: 0 0 12px;
}

/* Same palette as `.settings-input` and `.folder-select`; this used to
   carry its own navy rgba fill and lavender border, which made the
   Downloads → History and System → RSS controls the odd ones out. */
.rss-table-controls input,
.rss-table-controls select {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    padding: 10px 30px 10px 12px; /* right: chevron room */
    font-size: 14px;
    font-family: var(--font-body);
    transition: border-color 0.15s;
}

.rss-table-controls input:focus,
.rss-table-controls select:focus {
    outline: none;
    border-color: var(--accent);
}

.rss-table-controls input {
    flex: 1 1 320px;
}

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

.dl-progress-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 120px;
}

.dl-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.dl-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: var(--radius-sm);
    transition: width 0.3s ease;
}

.dl-progress-text {
    font-size: 11px;
    color: var(--text-dim);
    min-width: 40px;
    text-align: right;
    white-space: nowrap;
}

/* A download the client has paused keeps its bar, in the warning
   color, and its text says so. */
.dl-progress-paused .dl-progress-fill {
    background: var(--orange);
}

.ep-dl-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    margin-top: 4px;
}

/* Keep a short inline token (a JSON example, a flag) on one line. */
.nowrap { white-space: nowrap; }
