:root {
  --bg: #f4ece1;
  --bg-alt: #f2dac4;
  --panel: rgba(255, 251, 246, 0.9);
  --paper: #fff9f1;
  --ink: #3e2a21;
  --muted: #7b6356;
  --accent: #b85f44;
  --accent-soft: #ddb293;
  --line: #dac8b7;
  --shadow: 0 26px 60px rgba(87, 47, 31, 0.16);
  --radius-xl: 26px;
  --radius-lg: 18px;
  --radius-sm: 10px;
  --hero-subtitle: #5b4335;
  --glass-border: rgba(184, 133, 101, 0.23);
  --card-grad-a: rgba(255, 251, 246, 0.98);
  --card-grad-b: rgba(255, 245, 234, 0.96);
  --paper-line-a: rgba(255, 247, 236, 0.88);
  --paper-line-b: rgba(255, 240, 225, 0.78);
  --panel-strong: #fffaf4;
  --panel-soft: rgba(255, 248, 240, 0.93);
  --surface-input: #fffefb;
  --focus-ring: #9d553b;
  --pointer-shift-x: 0px;
  --pointer-shift-y: 0px;
  --stagger-index: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Manrope", sans-serif;
  transition: background 0.6s ease, color 0.45s ease;
  background:
    radial-gradient(70rem 40rem at 8% -15%, rgba(228, 181, 143, 0.54), transparent 72%),
    radial-gradient(58rem 32rem at 90% 7%, rgba(243, 215, 188, 0.7), transparent 66%),
    linear-gradient(165deg, var(--bg) 0%, var(--bg-alt) 100%);
}

body[data-theme="dark"] {
  --bg: #171210;
  --bg-alt: #2a201c;
  --panel: rgba(34, 27, 23, 0.88);
  --paper: #2f2521;
  --ink: #f7ebe4;
  --muted: #c7b1a3;
  --accent: #e89a77;
  --accent-soft: #805442;
  --line: #5b473c;
  --shadow: 0 30px 66px rgba(0, 0, 0, 0.45);
  --hero-subtitle: #dec8bb;
  --glass-border: rgba(235, 196, 168, 0.18);
  --card-grad-a: rgba(62, 47, 40, 0.95);
  --card-grad-b: rgba(45, 35, 30, 0.95);
  --paper-line-a: rgba(67, 53, 46, 0.86);
  --paper-line-b: rgba(53, 41, 36, 0.86);
  --panel-strong: #2f2521;
  --panel-soft: rgba(52, 40, 34, 0.92);
  --surface-input: #342922;
  --focus-ring: #f0b79a;
  background:
    radial-gradient(70rem 40rem at 8% -15%, rgba(155, 93, 65, 0.46), transparent 72%),
    radial-gradient(58rem 32rem at 90% 7%, rgba(95, 63, 48, 0.62), transparent 66%),
    linear-gradient(165deg, var(--bg) 0%, var(--bg-alt) 100%);
}

body.admin-open {
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.file-button:focus-within {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

.background-shapes {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
  transform: translate3d(var(--pointer-shift-x, 0px), var(--pointer-shift-y, 0px), 0);
  transition: transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
  will-change: transform;
}

.shape {
  position: absolute;
  border-radius: 999px;
  filter: blur(2px);
  opacity: 0.6;
  animation: float 14s ease-in-out infinite;
  will-change: transform;
}

.shape--one {
  width: 18rem;
  height: 18rem;
  top: 12%;
  left: -5%;
  background: rgba(214, 139, 99, 0.22);
}

.shape--two {
  width: 22rem;
  height: 22rem;
  bottom: -12%;
  right: -6%;
  background: rgba(178, 109, 82, 0.2);
  animation-delay: 2s;
}

.shape--three {
  width: 14rem;
  height: 14rem;
  right: 34%;
  top: 54%;
  background: rgba(248, 214, 182, 0.35);
  animation-delay: 5s;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1320px;
  margin: 0 auto;
  padding: 2.2rem 1.6rem 1.8rem;
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 0.7s ease, transform 0.7s ease;
}

body.is-ready .app {
  opacity: 1;
  transform: translateY(0);
}

.app--locked {
  filter: blur(12px);
  pointer-events: none;
  user-select: none;
}

.hero {
  padding: 1.4rem 1.3rem;
  margin-bottom: 1rem;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.hero-kicker {
  margin: 0;
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 0.3rem 0 0.5rem;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(2.35rem, 4vw, 3.4rem);
  font-weight: 700;
  line-height: 1.05;
}

.hero-subtitle {
  margin: 0;
  max-width: 62ch;
  color: var(--hero-subtitle);
}

.theme-toggle {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.4rem 0.82rem;
  font-size: 0.8rem;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(67, 38, 25, 0.12);
  transition: transform 0.28s ease, box-shadow 0.28s ease, border-color 0.28s ease;
}

.theme-toggle:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 14px 30px rgba(67, 38, 25, 0.18);
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 0.78fr) minmax(380px, 1fr);
  gap: 1rem;
  min-height: 72vh;
}

.list-panel,
.detail-panel {
  border: 1px solid var(--glass-border);
  background: var(--panel);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(7px);
  transition: border-color 0.35s ease, box-shadow 0.35s ease, background 0.35s ease;
}

.list-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 1rem;
}

[data-reveal] {
  opacity: 0;
  transform: translateY(24px) scale(0.985);
  transition: opacity 0.75s cubic-bezier(0.16, 1, 0.3, 1), transform 0.75s cubic-bezier(0.16, 1, 0.3, 1);
}

[data-reveal].is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.85rem;
}

.panel-header h2 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 2rem;
}

.counter {
  color: var(--muted);
  font-size: 0.84rem;
}

.chip-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.chip {
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.22s ease;
}

.chip:hover {
  border-color: var(--accent);
  color: var(--ink);
}

.chip.is-active {
  background: linear-gradient(140deg, #d88f70 0%, #b45a3d 100%);
  border-color: transparent;
  color: #fff;
}

.cards {
  display: grid;
  gap: 0.6rem;
  overflow: auto;
  padding-right: 0.2rem;
}

.letter-card {
  position: relative;
  overflow: hidden;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: linear-gradient(156deg, var(--card-grad-a), var(--card-grad-b));
  padding: 0.95rem 1rem;
  text-align: left;
  cursor: pointer;
  transition: transform 0.24s ease, box-shadow 0.24s ease, border-color 0.24s ease;
  animation: reveal 0.38s ease both;
  animation-delay: calc(var(--stagger-index, 0) * 0.05s);
}

.letter-card::after {
  content: "";
  position: absolute;
  top: -60%;
  left: -38%;
  width: 28%;
  height: 220%;
  pointer-events: none;
  background: linear-gradient(105deg, transparent, rgba(255, 238, 225, 0.6), transparent);
  transform: translateX(-180%) rotate(14deg);
  opacity: 0;
  transition: transform 0.75s ease, opacity 0.45s ease;
}

.letter-card:hover {
  transform: translateY(-4px) scale(1.012);
  border-color: var(--accent);
  box-shadow: 0 18px 34px rgba(103, 58, 39, 0.2);
}

.letter-card:hover::after {
  opacity: 0.72;
  transform: translateX(560%) rotate(14deg);
}

.letter-card.is-active {
  border-color: var(--accent);
  box-shadow:
    inset 0 0 0 1px rgba(180, 100, 71, 0.27),
    0 12px 26px rgba(103, 58, 39, 0.18);
}

.letter-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.8rem;
}

.letter-card h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}

.sticker {
  flex-shrink: 0;
  color: var(--accent);
  font-size: 1.05rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 999px;
  background: rgba(203, 132, 95, 0.15);
  border: 1px solid rgba(190, 123, 90, 0.25);
}

.sticker::before {
  display: block;
  line-height: 1;
}

.sticker--1::before {
  content: "\2665";
}

.sticker--2::before {
  content: "\2605";
}

.sticker--3::before {
  content: "\2726";
}

.sticker--4::before {
  content: "\2661";
}

.date {
  display: block;
  margin-top: 0.28rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.teaser {
  margin: 0.5rem 0 0;
  color: var(--hero-subtitle);
  font-size: 0.86rem;
}

.detail-panel {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  min-height: 0;
  padding: 1rem;
}

.detail-panel.is-letter-switching .paper,
.detail-panel.is-letter-switching .audio-panel,
.detail-panel.is-letter-switching .original-panel {
  animation: detailSwitch 0.34s ease;
}

.back-button {
  align-self: flex-start;
  border: 0;
  background: linear-gradient(140deg, #8f5a44, #653d2e);
  color: #fff;
  border-radius: 999px;
  padding: 0.5rem 0.9rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: transform 0.24s ease, box-shadow 0.24s ease;
}

.back-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(67, 39, 27, 0.3);
}

.paper {
  border-radius: 22px;
  border: 1px solid var(--line);
  padding: 1.1rem 1.2rem 1.2rem;
  background:
    repeating-linear-gradient(
      -12deg,
      var(--paper-line-a) 0,
      var(--paper-line-a) 18px,
      var(--paper-line-b) 18px,
      var(--paper-line-b) 36px
    );
  box-shadow: inset 0 0 0 1px rgba(190, 139, 102, 0.2);
  overflow: auto;
  flex: 1;
  min-height: 12rem;
  transition: border-color 0.35s ease, background 0.35s ease;
}

.paper-header {
  margin-bottom: 0.8rem;
}

.paper-category {
  margin: 0;
  color: #8f654e;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.72rem;
}

.paper h2 {
  margin: 0.3rem 0 0.2rem;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.7rem, 2.1vw, 2.3rem);
}

.paper-date {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
}

.paper-body {
  color: var(--ink);
  line-height: 1.7;
  font-size: 0.98rem;
}

.paper-body p {
  margin: 0 0 0.75rem;
}

.paper-signature {
  margin: 1rem 0 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.32rem;
  color: var(--ink);
}

.audio-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  padding: 0.9rem;
  transition: border-color 0.35s ease, background 0.35s ease;
}

.audio-panel.is-muted {
  opacity: 0.72;
}

.audio-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 0.7rem;
}

.audio-top h3 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.5rem;
}

.audio-top p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.audio-main-controls {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.5rem 0.8rem;
}

.audio-main-controls button {
  border: 0;
  background: linear-gradient(140deg, #d98466, #b75d3f);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 0.58rem 0.8rem;
  cursor: pointer;
  font-weight: 600;
}

.audio-main-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

input[type="range"] {
  accent-color: #ba6043;
}

.time-row {
  grid-column: 2;
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.74rem;
}

.audio-volume {
  margin-top: 0.7rem;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 0.6rem;
}

.audio-volume label {
  color: var(--muted);
  font-size: 0.8rem;
}

.audio-hint {
  margin: 0.65rem 0 0;
  color: #6a5348;
  font-size: 0.8rem;
}

.original-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-strong);
  padding: 0.9rem;
  transition: border-color 0.35s ease, background 0.35s ease;
}

.original-top {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  align-items: center;
}

.original-top h3 {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.45rem;
}

.original-top button {
  border: 1px solid #ca9a7d;
  background: #fffcf8;
  color: #724f3f;
  border-radius: 999px;
  padding: 0.42rem 0.82rem;
  font-size: 0.78rem;
  cursor: pointer;
}

.original-figure {
  margin: 0.75rem 0 0;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid #dcc2af;
  background: #f9eee0;
}

.original-figure img {
  display: block;
  width: 100%;
  max-height: 380px;
  object-fit: contain;
  background: #f4e4d1;
}

.original-figure figcaption {
  margin: 0;
  padding: 0.5rem 0.65rem;
  color: #6a4f41;
  font-size: 0.78rem;
  background: rgba(246, 225, 206, 0.65);
}

.memory-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel-soft);
  padding: 0.85rem;
  transition: border-color 0.35s ease, background 0.35s ease;
}

.memory-panel h3 {
  margin: 0 0 0.55rem;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.4rem;
}

.memory-track {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.55rem;
}

.memory-card {
  margin: 0;
  border-radius: 14px;
  min-height: 86px;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(176, 124, 89, 0.38);
}

.memory-card figcaption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 0.35rem 0.42rem;
  font-size: 0.7rem;
  background: linear-gradient(180deg, transparent, rgba(36, 23, 17, 0.55));
  color: #fff;
}

.memory-card--one {
  background:
    linear-gradient(150deg, rgba(232, 180, 138, 0.95), rgba(204, 123, 87, 0.75)),
    radial-gradient(circle at 70% 22%, rgba(255, 243, 231, 0.7), transparent 40%);
}

.memory-card--two {
  background:
    linear-gradient(145deg, rgba(214, 170, 124, 0.96), rgba(166, 104, 72, 0.72)),
    radial-gradient(circle at 30% 28%, rgba(255, 242, 225, 0.7), transparent 42%);
}

.memory-card--three {
  background:
    linear-gradient(120deg, rgba(181, 120, 91, 0.92), rgba(222, 166, 123, 0.84)),
    radial-gradient(circle at 35% 20%, rgba(255, 244, 229, 0.6), transparent 42%);
}

.admin-toggle {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 15;
  border: 1px solid rgba(149, 89, 62, 0.4);
  background: rgba(255, 247, 237, 0.92);
  color: #633f2f;
  border-radius: 999px;
  padding: 0.52rem 0.9rem;
  font-size: 0.82rem;
  box-shadow: 0 12px 30px rgba(76, 43, 29, 0.2);
  cursor: pointer;
}

.admin-drawer {
  position: fixed;
  inset: 0;
  z-index: 25;
}

.admin-backdrop {
  position: absolute;
  inset: 0;
  border: 0;
  background: rgba(23, 13, 9, 0.47);
  backdrop-filter: blur(4px);
}

.admin-drawer[hidden] {
  display: none;
}

.admin-panel {
  position: absolute;
  top: 0;
  right: 0;
  width: min(840px, 100%);
  height: 100%;
  overflow: auto;
  border-left: 1px solid #d5b79f;
  background: linear-gradient(180deg, #fff8ef 0%, #fdf2e5 100%);
  box-shadow: -18px 0 40px rgba(48, 25, 18, 0.22);
  padding: 1rem;
  display: grid;
  align-content: flex-start;
  gap: 0.8rem;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
}

.admin-kicker {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7e6152;
}

.admin-header h2 {
  margin: 0.28rem 0 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 2.2rem;
}

.admin-close {
  border: 1px solid #c79d81;
  background: #fff;
  color: #734d3d;
  border-radius: 999px;
  padding: 0.43rem 0.75rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.admin-message {
  min-height: 1.2rem;
  margin: 0;
  color: #5f4336;
  font-size: 0.82rem;
}

.admin-message[data-kind="error"] {
  color: #9f2e2e;
}

.admin-message[data-kind="success"] {
  color: #2f6a3a;
}

.admin-section {
  border: 1px solid #e2cdb9;
  border-radius: 16px;
  background: rgba(255, 252, 248, 0.92);
  padding: 0.8rem;
}

.admin-section h3 {
  margin: 0 0 0.6rem;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.6rem;
}

.admin-section-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: center;
  margin-bottom: 0.6rem;
}

.admin-grid {
  display: grid;
  gap: 0.55rem;
}

.admin-grid--two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.admin-field {
  display: grid;
  gap: 0.35rem;
}

.admin-field span {
  font-size: 0.8rem;
  color: #755a4b;
}

.admin-field input,
.admin-field textarea {
  width: 100%;
  border: 1px solid #d8baa1;
  border-radius: 10px;
  padding: 0.52rem 0.6rem;
  font: inherit;
  color: #412e25;
  background: #fffefb;
}

.admin-field textarea {
  resize: vertical;
  min-height: 140px;
}

.admin-field--inline {
  align-self: end;
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.admin-field--inline span {
  font-size: 0.86rem;
}

.admin-note {
  margin: 0.55rem 0 0;
  color: #7c6253;
  font-size: 0.76rem;
}

.admin-inline-actions {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.admin-inline-actions button,
.admin-footer button,
.file-button {
  border: 1px solid #c99d81;
  background: #fff;
  color: #6a4737;
  border-radius: 10px;
  padding: 0.46rem 0.66rem;
  font-size: 0.8rem;
  cursor: pointer;
}

.admin-inline-actions button.primary,
.admin-footer button.primary {
  border-color: transparent;
  background: linear-gradient(140deg, #d78668, #af5337);
  color: #fff;
}

.admin-inline-actions button.danger,
.admin-footer button.danger {
  border-color: #cc8d8d;
  color: #a14141;
}

.admin-editor-layout {
  display: grid;
  grid-template-columns: minmax(180px, 0.5fr) minmax(0, 1fr);
  gap: 0.7rem;
}

.admin-letter-list {
  border: 1px solid #e2cdb9;
  border-radius: 12px;
  background: rgba(255, 249, 240, 0.9);
  padding: 0.45rem;
  max-height: 70vh;
  overflow: auto;
  display: grid;
  gap: 0.35rem;
  align-content: flex-start;
}

.admin-letter-item {
  width: 100%;
  border: 1px solid #dcc1ac;
  border-radius: 10px;
  background: #fff;
  color: #624535;
  text-align: left;
  padding: 0.42rem 0.5rem;
  cursor: pointer;
}

.admin-letter-item strong {
  display: block;
  font-size: 0.8rem;
}

.admin-letter-item span {
  display: block;
  margin-top: 0.15rem;
  color: #826655;
  font-size: 0.72rem;
}

.admin-letter-item.is-active {
  border-color: #c87757;
  box-shadow: inset 0 0 0 1px rgba(188, 97, 64, 0.28);
}

.admin-editor-form {
  display: grid;
  gap: 0.5rem;
}

.admin-divider {
  border-top: 1px dashed #dbbea7;
  margin: 0.25rem 0;
}

.file-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.admin-footer {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.admin-footer .primary {
  border-color: transparent;
  background: linear-gradient(140deg, #d78668, #af5337);
  color: #fff;
}

.password-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(44, 28, 20, 0.45);
  backdrop-filter: blur(8px);
}

.password-gate[hidden] {
  display: none;
}

.password-card {
  width: min(420px, 100%);
  border-radius: var(--radius-xl);
  border: 1px solid rgba(237, 203, 177, 0.58);
  background: #fff8ef;
  box-shadow: var(--shadow);
  padding: 1.25rem;
  display: grid;
  gap: 0.55rem;
}

.password-kicker {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-size: 0.75rem;
}

.password-card h2 {
  margin: 0.2rem 0 0;
  font-family: "Cormorant Garamond", serif;
  font-size: 2rem;
}

.password-card p {
  margin: 0;
}

.password-card label {
  margin-top: 0.4rem;
  color: var(--muted);
  font-size: 0.84rem;
}

.password-card input {
  border: 1px solid #d3b8a0;
  border-radius: 10px;
  padding: 0.62rem 0.66rem;
  font-size: 1rem;
}

.password-card button {
  margin-top: 0.4rem;
  border: 0;
  border-radius: 10px;
  background: linear-gradient(140deg, #c27051, #a14f36);
  color: #fff;
  padding: 0.65rem;
  font-size: 0.95rem;
  cursor: pointer;
}

.password-error {
  min-height: 1.2rem;
  color: #9f2e2e;
  font-size: 0.84rem;
}

.empty-state {
  margin: 0;
  padding: 0.9rem;
  border-radius: 12px;
  border: 1px dashed #d4b9a2;
  background: rgba(255, 248, 239, 0.7);
  color: #6f5648;
  font-size: 0.88rem;
}

body[data-theme="dark"] .theme-toggle {
  background: rgba(49, 38, 32, 0.9);
  border-color: #70594d;
  color: #f5e9e1;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.36);
}

body[data-theme="dark"] .admin-toggle {
  border-color: #73584a;
  background: rgba(46, 35, 30, 0.92);
  color: #f5e8df;
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.34);
}

body[data-theme="dark"] .sticker {
  background: rgba(232, 154, 119, 0.18);
  border-color: rgba(232, 154, 119, 0.36);
}

body[data-theme="dark"] .letter-card::after {
  background: linear-gradient(105deg, transparent, rgba(255, 214, 189, 0.42), transparent);
}

body[data-theme="dark"] .date,
body[data-theme="dark"] .paper-date,
body[data-theme="dark"] .audio-top p,
body[data-theme="dark"] .audio-hint,
body[data-theme="dark"] .audio-volume label,
body[data-theme="dark"] .counter,
body[data-theme="dark"] .time-row {
  color: #cab4a7;
}

body[data-theme="dark"] .paper-category {
  color: #d7af98;
}

body[data-theme="dark"] .audio-main-controls button {
  background: linear-gradient(140deg, #d98765, #ad5a3d);
}

body[data-theme="dark"] .original-top button {
  background: #3a2d27;
  border-color: #7d6153;
  color: #f1ddd0;
}

body[data-theme="dark"] .original-figure {
  border-color: #6a5246;
  background: #332722;
}

body[data-theme="dark"] .original-figure img {
  background: #2a211d;
}

body[data-theme="dark"] .original-figure figcaption {
  color: #d8c0b2;
  background: rgba(35, 26, 22, 0.84);
}

body[data-theme="dark"] .memory-card {
  border-color: rgba(221, 175, 144, 0.34);
}

body[data-theme="dark"] .admin-backdrop {
  background: rgba(6, 4, 3, 0.66);
}

body[data-theme="dark"] .admin-panel {
  border-left-color: #604b40;
  background: linear-gradient(180deg, #2b221e 0%, #221b17 100%);
  box-shadow: -20px 0 42px rgba(0, 0, 0, 0.42);
}

body[data-theme="dark"] .list-panel,
body[data-theme="dark"] .detail-panel,
body[data-theme="dark"] .paper,
body[data-theme="dark"] .audio-panel,
body[data-theme="dark"] .original-panel,
body[data-theme="dark"] .memory-panel,
body[data-theme="dark"] .admin-panel,
body[data-theme="dark"] .password-card {
  color: var(--ink);
}

body[data-theme="dark"] .letter-card h3,
body[data-theme="dark"] .paper h2,
body[data-theme="dark"] .memory-panel h3,
body[data-theme="dark"] .admin-header h2,
body[data-theme="dark"] .admin-section h3,
body[data-theme="dark"] .admin-letter-item strong,
body[data-theme="dark"] .password-card h2,
body[data-theme="dark"] .password-card p {
  color: #f7ebe4;
}

body[data-theme="dark"] .admin-kicker,
body[data-theme="dark"] .admin-field span,
body[data-theme="dark"] .admin-note,
body[data-theme="dark"] .admin-message {
  color: #d2baab;
}

body[data-theme="dark"] .admin-close,
body[data-theme="dark"] .admin-inline-actions button,
body[data-theme="dark"] .admin-footer button,
body[data-theme="dark"] .file-button,
body[data-theme="dark"] .admin-letter-item {
  background: #3a2d27;
  border-color: #795f51;
  color: #f2e2d8;
}

body[data-theme="dark"] .admin-inline-actions button.primary,
body[data-theme="dark"] .admin-footer button.primary {
  background: linear-gradient(140deg, #d58467, #aa5338);
  color: #fff;
}

body[data-theme="dark"] .admin-inline-actions button.danger,
body[data-theme="dark"] .admin-footer button.danger {
  border-color: #9b5d5d;
  color: #f6b1b1;
}

body[data-theme="dark"] .admin-letter-list,
body[data-theme="dark"] .admin-section {
  border-color: #5f4a3e;
  background: rgba(53, 41, 35, 0.92);
}

body[data-theme="dark"] .admin-letter-item span {
  color: #c6ada0;
}

body[data-theme="dark"] .admin-letter-item.is-active {
  border-color: #de8f6d;
  box-shadow: inset 0 0 0 1px rgba(226, 144, 108, 0.42);
}

body[data-theme="dark"] .admin-divider {
  border-top-color: #675044;
}

body[data-theme="dark"] .admin-field input,
body[data-theme="dark"] .admin-field textarea,
body[data-theme="dark"] .password-card input {
  background: var(--surface-input);
  border-color: #775f52;
  color: #f3e4da;
}

body[data-theme="dark"] .admin-field input::placeholder,
body[data-theme="dark"] .admin-field textarea::placeholder,
body[data-theme="dark"] .password-card input::placeholder {
  color: #cdb7ab;
  opacity: 1;
}

body[data-theme="dark"] .admin-field input:-webkit-autofill,
body[data-theme="dark"] .admin-field textarea:-webkit-autofill,
body[data-theme="dark"] .password-card input:-webkit-autofill {
  -webkit-text-fill-color: #f3e4da;
  box-shadow: 0 0 0 1000px var(--surface-input) inset;
}

body[data-theme="dark"] .password-gate {
  background: rgba(9, 7, 6, 0.7);
}

body[data-theme="dark"] .password-card {
  border-color: #685143;
  background: #2e241f;
}

body[data-theme="dark"] .password-card button {
  background: linear-gradient(140deg, #ce8062, #944c35);
}

body[data-theme="dark"] .empty-state {
  border-color: #6e564a;
  background: rgba(54, 41, 35, 0.74);
  color: #dcc4b6;
}

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

  .app {
    padding: 1rem 0.9rem 1.2rem;
  }

  .hero-top {
    flex-wrap: wrap;
    gap: 0.55rem;
  }

  .theme-toggle {
    padding: 0.34rem 0.7rem;
    font-size: 0.75rem;
  }

  .layout {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .list-panel,
  .detail-panel {
    min-height: auto;
  }

  .list-panel {
    max-height: 68vh;
  }

  .detail-panel {
    display: none;
  }

  body.mobile-detail .list-panel {
    display: none;
  }

  body.mobile-detail .detail-panel {
    display: flex;
  }

  .back-button {
    display: inline-flex;
  }

  .memory-track {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-toggle {
    right: 0.7rem;
    bottom: 0.7rem;
  }

  .admin-panel {
    width: 100%;
    padding: 0.8rem;
  }

  .admin-grid--two {
    grid-template-columns: 1fr;
  }

  .admin-editor-layout {
    grid-template-columns: 1fr;
  }

  .admin-letter-list {
    max-height: 30vh;
  }
}

@media (min-width: 961px) {
  .back-button {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  [data-reveal] {
    opacity: 1 !important;
    transform: none !important;
  }
}

@keyframes float {
  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-14px) rotate(3deg);
  }
}

@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes detailSwitch {
  from {
    opacity: 0.55;
    transform: translateY(10px) scale(0.992);
    filter: saturate(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: saturate(1);
  }
}
