/* Chartage: warm paper, deep ink, one muted accent. The photos and stories are the content;
   the interface stays quiet. */

/* ---------- Fonts (self-hosted, SIL Open Font License; see /fonts) ---------- */

@font-face {
    font-family: "Newsreader";
    font-style: normal;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/newsreader-latin-opsz-normal.woff2") format("woff2-variations");
}

@font-face {
    font-family: "Newsreader";
    font-style: italic;
    font-weight: 200 800;
    font-display: swap;
    src: url("../fonts/newsreader-latin-opsz-italic.woff2") format("woff2-variations");
}

@font-face {
    font-family: "Inter";
    font-style: normal;
    font-weight: 100 900;
    font-display: swap;
    src: url("../fonts/inter-latin-wght-normal.woff2") format("woff2-variations");
}

/* ---------- Tokens ---------- */

:root {
    /* Always dark, like candlelight, matching allenokie.com (Jon, 2026-10-01): a darkened room,
       not inverted colors. */
    --paper: #1a1816;
    --paper-raised: #23201d;
    --paper-sunk: #151311;
    --ink: #ece5da;
    --ink-soft: #b4ab9e;
    --rule: #36312c;
    --rule-strong: #4a443d;
    --control-border: #7d746a;
    --accent: #d2b08a;
    --accent-hover: #e0c29f;
    --accent-ink: #1d1a17;
    --accent-wash: #2e2822;
    --danger: #e39a8c;
    --success: #9cc9a4;
    --focus: #8cc4ec;
    --shadow-card: 0 1px 2px rgb(0 0 0 / 30%);
    --shadow-photo: 0 1px 2px rgb(0 0 0 / 40%), 0 12px 32px rgb(0 0 0 / 45%);

    --font-serif: "Newsreader", "Source Serif 4", Georgia, "Times New Roman", serif;
    --font-sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-7: 3rem;
    --space-8: 4.5rem;
    --radius: 10px;
    --radius-small: 6px;
    --touch: 44px;
    --measure: 38rem;
    --page: 76rem;
    --ease: cubic-bezier(0.2, 0, 0, 1);

    color-scheme: dark;
}

/* ---------- Base ---------- */

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

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

body {
    margin: 0;
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--font-sans);
    font-size: 1.0625rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3 {
    font-family: var(--font-serif);
    font-weight: 500;
    line-height: 1.25;
    margin: 0 0 var(--space-4);
    text-wrap: balance;
}

h1 { font-size: clamp(1.9rem, 5vw, 2.4rem); }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.15rem; }

p { margin: 0 0 var(--space-4); }

a {
    color: var(--accent);
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
}

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

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}

h1:focus, main:focus { outline: none; }

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    left: var(--space-4);
    top: -100px;
    z-index: 100;
    padding: var(--space-3) var(--space-4);
    background: var(--paper-raised);
    border-radius: var(--radius-small);
    box-shadow: var(--shadow-card);
}

.skip-link:focus { top: var(--space-4); }

.quiet { color: var(--ink-soft); }

/* ---------- Boot screen (shown while the app loads) ---------- */

.boot {
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    place-content: center;
    text-align: center;
    padding: var(--space-6);
    animation: fade-in 1.2s var(--ease) both;
}

.boot-wordmark {
    margin: 0;
    font-family: var(--font-serif);
    font-size: clamp(2.5rem, 8vw, 3.5rem);
    font-weight: 500;
    letter-spacing: 0.01em;
}

.boot-subtitle {
    margin: var(--space-2) 0 0;
    font-family: var(--font-serif);
    font-weight: 300;
    color: var(--ink-soft);
    font-size: 1.15rem;
}

/* ---------- Header and navigation ---------- */

.site-header {
    border-bottom: 1px solid var(--rule);
    background: var(--paper);
}

/* The name on the left; the pages, then the person signed in (AccountMenu), on the right. */
.site-header-inner {
    max-width: var(--page);
    margin: 0 auto;
    padding: var(--space-4) var(--space-5);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3) var(--space-4);
}

.brand {
    display: flex;
    flex-direction: column;
    margin-right: auto;
    color: var(--ink);
    text-decoration: none;
    min-height: var(--touch);
    justify-content: center;
}

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

.brand-name {
    font-family: var(--font-serif);
    font-size: 1.7rem;
    font-weight: 500;
    line-height: 1.1;
    letter-spacing: 0.01em;
}

.brand-sub {
    font-family: var(--font-serif);
    font-weight: 300;
    font-size: 0.95rem;
    color: var(--ink-soft);
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-2);
}

.site-nav a {
    display: inline-flex;
    align-items: center;
    min-height: var(--touch);
    padding: 0 var(--space-3);
    border-radius: var(--radius-small);
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
}

.site-nav a:hover { background: var(--paper-sunk); }

.site-nav a.active {
    color: var(--accent);
    box-shadow: inset 0 -2px 0 var(--accent);
    border-radius: 0;
}

/* The person signed in: their initials in a circle; it opens a small menu below it. */
.account { position: relative; order: 1; }

.account-button {
    position: relative;
    z-index: 31;
    display: grid;
    place-items: center;
    width: var(--touch);
    height: var(--touch);
    padding: 0;
    color: var(--accent-ink);
    background: var(--accent);
    border: 2px solid var(--paper);
    border-radius: 50%;
    box-shadow: 0 0 0 1px var(--accent);
    font: 600 0.95rem/1 var(--font-sans);
    letter-spacing: 0.02em;
    cursor: pointer;
}

.account-button:hover { background: var(--accent-hover); box-shadow: 0 0 0 1px var(--accent-hover); }
.account-button[aria-expanded="true"] { box-shadow: 0 0 0 2px var(--accent-hover); }

/* Catches a click anywhere else, to close the menu. */
.account-backdrop { position: fixed; inset: 0; z-index: 30; }

/* A tooltip for a button that's only an icon: its data-tip, above it, on hover or keyboard focus
   (it also has an aria-label, for screen readers). */
.tip { position: relative; }
.tip::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    z-index: 5;
    width: max-content;
    max-width: 15rem;
    padding: var(--space-1) var(--space-2);
    color: var(--ink);
    background: var(--paper-raised);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius-small);
    box-shadow: var(--shadow-card);
    font: 0.75rem/1.35 var(--font-sans);
    text-align: center;
    text-decoration: none;
    white-space: normal;
    transform: translateX(-50%);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s var(--ease) 0.15s;
}
.tip:hover::after, .tip:focus-visible::after { opacity: 1; }

.account-menu {
    position: absolute;
    top: calc(100% + var(--space-2));
    right: 0;
    z-index: 32;
    min-width: 15rem;
    max-width: calc(100vw - 2rem);
    padding: var(--space-2) 0;
    background: var(--paper-raised);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-photo);
}

.account-who {
    margin: 0;
    padding: var(--space-2) var(--space-4) var(--space-3);
    border-bottom: 1px solid var(--rule);
    color: var(--ink-soft);
    font-size: 0.9rem;
}

.account-who strong { display: block; color: var(--ink); font-size: 1rem; font-weight: 600; overflow-wrap: anywhere; }

.account-who + .account-item { margin-top: var(--space-2); }

.account-item {
    display: block;
    width: 100%;
    min-height: var(--touch);
    padding: 0 var(--space-4);
    color: var(--ink);
    background: none;
    border: 0;
    font: inherit;
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

.account-item:hover, .account-item:focus-visible { background: var(--paper-sunk); }

/* Where the pages no longer fit beside the name: the circle stays at the top right, and the
   pages go on a row of their own below. */
@media (max-width: 52rem) {
    .account { order: 0; }
    .site-nav { order: 1; flex-basis: 100%; }
}

.site-main {
    max-width: var(--page);
    margin: 0 auto;
    padding: var(--space-6) var(--space-5) var(--space-8);
}

.plain-main { padding: 0 var(--space-5); }

/* ---------- Pages ---------- */

.page-narrow {
    max-width: var(--measure);
    margin: 0 auto;
}

.intro {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    color: var(--ink-soft);
    margin-bottom: var(--space-6);
}

.welcome {
    max-width: var(--measure);
    margin: 0 auto;
    padding: var(--space-8) 0;
    text-align: center;
    animation: fade-in 0.6s var(--ease) both;
}

.wordmark {
    margin: 0;
    font-family: var(--font-serif);
    font-weight: 500;
    font-size: clamp(2.6rem, 9vw, 3.6rem);
    letter-spacing: 0.01em;
}

.subtitle {
    margin: var(--space-2) 0 var(--space-6);
    font-family: var(--font-serif);
    font-weight: 300;
    font-size: 1.25rem;
    color: var(--ink-soft);
}

.lede {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    line-height: 1.65;
    margin-bottom: var(--space-6);
}

.fine-print {
    margin-top: var(--space-6);
    font-size: 0.95rem;
    color: var(--ink-soft);
}

.welcome .card { text-align: left; }

.empty-state {
    max-width: var(--measure);
    margin: var(--space-7) auto;
    text-align: center;
    color: var(--ink-soft);
}

.empty-title {
    font-family: var(--font-serif);
    font-size: 1.5rem;
    color: var(--ink);
}

/* ---------- Welcome photo ---------- */

.welcome-cover {
    position: relative;
    max-width: 30rem;
    margin: 0 auto var(--space-6);
    overflow: hidden;
    border-radius: 4px;
    box-shadow: var(--shadow-photo);
}

.welcome-cover::before {
    content: "";
    position: absolute;
    inset: -12px;
    background-image: var(--ph, none);
    background-size: cover;
    filter: blur(12px);
}

.welcome-cover img {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
}

.welcome-note {
    font-family: var(--font-serif);
    font-size: 1.25rem;
    line-height: 1.65;
    margin-bottom: var(--space-6);
}

/* ---------- Owner tools ---------- */

.owner-cover {
    max-width: 18rem;
    margin: 0 0 var(--space-3);
    overflow: hidden;
    border-radius: 4px;
}

.owner-cover img { display: block; width: 100%; height: auto; }

.owner-cover-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.owner-cover-hint { margin-top: var(--space-2); }

/* "Email me my link" for someone not on the list (and how to be), or not any more: said plainly. */
.sign-in-notice {
    margin: var(--space-4) 0 0;
    padding: var(--space-3) var(--space-4);
    color: var(--ink);
    background: var(--accent-wash);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-small);
}

/* A person's name: on their first visit, and from the circle at the top right. */
.name-form-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

/* A file input dressed as a quiet button (its label), the same size as the buttons beside it:
   without a label's margin, which made the row taller and the buttons stretch to fill it. */
.file-choice { margin: 0; }
.file-choice:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.file-choice.is-disabled { opacity: 0.6; cursor: default; }

.welcome-note-form { margin-top: var(--space-5); }

.hidden-photos {
    list-style: none;
    margin: 0 0 var(--space-6);
    padding: 0;
    display: grid;
    gap: var(--space-3);
}

.hidden-photo {
    display: grid;
    grid-template-columns: 6rem 1fr;
    gap: var(--space-4);
    align-items: center;
}

/* ---------- Cards and notices ---------- */

.card {
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    padding: var(--space-5);
    margin-bottom: var(--space-6);
    box-shadow: var(--shadow-card);
}

.card > :last-child { margin-bottom: 0; }

.notice {
    background: var(--accent-wash);
    border-radius: var(--radius);
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-6);
}

.notice h2 {
    font-size: 1.1rem;
    margin-bottom: var(--space-2);
}

.notice p:last-child { margin-bottom: 0; }

.notice-small {
    padding: var(--space-3) var(--space-4);
    font-size: 0.95rem;
}

/* ---------- Forms ---------- */

.field { margin-bottom: var(--space-4); }

label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--space-2);
}

.optional {
    font-weight: 400;
    color: var(--ink-soft);
}

input[type="text"], input[type="email"], input[type="number"], input[type="search"], input:not([type]), textarea, select {
    display: block;
    width: 100%;
    min-height: var(--touch);
    padding: var(--space-3) var(--space-3);
    font: inherit;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--control-border);
    border-radius: var(--radius-small);
    transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}

textarea {
    resize: vertical;
    line-height: 1.5;
}

/* Selects and text inputs size their text differently; a shared height keeps them level. */
input[type="text"], input[type="email"], input[type="number"], input[type="search"], input:not([type]), select {
    height: 3rem;
    padding-block: 0;
    line-height: 1.25;
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent);
    outline: none;
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 35%, transparent);
}

input::placeholder, textarea::placeholder { color: color-mix(in srgb, var(--ink-soft) 75%, transparent); }

[aria-invalid="true"] { border-color: var(--danger); }

.hint {
    margin: var(--space-1) 0 0;
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.field-error {
    margin: var(--space-2) 0 var(--space-3);
    color: var(--danger);
    font-weight: 500;
}

.form-message {
    margin: var(--space-4) 0 0;
    padding: var(--space-3) var(--space-4);
    border-left: 3px solid var(--success);
    background: color-mix(in srgb, var(--success) 10%, transparent);
    border-radius: 0 var(--radius-small) var(--radius-small) 0;
}

/* ---------- Buttons ---------- */

.btn, .btn-quiet {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--touch);
    padding: 0 var(--space-5);
    font: inherit;
    font-weight: 600;
    border-radius: var(--radius-small);
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.btn {
    background: var(--accent);
    color: var(--accent-ink);
    border: 1px solid var(--accent);
}

.btn:hover:not(:disabled) { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--accent-ink); }

.btn-quiet {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--control-border);
    font-weight: 500;
}

.btn-quiet:hover:not(:disabled) { background: var(--paper-sunk); }

.btn:disabled, .btn-quiet:disabled {
    opacity: 0.6;
    cursor: default;
}

.btn-block { width: 100%; }

/* Deleting: plainly red. Outlined on the page; filled where it's confirmed. */
.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch);
    padding: 0 var(--space-5);
    font: inherit;
    font-weight: 600;
    color: var(--danger);
    background: transparent;
    border: 1px solid var(--danger);
    border-radius: var(--radius-small);
    cursor: pointer;
}

.btn-danger:hover:not(:disabled) { background: rgb(227 154 140 / 12%); }

.btn.btn-danger { color: var(--accent-ink); background: var(--danger); border-color: var(--danger); }
.btn.btn-danger:hover:not(:disabled) { color: var(--accent-ink); background: #eab0a5; border-color: #eab0a5; }
.btn-danger:disabled { opacity: 0.6; cursor: default; }

.btn-small {
    min-height: var(--touch);
    padding: 0 var(--space-4);
    font-size: 0.95rem;
}

.btn-link {
    display: inline;
    padding: var(--space-2) 0;
    min-height: var(--touch);
    font: inherit;
    color: var(--accent);
    background: none;
    border: 0;
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 0.18em;
    cursor: pointer;
}

/* A page left open across a deploy offers to reload. */
.update-notice {
    padding: var(--space-2) var(--space-4);
    text-align: center;
    background: var(--accent-wash);
    border-bottom: 1px solid var(--rule);
}

.update-notice p { margin: 0; }

/* ---------- People ---------- */

.people-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border-top: 1px solid var(--rule);
}

.person {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: var(--space-3) var(--space-5);
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--rule);
}

.person.is-revoked .person-name { color: var(--ink-soft); }

.person-main {
    flex: 1 1 18rem;
    min-width: 0;
}

.person-name {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 1.2rem;
}

.person-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-4);
    margin: var(--space-1) 0 0;
    font-size: 0.93rem;
    color: var(--ink-soft);
    overflow-wrap: anywhere;
}

.confirm-text {
    flex-basis: 100%;
    margin: 0 0 var(--space-1);
    max-width: 26rem;
    font-size: 0.95rem;
}

.badge {
    display: inline-block;
    margin-left: var(--space-2);
    padding: 0.1rem 0.55rem;
    font-family: var(--font-sans);
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    vertical-align: middle;
    color: var(--accent);
    background: var(--accent-wash);
    border-radius: 999px;
}

.badge-muted {
    color: var(--ink-soft);
    background: var(--paper-sunk);
}

/* Admins: find, order, and narrow the list. */
.people-summary {
    margin-bottom: var(--space-4);
    color: var(--ink-soft);
}

.people-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4);
}

.people-find { flex: 1 1 16rem; }
.people-order { flex: 0 1 14rem; }

/* Separate pills rather than one segmented bar: there are several, and they wrap on phones. */
.filters.people-filters {
    gap: var(--space-2);
    padding: 0;
    background: none;
    border-radius: 0;
}

.people-filters .filter { border: 1px solid var(--control-border); }

.people-filters .filter[aria-pressed="true"] {
    background: var(--accent-wash);
    border-color: var(--accent);
    box-shadow: none;
}

.filter-count {
    margin-left: var(--space-1);
    font-weight: 400;
    color: var(--ink-soft);
}

.people-showing {
    min-height: 1.5em;
    margin: var(--space-2) 0 var(--space-3);
    font-size: 0.93rem;
}

/* Each person's Manage panel opens below them, across the row; its button stays at the right. */
.person-manage {
    flex: 0 1 auto;
    margin-left: auto;
}

.person-manage[open] {
    flex-basis: 100%;
    text-align: right;
}

.person-manage > summary {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--touch);
    padding: 0 var(--space-4);
    font-size: 0.95rem;
    font-weight: 500;
    list-style: none;
    border: 1px solid var(--control-border);
    border-radius: var(--radius-small);
    cursor: pointer;
    transition: background-color 0.15s var(--ease);
}

.person-manage > summary::-webkit-details-marker { display: none; }
.person-manage > summary:hover { background: var(--paper-sunk); }

.person-manage > summary::after {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-0.15rem) rotate(45deg);
    transition: transform 0.2s var(--ease);
}

.person-manage[open] > summary::after { transform: translateY(0.1rem) rotate(-135deg); }

.person-manage-body {
    display: grid;
    gap: var(--space-3);
    margin-top: var(--space-3);
    padding: var(--space-4);
    text-align: left;
    border: 1px solid var(--rule);
    border-radius: var(--radius-small);
}

.person-manage-body .confirm-text { margin: 0; max-width: 34rem; }

.person-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* ---------- Adding photos ---------- */

.add-photos {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
    gap: var(--space-4);
    padding: var(--space-5);
    margin-bottom: var(--space-6);
    border: 2px dashed var(--rule-strong);
    border-radius: var(--radius);
    background: var(--paper-raised);
    transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}

.add-photos.is-dragging {
    border-color: var(--accent);
    background: var(--accent-wash);
}

.add-choice {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-1);
    min-height: 8.5rem;
    padding: var(--space-4);
    margin: 0;
    text-align: center;
    color: var(--accent-ink);
    background: var(--accent);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background-color 0.15s var(--ease);
}

.add-choice:hover { background: var(--accent-hover); }
.add-choice:focus-within { outline: 3px solid var(--focus); outline-offset: 3px; }

.add-icon { width: 2.2rem; height: 2.2rem; }
.add-label { font-size: 1.15rem; font-weight: 600; }
.add-hint { font-size: 0.9rem; opacity: 0.9; }

.drop-hint {
    grid-column: 1 / -1;
    margin: 0;
    text-align: center;
    color: var(--ink-soft);
}

/* Touch screens get "Take a photo"; mouse and trackpad users get drag and drop. */
.only-touch, .add-choice.only-touch { display: none; }

@media (pointer: coarse) {
    .only-touch { display: inline; }
    .add-choice.only-touch { display: flex; }
    .only-pointer { display: none; }
}

/* ---------- The tray ---------- */

.tray-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.tray-head h2 { margin: 0; }

.tray-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: var(--space-4);
}

.tray-item {
    position: relative;
    display: grid;
    grid-template-columns: 7.5rem 1fr;
    gap: var(--space-4);
    padding: var(--space-4);
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
}

/* Remove: a red ✕ at the card's corner, until the photo is posted. */
.tray-remove {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    padding: 0;
    color: var(--danger);
    background: transparent;
    border: 0;
    border-radius: 50%;
    cursor: pointer;
}

.tray-remove:hover:not(:disabled) { background: rgb(227 154 140 / 12%); }
.tray-remove:disabled { opacity: 0.6; cursor: default; }
.tray-remove svg { width: 1.6rem; height: 1.6rem; }
.tray-item.has-remove .tray-body { padding-right: 2.25rem; }

/* The photo, and under it Post, which then says "✓ Posted". */
.tray-side {
    display: grid;
    gap: var(--space-2);
    align-content: start;
}

.tray-side .btn { width: 100%; padding: 0 var(--space-2); }

.tray-thumb {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: var(--radius-small);
    background-color: var(--paper-sunk);
    display: grid;
    place-items: center;
    color: var(--ink-soft);
}

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

.tray-open { display: block; width: 100%; height: 100%; }

.tray-glyph { width: 2.2rem; height: 2.2rem; }

.tray-body { min-width: 0; }

.tray-name {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.tray-status {
    margin: var(--space-1) 0 var(--space-2);
    color: var(--ink-soft);
}

.tray-item.is-failed .tray-status { color: var(--danger); }

/* On "Add a memory": quietly beside the name. */
.tray-status-beside {
    margin: 0 0 0 var(--space-2);
    font-size: 0.9rem;
    font-weight: 400;
}

.tray-note { margin: 0 0 var(--space-2); font-size: 0.95rem; }

.tray-item progress {
    width: 100%;
    height: 0.5rem;
    margin-bottom: var(--space-2);
    accent-color: var(--accent);
}

.tray-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
}

/* Under the photo: Post to Memory Wall; with versions, a link to choose on its page. */
.tray-post {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
    min-height: var(--touch);
    padding-top: var(--space-1);
    font-size: 0.85rem;
    line-height: 1.3;
    cursor: pointer;
}

.tray-post input {
    flex: none;
    width: 1.15rem;
    height: 1.15rem;
    margin: 0.05rem 0 0;
    accent-color: var(--accent);
}

.tray-post:has(input:disabled) { cursor: default; }
.tray-choose { display: block; padding: var(--space-1) 0; font-size: 0.85rem; }

.tray-title-field {
    display: grid;
    gap: var(--space-1);
    margin-bottom: var(--space-3);
}

.tray-title-field input { width: 100%; }

.tray-title-saved { min-height: 1.35em; margin: calc(-1 * var(--space-2)) 0 var(--space-2); }

.tray-review { margin: 0 0 var(--space-4); color: var(--ink-soft); }

/* "Photos I added": All / Unposted, and Add a memory. */
.review-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

@media (max-width: 30rem) {
    .tray-item { grid-template-columns: 5.5rem 1fr; }
}

/* ---------- Gallery ---------- */

.gallery-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    margin-bottom: var(--space-5);
}

.filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
    padding: var(--space-1);
    background: var(--paper-sunk);
    border-radius: 999px;
}

.filter {
    min-height: var(--touch);
    padding: 0 var(--space-4);
    font: inherit;
    font-size: 0.95rem;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

.filter[aria-pressed="true"], .filter[aria-current="page"] {
    background: var(--paper-raised);
    box-shadow: var(--shadow-card);
    font-weight: 600;
}

/* A filter that goes to another page ("Photos I added"), styled like the ones that switch views. */
a.filter {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

a.filter:hover { background: var(--accent-wash); }

.filter-unposted { color: var(--accent); }

/* Justified rows: each tile grows in proportion to its aspect ratio, so every row is the
   same height and fills the width, in timeline order. */
.justified {
    --row: 220px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.justified::after {
    content: "";
    flex-grow: 1000000;
}

/* A tile is the photo (its width follows its aspect ratio, so a row shares one height) and one
   line for its title underneath, reserved even when empty so rows stay level. */
.tile {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex-grow: calc(var(--ar) * 100);
    flex-basis: calc(var(--ar) * var(--row));
    min-width: 0;
    color: var(--ink-soft);
    text-decoration: none;
    border-radius: 4px;
}

.tile-photo {
    position: relative;
    display: block;
    aspect-ratio: var(--ar);
    max-height: calc(var(--row) * 1.6);
    overflow: hidden;
    border-radius: 4px;
    box-shadow: var(--shadow-photo);
}

.tile-title {
    display: block;
    min-height: 1.35em;
    font-size: 0.8125rem;
    line-height: 1.35;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tile:hover .tile-title { color: var(--ink); }

.tile-photo::before, .photo-figure::before {
    content: "";
    position: absolute;
    inset: -12px;
    background-image: var(--ph, none);
    background-size: cover;
    background-position: center;
    filter: blur(12px);
}

.tile-photo img {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Arranging the Undated section: tiles are dragged, or moved with the arrows under each photo. */
.section-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-2) var(--space-4);
}

.is-arranging .tile { cursor: grab; }
.is-arranging .tile.is-dragging { opacity: 0.45; }
.is-arranging .tile.is-drop-target .tile-photo { outline: 3px solid var(--accent); outline-offset: 2px; }
.is-arranging .tile-photo img { pointer-events: none; }

.arrange-tools {
    display: flex;
    gap: 4px;
}

.arrange-btn {
    flex: 1;
    min-width: 0;
    min-height: var(--touch);
    font: inherit;
    font-size: 1.35rem;
    line-height: 1;
    color: var(--ink);
    background: var(--paper-raised);
    border: 1px solid var(--control-border);
    border-radius: var(--radius-small);
    cursor: pointer;
}

.arrange-btn:hover:not(:disabled) { background: var(--paper-sunk); }
.arrange-btn:disabled { opacity: 0.35; cursor: default; }

.tile:focus-visible { outline-offset: 3px; }

img.fade {
    opacity: 0;
    transition: opacity 0.5s var(--ease);
}

img.fade.is-loaded { opacity: 1; }

.more {
    display: flex;
    justify-content: center;
    margin-top: var(--space-6);
}

@media (max-width: 40rem) {
    .justified { --row: 150px; gap: 5px; }
}

/* ---------- Photo view ---------- */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--touch);
    margin-bottom: var(--space-3);
    color: var(--ink-soft);
    text-decoration: none;
}

.back-link:hover { color: var(--ink); }

.photo-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(18rem, 1fr);
    gap: var(--space-6);
    align-items: start;
}

.photo-figure {
    position: relative;
    margin: 0;
    overflow: hidden;
    border-radius: 4px;
    box-shadow: var(--shadow-photo);
    background-color: var(--paper-sunk);
    /* A tall picture fits the screen, so the versions and tools under it stay in reach. */
    width: min(100%, calc(62vh * var(--ar, 1)));
    margin-inline: auto;
}

.photo-figure img {
    position: relative;
    display: block;
    width: 100%;
    height: auto;
}

.photo-story h1 { font-size: clamp(1.6rem, 4vw, 2.1rem); }

.photo-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;   /* the button's text lines up with the words beside it */
    gap: var(--space-1) var(--space-4);
    color: var(--ink-soft);
}

@media (max-width: 60rem) {
    .photo-layout { grid-template-columns: 1fr; }
    .photo-figure { width: auto; margin: 0 calc(-1 * var(--space-4)); border-radius: 0; }
}

/* ---------- Timeline ---------- */

.decade-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    gap: var(--space-1);
    overflow-x: auto;
    margin: 0 calc(-1 * var(--space-5)) var(--space-5);
    padding: var(--space-2) var(--space-5);
    background: color-mix(in srgb, var(--paper) 92%, transparent);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--rule);
    scrollbar-width: none;
}

.decade-bar a {
    flex: none;
    display: inline-flex;
    align-items: center;
    min-height: var(--touch);
    padding: 0 var(--space-3);
    border-radius: 999px;
    color: var(--ink);
    text-decoration: none;
    font-weight: 500;
}

.decade-bar a:hover { background: var(--paper-sunk); }

.decade {
    scroll-margin-top: 4.5rem;
    margin-bottom: var(--space-7);
}

.decade-title {
    font-size: clamp(1.7rem, 4vw, 2.2rem);
    margin-bottom: var(--space-2);
}

.year-title {
    margin: var(--space-5) 0 var(--space-3);
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--ink-soft);
}

.undated-note { max-width: var(--measure); }

/* ---------- Photo view: toolbar, story, additions ---------- */

.photo-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.photo-toolbar .back-link { margin-bottom: 0; }
.photo-toolbar .btn-danger { margin-left: auto; }   /* at the right, on a line of its own too */

.photo-stage {
    position: sticky;
    top: var(--space-4);
    touch-action: pan-y pinch-zoom;
}

.photo-open {
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    background: none;
    cursor: zoom-in;
}

.photo-pending { padding: var(--space-7) var(--space-4); text-align: center; }

.photo-hint {
    margin: var(--space-2) 0 0;
    font-size: 0.9rem;
    color: var(--ink-soft);
    text-align: center;
}

.story-text {
    font-family: var(--font-serif);
    font-size: 1.2rem;
    line-height: 1.7;
}

.story-text p { margin-bottom: var(--space-4); }
.story-text a { overflow-wrap: anywhere; }

.story-primary { margin-top: var(--space-5); }

.story-edited, .addition-meta, .hidden-note {
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.story-actions, .addition-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-4);
}

.story-empty {
    margin: var(--space-5) 0;
    padding: var(--space-5);
    text-align: center;
    border: 1px dashed var(--rule-strong);
    border-radius: var(--radius);
}

.story-empty p {
    font-family: var(--font-serif);
    font-size: 1.2rem;
}

.additions {
    margin-top: var(--space-6);
    border-top: 1px solid var(--rule);
}

.addition {
    padding: var(--space-5) 0 var(--space-3);
    border-bottom: 1px solid var(--rule);
}

.addition .story-text { font-size: 1.1rem; }

.addition.is-hidden .story-text { opacity: 0.55; }

.addition-meta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1) var(--space-3);
    margin: calc(-1 * var(--space-2)) 0 var(--space-1);
}

.addition-author { font-weight: 600; color: var(--ink); }

.add-to-story {
    margin-top: var(--space-6);
    padding-top: var(--space-5);
}

.quiet-link { color: var(--ink-soft); }

/* ---------- Story editor and date picker ---------- */

.story-editor, .date-picker {
    margin: var(--space-4) 0;
}

.toolbar {
    display: flex;
    gap: var(--space-1);
    margin-bottom: var(--space-2);
}

.tool {
    min-width: var(--touch);
    min-height: var(--touch);
    padding: 0 var(--space-3);
    font: inherit;
    font-size: 0.95rem;
    color: var(--ink);
    background: var(--paper-raised);
    border: 1px solid var(--control-border);
    border-radius: var(--radius-small);
    cursor: pointer;
}

.tool:hover { background: var(--paper-sunk); }

.story-editor textarea {
    font-family: var(--font-serif);
    font-size: 1.15rem;
    line-height: 1.6;
}

.counter.is-over { color: var(--accent); font-weight: 500; }

.editor-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

/* Edit this image: making something new from it, below the editor. */
.edit-create {
    margin-top: var(--space-6);
    padding-top: var(--space-5);
    border-top: 1px solid var(--rule);
}

.edit-create h2 { font-size: 1.25rem; }

.date-picker fieldset {
    margin: 0 0 var(--space-3);
    padding: var(--space-4);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
    background: var(--paper-raised);
}

.date-picker legend {
    padding: 0 var(--space-2);
    font-weight: 600;
}

.date-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 0 var(--space-3);
}

.date-fields .field { min-width: 7rem; }

.date-fields input { width: 7rem; }

/* ---------- Tray details ---------- */

.tray-details {
    margin: var(--space-2) 0 var(--space-3);
    padding-top: var(--space-2);
    border-top: 1px solid var(--rule);
}

.tray-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;   /* the label, the words, and the link read as one line */
    gap: var(--space-1) var(--space-3);
    margin: 0 0 var(--space-2);
}

.tray-label { font-weight: 600; }

.tray-excerpt { overflow-wrap: anywhere; }

/* ---------- Phone capture ---------- */

.add-phone {
    font: inherit;
    border: 0;
    width: 100%;
}

.handoff {
    grid-column: 1 / -1;
    padding: var(--space-5);
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
}

.handoff h2 { margin-bottom: var(--space-4); }

.handoff-connect {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-5);
    align-items: center;
    margin-bottom: var(--space-4);
}

.qr {
    flex: none;
    width: 14rem;
    padding: var(--space-3);
    background: #ffffff;
    border-radius: var(--radius);
    box-shadow: var(--shadow-card);
}

.qr svg { display: block; width: 100%; height: auto; }

.handoff-steps { flex: 1 1 16rem; }
.handoff-steps ol { padding-left: 1.2rem; margin: 0 0 var(--space-3); }
.handoff-steps li { margin-bottom: var(--space-1); }

.capture-code {
    font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
    font-size: 1.15rem;
    letter-spacing: 0.08em;
    white-space: nowrap;
}

.capture-connected {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--success);
}

.handoff-photos {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    list-style: none;
    padding: 0;
    margin: 0 0 var(--space-4);
}

.handoff-photo {
    position: relative;
    width: 7.5rem;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: var(--radius-small);
    display: grid;
    place-items: center;
}

.handoff-photo img { width: 100%; height: 100%; object-fit: cover; position: relative; }

.handoff-wait {
    padding: var(--space-2);
    font-size: 0.85rem;
    text-align: center;
    color: var(--ink-soft);
}

/* The phone page (/capture) */

.capture {
    max-width: 30rem;
    margin: 0 auto;
    padding: var(--space-5) var(--space-4) var(--space-7);
}

.capture-brand { margin-bottom: var(--space-5); min-height: 0; }

.capture-choices {
    grid-template-columns: 1fr;
    padding: var(--space-3);
    border-style: solid;
}

.capture-choices .add-choice { display: flex; }

.capture-list {
    list-style: none;
    padding: 0;
    margin: var(--space-4) 0 0;
}

.capture-item {
    display: flex;
    justify-content: space-between;
    gap: var(--space-3);
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--rule);
}

.capture-name { overflow-wrap: anywhere; }
.capture-status { flex: none; color: var(--ink-soft); }
.capture-item.is-done .capture-status { color: var(--success); font-weight: 600; }
.capture-item.is-failed .capture-status { color: var(--danger); }

/* ---------- Editing ---------- */

.edit-page { max-width: 64rem; margin: 0 auto; }

/* The stage takes the photo's shape as turned (editor.js sets --ratio), so nothing shows around
   it: as tall as fits, never wider than the page. */
.editor-stage {
    --ratio: 1.5;
    --stage-height: min(68vh, 44rem);
    width: min(100%, calc(var(--stage-height) * var(--ratio)));
    aspect-ratio: var(--ratio);
    margin: 0 auto var(--space-4);
    background: var(--paper-sunk);
    border-radius: var(--radius);
    overflow: hidden;
}

.editor-stage img {
    display: block;
    max-width: 100%;
}

/* Fix the angle: the photo as shared, with a handle on each corner of the picture. */
.editor-stage { position: relative; }
.editor-stage.is-cornering img { width: 100%; height: 100%; max-width: none; }

.corner-overlay { position: absolute; inset: 0; touch-action: none; }
.corner-overlay svg { position: absolute; inset: 0; width: 100%; height: 100%; }

.corner-outline {
    fill: rgb(210 176 138 / 12%);
    stroke: var(--accent);
    stroke-width: 2;
    vector-effect: non-scaling-stroke;
}

.corner-handle {
    position: absolute;
    width: var(--touch);
    height: var(--touch);
    margin: calc(var(--touch) / -2) 0 0 calc(var(--touch) / -2);
    padding: 0;
    border: 2px solid var(--accent);
    border-radius: 50%;
    background: rgb(26 24 22 / 35%);
    cursor: grab;
    touch-action: none;
}

.corner-handle::after {
    content: "";
    position: absolute;
    inset: 50% auto auto 50%;
    width: 6px;
    height: 6px;
    margin: -3px 0 0 -3px;
    border-radius: 50%;
    background: var(--accent);
}

.corner-handle.is-dragging { cursor: grabbing; background: rgb(26 24 22 / 15%); }

.corner-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
}

.corner-tools .hint, .corner-tools .field-error { flex-basis: 100%; margin: 0; }

.fix-create { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin: 0; }
.fix-create .hint { margin: 0; }

.edit-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3) var(--space-5);
    margin-bottom: var(--space-5);
}

.edit-tools .hint { flex-basis: 100%; margin: 0; }

.tool-group { display: flex; gap: var(--space-2); }

.tool-icon { width: 1.3rem; height: 1.3rem; }

/* Cropper.js, in Chartage's colors */
.editor-stage .cropper-view-box { outline-color: var(--accent); }
.editor-stage .cropper-line, .editor-stage .cropper-point { background-color: var(--accent); }
.editor-stage .cropper-point { width: 14px; height: 14px; opacity: 0.9; }
.editor-stage .cropper-point.point-se { width: 14px; height: 14px; }

@media (pointer: coarse) {
    .editor-stage .cropper-point { width: 22px; height: 22px; }
}

/* ---------- A photo at full size (PhotoViewer, viewer.js) ---------- */

.photo-viewer {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    background: #000;
    color: #ece5da;
    overflow: hidden;
}

.photo-viewer::backdrop { background: #000; }

.photo-viewer-stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
    touch-action: none;
    cursor: zoom-in;
    outline: none;
}

.photo-viewer-stage.is-zoomed { cursor: grab; }
.photo-viewer-stage.is-zoomed:active { cursor: grabbing; }

.photo-viewer-image {
    position: absolute;
    top: 0;
    left: 0;
    max-width: none;
    transform-origin: 0 0;
    user-select: none;
    -webkit-user-drag: none;
    opacity: 0;
    transition: opacity 0.2s var(--ease);
}

.photo-viewer-stage.is-ready .photo-viewer-image { opacity: 1; }

.photo-viewer-close {
    position: absolute;
    top: var(--space-3);
    right: var(--space-3);
    width: 48px;
    height: 48px;
    font-size: 2rem;
    line-height: 1;
    color: #ece5da;
    background: rgb(0 0 0 / 55%);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}

.photo-viewer-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-2) var(--space-4);
    padding: var(--space-3);
    background: linear-gradient(transparent, rgb(0 0 0 / 70%));
    pointer-events: none;
}

.photo-viewer-hint { margin: 0; font-size: 0.85rem; opacity: 0.75; }

.photo-viewer-tools {
    display: flex;
    gap: var(--space-1);
    pointer-events: auto;
}

.photo-viewer-tools button {
    min-width: var(--touch);
    min-height: var(--touch);
    padding: 0 var(--space-3);
    font: inherit;
    font-size: 0.95rem;
    color: #ece5da;
    background: rgb(0 0 0 / 55%);
    border: 1px solid rgb(236 229 218 / 25%);
    border-radius: 999px;
    cursor: pointer;
}

.photo-viewer-tools button[aria-label] { font-size: 1.3rem; }

@media (max-width: 60rem) {
    .photo-stage { position: static; }
}

@media (max-width: 40rem) {
    .decade-bar { margin: 0 calc(-1 * var(--space-4)) var(--space-4); padding: var(--space-2) var(--space-4); }
}

/* ---------- Blazor error bar ---------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    padding: var(--space-4) var(--space-8) var(--space-4) var(--space-5);
    background: var(--paper-raised);
    color: var(--ink);
    border-top: 1px solid var(--rule);
    box-shadow: 0 -4px 16px rgb(0 0 0 / 8%);
}

#blazor-error-ui .reload { margin-left: var(--space-3); }

#blazor-error-ui .dismiss {
    position: absolute;
    right: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    min-width: var(--touch);
    min-height: var(--touch);
    border: 0;
    background: none;
    color: var(--ink-soft);
    font-size: 1.4rem;
    cursor: pointer;
}

/* ---------- Create with AI ---------- */

.create-page { max-width: 64rem; margin: 0 auto; }

.create-layout {
    display: grid;
    grid-template-columns: minmax(0, 28rem) minmax(0, 1fr);
    gap: var(--space-6);
    align-items: start;
}

/* For a version: its stage and conversation, in one column; nothing beside the stage to keep it
   in view for, so it scrolls with the rest (held in place, what follows slid over it). */
.create-layout.is-version { grid-template-columns: minmax(0, 40rem); }
.create-layout.is-version .create-stage-column { position: static; }

/* The stage: the photo, and whatever is made from it, shown in the same place. On wide screens
   it stays in view while the ideas beside it scroll. */
.create-stage-column {
    position: sticky;
    top: var(--space-4);
}

.create-stage { scroll-margin-top: var(--space-4); }

.stage-figure {
    --stage-height: min(62vh, 36rem);
    position: relative;
    width: min(100%, calc(var(--stage-height) * var(--ar, 1)));
    aspect-ratio: var(--ar, 1);
    margin: 0 auto var(--space-3);
    overflow: hidden;
    border-radius: var(--radius-small);
    box-shadow: var(--shadow-photo);
}

.stage-figure::before {
    content: "";
    position: absolute;
    inset: -12px;
    background-image: var(--ph, none);
    background-size: cover;
    background-position: center;
    filter: blur(12px);
}

.stage-figure img { position: relative; display: block; width: 100%; height: 100%; object-fit: contain; }

.stage-figure.is-working img { animation: breathe 1.6s var(--ease) infinite alternate; }

@keyframes breathe { to { opacity: 0.55; } }

.stage-progress {
    position: absolute;
    right: var(--space-3);
    bottom: var(--space-3);
    left: var(--space-3);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    color: var(--ink);
    background: var(--paper-raised);
    border-radius: var(--radius-small);
    box-shadow: var(--shadow-card);
}

.stage-note { text-align: center; }

.stage-caption {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2) var(--space-3);
    margin-bottom: var(--space-3);
}

.stage-caption p {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-2);
    margin: 0;
}

.stage-caption strong { font-family: var(--font-serif); font-size: 1.2rem; font-weight: 500; overflow-wrap: anywhere; }

.create-stage .creation-actions { margin-bottom: var(--space-3); }

/* The conversation with the AI under the stage: what you asked, what it asked and said. */
.create-chat { margin: var(--space-5) 0 var(--space-3); }

.chat {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    padding: 0;
    list-style: none;
}

.chat-line {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--space-3);
    align-items: baseline;
    max-width: min(34rem, 92%);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius);
}

.chat-line.from-you { justify-self: end; background: var(--accent-wash); }
.chat-line.from-ai { justify-self: start; background: var(--paper-sunk); }
.chat-line.is-pending .chat-text { color: var(--ink-soft); }
.chat-line .spinner { vertical-align: middle; margin-right: var(--space-1); }

.chat-who {
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-soft);
}

.chat-text { margin: 0; overflow-wrap: anywhere; }

.chat-version {
    justify-self: center;
    font-size: 0.9rem;
}

.chat-composer {
    display: grid;
    gap: var(--space-2);
    margin: var(--space-3) 0 var(--space-5);
}

.chat-composer label { margin-bottom: 0; }

.chat-send {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
}

.chat-send .hint { margin: 0; }

.chat-choices, .chat-suggestion {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
}

.chat-suggestion .hint { margin: 0; }

/* Rotate or crop: the AI's suggestion first, then turning, the crop's shape, and straightening. */
.fix-up {
    display: grid;
    gap: var(--space-2);
    padding-bottom: var(--space-4);
    margin-bottom: var(--space-2);
    border-bottom: 1px solid var(--rule);
}

.fix-up > .btn-quiet { justify-self: start; }
.fix-up .hint, .fix-up .form-message { margin: 0; }

.straighten {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
}

.straighten label { margin: 0; }
.straighten input[type="range"] { flex: 1 1 12rem; min-height: var(--touch); accent-color: var(--accent); }
.straighten output { min-width: 11rem; font-variant-numeric: tabular-nums; color: var(--ink-soft); }

/* Pointing to someone on the stage: the picture waits for a tap, then shows a ring there. */
.stage-figure.is-pointing { cursor: crosshair; outline: 3px dashed var(--accent); outline-offset: 3px; }

.point-ring {
    position: absolute;
    width: 2.75rem;
    height: 2.75rem;
    margin: -1.375rem 0 0 -1.375rem;
    border: 3px solid #e02020;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.85), inset 0 0 0 2px rgba(255, 255, 255, 0.85);
    pointer-events: none;
}

.point-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
}

.point-tools .hint, .point-set { margin: 0; }
.point-tools .btn-link { padding: 0; min-height: var(--touch); }
.chat-pointed { margin-left: 0.35em; color: var(--ink-soft); font-size: 0.9em; }

/* A tap-to-use answer or suggestion: a quiet box, like a field that's already filled in. */
.suggestion {
    min-height: var(--touch);
    padding: var(--space-2) var(--space-3);
    font: inherit;
    font-size: 0.95rem;
    line-height: 1.45;
    text-align: left;
    color: var(--ink);
    background: var(--paper-raised);
    border: 1px solid var(--control-border);
    border-left: 3px solid var(--accent);
    border-radius: var(--radius-small);
    cursor: pointer;
    transition: background-color 0.15s var(--ease);
}

.chat-suggestion .suggestion { flex: 1 1 100%; }

.suggestion:hover:not(:disabled) { background: var(--accent-wash); }
.suggestion:disabled { opacity: 0.6; cursor: default; }

.create-tools h2 { font-size: 1.25rem; margin-bottom: var(--space-3); }
.create-tools > .hint, .create-tools > .notice { margin-bottom: var(--space-5); }

.create-tools section + section {
    margin-top: var(--space-6);
    padding-top: var(--space-5);
    border-top: 1px solid var(--rule);
}

.idea-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
}

.idea {
    min-height: var(--touch);
    padding: 0 var(--space-4);
    font: inherit;
    font-size: 0.95rem;
    color: var(--ink);
    background: var(--paper-raised);
    border: 1px solid var(--control-border);
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.idea:hover:not(:disabled) { background: var(--accent-wash); border-color: var(--accent); }
.idea:disabled { opacity: 0.5; cursor: default; }
.idea-classic { background: var(--paper); }

.idea-subhead {
    margin: var(--space-5) 0 var(--space-3);
    font-family: var(--font-sans);
    font-size: 1rem;
    font-weight: 600;
}

.label { font-weight: 500; margin-bottom: var(--space-1); }

.chosen-photos {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-bottom: var(--space-3);
}

.chosen-photo {
    position: relative;
    width: 7rem;
    height: 7rem;
    margin: 0;
    overflow: hidden;
    border-radius: var(--radius-small);
}

.chosen-photo img { position: relative; width: 100%; height: 100%; object-fit: cover; }

.chosen-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: var(--touch);
    height: var(--touch);
    font-size: 1.2rem;
    line-height: 1;
    color: var(--ink);
    background: var(--paper-raised);
    border: 1px solid var(--control-border);
    border-radius: 999px;
    cursor: pointer;
}

/* Cut-outs sit on a soft checkerboard, the usual sign for "see-through". Both squares are drawn,
   so the inline background color from TileStyle can't hide it. */
.stage-figure.is-transparent {
    background-image: conic-gradient(var(--rule) 25%, var(--paper-raised) 0 50%, var(--rule) 0 75%, var(--paper-raised) 0);
    background-size: 20px 20px;
}

.spinner {
    flex: none;
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid var(--rule-strong);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

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

.creation-badge {
    padding: 0.1rem 0.55rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent);
    background: var(--accent-wash);
    border-radius: 999px;
}

.creation-prompt, .creation-source { font-size: 0.95rem; color: var(--ink-soft); overflow-wrap: anywhere; }

.creation-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
}

/* Owner tools: an on/off switch. The words beside it say the state too. */
.switch-row { margin-bottom: var(--space-3); }

.switch-label { margin-right: var(--space-2); font-weight: 600; }

.switch {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    min-height: var(--touch);
    padding: 0 var(--space-1);
    font: inherit;
    color: var(--ink);
    background: none;
    border: 0;
    border-radius: var(--radius-small);
    cursor: pointer;
}

.switch:disabled { cursor: default; opacity: 0.6; }

.switch-track {
    position: relative;
    width: 3rem;
    height: 1.75rem;
    background: var(--paper-sunk);
    border-radius: 999px;
    box-shadow: inset 0 0 0 1px var(--control-border);
    transition: background-color 0.2s var(--ease);
}

.switch-thumb {
    position: absolute;
    top: 0.25rem;
    left: 0.25rem;
    width: 1.25rem;
    height: 1.25rem;
    background: var(--control-border);
    border-radius: 50%;
    transition: transform 0.2s var(--ease), background-color 0.2s var(--ease);
}

.switch[aria-checked="true"] .switch-track { background: var(--accent); box-shadow: none; }
.switch[aria-checked="true"] .switch-thumb { background: var(--paper-raised); transform: translateX(1.25rem); }

.switch-state { min-width: 2rem; font-weight: 500; }

.ai-spend { margin-bottom: var(--space-1); }

.ai-limits {
    margin: var(--space-5) 0 var(--space-4);
    padding-top: var(--space-4);
    border-top: 1px solid var(--rule);
}

.ai-limits input[type="number"] { max-width: 9rem; }

/* What the models were asked, for the maker and the Owner. */
.made-how {
    margin-bottom: var(--space-3);
    font-size: 0.9rem;
    color: var(--ink-soft);
}

.made-how summary { cursor: pointer; min-height: var(--touch); display: flex; align-items: center; width: fit-content; }
.made-how ol { margin: 0 0 0 var(--space-5); padding: 0; overflow-wrap: anywhere; }

.ai-models {
    display: grid;
    grid-template-columns: max-content minmax(0, 1fr);
    gap: var(--space-1) var(--space-3);
    margin: var(--space-4) 0 var(--space-2);
    font-size: 0.95rem;
}

.ai-models dt { color: var(--ink-soft); }
.ai-models dd { margin: 0; overflow-wrap: anywhere; }

@media (max-width: 40rem) {
    .ai-models { grid-template-columns: 1fr; }
    .ai-models dd { margin-bottom: var(--space-2); }
}

/* Made with AI: a quiet mark before the tile's title (its alt text says so in words), and a
   plain line on the photo's page. */
.tile-ai {
    margin-right: 0.3em;
    font-size: 0.8em;
    color: var(--ink-soft);
    opacity: 0.7;
}

/* In "Photos I added": a photo with nothing of it chosen for the gallery. */
.tile-photo.is-set-aside { opacity: 0.6; }
.tile-note { margin-top: -3px; font-size: 0.75rem; font-style: italic; color: var(--ink-soft); }

/* The photo's versions under the stage: the photo as shared, the kept ones, and your own drafts. */
.version-strip {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-3);
}

.version-thumb {
    position: relative;
    display: block;
    height: 3.5rem;
    aspect-ratio: var(--ar);
    min-width: var(--touch);
    max-width: 7rem;
    overflow: hidden;
    border-radius: var(--radius-small);
    outline: 2px solid transparent;
    outline-offset: 2px;
}

.version-thumb[aria-current="true"] { outline-color: var(--accent); }

/* A draft: only its maker sees it, until it's kept. */
.version-thumb.is-draft { outline-style: dashed; outline-color: var(--rule-strong); }
.version-thumb.is-draft[aria-current="true"] { outline-color: var(--accent); }

.version-thumb img {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.version-caption { margin: var(--space-2) 0 0; font-size: 0.9rem; color: var(--ink-soft); }

/* What can be done with the picture shown: include it in the gallery, edit it, make something new.
   Centered under it, like the picture and its versions. */
.picture-tools { margin-top: var(--space-4); }
.picture-tools > p { margin: var(--space-2) 0 0; text-align: center; }

.picture-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: var(--space-2) var(--space-3);
}

.photo-stage .version-strip { justify-content: center; }
.photo-stage .version-caption { text-align: center; }

/* Post to Memory Wall, and under it, Show as another view (one or the other). */
.picture-choices { display: grid; justify-items: start; }

/* A version's description, edited under its picture. */
.describe-form { max-width: 32rem; margin: var(--space-2) auto 0; }
.describe-row { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.describe-row input { flex: 1 1 14rem; width: auto; }

/* Download, at the picture's top right corner. */
.photo-download {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    display: grid;
    place-items: center;
    width: var(--touch);
    height: var(--touch);
    padding: 0;
    color: #fff;
    background: rgb(20 18 16 / 55%);
    border: 1px solid rgb(255 255 255 / 25%);
    border-radius: 50%;
    cursor: pointer;
}

.photo-download:hover:not(:disabled) { background: rgb(20 18 16 / 80%); }
.photo-download svg { width: 1.35rem; height: 1.35rem; }

/* "Delete this photo?" */
/* A question before something that can't be taken back; and the same look for changing your name. */
.confirm-dialog, .name-dialog, .download-dialog {
    width: min(30rem, calc(100vw - 2rem));
    padding: var(--space-5);
    color: var(--ink);
    background: var(--paper-raised);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-photo);
}

.confirm-dialog::backdrop, .name-dialog::backdrop, .download-dialog::backdrop { background: rgb(0 0 0 / 60%); }
.confirm-dialog h2, .name-dialog h2, .download-dialog h2 { margin-top: 0; font-size: 1.35rem; }

/* Download the Memory Wall: what it holds, then how far it's got. */
.download-dialog .download-hint { margin: 0 0 var(--space-2); padding-left: calc(1.25rem + var(--space-2)); }

.download-progress {
    display: block;
    width: 100%;
    height: 0.5rem;
    margin: 0 0 var(--space-3);
    accent-color: var(--accent);
}

.confirm-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-4);
}

.check-action input {
    flex: none;
    width: 1.25rem;
    height: 1.25rem;
    margin: 0;
    accent-color: var(--accent);
}

.check-action {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--touch);
    font-size: 0.95rem;
    cursor: pointer;
}

.photo-made-from {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: var(--space-1) var(--space-2);
    color: var(--ink-soft);
}


/* The photo picker */
.picker {
    width: min(56rem, calc(100vw - 2rem));
    max-height: calc(100dvh - 2rem);
    padding: 0;
    color: var(--ink);
    background: var(--paper);
    border: 0;
    border-radius: var(--radius);
    box-shadow: var(--shadow-photo);
}

.picker::backdrop { background: rgb(0 0 0 / 45%); }

.picker-inner {
    display: flex;
    flex-direction: column;
    max-height: calc(100dvh - 2rem);
    padding: var(--space-5);
}

.picker-head h2 { font-size: 1.3rem; margin-bottom: var(--space-1); }

.picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr));
    gap: var(--space-2);
    overflow-y: auto;
    padding: var(--space-1);
}

.picker-tile {
    position: relative;
    aspect-ratio: 1;
    padding: 0;
    overflow: hidden;
    border: 0;
    border-radius: var(--radius-small);
    cursor: pointer;
}

.picker-tile img { position: relative; width: 100%; height: 100%; object-fit: cover; }
.picker-tile:disabled { opacity: 0.45; cursor: default; }
.picker-tile[aria-pressed="true"] { outline: 4px solid var(--accent); outline-offset: -4px; }

.picker-check {
    position: absolute;
    top: 6px;
    right: 6px;
    display: none;
    place-items: center;
    width: 28px;
    height: 28px;
    color: var(--accent-ink);
    background: var(--accent);
    border-radius: 999px;
    font-weight: 700;
}

.picker-tile[aria-pressed="true"] .picker-check { display: grid; }

/* A version's tile says which it is ("Cartoon"), as the photo itself may sit beside it. */
.picker-version {
    position: absolute;
    left: 6px;
    bottom: 6px;
    max-width: calc(100% - 12px);
    padding: 2px 8px;
    overflow: hidden;
    color: #fff;
    background: rgb(0 0 0 / 62%);
    border-radius: 999px;
    font-size: 0.75rem;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.picker-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: var(--space-4);
}

@media (max-width: 52rem), (max-height: 40rem) {
    .create-stage-column { position: static; }
}

@media (max-width: 52rem) {
    .create-layout { grid-template-columns: minmax(0, 1fr); }   /* the strip scrolls instead of widening the page */
    .stage-figure { --stage-height: 60vh; }
}

/* ---------- Obituary ---------- */

/* /obit: a quiet column, like a printed page; the picture first, then the name and dates. */
.obituary-page {
    max-width: var(--measure);
    margin: 0 auto;
    animation: fade-in 0.6s var(--ease) both;
}

.obituary-portrait {
    position: relative;
    width: min(20rem, 72%);
    aspect-ratio: var(--ar);
    margin: var(--space-2) auto var(--space-6);
    overflow: hidden;
    border-radius: 4px;
    box-shadow: var(--shadow-photo);
}

.obituary-portrait::before {
    content: "";
    position: absolute;
    inset: -12px;
    background-image: var(--ph, none);
    background-size: cover;
    filter: blur(12px);
}

.obituary-portrait img {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.obituary-head {
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-5);
    text-align: center;
    border-bottom: 1px solid var(--rule);
}

.obituary-head :is(h1, h2, h3) {
    margin-bottom: var(--space-2);
    font-size: clamp(2rem, 6vw, 2.75rem);
}

.obit-version-text .obituary-head :is(h1, h2, h3) { font-size: 1.6rem; }

.obituary-dates {
    margin: 0;
    font-family: var(--font-serif);
    font-size: 1.15rem;
    letter-spacing: 0.02em;
    color: var(--ink-soft);
}

.obituary-foot {
    margin-top: var(--space-7);
    padding-top: var(--space-5);
    text-align: center;
    color: var(--ink-soft);
    border-top: 1px solid var(--rule);
}

/* The admins' way back to editing, last on the page. */
.obituary-foot .btn-quiet { margin-top: var(--space-4); }

/* /obit/edit: the draft on the left, the writing help beside it; on a phone they take turns. */
.obit-editor-head {
    display: grid;
    gap: var(--space-1);
    margin-bottom: var(--space-3);
}

.obit-editor-head h1 { margin: 0; }
.obit-editor-head .back-link { margin-bottom: 0; }

.obit-status {
    margin: 0;
    font-size: 0.95rem;
    color: var(--ink-soft);
}

/* Whether it's saved, Preview and Publish, and anything needing an answer stay in reach while
   scrolling through a long obituary. */
.obit-editor-bar {
    position: sticky;
    top: 0;
    z-index: 3;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    margin-bottom: var(--space-4);
    padding: var(--space-2) 0;
    background: var(--paper);
    border-bottom: 1px solid var(--rule);
}

.obit-panes { display: none; }

.obit-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-left: auto;
}

.obit-editor-bar > :is(.obit-conflict, .obit-confirm, .form-message) { flex-basis: 100%; margin: 0; }
.obit-editor-bar .obit-confirm h2 { margin-bottom: var(--space-1); font-size: 1.1rem; }
.obit-editor-bar .notice p { margin-bottom: var(--space-2); }

.obit-editor-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(20rem, 27rem);
    gap: var(--space-6);
    align-items: start;
}

.obit-undo {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0 var(--space-3);
}

.obit-portrait {
    margin: 0 0 var(--space-4);
    padding: 0;
    border: 0;
}

.obit-portrait legend {
    margin-bottom: var(--space-2);
    padding: 0;
    font-weight: 500;
}

.obit-portrait-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-3);
}

.obit-portrait-thumb {
    width: 6rem;
    aspect-ratio: var(--ar);
    overflow: hidden;
    border-radius: 4px;
    box-shadow: var(--shadow-card);
}

.obit-portrait-thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }

.obit-portrait-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }

.obit-body textarea { min-height: 24rem; }

.obit-preview {
    padding: var(--space-6) var(--space-5);
    border: 1px dashed var(--rule-strong);
    border-radius: var(--radius);
}

.obit-versions {
    margin-top: var(--space-6);
    padding-top: var(--space-3);
    border-top: 1px solid var(--rule);
}

.obit-versions > summary {
    display: flex;
    align-items: center;
    min-height: var(--touch);
    font-weight: 500;
    cursor: pointer;
}

.obit-version-list {
    display: grid;
    margin: var(--space-2) 0 0;
    padding: 0;
    list-style: none;
}

.obit-version {
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--rule);
}

.obit-version-meta { margin: 0; font-size: 0.95rem; }

.obit-version-changes {
    margin: var(--space-1) 0 0;
    font-size: 0.95rem;
    color: var(--ink-soft);
}

.obit-version-actions { display: flex; flex-wrap: wrap; gap: 0 var(--space-4); }

.obit-version-text {
    margin-top: var(--space-2);
    padding: var(--space-5) var(--space-4);
    background: var(--paper-raised);
    border-radius: var(--radius);
}

/* The writing help: the conversation scrolls inside, so the box to write in stays in view. */
.obit-help-pane {
    position: sticky;
    top: 4.5rem;
}

.obit-help {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 6rem);
    max-height: calc(100dvh - 6rem);
    padding: var(--space-4);
    background: var(--paper-raised);
    border: 1px solid var(--rule);
    border-radius: var(--radius);
}

.obit-help-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0 var(--space-3);
}

.obit-help-head h2 { margin: 0; font-size: 1.25rem; }

.obit-help-tools { display: flex; flex-wrap: wrap; gap: 0 var(--space-3); font-size: 0.95rem; }

.obit-help-intro { margin: var(--space-3) 0; color: var(--ink-soft); }

.obit-help .chat-choices { margin-bottom: var(--space-3); }

.obit-help .chat-composer { margin-bottom: 0; }

.obit-help-note { margin: var(--space-2) 0 0; font-size: 0.9rem; color: var(--ink-soft); }

.obit-chat {
    flex: 1 1 auto;
    min-height: 6rem;
    margin: var(--space-3) 0 0;
    padding-right: var(--space-1);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.obit-chat .chat-line { max-width: 100%; }
.obit-chat .chat-line.from-you { max-width: 92%; white-space: pre-line; }
.obit-chat .chat-text p { margin-bottom: var(--space-2); }
.obit-chat .chat-text p:last-child { margin-bottom: 0; }
.obit-chat .chat-line.is-failed .chat-text { color: var(--ink-soft); }

.obit-chats {
    display: grid;
    gap: var(--space-2);
    margin: var(--space-3) 0;
    padding: 0;
    overflow-y: auto;
    list-style: none;
}

.obit-chat-pick {
    display: grid;
    gap: 2px;
    width: 100%;
    min-height: var(--touch);
    padding: var(--space-3);
    font: inherit;
    text-align: left;
    color: var(--ink);
    background: var(--paper);
    border: 1px solid var(--rule);
    border-radius: var(--radius-small);
    cursor: pointer;
}

.obit-chat-pick:hover { background: var(--paper-sunk); }
.obit-chat-title { font-weight: 500; overflow-wrap: anywhere; }
.obit-chat-meta { font-size: 0.85rem; color: var(--ink-soft); }

/* The AI's revision: what it changes (or the whole text), and using it. */
.revision {
    padding: var(--space-3) var(--space-4);
    background: var(--paper);
    border: 1px solid var(--rule-strong);
    border-radius: var(--radius);
}

.revision.is-writing { border-style: dashed; }

.revision-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0 var(--space-3);
}

.revision-head .btn-link { font-size: 0.9rem; }

.revision-title {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
}

.revision-text, .text-changes {
    margin-top: var(--space-2);
    font-family: var(--font-serif);
    font-size: 1.05rem;
    line-height: 1.6;
}

.revision-text p, .text-changes p { margin: 0 0 var(--space-3); }

.diff-added {
    padding: 0 0.1em;
    color: var(--ink);
    text-decoration: none;
    background: color-mix(in srgb, var(--success) 24%, transparent);
    border-radius: 3px;
}

.diff-removed {
    margin-right: 0.15em;
    padding: 0 0.1em;
    color: var(--ink-soft);
    text-decoration: line-through;
    text-decoration-color: var(--danger);
    text-decoration-thickness: 1.5px;
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    border-radius: 3px;
}

/* A paragraph added or taken out whole: a line at its side says which. */
.text-changes .diff-new { padding-left: var(--space-3); border-left: 3px solid var(--success); }
.text-changes .diff-gone { padding-left: var(--space-3); border-left: 3px solid var(--danger); }

.diff-unchanged {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-style: italic;
    color: var(--ink-soft);
}

.revision-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-2) var(--space-3);
    margin-top: var(--space-1);
}

.revision-actions .hint { margin: 0; }
.revision-used { font-weight: 600; color: var(--success); }
.revision-was-used { margin: var(--space-1) 0 0; }

@media (max-width: 60rem) {
    .obit-editor-grid { grid-template-columns: minmax(0, 1fr); }
    .obit-panes { display: flex; flex-basis: 100%; justify-content: center; }
    .obit-editor.show-text .obit-help-pane { display: none; }
    .obit-editor.show-help .obit-draft { display: none; }
    .obit-help-pane { position: static; }
    .obit-help { max-height: calc(100dvh - 7rem); min-height: 24rem; padding: var(--space-3); }
}

/* ---------- Motion ---------- */

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- Small screens ---------- */

@media (max-width: 40rem) {
    body { font-size: 1.0625rem; }
    .site-header-inner { padding: var(--space-3) var(--space-4); }
    .site-main { padding: var(--space-5) var(--space-4) var(--space-7); }
    .plain-main { padding: 0 var(--space-4); }
    .welcome { padding: var(--space-7) 0; }
    .card { padding: var(--space-4); }
}
