:root {
  --slate-900: #2c3d49;
  --slate-700: #3c4e5b;
  --slate-500: #526776;
  --mist: #edf4f9;
  --line: #d3dee6;
  --orange: #ed673c;
  --orange-deep: #c9521a;
  --paper: #ffffff;
  --danger: #b3261e;
  --display: 'Montserrat', 'Helvetica Neue', Arial, sans-serif;
  --body: 'Open Sans', 'Helvetica Neue', Arial, sans-serif;
  --measure: 44rem;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--body);
  font-size: 1.0625rem;
  line-height: 1.55;
  color: var(--slate-900);
  background: var(--paper);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.12; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.9rem, 6vw, 2.6rem); }
h2 { font-size: 1.25rem; }
p { margin: 0; }
a { color: var(--orange-deep); }

:focus-visible { outline: 3px solid var(--orange); outline-offset: 2px; }

/* ---------- masthead ---------- */

.masthead { background: var(--slate-900); color: #fff; border-bottom: 5px solid var(--orange); }
.masthead-inner {
  max-width: var(--measure); margin: 0 auto; padding: 0.9rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.logo { height: 2.6rem; width: auto; display: block; }
.masthead-title { font-family: var(--display); font-weight: 700; font-size: 0.95rem; color: #c9d6df; }
.masthead a { color: #c9d6df; }

.rail { background: var(--slate-700); }
.rail ol {
  list-style: none; margin: 0 auto; padding: 0 0.5rem; max-width: var(--measure);
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.rail button {
  width: 100%; background: none; border: 0; color: #b9c8d2; cursor: pointer;
  font: 700 0.9rem var(--display); padding: 0.7rem 0.25rem;
  display: flex; align-items: center; justify-content: center; gap: 0.5rem;
  border-bottom: 4px solid transparent;
}
.rail-num {
  width: 1.6rem; height: 1.6rem; border-radius: 50%; border: 2px solid currentColor;
  display: grid; place-items: center; font-size: 0.8rem; flex: none;
}
.rail li[data-state="current"] button { color: #fff; border-bottom-color: var(--orange); }
.rail li[data-state="current"] .rail-num { background: var(--orange); border-color: var(--orange); color: var(--slate-900); }
.rail li[data-state="done"] button { color: #fff; }
.rail li[data-state="done"] .rail-num { background: #fff; border-color: #fff; color: var(--slate-900); }
@media (max-width: 26rem) { .rail-label { font-size: 0.8rem; } .rail button { flex-direction: column; gap: 0.2rem; } }

/* ---------- layout ---------- */

main { flex: 1; width: 100%; max-width: var(--measure); margin: 0 auto; padding: 2rem 1.25rem 3rem; }
.panel > h1 { margin-bottom: 0.6rem; }
.lede { color: var(--slate-500); max-width: 36rem; margin-bottom: 2rem; }
.hint { color: var(--slate-500); font-size: 0.92rem; margin-top: 0.4rem; }
.error { color: var(--danger); font-weight: 600; margin-top: 0.6rem; }

/* ---------- fields ---------- */

.field { margin: 0 0 1.5rem; padding: 0; border: 0; min-width: 0; }
.field-pair { display: grid; gap: 0 1rem; }
@media (min-width: 36rem) { .field-pair { grid-template-columns: 1fr 1fr; } }

label, legend { display: block; font-weight: 700; margin-bottom: 0.4rem; padding: 0; }
.optional { font-weight: 400; color: var(--slate-500); font-size: 0.9rem; margin-left: 0.35rem; }

input[type="text"], input[type="url"], input[type="month"], input[type="password"], select, textarea {
  width: 100%; font: inherit; color: inherit; background: #fff;
  border: 2px solid var(--line); border-radius: 6px; padding: 0.7rem 0.8rem; min-height: 3rem;
  appearance: none; -webkit-appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%232c3d49' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 0.9rem center; background-size: 0.75rem; padding-right: 2.4rem;
}
textarea { resize: vertical; line-height: 1.5; min-height: 5.5rem; max-height: 60vh; field-sizing: content; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--slate-700); box-shadow: 0 0 0 3px rgba(237, 103, 60, 0.35); }
::placeholder { color: #8a9aa6; opacity: 1; }
.invalid { border-color: var(--danger) !important; }
textarea.filled-by-voice { animation: voice-fill 1.6s ease-out; }
@keyframes voice-fill { from { background: #fde3d8; } to { background: #fff; } }

.combo { position: relative; }
.combo-list {
  position: absolute; z-index: 5; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 0.3rem; list-style: none;
  background: #fff; border: 2px solid var(--slate-700); border-radius: 6px; max-height: 16rem; overflow-y: auto;
  box-shadow: 0 8px 20px rgba(44, 61, 73, 0.22);
}
.combo-list li { padding: 0.6rem 0.7rem; border-radius: 4px; cursor: pointer; display: flex; justify-content: space-between; gap: 1rem; }
.combo-list li span { color: var(--slate-500); }
.combo-list li[aria-selected="true"] { background: var(--slate-900); color: #fff; }
.combo-list li[aria-selected="true"] span { color: #c9d6df; }
.combo-list .combo-empty { color: var(--slate-500); cursor: default; }

.chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.chip {
  font: 600 0.95rem var(--body); color: var(--slate-900); background: #fff; cursor: pointer;
  border: 2px solid var(--line); border-radius: 999px; padding: 0.5rem 0.95rem; min-height: 2.75rem;
}
.chip[aria-pressed="true"] { background: var(--slate-900); border-color: var(--slate-900); color: #fff; }

/* ---------- buttons ---------- */

.btn {
  font: 700 1rem var(--display); border-radius: 6px; border: 2px solid transparent; cursor: pointer;
  padding: 0.75rem 1.4rem; min-height: 3rem; text-decoration: none; display: inline-flex; align-items: center; justify-content: center;
}
.btn.primary { background: var(--orange-deep); color: #fff; }
.btn.primary:hover { background: #b34714; }
.btn.ghost { background: #fff; color: var(--slate-900); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--slate-500); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.small { min-height: 2.4rem; padding: 0.4rem 0.9rem; font-size: 0.9rem; }
.link-btn { font: inherit; font-weight: 600; color: var(--orange-deep); background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; }

.actions { position: sticky; bottom: 0; background: #fff; border-top: 2px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.actions-inner { max-width: var(--measure); margin: 0 auto; padding: 0.75rem 1.25rem; display: flex; align-items: center; gap: 1rem; }
.save-state { flex: 1; text-align: center; color: var(--slate-500); font-size: 0.88rem; }
.actions .btn { white-space: nowrap; }
@media (max-width: 26rem) { .actions-inner { gap: 0.6rem; } .actions .btn { padding-inline: 1rem; } .save-state { font-size: 0.78rem; } }

/* ---------- login ---------- */

.login { max-width: 26rem; }
.login-row { display: flex; gap: 0.6rem; }
.login-row input { flex: 1; min-width: 0; }

/* ---------- photos ---------- */

.dropzone {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.2rem;
  border: 3px dashed var(--slate-500); border-radius: 10px; background: var(--mist);
  padding: 2.2rem 1rem; cursor: pointer; text-align: center; margin: 0 0 1rem; position: relative;
}
.dropzone input, .memo-upload input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.dropzone:focus-within { outline: 3px solid var(--orange); outline-offset: 2px; }
.dropzone.over { background: #fde3d8; border-color: var(--orange-deep); }
.dropzone-title { font: 800 1.35rem var(--display); }
.dropzone-hint { color: var(--slate-500); font-weight: 400; }

.photos { list-style: none; padding: 0; margin: 1rem 0 2rem; display: grid; gap: 0.9rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.photo .caption {
  border: 0; border-top: 2px solid var(--line); border-radius: 0; min-height: 4.2rem; resize: none;
  padding: 0.6rem 0.7rem; font-size: 0.98rem; field-sizing: fixed;
}
.photo .caption:focus { box-shadow: inset 0 0 0 3px rgba(237, 103, 60, 0.45); }
.photo .caption.invalid { box-shadow: inset 0 0 0 2px var(--danger); background: #fdf1f0; }
.photo { border: 2px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.photo[data-best="true"] { border-color: var(--orange); }
.photo-frame { position: relative; aspect-ratio: 4 / 3; background: var(--mist); display: grid; place-items: center; }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-fallback { padding: 0.5rem; font-size: 0.8rem; color: var(--slate-500); text-align: center; word-break: break-all; }
.photo-progress { position: absolute; left: 0; right: 0; bottom: 0; height: 6px; background: rgba(44, 61, 73, 0.25); }
.photo-progress span { display: block; height: 100%; background: var(--orange); width: 0; transition: width 0.2s; }
.photo-note { position: absolute; inset: auto 0 0 0; background: rgba(44, 61, 73, 0.85); color: #fff; font-size: 0.8rem; padding: 0.3rem 0.5rem; }
.photo-tools { position: absolute; top: 0.35rem; right: 0.35rem; left: 0.35rem; display: flex; justify-content: space-between; }
.icon-btn {
  width: 2.4rem; height: 2.4rem; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, 0.94); color: var(--slate-900); display: grid; place-items: center; padding: 0;
  box-shadow: 0 1px 3px rgba(44, 61, 73, 0.4);
}
.icon-btn svg { width: 1.2rem; height: 1.2rem; }
.icon-btn.star[aria-pressed="true"] { background: var(--orange); color: #fff; }
.stage { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 2px solid var(--line); }
.stage button {
  font: 600 0.82rem var(--body); background: #fff; color: var(--slate-500); border: 0; border-left: 2px solid var(--line);
  padding: 0.55rem 0; cursor: pointer; min-height: 2.6rem;
}
.stage button:first-child { border-left: 0; }
.stage button[aria-pressed="true"] { background: var(--slate-900); color: #fff; }

/* ---------- recorder ---------- */

.recorder { background: var(--slate-900); color: #fff; border-radius: 10px; padding: 1.4rem 1.25rem; margin-bottom: 2rem; }
.recorder-main { display: flex; align-items: center; gap: 1.1rem; }
.rec-btn {
  position: relative; flex: none; width: 5.25rem; height: 5.25rem; border-radius: 50%; cursor: pointer;
  background: #fff; border: 0; display: grid; place-items: center; padding: 0;
}
.rec-btn { color: var(--orange-deep); }
.rec-mic { width: 2.9rem; height: 2.9rem; }
.rec-stop { display: none; width: 1.9rem; height: 1.9rem; border-radius: 6px; background: var(--orange-deep); }
.rec-ring { position: absolute; inset: -6px; border-radius: 50%; border: 4px solid var(--orange); opacity: 0; transform: scale(1); }
.recorder[data-state="recording"] .rec-mic { display: none; }
.recorder[data-state="recording"] .rec-stop { display: block; }
.recorder[data-state="recording"] .rec-ring { opacity: 0.9; }
.recorder[data-state="working"] .rec-btn { opacity: 0.5; cursor: default; }
.recorder[data-state="working"] .rec-mic { animation: pulse 1.1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(0.8); opacity: 0.6; } }
.recorder-status { font: 800 1.3rem var(--display); font-variant-numeric: tabular-nums; }
.recorder-sub { color: #b9c8d2; font-size: 0.95rem; }
.prompts { margin: 1.2rem 0 0; padding: 1rem 0 0 1.2rem; border-top: 1px solid rgba(255, 255, 255, 0.18); color: #dbe5ec; font-size: 0.97rem; }
.prompts li { margin-bottom: 0.3rem; }
.recorder .error { color: #ffb4a3; }
.recordings { list-style: none; margin: 1rem 0 0; padding: 0; display: grid; gap: 0.6rem; }
.recordings li { background: rgba(255, 255, 255, 0.08); border-radius: 8px; padding: 0.6rem 0.7rem; display: flex; flex-wrap: wrap; align-items: center; gap: 0.6rem; }
.recordings audio { flex: 1; min-width: 12rem; height: 2.4rem; }
.recordings .rec-note { flex-basis: 100%; color: #ffd0c2; font-size: 0.9rem; }
.recorder .link-btn { color: #ffb79e; display: inline-block; margin-top: 1rem; position: relative; }

/* ---------- review + admin detail ---------- */

.summary { border-top: 2px solid var(--line); padding: 1.1rem 0; }
.summary-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 0.6rem; }
.facts { margin: 0; display: grid; grid-template-columns: minmax(7rem, max-content) 1fr; gap: 0.3rem 1rem; }
.facts dt { color: var(--slate-500); }
.facts dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.missing { color: var(--danger); font-weight: 600; }
.story-block { margin-top: 0.9rem; }
.story-block h3 { font-size: 0.95rem; margin-bottom: 0.2rem; }
.story-block p { white-space: pre-wrap; overflow-wrap: anywhere; }
.strip { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.strip img { width: 4.5rem; height: 3.4rem; object-fit: cover; border-radius: 4px; background: var(--mist); }

/* ---------- admin ---------- */

.admin-main { max-width: 68rem; }
.admin-bar { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.project-list { list-style: none; margin: 0; padding: 0; border-top: 2px solid var(--line); }
.project-list li a {
  display: grid; grid-template-columns: 6rem 1fr auto; gap: 1rem; align-items: center;
  padding: 0.8rem 0; border-bottom: 2px solid var(--line); color: inherit; text-decoration: none;
}
.project-list li a:hover .pl-name { color: var(--orange-deep); }
.pl-cover { width: 6rem; height: 4.5rem; object-fit: cover; border-radius: 4px; background: var(--mist); display: block; }
.pl-name { font: 800 1.1rem var(--display); }
.pl-meta { color: var(--slate-500); font-size: 0.92rem; }
.badge { font-size: 0.8rem; font-weight: 700; padding: 0.15rem 0.6rem; border-radius: 999px; background: var(--mist); color: var(--slate-700); white-space: nowrap; }
.badge.new { background: var(--slate-900); color: #fff; }
.gallery { list-style: none; padding: 0; margin: 0.6rem 0 0; display: grid; gap: 0.8rem; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); }
.gallery a { display: block; }
.gallery img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: 6px; background: var(--mist); display: block; }
.gallery figcaption { font-size: 0.85rem; color: var(--slate-500); margin-top: 0.25rem; overflow-wrap: anywhere; }
.gallery figure { margin: 0; }
.admin-detail audio { width: 100%; max-width: 30rem; display: block; margin: 0.4rem 0; }
.detail-actions { display: flex; gap: 0.6rem; flex-wrap: wrap; margin: 1rem 0 1.5rem; }
.empty { padding: 3rem 0; color: var(--slate-500); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
