@import url("https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;1,400&family=Inter:wght@400;500;600&display=swap");

/* Forget-me-not palette: soft blue on warm paper */
:root {
  --bg: #faf8f3;
  --surface: #ffffff;
  --ink: #27303c;
  --muted: #6c7482;
  --line: #e5e3dd;
  --accent: #4a73b2;
  --accent-ink: #ffffff;
  --accent-soft: #eef3fa;
  --petal: #8db3e2;
  --petal-edge: #7ea5da;
  --silhouette: #b3ab9f;
  --danger: #a33a2a;
  --shadow: 0 1px 2px rgba(40, 50, 70, 0.05), 0 6px 20px rgba(40, 50, 70, 0.06);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171a1f;
    --surface: #20242b;
    --ink: #e8ecf2;
    --muted: #9aa3b0;
    --line: #333944;
    --accent: #9bbbea;
    --accent-ink: #14181e;
    --accent-soft: #232a35;
    --silhouette: #5c6370;
    --danger: #f0a294;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.6 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; width: 100%; }
h1, h2 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 500; letter-spacing: .01em; }

button, .btn {
  font: inherit; font-weight: 500;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  padding: 10px 18px; border-radius: 999px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none;
  min-height: 44px;
}
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
@media (hover: hover) {
  button:not(.primary):not(:disabled):hover, .btn:not(.primary):hover { border-color: var(--accent); }
  button.primary:not(:disabled):hover, .btn.primary:hover { filter: brightness(1.06); }
}
/* Phones: no browser tap flash (Android paints a square blue box, even on top of the photo viewer);
   a gentle pressed look instead (app.js listens for touches so iOS applies :active too). */
button, .btn, a, summary, label { -webkit-tap-highlight-color: transparent; }
button:not(:disabled):active, .btn:active { filter: brightness(.92); }
input, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; width: 100%;
}
input:focus, textarea:focus, button:focus-visible, .btn:focus-visible, summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: block; font-size: 14px; color: var(--muted); margin: 0 0 6px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* small line icons (symbols live at the top of index.html) */
.icons { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- motifs ---------- */
.landing-art { display: block; width: min(320px, 86vw); height: auto; margin: 0 auto 6px; }
.frieze {
  display: flex; align-items: flex-end; justify-content: center; gap: clamp(10px, 3vw, 22px);
  color: var(--silhouette); padding: 28px 16px 10px; flex-wrap: nowrap;
}
.frieze svg { display: block; height: auto; flex: none; }
.frieze .f-hare { width: 40px; }
.frieze .f-pointer { width: 62px; }
.frieze .f-tit { width: 34px; }
.frieze .f-bee { width: 30px; margin-bottom: 8px; }
.frieze .f-fmn { width: 13px; margin-bottom: 4px; opacity: .9; }
.divider { display: flex; justify-content: center; gap: 6px; margin: 14px 0 0; }
.divider svg { width: 14px; height: 14px; }

/* ---------- landing / login ---------- */
.login { flex: 1; display: grid; place-items: center; padding: 32px 16px 8px; }
.login-card { width: 100%; max-width: 380px; text-align: center; }
.login-card h1 { font-size: clamp(42px, 11vw, 54px); margin: 0; line-height: 1.05; }
.login-card .lede { color: var(--muted); margin: 8px 0 28px; }
.login-card form { display: grid; gap: 12px; }
.err { color: var(--danger); min-height: 1.5em; font-size: 14px; }

/* ---------- gallery header ---------- */
header.hero { text-align: center; padding: 40px 16px 28px; }
.cover {
  width: 168px; height: 168px; border-radius: 50%; object-fit: cover;
  margin: 0 auto 18px; display: block; border: 4px solid var(--surface); box-shadow: var(--shadow);
  background: var(--line);
}
header.hero .landing-art { width: min(260px, 70vw); }
header.hero h1 { font-size: clamp(40px, 7vw, 58px); margin: 0; line-height: 1.05; }
header.hero .dates { font-family: "Cormorant Garamond", Georgia, serif; font-size: 22px; color: var(--muted); margin-top: 4px; }
header.hero .intro { max-width: 620px; margin: 14px auto 0; color: var(--muted); white-space: pre-line; }

.bar {
  position: sticky; top: 0; z-index: 5; background: var(--bg);
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); border-bottom: 1px solid var(--line); border-top: 1px solid var(--line);
}
.bar .wrap { display: flex; gap: 10px; align-items: center; justify-content: center; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.bar button { white-space: nowrap; }
@media (max-width: 559px) {
  .bar .wrap > button { flex: 1 1 0; padding-left: 10px; padding-right: 10px; }
  .bar #editBtn { flex-basis: 100%; }
}
/* thin progress line under the bar while uploads are running */
.bar-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 3px; background: var(--line); }
.bar-progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .3s; }
/* Translucent tints where color-mix() works (Safari 16.2+). Guarded rather than given a fallback
   declaration: with var() inside, an unsupported color-mix() would leave the bar see-through. */
@supports (background: color-mix(in srgb, red 50%, transparent)) {
  .bar { background: color-mix(in srgb, var(--bg) 92%, transparent); }
  .bar-progress { background: color-mix(in srgb, var(--accent) 18%, transparent); }
}
main.content { flex: 1; }

/* ---------- panels (upload, download, edit) ---------- */
.panel {
  position: relative; max-width: 760px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 20px; margin: 20px auto;
}
.panel h2 { margin: 0 0 4px; font-size: 28px; padding-right: 40px; }
.panel .hint { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.panel-x { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; padding: 0; border-color: transparent; background: transparent; color: var(--muted); }
.panel-x:hover { color: var(--ink); background: var(--bg); }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 640px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.field-hint { margin: 6px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); }

/* the big "Choose photos & videos" button; on computers it sits in a drop area */
.drop { margin: 16px 0 0; text-align: center; }
button.choose { width: 100%; max-width: 460px; min-height: 58px; font-size: 18px; }
.drop-hint { margin: 10px 0 0; font-size: 14px; color: var(--muted); }
.can-drag { display: none; }
@media (hover: hover) and (pointer: fine) {
  .drop { border: 2px dashed var(--line); border-radius: var(--radius); padding: 22px 16px 16px; }
  .can-drag { display: inline; }
}

/* upload list (the right padding keeps a long list's scrollbar off the Retry buttons) */
.queue { list-style: none; padding: 0 8px 0 0; margin: 14px 0 0; position: relative; max-height: min(62vh, 480px); overflow-y: auto; }
.queue:empty { margin: 0; }
.queue li {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; grid-template-areas: "pv name st" "pv sub st";
  column-gap: 12px; row-gap: 3px; align-items: center; padding: 8px 2px; border-top: 1px solid var(--line);
}
.queue li:first-child { border-top: 0; }
.queue li:focus { outline: none; }
.queue li:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; border-radius: 8px; }
.queue .pv {
  grid-area: pv; width: 44px; height: 44px; border-radius: 8px; overflow: hidden; position: relative;
  background: var(--bg); border: 1px solid var(--line); display: grid; place-items: center; color: var(--muted);
}
.queue .pv img { width: 100%; height: 100%; object-fit: cover; display: block; }
.queue .pv .ic { width: 24px; height: 24px; stroke-width: 1.6; }
.queue .pv.vid::after { content: "▶"; position: absolute; right: 3px; bottom: 1px; font-size: 10px; line-height: 1.4; color: #fff; text-shadow: 0 0 3px rgba(0, 0, 0, .8); }
.queue .name { grid-area: name; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 15px; line-height: 1.35; }
.queue .st { grid-area: st; font-size: 14px; color: var(--muted); text-align: right; min-width: 3.2em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.queue .sub { grid-area: sub; display: flex; align-items: center; gap: 10px; font-size: 13px; line-height: 1.35; color: var(--muted); min-width: 0; }
.queue .size { flex: none; }
.queue .sub .prog { flex: 1; }
.queue .why { display: none; color: var(--danger); }
.queue .retry { grid-area: st; padding: 8px 16px; }
.queue li[data-status="done"] .st { color: var(--accent); display: inline-flex; align-items: center; justify-content: flex-end; gap: 4px; }
.queue .st .ic { width: 16px; height: 16px; stroke-width: 2.4; }
.queue li[data-status="done"] .sub .prog { visibility: hidden; }
.queue li[data-status="failed"] .st, .queue li[data-status="failed"] .sub .prog { display: none; }
.queue li[data-status="failed"] .why { display: inline; }
/* waiting for the connection: the message takes the line under the name */
.queue li[data-status="paused"] { grid-template-areas: "pv name name" "pv st st"; }
.queue li[data-status="paused"] .sub { display: none; }
.queue li[data-status="paused"] .st { text-align: left; white-space: normal; color: var(--accent); }
.prog { height: 4px; background: var(--line); border-radius: 4px; overflow: hidden; }
.prog > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.up-status { margin: 14px 0 0; font-size: 14px; color: var(--muted); }
/* "waiting for the connection" and "still uploading": worth noticing, but nothing has gone wrong */
.up-status.alert { color: var(--ink); background: var(--accent-soft); border-radius: 10px; padding: 10px 14px; }
.summary { margin: 14px 0 0; font-weight: 500; }
.summary > span { display: block; }
.summary .ok { display: flex; align-items: center; gap: 6px; }
.summary .ok .ic { width: 18px; height: 18px; stroke-width: 2.4; color: var(--accent); }
.summary .bad { color: var(--danger); font-weight: 400; }
.summary .note { color: var(--muted); font-weight: 400; }
.up-status:empty, .summary:empty { margin: 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; scroll-margin-bottom: 24px; }
.actions:not(:has(> :not(.hidden))) { margin: 0; }
.actions button { flex: 1 1 160px; }
.tips { margin-top: 16px; font-size: 14px; color: var(--muted); }
.tips p { margin: 0 0 10px; }
.tips p:last-child { margin-bottom: 0; }
.tips .ios-note { color: var(--ink); background: var(--accent-soft); border-radius: 12px; padding: 12px 14px; }

/* download everything */
.parts { display: grid; gap: 10px; }
/* block (not flex) so a long label wraps neatly, centred, with the icon leading the first line */
.parts .part-link { display: block; text-align: center; line-height: 1.45; padding: 11px 18px; }
.part-link .ic { display: inline-block; vertical-align: -4px; margin-right: 8px; }
/* a part already saved (remembered in this browser) */
.part-link .ic.tick { margin: 0 0 0 6px; color: var(--accent); stroke-width: 2.4; }
.part-link.primary .ic.tick { color: inherit; }
.dl-note { margin: 0 0 14px; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); font-size: 14px; }
.tip { margin: 14px 0 0; font-size: 14px; color: var(--muted); }
.missing { margin-top: 16px; padding: 14px 16px; border-radius: 12px; background: var(--accent-soft); font-size: 14px; }
.missing p { margin: 0; }
.which { margin-top: 6px; }
.which summary { cursor: pointer; padding: 8px 0; color: var(--accent); font-weight: 500; }
.which ul { margin: 0; padding-left: 20px; max-height: 200px; overflow: auto; color: var(--muted); overflow-wrap: anywhere; }
.fix-offer { margin-top: 10px; }
.fix-offer .fix-note { color: var(--muted); margin-bottom: 10px; }
.fix { margin-top: 16px; }
.fix .prog { height: 6px; }
.fix-status { margin: 8px 0 0; font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }

/* ---------- gallery ---------- */
.count { text-align: center; color: var(--muted); font-size: 14px; margin: 22px 0 0; }
.count:empty { display: none; }
.gallery {
  display: grid; gap: 8px; margin: 12px 0 40px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
@media (min-width: 700px) { .gallery { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; } }
.tile {
  position: relative; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: var(--line);
  cursor: pointer; border: 0; padding: 0; min-height: 0;
}
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
/* no preview (e.g. HEIC added from a computer, RAW, TIFF): a quiet icon and the file name */
.tile .ph {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
  padding: 12px; color: var(--muted); font-size: 13px; line-height: 1.35; text-align: center;
}
.tile .ph .ic { width: 30px; height: 30px; stroke-width: 1.5; opacity: .75; }
.tile .ph span { overflow-wrap: anywhere; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
.tile .badge { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 12px; padding: 2px 8px; border-radius: 999px; }
/* a gentle ring around photos that have just been added */
.tile.fresh { animation: fresh 3.2s ease-out; }
@keyframes fresh {
  0%, 45% { box-shadow: 0 0 0 3px var(--bg), 0 0 0 6px var(--accent); }
  100% { box-shadow: 0 0 0 3px transparent, 0 0 0 6px transparent; }
}
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.list-error { text-align: center; padding: 32px 0 40px; }
.list-error p { margin: 0 0 16px; text-wrap: balance; }
.empty p { margin: 0 0 16px; }
.index-note { text-align: center; color: var(--muted); padding: 32px 0 40px; }
.index-note p { margin: 0 0 16px; text-wrap: balance; }
.reindex-box { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
/* with the upload panel open, its own big button is the one to press */
main.content:has(#uploadPanel:not(.hidden)) #emptyAdd { display: none; }

/* shown while files are dragged over the page (computers only) */
.drop-overlay {
  position: fixed; inset: 12px; z-index: 40; display: none; align-items: center; justify-content: center;
  padding: 20px; text-align: center; pointer-events: none;
  border: 3px dashed var(--accent); border-radius: 22px; background: var(--bg);
}
@supports (background: color-mix(in srgb, red 50%, transparent)) {
  .drop-overlay { background: color-mix(in srgb, var(--bg) 90%, transparent); }
}
.drop-overlay span { font: 500 clamp(28px, 4vw, 40px)/1.2 "Cormorant Garamond", Georgia, serif; color: var(--ink); }
body.dragging .drop-overlay { display: flex; }

/* ---------- viewer ---------- */
.viewer { position: fixed; inset: 0; background: rgba(12, 14, 18, .95); z-index: 20; display: none; flex-direction: column; color: #fff; }
.viewer.open { display: flex; }
.viewer .stage { flex: 1; display: grid; place-items: center; min-height: 0; padding: 8px; }
.viewer .stage img, .viewer .stage video { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer .stage p { max-width: 420px; text-align: center; color: #d6dbe3; padding: 0 16px; }
.viewer .meta { padding: 12px 16px 16px; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.viewer .meta .info { margin-right: auto; font-size: 14px; color: #cfd5de; }
.viewer .meta .info b { color: #fff; font-weight: 500; }
.viewer button, .viewer .btn { background: rgba(255,255,255,.1); color: #fff; border-color: rgba(255,255,255,.2); }
/* the arrows sit over the photo itself, so they need their own dark backing to show on a light photo */
.viewer .nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(16, 19, 24, .5); border-color: rgba(255, 255, 255, .35); }
.viewer .prev { left: 10px; } .viewer .next { right: 10px; }
.viewer .close { position: absolute; top: 10px; right: 10px; }
.viewer button.danger { color: #ffb4a8; }

footer.site { text-align: center; color: var(--muted); font-size: 13px; padding: 0 16px 28px; }
footer.site a { color: inherit; }
/* Sign out is a button (it signs out with a POST), dressed as the small link it always was */
footer.site .link {
  font: inherit; color: inherit; background: none; border: 0; border-radius: 6px;
  min-height: 44px; padding: 0 10px; text-decoration: underline; text-underline-offset: 2px;
}
@media (hover: hover) { footer.site .link:hover { color: var(--ink); } }
.hidden { display: none !important; }
.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; }
#adminBadge { margin-right: 2px; }
