:root {
  --mist: #dfe5de;
  --paper: #eee7d8;
  --paper-deep: #ded3bd;
  --ink: #18221f;
  --ink-soft: rgba(24, 34, 31, 0.64);
  --forest: #21443b;
  --red: #8c342e;
  --bronze: #9d7135;
  --line: rgba(24, 34, 31, 0.2);
  --line-strong: rgba(24, 34, 31, 0.38);
  font-family: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--mist);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--mist);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  color: inherit;
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
canvas:focus-visible {
  outline: 3px solid rgba(140, 52, 46, 0.35);
  outline-offset: 3px;
}

.memory-app {
  display: grid;
  grid-template-rows: 76px minmax(0, 1fr) 46px;
  width: 100%;
  height: 100dvh;
  overflow: hidden;
  background: var(--mist);
}

.site-header {
  position: relative;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding: 0 30px;
  border-bottom: 1px solid var(--line);
  background: rgba(223, 229, 222, 0.94);
  backdrop-filter: blur(14px);
}

.wordmark {
  display: inline-grid;
  justify-self: start;
  gap: 2px;
  text-decoration: none;
}

.wordmark span,
.section-index,
.dialog-head p {
  margin: 0;
  color: var(--red);
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: 0.18em;
}

.wordmark strong {
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 18px;
  letter-spacing: 0.08em;
}

.header-count {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: var(--ink-soft);
  font-size: 12px;
}

.header-count strong {
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.compose-button,
.submit-button {
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--ink);
  border-radius: 4px;
  color: var(--paper);
  background: var(--ink);
}

.compose-button {
  justify-self: end;
}

.compose-button span {
  margin-right: 6px;
  color: #d2a662;
  font-size: 18px;
}

.experience {
  display: grid;
  grid-template-columns: minmax(230px, 0.72fr) minmax(520px, 1.76fr) minmax(250px, 0.78fr);
  min-height: 0;
}

.intro-panel,
.reading-panel {
  position: relative;
  z-index: 3;
  min-width: 0;
  padding: clamp(28px, 3.6vw, 62px) clamp(22px, 2.8vw, 46px);
}

.intro-panel {
  border-right: 1px solid var(--line);
}

.intro-panel h1 {
  max-width: 6em;
  margin: clamp(34px, 7vh, 76px) 0 0;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: clamp(42px, 4.5vw, 76px);
  font-weight: 600;
  line-height: 1.05;
  letter-spacing: 0;
}

.intro-copy {
  max-width: 17em;
  margin: 24px 0 0;
  color: var(--ink-soft);
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 17px;
  line-height: 1.9;
}

.intro-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 20px;
  margin-top: clamp(40px, 9vh, 96px);
  color: var(--ink-soft);
  font-size: 12px;
}

.intro-meta strong {
  color: var(--ink);
  font-family: Georgia, serif;
  font-size: 16px;
  font-weight: 400;
}

.intro-rule {
  height: 1px;
  margin-top: 12px;
  background: var(--line-strong);
}

.intro-note {
  max-width: 19em;
  margin: 16px 0 0;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.8;
}

.light-field {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg, rgba(61, 53, 40, 0.035) 0 1px, transparent 1px 44px),
    var(--paper);
}

.light-field::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 0 90px rgba(74, 61, 41, 0.12);
}

#memory-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.lamp-canopy {
  position: absolute;
  z-index: 4;
  top: clamp(24px, 4vh, 48px);
  left: 50%;
  width: min(92%, 820px);
  aspect-ratio: 1600 / 307;
  transform: translateX(-50%);
  pointer-events: none;
  filter: drop-shadow(18px 24px 14px rgba(55, 39, 25, 0.24));
}

.lamp-canopy img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.field-mark {
  position: absolute;
  z-index: 5;
  right: 24px;
  bottom: 24px;
  display: grid;
  place-items: center;
  width: 46px;
  min-height: 132px;
  padding: 8px 0;
  color: #eadcc2;
  border: 1px solid #6f2521;
  background: var(--red);
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 15px;
  line-height: 1.5;
}

.reading-panel {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: #d7dfda;
}

.reading-dedication {
  margin: clamp(52px, 9vh, 100px) 0 0;
  color: var(--red);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.08em;
}

.reading-panel blockquote {
  margin: 22px 0 0;
  color: var(--ink);
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: clamp(22px, 2vw, 32px);
  line-height: 1.68;
  letter-spacing: 0;
}

.reading-signature {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-top: 30px;
  padding-top: 16px;
  border-top: 1px solid var(--line-strong);
}

.reading-signature strong {
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 16px;
}

.reading-signature span {
  color: var(--ink-soft);
  font-family: Georgia, serif;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.reading-nav {
  display: grid;
  grid-template-columns: 42px 1fr 42px;
  align-items: center;
  gap: 10px;
  margin-top: auto;
}

.reading-nav button,
.close-button {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  background: transparent;
  font-size: 18px;
}

.reading-nav span {
  color: var(--ink-soft);
  text-align: center;
  font-family: Georgia, serif;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 0 30px;
  color: rgba(24, 34, 31, 0.58);
  border-top: 1px solid var(--line);
  font-family: Georgia, serif;
  font-size: 10px;
  letter-spacing: 0.1em;
}

.site-footer button {
  padding: 0;
  color: var(--red);
  border: 0;
  background: transparent;
  font-family: "Noto Sans SC", sans-serif;
  font-size: 12px;
  letter-spacing: 0;
}

.compose-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100dvh - 40px);
  margin: auto;
  padding: 0;
  color: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--paper);
  box-shadow: 0 28px 90px rgba(18, 24, 22, 0.36);
}

.compose-dialog::backdrop {
  background: rgba(17, 27, 24, 0.66);
  backdrop-filter: blur(7px);
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin: 7px 0 0;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 30px;
  letter-spacing: 0;
}

#memory-form {
  display: grid;
  gap: 18px;
  padding: 24px 26px 26px;
}

.form-row {
  display: grid;
  grid-template-columns: 0.72fr 1.28fr;
  gap: 14px;
}

#memory-form label {
  display: grid;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 12px;
}

.form-label-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.form-label-line output {
  color: var(--red);
  font-family: Georgia, serif;
  font-variant-numeric: tabular-nums;
}

#memory-form input,
#memory-form textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  padding: 11px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.34);
  outline: none;
}

#memory-form textarea {
  min-height: 132px;
  resize: vertical;
  font-family: "Songti SC", "Noto Serif SC", serif;
  font-size: 17px;
  line-height: 1.8;
}

.form-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.form-foot p,
.form-status {
  margin: 0;
  color: var(--ink-soft);
  font-size: 11px;
  line-height: 1.6;
}

.submit-button {
  flex: 0 0 auto;
}

.submit-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.form-status {
  min-height: 18px;
  color: var(--red);
}

.toast {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: 24px;
  padding: 10px 14px;
  color: var(--paper);
  border-radius: 3px;
  background: var(--ink);
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (max-width: 1080px) {
  .experience {
    grid-template-columns: minmax(210px, 0.66fr) minmax(460px, 1.5fr) minmax(230px, 0.72fr);
  }

  .intro-panel,
  .reading-panel {
    padding-inline: 24px;
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
  }

  .memory-app {
    grid-template-rows: auto auto auto;
    min-height: 100dvh;
    height: auto;
    overflow: visible;
  }

  .site-header {
    grid-template-columns: 1fr auto;
    min-height: 72px;
    padding: 12px 16px;
  }

  .header-count {
    display: none;
  }

  .experience {
    grid-template-columns: 1fr;
  }

  .intro-panel,
  .reading-panel {
    padding: 28px 20px;
    border: 0;
  }

  .intro-panel h1 {
    margin-top: 30px;
    font-size: 46px;
  }

  .intro-meta {
    margin-top: 32px;
  }

  .light-field {
    min-height: 72dvh;
    border-block: 1px solid var(--line);
  }

  .lamp-canopy {
    width: min(94%, 620px);
  }

  .reading-panel {
    min-height: 420px;
  }

  .reading-dedication {
    margin-top: 0;
  }

  .site-footer {
    min-height: 52px;
    padding-inline: 16px;
  }
}

@media (max-width: 520px) {
  .compose-button {
    width: 42px;
    padding: 0;
    overflow: hidden;
    white-space: nowrap;
    color: transparent;
  }

  .compose-button span {
    display: block;
    margin: 0;
    color: var(--paper);
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .form-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .submit-button {
    width: 100%;
  }

  .site-footer span {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: none;
  }
}
