:root {
  color-scheme: dark;
  --bg: #08090d;
  --panel: #12141b;
  --panel-2: #191c24;
  --panel-3: #101820;
  --text: #f3efe6;
  --muted: #b7afa1;
  --line: rgba(255, 255, 255, 0.12);
  --gold: #c7a75d;
  --gold-2: #ead29a;
  --sky: #8fc7d9;
  --olive: #7f9b6d;
  --red: #b65a5a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% 0%, rgba(143, 199, 217, 0.13), transparent 30rem),
    radial-gradient(circle at 82% 8%, rgba(199, 167, 93, 0.14), transparent 24rem),
    linear-gradient(180deg, #08090d 0%, #101820 52%, #0b0d11 100%);
  color: var(--text);
  font-family: Inter, "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  line-height: 1.6;
}

a { color: var(--gold-2); text-decoration: none; }
a:hover { text-decoration: underline; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(8, 9, 13, 0.86);
  backdrop-filter: blur(18px);
}

.brand {
  display: grid;
  gap: 0;
  color: var(--text);
}

.brand .kicker {
  color: var(--sky);
  font-size: 12px;
  text-transform: uppercase;
}

.brand span:not(.kicker) {
  font-size: 22px;
  font-weight: 700;
}

.brand small { color: var(--muted); }

nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.nav-button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  min-width: 104px;
  padding: 8px 12px;
  border: 1px solid rgba(143, 199, 217, 0.28);
  border-radius: 8px;
  background: rgba(143, 199, 217, 0.08);
  color: var(--text);
  text-align: center;
  line-height: 1.15;
}

.nav-button:hover {
  border-color: rgba(234, 210, 154, 0.55);
  background: rgba(234, 210, 154, 0.1);
  text-decoration: none;
}

.nav-button.primary {
  border-color: rgba(234, 210, 154, 0.62);
  background: rgba(199, 167, 93, 0.18);
  color: var(--gold-2);
}

.nav-button small,
.button small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 64px;
}

.book-mode {
  overflow: hidden;
}

.book-mode .site-header {
  position: static;
  padding-top: 10px;
  padding-bottom: 10px;
}

.book-mode main {
  width: min(1180px, calc(100% - 28px));
  height: calc(100vh - 86px);
  padding: 10px 0 14px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  overflow: hidden;
}

.hero {
  min-height: 52vh;
  display: grid;
  grid-template-columns: minmax(240px, 380px) minmax(0, 1fr);
  align-items: center;
  gap: clamp(28px, 5vw, 64px);
  padding: 56px 0 36px;
}

.hero-text {
  text-align: left;
}

.portrait-wrap {
  position: relative;
}

.portrait-wrap::before {
  content: "";
  position: absolute;
  inset: 18px -14px -18px 14px;
  border: 1px solid rgba(143, 199, 217, 0.36);
  border-radius: 8px;
}

.portrait {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: center 28%;
  border-radius: 8px;
  border: 1px solid rgba(234, 210, 154, 0.48);
  box-shadow: 0 28px 90px rgba(0,0,0,0.42);
}

.eyebrow, .muted {
  color: var(--muted);
}

.eyebrow {
  letter-spacing: 0;
  text-transform: uppercase;
  color: var(--sky);
  font-size: 13px;
}

.hero h1 {
  margin: 10px 0 18px;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: clamp(42px, 9vw, 92px);
  line-height: 1.02;
  font-weight: 500;
}

.hero h1 span {
  color: var(--gold-2);
}

.hero h1 small {
  display: block;
  margin-top: 12px;
  font-size: clamp(22px, 3vw, 34px);
  color: var(--muted);
}

.hero-copy {
  max-width: 720px;
  margin: 0 0 8px;
  color: #ded7cc;
  font-size: 18px;
}

.scripture {
  margin: 0 0 2px;
  color: var(--gold-2);
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: clamp(21px, 3vw, 31px);
}

.scripture-ref {
  margin: 0 0 18px;
  color: var(--sky);
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.book-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 22px;
}

.zh { color: var(--muted); }

.share-band {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 0 0 20px;
  padding: 18px 20px;
  border-top: 1px solid rgba(143, 199, 217, 0.22);
  border-bottom: 1px solid rgba(143, 199, 217, 0.22);
  background: rgba(143, 199, 217, 0.06);
}

.share-band p {
  margin: 4px 0 0;
  color: var(--muted);
}

.toolbar, .panel {
  background: linear-gradient(180deg, rgba(255,255,255,0.058), rgba(143, 199, 217, 0.025));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.22);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}

.memory-card {
  display: block;
  overflow: hidden;
  min-height: 310px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, var(--panel), var(--panel-3));
  color: var(--text);
  transition: transform 160ms ease, border-color 160ms ease;
}

.memory-card:hover {
  transform: translateY(-2px);
  border-color: rgba(143, 199, 217, 0.52);
  text-decoration: none;
}

.card-photo {
  height: 190px;
  background: var(--panel-2);
}

.card-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-placeholder {
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--sky);
  text-align: center;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: 28px;
}

.card-body { padding: 18px; }
.card-body h2 { margin: 0 0 8px; font-size: 20px; }
.card-body p { margin: 0; color: var(--muted); }

.panel {
  margin-bottom: 20px;
}

.panel.narrow {
  max-width: 520px;
  margin: 36px auto;
}

.panel h1, .panel h2 {
  margin-top: 0;
}

.lead {
  max-width: 760px;
  color: #ded7cc;
  font-size: 18px;
}

.email-addresses {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin: 22px 0;
}

.email-addresses a {
  display: block;
  padding: 16px;
  border: 1px solid rgba(234, 210, 154, 0.36);
  border-radius: 8px;
  background: rgba(234, 210, 154, 0.08);
  color: var(--gold-2);
  overflow-wrap: anywhere;
}

.instruction-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.instruction-grid ol {
  margin-bottom: 0;
  padding-left: 22px;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #090b10;
  color: var(--text);
  padding: 12px 14px;
  font: inherit;
}

textarea { resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.button, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #1a1d25;
  color: var(--text);
  padding: 9px 14px;
  font: inherit;
  cursor: pointer;
  text-align: center;
}

.button.small {
  min-height: 34px;
  padding: 7px 11px;
  font-size: 14px;
}

.button.primary, button.primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #18130a;
  font-weight: 700;
}

.post-nav {
  margin: 24px 0 0;
}

.bottom-nav {
  margin-top: 22px;
}

.back-button {
  min-width: min(100%, 340px);
  box-shadow: 0 10px 26px rgba(199, 167, 93, 0.16);
}

.button.danger, button.danger {
  background: rgba(182, 90, 90, 0.12);
  border-color: rgba(182, 90, 90, 0.55);
  color: #ffd2d2;
}

.user-pill, .status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  font-size: 13px;
}

.status-badge {
  color: var(--gold-2);
  border-color: rgba(199, 167, 93, 0.45);
}

.notice, .flash {
  padding: 12px 14px;
  border: 1px solid rgba(199, 167, 93, 0.35);
  border-radius: 8px;
  background: rgba(199, 167, 93, 0.1);
}

.post-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.control-row, .actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.control-row form, .actions form { margin: 0; }

.photo-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
  margin: 18px 0;
}

.photo-strip img {
  width: 100%;
  max-height: 460px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--line);
}

.message {
  font-size: 18px;
  white-space: normal;
}

.memory-flow::after {
  content: "";
  display: block;
  clear: both;
}

.memory-inline-photo {
  float: left;
  width: min(42%, 320px);
  max-height: 420px;
  object-fit: cover;
  margin: 4px 22px 14px 0;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
}

.additional-photos {
  clear: both;
  margin-top: 22px;
}

@media (max-width: 720px) {
  .memory-inline-photo {
    float: none;
    display: block;
    width: 100%;
    max-height: 360px;
    margin: 0 0 16px;
  }
}

.book-intro {
  padding: 32px 0 18px;
}

.book-mode .book-intro {
  padding: 0;
}

.book-intro h1 {
  max-width: 820px;
  margin: 8px 0 10px;
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: clamp(34px, 6vw, 64px);
  line-height: 1.08;
  font-weight: 500;
}

.book-mode .book-intro h1 {
  margin: 2px 0 4px;
  font-size: clamp(26px, 4vh, 42px);
}

.book-intro p {
  max-width: 760px;
  color: var(--muted);
  font-size: 18px;
}

.book-mode .book-intro p {
  display: inline;
  margin: 0 14px 0 0;
  font-size: 14px;
}

.open-book {
  max-width: 980px;
  margin: 22px auto 18px;
  padding: clamp(18px, 3vw, 34px);
  border: 1px solid rgba(234, 210, 154, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(143, 199, 217, 0.08), rgba(0,0,0,0.16)),
    rgba(8, 9, 13, 0.58);
  box-shadow: 0 34px 100px rgba(0, 0, 0, 0.46);
  perspective: 1800px;
}

.book-mode .open-book {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  padding: clamp(10px, 2vh, 18px);
  overflow: hidden;
}

.book-view {
  display: none;
}

.book-view.active {
  display: block;
}

.book-cover-wrap {
  width: min(520px, 100%);
  margin: 0 auto;
  transform: rotateY(-7deg);
  transform-origin: left center;
  filter: drop-shadow(24px 28px 44px rgba(0,0,0,0.34));
}

.book-mode .book-cover-wrap {
  height: 100%;
  width: min(430px, 80%);
}

.book-spread {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0;
  min-height: 620px;
  border: 1px solid rgba(234, 210, 154, 0.32);
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02) 48%, rgba(0,0,0,0.42) 50%, rgba(255,255,255,0.03) 52%, rgba(255,255,255,0.05)),
    rgba(16, 24, 32, 0.92);
}

.book-mode .book-spread {
  height: 100%;
  min-height: 0;
}

.book-page-entry {
  min-height: 620px;
  padding: clamp(22px, 4vw, 40px);
  background:
    linear-gradient(90deg, rgba(0,0,0,0.18), transparent 10%, transparent 90%, rgba(0,0,0,0.18)),
    linear-gradient(180deg, rgba(234, 210, 154, 0.08), rgba(143, 199, 217, 0.04)),
    rgba(16, 24, 32, 0.92);
  box-shadow: inset 0 0 42px rgba(0,0,0,0.16);
}

.book-mode .book-page-entry {
  min-height: 0;
  height: 100%;
  overflow: auto;
  padding: clamp(18px, 3vh, 32px);
}

.book-cover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(199, 167, 93, 0.2), rgba(16, 24, 32, 0.94)),
    rgba(16, 24, 32, 0.96);
  border: 1px solid rgba(234, 210, 154, 0.5);
  border-left: 14px solid rgba(199, 167, 93, 0.68);
  border-radius: 8px;
}

.book-mode .book-cover {
  overflow: hidden;
}

.dedication-page {
  background:
    linear-gradient(180deg, rgba(143, 199, 217, 0.18), rgba(16, 24, 32, 0.92)),
    rgba(16, 24, 32, 0.94);
}

.memory-invite-page {
  background:
    linear-gradient(180deg, rgba(127, 155, 109, 0.18), rgba(16, 24, 32, 0.92)),
    rgba(16, 24, 32, 0.94);
}

.end-page {
  background:
    linear-gradient(180deg, rgba(199, 167, 93, 0.16), rgba(16, 24, 32, 0.94)),
    rgba(16, 24, 32, 0.96);
}

.book-page-entry:nth-child(odd) {
  border-right: 1px solid rgba(255,255,255,0.1);
}

.blank-page {
  background:
    linear-gradient(180deg, rgba(234, 210, 154, 0.04), rgba(143, 199, 217, 0.025)),
    rgba(16, 24, 32, 0.88);
}

.book-page-entry img {
  width: 100%;
  max-height: 260px;
  object-fit: cover;
  border: 1px solid rgba(234, 210, 154, 0.28);
  border-radius: 8px;
  margin-bottom: 18px;
}

.book-cover img {
  width: min(72%, 280px);
  max-height: 300px;
  aspect-ratio: 3 / 4;
  object-position: center 28%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.38);
}

.book-mode .book-cover img {
  width: min(62%, 230px);
  max-height: min(36vh, 250px);
}

.book-page-label {
  margin: 0 0 8px;
  color: var(--sky);
  text-transform: uppercase;
  font-size: 12px;
}

.book-page-entry h2 {
  margin: 0 0 10px;
  color: var(--gold-2);
  font-family: Georgia, "Noto Serif TC", serif;
  font-size: clamp(24px, 4vw, 36px);
  line-height: 1.14;
}

.book-mode .book-page-entry h2 {
  font-size: clamp(22px, 4vh, 34px);
}

.book-byline {
  margin: 0 0 16px;
  color: var(--muted);
}

.book-subtitle {
  margin: -6px 0 20px;
  color: var(--muted);
  font-size: 20px;
}

.book-position {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 12px;
  color: var(--gold-2);
  font-family: Georgia, "Noto Serif TC", serif;
}

.book-mode .book-actions {
  justify-content: center;
  margin: 0;
}

button:disabled {
  cursor: default;
  opacity: 0.45;
}

.empty-page p {
  color: #ded7cc;
}

.comment {
  border-top: 1px solid var(--line);
  padding: 14px 0;
}

.comment span {
  display: block;
  color: var(--muted);
  font-size: 14px;
}

.comment p { margin-bottom: 0; }
.comment-form { margin-top: 20px; }

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th, .admin-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.admin-table small { color: var(--muted); }

@media (max-width: 760px) {
  .book-mode {
    overflow: auto;
  }
  .book-mode main {
    min-height: calc(100vh - 96px);
    height: auto;
    overflow: visible;
  }
  .book-mode .book-intro p {
    display: none;
  }
  .book-mode .book-actions {
    position: sticky;
    bottom: 0;
    padding: 8px 0;
    background: rgba(8, 9, 13, 0.92);
  }
  .site-header, .toolbar, .post-head, .share-band {
    align-items: flex-start;
    flex-direction: column;
  }
  nav { justify-content: flex-start; }
  .nav-button {
    min-width: calc(50% - 6px);
    flex: 1 1 calc(50% - 6px);
  }
  .form-row, .email-addresses, .instruction-grid { grid-template-columns: 1fr; }
  .open-book {
    padding: 12px;
  }
  .book-cover-wrap {
    transform: none;
  }
  .book-spread {
    grid-template-columns: 1fr;
    height: auto;
    min-height: calc(100vh - 250px);
  }
  .book-page-entry {
    min-height: calc(100vh - 250px);
  }
  .book-mode .book-page-entry {
    height: auto;
    min-height: calc(100vh - 250px);
  }
  .book-page-entry:nth-child(odd) {
    border-right: 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
  }
  .hero {
    grid-template-columns: 1fr;
    min-height: 0;
    padding-top: 24px;
  }
  .hero-text { text-align: center; }
  .hero-copy { margin-left: auto; margin-right: auto; }
  .portrait-wrap {
    width: min(78vw, 320px);
    margin: 0 auto;
  }
}
