:root {
    --window-width: 480px;

    --accent: #007aff;
    --accent-hover: #2b90ff;
    --accent-press: #0066d6;
    --switch-on: #34c759;
    --switch-off: rgba(120, 120, 128, 0.32);
    --result: #10b981;
    --warn: #c77a00;
    --danger: #d70015;
    /* "Text" kind word — a cyan/teal. Darker on the light glass so it stays legible:
       this hits ~4.8:1 on the card, meeting WCAG AA for 11.5px text
       (the dark theme uses the bright #0affe4 on its dark card). */
    --text-kind: #127c70;
    /* Vibrant purple — the standout border on the create input. */
    --purple: #af52de;

    --bg-1: #e7e8ec;
    --bg-2: #f6f7f9;
    --glow-1: rgba(0, 122, 255, 0.20);
    --glow-2: rgba(255, 64, 129, 0.14);

    --text: #1d1d1f;
    --text-secondary: rgba(60, 60, 67, 0.6);
    --text-tertiary: rgba(60, 60, 67, 0.4);

    --card-bg: rgba(255, 255, 255, 0.58);
    --card-border: rgba(255, 255, 255, 0.7);
    --card-highlight: rgba(255, 255, 255, 0.9);
    --card-shadow: 0 24px 70px -22px rgba(20, 24, 40, 0.42), 0 8px 22px -14px rgba(20, 24, 40, 0.28);

    --field-bg: rgba(255, 255, 255, 0.72);
    --field-border: rgba(0, 0, 0, 0.1);
    --separator: rgba(0, 0, 0, 0.08);

    --radius-window: 28px;
    --radius-control: 12px;

    --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", "Segoe UI", Roboto, system-ui, sans-serif;
    --font-mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Monaco, "Cascadia Code", monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --accent: #0a84ff;
        --accent-hover: #3d9bff;
        --accent-press: #0a6fd6;
        --switch-off: rgba(120, 120, 128, 0.5);
        --result: #34d399;
        --warn: #ffd60a;
        --danger: #ff453a;
        --text-kind: #0affe4;
        --purple: #bf5af2;

        --bg-1: #121214;
        --bg-2: #202024;
        --glow-1: rgba(10, 132, 255, 0.22);
        --glow-2: rgba(191, 90, 242, 0.18);

        --text: #f5f5f7;
        --text-secondary: rgba(235, 235, 245, 0.6);
        --text-tertiary: rgba(235, 235, 245, 0.35);

        --card-bg: rgba(40, 40, 44, 0.55);
        --card-border: rgba(255, 255, 255, 0.12);
        --card-highlight: rgba(255, 255, 255, 0.1);
        --card-shadow: 0 28px 80px -24px rgba(0, 0, 0, 0.7), 0 10px 26px -16px rgba(0, 0, 0, 0.6);

        --field-bg: rgba(255, 255, 255, 0.06);
        --field-border: rgba(255, 255, 255, 0.12);
        --separator: rgba(255, 255, 255, 0.1);
    }
}

* {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    scroll-behavior: smooth;
    /* Paint the background on the root so it extends under the Safari toolbars and
       into the overscroll/safe-area, instead of leaving those areas blank. */
    min-height: 100%;
    background-color: var(--bg-1);
    background-image:
        radial-gradient(1100px 760px at 12% 6%, var(--glow-1), transparent 60%),
        radial-gradient(1000px 720px at 88% 96%, var(--glow-2), transparent 58%),
        linear-gradient(155deg, var(--bg-2), var(--bg-1));
    background-attachment: fixed;
}

/* The `hidden` attribute must win over the component `display` rules below
   (a class selector would otherwise override the UA `[hidden]` style). */
[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Top-anchored, not vertically centered: as the result/history grow the window
       stays put at the top instead of re-centering (which read as a scroll jump). */
    justify-content: flex-start;
    padding: calc(44px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
    font-family: var(--font);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.app-window {
    width: min(100%, var(--window-width));
    background: var(--card-bg);
    -webkit-backdrop-filter: blur(40px) saturate(180%);
    backdrop-filter: blur(40px) saturate(180%);
    border: 0.5px solid var(--card-border);
    border-radius: var(--radius-window);
    box-shadow: var(--card-shadow), inset 0 1px 0 var(--card-highlight);
    /* More room above the logo, balancing the reserved storage-pill slot below the
       tagline so the top reads the same with or without the pill showing. */
    padding: clamp(34px, 6vw, 48px) clamp(22px, 5vw, 34px) clamp(22px, 5vw, 34px);
}

@supports not ((-webkit-backdrop-filter: blur(1px)) or (backdrop-filter: blur(1px))) {
    :root {
        --card-bg: rgba(252, 252, 253, 0.96);
    }

    @media (prefers-color-scheme: dark) {
        :root {
            --card-bg: rgba(36, 36, 40, 0.97);
        }
    }
}

main > header {
    text-align: center;
}

header h1 {
    margin: 0;
    font-size: clamp(28px, 8vw, 38px);
    font-weight: 600;
    letter-spacing: -0.022em;
}

/* Default paragraph: centered secondary text (tagline, status, info lines). */
main p {
    margin: 14px auto 0;
    max-width: 32ch;
    text-align: center;
    font-size: 15px;
    line-height: 1.45;
    color: var(--text-secondary);
}

main p.meta {
    font-size: 12.5px;
}

form {
    margin: 24px 0 0;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    font-family: inherit;
    font-size: 16px;
    color: var(--text);
    background: var(--field-bg);
    /* A thin, vibrant purple line so the input is the obvious focal point. */
    border: 1.5px solid var(--purple);
    border-radius: var(--radius-control);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
    transition: border-color 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
    -webkit-appearance: none;
    appearance: none;
}

.form-control::placeholder {
    color: var(--text-tertiary);
}

.form-control:focus {
    outline: none;
    border-color: var(--purple);
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--purple) 26%, transparent);
}

/* Greyed after a successful submit; focusing or editing the field restores it. */
.form-control.submitted {
    opacity: 0.55;
}

/* Auto-growing textarea: wrap long lines instead of scrolling sideways, and keep
   pasted newlines. JS sets the height; CSS bounds it. */
textarea.form-control {
    display: block;
    resize: none;
    min-height: 46px;
    max-height: 40vh;
    line-height: 1.45;
    /* Vertically centre the text when the field is taller than its content (a
       single line at min-height). Some engines, notably Windows Edge, otherwise
       top-align it; supported engines centre, the rest are unaffected. */
    align-content: center;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    overflow-x: hidden;
    /* No scrollbar while the content fits; app.js flips this to `auto` only once
       the text exceeds max-height. */
    overflow-y: hidden;
}

/* Radio-group wrapper: strip the native fieldset chrome; the legend is the caption. */
.picker {
    margin: 16px 0 0;
    padding: 0;
    border: 0;
    min-width: 0;
}

.picker > legend {
    padding: 0;
    margin: 0 0 7px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent);
}

/* iOS-style segmented control (Expires in, Limit), built from native radios so it
   works without JavaScript. The radio is visually hidden; its label is the chip. */
.segmented {
    display: flex;
    gap: 2px;
    padding: 3px;
    background: var(--switch-off);
    border-radius: var(--radius-control);
}

.seg-radio {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.seg-label {
    flex: 1;
    min-width: 0;
    text-align: center;
    padding: 8px 6px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text);
    border-radius: calc(var(--radius-control) - 3px);
    cursor: pointer;
    user-select: none;
    transition: background 0.15s ease, box-shadow 0.15s ease, color 0.15s ease;
}

.seg-radio:checked + .seg-label {
    background: var(--card-highlight);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

@media (prefers-color-scheme: dark) {
    .seg-radio:checked + .seg-label {
        background: rgba(120, 120, 128, 0.55);
    }
}

.seg-radio:focus-visible + .seg-label {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent);
}

/* The infinity chip (Limit: unlimited) reads a touch larger than the digits. */
.infinity {
    font-size: 17px;
    line-height: 1;
}

/* "Custom" reveal: hidden until its segment is picked. CSS `:has()` drives the
   no-JS path; app.js also focuses the field when Custom is chosen. */
.custom-field {
    display: none;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.picker:has(.seg-radio[value="custom"]:checked) .custom-field {
    display: flex;
}

.custom-num {
    flex: 1;
    min-width: 0;
    padding: 9px 11px;
    font-family: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--field-bg);
    border: 0.5px solid var(--field-border);
    border-radius: 10px;
    -webkit-appearance: none;
    appearance: none;
}

.custom-num:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
}

/* Specify-expiry unit chips: keep the number field fairly compact, chips take the rest. */
#ttl-custom-value {
    flex: 0 0 6.5em;
}

.unit-segmented {
    flex: 1;
    min-width: 13em;
}

/* "Up to N days" hint under the Specify-expiry field. */
.custom-hint {
    flex: 0 0 100%;
    margin-top: 2px;
    padding-left: 8px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Explanatory note under a picker (e.g. the per-type line on the Type picker). */
.picker-note {
    display: block;
    margin-top: 7px;
    padding-left: 8px;
    font-size: 12px;
    line-height: 1.4;
    color: var(--text-secondary);
}

/* The Type picker has no legend and sits above Expiry; show only the description
   line for the checked type. :has drives it, so it works without JavaScript. */
.type-picker .picker-note { display: none; }
.type-picker:has(#type-public:checked) .for-public,
.type-picker:has(#type-private:checked) .for-private,
.type-picker:has(#type-once:checked) .for-once { display: block; }

/* Keep each of the three type labels on a single line. */
.type-picker .seg-label { white-space: nowrap; }

/* Whole-form error under the action — on-page, never an alert. Danger colour since
   it means the link was not created. */
.form-error {
    margin: 12px auto 0;
    max-width: 36ch;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--danger);
}

/* macOS-style switch row */
.switch-row {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 4px;
    cursor: pointer;
    user-select: none;
}

.switch-label {
    flex: 1;
    min-width: 0;
}

.switch-label strong {
    display: block;
    font-size: 15px;
    font-weight: 500;
}

.switch-label small {
    display: block;
    margin-top: 2px;
    font-size: 12.5px;
    line-height: 1.35;
    color: var(--text-secondary);
}

.switch {
    position: relative;
    flex: none;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-track {
    display: block;
    width: 45px;
    height: 27px;
    border-radius: 14px;
    background: var(--switch-off);
    transition: background 0.25s ease;
}

.switch-thumb {
    position: absolute;
    top: 2.5px;
    left: 2.5px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08), 0 2px 5px rgba(0, 0, 0, 0.3);
    transition: transform 0.25s cubic-bezier(0.3, 1.4, 0.5, 1);
}

.switch input:checked + .switch-track {
    background: var(--switch-on);
}

.switch input:checked + .switch-track .switch-thumb {
    transform: translateX(18px);
}

.switch input:focus-visible + .switch-track {
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #fff;
    background: linear-gradient(180deg, var(--accent-hover), var(--accent));
    border: none;
    border-radius: var(--radius-control);
    padding: 12px 18px;
    min-height: 46px;
    cursor: pointer;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 1px 2px rgba(0, 0, 0, 0.18);
    transition: filter 0.15s ease, transform 0.06s ease, box-shadow 0.15s ease;
    -webkit-appearance: none;
    appearance: none;
}

.btn:hover {
    filter: brightness(1.05);
}

.btn:active {
    transform: scale(0.985);
}

.btn:focus-visible {
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.28), 0 0 0 4px color-mix(in srgb, var(--accent) 30%, transparent);
}

.btn-block {
    display: flex;
    width: 100%;
    margin-top: 18px;
}

/* Split action button: "Create Link" fused with a smaller "+ Copy" */
.split-btn {
    display: flex;
    gap: 2px;
    margin-top: 18px;
}

.split-btn .btn {
    margin-top: 0;
}

.split-primary {
    flex: 1;
    border-radius: var(--radius-control) 0 0 var(--radius-control);
}

/* "Clear" sits where Copy was — caution colour, since it discards the input. */
.split-clear {
    flex: none;
    padding: 0 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 0 var(--radius-control) var(--radius-control) 0;
    background: linear-gradient(180deg, #ff9f0a, #ff9500);
    color: #fff;
}

.split-clear:hover {
    filter: brightness(1.05);
}

/* Result panel — a semantic <output> holding the created/previewed link. */
.result {
    display: block;
    margin: 18px 0 0;
    padding: 15px 16px 8px;
    border-radius: 14px;
    background: color-mix(in srgb, var(--result) 13%, var(--field-bg));
    border: 0.5px solid color-mix(in srgb, var(--result) 38%, transparent);
    transition: opacity 0.18s ease;
}

/* Dim the result when the input no longer matches the link it produced. */
.result.stale {
    opacity: 0.5;
}

/* The created-link result (the landing/result page #link-panel) drops the green
   box; direction C presents the URL in a read-only-style field with Copy docked
   on the right, the meta and any note beneath. (The preview page keeps the plain
   .result box above.) */
/* The created-link result drops the green box: the URL is the hero (coloured),
   centred, with its meta and a Copy pill beneath and an optional note last. The
   preview page keeps the plain .result box above. */
#link-panel {
    margin: 24px 0 4px;
    padding: 0;
    background: none;
    border: 0;
    /* Focused programmatically (for ⌘C) — suppress the browser focus ring, which
       inherits .result's 14px radius and renders a notched outline around the hero. */
    outline: none;
    text-align: center;
}


.result-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    color: color-mix(in srgb, var(--switch-on) 60%, var(--text));
    margin-bottom: 11px;
}

/* The link name as the giant hero (direction R4): the memorable word, big and in
   the accent colour, centred and selectable. */
.result-word {
    display: block;
    font-family: var(--font-mono);
    /* The mockup's "arson" is a fixed 30px; clamp only shrinks it on narrow phones. */
    font-size: clamp(24px, 7vw, 30px);
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.01em;
    word-break: break-all;
    margin-bottom: 4px;
    color: var(--accent);
    user-select: text;
}

/* The full URL beneath the hero word: small and quiet — dim scheme, standout host
   — rendered in parts by app.js. Wraps so the whole link stays visible/copyable. */
.result-url {
    display: block;
    margin-top: 0;
    font-family: var(--font-mono);
    font-size: 15px;
    line-height: 1.4;
    word-break: break-all;
    color: var(--text-tertiary);
    user-select: text;
}

/* Copy confirmation: a green check trails the URL on copy (the Copy button or ⌘C),
   showing the whole link was copied; clears with the button's "Copied" after 1.5s.
   Opacity-toggled (space reserved) so the centred line never reflows. */
.result-url::after {
    content: "\2713";
    margin-left: 0.4em;
    font-weight: 700;
    color: var(--switch-on);
    opacity: 0;
    transition: opacity 0.18s ease;
}

.result-url.copied::after {
    opacity: 1;
}

/* A dead result strikes through both the hero name word and the URL — the link no
   longer resolves, so its whole identity reads as crossed out. */
.result.expired .result-word,
.result.expired .result-url {
    text-decoration: line-through;
}

.result-url .u-scheme,
.result-url .u-sep,
.result-url .u-frag {
    color: var(--text-tertiary);
}

.result-url .u-host {
    color: var(--text-secondary);
}

/* R4: the link name is already the giant hero above, so keep it quiet here — the
   whole sub-URL reads as one calm gray address instead of re-accenting the name. */
.result-url .u-name {
    color: var(--text-secondary);
    font-weight: 400;
}

/* Override the per-word accent/purple inside the URL: the address stays gray (the
   coloured hero already carries the name), with only the host/name a touch clearer. */
.result-url .nw-0,
.result-url .nw-1 {
    color: inherit;
}

/* Shoutkey name words, alternating colour so a multi-word name reads as separate
   words (the result hero, the URL name, history rows, and the interstitial). The
   explicit per-word colour overrides whatever the surrounding context paints. */
.nw-0 { color: var(--accent); }
.nw-1 { color: var(--purple); }

/* The preview page uses a plainer inline code (no box). Must exclude the result
   hero word — this selector (0,2,1) otherwise outweighs `.result-word` (0,1,0) and
   would shrink the hero to 13px in `var(--text)` instead of the 30px accent. */
.result > code:not(.result-url):not(.result-word) {
    display: block;
    font-family: var(--font-mono);
    font-size: 13px;
    word-break: break-all;
    color: var(--text);
    user-select: text;
}

/* Foot beneath the hero URL: the meta line, then the Copy pill, centred. */
.result-foot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 13px;
}

.result-meta {
    font-size: 12.5px;
    color: var(--text-secondary);
}

/* Shown when a public link got more than one word because the short tiers are
   crowded — explains why the name is longer than the usual single word. */
.result-note {
    margin: 8px 0 0;
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--text-secondary);
}

/* Time left reads green (alive) by default, then warns as the deadline nears. */
.countdown {
    color: var(--switch-on);
    font-weight: 600;
}

.countdown.expiring-soon {
    color: var(--warn);
    font-weight: 600;
}

.countdown.expiring-now {
    color: var(--danger);
    font-weight: 600;
}

.result-actions {
    display: flex;
    align-items: center;
    gap: 9px;
}

/* Copy pill beneath the URL. */
.result-copy {
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 12%, transparent);
    border: 0.5px solid color-mix(in srgb, var(--accent) 22%, transparent);
    border-radius: 999px;
    padding: 7px 22px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.result-copy:hover {
    background: color-mix(in srgb, var(--accent) 20%, transparent);
    border-color: color-mix(in srgb, var(--accent) 32%, transparent);
}

.result-copy.copied {
    color: var(--switch-on);
    background: color-mix(in srgb, var(--switch-on) 18%, transparent);
    border-color: color-mix(in srgb, var(--switch-on) 30%, transparent);
}

/* Expired link: nothing to copy — the button goes inert and neutral. */
.result-copy:disabled {
    color: var(--text-tertiary);
    background: color-mix(in srgb, var(--text) 8%, transparent);
    border-color: var(--separator);
    cursor: not-allowed;
}

/* Text-link viewer body. */
.text-body {
    margin: 16px 0 0;
    padding: 14px;
    max-height: 60vh;
    overflow: auto;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--text);
    background: var(--field-bg);
    border: 0.5px solid var(--field-border);
    border-radius: var(--radius-control);
}

/* ==========================================================================
   Always-preview interstitial (GET /:name) and the token-gated revealed view.
   Buttons by ACTION: blue (default .btn) = Reveal (you stay on YuioLink);
   amber (.btn--go, dark text) = Continue (you leave to the external site).
   ========================================================================== */

/* Masthead links home; keep it the heading colour, not link-blue. */
.app-window header h1 a {
    color: inherit;
    text-decoration: none;
}

.app-window header h1 a:hover {
    opacity: 0.7;
}

/* "yuio.link/<name>" source line. */
.pv-from {
    display: block;
    text-align: center;
    font-family: var(--font-mono);
    font-size: 14px;
    color: var(--text-secondary);
    word-break: break-all;
    margin-top: 26px;
}

.pv-from .name {
    color: var(--text);
    font-weight: 600;
}

.pv-arrow {
    display: block;
    text-align: center;
    font-size: 24px;
    line-height: 1;
    color: var(--accent);
    margin: 14px 0;
}

/* Domain-only host (limited links) and the "A text snippet" placeholder. */
.pv-host {
    display: block;
    text-align: center;
    font-family: var(--font-mono);
    font-size: clamp(24px, 7vw, 30px);
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.12;
    word-break: break-all;
    color: var(--text);
}

.pv-host .sub {
    color: var(--text-tertiary);
    font-weight: 600;
}

.pv-host.plain {
    font-family: var(--font);
}

/* Full destination URL, coloured by part (registrable domain highlighted). */
.pv-url {
    display: block;
    text-align: center;
    margin-top: 4px;
    font-family: var(--font-mono);
    font-size: 13.5px;
    line-height: 1.9;
    letter-spacing: 0.03em;
    word-break: break-all;
}

.pv-url .sch {
    color: var(--text-tertiary);
}

.pv-url .pn {
    color: var(--accent);
}

.pv-url .sub {
    color: var(--text-secondary);
}

.pv-url .reg {
    color: var(--text);
    font-weight: 700;
    font-size: 1.06em;
    padding: 1px 4px;
    border-radius: 4px;
    background: color-mix(in srgb, var(--accent) 13%, transparent);
}

.pv-url .seg {
    color: var(--text-secondary);
}

.pv-url .qv {
    color: var(--text);
}

/* Lookalike / IDN warning: red (danger), plain language, left-aligned table. */
.pv-idn {
    margin: 13px auto 0;
    max-width: 94%;
    padding: 11px 14px;
    border-radius: 10px;
    text-align: left;
    font-size: 11.5px;
    line-height: 1.5;
    color: var(--text-secondary);
    background: color-mix(in srgb, var(--danger) 9%, var(--field-bg));
    border: 0.5px solid color-mix(in srgb, var(--danger) 38%, transparent);
}

.pv-idn p {
    margin: 0 0 9px;
    max-width: none;
    text-align: left;
    font-size: inherit;
    color: inherit;
}

.pv-idn p strong {
    color: var(--danger);
    font-weight: 700;
}

.pv-idn .rows {
    display: grid;
    grid-template-columns: auto 1fr;
    column-gap: 12px;
    row-gap: 3px;
    font-family: var(--font-mono);
    line-height: 1.7;
}

.pv-idn .lbl {
    color: var(--text-tertiary);
}

.pv-idn .val {
    color: var(--text);
    font-weight: 700;
    word-break: break-all;
}

/* The consume forms wrap a single button; drop the form's default top margin so
   the button's own .pv-btn spacing governs. */
.pv-form {
    margin: 0;
}

.pv-btn {
    margin-top: 24px;
}

/* Amber Continue: leaving the site. Dark text keeps ~8:1 (white can't on amber). */
.btn--go {
    background: linear-gradient(180deg, #ffb52e, #ff9f0a);
    color: #241a05;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4), 0 1px 2px rgba(0, 0, 0, 0.18);
}

.btn--go:focus-visible {
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.4),
        0 0 0 4px color-mix(in srgb, #ff9f0a 42%, transparent);
}

/* Neutral pill for a limited link ("Limited Use" / "Opens Once"). */
.pv-badge-wrap {
    text-align: center;
    margin-top: 16px;
}

.pv-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    padding: 3px 12px;
    border-radius: 999px;
    color: var(--text-secondary);
    background: color-mix(in srgb, var(--text) 8%, transparent);
}

.pv-meta {
    text-align: center;
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 9px;
}

/* "One view used." with a leading green check. Kept to one line (no wrap). */
.pv-revealed {
    text-align: center;
    font-size: 11.5px;
    color: var(--text-secondary);
    margin-top: 11px;
    white-space: nowrap;
}

.pv-revealed::before {
    content: "\2713\00a0";
    color: var(--switch-on);
    font-weight: 700;
}

/* The recycling caution, with "Always check the destination." on its own line. */
.pv-caution {
    display: block;
    text-align: center;
    font-size: 11.5px;
    line-height: 1.6;
    color: var(--text-tertiary);
    margin-top: 20px;
    padding-top: 15px;
    border-top: 0.5px solid var(--separator);
}

.pv-caution strong {
    display: block;
    margin-top: 6px;
    color: var(--text);
    font-weight: 700;
}

.pv-caution.single strong {
    display: inline;
    margin: 0;
}

/* Split storage pill near the top, always shown. Two butted segments clipped to a
   pill: left = status (links to the list), right = local-persistence toggle in its
   own colour, for a clean colour cut between them. */
.storage-pill {
    display: flex;
    width: fit-content;
    max-width: 100%;
    margin: 16px auto 0;
    border-radius: 999px;
    overflow: hidden;
    font-size: 12.5px;
}

.storage-status {
    display: flex;
    align-items: center;
    padding: 6px 13px;
    font-weight: 500;
    color: var(--accent);
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease;
}

.storage-status:hover {
    background: color-mix(in srgb, var(--accent) 22%, transparent);
    text-decoration: none;
}

/* HIG-style switch on the old purple (mockup C): a "Local History" label and a toggle
   that shows state by colour + knob position (green/right = on), not by words. */
.storage-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 500;
    padding: 6px 12px;
    border: none;
    color: #fff;
    background: #8b5cf6;
    cursor: pointer;
    white-space: nowrap;
    transition: filter 0.15s ease;
}

.storage-toggle:hover {
    filter: brightness(1.07);
}

/* The switch track + sliding knob — white-translucent on the purple, green when on. */
.storage-switch {
    position: relative;
    flex: none;
    width: 30px;
    height: 18px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.3);
    transition: background 0.2s ease;
}

.storage-switch::before {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease;
}

.storage-toggle.on .storage-switch {
    background: var(--switch-on);
}

.storage-toggle.on .storage-switch::before {
    transform: translateX(12px);
}

/* Caution line under the pill when history was turned off with links still present. */
.storage-warning {
    margin: 9px auto 0;
    max-width: 34ch;
    font-size: 12px;
    line-height: 1.4;
    color: var(--warn);
}

/* Created-link history (bottom). In memory for the session unless persisted. */
.history {
    margin: 22px 0 0;
    padding-top: 18px;
    border-top: 0.5px solid var(--separator);
    scroll-margin-top: 18px;
}

.history-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

/* Collapse toggle: chevron + title; rotates and hides the list when collapsed. */
.history-toggle {
    display: inline-flex;
    align-items: center;
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
}

.history-chevron {
    display: inline-block;
    margin-right: 6px;
    color: var(--text-tertiary);
    transition: transform 0.15s ease;
    transform: rotate(90deg);
}

.history.collapsed .history-chevron {
    transform: rotate(0deg);
}

.history.collapsed .history-body {
    display: none;
}

.history-title {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--accent);
}

/* Grouped inset (mockup "A · grouped inset"): one rounded panel holding the rows,
   with hairline dividers between them (iOS-settings feel). */
.history-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--field-bg);
    border: 0.5px solid var(--field-border);
    border-radius: 12px;
    overflow: hidden;
}

.history-item {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    /* A uniform row height so a one-line tombstone matches a two-line live row. */
    min-height: 56px;
    padding: 11px 13px;
    border-bottom: 0.5px solid var(--separator);
}

.history-item:last-child {
    border-bottom: 0;
}

/* Expired links stay in the list until cleared via "Clear Expired". Only the dead
   link's text fades — the × and its remove menu stay fully lit so it is easy to clear
   (dimming the whole row would dim the confirm overlay drawn over it too). */
.history-item.expired .history-url,
.history-item.expired .history-meta {
    opacity: 0.5;
}

/* A dead row is done, not urgent — mute its countdown to grey. Otherwise the red
   "expired" warning keeps shouting from a row that is only waiting to be cleared. */
.history-item.expired .countdown {
    color: var(--text-secondary);
}

/* Clear Expired only tidies dead links -> green (safe). It sits beside Clear All in
   the head; app.js keeps it hidden until something has actually expired. */
.history-clear-expired {
    font-family: inherit;
    font-size: 12.5px;
    color: var(--result);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.history-clear-expired:hover {
    text-decoration: underline;
}

/* The kind as a coloured word (mockup H3 / Rb): Redirect in accent blue, Text in
   golden yellow — no chip, sitting before the green time on the meta line. */
.kind-word {
    flex: none;
    font-weight: 600;
}

.kind-word.redirect {
    color: var(--accent);
}

.kind-word.text {
    color: var(--text-kind);
}

/* Line 2 of a history entry: the meta on the left, the actions (Copy, Remove) on
   the right. Line 1 (the full-width URL) sits above it. */
.history-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
}

.history-actions {
    flex: none;
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Line 1: the tri-colour URL plus a trailing green copy-check, on one row. */
.history-l1 {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

/* The full-width tri-colour URL — dim scheme, standout host, the name highlighted
   by word. flex: 1 so it takes the whole line (the actions moved to line 2); it
   still ellipsizes when a redirect URL is too long for the row. */
.history-url {
    flex: 1 1 auto;
    min-width: 0;
    font-family: var(--font-mono);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    user-select: text;
}

/* Green check trailing the URL on copy (matches the result); opacity-toggled so the
   row never reflows. */
.history-check {
    flex: none;
    font-size: 13px;
    font-weight: 700;
    color: var(--switch-on);
    opacity: 0;
    transition: opacity 0.18s ease;
}

.history-check::before {
    content: "\2713";
}

.history-check.show {
    opacity: 1;
}

.history-url .u-scheme,
.history-url .u-sep,
.history-url .u-frag {
    color: var(--text-tertiary);
}

.history-url .u-host {
    color: var(--text-secondary);
}

.history-url .u-name {
    color: var(--text-secondary);
    font-weight: 400;
}

/* Match the result: keep the name gray in the URL, not accent-highlighted. */
.history-url .nw-0,
.history-url .nw-1 {
    color: inherit;
}

/* Line 2: kind pill + expiry, in the UI font (mockup A). */
.history-meta {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 11.5px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.history-copy {
    flex: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--accent);
    background: none;
    border: 0;
    padding: 6px 2px;
    cursor: pointer;
}

.history-copy:hover {
    text-decoration: underline;
}

.history-copy.copied {
    color: var(--switch-on);
    text-decoration: none;
}

/* Per-item Remove…: a quiet text button beside Copy that toggles the confirm
   overlay. It sits above the overlay (z-index) so clicking it again closes the
   prompt (there is no separate cancel). */
.history-remove {
    position: relative;
    z-index: 2;
    flex: none;
    font-family: inherit;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: 0;
    padding: 6px 2px;
    cursor: pointer;
}

.history-remove:hover {
    color: var(--danger);
    text-decoration: underline;
}

/* Confirmation drawn over the row: a short prompt and the two ways to remove. */
.history-confirm {
    position: absolute;
    inset: 0;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    /* Extra right padding clears the × column so the actions never slide under it. */
    padding: 0 38px 0 12px;
    /* Near-opaque so the row underneath does not bleed through (--field-bg is only
       6% in dark mode); the blur still softens the edge. */
    background: color-mix(in srgb, var(--bg-2) 93%, transparent);
    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);
    border-radius: 10px;
}

.history-confirm-label {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-confirm-label.error {
    color: var(--danger);
}

.history-confirm-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
}

.history-confirm-server,
.history-confirm-forget {
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
    border: 0.5px solid transparent;
    padding: 5px 11px;
    cursor: pointer;
    white-space: nowrap;
}

.history-confirm-server {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 13%, transparent);
    border-color: color-mix(in srgb, var(--danger) 24%, transparent);
}

/* An expired link is already erased server-side, so there is nothing to delete: the
   button goes inert and neutral (no red alarm), leaving only Forget. */
.history-confirm-server:disabled {
    color: var(--text-tertiary);
    background: color-mix(in srgb, var(--text) 8%, transparent);
    border-color: var(--separator);
    cursor: not-allowed;
}

.history-confirm-forget {
    color: var(--warn);
    background: color-mix(in srgb, var(--warn) 14%, transparent);
    border-color: color-mix(in srgb, var(--warn) 26%, transparent);
}

/* Spinner shown in the confirm overlay while the server is contacted. */
.history-spinner {
    flex: none;
    width: 14px;
    height: 14px;
    border: 2px solid color-mix(in srgb, var(--text) 18%, transparent);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: history-spin 0.7s linear infinite;
}

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

/* Tombstone marking where a removed entry was: a faded, recessed slot rather than the
   old dashed border (which vanished on the last row and read as noise). The muted fill
   reads as "emptied" in any position; it keeps the list's solid hairline separators. */
.history-tomb {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    background: color-mix(in srgb, var(--text) 6%, transparent);
}

.history-tomb-msg {
    flex: 1;
    min-width: 0;
    font-size: 12px;
    font-style: italic;
    color: var(--text-secondary);
}

.history-tomb-clear {
    flex: none;
    font-family: inherit;
    font-size: 12px;
    color: #ff9500;
    background: none;
    border: 0;
    padding: 4px 2px;
    cursor: pointer;
}

.history-tomb-clear:hover {
    text-decoration: underline;
}

/* The grace-window out: also delete the just-forgotten link from the server. Its label
   counts down the seconds left; tabular figures keep the width steady as it ticks. */
.history-tomb-delete {
    flex: none;
    font-family: inherit;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    color: var(--danger);
    background: none;
    border: 0;
    padding: 4px 2px;
    cursor: pointer;
}

.history-tomb-delete:hover {
    text-decoration: underline;
}

/* Clear All and Clear Expired live together at the top-right of the history head. */
.history-head-actions {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Clear All wipes the whole local list -> red (destructive). */
.history-clear {
    font-family: inherit;
    font-size: 12.5px;
    color: var(--danger);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.history-clear:hover {
    text-decoration: underline;
}

main > footer {
    margin: 22px 0 0;
    padding-top: 18px;
    border-top: 0.5px solid var(--separator);
    text-align: center;
    font-size: 12.5px;
    color: var(--text-secondary);
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code {
    font-family: var(--font-mono);
}

.error-code {
    font-size: 52px;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin: 8px 0 0;
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

