/* ----------------------------------------------------------------------
 * RAMS Engine — brand stylesheet
 * Editorial / Swiss-influenced. Warm off-white, near-black, burnt-orange.
 * No utility framework. Hand-tuned tokens, predictable cascade.
 * -------------------------------------------------------------------- */

:root {
    /* Palette */
    --bg:           #FAF7F2;
    --bg-alt:       #F3EEE5;
    --surface:      #FFFFFF;

    --text:         #141413;
    --text-2:       #5C5A55;
    --text-muted:   #8B8882;

    --border:       #E8E2D5;
    --border-2:     #D4CDBE;

    --accent:       #CC5500;
    --accent-hover: #A84500;
    --accent-active:#8E3A00;

    --success:      #2E6F40;
    --error:        #9B2D1F;

    /* Type */
    --serif: "Fraunces", Georgia, "Times New Roman", serif;
    --sans:  "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

    /* Spacing (8px base) */
    --space-1: 8px;
    --space-2: 16px;
    --space-3: 24px;
    --space-4: 32px;
    --space-5: 48px;
    --space-6: 64px;
    --space-8: 80px;
    --space-12: 120px;

    /* Layout */
    --max-w: 1200px;
    --max-prose: 680px;
    --gutter: 24px;
    --page-pad: 48px;

    --radius: 6px;
}

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

html, body { margin: 0; padding: 0; }

html {
    background: var(--bg);
    color: var(--text);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

main { flex: 1; }

img, svg { max-width: 100%; height: auto; display: block; }

/* ---- Type ---- */

h1, h2, h3, h4 { margin: 0; font-weight: 400; }

.h1, h1 {
    font-family: var(--serif);
    font-size: 72px;
    line-height: 1.05;
    letter-spacing: -0.025em;
    font-weight: 400;
    font-optical-sizing: auto;
}

.h2, h2 {
    font-family: var(--serif);
    font-size: 48px;
    line-height: 1.1;
    letter-spacing: -0.02em;
    font-weight: 400;
}

.h3, h3 {
    font-family: var(--sans);
    font-size: 24px;
    line-height: 1.3;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.h4, h4 {
    font-family: var(--sans);
    font-size: 18px;
    line-height: 1.4;
    font-weight: 600;
}

p { margin: 0 0 1.25em; max-width: var(--max-prose); }

.lead { font-size: 20px; line-height: 1.6; color: var(--text-2); }

.eyebrow {
    font-size: 13px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 0 0 var(--space-3);
}

.caption { font-size: 13px; color: var(--text-muted); font-weight: 500; }

.muted { color: var(--text-muted); }
.text-2 { color: var(--text-2); }

a {
    color: var(--accent);
    text-decoration: underline;
    text-underline-offset: 3px;
    text-decoration-thickness: 1px;
    transition: text-decoration-thickness 0.15s ease;
}
a:hover { text-decoration-thickness: 2px; }
a.plain { color: inherit; text-decoration: none; }
a.plain:hover { text-decoration: none; }

@media (max-width: 720px) {
    html { font-size: 16px; }
    .h1, h1 { font-size: 44px; }
    .h2, h2 { font-size: 32px; }
    .h3, h3 { font-size: 20px; }
    .lead { font-size: 18px; }
    :root { --page-pad: 20px; --gutter: 16px; }
}

/* ---- Layout ---- */

.container {
    width: 100%;
    max-width: var(--max-w);
    margin: 0 auto;
    padding-left: var(--page-pad);
    padding-right: var(--page-pad);
}

.prose { max-width: var(--max-prose); }

.section { padding: var(--space-12) 0; }
.section--tight { padding: var(--space-6) 0; }
.section--alt { background: var(--bg-alt); }

.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

@media (max-width: 720px) {
    .section { padding: var(--space-8) 0; }
}

/* ---- Skip link ---- */

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    padding: 12px 16px;
    background: var(--text);
    color: var(--bg);
    text-decoration: none;
    z-index: 100;
}
.skip-link:focus { left: 16px; top: 16px; }

/* ---- Nav ---- */

.nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg);
    height: 72px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid transparent;
    transition: border-color 0.25s ease;
}
.nav.is-scrolled { border-bottom-color: var(--border); }
.nav__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}
.brand {
    display: inline-block;
    line-height: 0.85;
    text-decoration: none;
    color: var(--text);
    flex-shrink: 0;
}
.brand:hover { text-decoration: none; color: var(--text); }
.brand__top {
    display: block;
    font-family: var(--serif);
    font-size: 30px;
    font-weight: 500;
    letter-spacing: -0.025em;
    font-optical-sizing: auto;
}
.brand__sub {
    display: block;
    font-family: var(--serif);
    font-size: 17px;
    font-weight: 400;
    font-style: italic;
    letter-spacing: -0.005em;
    color: var(--text-2);
}
.nav__links {
    display: flex;
    align-items: center;
    gap: 32px;
    list-style: none;
    margin: 0;
    padding: 0;
}
.nav__link {
    color: var(--text-2);
    text-decoration: none;
    font-size: 15px;
}
.nav__link:hover { color: var(--text); text-decoration: none; }
.nav__link.is-active { color: var(--text); position: relative; }
.nav__link.is-active::after {
    content: "";
    width: 4px; height: 4px; border-radius: 50%;
    background: var(--accent);
    position: absolute;
    bottom: -10px; left: 50%; transform: translateX(-50%);
}

.nav__toggle {
    display: none;
    background: transparent;
    border: 0;
    padding: 8px;
    cursor: pointer;
    color: var(--text);
}

/* ---- App shell nav (authenticated, full-bleed) ---- */

.app-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    --app-nav-height: 80px;
    height: var(--app-nav-height);
    width: 100%;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 0 var(--page-pad);
    display: flex;
    align-items: center;
}
.app-nav__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    gap: 16px;
}
.app-nav__left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}
.app-nav__divider {
    width: 1px;
    height: 22px;
    background: var(--border-2);
    display: inline-block;
    flex-shrink: 0;
}
.app-nav__workspace {
    font-family: var(--serif);
    font-size: 17px;
    color: var(--text-2);
    text-decoration: none;
    letter-spacing: -0.005em;
    transition: color 0.15s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.app-nav__workspace:hover { color: var(--text); text-decoration: none; }
.app-nav__right {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-shrink: 0;
}
.app-nav__user {
    display: inline-flex;
    align-items: center;
    gap: 10px;
}
.app-nav__avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    text-transform: uppercase;
}
.app-nav__username {
    font-size: 14px;
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
}

@media (max-width: 900px) {
    .app-nav__divider, .app-nav__workspace { display: none; }
}
@media (max-width: 720px) {
    .app-nav { height: 64px; padding: 0 16px; }
    .brand__top { font-size: 24px; }
    .brand__sub { font-size: 14px; }
    .app-nav__username { display: none; }
}

@media (max-width: 720px) {
    .nav { height: 64px; }
    .nav__links { display: none; }
    .nav__toggle { display: inline-flex; }
    .nav__links.is-open {
        display: flex;
        position: fixed;
        inset: 64px 0 0 0;
        flex-direction: column;
        align-items: flex-start;
        gap: 24px;
        background: var(--bg);
        padding: 32px 20px;
        z-index: 50;
    }
    .nav__links.is-open .nav__link { font-size: 24px; }
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    font-family: var(--sans);
    font-size: 15px;
    font-weight: 500;
    line-height: 1;
    letter-spacing: 0;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
    min-height: 44px;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:hover { background: var(--accent-hover); color: #fff; }
.btn--primary:active { background: var(--accent-active); }

.btn--ghost { background: transparent; color: var(--text); border-color: var(--border-2); }
.btn--ghost:hover { border-color: var(--text); color: var(--text); }

.btn--small { padding: 10px 20px; font-size: 14px; min-height: 40px; }
.btn--block { display: flex; width: 100%; }
.btn--danger { background: transparent; color: var(--error); border-color: var(--border-2); }
.btn--danger:hover { border-color: var(--error); }

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

.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.field__label { font-size: 14px; font-weight: 500; color: var(--text); }
.field__hint { font-size: 13px; color: var(--text-muted); }
.field__error { font-size: 13px; color: var(--error); }

.input, .select, .textarea {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--border-2);
    padding: 10px 0;
    background: transparent;
    font-family: var(--sans);
    font-size: 16px;
    color: var(--text);
    border-radius: 0;
    transition: border-color 0.15s ease;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none;
    border-bottom: 2px solid var(--accent);
    padding-bottom: 9px;
}
.textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.select { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-2) 50%), linear-gradient(135deg, var(--text-2) 50%, transparent 50%); background-position: calc(100% - 16px) 18px, calc(100% - 11px) 18px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 28px; }

.input--boxed {
    border: 1px solid var(--border-2);
    padding: 12px 14px;
    border-radius: var(--radius);
}
.input--boxed:focus { border: 1px solid var(--accent); padding: 12px 14px; }

input[type="color"] {
    width: 60px; height: 40px; padding: 0;
    border: 1px solid var(--border-2); border-radius: var(--radius);
    cursor: pointer; background: transparent;
}

.checkbox { display: inline-flex; align-items: center; gap: 10px; font-size: 15px; cursor: pointer; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ---- Cards ---- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4);
}
.card--alt { background: var(--bg-alt); border-color: var(--border); }
.card__title { margin-bottom: 12px; }

.grid { display: grid; gap: var(--gutter); }
.grid--2 { grid-template-columns: repeat(2, 1fr); }
.grid--3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) {
    .grid--2, .grid--3 { grid-template-columns: 1fr; }
}

.stack > * + * { margin-top: var(--space-2); }
.stack-3 > * + * { margin-top: var(--space-3); }
.stack-4 > * + * { margin-top: var(--space-4); }
.stack-5 > * + * { margin-top: var(--space-5); }

.row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.row--end { justify-content: flex-end; }
.row--between { justify-content: space-between; }

/* ---- Footer ---- */

.footer {
    background: var(--bg-alt);
    border-top: 1px solid var(--border);
    padding: var(--space-8) 0 var(--space-5);
    margin-top: var(--space-12);
}
.footer__cols { display: grid; grid-template-columns: repeat(4, 1fr); gap: var(--gutter); }
.footer__heading { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 16px; }
.footer__list { list-style: none; padding: 0; margin: 0; }
.footer__list li + li { margin-top: 8px; }
.footer__link { font-size: 14px; color: var(--text-2); text-decoration: none; }
.footer__link:hover { color: var(--text); text-decoration: none; }
.footer__bottom { border-top: 1px solid var(--border); margin-top: 32px; padding-top: 32px; font-size: 13px; color: var(--text-muted); }

@media (max-width: 720px) {
    .footer__cols { grid-template-columns: 1fr; gap: 32px; }
    .footer { margin-top: var(--space-8); }
}

/* ---- Hero ---- */

.hero { padding: var(--space-12) 0 var(--space-8); }
.hero__headline { max-width: 880px; }
.hero__lead { margin-top: var(--space-3); max-width: 560px; }
.hero__cta { margin-top: var(--space-5); display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }

/* ---- App shell (authenticated) ---- */

.app {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: calc(100vh - 80px);
}
.app__sidebar {
    border-right: 1px solid var(--border);
    padding: var(--space-4) var(--space-3);
    background: var(--bg);
}
.app__main { padding: var(--space-5) var(--space-5); }
.app__title { display: flex; justify-content: space-between; align-items: flex-end; gap: 24px; margin-bottom: var(--space-5); flex-wrap: wrap; }

.side-nav { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; }
.side-nav__link {
    display: flex; align-items: center;
    padding: 10px 12px; border-radius: var(--radius);
    color: var(--text-2); text-decoration: none; font-size: 15px;
}
.side-nav__link:hover { background: var(--bg-alt); color: var(--text); text-decoration: none; }
.side-nav__link.is-active { background: var(--bg-alt); color: var(--text); font-weight: 500; }
.side-nav__group { margin-top: var(--space-3); padding-top: var(--space-3); border-top: 1px solid var(--border); }

@media (max-width: 900px) {
    .app { grid-template-columns: 1fr; }
    .app__sidebar { border-right: 0; border-bottom: 1px solid var(--border); padding: var(--space-2) var(--page-pad); }
    .side-nav { flex-direction: row; flex-wrap: wrap; gap: 4px; }
    .side-nav__group { margin-top: 0; padding-top: 0; border: 0; }
    .app__main { padding: var(--space-4) var(--page-pad); }
}

/* ---- Tables ---- */

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
    text-align: left; padding: 16px 12px;
    border-bottom: 1px solid var(--border);
    font-size: 15px; vertical-align: top;
}
.table th { font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }
.table tr:hover td { background: var(--bg-alt); }
.table a { color: var(--text); text-decoration: none; font-weight: 500; }
.table a:hover { color: var(--accent); text-decoration: none; }

/* ---- Status pills ---- */

.pill {
    display: inline-flex; align-items: center;
    padding: 4px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 500; letter-spacing: 0.02em;
    background: var(--bg-alt); color: var(--text-2);
    border: 1px solid var(--border);
}
.pill--draft { background: var(--bg-alt); color: var(--text-2); }
.pill--completed { background: rgba(46, 111, 64, 0.08); color: var(--success); border-color: rgba(46, 111, 64, 0.2); }

/* ---- Alerts / flash ---- */

.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg-alt);
    font-size: 14px;
    margin-bottom: var(--space-3);
}
.alert--success { background: rgba(46, 111, 64, 0.06); color: var(--success); border-color: rgba(46, 111, 64, 0.2); }
.alert--error { background: rgba(155, 45, 31, 0.06); color: var(--error); border-color: rgba(155, 45, 31, 0.2); }

/* ---- Auth shell ---- */

.auth {
    min-height: calc(100vh - 72px);
    display: grid;
    place-items: center;
    padding: var(--space-6) var(--page-pad);
}
.auth__card {
    width: 100%;
    max-width: 420px;
}
.auth__head { margin-bottom: var(--space-4); }
.auth__head h1 { font-size: 36px; line-height: 1.15; }
.auth__foot { margin-top: var(--space-4); font-size: 14px; color: var(--text-2); }

/* ---- Branded RAMS view ---- */

.brand-doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-5); }
.brand-doc__head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-3); padding-bottom: var(--space-3); border-bottom: 2px solid var(--brand-primary, var(--text)); margin-bottom: var(--space-4); }
.brand-doc__logo img { max-height: 64px; }
.brand-doc__meta { text-align: right; font-size: 13px; color: var(--text-2); }

/* ---- FRA editor (long form with sticky sidebar) ---- */

.fra {
    display: grid;
    grid-template-columns: 220px 1fr;
    gap: var(--space-5);
    align-items: start;
}
.fra__toc {
    position: sticky;
    top: 96px;
    align-self: start;
    max-height: calc(100vh - 108px);
    overflow-y: auto;
    border-right: 1px solid var(--border);
    padding-right: var(--space-3);
}
.fra__toc h4 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin: var(--space-3) 0 8px; font-weight: 600; }
.fra__toc h4:first-child { margin-top: 0; }
.fra__toc ol { list-style: none; padding: 0; margin: 0; counter-reset: toc; }
.fra__toc ol li { counter-increment: toc; }
.fra__toc a { display: block; padding: 6px 4px; font-size: 14px; color: var(--text-2); text-decoration: none; border-left: 2px solid transparent; padding-left: 10px; }
.fra__toc a:hover { color: var(--text); text-decoration: none; border-left-color: var(--border-2); }
.fra__toc a.is-active { color: var(--text); border-left-color: var(--accent); font-weight: 500; }

.fra__main { min-width: 0; }

.fra__section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-4);
    margin-bottom: var(--space-4);
    scroll-margin-top: 96px;
}
.fra__section h2 { font-size: 28px; line-height: 1.15; margin-bottom: 8px; }
.fra__section .lead { font-size: 16px; margin-bottom: var(--space-3); }

.fra__qrow {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 16px;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border);
}
.fra__qrow:last-child { border-bottom: 0; }
.fra__qref { font-family: var(--serif); font-size: 22px; color: var(--text-muted); padding-top: 4px; }
.fra__q { font-weight: 500; line-height: 1.5; margin-bottom: 12px; }
.fra__suggested { font-size: 12px; color: var(--text-muted); margin-top: -4px; margin-bottom: 8px; font-style: italic; }

.answer-row {
    display: inline-flex;
    border: 1px solid var(--border-2);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 12px;
}
.answer-row label {
    padding: 8px 18px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-right: 1px solid var(--border-2);
    background: transparent;
    color: var(--text-2);
    transition: background 0.12s ease, color 0.12s ease;
}
.answer-row label:last-child { border-right: 0; }
.answer-row input { display: none; }
.answer-row input:checked + span { background: var(--text); color: var(--bg); }
.answer-row label:has(input:checked) { background: var(--text); color: var(--bg); }
.answer-row label:hover:not(:has(input:checked)) { background: var(--bg-alt); }

/* Action-plan repeater */
.action-row {
    display: grid;
    grid-template-columns: 1fr 160px 160px auto;
    gap: 12px;
    align-items: start;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}
.action-row:last-of-type { border-bottom: 0; }
.action-row textarea { min-height: 60px; }
.action-row .field { margin-bottom: 0; }

@media (max-width: 720px) {
    .action-row { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .fra { grid-template-columns: 1fr; }
    .fra__toc { position: static; max-height: none; border-right: 0; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: var(--space-3); margin-bottom: var(--space-3); }
    .fra__toc ol { display: flex; flex-wrap: wrap; gap: 8px; }
    .fra__toc a { border: 1px solid var(--border); border-radius: var(--radius); padding: 6px 10px; }
    .fra__toc a.is-active { border-color: var(--accent); color: var(--text); }
}

/* ---- Photo gallery (AJAX) ---- */

.uploader {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border: 1px dashed var(--border-2);
    border-radius: var(--radius);
    background: transparent;
    margin-bottom: var(--space-3);
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease;
}
.uploader:hover { border-color: var(--text); background: var(--bg-alt); }
.uploader__icon {
    width: 36px; height: 36px;
    border-radius: var(--radius);
    background: var(--bg-alt);
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--text-2);
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
}
.uploader:hover .uploader__icon { background: var(--bg); color: var(--text); }
.uploader__icon svg { width: 18px; height: 18px; }
.uploader__copy { flex: 1; min-width: 0; }
.uploader__title { display: block; font-size: 14px; font-weight: 500; color: var(--text); line-height: 1.3; }
.uploader__hint { display: block; font-size: 12px; color: var(--text-muted); margin-top: 2px; line-height: 1.3; }
.uploader__count {
    font-size: 12px; color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}
.uploader input[type="file"] { display: none; }
.uploader.is-disabled {
    opacity: 0.55;
    cursor: not-allowed;
    pointer-events: none;
}

/* Section-wide drop target gets a subtle ring when a file is being dragged over it */
.photos-zone.is-dragover { background: var(--bg-alt); border-radius: var(--radius); }
.photos-zone.is-dragover .uploader {
    border-color: var(--accent);
    border-style: solid;
    background: var(--surface);
}
.photos-zone.is-dragover .uploader__icon { background: var(--accent); color: white; }

.photo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 16px;
}

.photo-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    position: relative;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.photo-card.is-uploading { opacity: 0.6; }
.photo-card.is-removing { opacity: 0; transform: scale(0.95); pointer-events: none; }
.photo-card.is-error { border-color: var(--error); }

.photo-card__image {
    position: relative;
    background: var(--bg-alt);
    cursor: zoom-in;
    aspect-ratio: 4 / 3;
    overflow: hidden;
}
.photo-card__image img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-card__image.is-loading::after {
    content: ""; position: absolute; inset: 0;
    background: repeating-linear-gradient(45deg, var(--bg) 0 12px, var(--bg-alt) 12px 24px);
    background-size: 40px 40px;
    animation: shimmer 1.4s linear infinite;
}
@keyframes shimmer { from { background-position: 0 0; } to { background-position: 40px 40px; } }

.photo-card__remove {
    position: absolute;
    top: 8px; right: 8px;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: rgba(20, 20, 19, 0.6);
    color: white;
    border: 0;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
    backdrop-filter: blur(4px);
}
.photo-card:hover .photo-card__remove,
.photo-card__remove:focus-visible { opacity: 1; }
.photo-card__remove:hover { background: var(--error); }
.photo-card__remove svg { width: 14px; height: 14px; }
.photo-card__remove.is-confirming { opacity: 1; width: auto; padding: 0 12px; border-radius: 14px; font-size: 12px; font-weight: 500; background: var(--error); }

.photo-card__body { padding: 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.photo-card__body input,
.photo-card__body textarea {
    border: 1px solid transparent;
    border-bottom: 1px solid var(--border-2);
    background: transparent;
    padding: 4px 6px;
    font-size: 13px;
    border-radius: 4px;
    transition: border-color 0.15s ease, background 0.15s ease;
    width: 100%;
    font-family: var(--sans);
    color: var(--text);
}
.photo-card__body input { font-weight: 500; }
.photo-card__body textarea { resize: vertical; min-height: 44px; line-height: 1.5; color: var(--text-2); }
.photo-card__body input:hover,
.photo-card__body textarea:hover { background: var(--bg-alt); }
.photo-card__body input:focus,
.photo-card__body textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--surface);
}
.photo-card__status {
    font-size: 11px;
    color: var(--text-muted);
    height: 14px;
    display: flex;
    align-items: center;
    gap: 4px;
}
.photo-card__status.is-saving { color: var(--text-muted); }
.photo-card__status.is-saved { color: var(--success); }
.photo-card__status.is-error { color: var(--error); }
.photo-card__progress {
    position: absolute;
    left: 0; bottom: 0; height: 3px;
    background: var(--accent);
    width: 0;
    transition: width 0.2s ease;
}

/* ---- Shared page chrome ---- */
.page-head { max-width: 800px; margin-bottom: var(--space-5); }
.page-head h1 { margin-bottom: 0; }
.page-head .lead { margin-top: var(--space-3); }

.cta-card {
    background: var(--bg-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--space-5);
    max-width: 760px;
    margin: 0 auto;
}
.cta-card .eyebrow { margin-bottom: var(--space-2); }
.cta-card .h2 { margin-bottom: 0; }
.cta-card .hero__cta { margin-top: var(--space-4); }
@media (max-width: 720px) {
    .cta-card { padding: var(--space-4); }
}

.hide-on-mobile { display: inline; }
@media (max-width: 720px) {
    .hide-on-mobile { display: none; }
}

/* ---- Global toast ---- */
.toast {
    position: fixed;
    bottom: 24px; left: 50%;
    transform: translateX(-50%) translateY(8px);
    background: var(--text);
    color: var(--bg);
    padding: 12px 20px 12px 16px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 200;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    max-width: calc(100vw - 48px);
}
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--success { background: var(--success); color: white; }
.toast--error   { background: var(--error);   color: white; }
.toast__icon { width: 18px; height: 18px; flex-shrink: 0; }
.toast__icon svg { width: 100%; height: 100%; }

/* PDF preview modal */
.pdf-modal {
    position: fixed;
    inset: 0;
    background: rgba(20, 20, 19, 0.78);
    z-index: 400;
    display: none;
    align-items: stretch;
    justify-content: center;
    padding: 24px;
}
.pdf-modal.is-open { display: flex; }
.pdf-modal__panel {
    background: var(--surface);
    border-radius: var(--radius);
    width: 100%;
    max-width: 1200px;
    margin: auto;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 14px 60px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}
.pdf-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
.pdf-modal__title {
    font-family: var(--serif);
    font-size: 18px;
    color: var(--text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.pdf-modal__title small {
    color: var(--text-muted);
    font-size: 13px;
    font-family: var(--sans);
    margin-left: 8px;
}
.pdf-modal__actions { display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0; }
.pdf-modal__body {
    flex: 1;
    position: relative;
    background: var(--bg-alt);
    overflow: hidden;
}
.pdf-modal__iframe { width: 100%; height: 100%; border: 0; display: block; }
.pdf-modal__loading {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    font-size: 14px;
    gap: 10px;
}
.pdf-modal__loading svg {
    width: 18px; height: 18px;
    animation: pdf-spin 0.9s linear infinite;
}
@keyframes pdf-spin { from { transform: rotate(0); } to { transform: rotate(360deg); } }

@media (max-width: 720px) {
    .pdf-modal { padding: 0; }
    .pdf-modal__panel { border-radius: 0; height: 100vh; max-width: none; }
    .pdf-modal__title small { display: none; }
}

/* Lightbox */
.lightbox {
    position: fixed; inset: 0;
    background: rgba(20, 20, 19, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
    padding: 40px 24px;
}
.lightbox.is-open { opacity: 1; pointer-events: auto; }
.lightbox__img {
    max-width: 100%;
    max-height: 80vh;
    object-fit: contain;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    border-radius: 4px;
}
.lightbox__caption {
    color: rgba(250, 247, 242, 0.85);
    font-size: 14px;
    margin-top: 16px;
    text-align: center;
    max-width: 60ch;
}
.lightbox__close {
    position: absolute;
    top: 20px; right: 20px;
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 0;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.lightbox__close:hover { background: rgba(255, 255, 255, 0.2); }
.lightbox__close svg { width: 20px; height: 20px; }
.lightbox__nav {
    position: absolute;
    top: 50%; transform: translateY(-50%);
    width: 48px; height: 48px;
    background: rgba(255, 255, 255, 0.08);
    border: 0;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.lightbox__nav:hover { background: rgba(255, 255, 255, 0.18); }
.lightbox__nav--prev { left: 24px; }
.lightbox__nav--next { right: 24px; }
.lightbox__nav svg { width: 24px; height: 24px; }
.lightbox__counter {
    position: absolute;
    top: 28px; left: 24px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
}

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

/* ---- Print ---- */
@media print {
    .nav, .footer, .app__sidebar, .no-print { display: none !important; }
    body { background: white; }
    .app { grid-template-columns: 1fr; }
    .app__main { padding: 0; }
}
