/*
 * Reader — paper and ink.
 * System fonts only (no downloads); one accent; themes via [data-theme] on <html>,
 * set by /js/prefs.js before first paint. No inline styles (CSP style-src 'self').
 */

:root {
    --serif: Charter, "Bitstream Charter", "Sitka Text", "Iowan Old Style", "Palatino Linotype", Cambria, Georgia, serif;
    --sans: "Seravek", "Gill Sans Nova", Ubuntu, Calibri, "Noto Sans", "DejaVu Sans", system-ui, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", "DejaVu Sans Mono", Menlo, monospace;

    --paper: #f6f2ea;
    --paper-2: #efe9dd;
    --ink: #1e1b17;
    --ink-2: #4a443c;
    --muted: #7a7266;
    --rule: #ddd4c4;
    --accent: #a33a24;
    --accent-ink: #fffaf2;
    --bad: #9b2c1d;
    --shadow: 0 1px 0 rgba(30, 27, 23, .04), 0 12px 32px -18px rgba(30, 27, 23, .35);

    --measure: 38rem;
    --body-size: 1.1875rem;
    --body-font: var(--serif);
    --bar-h: 4.25rem;

    color-scheme: light;
}

/* Themes. "auto" follows the system (dark at night). */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="sepia"]) {
        --paper: #151412; --paper-2: #1d1b18; --ink: #e9e3d8; --ink-2: #c9c1b3;
        --muted: #8f877a; --rule: #2f2b26; --accent: #e3825f; --accent-ink: #1a1310;
        --bad: #e58a74; --shadow: 0 12px 32px -18px rgba(0, 0, 0, .8);
        color-scheme: dark;
    }
}
:root[data-theme="sepia"] {
    --paper: #f1e5cc; --paper-2: #e9dbbd; --ink: #3a2c1e; --ink-2: #5a4632;
    --muted: #84705a; --rule: #d9c7a4; --accent: #9a4a1f; --accent-ink: #fbf3e2;
    color-scheme: light;
}
:root[data-theme="dark"] {
    --paper: #151412; --paper-2: #1d1b18; --ink: #e9e3d8; --ink-2: #c9c1b3;
    --muted: #8f877a; --rule: #2f2b26; --accent: #e3825f; --accent-ink: #1a1310;
    --bad: #e58a74; --shadow: 0 12px 32px -18px rgba(0, 0, 0, .8);
    color-scheme: dark;
}

/* Text settings: 5 sizes, serif / sans. */
:root[data-size="1"] { --body-size: 1rem; }
:root[data-size="2"] { --body-size: 1.0938rem; }
:root[data-size="3"] { --body-size: 1.1875rem; }
:root[data-size="4"] { --body-size: 1.3125rem; }
:root[data-size="5"] { --body-size: 1.4688rem; }
:root[data-font="sans"] { --body-font: var(--sans); }

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

/* `hidden` wins over any display set by a class (JS toggles it). */
[hidden] { display: none !important; }

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    background: var(--paper);
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-x: clip; /* a stray wide element must never scroll the page sideways */
    background: var(--paper);
    color: var(--ink);
    font: 400 1rem/1.5 var(--sans);
    font-kerning: normal;
    -webkit-font-smoothing: antialiased;
    transition: background-color .25s ease, color .25s ease;
}

a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 2px; }

.visually-hidden {
    position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip-path: inset(50%); white-space: nowrap;
}

code { font-family: var(--mono); font-size: .9em; }

/* ── Buttons ───────────────────────────────────────────── */

.btn, .act, .chip, .seg-btn {
    font: inherit;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: 44px; padding: 0 1.1rem;
    border: 1px solid var(--rule); border-radius: 999px;
    background: transparent; color: var(--ink);
    font-family: var(--sans); font-size: .95rem; letter-spacing: .01em;
    transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-quiet { min-height: 36px; padding: 0 .9rem; font-size: .875rem; }

.btn-link {
    background: none; border: 0; padding: .5rem 0; min-height: 44px;
    font: inherit; color: var(--muted); text-decoration: underline;
    text-decoration-thickness: 1px; text-underline-offset: 3px; cursor: pointer;
}
.btn-link:hover { color: var(--ink); }

/* ── Wordmark & masthead ──────────────────────────────── */

.wordmark {
    margin: 0;
    font-family: var(--serif);
    font-style: italic;
    font-weight: 700;
    font-size: 2.6rem;
    line-height: 1;
    letter-spacing: -.02em;
}
.wordmark::after {
    content: ".";
    color: var(--accent);
    font-style: normal;
}

.masthead {
    max-width: 46rem;
    margin: 0 auto;
    padding: max(2rem, env(safe-area-inset-top)) 1.25rem .9rem;
    border-bottom: 3px double var(--rule);
    display: flex; flex-direction: column-reverse; gap: .35rem;
}
.masthead-date {
    margin: 0;
    font-family: var(--sans);
    font-size: .72rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--muted);
}

/* ── List ──────────────────────────────────────────────── */

.list-wrap {
    max-width: 46rem;
    margin: 0 auto;
    padding: 0 1.25rem 3rem;
}

.tabs {
    display: flex; gap: 1.5rem;
    border-bottom: 1px solid var(--rule);
}
.tab {
    position: relative;
    display: inline-flex; align-items: center; gap: .3rem;
    min-height: 48px;
    font-family: var(--serif);
    font-size: 1.15rem;
    text-decoration: none;
    color: var(--muted);
    transition: color .15s ease;
}
.tab:hover { color: var(--ink); }
.tab.is-active { color: var(--ink); }
.tab.is-active::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: -1px;
    height: 2px; background: var(--accent);
}
.tab-count { font-family: var(--mono); font-size: .8rem; color: var(--muted); }

.chips {
    display: flex; flex-wrap: wrap; gap: .5rem;
    padding: .9rem 0 .4rem;
}
.chip {
    display: inline-flex; align-items: center;
    min-height: 34px; padding: 0 .85rem;
    border: 1px solid var(--rule); border-radius: 999px;
    font-size: .85rem; letter-spacing: .02em;
    text-decoration: none; color: var(--ink-2);
    transition: border-color .15s ease, background-color .15s ease;
}
.chip:hover { border-color: var(--ink-2); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }

.rows { list-style: none; margin: 0; padding: 0; }

.row {
    position: relative;
    display: flex; align-items: flex-start; gap: 1rem;
    border-bottom: 1px solid var(--rule);
    animation: row-in .35s ease both;
}
.row:nth-child(2) { animation-delay: .03s; }
.row:nth-child(3) { animation-delay: .06s; }
.row:nth-child(4) { animation-delay: .09s; }
.row:nth-child(5) { animation-delay: .12s; }
.row:nth-child(n+6) { animation-delay: .15s; }
@keyframes row-in { from { opacity: 0; transform: translateY(4px); } }

.row-link {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; gap: .3rem;
    padding: .95rem 0 1rem;
    text-decoration: none;
}
.row-title {
    font-family: var(--serif);
    font-size: 1.16rem;
    line-height: 1.3;
    font-weight: 600;
    letter-spacing: -.005em;
    overflow-wrap: anywhere;
    transition: color .15s ease;
}
.row-link:hover .row-title { color: var(--accent); }
.row-link:visited .row-title { color: var(--ink-2); }

.row-meta {
    display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .55rem; row-gap: .1rem;
    font-size: .8rem; color: var(--muted);
}
.row-meta > span + span::before { content: "·"; margin-right: .55rem; color: var(--rule); }
.row-source {
    font-size: .68rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 600;
    color: var(--ink-2);
}
.row-source-mail { color: var(--accent); }
.row-site { overflow-wrap: anywhere; }
.row-min, .row-age { font-family: var(--mono); font-size: .74rem; }

.row-note { font-size: .8rem; font-style: italic; color: var(--muted); }
.row-note-bad { color: var(--bad); }

.row-progress, .row-progress::-webkit-progress-bar {
    appearance: none; -webkit-appearance: none;
    display: block; width: 100%; height: 2px; margin-top: .25rem;
    border: 0; background: var(--paper-2); border-radius: 2px; overflow: hidden;
}
.row-progress::-webkit-progress-value { background: var(--accent); }
.row-progress::-moz-progress-bar { background: var(--accent); }

.row-action { display: flex; align-items: center; gap: .6rem; padding-top: .95rem; }
.row-verdict { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.row-done .row-title { font-weight: 500; color: var(--ink-2); }

.empty {
    margin: 3rem 0; text-align: center;
    font-family: var(--serif); font-style: italic; font-size: 1.2rem; color: var(--muted);
}

.postponed { margin-top: 1.5rem; }
.postponed summary {
    display: inline-flex; align-items: center; gap: .35rem; min-height: 44px;
    cursor: pointer; list-style: none;
    font-size: .85rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.postponed summary::-webkit-details-marker { display: none; }
.postponed summary::before { content: "▸"; transition: transform .2s ease; }
.postponed[open] summary::before { transform: rotate(90deg); }
.postponed .row { opacity: .72; }

.list-foot-note { margin-top: 1.5rem; font-size: .8rem; color: var(--muted); }

.site-foot {
    max-width: 46rem; margin: 0 auto;
    padding: 1rem 1.25rem max(2rem, env(safe-area-inset-bottom));
    display: flex; justify-content: flex-end;
}

/* ── Reading view ──────────────────────────────────────── */

.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; justify-content: space-between;
    max-width: calc(var(--measure) + 2.5rem); margin: 0 auto;
    padding: env(safe-area-inset-top) 1.25rem 0;
    background: var(--paper);
    transition: transform .25s ease, background-color .25s ease;
}
.topbar.is-hidden { transform: translateY(-100%); }
.topbar-back {
    display: inline-flex; align-items: center; min-height: 48px;
    font-size: .9rem; color: var(--muted); text-decoration: none;
}
.topbar-back:hover { color: var(--ink); }
.topbar-prefs {
    min-width: 48px; min-height: 48px;
    background: none; border: 0; color: var(--ink-2); cursor: pointer;
    font-family: var(--serif); font-size: 1.15rem;
}
.topbar-prefs[aria-expanded="true"] { color: var(--accent); }

.prefs {
    position: sticky; top: calc(48px + env(safe-area-inset-top)); z-index: 9;
    max-width: 24rem; margin: 0 1rem 0 auto;
    padding: 1rem 1.1rem;
    background: var(--paper-2); color: var(--ink);
    border: 1px solid var(--rule); border-radius: 12px;
    box-shadow: var(--shadow);
    display: grid; gap: .8rem;
    animation: prefs-in .18s ease both;
}
@media (min-width: 46rem) { .prefs { margin-right: calc((100vw - var(--measure)) / 2 - 2rem); } }
.prefs[hidden] { display: none; }
@keyframes prefs-in { from { opacity: 0; transform: translateY(-6px); } }
.prefs-row { display: grid; grid-template-columns: 5rem 1fr; align-items: center; gap: .6rem; }
.prefs-label { font-size: .72rem; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.seg {
    display: flex; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden;
}
.seg-btn {
    flex: 1; min-height: 44px; padding: 0 .4rem;
    background: transparent; border: 0; color: var(--ink-2);
    font-size: .8rem;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--rule); }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg-size-1 { font-family: var(--serif); font-size: .75rem; }
.seg-size-2 { font-family: var(--serif); font-size: .9rem; }
.seg-size-3 { font-family: var(--serif); font-size: 1.05rem; }
.seg-size-4 { font-family: var(--serif); font-size: 1.2rem; }
.seg-size-5 { font-family: var(--serif); font-size: 1.4rem; }
.seg-font-serif { font-family: var(--serif); font-size: .9rem; }
.seg-font-sans { font-family: var(--sans); font-size: .9rem; }
.swatch-light { background: #f6f2ea; color: #1e1b17; }
.swatch-sepia { background: #f1e5cc; color: #3a2c1e; }
.swatch-dark { background: #151412; color: #e9e3d8; }
.swatch[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent); background-clip: padding-box; }
.swatch-light[aria-pressed="true"] { background: #f6f2ea; color: #1e1b17; }
.swatch-sepia[aria-pressed="true"] { background: #f1e5cc; color: #3a2c1e; }
.swatch-dark[aria-pressed="true"] { background: #151412; color: #e9e3d8; }

.reading {
    max-width: var(--measure);
    margin: 0 auto;
    padding: 1.5rem 1.25rem calc(var(--bar-h) + 4rem + env(safe-area-inset-bottom));
}
.reading-head { margin-bottom: 2.2rem; padding-bottom: 1.4rem; border-bottom: 1px solid var(--rule); }
.reading-title {
    margin: 0 0 .9rem;
    font-family: var(--serif);
    font-size: clamp(1.75rem, 1.2rem + 2.4vw, 2.5rem);
    line-height: 1.15;
    font-weight: 700;
    letter-spacing: -.015em;
    overflow-wrap: anywhere;
    text-wrap: balance;
}
.reading-meta {
    display: flex; flex-wrap: wrap; column-gap: .55rem;
    margin: 0; font-size: .85rem; color: var(--muted);
}
.reading-meta > span + span::before { content: "·"; margin-right: .55rem; color: var(--rule); }
.reading-author { margin: .3rem 0 0; font-size: .85rem; color: var(--ink-2); }
.reading-why {
    margin: 1rem 0 0; padding-left: .9rem; border-left: 2px solid var(--accent);
    font-family: var(--serif); font-style: italic; color: var(--ink-2);
}
.reading-original {
    display: inline-flex; align-items: center; min-height: 44px; margin-top: .4rem;
    font-size: .85rem; color: var(--accent); text-decoration: none;
    letter-spacing: .02em;
}
.reading-original:hover { text-decoration: underline; text-underline-offset: 3px; }

.reading-note {
    font-family: var(--serif); font-size: 1.1rem; font-style: italic; color: var(--ink-2);
}
.reading-note a { color: var(--accent); font-style: normal; white-space: nowrap; }
.reading-error {
    margin: -.4rem 0 1.2rem; padding-left: .8rem;
    border-left: 2px solid var(--bad);
    font-size: .85rem; color: var(--ink-2);
}
.reading-retry { margin: 0; }

/* The article itself: everything inside is sanitized outside HTML. */
.reading-body {
    font-family: var(--body-font);
    font-size: var(--body-size);
    line-height: 1.62;
    color: var(--ink);
    overflow-wrap: break-word;
    hyphens: auto;
    font-variant-numeric: oldstyle-nums proportional-nums;
}
.reading-body > :first-child { margin-top: 0; }
.reading-body p, .reading-body ul, .reading-body ol, .reading-body blockquote,
.reading-body pre, .reading-body figure, .reading-body table { margin: 0 0 1.1em; }
.reading-body h1, .reading-body h2, .reading-body h3,
.reading-body h4, .reading-body h5, .reading-body h6 {
    margin: 1.8em 0 .55em; line-height: 1.25; font-weight: 700;
    font-family: var(--body-font); letter-spacing: -.01em;
}
.reading-body h1 { font-size: 1.5em; }
.reading-body h2 { font-size: 1.3em; }
.reading-body h3 { font-size: 1.12em; }
.reading-body h4, .reading-body h5, .reading-body h6 { font-size: 1em; }
.reading-body a {
    color: var(--accent);
    text-decoration-thickness: 1px; text-underline-offset: .18em;
}
.reading-body ul, .reading-body ol { padding-left: 1.4em; }
.reading-body li + li { margin-top: .3em; }
.reading-body blockquote {
    margin-left: 0; padding-left: 1.1em;
    border-left: 3px solid var(--rule);
    color: var(--ink-2); font-style: italic;
}
.reading-body pre, .reading-body code {
    font-family: var(--mono); font-size: .84em;
    background: var(--paper-2); border-radius: 4px;
}
.reading-body code { padding: .1em .3em; }
.reading-body pre { padding: .9em 1em; overflow-x: auto; hyphens: none; }
.reading-body pre code { padding: 0; background: none; }
.reading-body img { display: block; max-width: 100%; height: auto; margin: 0 auto; border-radius: 3px; }
.reading-body figure { margin-left: 0; margin-right: 0; }
.reading-body figcaption { margin-top: .5em; font-family: var(--sans); font-size: .8em; color: var(--muted); }
.reading-body hr { border: 0; text-align: center; margin: 2em 0; }
.reading-body hr::after { content: "⁂"; color: var(--muted); letter-spacing: .4em; }
/* Wide tables (newsletters) scroll inside their own box. */
.reading-body table {
    display: block; max-width: 100%; overflow-x: auto;
    border-collapse: collapse; font-size: .9em; font-family: var(--sans);
}
.reading-body th, .reading-body td { padding: .35em .6em; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }

/* Sticky decision bar. */
.actionbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
    display: flex; justify-content: center; align-items: center; gap: .6rem;
    padding: .7rem max(1rem, env(safe-area-inset-right)) max(.7rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
    background: color-mix(in srgb, var(--paper) 88%, transparent);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--rule);
}
.actionbar form { display: contents; }
.act {
    min-height: 48px; min-width: 6.5rem; padding: 0 1.2rem;
    border: 1px solid var(--rule); border-radius: 999px;
    background: var(--paper); color: var(--ink);
    font-family: var(--sans); font-size: .95rem; letter-spacing: .01em;
    transition: background-color .15s ease, border-color .15s ease, transform .1s ease;
}
.act:hover { border-color: var(--ink-2); }
.act:active { transform: translateY(1px); }
.act-primary { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.act-primary:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.act-quiet { color: var(--muted); }
.act[disabled] { opacity: .55; cursor: progress; }
.actionbar-state { margin: 0; font-size: .85rem; color: var(--muted); }

@media (max-width: 26rem) {
    .act { min-width: 0; flex: 1; padding: 0 .6rem; }
}

/* ── Gate (login, setup, not configured) ───────────────── */

.gate {
    display: grid; place-items: center;
    padding: 1.25rem;
    background:
        radial-gradient(120% 60% at 50% 0%, var(--paper-2), transparent 70%),
        var(--paper);
}
.gate-card {
    width: 100%; max-width: 23rem;
    padding: 2.2rem 1.8rem 2rem;
    border-top: 3px solid var(--ink);
    background: var(--paper);
    box-shadow: var(--shadow);
}
.gate-card .wordmark { font-size: 2.1rem; margin-bottom: 1.6rem; }
.gate-card h1 {
    margin: 0 0 .6rem;
    font-family: var(--serif); font-size: 1.35rem; font-weight: 600;
}
.gate-note { margin: 0 0 1.2rem; font-size: .9rem; color: var(--ink-2); }
.gate-error, .gate-ok {
    margin: 0 0 1rem; padding: .6rem .8rem;
    border-left: 3px solid var(--bad);
    background: var(--paper-2); font-size: .9rem;
}
.gate-ok { border-left-color: var(--accent); }
.gate-form { display: grid; gap: 1rem; margin-top: 1rem; }
.gate-form label { display: grid; gap: .35rem; }
.gate-form label span {
    font-size: .72rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.gate-form input {
    min-height: 48px; padding: 0 .9rem;
    border: 1px solid var(--rule); border-radius: 8px;
    background: var(--paper); color: var(--ink);
    font: 1rem var(--sans);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.gate-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.gate-form .btn { margin-top: .4rem; }

/* ── Adding links: field, notes, bookmarklet ───────────── */

/* One line under the masthead: a label set like a newspaper kicker, an
   ink underline that turns accent on focus, the round button of the app. */
.add {
    display: flex; align-items: flex-end; gap: .75rem;
    padding: 1.1rem 0 1.25rem;
}
.add-field { flex: 1; min-width: 0; display: grid; gap: .15rem; }
.add-label {
    font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; font-weight: 600;
    color: var(--muted);
}
.add-input {
    width: 100%; min-height: 44px; padding: 0 .1rem;
    border: 0; border-bottom: 1.5px solid var(--ink-2); border-radius: 0;
    background: transparent; color: var(--ink);
    font: 1rem var(--mono);
    transition: border-color .15s ease;
}
.add-input::placeholder { color: var(--muted); opacity: .7; }
.add-input:focus { outline: none; border-bottom-color: var(--accent); }
.add-input:focus-visible { outline: none; }
.add-btn { flex: none; }

.flash {
    margin: 0 0 .9rem; padding: .55rem .8rem;
    border-left: 3px solid var(--accent);
    background: var(--paper-2);
    font-size: .9rem; color: var(--ink-2);
    animation: row-in .35s ease both;
}
.flash-error { border-left-color: var(--bad); }

.bookmarklet { margin-top: 2.5rem; border-top: 1px solid var(--rule); }
.bookmarklet summary {
    display: inline-flex; align-items: center; gap: .35rem; min-height: 44px;
    cursor: pointer; list-style: none;
    font-size: .8rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
}
.bookmarklet summary::-webkit-details-marker { display: none; }
.bookmarklet summary::before { content: "▸"; transition: transform .2s ease; }
.bookmarklet[open] summary::before { transform: rotate(90deg); }
.bookmarklet-body { padding: .3rem 0 .5rem; font-size: .9rem; color: var(--ink-2); max-width: 34rem; }
.bookmarklet-body p { margin: .8rem 0 0; }
/* The thing to drag: a little red bookmark ribbon with a notch. */
.bookmarklet-link {
    display: inline-flex; align-items: center;
    min-height: 40px; padding: 0 1.4rem 0 .9rem;
    background: var(--accent); color: var(--accent-ink);
    font-family: var(--serif); font-style: italic; font-weight: 700; font-size: 1rem;
    text-decoration: none; cursor: grab;
    clip-path: polygon(0 0, 100% 0, calc(100% - .55rem) 50%, 100% 100%, 0 100%);
    box-shadow: var(--shadow);
    transition: transform .15s ease;
}
.bookmarklet-link:hover { transform: translateY(-1px) rotate(-1deg); }
.bookmarklet-link:active { cursor: grabbing; }
.bookmarklet-note { font-size: .8rem; color: var(--muted); font-style: italic; }
.bookmarklet-note.is-flash { animation: note-flash 1.2s ease; }
@keyframes note-flash { 0%, 40% { color: var(--accent); } }
kbd {
    font-family: var(--mono); font-size: .78em;
    padding: .05em .35em; border: 1px solid var(--rule); border-bottom-width: 2px; border-radius: 4px;
}

/* Share pages (gate card): what is being added, set like a clipping. */
.share-preview {
    margin: 0 0 1.2rem; padding: .9rem 1rem;
    border: 1px solid var(--rule); border-left: 3px solid var(--ink);
    background: var(--paper-2);
}
.share-title {
    margin: 0 0 .35rem;
    font-family: var(--serif); font-size: 1.05rem; font-weight: 600; line-height: 1.3;
    overflow-wrap: anywhere;
}
.share-url {
    margin: 0; font-family: var(--mono); font-size: .78rem; color: var(--muted);
    overflow-wrap: anywhere;
    display: -webkit-box; -webkit-line-clamp: 4; line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden;
}
.share-done::before { content: "✓ "; color: var(--accent); }
.share-actions { display: flex; flex-wrap: wrap; gap: .6rem; }
.share-actions .btn { text-decoration: none; }
.share-foot { margin: 1rem 0 0; font-size: .85rem; text-align: center; }
.share-foot a { color: var(--muted); }

/* ── API reference (/api/docs) ─────────────────────────── */

.docs { max-width: 46rem; margin: 0 auto; padding: 1.2rem 1.25rem 4rem; }
.docs-intro { font-family: var(--serif); font-size: 1.1rem; color: var(--ink-2); }
.docs-server { font-size: .85rem; color: var(--muted); }
.masthead-date a { color: inherit; }
.op { margin-top: 2.2rem; padding-top: 1.4rem; border-top: 3px double var(--rule); }
.op-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: .7rem; margin: 0 0 .5rem; font-size: 1.25rem; }
.op-method {
    font-family: var(--sans); font-size: .72rem; font-weight: 700; letter-spacing: .12em;
    padding: .2rem .5rem; border-radius: 3px; background: var(--ink); color: var(--paper);
}
.op-method-post { background: var(--accent); color: var(--accent-ink); }
.op-path { font-size: 1.1rem; }
.op-summary { margin: 0 0 .6rem; font-family: var(--serif); font-size: 1.15rem; font-weight: 600; }
.op-desc { margin: 0 0 .8rem; color: var(--ink-2); }
.op-desc, .op-auth { max-width: var(--measure); }
.op-auth { font-size: .9rem; color: var(--ink-2); }
.op-label {
    margin: 1.3rem 0 .4rem;
    font-size: .68rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}
.op-auth .op-label { margin: 0 .4rem 0 0; }
.fields { width: 100%; border-collapse: collapse; font-size: .9rem; }
.fields th, .fields td { padding: .5rem .6rem .5rem 0; border-bottom: 1px solid var(--rule); text-align: left; vertical-align: top; }
.fields th { white-space: nowrap; font-weight: 400; }
.fields-type { font-family: var(--mono); font-size: .8rem; color: var(--muted); white-space: nowrap; }
.req { color: var(--accent); margin-left: .15rem; }
.fields-ref { color: var(--ink); text-decoration-color: var(--rule); text-underline-offset: .2em; }
.fields-ref:hover, .fields-ref:focus-visible { text-decoration-color: var(--accent); }
.schema { scroll-margin-top: 1rem; }
.schema + .schema { margin-top: 1.6rem; }
.schema-name { margin: 1rem 0 .3rem; font-size: 1rem; font-weight: 400; }
.schema:target .schema-name code { box-shadow: inset 0 -.45em 0 color-mix(in srgb, var(--accent) 22%, transparent); }
.responses { display: grid; grid-template-columns: auto 1fr; gap: .45rem .9rem; margin: 0; font-size: .9rem; }
.responses dd { margin: 0; color: var(--ink-2); }
.responses-shape { display: block; margin-top: .15rem; font-size: .8rem; color: var(--muted); }
.status { font-family: var(--mono); font-weight: 700; }
.status-2xx { color: var(--ink); }
.status-4xx, .status-5xx { color: var(--bad); }

@media (max-width: 26rem) {
    .add { flex-wrap: wrap; }
    .add-btn { width: 100%; }
    /* list<SyncedMessage> must not push the docs table past a phone screen. */
    .fields-type { white-space: normal; overflow-wrap: anywhere; }
}

/* ── Installed app & offline (Part 3) ──────────────────── */

/* Offline: a quiet strip set like the date line, with an unlit lamp. */
.offline-note {
    display: flex; align-items: center; gap: .55rem;
    margin: 1rem 0 0; padding: .55rem .8rem;
    border: 1px solid var(--rule); border-radius: 8px;
    background: var(--paper-2);
    font-size: .8rem; letter-spacing: .04em; color: var(--ink-2);
    animation: row-in .35s ease both;
}
.offline-note::before {
    content: ""; flex: none;
    width: .5rem; height: .5rem; border-radius: 50%;
    border: 1.5px solid var(--muted);
}
/* Adding a link needs the server. */
:root[data-offline] .add { opacity: .4; pointer-events: none; }

/* Install hint: a clipped notice with a dashed edge, closable. */
.install {
    display: flex; flex-wrap: wrap; align-items: center; gap: .25rem .6rem;
    margin: 1rem 0 0; padding: .3rem .2rem .3rem .9rem;
    border: 1px dashed var(--rule); border-radius: 10px;
    font-size: .85rem; line-height: 1.45; color: var(--ink-2);
}
.install-text { flex: 1 1 14rem; margin: .45rem 0; }
.install-kicker {
    margin-right: .3rem;
    font-size: .68rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase;
    color: var(--accent);
}
.install-dots {
    display: inline-grid; place-items: center;
    width: 1.35rem; height: 1.35rem; margin: 0 .1rem;
    border: 1px solid var(--rule); border-radius: 50%;
    font-weight: 700; line-height: 1; color: var(--ink);
}
.install-now { flex: none; }
.install-close {
    flex: none; min-width: 44px; min-height: 44px;
    border: 0; background: none; cursor: pointer;
    font: 1.35rem/1 var(--sans); color: var(--muted);
    -webkit-tap-highlight-color: transparent;
}
.install-close:hover { color: var(--ink); }

/* Toast: what just happened, above the decision bar on the reading view. */
.toast {
    position: fixed; z-index: 30;
    left: 50%; translate: -50% 0;
    bottom: max(1.25rem, calc(env(safe-area-inset-bottom) + .75rem));
    width: max-content; max-width: calc(100vw - 2rem);
    margin: 0; padding: .7rem 1.1rem;
    border-radius: 10px;
    background: var(--ink); color: var(--paper);
    box-shadow: var(--shadow);
    font-size: .9rem; line-height: 1.35;
}
.page-item .toast { bottom: calc(var(--bar-h) + 1rem + env(safe-area-inset-bottom)); }
.toast.is-in { animation: toast-in .25s ease both; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ── Phones and notches ────────────────────────────────── */

/* Landscape on a phone with a notch: keep text off the cut-outs. */
.masthead, .list-wrap, .reading, .site-foot {
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
}
.topbar {
    padding-left: max(1.25rem, env(safe-area-inset-left));
    padding-right: max(1.25rem, env(safe-area-inset-right));
}

@media (max-width: 26rem) {
    .masthead { padding-top: max(1.4rem, env(safe-area-inset-top)); }
    .wordmark { font-size: 2.25rem; }
    .tabs { gap: 1.1rem; }
    .tab { font-size: 1.08rem; }
    .row-title { font-size: 1.1rem; }
    .reading { padding-top: 1rem; }
    .actionbar { gap: .45rem; }
    .prefs { margin: 0 .75rem; max-width: none; }
    .prefs-row { grid-template-columns: 4.2rem 1fr; }
    .seg-btn { padding: 0 .2rem; font-size: .75rem; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
