/* ========== STUDIO — CLIENT GALLERIES ========== */
/* Shared by index.html (homepage), gallery.html, invoice.html, 404.html.     */
/* Tokens mirror styles/main.css (the studio project can't reach ../styles).  */

/* ========== DESIGN TOKENS ========== */
:root {
    --background-dark: #0a0a0b;
    --background-elevated: #12121a;
    --background-deep: #050506;

    --surface-01: rgba(255, 255, 255, 0.04);
    --surface-02: rgba(255, 255, 255, 0.08);
    --surface-03: rgba(255, 255, 255, 0.12);

    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-default: rgba(255, 255, 255, 0.14);
    --border-strong: rgba(255, 255, 255, 0.24);

    --text-primary: #ffffff;
    --text-secondary: #b8b8ba;
    --text-tertiary: #8e8e93;   /* brighter than the portfolio's #6e6e73 so small caps labels pass 4.5:1 */
    --text-disabled: #48484d;

    --error: rgba(255, 59, 48, 1);
    --error-surface: rgba(255, 59, 48, 0.12);
    --error-border: rgba(255, 59, 48, 0.4);

    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;
    --space-20: 80px;

    --radius-button: 8px;
    --radius-pill: 20px;

    --font-size-xs: 10px;
    --font-size-sm: 12px;
    --font-size-caps: 12px;       /* small all-caps labels (eyebrows, links, meta) */
    --font-size-caps-lg: 13px;    /* all-caps UI text: tabs, pills, dates, buttons */
    --font-size-base: 14px;
    --font-size-md: 16px;
    --font-size-lg: 18px;
    --font-size-xl: 20px;
    --font-size-2xl: 24px;

    --letter-spacing-tight: -0.02em;
    --letter-spacing-wide: 0.025em;
    --letter-spacing-wider: 0.05em;
    --letter-spacing-widest: 0.1em;

    --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
    --font-display: 'Inter Tight', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    --ease: cubic-bezier(0.4, 0, 0.2, 1);
    --duration: 0.2s;
    --duration-slow: 0.6s;

    --nav-height: 64px;
    --touch: 44px;
    --gutter: clamp(16px, 3vw, 40px);
    --gap: 8px;
}

/* ========== BASE ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
    background: var(--background-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: var(--font-size-base);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
}

body.is-locked { overflow: hidden; }

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

[hidden] { display: none !important; }   /* components set display (e.g. .btn), which would otherwise beat the attribute */

a { color: inherit; text-decoration: none; }

button, input, textarea, select { font: inherit; color: inherit; }

button { background: none; border: 0; cursor: pointer; }

:focus-visible { outline: 1px solid var(--text-primary); outline-offset: 3px; }

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

.mono {
    font-family: var(--font-mono);
    font-size: var(--font-size-caps-lg);
    letter-spacing: var(--letter-spacing-wider);
    text-transform: uppercase;
}

.eyebrow {
    font-family: var(--font-mono);
    font-size: var(--font-size-caps);
    letter-spacing: var(--letter-spacing-widest);
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.svg-icon { width: 18px; height: 18px; flex: none; }

/* ========== BUTTONS & FIELDS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-height: var(--touch);
    padding: 0 var(--space-5);
    border: 1px solid var(--border-default);
    border-radius: 0;
    font-family: var(--font-mono);
    font-size: var(--font-size-caps-lg);
    letter-spacing: var(--letter-spacing-wider);
    text-transform: uppercase;
    color: var(--text-primary);
    background: transparent;
    transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease), color var(--duration) var(--ease), opacity var(--duration) var(--ease);
    white-space: nowrap;
}

.btn:hover { border-color: var(--border-strong); background: var(--surface-01); }

.btn--solid { background: var(--text-primary); color: var(--background-dark); border-color: var(--text-primary); }
.btn--solid:hover { background: var(--text-secondary); border-color: var(--text-secondary); }

.btn--ghost { border-color: transparent; }
.btn--ghost:hover { border-color: var(--border-subtle); }

.btn--block { width: 100%; }

.btn[disabled], .btn.is-busy { opacity: 0.45; pointer-events: none; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    min-width: var(--touch);
    height: var(--touch);
    padding: 0 var(--space-3);
    color: var(--text-secondary);
    font-family: var(--font-mono);
    font-size: var(--font-size-caps);
    letter-spacing: var(--letter-spacing-widest);
    text-transform: uppercase;
    transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.icon-btn:hover { color: var(--text-primary); }
.icon-btn.is-active { color: var(--text-primary); }
.icon-btn .count { color: var(--text-tertiary); }

.field { display: flex; flex-direction: column; gap: var(--space-2); }

.field label {
    font-family: var(--font-mono);
    font-size: var(--font-size-caps);
    letter-spacing: var(--letter-spacing-widest);
    text-transform: uppercase;
    color: var(--text-tertiary);
}

.input {
    width: 100%;
    min-height: var(--touch);
    padding: 0 var(--space-4);
    background: var(--surface-01);
    border: 1px solid var(--border-default);
    border-radius: 0;
    font-family: var(--font-mono);
    font-size: var(--font-size-md); /* 16px stops iOS zoom */
    color: var(--text-primary);
    transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}

textarea.input { padding: var(--space-3) var(--space-4); min-height: 96px; resize: vertical; line-height: 1.5; }

.input::placeholder { color: var(--text-disabled); }
.input:focus { outline: none; border-color: var(--border-strong); background: var(--surface-02); }
.input.is-invalid { border-color: var(--error-border); }

.pin-input { letter-spacing: 0.6em; text-align: center; font-size: var(--font-size-2xl); }

.form-error {
    min-height: 18px;
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    color: var(--error);
}

.choice {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-height: 56px;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    transition: border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.choice + .choice { margin-top: -1px; }
.choice:hover { background: var(--surface-01); }
.choice:has(input:checked) { border-color: var(--border-strong); background: var(--surface-01); position: relative; }
.choice input { accent-color: #fff; width: 16px; height: 16px; flex: none; }
.choice__text { display: flex; flex-direction: column; gap: 2px; }
.choice__title { font-size: var(--font-size-base); color: var(--text-primary); }
.choice__meta { font-family: var(--font-mono); font-size: var(--font-size-caps); letter-spacing: var(--letter-spacing-wider); color: var(--text-tertiary); text-transform: uppercase; }

/* ========== BRAND HEADER (homepage, invoice, 404) ========== */
.site-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-6) var(--gutter);
    border-bottom: 1px solid var(--border-subtle);
}

.wordmark {
    display: inline-flex;
    align-items: center;
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--font-size-md);
    letter-spacing: 0.32em;
    text-transform: uppercase;
    white-space: nowrap;
}

.wordmark__logo { display: block; height: 16px; width: auto; }

/* header-bar pages (homepage, invoice, 404) sit the logo closer to the small mono links */
.site-header .wordmark__logo { height: 12px; }

/* 44px tap target around the logo without moving it */
.wordmark { padding: 14px 0; margin: -14px 0; }

@media (max-width: 760px) {
    .wordmark__logo { height: 13px; }
    .wordmark { padding: 16px 0; margin: -16px 0; }
}

.site-links { display: flex; align-items: center; gap: var(--space-1); }

.site-links a {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--touch);
    padding: 0 var(--space-3);
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    font-size: var(--font-size-caps);
    letter-spacing: var(--letter-spacing-wider);
    text-transform: uppercase;
    transition: color var(--duration) var(--ease);
}

.site-links a:hover { color: var(--text-primary); }

/* icon-only social links: a full 44px square each (the invoice page's text email link is excluded) */
.site-links:not([aria-label="Contact"]) a { justify-content: center; width: var(--touch); padding: 0; }

.site-footer a { display: inline-flex; align-items: center; min-height: var(--touch); }

.site-footer {
    padding: var(--space-12) var(--gutter) var(--space-10);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    color: var(--text-disabled);
}

/* ========== HOMEPAGE ========== */
.home-intro {
    padding: var(--space-16) var(--gutter) var(--space-8);
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.home-intro h1 {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(32px, 6vw, 72px);
    letter-spacing: var(--letter-spacing-tight);
    line-height: 1;
}

.tag-pills {
    display: flex;
    gap: var(--space-2);
    padding: 0 var(--gutter) var(--space-8);
    overflow-x: auto;
    scrollbar-width: none;
}

.tag-pills::-webkit-scrollbar { display: none; }

.pill {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    padding: 0 var(--space-4);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-pill);
    font-family: var(--font-sans);
    font-size: var(--font-size-caps-lg);
    font-weight: 500;
    letter-spacing: var(--letter-spacing-wider);
    text-transform: uppercase;
    color: var(--text-tertiary);
    white-space: nowrap;
    transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.pill:hover { color: var(--text-primary); border-color: var(--border-default); }

.pill.is-active { color: var(--background-dark); background: var(--text-primary); border-color: var(--text-primary); }

@media (pointer: coarse) {
    .pill { min-height: var(--touch); }
}

.collection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: var(--space-12) var(--space-6);
    padding: 0 var(--gutter);
}

.collection-card { display: flex; flex-direction: column; gap: var(--space-4); }

.collection-card__media {
    position: relative;
    aspect-ratio: 3 / 2;
    overflow: hidden;
    background: var(--surface-01);
}

.collection-card__media img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--duration-slow) var(--ease), opacity var(--duration-slow) var(--ease);
    opacity: 0;
}

.collection-card__media img.is-loaded { opacity: 1; }

.collection-card:hover .collection-card__media img { transform: scale(1.025); }

.collection-card__title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: var(--font-size-xl);
    letter-spacing: -0.01em;
    line-height: 1.2;
}

.collection-card__meta { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); }

.empty-state {
    padding: var(--space-20) var(--gutter);
    text-align: center;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    letter-spacing: var(--letter-spacing-wider);
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-16) var(--gutter) 0;
}

.pagination a, .pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: var(--touch);
    height: var(--touch);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    color: var(--text-tertiary);
    border: 1px solid transparent;
    transition: color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.pagination a:hover { color: var(--text-primary); border-color: var(--border-subtle); }
.pagination .is-current { color: var(--text-primary); border-color: var(--border-default); }

.skeleton { background: linear-gradient(90deg, var(--surface-01), var(--surface-02), var(--surface-01)); background-size: 200% 100%; animation: shimmer 1.6s linear infinite; }

.skeleton--line { height: 22px; width: 60%; }

@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ========== GALLERY: COVER ========== */
.cover {
    position: relative;
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    overflow: hidden;
    background: var(--background-deep);
}

.cover__media {
    position: absolute;
    inset: 0;
}

.cover__media img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transform: scale(1.04);
    transition: opacity 1.2s var(--ease), transform 2.4s var(--ease);
}

.cover__media img.is-loaded { opacity: 1; transform: scale(1); }

/* the 2400px layer fades in over the (already visible) thumb; no second zoom-in */
.cover__media .cover__full { transition: opacity 0.8s var(--ease); }
.cover__lqip.is-loaded + .cover__full { transform: scale(1); }

.cover__media::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(10, 10, 11, 0.55) 0%, rgba(10, 10, 11, 0) 28%, rgba(10, 10, 11, 0) 50%, rgba(10, 10, 11, 0.85) 100%);
    pointer-events: none;
}

.cover__top {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-6) var(--gutter);
}

/* labels drawn over the photo can't rely on gray-on-dark contrast */
.cover__top .eyebrow { color: var(--text-secondary); text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }

.cover__body {
    position: relative;
    z-index: 2;
    align-self: flex-end;
    width: 100%;
    padding: var(--space-20) var(--gutter) var(--space-12);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: var(--space-8);
}

.cover__title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(36px, 7vw, 96px);
    line-height: 0.98;
    letter-spacing: -0.03em;
    max-width: 14ch;
    text-wrap: balance;
}

.cover__meta { display: flex; gap: var(--space-4); margin-top: var(--space-5); color: var(--text-secondary); flex-wrap: wrap; }

.cover__meta .dot { color: var(--text-disabled); }

.cover__cta { justify-self: end; }

.cover__cta .btn { backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); background: rgba(10, 10, 11, 0.28); border-color: rgba(255, 255, 255, 0.32); }
.cover__cta .btn:hover { background: rgba(10, 10, 11, 0.5); border-color: rgba(255, 255, 255, 0.6); }

.cover__scroll {
    position: absolute;
    left: 50%;
    bottom: var(--space-6);
    z-index: 2;
    width: 1px;
    height: 40px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.6));
    transform: translateX(-50%);
    animation: scroll-cue 2.4s var(--ease) infinite;
}

@keyframes scroll-cue {
    0% { transform: translateX(-50%) scaleY(0); transform-origin: top; }
    45% { transform: translateX(-50%) scaleY(1); transform-origin: top; }
    55% { transform: translateX(-50%) scaleY(1); transform-origin: bottom; }
    100% { transform: translateX(-50%) scaleY(0); transform-origin: bottom; }
}

/* split layout: text column + image column */
.cover--split { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
.cover--split .cover__media { position: relative; grid-column: 2; grid-row: 1; }
.cover--split .cover__media::after { background: none; }
.cover--split .cover__body {
    grid-column: 1;
    grid-row: 1;
    align-self: stretch;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    align-items: flex-start;
    gap: var(--space-10);
    padding-top: calc(var(--space-20) + var(--space-8));
    border-right: 1px solid var(--border-subtle);
}
.cover--split .cover__cta { justify-self: auto; }
.cover--split .cover__top { right: auto; width: calc(100% * 5 / 12); }
.cover--split .cover__scroll { display: none; }

/* minimal layout: typographic header only */
.cover--minimal { min-height: 0; display: block; background: var(--background-dark); border-bottom: 1px solid var(--border-subtle); }
.cover--minimal .cover__media { display: none; }
.cover--minimal .cover__top { position: relative; }
.cover--minimal .cover__body { padding: var(--space-16) var(--gutter) var(--space-12); grid-template-columns: 1fr; text-align: center; justify-items: center; }
.cover--minimal .cover__title { max-width: 20ch; font-size: clamp(32px, 5.5vw, 72px); }
.cover--minimal .cover__meta { justify-content: center; }
.cover--minimal .cover__cta { display: none; }
.cover--minimal .cover__scroll { display: none; }

/* orbit layout: the home page's rotating photo wheel around the title (gallery.js → ORBIT COVER).
   The photos are copies in .orbit, a layer over the whole page: above the grid and the nav (so they
   fly over it), under the cover's text and the overlays. */
.cover--orbit { height: 100vh; height: 100svh; min-height: 0; align-items: center; justify-content: center; background: var(--background-dark); }
.orbit__grid { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cover--orbit .cover__top,
.cover--orbit .cover__scroll { z-index: 70; }
.orbit__center {
    position: relative;
    z-index: 70;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-8);
    max-width: min(640px, 100%);
    padding: 0 var(--gutter);
    text-align: center;
    pointer-events: none;
    animation: orbit-title-in 0.8s linear both;
}
.orbit__center .cover__title { font-size: clamp(32px, 4.4vw, 64px); }
.orbit__center .cover__meta { justify-content: center; }
.orbit__center .btn { pointer-events: auto; }
@keyframes orbit-title-in { from { opacity: 0; } }

body.has-orbit #app { position: relative; }
.orbit { position: absolute; inset: 0; z-index: 60; overflow: hidden; overflow: clip; pointer-events: none; }
.orbit__photo { position: absolute; top: 0; left: 0; opacity: 0; }
.orbit.is-interactive .orbit__photo { pointer-events: auto; cursor: zoom-in; }
.orbit__frame { display: block; width: 100%; height: 100%; transition: transform 0.15s var(--ease), box-shadow 0.2s var(--ease); }
.orbit__frame img { width: 100%; height: 100%; object-fit: cover; opacity: 0; transition: opacity var(--duration-slow) var(--ease); user-select: none; -webkit-user-drag: none; -webkit-touch-callout: none; }
.orbit__frame img.is-loaded { opacity: 1; }
@media (hover: hover) and (pointer: fine) {
    .orbit.is-interactive .orbit__photo:hover { z-index: 1; }
    .orbit.is-interactive .orbit__photo:hover .orbit__frame { transform: scale(1.05); box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 0 24px rgba(255, 255, 255, 0.18); }
}
/* a photo's tile stays an empty slot until its copy lands */
body.orbit-flying .tile[data-orbit] > * { visibility: hidden; }

@media (max-width: 760px) {
    .cover__body { grid-template-columns: 1fr; padding-bottom: var(--space-16); }
    .cover__cta { justify-self: start; }
    .cover--split { grid-template-columns: 1fr; grid-template-rows: 62svh auto; min-height: 0; }
    .cover--split .cover__media { grid-column: 1; grid-row: 1; }
    .cover--split .cover__body { grid-column: 1; grid-row: 2; border-right: 0; padding-top: var(--space-10); gap: var(--space-8); }
    .cover--split .cover__top { width: 100%; }
}

/* ========== GALLERY: NAV ========== */
.gallery-nav {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(10, 10, 11, 0.86);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-subtle);
}

.gallery-nav__inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: var(--space-4);
    min-height: var(--nav-height);
    padding: 0 max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
}

.gallery-nav__id { display: flex; align-items: baseline; gap: var(--space-4); min-width: 0; }

.gallery-nav__title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--font-size-md);
    letter-spacing: -0.01em;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.gallery-nav__brand { white-space: nowrap; padding: 15px 0; margin: -15px 0; }

.set-tabs {
    display: flex;
    gap: var(--space-1);
    overflow-x: auto;
    scrollbar-width: none;
    min-width: 0;
}

.set-tabs::-webkit-scrollbar { display: none; }

.set-tab {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    height: var(--touch);
    padding: 0 var(--space-3);
    font-family: var(--font-mono);
    font-size: var(--font-size-caps-lg);
    letter-spacing: var(--letter-spacing-wider);
    text-transform: uppercase;
    color: var(--text-tertiary);
    white-space: nowrap;
    transition: color var(--duration) var(--ease);
}

.set-tab::after {
    content: '';
    position: absolute;
    left: var(--space-3);
    right: var(--space-3);
    bottom: 6px;
    height: 1px;
    background: var(--text-primary);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform var(--duration) var(--ease);
}

.set-tab:hover { color: var(--text-secondary); }
.set-tab.is-active { color: var(--text-primary); }
.set-tab.is-active::after { transform: scaleX(1); }

.gallery-nav__row2 { display: flex; align-items: center; gap: var(--space-4); padding: 0 calc(var(--gutter) - var(--space-3)); border-top: 1px solid var(--border-subtle); }

.gallery-actions { display: flex; align-items: center; gap: 0; }

.gallery-actions .icon-btn .label { display: none; }

@media (min-width: 1000px) {
    .gallery-actions .icon-btn .label { display: inline; }
}

@media (max-width: 640px) {
    .gallery-nav__brand { display: none; }
    .gallery-actions .icon-btn { padding: 0 var(--space-2); }
}

/* Phones: the title/actions row slides up while scrolling down; set tabs stay pinned */
@media (max-width: 760px) {
    .gallery-nav { --nav-height: 56px; transition: transform 0.25s var(--ease); }
    .gallery-nav.is-compact { transform: translateY(calc(-1 * var(--nav-collapse, 56px))); }
}

.favorites-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
    padding: var(--space-4) var(--gutter);
    border-bottom: 1px solid var(--border-subtle);
    background: var(--background-dark);
}

.favorites-bar__text { display: flex; flex-direction: column; gap: 2px; }

/* ========== GALLERY: GRID ========== */
.gallery-main { padding: var(--gap) var(--gutter) var(--space-20); min-height: 60vh; }

.gallery-main.spacing-large { --gap: 20px; }

@media (max-width: 640px) {
    .gallery-main { --gap: 4px; padding-left: var(--gap); padding-right: var(--gap); }
    .gallery-main.spacing-large { --gap: 12px; padding-left: var(--gap); padding-right: var(--gap); }
}

.grid { display: flex; gap: var(--gap); align-items: flex-start; }

.grid__col { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: var(--gap); }

.grid--rows { flex-direction: column; align-items: stretch; }

.grid__row { display: flex; gap: var(--gap); }

.tile {
    position: relative;
    display: block;
    width: 100%;
    overflow: hidden;
    background: var(--surface-01);
    cursor: zoom-in;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.grid__row .tile { flex: none; width: auto; }

.tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity var(--duration-slow) var(--ease), transform var(--duration-slow) var(--ease);
    -webkit-user-drag: none;
    user-select: none;
    -webkit-touch-callout: none;
}

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

.tile__open { position: absolute; inset: 0; z-index: 1; cursor: zoom-in; }
.tile__open:focus-visible { outline-offset: -3px; }

.tile__shade {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(10, 10, 11, 0) 55%, rgba(10, 10, 11, 0.7) 100%);
    opacity: 0;
    transition: opacity var(--duration) var(--ease);
}

.tile__bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-2);
    padding: 0 var(--space-1) 0 var(--space-3);
    opacity: 0;
    transform: translateY(4px);
    transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
    pointer-events: none;
}

.tile__actions { display: flex; margin-left: auto; }

.tile__actions .icon-btn { color: var(--text-primary); pointer-events: auto; }

.tile__fav-flag {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    z-index: 3;
    width: 28px;
    height: 28px;
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
    filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.6));
    pointer-events: none;
}

.tile.is-favorite .tile__fav-flag { display: flex; }

/* videos: the poster frame, a quiet play mark and the running time */
.tile--video, .tile--video .tile__open { cursor: pointer; }

.tile__play {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 2;
    width: 48px;
    height: 48px;
    margin: -24px 0 0 -24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: 50%;
    background: rgba(10, 10, 11, 0.35);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    pointer-events: none;
    transition: background var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.tile__play .svg-icon { width: 18px; height: 18px; margin-left: 2px; }

.tile__duration {
    position: absolute;
    left: var(--space-2);
    bottom: var(--space-2);
    z-index: 3;
    padding: 2px var(--space-2);
    background: rgba(10, 10, 11, 0.55);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: var(--text-primary);
    font-size: var(--font-size-caps);
    line-height: 18px;
    letter-spacing: var(--letter-spacing-wide);
    font-variant-numeric: tabular-nums;
    pointer-events: none;
}

@media (max-width: 520px) {
    .tile__play { width: 36px; height: 36px; margin: -18px 0 0 -18px; }
    .tile__play .svg-icon { width: 14px; height: 14px; }
    .tile__duration { left: var(--space-1); bottom: var(--space-1); padding: 0 6px; }
}

@media (hover: hover) and (pointer: fine) {
    .tile:hover .tile__shade, .tile:focus-within .tile__shade { opacity: 1; }
    .tile:hover .tile__bar, .tile:focus-within .tile__bar { opacity: 1; transform: none; pointer-events: auto; }
    .tile:hover.is-favorite .tile__fav-flag { display: none; }
    .tile:hover img { transform: scale(1.015); }
    .tile--video:hover .tile__play { background: rgba(10, 10, 11, 0.55); border-color: rgba(255, 255, 255, 0.5); }
}

@media (hover: none) {
    .tile__bar { display: none; }
}

.grid-sentinel { height: 1px; }

.grid-status {
    padding: var(--space-12) 0;
    text-align: center;
    color: var(--text-tertiary);
}

.grid-end { display: flex; align-items: center; gap: var(--space-4); padding: var(--space-16) 0 0; color: var(--text-disabled); }
.grid-end::before, .grid-end::after { content: ''; flex: 1; height: 1px; background: var(--border-subtle); }

/* ========== GALLERY: JOURNAL ========== */
/* settings.layout = 'journal': sets become dated entries on one page, with a date index —
   a sticky rail on wide screens, a sheet from the nav's date bar below that */
.journal { display: grid; grid-template-columns: minmax(0, 1fr); align-items: start; }

.journal__entries { min-width: 0; }

.journal-year {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-20) 0 var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.journal-year:first-child { padding-top: var(--space-10); }

.journal-year__label {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(44px, 6vw, 80px);
    line-height: 0.9;
    letter-spacing: -0.04em;
}

.journal-year .eyebrow { white-space: nowrap; }

.entry { padding-top: var(--space-12); }

.entry__head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: end;
    column-gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.entry__title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(24px, 2.4vw, 32px);
    line-height: 1.05;
    letter-spacing: -0.02em;
}

.entry__meta { display: flex; flex-wrap: wrap; gap: 0 var(--space-2); margin-top: var(--space-2); }

.entry__meta .dot { color: var(--text-disabled); }

.entry__actions { display: flex; margin-right: calc(-1 * var(--space-3)); margin-bottom: calc(-1 * var(--space-2)); }

.entry__note {
    grid-column: 1 / -1;
    max-width: 64ch;
    margin-top: var(--space-3);
    color: var(--text-secondary);
    white-space: pre-line;
    text-wrap: pretty;
}

/* placeholder size until the entry builds (exact: computed from the photos' dimensions) */
.entry__grid:empty { background: var(--surface-01); }

.journal .grid-end { padding-top: var(--space-20); }

/* ---- date index ---- */
.jindex__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-3);
    padding-bottom: var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.jindex__order {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    min-height: 32px;
    font-family: var(--font-mono);
    font-size: var(--font-size-caps);
    letter-spacing: var(--letter-spacing-widest);
    text-transform: uppercase;
    color: var(--text-tertiary);
    transition: color var(--duration) var(--ease);
}

.jindex__order .svg-icon { width: 14px; height: 14px; }
.jindex__order:hover { color: var(--text-primary); }

.jindex__years, .jindex__months { list-style: none; }

.jindex__year { padding: var(--space-3) 0; border-bottom: 1px solid var(--border-subtle); }

.jindex__year-label {
    display: block;
    margin-bottom: var(--space-1);
    font-family: var(--font-display);
    font-weight: 500;
    font-size: var(--font-size-lg);
    letter-spacing: -0.01em;
    color: var(--text-tertiary);
    transition: color var(--duration) var(--ease);
}

button.jindex__year-label:hover, .jindex__year.is-current .jindex__year-label { color: var(--text-primary); }

.jindex__month { display: grid; grid-template-columns: 40px minmax(0, 1fr); align-items: start; }

.jindex__month-label {
    font-family: var(--font-mono);
    font-size: var(--font-size-caps);
    letter-spacing: var(--letter-spacing-wider);
    text-transform: uppercase;
    line-height: 26px;
    color: var(--text-disabled);
}

.jindex__month.is-current .jindex__month-label { color: var(--text-secondary); }

.jindex__days { display: flex; flex-wrap: wrap; }

.jindex__day {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    font-family: var(--font-mono);
    font-size: var(--font-size-caps);
    font-variant-numeric: tabular-nums;
    color: var(--text-tertiary);
    transition: color var(--duration) var(--ease), background var(--duration) var(--ease);
}

.jindex__day:hover { color: var(--text-primary); background: var(--surface-02); }
.jindex__day.is-active { color: var(--background-dark); background: var(--text-primary); }

.jindex__named a { display: block; padding: var(--space-1) 0; color: var(--text-tertiary); }
.jindex__named a:hover, .jindex__named a.is-active { color: var(--text-primary); }

/* rail: wide screens */
.journal__index { display: none; }

@media (min-width: 1100px) {
    .journal { grid-template-columns: minmax(0, 1fr) 216px; column-gap: var(--space-12); }
    .journal__index {
        display: block;
        position: sticky;
        top: calc(var(--nav-height) + var(--space-8));
        max-height: calc(100vh - var(--nav-height) - var(--space-8) - 88px);   /* ends above the back-to-top button */
        margin-top: var(--space-10);
        overflow-y: auto;
        overscroll-behavior: contain;
        scrollbar-width: none;
    }
    .journal__index::-webkit-scrollbar { display: none; }
    .journal-bar { display: none; }
}

/* sheet: phones and tablets, opened from the nav's date bar */
.modal--index .modal__panel { max-width: 520px; }
.jindex--sheet .jindex__head { padding-top: var(--space-2); }
.jindex--sheet .jindex__month { grid-template-columns: 52px minmax(0, 1fr); }
.jindex--sheet .jindex__month-label { line-height: 40px; }
.jindex--sheet .jindex__day { min-width: 40px; height: 40px; font-size: var(--font-size-caps-lg); }

/* nav date bar (below 1100px): the current entry, tap for the index */
.gallery-nav__row2.journal-bar { padding: 0; }

.journal-bar__now {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    width: 100%;
    min-height: var(--touch);
    padding: 0 max(var(--gutter), env(safe-area-inset-right)) 0 max(var(--gutter), env(safe-area-inset-left));
    text-align: left;
}

.journal-bar__now .mono { color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.journal-bar__jump { display: inline-flex; align-items: center; gap: var(--space-1); flex: none; transition: color var(--duration) var(--ease); }
.journal-bar__jump .svg-icon { width: 14px; height: 14px; }
.journal-bar__now:hover .journal-bar__jump { color: var(--text-primary); }

@media (max-width: 640px) {
    .journal-year, .entry__head, .journal .grid-end { padding-left: var(--space-3); padding-right: var(--space-3); }
    .entry__head { padding-right: var(--space-1); }
    .entry__actions { margin-right: 0; }
    .entry { padding-top: var(--space-10); }
    .journal-year { padding-top: var(--space-16); }
}

/* ========== LIGHTBOX ========== */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    grid-template-columns: minmax(0, 1fr);
    background: rgba(5, 5, 6, var(--lb-backdrop, 1));
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration) var(--ease), visibility 0s linear var(--duration);
    touch-action: none;
    overscroll-behavior: contain;
}

.lightbox.is-open { opacity: 1; visibility: visible; transition: opacity var(--duration) var(--ease); }
.lightbox[hidden] { display: none; }

.lightbox__top, .lightbox__bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    min-height: var(--nav-height);
    padding: 0 calc(var(--gutter) - var(--space-3));
    transition: opacity var(--duration) var(--ease);
}

.lightbox__info { flex: 1 1 auto; display: flex; align-items: baseline; gap: var(--space-4); min-width: 0; padding-left: var(--space-3); }

.lightbox__counter { color: var(--text-secondary); white-space: nowrap; }

.lightbox__name { color: var(--text-tertiary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: var(--letter-spacing-wide); text-transform: none; }

.lightbox__tools { flex: none; display: flex; align-items: center; }

.lightbox__close { flex: none; }

/* desktop/tablet: note, filename and title sit in one row, as before */
.lightbox__meta { display: contents; }

.lightbox__dock:empty { display: none; }

.lightbox__bottom-name { display: none; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-tertiary); text-transform: none; letter-spacing: var(--letter-spacing-wide); }

.lightbox__stage {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 var(--space-16);
    overflow: hidden;
}

.lightbox__frame {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    transition: transform var(--duration) var(--ease), opacity var(--duration) var(--ease);
}

.lightbox__frame.is-dragging { transition: none; }

.lightbox__img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    opacity: 0;
    user-select: none;
    -webkit-user-drag: none;
    -webkit-touch-callout: none;
    transition: opacity var(--lb-fade, 0ms) ease-in-out, filter var(--duration-slow) var(--ease);
}

.lightbox__img.is-current { opacity: 1; }

.lightbox__img.is-preview { filter: blur(8px); }

.lightbox__img.is-zoom-anim { transition: opacity var(--lb-fade, 0ms) ease-in-out, filter var(--duration-slow) var(--ease), transform 0.25s var(--ease); }

/* video: a native player in place of the photo layers, boxed to the video's own shape so the
   controls sit under the picture rather than at the bottom of the screen */
.lightbox__frame.is-video .lightbox__img { visibility: hidden; }

.lightbox__video {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: var(--background-deep);
    outline: none;
}

.lightbox__video:focus-visible { outline: 1px solid var(--border-strong); outline-offset: 2px; }

@supports (width: 1cqw) {
    .lightbox__frame.is-video { container-type: size; }
    .lightbox__video { width: min(100cqw, 100cqh * var(--ar, 1.7778)); height: auto; aspect-ratio: var(--ar, 1.7778); }
}

/* zoomed: the photo gets the whole screen until you zoom back out */
.lightbox.is-zoomed .lightbox__top,
.lightbox.is-zoomed .lightbox__bottom,
.lightbox.is-zoomed .lightbox__nav { opacity: 0; pointer-events: none; }

.lightbox__nav {
    position: absolute;
    top: 50%;
    z-index: 2;
    transform: translateY(-50%);
    width: 56px;
    height: 96px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: color var(--duration) var(--ease);
}

.lightbox__nav:hover { color: var(--text-primary); }
.lightbox__nav[disabled] { opacity: 0.2; pointer-events: none; }
.lightbox__nav--prev { left: var(--space-2); }
.lightbox__nav--next { right: var(--space-2); }
.lightbox__nav .svg-icon { width: 28px; height: 28px; }

.lightbox__note { flex: 1; max-width: 560px; display: none; }
.lightbox__note.is-visible { display: block; }
.lightbox__note .input { min-height: 40px; font-size: var(--font-size-sm); }

.lightbox__progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1px;
    background: var(--text-primary);
    transform: scaleX(0);
    transform-origin: left;
}

.lightbox.is-playing .lightbox__progress { animation: slideshow-progress linear forwards; animation-duration: var(--slide-ms, 3000ms); }

@keyframes slideshow-progress { from { transform: scaleX(0); } to { transform: scaleX(1); } }

.lightbox.is-chrome-hidden .lightbox__top, .lightbox.is-chrome-hidden .lightbox__bottom, .lightbox.is-chrome-hidden .lightbox__nav { opacity: 0; }

.lightbox.is-slideshow .lightbox__top,
.lightbox.is-slideshow .lightbox__bottom,
.lightbox.is-slideshow .lightbox__nav { opacity: 0; pointer-events: none; }

.lightbox.is-slideshow:not(.is-awake) { cursor: none; }

/* full screen: the controls and cursor fade after a moment of stillness (gallery.js → wakeFullscreenChrome) */
.lightbox.is-idle:not(.is-slideshow) .lightbox__top,
.lightbox.is-idle:not(.is-slideshow) .lightbox__bottom,
.lightbox.is-idle:not(.is-slideshow) .lightbox__nav { opacity: 0; transition-duration: var(--duration-slow); }
.lightbox.is-idle:not(.is-slideshow) { cursor: none; }

.lightbox__slidebar {
    position: absolute;
    left: 50%;
    bottom: calc(var(--space-8) + env(safe-area-inset-bottom, 0px));
    z-index: 3;
    display: none;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1);
    background: rgba(10, 10, 11, 0.55);
    border: 1px solid var(--border-subtle);
    -webkit-backdrop-filter: blur(16px);
    backdrop-filter: blur(16px);
    transform: translateX(-50%);
    opacity: 0.3;
    transition: opacity var(--duration-slow) var(--ease);
}

.lightbox.is-slideshow .lightbox__slidebar { display: flex; }

.lightbox.is-awake .lightbox__slidebar,
.lightbox__slidebar:hover,
.lightbox__slidebar:has(:focus-visible) { opacity: 1; transition-duration: var(--duration); }

.lightbox__slidebar .icon-btn { color: var(--text-primary); }

.lightbox__slidebar .label { display: inline; }

@media (hover: none) { .lightbox__slidebar { opacity: 1; } }

/* ========== BACK TO TOP ========== */
.back-to-top {
    position: fixed;
    right: calc(var(--gutter) - var(--space-2));
    bottom: calc(var(--space-6) + env(safe-area-inset-bottom, 0px));
    z-index: 150;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    background: rgba(10, 10, 11, 0.6);
    border: 1px solid var(--border-default);
    -webkit-backdrop-filter: blur(12px);
    backdrop-filter: blur(12px);
    cursor: pointer;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease), visibility 0s linear var(--duration), color var(--duration) var(--ease), border-color var(--duration) var(--ease);
}

.back-to-top.is-visible { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }

.back-to-top:hover { color: var(--text-primary); border-color: var(--border-strong); }

.back-to-top .svg-icon { width: 18px; height: 18px; transform: rotate(180deg); }

@media (max-width: 760px) {
    .lightbox__stage { padding: 0; }
    .lightbox__nav { display: none; }
    .lightbox__top { min-height: 52px; }
    .lightbox__name { display: none; }
    .lightbox__bottom { flex-direction: column; align-items: stretch; gap: 0; min-height: 0; padding: var(--space-2) var(--space-2) var(--space-1); }
    .lightbox__meta { display: flex; align-items: center; min-height: 0; }
    .lightbox__meta:empty { display: none; }
    .lightbox__bottom-name { display: block; padding: var(--space-1) var(--space-2); }
    .lightbox__bottom [data-lb-title] { display: none; }
    .lightbox__note { max-width: none; }
    .lightbox__note.is-visible + .lightbox__bottom-name { display: none; }
    .lightbox__note .input { font-size: var(--font-size-md); min-height: var(--touch); } /* 16px: no iOS zoom on focus */
    .lightbox__dock { display: flex; }
    .lightbox__dock .lightbox__tools { flex: 1; justify-content: space-around; }
    .lightbox__tools .icon-btn { min-width: var(--touch); padding: 0 var(--space-3); }
    .lightbox__tools .label { display: none; }
    /* the 1000px thumb is already ~full resolution on a phone, so show it sharp while 2400px loads */
    .lightbox__img.is-preview { filter: none; }
}

.lightbox__tools .label { display: none; }

@media (min-width: 1100px) {
    .lightbox__tools .label { display: inline; }
}

/* ========== DIALOGS / SHEETS ========== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    background: rgba(5, 5, 6, 0.72);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    opacity: 0;
    transition: opacity var(--duration) var(--ease);
}

.modal.is-open { opacity: 1; }

.modal__panel {
    position: relative;
    width: 100%;
    max-width: 440px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--background-dark);   /* black like the page; the border and blurred backdrop set it apart */
    border: 1px solid var(--border-default);
    padding: var(--space-8);
    transform: translateY(8px);
    transition: transform var(--duration) var(--ease);
}

.modal.is-open .modal__panel { transform: none; }

.modal__close { position: absolute; top: var(--space-2); right: var(--space-2); }

.modal__title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: var(--font-size-2xl);
    letter-spacing: -0.01em;
    line-height: 1.2;
    margin-bottom: var(--space-2);
    padding-right: var(--space-10);
}

.modal__text { color: var(--text-secondary); margin-bottom: var(--space-6); }

.modal__body { display: flex; flex-direction: column; gap: var(--space-5); }

.modal__section-title { margin-bottom: var(--space-3); }

.file-list { display: flex; flex-direction: column; border-top: 1px solid var(--border-subtle); }

.save-sheet, .save-batch { display: flex; flex-direction: column; gap: var(--space-4); }

.save-progress { position: relative; height: 2px; background: var(--surface-02); overflow: hidden; }

.save-progress__bar {
    position: absolute;
    inset: 0;
    background: var(--text-primary);
    transform: scaleX(0.02);
    transform-origin: left;
    transition: transform var(--duration) var(--ease);
}

.save-batch__label { color: var(--text-primary); }

.save-batch__hint { color: var(--text-tertiary); font-size: var(--font-size-sm); }

.save-sheet .form-error:empty { display: none; }

.file-list a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-4);
    min-height: var(--touch);
    border-bottom: 1px solid var(--border-subtle);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.file-list a:hover { color: var(--text-primary); }

@media (max-width: 640px) {
    .modal { align-items: flex-end; padding: 0; }
    .modal__panel { max-width: none; border-left: 0; border-right: 0; border-bottom: 0; padding: var(--space-6) var(--space-5) calc(var(--space-6) + env(safe-area-inset-bottom)); transform: translateY(24px); }
}

/* ========== GATES (password / email / unavailable) ========== */
.gate {
    position: fixed;
    inset: 0;
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    background: rgba(5, 5, 6, 0.62);
    backdrop-filter: blur(28px) saturate(0.6);
    -webkit-backdrop-filter: blur(28px) saturate(0.6);
}

.gate__panel { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: var(--space-6); text-align: center; }

.gate__title {
    font-family: var(--font-display);
    font-weight: 500;
    font-size: clamp(28px, 5vw, 44px);
    letter-spacing: -0.02em;
    line-height: 1.05;
    text-wrap: balance;
}

.gate__text { color: var(--text-secondary); }

.gate form { display: flex; flex-direction: column; gap: var(--space-3); text-align: left; }

.gate .gate__lock { margin: 0 auto; color: var(--text-tertiary); }

.unavailable {
    min-height: 100vh;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-5);
    padding: var(--space-10) var(--gutter);
    text-align: center;
}

.unavailable h1 { font-family: var(--font-display); font-weight: 500; font-size: clamp(28px, 5vw, 56px); letter-spacing: -0.02em; line-height: 1.05; max-width: 18ch; text-wrap: balance; }

.unavailable p { color: var(--text-secondary); max-width: 44ch; }

/* ========== TOAST ========== */
.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--space-6) + env(safe-area-inset-bottom));
    z-index: 400;
    transform: translate(-50%, 16px);
    opacity: 0;
    padding: var(--space-3) var(--space-5);
    background: var(--text-primary);
    color: var(--background-dark);
    font-family: var(--font-mono);
    font-size: var(--font-size-sm);
    letter-spacing: var(--letter-spacing-wide);
    pointer-events: none;
    transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease);
    max-width: calc(100vw - 32px);
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: var(--error); color: #fff; }

.spinner {
    width: 16px;
    height: 16px;
    border: 1px solid var(--border-default);
    border-top-color: var(--text-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

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

/* ========== INVOICE ========== */
.invoice-page { max-width: 920px; margin: 0 auto; padding: var(--space-12) var(--gutter) var(--space-20); }

.banner {
    display: flex;
    gap: var(--space-3);
    align-items: flex-start;
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-8);
    border: 1px solid var(--border-default);
    background: var(--surface-01);
}

.banner__title { font-weight: 500; }
.banner__text { color: var(--text-secondary); }
.banner--error { border-color: var(--error-border); background: var(--error-surface); }

.invoice-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-6); flex-wrap: wrap; padding-bottom: var(--space-8); border-bottom: 1px solid var(--border-subtle); }

.invoice-head h1 { font-family: var(--font-display); font-weight: 500; font-size: clamp(32px, 6vw, 56px); letter-spacing: -0.03em; line-height: 1; }

.invoice-head__number { margin-top: var(--space-3); color: var(--text-secondary); }

.invoice-head__due { text-align: right; display: flex; flex-direction: column; gap: var(--space-2); align-items: flex-end; }

.invoice-head__amount { font-family: var(--font-display); font-weight: 500; font-size: clamp(28px, 5vw, 44px); letter-spacing: -0.02em; line-height: 1; font-variant-numeric: tabular-nums; }

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 24px;
    padding: 0 var(--space-2);
    border: 1px solid var(--border-default);
    font-family: var(--font-mono);
    font-size: var(--font-size-caps);
    letter-spacing: var(--letter-spacing-widest);
    text-transform: uppercase;
    color: var(--text-secondary);
    white-space: nowrap;
}

.chip::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.chip--paid { color: var(--text-primary); border-color: var(--border-strong); }
.chip--overdue { color: var(--error); border-color: var(--error-border); }
.chip--due { color: var(--text-primary); }
.chip--upcoming, .chip--void, .chip--draft { color: var(--text-tertiary); }

.invoice-parties { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: var(--space-6); padding: var(--space-8) 0; border-bottom: 1px solid var(--border-subtle); }

.invoice-parties dt { margin-bottom: var(--space-2); }
.invoice-parties dd { color: var(--text-secondary); line-height: 1.6; }
.invoice-parties dd strong { color: var(--text-primary); font-weight: 500; }

.invoice-section { padding: var(--space-8) 0; border-bottom: 1px solid var(--border-subtle); }
.invoice-section:last-of-type { border-bottom: 0; }
.invoice-section > .eyebrow { margin-bottom: var(--space-4); display: block; }

.line-items { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }

.line-items th {
    text-align: left;
    font-family: var(--font-mono);
    font-size: var(--font-size-caps);
    letter-spacing: var(--letter-spacing-widest);
    text-transform: uppercase;
    color: var(--text-tertiary);
    font-weight: 400;
    padding: 0 0 var(--space-3);
    border-bottom: 1px solid var(--border-subtle);
}

.line-items td { padding: var(--space-4) 0; border-bottom: 1px solid var(--border-subtle); vertical-align: top; }

.line-items .num { text-align: right; font-family: var(--font-mono); font-size: var(--font-size-sm); white-space: nowrap; padding-left: var(--space-4); }

.line-items .desc { color: var(--text-primary); }
.line-items .desc small { display: block; color: var(--text-tertiary); font-family: var(--font-mono); font-size: var(--font-size-caps); margin-top: 2px; letter-spacing: var(--letter-spacing-wide); }

.totals { margin-left: auto; width: min(100%, 360px); margin-top: var(--space-6); display: grid; grid-template-columns: 1fr auto; row-gap: var(--space-3); font-variant-numeric: tabular-nums; }

.totals dt { color: var(--text-tertiary); }
.totals dd { text-align: right; font-family: var(--font-mono); font-size: var(--font-size-sm); padding-left: var(--space-6); }
.totals .is-strong { color: var(--text-primary); padding-top: var(--space-3); border-top: 1px solid var(--border-default); }
.totals dd.is-strong { font-size: var(--font-size-md); }

.schedule { display: flex; flex-direction: column; }

.schedule__row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    align-items: center;
    gap: var(--space-4);
    min-height: 64px;
    padding: var(--space-3) 0;
    border-bottom: 1px solid var(--border-subtle);
}

.schedule__row:first-child { border-top: 1px solid var(--border-subtle); }

.schedule__label { display: flex; flex-direction: column; gap: 2px; }
.schedule__amount { font-family: var(--font-mono); font-size: var(--font-size-sm); text-align: right; font-variant-numeric: tabular-nums; }
.schedule__amount small { display: block; color: var(--text-tertiary); font-size: var(--font-size-caps); }

.pay-actions { display: flex; gap: var(--space-3); flex-wrap: wrap; margin-top: var(--space-6); }

.invoice-notes { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: var(--space-8); }
.invoice-notes p { color: var(--text-secondary); white-space: pre-wrap; line-height: 1.7; }

.invoice-toolbar { display: flex; justify-content: flex-end; gap: var(--space-2); margin-bottom: var(--space-6); }

.payments-list { display: flex; flex-direction: column; }
.payments-list__row { display: grid; grid-template-columns: 1fr auto; gap: var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--border-subtle); font-family: var(--font-mono); font-size: var(--font-size-sm); color: var(--text-secondary); }
.payments-list__row:first-child { border-top: 1px solid var(--border-subtle); }

@media (max-width: 640px) {
    .invoice-head__due { text-align: left; align-items: flex-start; }
    .line-items thead { display: none; }
    .line-items tr { display: grid; grid-template-columns: 1fr auto; padding: var(--space-4) 0; border-bottom: 1px solid var(--border-subtle); }
    .line-items td { border: 0; padding: 0; }
    .line-items td.desc { grid-column: 1 / -1; margin-bottom: var(--space-2); }
    .line-items td.qty, .line-items td.price { display: none; }
    .line-items td.qty-price { display: block; text-align: left; padding-left: 0; color: var(--text-tertiary); }
    .line-items td.amount { grid-column: 2; grid-row: 2; }
    .schedule__row { grid-template-columns: 1fr auto; }
    .schedule__row .chip { grid-column: 1; justify-self: start; }
    .schedule__amount { grid-row: 1 / 3; grid-column: 2; }
    .pay-actions .btn { flex: 1 1 100%; }
}

@media (min-width: 641px) {
    .line-items td.qty-price { display: none; }
}

/* ========== 404 ========== */
.not-found { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; }
.not-found__body { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: var(--space-6); padding: var(--space-16) var(--gutter); }
.not-found__code { font-family: var(--font-display); font-weight: 500; font-size: clamp(96px, 22vw, 280px); letter-spacing: -0.06em; line-height: 0.82; color: var(--text-primary); }
.not-found__text { color: var(--text-secondary); max-width: 40ch; font-size: var(--font-size-md); }
.not-found__actions { display: flex; gap: var(--space-3); flex-wrap: wrap; }

/* ========== REDUCED MOTION ========== */
@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    .cover__media img { transform: none; }
    .cover__scroll { display: none; }
    .lightbox.is-playing .lightbox__progress { animation: none; }
}

/* ========== PRINT (invoice → PDF) ========== */
@media print {
    :root {
        --text-primary: #000;
        --text-secondary: #222;
        --text-tertiary: #555;
        --text-disabled: #888;
        --border-subtle: #ddd;
        --border-default: #bbb;
        --border-strong: #000;
        --surface-01: transparent;
    }
    body { background: #fff; color: #000; }
    .no-print, .site-links, .pay-actions, .invoice-toolbar, .banner, .toast { display: none !important; }
    .wordmark__logo { filter: invert(1); }   /* white logo → black on paper */
    .site-header { padding: 0 0 16px; }
    .invoice-page { padding: 24px 0 0; max-width: none; }
    .chip--overdue { color: #000; border-color: #000; }
    .invoice-section, .schedule__row, .line-items tr { break-inside: avoid; }
    @page { margin: 18mm 16mm; }
}

.grid-status__hint { margin-top: var(--space-2); }
.grid-status__retry { margin-top: var(--space-4); }

.modal__body > form { display: flex; flex-direction: column; gap: var(--space-5); }
.modal__body > form .form-error:empty { display: none; }

@media (max-width: 420px) {
    .wordmark { letter-spacing: 0.22em; font-size: var(--font-size-base); }
    .site-header { gap: var(--space-2); }
    .site-links { gap: 0; margin-right: calc(var(--space-2) * -1); }
    .site-links a { min-width: var(--touch); justify-content: center; padding: 0 var(--space-2); }
}
