:root {
  --memory-ui-paper: rgba(247, 241, 229, .96);
  --memory-ui-ink: #29322e;
  --memory-ui-muted: #6f7068;
  --memory-ui-line: rgba(41, 50, 46, .17);
  --memory-ui-shadow: 0 18px 54px rgba(27, 34, 31, .16);
  --memory-ui-ease: cubic-bezier(.22, 1, .36, 1);
}

html,
body {
  max-width:100%;
  overflow-x:clip;
}

.memory-weather {
  --weather-a: rgba(125, 151, 151, .17);
  --weather-b: rgba(221, 188, 151, .13);
  --weather-x: 24%;
  --weather-y: 78%;
  position: fixed;
  z-index: 4;
  inset: -6%;
  pointer-events: none;
  opacity: .32;
  background:
    radial-gradient(circle at var(--weather-x) 18%, var(--weather-a), transparent 35%),
    radial-gradient(circle at var(--weather-y) 82%, var(--weather-b), transparent 42%);
  mix-blend-mode: soft-light;
  transform: scale(1.02);
  animation: memory-weather-drift 24s ease-in-out infinite alternate;
  transition: background-position .8s ease, opacity .4s ease;
}

body[data-music-module="home"] .memory-weather { --weather-a:rgba(170,133,88,.15); --weather-b:rgba(80,112,94,.11); }
body[data-music-module="objects"] .memory-weather,
body[data-music-module="vol06"] .memory-weather { --weather-a:rgba(183,131,76,.16); --weather-b:rgba(87,133,124,.12); }
body[data-music-module="vol01"] .memory-weather { --weather-a:rgba(93,132,143,.18); --weather-b:rgba(211,170,129,.12); }
body[data-music-module="vol02"] .memory-weather { --weather-a:rgba(86,144,163,.17); --weather-b:rgba(226,171,122,.13); }
body[data-music-module="vol03"] .memory-weather { --weather-a:rgba(139,82,91,.14); --weather-b:rgba(82,111,130,.14); }
body[data-music-module="vol04"] .memory-weather { --weather-a:rgba(75,112,148,.19); --weather-b:rgba(222,129,105,.14); }
body[data-music-module="vol05"] .memory-weather { --weather-a:rgba(129,176,199,.18); --weather-b:rgba(226,184,123,.1); }
body[data-music-module="vol07"] .memory-weather { --weather-a:rgba(76,126,104,.15); --weather-b:rgba(174,101,94,.1); }
body[data-music-module="vol08"] .memory-weather { --weather-a:rgba(80,111,124,.13); --weather-b:rgba(190,117,76,.09); }

@keyframes memory-weather-drift {
  from { transform:scale(1.02) translate3d(-.45%, -.22%, 0); }
  to { transform:scale(1.035) translate3d(.45%, .22%, 0); }
}

/* One quiet entry replaces the three persistent utility buttons. */
.memory-reader-menu {
  position: fixed;
  z-index: 2147482000;
  top: max(12px, env(safe-area-inset-top));
  right: max(12px, env(safe-area-inset-right));
  color: var(--memory-ui-ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

.memory-reader-menu__toggle {
  position: relative;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(41, 50, 46, .16);
  border-radius: 50%;
  color: var(--memory-ui-ink);
  background: rgba(247, 241, 229, .76);
  box-shadow: 0 5px 18px rgba(31, 34, 31, .08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  cursor: pointer;
  opacity: .7;
  transition: opacity 180ms ease, background 180ms ease, transform 180ms var(--memory-ui-ease);
}

.memory-reader-menu__toggle:hover,
.memory-reader-menu__toggle:focus-visible,
.memory-reader-menu[data-open="true"] .memory-reader-menu__toggle {
  opacity: 1;
  background: var(--memory-ui-paper);
}

.memory-reader-menu__toggle:active { transform:scale(.96); }
.memory-reader-menu__dots { width:18px; display:flex; justify-content:space-between; }
.memory-reader-menu__dots::before,
.memory-reader-menu__dots::after,
.memory-reader-menu__dots i {
  content: "";
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: currentColor;
}

.memory-reader-menu__panel {
  position: absolute;
  top: 56px;
  right: 0;
  width: min(320px, calc(100vw - 24px));
  padding: 18px;
  border: 1px solid var(--memory-ui-line);
  color: var(--memory-ui-ink);
  background: var(--memory-ui-paper);
  box-shadow: var(--memory-ui-shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(-6px) scale(.985);
  transform-origin: top right;
  transition:
    opacity 180ms ease,
    transform 220ms var(--memory-ui-ease),
    visibility 0s linear 220ms;
}

.memory-reader-menu[data-open="true"] .memory-reader-menu__panel {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: none;
  transition-delay: 0s;
}

.memory-reader-menu__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--memory-ui-line);
}

.memory-reader-menu__title {
  margin: 0;
  font: 600 15px/1.5 "Songti SC", "STSong", serif;
  letter-spacing: .06em;
}

.memory-reader-menu__close {
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  color: inherit;
  background: transparent;
  cursor: pointer;
  font: 300 24px/1 Georgia, serif;
}

.memory-reader-menu__actions {
  display: grid;
  gap: 0;
  padding-top: 6px;
}

.memory-reader-menu__actions > button,
.memory-reader-menu__actions > a {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 10px 2px;
  border: 0;
  border-bottom: 1px solid var(--memory-ui-line);
  border-radius: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  font: 500 14px/1.5 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  text-align: left;
}

.memory-reader-menu__actions > button::after,
.memory-reader-menu__actions > a::after {
  content: "›";
  color: var(--memory-ui-muted);
  font: 400 21px/1 Georgia, serif;
}

.memory-reader-menu__actions > [aria-pressed="true"]::after { content:"已减少"; font:600 10px/1.4 system-ui,sans-serif; letter-spacing:.08em; }
.memory-reader-menu__actions > button:hover,
.memory-reader-menu__actions > button:focus-visible,
.memory-reader-menu__actions > a:hover,
.memory-reader-menu__actions > a:focus-visible,
.memory-reader-menu__close:hover,
.memory-reader-menu__close:focus-visible {
  color: #704e46;
  outline: none;
}

.memory-reader-menu__music { padding-top: 12px; }
.memory-reader-shell-ready .top-actions,
.memory-reader-shell-ready .utility,
.memory-reader-shell-ready .top { display:none !important; }

.memory-path-hidden { display:none !important; }

/* The story shelf adds depth without lengthening the first reading path. */
.story-paths {
  border-top: 1px solid var(--memory-ui-line);
}

.story-path {
  border-bottom: 1px solid var(--memory-ui-line);
}

.story-path__toggle {
  width: 100%;
  min-height: 78px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 15px 2px;
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
}

.story-path__number {
  color: #a96350;
  font: 700 10px/1 system-ui, sans-serif;
  letter-spacing: .12em;
}

.story-path__label {
  min-width: 0;
  display: grid;
  gap: 5px;
}

.story-path__label strong {
  font: 500 clamp(18px, 2.1vw, 27px)/1.25 "Iowan Old Style", "Songti SC", "STSong", serif;
  letter-spacing: -.025em;
}

.story-path__label small,
.story-path__time {
  color: var(--memory-ui-muted);
  font: 12px/1.6 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

.story-path__time {
  display: flex;
  align-items: center;
  gap: 11px;
  white-space: nowrap;
}

.story-path__time::after {
  content: "＋";
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid var(--memory-ui-line);
  border-radius: 50%;
  color: #a96350;
  font: 400 18px/1 Georgia, serif;
  transition: transform 220ms var(--memory-ui-ease);
}

.story-path-open .story-path__time::after {
  transform: rotate(45deg);
}

.story-path__toggle:hover,
.story-path__toggle:focus-visible {
  color: #704e46;
  outline: none;
}

.story-path__panel {
  max-height: 0;
  overflow: hidden;
  visibility: hidden;
  opacity: 0;
  transform: translateY(-5px);
  transition:
    max-height 280ms var(--memory-ui-ease),
    opacity 180ms ease,
    transform 240ms var(--memory-ui-ease),
    visibility 0s linear 280ms;
}

.story-path-open .story-path__panel {
  visibility: visible;
  opacity: 1;
  transform: none;
  transition-delay: 0s;
}

.story-path__inner {
  display: grid;
  grid-template-columns: minmax(0, .72fr) minmax(280px, 1.28fr);
  gap: clamp(20px, 4vw, 54px);
  padding: 4px 2px 24px 52px;
}

.story-path__intro {
  margin: 0;
  color: var(--memory-ui-muted);
  font-size: clamp(15px, 1.35vw, 18px);
  line-height: 1.85;
  text-wrap: pretty;
}

.story-path__links {
  display: grid;
}

.story-path__links a {
  min-height: 52px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 11px 0;
  border-top: 1px solid var(--memory-ui-line);
  color: inherit;
  text-decoration: none;
  font: 500 14px/1.55 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

.story-path__links a:last-child {
  border-bottom: 1px solid var(--memory-ui-line);
}

.story-path__links a::after {
  content: "去这一页";
  color: var(--memory-ui-muted);
  font-size: 11px;
  font-weight: 500;
}

.story-path__links a:hover,
.story-path__links a:focus-visible {
  color: #704e46;
  outline: none;
}

/* Page navigation stays available but no longer competes with the page. */
.controls {
  opacity: 0 !important;
  pointer-events: none !important;
  box-shadow: 0 8px 24px rgba(0,0,0,.13) !important;
  transition: opacity 180ms ease !important;
}
.controls.visible {
  opacity: .66 !important;
  pointer-events: auto !important;
}
.controls.visible:hover,
.controls.visible:focus-within { opacity:.92 !important; }
.controls .icon-btn { min-width:44px !important; min-height:44px !important; }

/* Details are optional on every screen, not just mobile. */
.memory-layered .memory-detail,
.memory-echo-content {
  max-height: 0;
  margin-top: 0 !important;
  margin-bottom: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  overflow: hidden;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition:
    max-height 240ms var(--memory-ui-ease),
    padding 220ms ease,
    opacity 160ms ease,
    transform 220ms var(--memory-ui-ease),
    visibility 0s linear 240ms,
    margin 220ms ease;
}

.memory-layered.memory-details-open .memory-detail,
.memory-echo.memory-echo-open .memory-echo-content {
  margin-top: 13px !important;
  margin-bottom: 8px !important;
  padding-top: 4px !important;
  padding-bottom: 4px !important;
  opacity: 1;
  visibility: visible;
  transform: none;
  transition-delay: 0s;
}

.memory-detail-toggle,
.memory-echo-toggle {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 10px 0 2px;
  padding: 9px 0;
  border: 0;
  border-bottom: 1px solid currentColor;
  color: inherit;
  background: transparent;
  cursor: pointer;
  opacity: .66;
  font: 600 12px/1.5 "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  letter-spacing: .08em;
  touch-action: manipulation;
}

.memory-echo { position:relative; overflow:hidden; padding:0 !important; }
.memory-echo-content { display:block; }
.memory-echo-toggle { width:100%; padding-inline:2px; text-align:left; }
.memory-detail-toggle::after,
.memory-echo-toggle::after {
  content: "＋";
  font: 400 18px/1 Georgia, serif;
  transition: transform 200ms var(--memory-ui-ease);
}
.memory-details-open .memory-detail-toggle::after,
.memory-echo-open .memory-echo-toggle::after { transform:rotate(45deg); }
.memory-detail-toggle:hover,
.memory-detail-toggle:focus-visible,
.memory-echo-toggle:hover,
.memory-echo-toggle:focus-visible { opacity:1; outline:none; }

.memory-next-link {
  width: min(620px, 100%);
  margin: 26px auto 22px;
  padding: 17px 0;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 20px;
  align-items: end;
  color: inherit;
  border-top: 1px solid currentColor;
  border-bottom: 1px solid currentColor;
  text-decoration: none;
  opacity: .68;
  transition: opacity 180ms ease;
}
.memory-next-link:hover,
.memory-next-link:focus-visible { opacity:1; outline:none; }
.memory-next-kicker { grid-column:1 / -1; font:700 10px/1.5 system-ui,sans-serif; letter-spacing:.16em; opacity:.6; }
.memory-next-copy { max-width:33em; font-size:clamp(15px,1.6vw,19px); line-height:1.65; }
.memory-next-arrow { font:400 26px/1 Georgia,serif; transform:translateY(-2px); }

details.object > summary { min-height:44px; }
details.object > summary:focus-visible { outline:3px solid rgba(183,138,72,.45); outline-offset:3px; }

@media (max-width: 720px) {
  .memory-weather { inset:-4%; opacity:.23; animation-duration:32s; }
  .memory-reader-menu { top:max(9px,env(safe-area-inset-top)); right:max(9px,env(safe-area-inset-right)); }
  .memory-reader-menu__toggle { width:44px; height:44px; }
  .memory-reader-menu__panel { top:52px; width:min(304px,calc(100vw - 18px)); padding:16px; }
  .memory-reader-menu__actions > button,
  .memory-reader-menu__actions > a { font-size:14px; }
  .story-path__toggle {
    min-height: 82px;
    grid-template-columns: 30px minmax(0, 1fr) 36px;
    gap: 10px;
    padding: 13px 0;
  }
  .story-path__label strong { font-size: 19px; line-height: 1.35; }
  .story-path__label small { font-size: 12px; line-height: 1.55; }
  .story-path__time { font-size: 0; }
  .story-path__time::after { width: 34px; height: 34px; }
  .story-path__inner {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 2px 0 24px 40px;
  }
  .story-path__intro { font-size: 16px; line-height: 1.78; }
  .story-path__links a {
    min-height: 54px;
    padding: 12px 0;
    font-size: 14px;
  }
  .memory-next-link { margin:22px auto 16px; padding:15px 0; gap:7px 14px; }
  .memory-next-copy { font-size:15px; line-height:1.65; }
  .controls { bottom:max(10px,env(safe-area-inset-bottom)) !important; }
  .body-copy,
  .detail-list,
  .reflection-copy { font-size:max(16px,1em) !important; line-height:1.72 !important; }
}

@media (prefers-reduced-motion: reduce) {
  .memory-weather { animation:none; transition:none; }
  .memory-reader-menu__toggle,
  .memory-reader-menu__panel,
  .story-path__panel,
  .story-path__time::after,
  .memory-detail,
  .memory-detail-toggle::after,
  .memory-echo-content,
  .memory-echo-toggle::after,
  .memory-next-link,
  .controls { transition:none !important; }
}

@media print {
  .memory-reader-menu,
  .controls { display:none !important; }
}
