:root {
  --paper: #f4efe5;
  --paper-deep: #e8dfcf;
  --ink: #24251f;
  --muted: #6d6a61;
  --forest: #1f3a35;
  --forest-soft: #34554d;
  --rust: #b85f3d;
  --line: rgba(36, 37, 31, 0.16);
  --white: #fffdf8;
  --shadow: 0 20px 60px rgba(40, 34, 24, 0.12);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.55;
}
button, input, textarea { font: inherit; }
button { cursor: pointer; }
img { display: block; max-width: 100%; image-orientation: from-image; }
[hidden] { display: none !important; }

.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem clamp(1rem, 4vw, 3.5rem);
  border-bottom: 1px solid rgba(255,255,255,.1);
  color: var(--white);
  background: rgba(31, 58, 53, .96);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: .7rem; color: inherit; text-decoration: none; }
.brand-mark {
  display: grid; place-items: center; width: 2.4rem; aspect-ratio: 1; border: 1px solid rgba(255,255,255,.35);
  border-radius: 50%; font-family: Georgia, "Times New Roman", serif; font-size: .82rem;
}
.brand strong, .brand small { display: block; line-height: 1.1; }
.brand small { margin-top: .22rem; color: rgba(255,255,255,.65); font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; }
.top-actions, .editor-toolbar, .dialog-actions { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.button {
  min-height: 2.75rem; padding: .65rem 1rem; border: 1px solid transparent; border-radius: 999px;
  font-weight: 700; transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.button:hover { transform: translateY(-1px); }
.button:focus-visible, .icon-button:focus-visible, .text-link:focus-visible, .slide-arrow:focus-visible {
  outline: 3px solid #efb77f; outline-offset: 3px;
}
.button-primary { color: var(--white); background: var(--rust); }
.button-primary:hover { background: #a95134; }
.button-quiet { color: inherit; border-color: currentColor; background: transparent; }
.topbar .button-quiet { color: var(--white); border-color: rgba(255,255,255,.3); }
.danger-link { color: #8e2f2f; }

.hero {
  min-height: calc(100svh - 4.4rem); display: grid; grid-template-columns: minmax(0, 1fr) minmax(18rem, .8fr);
  align-items: center; overflow: hidden; padding: clamp(4rem, 9vw, 8rem) clamp(1.25rem, 8vw, 8rem);
  color: var(--white); background: var(--forest);
}
.hero-copy { position: relative; z-index: 2; max-width: 48rem; }
.eyebrow { margin: 0 0 .75rem; color: var(--rust); font-size: .75rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.hero .eyebrow { color: #df9b79; }
h1, h2 { margin: 0; font-family: Georgia, "Times New Roman", serif; line-height: 1.02; }
.hero h1 { max-width: 12ch; font-size: clamp(3.7rem, 9vw, 8.5rem); letter-spacing: -.05em; }
.hero h1 em { color: #df9b79; font-weight: 600; }
.hero-lead { max-width: 39rem; margin: 2rem 0; color: rgba(255,255,255,.72); font-size: clamp(1.05rem, 2vw, 1.35rem); }
.hero-number {
  justify-self: center; color: transparent; font-family: Georgia, "Times New Roman", serif; font-size: clamp(18rem, 42vw, 40rem);
  font-weight: 600; line-height: .7; -webkit-text-stroke: 1px rgba(255,255,255,.14); transform: rotate(-6deg); user-select: none;
}
.text-link { padding: .2rem 0; border: 0; color: inherit; background: none; font-weight: 800; text-decoration: underline; text-decoration-color: var(--rust); text-underline-offset: .35rem; }

.story-section { padding: clamp(4rem, 8vw, 8rem) clamp(1.1rem, 7vw, 7rem); }
.section-heading { max-width: 48rem; margin-bottom: clamp(3rem, 7vw, 6rem); }
.section-heading h2 { max-width: 15ch; font-size: clamp(2.5rem, 6vw, 5rem); letter-spacing: -.035em; }
.section-heading > p:last-child { color: var(--muted); }
.timeline { position: relative; max-width: 88rem; margin-inline: auto; }
.timeline::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--line); }
.moment {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: clamp(3rem, 8vw, 8rem); align-items: center;
  min-height: 70vh; padding: clamp(2.5rem, 6vw, 6rem) 0;
}
.moment::after { content: ""; position: absolute; left: calc(50% - .4rem); width: .8rem; aspect-ratio: 1; border: .2rem solid var(--paper); border-radius: 50%; background: var(--rust); }
.moment:nth-child(even) .moment-image { order: 2; }
.moment:nth-child(even) .moment-copy { order: 1; text-align: right; }
.moment-image {
  position: relative; display: grid; place-items: center; height: min(66vh, 46rem); min-height: 26rem; overflow: hidden; border: .65rem solid var(--white);
  background: var(--paper-deep); box-shadow: var(--shadow); transform: rotate(-1.2deg);
}
.moment:nth-child(even) .moment-image { transform: rotate(1.2deg); }
.moment-image img { transition: transform .25s ease; }
.moment-copy { max-width: 30rem; }
.moment-copy .year { margin: 0 0 .8rem; color: var(--rust); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.moment-copy h3 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 4.5vw, 4rem); line-height: 1.05; }
.moment-copy .caption { margin-top: 1.2rem; color: var(--muted); font-size: 1.05rem; white-space: pre-wrap; }
.moment-copy .placeholder-copy { font-style: italic; opacity: .74; }

.editor { min-height: 100vh; padding: clamp(2rem, 5vw, 5rem) clamp(1rem, 5vw, 5rem); }
.editor-heading { display: flex; justify-content: space-between; gap: 2rem; align-items: end; margin: 0 auto 2rem; max-width: 92rem; }
.editor-heading h1 { font-size: clamp(2.5rem, 6vw, 5rem); }
.editor-heading > div > p:last-child { color: var(--muted); }
.save-status { padding: .5rem .8rem; border-radius: 999px; color: var(--forest); background: rgba(31,58,53,.1); font-size: .78rem; font-weight: 800; white-space: nowrap; }
.save-status.is-error { color: #8e2f2f; background: rgba(142,47,47,.1); }
.editor-toolbar { max-width: 92rem; margin: 0 auto 1.3rem; }
.editor-toolbar .button-quiet { border-color: var(--line); }
.editor-tabs {
  display: inline-flex; gap: .35rem; max-width: 92rem; margin: 0 auto 1.5rem; padding: .35rem;
  border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.42);
}
.editor-tab {
  display: flex; align-items: center; gap: .55rem; min-height: 2.8rem; padding: .55rem .9rem; border: 0;
  border-radius: 999px; color: var(--muted); background: transparent; font-weight: 800;
}
.editor-tab span { display: grid; place-items: center; min-width: 1.7rem; height: 1.7rem; padding: 0 .4rem; border-radius: 999px; background: var(--paper-deep); font-size: .75rem; }
.editor-tab.is-active { color: var(--white); background: var(--forest); }
.editor-tab.is-active span { color: var(--forest); background: var(--white); }
#storyPanel, #bankPanel { max-width: 92rem; margin: auto; }
.editor-tip {
  display: flex; gap: .8rem; align-items: center; margin: 0 auto 2rem; padding: 1rem 1.15rem;
  border-left: .25rem solid var(--rust); background: rgba(255,255,255,.45);
}
.bank-tip { border-left-color: var(--forest-soft); }
.editor-tip > span { color: var(--rust); font-size: 1.5rem; }
.editor-tip p { margin: 0; }
.editor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; max-width: 92rem; margin: auto; }
.editor-card {
  position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 1rem; background: rgba(255,253,248,.78);
  box-shadow: 0 7px 25px rgba(40,34,24,.05); transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease;
}
.editor-card[draggable="true"] { cursor: grab; }
.editor-card.dragging { opacity: .45; transform: scale(.97); }
.editor-card.drop-target { box-shadow: 0 0 0 4px rgba(184,95,61,.35); }
.editor-card.is-hidden { opacity: .62; }
.card-image { display: grid; place-items: center; height: 13rem; overflow: hidden; background: #d8d0c3; }
.card-image img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 1rem; }
.card-index { color: var(--rust); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.card-body h3 { overflow: hidden; margin: .25rem 0; font-size: 1rem; text-overflow: ellipsis; white-space: nowrap; }
.card-body p { overflow: hidden; margin: 0; color: var(--muted); font-size: .85rem; text-overflow: ellipsis; white-space: nowrap; }
.card-actions { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: .35rem; padding: 0 1rem 1rem; }
.card-actions button { min-height: 2.4rem; border: 1px solid var(--line); border-radius: .65rem; color: var(--ink); background: transparent; font-weight: 700; }
.card-actions button:hover { background: var(--paper-deep); }
.card-edit { grid-column: span 3; color: var(--white) !important; border-color: var(--forest) !important; background: var(--forest) !important; }
.card-remove { grid-column: span 3; color: var(--rust) !important; }
.empty-state { padding: 2rem; border: 1px dashed var(--line); border-radius: 1rem; color: var(--muted); text-align: center; }
.editor-empty { grid-column: 1 / -1; padding: 4rem 2rem; }

.bank-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .9rem; }
.bank-card { overflow: hidden; border: 2px solid transparent; border-radius: 1rem; background: rgba(255,253,248,.78); box-shadow: 0 7px 25px rgba(40,34,24,.05); }
.bank-card.is-selected { border-color: var(--forest-soft); }
.bank-image { position: relative; display: grid; place-items: center; height: 11rem; overflow: hidden; background: #d8d0c3; }
.bank-image img { width: 100%; height: 100%; object-fit: cover; }
.bank-badge { position: absolute; top: .6rem; left: .6rem; padding: .32rem .55rem; border-radius: 999px; color: var(--white); background: rgba(31,58,53,.88); font-size: .66rem; font-weight: 800; }
.bank-card:not(.is-selected) .bank-badge { color: var(--ink); background: rgba(255,253,248,.9); }
.bank-card-body { display: grid; grid-template-columns: 1fr auto; gap: .75rem; align-items: center; padding: .85rem; }
.bank-card-body h3 { overflow: hidden; margin: 0; font-size: .92rem; text-overflow: ellipsis; white-space: nowrap; }
.bank-card-body p { margin: .15rem 0 0; color: var(--muted); font-size: .75rem; }
.bank-select, .bank-edit { min-height: 2.3rem; padding: .45rem .65rem; border: 1px solid var(--line); border-radius: .65rem; background: transparent; font-weight: 800; }
.bank-select.is-selected { color: var(--white); border-color: var(--forest); background: var(--forest); }
.bank-edit { grid-column: 1 / -1; }

.edit-dialog { width: min(44rem, calc(100% - 1.5rem)); max-height: 92vh; padding: 0; overflow: auto; border: 0; border-radius: 1.25rem; background: var(--white); box-shadow: var(--shadow); }
.edit-dialog::backdrop { background: rgba(20,29,26,.74); backdrop-filter: blur(6px); }
.edit-dialog form { padding: clamp(1rem, 4vw, 2rem); }
.dialog-heading { display: flex; justify-content: space-between; gap: 1rem; align-items: start; margin-bottom: 1rem; }
.dialog-heading h2 { font-size: 2.25rem; }
.icon-button { width: 2.6rem; aspect-ratio: 1; border: 1px solid var(--line); border-radius: 50%; background: transparent; font-size: 1.7rem; line-height: 1; }
.dialog-preview { display: grid; place-items: center; height: 17rem; margin: 1rem 0 1.5rem; overflow: hidden; border-radius: .8rem; background: var(--paper-deep); }
.dialog-preview img { max-width: none; max-height: none; }
.edit-dialog label { display: grid; gap: .4rem; margin-bottom: 1rem; font-size: .82rem; font-weight: 800; }
.edit-dialog input, .edit-dialog textarea { width: 100%; padding: .85rem; border: 1px solid var(--line); border-radius: .65rem; color: var(--ink); background: white; }
.edit-dialog textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: 9rem 1fr; gap: 1rem; }
.edit-dialog .checkbox-row { display: flex; align-items: center; }
.checkbox-row input { width: auto; }
.dialog-actions { justify-content: flex-end; }

.presentation { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; overflow: hidden; color: var(--white); background: #101915; }
.presentation-top { position: absolute; z-index: 3; top: 1.1rem; right: 1.2rem; left: 1.2rem; display: flex; align-items: center; justify-content: space-between; color: rgba(255,255,255,.68); }
.presentation-close { width: 3rem; aspect-ratio: 1; border: 1px solid rgba(255,255,255,.25); border-radius: 50%; color: white; background: rgba(255,255,255,.08); font-size: 2rem; line-height: 1; }
.slide { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(18rem, .7fr); align-items: center; width: min(94vw, 96rem); height: min(86vh, 58rem); margin: 0; }
.slide-image-frame { display: grid; place-items: center; min-height: 0; height: 100%; overflow: hidden; background: rgba(255,255,255,.04); }
.slide-image-frame img { max-width: none; max-height: none; will-change: width, height, transform; }
.slide figcaption { padding: clamp(2rem, 5vw, 5rem); }
.slide-year { color: #df9b79; font-size: .75rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.slide h2 { font-size: clamp(2.2rem, 5vw, 5.5rem); }
.slide figcaption > p:last-child { color: rgba(255,255,255,.68); font-size: 1.08rem; white-space: pre-wrap; }
.slide-arrow { position: absolute; z-index: 3; top: 50%; width: 3.5rem; height: 5rem; border: 0; color: white; background: rgba(255,255,255,.08); font-size: 3rem; transform: translateY(-50%); }
.slide-prev { left: 0; border-radius: 0 1rem 1rem 0; }
.slide-next { right: 0; border-radius: 1rem 0 0 1rem; }
.presentation-progress { position: absolute; right: 0; bottom: 0; left: 0; height: .25rem; background: rgba(255,255,255,.1); }
.presentation-progress span { display: block; height: 100%; background: var(--rust); transition: width .25s ease; }

footer { display: flex; justify-content: space-between; gap: 1rem; align-items: center; padding: 2rem clamp(1.2rem, 7vw, 7rem); color: rgba(255,255,255,.7); background: var(--forest); }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; }
  .hero-number { position: absolute; right: -2rem; opacity: .6; }
  .timeline::before { left: .38rem; }
  .moment { grid-template-columns: 1fr; min-height: auto; padding: 3rem 0 3rem 2.2rem; }
  .moment::after { left: 0; top: 6rem; }
  .moment:nth-child(even) .moment-image, .moment:nth-child(even) .moment-copy { order: initial; text-align: left; }
  .moment-image, .moment:nth-child(even) .moment-image { height: min(62vh, 38rem); min-height: 20rem; transform: rotate(0); }
  .slide { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1.5fr) auto; height: 88vh; }
  .slide figcaption { padding: 1.25rem 3.5rem 1.5rem; text-align: center; }
  .slide figcaption > p:last-child { max-height: 5rem; overflow: auto; }
  .slide h2 { font-size: clamp(1.8rem, 8vw, 3rem); }
  .editor-heading { display: block; }
  .save-status { display: inline-block; margin-top: .75rem; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; }
  .brand small { display: none; }
  .top-actions { justify-content: flex-end; }
  .button { min-height: 2.55rem; padding-inline: .8rem; font-size: .82rem; }
  .topbar .button-primary { display: none; }
  .hero { min-height: 82svh; }
  .hero h1 { font-size: clamp(3.3rem, 18vw, 5.5rem); }
  .story-section { padding-inline: .8rem; }
  .form-row { grid-template-columns: 1fr; gap: 0; }
  .editor-grid { grid-template-columns: 1fr; }
  .bank-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .bank-card-body { grid-template-columns: 1fr; }
  .bank-select, .bank-edit { width: 100%; }
  footer { align-items: flex-start; flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
