:root {
  color-scheme: light;
  --canvas: #f4ecdc;
  --paper: #fbf7ef;
  --paper-deep: #eee2cf;
  --ink: #2e211a;
  --muted: #635443;
  --edge: #d8c8ae;
  --bronze: #705138;
  --bronze-dark: #523621;
  --sage: #395039;
  --error: #8a332c;
  --radius: 14px;
  --serif: 'Iowan Old Style', 'Palatino Linotype', 'Book Antiqua', Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--canvas) url('./studio-assets/paper-grain.png'); color: var(--ink); font: 400 1rem/1.55 var(--sans); }
h1, h2, h3, p, figure { margin: 0; }
button, input, select, textarea { color: inherit; font: inherit; }
input, select, textarea { max-width: 100%; }
button { cursor: pointer; }
button[aria-disabled='true'], button:disabled { cursor: wait; }
a { color: var(--bronze-dark); text-underline-offset: 0.2em; }
img { display: block; width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid var(--bronze); outline-offset: 4px; }
.sr-only { position: absolute; clip-path: inset(50%); width: 1px; height: 1px; overflow: hidden; white-space: nowrap; }
.skip-link { position: fixed; z-index: 2; inset: 1rem auto auto 1rem; padding: 0.7rem 1rem; background: var(--paper); transform: translateY(-200%); }
.skip-link:focus { transform: translateY(0); }

.preview-bar { display: flex; gap: 0.45rem 1rem; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 0.4rem max(1rem, calc((100% - 86rem) / 2)); color: #f9f0e0; background: #3b2c23; }
.preview-bar p { font-size: 0.83rem; }
.preview-bar strong { margin-right: 0.25rem; }
.role-picker { display: flex; flex-wrap: wrap; gap: 0.15rem; }
.role-picker button { min-height: 44px; padding: 0.3rem 0.62rem; border: 1px solid transparent; border-radius: 5px; font-size: 0.83rem; color: inherit; background: none; }
.role-picker button:hover, .role-picker button[aria-pressed='true'] { background: #5c4635; border-color: #a58261; }
.role-picker button:focus-visible { outline-color: #f5d7aa; }
.masthead { background: var(--paper); border-bottom: 1px solid var(--edge); }
.masthead-inner { width: min(100%, 88rem); margin-inline: auto; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem 1rem; min-height: 4.3rem; padding: 0.65rem 1rem; }
.brand { display: inline-flex; gap: 0.65rem; align-items: center; padding: 0.35rem 0; color: var(--ink); font: 600 clamp(1.12rem, 2vw, 1.42rem)/1.1 var(--serif); letter-spacing: -0.025em; text-decoration: none; }
.brand-mark { width: 1.55rem; height: 1.55rem; display: grid; place-items: center; border: 1px solid var(--bronze); border-radius: 50%; }
.brand-mark::after { content: ''; width: 0.75rem; height: 0.75rem; border: 1px solid var(--bronze); transform: rotate(45deg); }
.account { min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: 0.3rem 0.85rem; font-size: 0.86rem; }
.account-name { overflow-wrap: anywhere; }
.account-name strong { display: block; line-height: 1.25; }
.account-name span { color: var(--muted); font-size: 0.77rem; }
.account-action { min-height: 44px; border: 0; background: none; color: var(--bronze-dark); font-weight: 700; padding: 0 0.15rem; }
.account-action:hover { text-decoration: underline; }

.shell { min-height: 70vh; max-width: 88rem; margin: auto; padding: 0 1rem max(2.5rem, env(safe-area-inset-bottom)); }
.workspace-nav { border-bottom: 1px solid var(--edge); display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.7rem 0; }
.nav-item { min-height: 44px; min-width: 5.6rem; display: inline-flex; align-items: center; justify-content: center; padding: 0.42rem 0.78rem; border: 1px solid transparent; border-radius: 6px; font-weight: 700; color: var(--ink); text-decoration: none; }
.nav-item:hover { background: var(--paper); }
.nav-item[aria-current='page'] { background: var(--paper-deep); border-color: var(--edge); }
.content { min-width: 0; padding-top: 1.2rem; }
.page-head { display: flex; align-items: end; flex-wrap: wrap; justify-content: space-between; gap: 0.85rem 1.4rem; margin: 0.8rem 0 1.15rem; }
h1, h2, h3 { font-family: var(--serif); font-weight: 550; line-height: 1.07; letter-spacing: -0.035em; overflow-wrap: anywhere; }
h1 { font-size: clamp(2.45rem, 6.8vw, 4.7rem); }
h2 { font-size: clamp(1.6rem, 4vw, 2.25rem); }
h3 { font-size: clamp(1.25rem, 3vw, 1.52rem); }
.page-head p, .section-head p, .detail-summary, .sign-in p { margin-top: 0.42rem; color: var(--muted); overflow-wrap: anywhere; }
.page-head .kicker, .kicker { color: var(--bronze-dark); font-weight: 700; font-size: 0.81rem; margin-bottom: 0.45rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem; }
.button { display: inline-flex; justify-content: center; align-items: center; gap: 0.25rem; min-height: 44px; padding: 0.58rem 0.88rem; border: 1px solid var(--bronze); border-radius: 7px; background: var(--paper); color: var(--bronze-dark); font: 700 0.9rem/1.25 var(--sans); text-decoration: none; }
.button:hover { background: var(--paper-deep); }
.button.primary { background: var(--bronze-dark); border-color: var(--bronze-dark); color: var(--paper); }
.button.primary:hover { background: #3d291a; }
.button[aria-disabled='true'], .button:disabled { opacity: 0.68; }
.card, .empty { border: 1px solid var(--edge); background: var(--paper); border-radius: var(--radius); }
.empty { padding: clamp(1.1rem, 4vw, 2rem); }
.empty p { margin: 0.5rem 0 0.9rem; color: var(--muted); }
.notice { padding: 0.75rem 0.85rem; margin: 0.75rem 0; border: 1px solid var(--edge); border-inline-start: 3px solid var(--bronze); border-radius: 6px; background: var(--paper); overflow-wrap: anywhere; }
.notice.error { border-inline-start-color: var(--error); color: var(--error); }
.badge { display: inline-flex; align-items: center; padding: 0.14rem 0.5rem; min-height: 1.55rem; border: 1px solid #cabb9e; border-radius: 30px; background: var(--paper-deep); color: var(--bronze-dark); font: 700 0.76rem/1.2 var(--sans); }
.badge.published { border-color: #bfc9b8; color: var(--sage); background: #e7ecdf; }

.album-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16.2rem), 1fr)); gap: 1rem; align-items: stretch; }
.album-card { min-width: 0; overflow: clip; position: relative; }
.album-card:hover { border-color: var(--bronze); }
.album-card > a { display: block; color: inherit; text-decoration: none; }
.album-card > a:focus-visible { outline-offset: -4px; }
.album-cover { aspect-ratio: 8 / 5; overflow: hidden; background: var(--paper-deep); }
.album-cover img { height: 100%; object-fit: cover; object-position: center 45%; }
.album-cover.is-empty { display: grid; place-items: center; background: linear-gradient(135deg, #e8d8ba, var(--paper-deep)); }
.album-cover.is-empty span { color: var(--bronze-dark); font: 500 1.12rem/1.3 var(--serif); }
.album-body { padding: 0.85rem 1rem 1rem; }
.album-body h2 { margin-top: 0.55rem; font-size: clamp(1.45rem, 3vw, 1.85rem); }
.album-body p { margin-top: 0.3rem; color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.album-meta { display: flex; gap: 0.2rem 0.55rem; flex-wrap: wrap; align-items: center; color: var(--muted); font-size: 0.78rem; }
.section-head { margin: 1.55rem 0 0.75rem; }
.back-link { min-height: 44px; padding-block: 0.65rem; display: inline-flex; align-items: center; font-weight: 700; }
.detail-head .page-head { margin-top: 0; }
.detail-meta { display: flex; align-items: center; gap: 0.5rem 0.8rem; flex-wrap: wrap; color: var(--muted); }
.detail-summary { max-width: 60ch; }
.detail-meta strong { color: var(--ink); }
.photo-gallery { display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fill, minmax(min(100%, 11.5rem), 1fr)); }
.photo-cell { min-width: 0; overflow: clip; }
.photo-open { display: block; width: 100%; padding: 0; color: inherit; border: none; background: transparent; text-align: start; }
.photo-open:focus-visible { outline-offset: -4px; }
.photo-cell img { aspect-ratio: 4 / 3; object-fit: cover; background: var(--paper-deep); }
.photo-cell img[hidden] + .image-unavailable { display: grid; }
.image-unavailable { display: none; aspect-ratio: 4 / 3; place-items: center; padding: 0.5rem; background: var(--paper-deep); text-align: center; color: var(--muted); }
.photo-cell .photo-name { display: block; padding: 0.53rem 0.72rem; font-size: 0.82rem; font-weight: 700; overflow-wrap: anywhere; }
.people-list { padding: 0 0.85rem; }
.person-row { display: grid; gap: 0.45rem; padding: 0.72rem 0; border-bottom: 1px solid var(--edge); }
.person-row:last-child { border-bottom: 0; }
.person-row strong { display: block; overflow-wrap: anywhere; }
.person-row p { color: var(--muted); font-size: 0.9rem; overflow-wrap: anywhere; }
.person-row .button { justify-self: start; }

.entry { display: grid; overflow: hidden; margin: clamp(1.2rem, 6vw, 4rem) auto; max-width: 66rem; }
.sign-in { padding: clamp(1.2rem, 5vw, 3.5rem); align-self: center; }
.entry h1 { font-size: clamp(2.35rem, 6vw, 4rem); }
.entry-photo { aspect-ratio: 3 / 2; overflow: hidden; background: var(--paper-deep); }
.entry-photo img { height: 100%; object-fit: cover; object-position: center 40%; }
.sign-in form { margin-top: 1rem; }
.sign-in .notice, .sign-in .kicker { margin-top: 0; }
.sign-in .notice { margin-top: 0.8rem; }
.sign-in .button { margin-top: 0.25rem; }

dialog { max-block-size: calc(100dvh - 2rem); width: min(calc(100% - 1.75rem), 35rem); margin: auto; padding: clamp(1rem, 4vw, 1.7rem); border: 1px solid var(--edge); border-radius: var(--radius); background: var(--paper); color: var(--ink); overflow: auto; }
dialog::backdrop { background: #251a13a1; }
.dialog-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.close-button { flex: none; min-width: 44px; min-height: 44px; border: 1px solid var(--edge); border-radius: 7px; background: transparent; font-size: 1.35rem; line-height: 1; }
.close-button:hover { background: var(--paper-deep); }
.dialog-note { margin: 0.65rem 0 0; color: var(--muted); }
.fields { display: grid; gap: 0.85rem; margin-top: 0.8rem; }
.fields > :last-child { margin-top: 0.25rem; }
.field { display: grid; gap: 0.32rem; align-content: start; font-weight: 700; }
.field input, .field select, .field textarea { width: 100%; min-width: 0; min-height: 44px; padding: 0.6rem 0.7rem; border: 1px solid #a38e74; border-radius: 6px; background: #fffdf8; color: var(--ink); font-size: 1rem; font-weight: 400; }
.field textarea { resize: vertical; min-height: 5.3rem; }
.field small { color: var(--muted); font-size: 0.83rem; font-weight: 400; }
fieldset { min-width: 0; padding: 0.5rem 0.7rem; border: 1px solid var(--edge); border-radius: 6px; }
legend { font-weight: 700; }
.check-row { display: flex; align-items: center; gap: 0.55rem; min-height: 44px; }
.check-row input { width: 1.12rem; height: 1.12rem; flex: none; accent-color: var(--bronze-dark); }
.invite-result { margin-top: 0.9rem; padding-top: 0.8rem; border-top: 1px solid var(--edge); }
.invite-result p { margin-bottom: 0.55rem; }
.invite-result .button { margin-top: 0.5rem; }
.viewer { width: min(calc(100% - 1rem), 65rem); }
.viewer img { margin-top: 0.8rem; max-height: 68dvh; object-fit: contain; background: var(--paper-deep); border-radius: 6px; }
.viewer .actions { justify-content: space-between; margin-top: 0.75rem; }
.viewer .viewer-count { flex-grow: 1; color: var(--muted); text-align: center; min-width: 4rem; font-size: 0.85rem; }
.upload-progress { margin: 0; padding-inline-start: 1.2rem; color: var(--muted); overflow-wrap: anywhere; }

@media (min-width: 38rem) {
  .masthead-inner, .shell { padding-inline: 1.5rem; }
  .person-row { grid-template-columns: minmax(0, 1fr) max-content; align-items: center; }
  .entry { grid-template-columns: 1fr 1fr; }
  .entry-photo { aspect-ratio: auto; min-height: 100%; }
}
@media (min-width: 57rem) {
  .masthead-inner, .shell { padding-inline: 2.2rem; }
  .shell.workspace { display: grid; grid-template-columns: 10rem minmax(0, 1fr); gap: clamp(1rem, 3vw, 3rem); }
  .workspace-nav { align-self: start; border-bottom: 0; border-inline-end: 1px solid var(--edge); min-height: 15rem; padding: 1.6rem 0.8rem 1.6rem 0; display: grid; align-content: start; }
  .nav-item { justify-content: flex-start; }
  .workspace .content { padding-top: 1.6rem; }
}

@supports (animation-timeline: view()) {
  @media (prefers-reduced-motion: no-preference) {
    .album-cover img { animation: cover-drift linear both; animation-timeline: view(block); }
    .photo-cell img { animation: photo-drift linear both; animation-timeline: view(block); }
    @keyframes cover-drift { from { transform: translateY(-2%) scale(1.05); } to { transform: translateY(2%) scale(1.05); } }
    @keyframes photo-drift { from { transform: translateX(-2%) scale(1.05); } to { transform: translateX(2%) scale(1.05); } }
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; }
}
@media (forced-colors: active) {
  .button, .badge, .card, .empty, .nav-item[aria-current] { border: 1px solid ButtonText; }
  .nav-item[aria-current], .role-picker button[aria-pressed='true'] { outline: 2px solid Highlight; outline-offset: -2px; }
}
