:root {
  --bg: #f6f2ec;
  --ink: #1d1a17;
  --muted: #7a7068;
  --line: #e2dbd2;
  --tile: #e6dfd6;
  --accent: #c8102e;
  --gap: 6px;
  --maxw: 1400px;
  --serif: 'Shippori Mincho', 'Hiragino Mincho ProN', Georgia, serif;
  --sans: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14110f; --ink: #efe9e2; --muted: #9c9187; --line: #2b2622; --tile: #221e1b; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-padding-top: 64px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ---------- hero ---------- */
#hero { position: relative; height: min(92vh, 900px); min-height: 420px; overflow: hidden; background: #1d1a17; color: #fff; }
.hero-img { position: absolute; inset: 0; background: center/cover no-repeat; transform: scale(1.04); opacity: 0; transition: opacity 1.2s, transform 8s ease-out; }
.hero-img.on { opacity: 1; transform: scale(1); }
.hero-shade { position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.25) 0%, rgba(0,0,0,0) 35%, rgba(0,0,0,.65) 100%); }
.hero-text { position: absolute; left: 0; right: 0; bottom: 0; padding: 0 max(24px, calc((100vw - var(--maxw)) / 2 + 24px)) 56px; }
.sun { width: 34px; height: 34px; border-radius: 50%; background: var(--accent); margin-bottom: 18px; box-shadow: 0 0 40px rgba(200,16,46,.5); }
#title { font: 700 clamp(48px, 9vw, 120px)/0.95 var(--serif); margin: 0; letter-spacing: -0.01em; }
#subtitle { font: 500 clamp(17px, 2vw, 22px)/1.4 var(--serif); margin: 14px 0 0; max-width: 40ch; opacity: .92; }
#fambtn { margin-top: 18px; background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: 7px 16px; font-size: 13px; backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
#fambtn:hover { background: rgba(255,255,255,.24); }
.fam-badge { position: absolute; left: 6px; bottom: 6px; z-index: 2; font-size: 11px; line-height: 1; padding: 4px 6px; border-radius: 999px; background: rgba(20,17,15,.6); color: #fff; pointer-events: none; }
.tools button:disabled { opacity: .5; cursor: default; }
dialog .sub { margin: -6px 0 14px; color: var(--muted); font-size: 13px; }
dialog .sub:empty { display: none; }
#stats { margin: 18px 0 0; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; opacity: .8; }

/* ---------- day nav ---------- */
#daynav { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
body.admin #daynav { top: 44px; }
#daynav .inner { max-width: var(--maxw); margin: 0 auto; display: flex; gap: 4px; overflow-x: auto; padding: 10px 16px; scrollbar-width: none; }
#daynav .inner::-webkit-scrollbar { display: none; }
#daynav a { flex: none; text-decoration: none; color: var(--muted); padding: 6px 12px; border-radius: 999px; font-size: 13px; white-space: nowrap; transition: background .2s, color .2s; }
#daynav a b { color: var(--ink); font-weight: 600; margin-right: 6px; }
#daynav a:hover { background: var(--tile); }
#daynav a.on { background: var(--ink); color: var(--bg); }
#daynav a.on b { color: var(--bg); }

/* ---------- days ---------- */
#days { max-width: var(--maxw); margin: 0 auto; padding: 0 16px 40px; }
.day { padding-top: 72px; }
.day-head { margin: 0 0 22px; }
.day-date { font-size: 12px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.day-date .place::before { content: '·'; margin: 0 8px; }
.day-title { font: 700 clamp(26px, 3.4vw, 40px)/1.1 var(--serif); margin: 0; }
.day-note { margin: 6px 0 0; color: var(--muted); max-width: 70ch; white-space: pre-wrap; }
.day-note:empty:not([contenteditable]) { display: none; }

.feature { position: relative; margin: 0 auto var(--gap); border-radius: 4px; overflow: hidden; background: var(--tile); cursor: zoom-in; }
.feature img { display: block; width: 100%; height: 100%; object-fit: contain; }

.rows { display: flex; flex-direction: column; gap: var(--gap); }
.row { display: flex; gap: var(--gap); }
.tile { position: relative; overflow: hidden; background: var(--tile); border-radius: 3px; cursor: zoom-in; flex-shrink: 0; }
.tile img, .feature img { opacity: 0; transition: opacity .5s; }
.tile img { display: block; width: 100%; height: 100%; object-fit: contain; }  /* tiles match the photo's ratio, so nothing is cropped */
.tile img.ok, .feature img.ok { opacity: 1; }

/* ---------- admin ---------- */
#adminbar { position: sticky; top: 0; z-index: 30; height: 44px; display: flex; align-items: center; gap: 12px; padding: 0 16px; background: #1d1a17; color: #f3ede6; font-size: 13px; }
#adminbar .dot { width: 8px; height: 8px; border-radius: 50%; background: #4ade80; }
#adminbar .hint { color: #a39890; flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
#adminbar button { background: #34302c; border: 0; border-radius: 6px; padding: 5px 10px; }
#adminbar button:hover { background: #48423d; }
#savestate { color: #a39890; }
.tools { position: absolute; top: 6px; right: 6px; display: none; gap: 4px; z-index: 2; }
body.admin .tile:hover .tools, body.admin .feature:hover .tools, body.admin .tools.pinned { display: flex; }
.tools button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(20,17,15,.72); color: #fff; font-size: 15px; line-height: 1; backdrop-filter: blur(4px); }
.tools button:hover { background: rgba(20,17,15,.95); }
.tools button.on { background: var(--accent); }
.tools button.grip { cursor: grab; touch-action: none; }
body.admin .rows .tile { cursor: grab; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none; }
.tile.drag-source { opacity: .35; }
.drop-marker { position: absolute; left: 0; top: 0; width: 4px; border-radius: 2px; background: var(--accent); z-index: 40; pointer-events: none; box-shadow: 0 0 0 2px rgba(255,255,255,.6); }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 200; pointer-events: none; border-radius: 6px; background: center/cover no-repeat var(--tile); box-shadow: 0 12px 32px rgba(0,0,0,.45); opacity: .92; }
.badge { position: absolute; left: 8px; top: 8px; z-index: 2; background: var(--accent); color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 999px; display: none; }
body.admin .is-cover .badge { display: block; }
body.admin .hidden-photo { outline: 2px dashed var(--muted); outline-offset: -2px; }
body.admin .hidden-photo img { opacity: .25 !important; filter: grayscale(1); }
body:not(.admin) .hidden-photo { display: none; }
[contenteditable] { outline: none; border-radius: 4px; box-shadow: 0 0 0 1px transparent; transition: box-shadow .2s; }
[contenteditable]:hover, [contenteditable]:focus { box-shadow: 0 0 0 1px var(--muted); }
#hero [contenteditable]:hover, #hero [contenteditable]:focus { box-shadow: 0 0 0 1px rgba(255,255,255,.6); }
[contenteditable]:empty::before { content: attr(data-placeholder); opacity: .45; }

/* ---------- footer ---------- */
footer { max-width: var(--maxw); margin: 0 auto; padding: 40px 16px 60px; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 13px; }
#login { background: none; border: 1px solid var(--line); width: 32px; height: 32px; border-radius: 50%; color: var(--muted); margin-left: auto; }
#empty { text-align: center; color: var(--muted); padding: 80px 16px; }

/* ---------- lightbox ---------- */
#lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(10,9,8,.96); display: flex; align-items: center; justify-content: center; touch-action: none; }
#lightbox[hidden] { display: none; }
#lightbox img { max-width: 100vw; max-height: calc(100vh - 70px); object-fit: contain; user-select: none; -webkit-user-drag: none; transition: opacity .2s; }
#lightbox button { position: absolute; background: none; border: 0; color: #fff; opacity: .7; font-size: 44px; line-height: 1; padding: 12px 18px; }
#lightbox button:hover { opacity: 1; }
.lb-close { top: 6px; right: 6px; }
.lb-prev { left: 4px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 4px; top: 50%; transform: translateY(-50%); }
.lb-meta { position: absolute; bottom: 0; left: 0; right: 0; padding: 16px 20px calc(16px + env(safe-area-inset-bottom)); color: #cfc6bd; font-size: 13px; text-align: center; letter-spacing: .04em; }
@media (hover: none) { .lb-prev, .lb-next { display: none; } }

/* ---------- dialog ---------- */
dialog { border: 0; border-radius: 12px; padding: 24px; width: min(340px, calc(100vw - 32px)); background: var(--bg); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h2 { font: 700 22px var(--serif); margin: 0 0 14px; }
dialog input { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: transparent; color: inherit; font: inherit; }
dialog .err { color: var(--accent); min-height: 1.5em; margin: 8px 0; font-size: 13px; }
dialog .row { display: flex; flex-direction: row-reverse; justify-content: flex-start; gap: 8px; } /* Unlock first in DOM so Enter submits it */
dialog button { border: 1px solid var(--line); background: transparent; border-radius: 8px; padding: 8px 14px; }
dialog button.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }

@media (max-width: 640px) {
  :root { --gap: 4px; }
  #days { padding: 0 8px 40px; }
  .day { padding-top: 48px; }
  .day-head { margin: 0 4px 16px; }
  #adminbar .hint { display: none; }
}
