:root {
  --paper: #F5EFE4;
  --paper-2: #ECE3D2;
  --ink: #2A241F;
  --muted: #7B6F62;
  --line: #DCCFB9;
  --terracotta: #B4532A;
  --terracotta-dk: #963F1C;
  --olive: #6E7045;
  --night: #16120F;
  --serif: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 3px;
  --gutter: clamp(16px, 4vw, 40px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .45em;
  height: 38px; padding: 0 16px;
  border: 1px solid transparent; border-radius: 999px;
  background: none; cursor: pointer; white-space: nowrap;
  font-size: 14px; font-weight: 500; letter-spacing: .01em; text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, opacity .15s;
}
.btn svg { width: 16px; height: 16px; }
.btn--primary { background: var(--terracotta); color: #FBF6EE; }
.btn--primary:hover { background: var(--terracotta-dk); }
.btn--primary:disabled { opacity: .45; cursor: default; }
.btn--ghost { border-color: var(--line); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--ghost.is-on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.btn--icon { width: 38px; padding: 0; font-size: 22px; line-height: 1; }
.btn--icon svg { fill: currentColor; }
.btn--icon:hover { background: var(--paper-2); }
.btn--small { width: 28px; height: 28px; font-size: 18px; }
.btn--wide { width: 100%; height: 46px; font-size: 15px; }
.btn--light { color: #F3ECE1; border-color: rgba(243,236,225,.3); }
.btn--light:hover { border-color: #F3ECE1; background: rgba(255,255,255,.06); }
:focus-visible { outline: 2px solid var(--terracotta); outline-offset: 2px; }

.eyebrow {
  margin: 0; font-size: 11px; font-weight: 600; letter-spacing: .22em; text-transform: uppercase;
  color: var(--terracotta);
}

/* ---------- login ---------- */
.login {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-items: center; padding: 48px var(--gutter);
  background:
    radial-gradient(120% 70% at 50% 0%, #FBF7F0 0%, transparent 60%),
    var(--paper);
}
.login__inner { position: relative; width: 100%; max-width: 380px; text-align: center; }
.arch {
  position: absolute; left: 50%; top: -34px; width: 280px; transform: translateX(-50%);
  color: var(--terracotta); opacity: .35; pointer-events: none;
  -webkit-mask-image: linear-gradient(#000 45%, transparent 78%); mask-image: linear-gradient(#000 45%, transparent 78%);
}
.login .eyebrow { position: relative; margin-top: 64px; }
.login__title {
  position: relative; margin: 14px 0 0;
  font: 500 clamp(44px, 12vw, 58px)/.95 var(--serif); letter-spacing: -.01em;
}
.login__title em {
  display: block; margin-top: 6px; font-weight: 400; font-style: italic; color: var(--terracotta);
}
.login__sub { position: relative; margin: 18px 0 40px; color: var(--muted); }
.login__form { display: grid; gap: 18px; text-align: left; }
.field { display: grid; gap: 6px; }
.field span { font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.field input {
  height: 44px; padding: 0 2px; border: 0; border-bottom: 1px solid var(--line);
  background: transparent; font-size: 16px; border-radius: 0;
}
.field input:focus { outline: none; border-bottom-color: var(--terracotta); }
.field input::placeholder { color: #B5A898; }
.login__error { min-height: 1.2em; margin: -6px 0 0; color: var(--terracotta-dk); font-size: 13px; }
.cypress { display: block; width: 100%; margin-top: 48px; color: var(--olive); }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(245,239,228,.92);
  -webkit-backdrop-filter: saturate(1.2) blur(12px); backdrop-filter: saturate(1.2) blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.topbar__row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px var(--gutter) 8px; max-width: 1400px; margin: 0 auto;
}
.brand { display: flex; align-items: baseline; gap: .4em; text-decoration: none; min-width: 0; }
.brand__title { font: 600 26px/1 var(--serif); white-space: nowrap; }
.brand__place { font: italic 400 22px/1 var(--serif); color: var(--terracotta); white-space: nowrap; }
.topbar__actions { display: flex; align-items: center; gap: 8px; }

.menu { position: relative; }
.menu__list {
  position: absolute; right: 0; top: calc(100% + 6px); min-width: 230px;
  background: #FBF8F2; border: 1px solid var(--line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(42,36,31,.12); padding: 6px; display: grid;
}
.menu__list button {
  text-align: left; padding: 10px 12px; border: 0; background: none; border-radius: 6px; cursor: pointer;
}
.menu__list button:hover { background: var(--paper-2); }

.daynav {
  display: flex; align-items: center; gap: 12px;
  padding: 0 var(--gutter) 12px; max-width: 1400px; margin: 0 auto;
}
.daynav__chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.daynav__chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: transparent; cursor: pointer;
  font-size: 13px; color: var(--muted); white-space: nowrap;
}
.chip b { font-weight: 600; color: var(--ink); margin-right: .35em; }
.chip:hover { border-color: var(--ink); }
.chip.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chip.is-active b { color: var(--paper); }
.daynav__person {
  flex: none; height: 30px; padding: 0 28px 0 12px; border: 1px solid var(--line); border-radius: 999px;
  background: transparent url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%237B6F62' stroke-width='1.4'/%3E%3C/svg%3E") no-repeat right 11px center / 9px;
  font-size: 13px; appearance: none; -webkit-appearance: none; cursor: pointer; max-width: 150px;
}

/* ---------- album ---------- */
.album { max-width: 1400px; margin: 0 auto; padding: 8px var(--gutter) 120px; }
.album__summary { margin: 16px 0 0; color: var(--muted); font-size: 13px; }
.day { padding-top: 36px; scroll-margin-top: 120px; }
.day__head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--line);
}
.day__title { margin: 6px 0 0; font: 500 clamp(26px, 5vw, 34px)/1.05 var(--serif); }
.day__title em { font-weight: 400; color: var(--muted); }
.day__tools { display: flex; align-items: center; gap: 14px; font-size: 13px; color: var(--muted); white-space: nowrap; }
.linkbtn {
  border: 0; background: none; padding: 0; cursor: pointer; font-size: 13px; font-weight: 500;
  color: var(--terracotta); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px;
}
.linkbtn:hover { color: var(--terracotta-dk); }

.grid {
  display: grid; gap: 4px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
@media (min-width: 900px) { .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; } }
@media (max-width: 420px) { .grid { grid-template-columns: repeat(3, 1fr); gap: 3px; } }

.tile {
  position: relative; aspect-ratio: 1; overflow: hidden; padding: 0; border: 0; cursor: zoom-in;
  background: var(--paper-2); border-radius: var(--radius); display: block; width: 100%;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s ease, opacity .3s; opacity: 0; }
.tile img.is-loaded { opacity: 1; }
.tile:hover img { transform: scale(1.03); }
.tile__ph {
  position: absolute; inset: 0; display: grid; place-items: center;
  font: 600 12px var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted);
}
.tile__badge {
  position: absolute; left: 8px; bottom: 8px; width: 26px; height: 26px; border-radius: 50%;
  background: rgba(22,18,15,.55); display: grid; place-items: center;
}
.tile__badge svg { width: 10px; height: 10px; fill: #fff; margin-left: 2px; }
.tile__check {
  position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 50%;
  border: 1.5px solid #fff; background: rgba(22,18,15,.25); display: none; place-items: center;
  box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.tile__check svg { width: 12px; height: 12px; stroke: #fff; fill: none; stroke-width: 2.4; opacity: 0; }
.is-selecting .tile { cursor: pointer; }
.is-selecting .tile__check { display: grid; }
.tile.is-selected .tile__check { background: var(--terracotta); border-color: var(--terracotta); }
.tile.is-selected .tile__check svg { opacity: 1; }
.tile.is-selected img { transform: scale(.9); border-radius: var(--radius); }
.is-selecting .tile:hover img { transform: none; }
.is-selecting .tile.is-selected:hover img { transform: scale(.9); }

.empty { text-align: center; padding: 90px 0; color: var(--muted); max-width: 380px; margin: 0 auto; }
.empty__title { font: italic 400 34px/1.1 var(--serif); color: var(--ink); margin: 0 0 10px; }
.loading { text-align: center; padding: 90px 0; color: var(--muted); font: italic 22px var(--serif); }

/* ---------- selection bar ---------- */
.selectbar {
  position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 30; display: flex; align-items: center; justify-content: space-between; gap: 18px;
  width: min(440px, calc(100% - 32px)); padding: 10px 10px 10px 20px;
  background: var(--night); color: #F3ECE1; border-radius: 999px;
  box-shadow: 0 16px 40px rgba(22,18,15,.3);
}
.selectbar > div { display: flex; gap: 6px; }

/* ---------- upload tray ---------- */
.tray {
  position: fixed; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 40;
  width: min(360px, calc(100% - 32px)); max-height: 50vh; display: flex; flex-direction: column;
  background: #FBF8F2; border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 18px 48px rgba(42,36,31,.18); overflow: hidden;
}
.tray__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 12px 12px 16px; border-bottom: 1px solid var(--line); }
.tray__head strong { font: 600 18px var(--serif); }
.tray__list { list-style: none; margin: 0; padding: 6px 0; overflow-y: auto; }
.tray__item { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: center; padding: 6px 16px; font-size: 13px; }
.tray__thumb { width: 40px; height: 40px; border-radius: 4px; background: var(--paper-2) center/cover; }
.tray__name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tray__bar { height: 3px; background: var(--paper-2); border-radius: 2px; margin-top: 6px; overflow: hidden; }
.tray__bar i { display: block; height: 100%; width: 0; background: var(--olive); transition: width .2s; }
.tray__item.is-done .tray__bar i { background: var(--olive); width: 100%; }
.tray__item.is-error .tray__bar i { background: var(--terracotta); width: 100%; }
.tray__status { color: var(--muted); font-size: 12px; }
.tray__item.is-error .tray__status { color: var(--terracotta-dk); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; top: calc(20px + env(safe-area-inset-top)); transform: translateX(-50%);
  z-index: 60; padding: 10px 18px; border-radius: 999px; background: var(--night); color: #F3ECE1;
  font-size: 14px; box-shadow: 0 10px 30px rgba(22,18,15,.25); max-width: calc(100% - 32px); text-align: center;
}

/* ---------- drop overlay ---------- */
.drop {
  position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; pointer-events: none;
  background: rgba(245,239,228,.9); border: 2px dashed var(--terracotta); margin: 12px; border-radius: 18px;
}
.drop p { font: italic 34px var(--serif); color: var(--terracotta); }

/* ---------- lightbox ---------- */
.lightbox { position: fixed; inset: 0; z-index: 50; background: var(--night); color: #F3ECE1; display: flex; flex-direction: column; }
.lightbox__bar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
}
.lightbox__meta { display: grid; font-size: 13px; line-height: 1.35; min-width: 0; }
.lightbox__meta span:first-child { font: 500 18px var(--serif); }
.lightbox__meta span:last-child { color: #B8AB9B; }
.lightbox__btns { display: flex; gap: 6px; }
.lightbox__stage { position: relative; flex: 1; min-height: 0; padding: 0 12px calc(40px + env(safe-area-inset-bottom)); touch-action: pan-y; display: flex; align-items: center; justify-content: center; }
.lightbox__stage img, .lightbox__stage video { display: block; width: 100%; height: 100%; object-fit: contain; }
.lightbox__stage p { color: #B8AB9B; }
.lightbox__nav {
  position: absolute; top: 50%; transform: translateY(-50%); width: 48px; height: 64px;
  border: 0; background: none; color: #F3ECE1; font-size: 44px; line-height: 1; cursor: pointer; opacity: .6;
}
.lightbox__nav:hover { opacity: 1; }
.lightbox__nav--prev { left: 4px; }
.lightbox__nav--next { right: 4px; }
.lightbox__count { position: absolute; bottom: calc(12px + env(safe-area-inset-bottom)); left: 0; right: 0; text-align: center; font-size: 12px; color: #8F8376; letter-spacing: .1em; }
@media (hover: none) { .lightbox__nav { display: none; } }

@media (max-width: 560px) {
  .brand { flex-direction: column; gap: 2px; }
  .brand__title { font-size: 22px; }
  .brand__place { font-size: 17px; }
  #selectBtn { padding: 0 12px; }
  .btn--primary span { display: none; }
  .topbar__actions .btn--primary { width: 38px; padding: 0; }
  .day__head { flex-direction: column; align-items: flex-start; gap: 8px; }
}
