:root {
  color-scheme: light;

  /* —— 纸与墨（封面 / 信笺，保持原样） —— */
  --parchment: #f7f3eb;
  --ink: #302c29;
  --muted: #6d6259;
  --paper: #fffcf6;

  /* —— 深空色彩系统 —— */
  --night: #05060f;                /* 主背景：深空蓝黑 */
  --night-panel: #0a101d;          /* 面板底色：深海军蓝 */
  --night-ink: #f2ece2;            /* 主文字：柔和象牙白 */
  --night-muted: #8f9bb3;          /* 次级文字：灰蓝 */
  --champagne: #e7c79b;            /* 强调：香槟金 */
  --champagne-dim: #c3a67f;        /* 弱化的金 */
  --warm-white: #f6ecdf;           /* 辅助光：低饱和暖白 */
  --silver: #c0c8d5;
  --gold: #eac995;

  /* —— 细线 / 光效 —— */
  --hairline: rgba(232, 214, 188, .10);
  --hairline-soft: rgba(232, 214, 188, .07);
  --hairline-lit: rgba(231, 199, 155, .26);
  --glow-warm: rgba(231, 199, 155, .45);
  --glass: linear-gradient(180deg, rgba(24, 30, 48, .55), rgba(9, 13, 23, .48));

  /* —— 字体体系 —— */
  --serif: "Songti SC", "Noto Serif CJK SC", "SimSun", "STSong", "STZhongsong", serif;
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "HarmonyOS Sans SC", "Source Han Sans SC", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --ease-soft: cubic-bezier(.22, .61, .36, 1);

  font-family: var(--sans);
  background: var(--parchment);
  color: var(--ink);
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html,body { overflow:hidden; height:100%; }
body { margin: 0; -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 4px;
}
section:focus, article:focus { outline: none; }
h1, h2, p { margin: 0; }

main > section { position:relative; width:100%; height:100vh; height:100dvh; overflow:hidden; }
.cover,.letter { background:radial-gradient(ellipse at 48% 38%,#fffcf5,#f4eee3 88%); }
.cover { display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; padding:5vh 1rem 11vh; }
.cover-copy { z-index:1; }
.cover h1 { font:500 clamp(2.25rem,6vw,4.65rem)/1.4 var(--serif); letter-spacing:.09em; }
.cover h1 span,.cover-copy p span { display:inline-block; }
.cover-copy p { color:var(--muted); margin-top:1rem; font:1rem/1.9 var(--serif); letter-spacing:.05em; }
.cover-art { width:min(40rem,85vw,62vh); height:auto; min-height:0; object-fit:contain; mix-blend-mode:multiply; mask-image:radial-gradient(ellipse closest-side,#000 72%,transparent 100%); }
.cover-link { position:absolute; inset:0; z-index:2; display:flex; justify-content:center; align-items:flex-end; padding-bottom:max(6vh,env(safe-area-inset-bottom)); text-decoration:none; }
.cover-link span,.letter-link { border-bottom:1px solid #b7a38d; padding:.6rem .15rem; color:#614f41; font:1rem/1.4 var(--serif); letter-spacing:.12em; }
.cover-link b { font-weight:400; margin-left:.5rem; }
.letter { display:grid; align-content:center; justify-items:center; padding:4rem 1.5rem; }
.letter-back,.atlas-title a { color:var(--muted); text-decoration:none; font-size:.85rem; padding:.75rem 0; display:inline-block; }
.letter-back { position:absolute; left:max(1.4rem,4vw); top:max(.8rem,env(safe-area-inset-top)); }
.envelope { width:min(28rem,82vw,93vh); aspect-ratio:1.68; position:relative; isolation:isolate; background:#dbc7aa; overflow:hidden; border:1px solid #c7b395; border-radius:3px; box-shadow:1px 17px 32px -12px #5b402b59; color:#54432f; }
.envelope-paper,.envelope-flap { position:absolute; inset:0; }
.envelope-paper { background:linear-gradient(35deg,#e2cfad,#f1e3c9 48%,#dfc8a6); clip-path:polygon(0 0,50% 49%,100% 0,100% 100%,0 100%); }
.envelope-flap { background:linear-gradient(155deg,#faf1df,#e2d0af); clip-path:polygon(0 0,100% 0,52% 57%,49% 58%); }
.seal { position:absolute; top:55%; left:50%; translate:-50% -50%; background:radial-gradient(at 30% 23%,#aa6754,#814739); border:3px double #ac7261; box-shadow:0 2px 3px #754e414f; width:2.3rem; height:2.3rem; border-radius:46% 48% 44% 48%; display:grid; place-items:center; color:#dfbba1; font-size:1.25rem; }
.address { position:absolute; bottom:11%; right:8%; font:clamp(1.1rem,3vw,1.4rem) var(--serif); letter-spacing:.16em; }
.address small { font-size:.68em; margin-left:.4em; }
.seal-hint { margin-top:2.3rem; color:var(--muted); font:.9rem var(--serif); letter-spacing:.1em; }
.envelope[hidden] + .seal-hint { display:none; }
.letter:has(.paper:not([hidden])) {
  grid-template-rows:minmax(0,1fr); align-items:center;
  padding:max(3.8rem,calc(env(safe-area-inset-top) + 3rem)) clamp(.75rem,3vw,2rem) max(1rem,env(safe-area-inset-bottom));
}
.paper {
  width:min(46rem,100%); max-height:100%; min-height:0; overflow:auto; overscroll-behavior:contain;
  padding:clamp(1.5rem,5vw,3.6rem) clamp(1.35rem,4.6vw,3.4rem);
  background:
    radial-gradient(140% 90% at 50% -10%, #fffdf8 0%, #fffaf0 46%, #fbf3e4 100%);
  border:1px solid #ded1bf; box-shadow:0 14px 50px #533c2414, inset 0 0 60px rgba(206,182,148,.08);
  animation:unfold .9s var(--ease-soft) both;
  font:clamp(1rem,1.35vw,1.12rem)/2.06 var(--serif); letter-spacing:.015em; color:#4f4137;
  scrollbar-width:thin; scrollbar-color:#cabbab #fffaf0;
}
@keyframes unfold { from { opacity:0; transform:translateY(14px) rotateX(-7deg); } }
.paper > * { animation:letter-rise .95s var(--ease-soft) both; }
.paper > *:nth-child(1) { animation-delay:.10s; }
.paper > *:nth-child(2) { animation-delay:.18s; }
.paper > *:nth-child(3) { animation-delay:.26s; }
.paper > *:nth-child(4) { animation-delay:.34s; }
.paper > *:nth-child(5) { animation-delay:.42s; }
.paper > *:nth-child(6) { animation-delay:.50s; }
.paper > *:nth-child(7) { animation-delay:.58s; }
.paper > *:nth-child(8) { animation-delay:.66s; }
.paper > *:nth-child(n+9) { animation-delay:.74s; }
@keyframes letter-rise { from { opacity:0; translate:0 10px; } to { opacity:1; translate:0 0; } }
.paper h2 { font:500 clamp(1.3rem,3vw,1.65rem)/1.6 var(--serif); letter-spacing:.04em; }
.paper p { margin-top:1em; }
.paper .letter-verse { margin:1.2em 0 1.65em; padding-left:1em; border-left:1px solid #c6b395; letter-spacing:.08em; }
.letter-link { display:block; width:fit-content; margin:1.65rem 0 0 auto; text-decoration:none; }
.letter-link span { margin-left:.5em; }

/* ============================================================
   星河回笺 · 深空舞台
   ============================================================ */
.night,.galaxy { background:var(--night); color:var(--night-ink); }
.galaxy { isolation:isolate; }
.galaxy,.galaxy-scene,.memory-stars,.binary-stars,.galaxy-scene canvas { position:absolute; inset:0; width:100%; height:100%; }
.galaxy-scene { touch-action:none; cursor:grab; user-select:none; }
.galaxy-scene:active { cursor:grabbing; }

/* 电影感的暗角：只在边缘压暗，不动星体本身 */
.galaxy::after {
  content:""; position:absolute; inset:0; z-index:0; pointer-events:none;
  background:radial-gradient(ellipse 82% 74% at 52% 47%,
    rgba(4,6,14,0) 48%, rgba(4,6,14,.30) 76%, rgba(2,3,9,.62) 100%);
}

.binary-stars { pointer-events:none; }
.galaxy button[data-sun] { position:absolute; top:0; left:0; translate:-50% -50%; width:44px; height:44px; padding:0; border:0; border-radius:50%; pointer-events:auto; background:transparent; }
/* 未命名时的悬停提示（命名后由 .sun-name 常驻显示，这里自动让位） */
.binary-stars button::after {
  content:attr(data-hint);
  position:absolute; top:calc(100% + 1px); left:50%; translate:-50% 0;
  white-space:nowrap; pointer-events:none;
  font:400 .7rem/1.7 var(--serif); letter-spacing:.14em;
  color:rgba(240,232,218,.72);
  text-shadow:0 1px 10px rgba(2,4,10,.95), 0 0 24px rgba(2,4,10,.85);
  opacity:0; transition:opacity .6s var(--ease-soft);
}
.binary-stars button[data-name=""]:is(:hover,:focus-visible)::after { opacity:.75; }
.binary-stars button:focus-visible { outline:1px solid rgba(231,199,155,.35); outline-offset:4px; }
/* 双星姓名：由 draw() 按真实投影位置逐帧摆放，左右分列，字重一致 */
.sun-name {
  position:absolute; left:0; top:0;
  white-space:nowrap; pointer-events:none; will-change:transform;
  font:400 clamp(.72rem,.95vw,.82rem)/1.6 var(--serif); letter-spacing:.16em;
  opacity:0; transition:opacity .9s var(--ease-soft);
  text-shadow:0 1px 2px rgba(2,4,10,.96), 0 0 10px rgba(2,4,10,.92), 0 0 24px rgba(2,4,10,.8);
}
.sun-name.is-on { opacity:.92; }
.sun-name[data-sun-name="silver"] { color:#f4eee3; }
.sun-name[data-sun-name="gold"] { color:rgba(231,199,155,.94); }

.memory-stars { pointer-events:none; overflow:hidden; }
.memory-star { position:absolute; left:0; top:0; translate:-50% -50%; width:44px; height:44px; border:0; border-radius:50%; background:transparent; pointer-events:auto; }
/* 选中星：缓慢呼吸的香槟金辉光（不动画数值，纯 CSS，不占渲染帧） */
.memory-star::before {
  content:""; position:absolute; inset:-12px; border-radius:50%; opacity:0;
  background:radial-gradient(circle, rgba(255,236,206,.42) 0%, rgba(231,199,155,.18) 44%, rgba(231,199,155,0) 72%);
  transition:opacity .8s var(--ease-soft);
}
.memory-star.is-lit::before { opacity:1; animation:breathe 5.2s ease-in-out infinite; }
@keyframes breathe {
  0%,100% { opacity:.5; transform:scale(.86); }
  50%     { opacity:1;  transform:scale(1.14); }
}
.memory-star:is(:hover,:focus-visible) { outline:none; box-shadow:inset 0 0 0 1px rgba(231,199,155,.26); }
.memory-star:focus-visible { box-shadow:inset 0 0 0 1px rgba(231,199,155,.5), 0 0 24px -6px rgba(231,199,155,.45); }

/* —— 左上标题 —— */
.atlas-title,.atlas-tools,.sky-legend,.galaxy-hint,.camera-controls,.add-memory { position:absolute; z-index:1; }
.galaxy { --edge:clamp(1.25rem,3.8vw,4rem); --foot:max(1.4rem,env(safe-area-inset-bottom)); }
.atlas-title { left:var(--edge); top:max(1rem,env(safe-area-inset-top)); pointer-events:none; }
.atlas-title a {
  pointer-events:auto; color:rgba(160,170,196,.78); font:.76rem/1 var(--sans);
  letter-spacing:.16em; padding:.55rem 0; transition:color .4s var(--ease-soft);
}
.atlas-title a:hover { color:var(--champagne); }
.atlas-title h2 {
  font:400 clamp(1.8rem,3.15vw,2.95rem)/1.42 var(--serif); letter-spacing:.2em;
  color:#f5efe5; text-shadow:0 2px 30px rgba(3,5,12,.92), 0 0 60px rgba(231,199,155,.07);
}
.atlas-title p { margin-top:.55rem; font:.68rem/1.7 var(--sans); letter-spacing:.22em; color:rgba(155,166,190,.75); }
.atlas-title i { font-style:normal; color:rgba(231,199,155,.65); }

/* —— 右上工具 —— */
.atlas-tools { right:var(--edge); top:max(1.6rem,env(safe-area-inset-top)); display:flex; align-items:center; gap:.5rem; }

/* 所有星图按钮：低对比玻璃 */
.galaxy button:not(.memory-star,[data-sun]) {
  color:rgba(214,220,234,.9);
  background:var(--glass);
  border:1px solid var(--hairline);
  border-radius:999px;
  font-size:.78rem; letter-spacing:.12em;
  min-height:40px; padding:0 1.05rem;
  -webkit-backdrop-filter:blur(12px) saturate(118%);
  backdrop-filter:blur(12px) saturate(118%);
  box-shadow:inset 0 1px 0 rgba(255,246,232,.055);
  transition:color .4s var(--ease-soft), border-color .4s var(--ease-soft),
             background-color .4s var(--ease-soft), box-shadow .4s var(--ease-soft);
}
.galaxy button:not(.memory-star,[data-sun]):hover {
  color:#f3e2c6; border-color:var(--hairline-lit);
  background:linear-gradient(180deg, rgba(44,38,30,.55), rgba(16,15,22,.5));
  box-shadow:inset 0 1px 0 rgba(255,246,232,.09), 0 0 28px -12px var(--glow-warm);
}

/* —— 星海留声：一枚小小的唱片，不抢星系的光 —— */
.galaxy button.vinyl {
  width:38px; height:38px; min-height:38px; padding:0;
  border-radius:50%;
  background:radial-gradient(circle at 50% 34%, #1b2438, #0a0f1c 72%);
  border:1px solid rgba(232,214,188,.14);
  box-shadow:inset 0 1px 0 rgba(255,246,232,.06), 0 8px 20px -14px #000, 0 0 16px -8px rgba(231,199,155,.4);
  display:grid; place-items:center; position:relative;
  transition:border-color .5s var(--ease-soft), box-shadow .5s var(--ease-soft), background-color .5s;
}
.galaxy button.vinyl:hover {
  background:radial-gradient(circle at 50% 34%, #232d45, #0c1220 72%);
  border-color:rgba(231,199,155,.34);
  box-shadow:inset 0 1px 0 rgba(255,246,232,.1), 0 0 24px -6px rgba(231,199,155,.45);
}
.vinyl-disc {
  width:26px; height:26px; border-radius:50%;
  background:
    radial-gradient(circle, #f6e9d3 0 2.6px, rgba(246,233,211,.42) 2.6px 3.6px, transparent 3.6px),
    radial-gradient(circle at 50% 36%, #182136, #090e19 74%);
  box-shadow:inset 0 0 0 1px rgba(232,214,188,.14);
  position:relative; display:block;
}
.vinyl-disc::before {
  content:""; position:absolute; inset:3px; border-radius:50%;
  background:repeating-radial-gradient(circle at 50% 50%, rgba(232,224,208,.135) 0 1px, transparent 1px 3px);
}
.vinyl-disc::after {
  content:""; position:absolute; inset:0; border-radius:50%;
  background:conic-gradient(from 0deg, transparent 0deg, rgba(255,244,224,.18) 34deg, transparent 96deg);
  opacity:.7;
}
.vinyl.is-open .vinyl-disc { animation:vinyl-spin 16s linear infinite; }
@keyframes vinyl-spin { to { transform:rotate(360deg); } }
.vinyl.is-open {
  border-color:rgba(231,199,155,.32);
  box-shadow:inset 0 1px 0 rgba(255,246,232,.1), 0 0 26px -6px rgba(231,199,155,.5);
}
.vinyl.is-open::before {
  content:""; position:absolute; inset:-7px; border-radius:50%; pointer-events:none;
  border:1px solid rgba(231,199,155,.18);
  animation:vinyl-halo 4.6s ease-in-out infinite;
}
@keyframes vinyl-halo {
  0%,100% { opacity:.35; transform:scale(.94); }
  50% { opacity:.85; transform:scale(1.04); }
}

/* —— 留声面板：只在点开时加载 iframe —— */
.music-panel {
  position:absolute; z-index:2; right:var(--edge);
  top:calc(max(1.6rem, env(safe-area-inset-top)) + 3.9rem);
  width:354px; max-width:calc(100vw - 2rem);
  max-height:calc(100dvh - 5.5rem); overflow-y:auto; overscroll-behavior:contain;
  padding:10px 12px 12px; border-radius:16px;
  background:linear-gradient(165deg, rgba(17,24,40,.84), rgba(8,12,22,.92));
  border:1px solid var(--hairline);
  -webkit-backdrop-filter:blur(18px) saturate(122%);
  backdrop-filter:blur(18px) saturate(122%);
  box-shadow:0 30px 70px -32px #000, inset 0 1px 0 rgba(255,246,232,.06);
  animation:music-in .5s var(--ease-soft) both;
  transition:right .6s var(--ease-soft);
}
@keyframes music-in { from { opacity:0; translate:0 -8px; } to { opacity:1; translate:0 0; } }
.music-head { display:flex; align-items:center; justify-content:space-between; gap:.6rem; margin-bottom:8px; }
.music-head-actions { display:flex; align-items:center; gap:.3rem; }
.music-title { font:400 .66rem/1 var(--sans); letter-spacing:.3em; color:rgba(231,199,155,.7); }
/* 曲目开关：是我们自己的按钮，只改容器高度，不碰 iframe */
.galaxy button.music-tracks {
  height:24px; min-height:24px; padding:0 .5rem; border-radius:999px;
  display:inline-flex; align-items:center; gap:.32rem;
  background:transparent; border:1px solid transparent; box-shadow:none;
  color:rgba(206,214,230,.58); font-size:.62rem; line-height:1; letter-spacing:.14em;
  transition:color .35s var(--ease-soft), border-color .35s, background-color .35s;
}
.galaxy button.music-tracks:hover {
  color:var(--champagne); border-color:var(--hairline-lit);
  background:rgba(231,199,155,.06); box-shadow:none;
}
.music-tracks i {
  width:0; height:0; border-left:3.5px solid transparent; border-right:3.5px solid transparent;
  border-top:4px solid currentColor; opacity:.7;
  transition:transform .45s var(--ease-soft);
}
.music-tracks[aria-expanded="true"] i { transform:rotate(180deg); }
.galaxy button.music-close {
  width:26px; height:26px; min-height:26px; padding:0; border-radius:50%;
  display:grid; place-items:center; line-height:1;
  border:1px solid var(--hairline); background:transparent; color:rgba(206,214,230,.7);
  font-size:1rem; box-shadow:none;
  transition:color .35s, border-color .35s, background-color .35s;
}
.galaxy button.music-close:hover { color:var(--champagne); border-color:var(--hairline-lit); background:rgba(231,199,155,.07); box-shadow:none; }
.music-frame {
  width:330px; max-width:100%; height:110px;
  border-radius:10px; overflow:hidden; background:#080d18;
  border:1px solid rgba(232,214,188,.06);
  transition:height .5s var(--ease-soft);
  scrollbar-width:thin;
}
.music-frame.is-open { height:430px; }
/* iframe 本身始终 330×430：容器只做裁切，展开时也不触碰它 */
.music-frame iframe { display:block; width:100%; height:430px; border:0; }
.music-foot { display:flex; align-items:center; gap:.5rem; margin-top:8px; min-height:18px; }
.music-note { color:rgba(150,162,186,.7); font:.62rem/1.5 var(--sans); letter-spacing:.02em; }
.music-note.is-alert { color:rgba(255,196,164,.88); }
.music-link {
  margin-left:auto; white-space:nowrap; text-decoration:none;
  color:rgba(231,199,155,.82); font:.64rem/1 var(--sans); letter-spacing:.1em;
  transition:color .35s var(--ease-soft);
}
.music-link:hover { color:#f8e6c8; }
.music-link i { font-style:normal; font-size:.9em; padding-left:.25em; opacity:.8; }
/* 记忆卡片打开时让位，音乐本身不受影响 */
body:has(#memory-detail[open]) .music-panel { right:calc(var(--edge) + clamp(19rem, 30vw, 27rem)); }

/* —— 图例 —— */
.sky-legend {
  left:var(--edge); bottom:calc(var(--foot) + 3.9rem);
  display:grid; gap:.6rem; pointer-events:none;
  color:rgba(163,174,196,.78); font:.67rem/1 var(--sans); letter-spacing:.22em;
  text-shadow:0 1px 12px rgba(3,5,12,.95), 0 0 24px rgba(3,5,12,.7);
}
.sky-legend span { display:flex; align-items:center; gap:.8rem; }
.sky-legend i { display:inline-block; width:4px; height:4px; margin-inline:2px; border-radius:50%; background:#bddaff; box-shadow:0 0 7px rgba(189,218,255,.75); }
.sky-legend span:nth-child(2) i { width:6px; height:6px; margin-inline:1px; background:#ebd3f2; box-shadow:0 0 9px rgba(235,211,242,.6); }
.sky-legend span:nth-child(3) i { width:8px; height:8px; margin-inline:0; background:#ffdfb6; box-shadow:0 0 12px rgba(255,223,182,.7); }

/* —— 底部控制：像悬浮在空间里的仪器，而不是工具栏 —— */
.camera-controls {
  bottom:var(--foot); left:var(--edge); display:flex; align-items:stretch;
  border-radius:999px; overflow:hidden;
  border:1px solid var(--hairline);
  background:var(--glass);
  -webkit-backdrop-filter:blur(16px) saturate(120%);
  backdrop-filter:blur(16px) saturate(120%);
  box-shadow:inset 0 1px 0 rgba(255,246,232,.055), 0 24px 50px -34px #000;
}
.galaxy .camera-controls button:not(.memory-star) {
  border:0; border-radius:0; background:transparent; box-shadow:none;
  min-width:42px; padding:0 .62rem; color:rgba(206,212,228,.82);
  -webkit-backdrop-filter:none; backdrop-filter:none;
}
.galaxy .camera-controls button:not(.memory-star):hover {
  color:var(--champagne); background:rgba(231,199,155,.055);
  box-shadow:inset 0 0 24px -12px var(--glow-warm);
}
.camera-controls button + button { box-shadow:inset 1px 0 0 var(--hairline-soft); }
.galaxy .camera-controls button + button:hover { box-shadow:inset 1px 0 0 var(--hairline-soft), inset 0 0 24px -12px var(--glow-warm); }

.add-memory { bottom:var(--foot); right:var(--edge); }
.galaxy .add-memory { color:rgba(240,220,190,.92); border-color:rgba(231,199,155,.2); padding:0 1.15rem; }
.galaxy .add-memory:hover { color:#fbeed6; border-color:rgba(231,199,155,.4); background:linear-gradient(180deg, rgba(56,44,30,.6), rgba(20,17,20,.5)); }

/* —— 底部提示：空间中的注脚 —— */
.galaxy-hint {
  bottom:calc(var(--foot) + .45rem); left:0; right:0;
  display:flex; align-items:center; justify-content:center;
  color:rgba(158,169,192,.74); font:.68rem/2 var(--sans); letter-spacing:.26em;
  pointer-events:none; text-shadow:0 1px 12px rgba(3,5,12,.9);
}
.galaxy-hint span { position:relative; padding:0 1.5rem; }
.galaxy-hint span + span::before {
  content:""; position:absolute; left:0; top:50%; width:3px; height:3px; margin-top:-1.5px;
  border-radius:50%; background:var(--champagne); opacity:.42;
  box-shadow:0 0 8px rgba(231,199,155,.55);
}

/* —— 底部回忆叙事：像有人在你身旁，轻声说起那一年 —— */
.memory-caption {
  position:absolute; z-index:1;
  left:0; right:0; bottom:calc(var(--foot) + 6.6rem);
  display:flex; justify-content:center;
  padding-inline:var(--edge);
  padding-right:var(--edge);
  pointer-events:none;
  transition:padding-right .65s var(--ease-soft), opacity .5s var(--ease-soft);
}
body:has(#memory-detail[open]) .memory-caption {
  padding-right:calc(var(--edge) + clamp(19rem, 30vw, 27rem));
}
.memory-caption p {
  position:relative;
  width:min(34rem, 46vw); margin:0; text-align:center;
  font:400 clamp(.94rem, 1.05vw, 1.06rem)/2.1 var(--serif);
  letter-spacing:.055em; color:#f0e9dc;
  text-shadow:0 2px 22px rgba(3,5,12,.92), 0 0 44px rgba(3,5,12,.55);
  opacity:1; translate:0 0;
  transition:opacity .5s var(--ease-soft), translate .55s var(--ease-soft);
}
/* 一块几乎没有边界的暗色空气，只是让文字从星尘里浮出来 */
.memory-caption p::before {
  content:""; position:absolute; z-index:-1; inset:-1.7rem -2.4rem;
  background:radial-gradient(ellipse at 50% 50%, rgba(3,5,13,.72) 0%, rgba(3,5,13,.46) 46%, rgba(3,5,13,0) 78%);
  pointer-events:none;
}
.memory-caption p em { font-style:normal; color:var(--champagne); }
.memory-caption.is-guide p { color:rgba(198,206,224,.9); font-size:.85rem; letter-spacing:.16em; }
.memory-caption.is-leaving p { opacity:0; translate:0 -6px; }
.memory-caption.is-entering p { opacity:0; translate:0 10px; }

/* ============================================================
   记忆卡片 · 悬浮在深空里的记忆载体
   ============================================================ */
#memory-detail {
  position:fixed; z-index:3;
  top:50%; right:clamp(.9rem,2.8vw,3rem); left:auto; margin:0;
  transform:translateY(-50%);
  width:clamp(19rem,30vw,26rem);
  max-height:calc(100dvh - 9rem);
  padding:0;
  color:var(--night-ink); color-scheme:dark;
  border:1px solid rgba(232,214,188,.085);
  border-top-color:rgba(255,240,214,.12);
  border-radius:20px;
  background:
    radial-gradient(120% 70% at 100% 0%, rgba(231,199,155,.07), transparent 58%),
    radial-gradient(110% 70% at 0% 100%, rgba(120,150,200,.075), transparent 62%),
    linear-gradient(165deg, rgba(16,23,38,.76) 0%, rgba(9,13,23,.83) 58%, rgba(7,10,18,.88) 100%);
  -webkit-backdrop-filter:blur(16px) saturate(120%);
  backdrop-filter:blur(16px) saturate(120%);
  box-shadow:
    0 34px 90px -36px rgba(0,0,0,.95),
    0 0 80px -46px var(--glow-warm),
    inset 0 1px 0 rgba(255,246,232,.075),
    inset 0 -1px 0 rgba(0,0,0,.4),
    inset 0 0 60px -30px rgba(231,199,155,.12);
  scrollbar-width:thin; scrollbar-color:rgba(231,199,155,.22) transparent;
  animation:card-in .6s var(--ease-soft) both;
}
@keyframes card-in {
  from { opacity:0; translate:0 14px; }
  to   { opacity:1; translate:0 0; }
}
#memory-detail::-webkit-scrollbar { width:6px; }
#memory-detail::-webkit-scrollbar-thumb { background:rgba(231,199,155,.16); border-radius:99px; }
#memory-detail .sheet { padding:clamp(1.15rem,2.1vw,1.75rem); }

#memory-detail .memory-close {
  position:sticky; top:0; float:right; z-index:2;
  margin:-.2rem -.15rem 0 .5rem;
  width:34px; height:34px; padding:0;
  display:grid; place-items:center;
  color:rgba(206,214,230,.7); font-size:1.15rem; line-height:1; font-weight:300;
  background:rgba(12,17,29,.45);
  border:1px solid var(--hairline); border-radius:50%;
  -webkit-backdrop-filter:blur(8px); backdrop-filter:blur(8px);
  transition:color .35s var(--ease-soft), border-color .35s, background-color .35s;
}
#memory-detail .memory-close:hover { color:var(--champagne); border-color:var(--hairline-lit); background:rgba(231,199,155,.075); }

#memory-detail .memory-header { padding-right:0; }
#memory-detail #memory-content.is-swapping { animation:ink-in .5s var(--ease-soft) both; }
@keyframes ink-in { from { opacity:0; translate:0 8px; filter:blur(3px); } to { opacity:1; translate:0 0; filter:blur(0); } }

.memory-meta {
  display:flex; align-items:baseline; flex-wrap:wrap; gap:.5rem .9rem;
  color:rgba(148,160,184,.88); font:.68rem/1.5 var(--sans); letter-spacing:.2em;
}
.memory-meta time { font-variant-numeric:tabular-nums; }
.memory-kind { color:rgba(231,199,155,.8); }
.memory-kind::before { content:"✦"; font-size:.62em; margin-right:.6em; vertical-align:.15em; opacity:.72; }
#memory-detail .memory h2 {
  margin:.9rem 0 1.3rem; overflow-wrap:anywhere;
  font:400 clamp(1.28rem,2.1vw,1.68rem)/1.52 var(--serif); letter-spacing:.06em;
  color:#f7f1e7; text-shadow:0 2px 24px rgba(0,0,0,.45);
}
#memory-detail .memory h2:focus, #memory-detail .memory h2:focus-visible { outline:none; }

.memory-media {
  position:relative;
  border:1px solid rgba(232,214,188,.08); border-radius:14px; overflow:hidden;
  background:rgba(9,14,25,.7);
  box-shadow:0 26px 50px -38px #000;
}
.memory-media img { width:100%; max-height:32dvh; display:block; object-fit:contain; }
#memory-detail .memory-media { margin-top:.15rem; }
/* 照片边缘向内收一点光，避免生硬的矩形切边 */
.memory-media::after {
  content:""; position:absolute; inset:0; border-radius:inherit; pointer-events:none;
  box-shadow:inset 0 0 0 1px rgba(255,246,232,.05), inset 0 0 44px rgba(4,6,14,.42);
}

.memory-body {
  margin:1.3rem 0 0; color:#e6e3db;
  font-size:1.0125rem; line-height:2.02; letter-spacing:.012em;
}
.memory-empty {
  margin:1.4rem 0 .2rem; color:rgba(150,162,186,.82);
  font:400 .92rem/1.9 var(--serif); letter-spacing:.08em;
}
.memory-body, .voice p { white-space:pre-wrap; overflow-wrap:anywhere; }

/* 双方对话：没有表格线，只有身份色与一道渐隐的发丝线 */
.voices { display:grid; gap:1.6rem; margin-top:2.1rem; background:none; border:0; }
.voice { display:grid; gap:.55rem; background:none; padding:0; }
.voice h3 {
  display:flex; align-items:center; gap:.7rem; margin:0;
  font:400 .68rem/1 var(--sans); letter-spacing:.3em;
}
.voice h3::before {
  content:""; width:4px; height:4px; flex:0 0 auto; border-radius:50%;
  background:currentColor; box-shadow:0 0 9px currentColor; opacity:.85;
}
.voice h3::after {
  content:""; flex:1; height:1px;
  background:linear-gradient(90deg, currentColor, transparent 72%);
  opacity:.16;
}
.voices .voice[data-voice="yu"] h3 { color:var(--champagne); }
.voices .voice[data-voice="nuan"] h3 { color:rgba(246,236,223,.92); }
.voice p { margin:0; color:rgba(226,228,234,.94); font-size:.98rem; line-height:1.98; letter-spacing:.012em; }

/* 底部操作：降权，退到正文之后 */
.memory-actions {
  margin-top:2.15rem; padding-top:1.15rem; border-top:1px solid var(--hairline-soft);
  display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:.35rem 1rem;
}
.edit-voices, .next-memory {
  display:inline-flex; align-items:center; min-height:40px; padding:0;
  background:none; border:none; text-decoration:none;
  font:.74rem/1 var(--sans); letter-spacing:.14em;
  color:rgba(146,158,182,.72);
  transition:color .4s var(--ease-soft);
}
.edit-voices:hover { color:var(--champagne); }
.next-memory { color:rgba(231,199,155,.72); }
.next-memory:hover { color:var(--champagne); }
.next-memory::before { content:"✦"; font-size:.7em; padding-right:.6em; opacity:.8; }

/* ============================================================
   表单 / 对话框（记录 · 索引 · 命名）
   ============================================================ */
.record-button {
  display:inline-flex; justify-content:center; align-items:center; min-height:46px; padding:.55rem 1.15rem;
  background:linear-gradient(180deg,#e9cda4,#d9b98f); color:#241d16;
  font-size:.82rem; letter-spacing:.14em;
  border:1px solid rgba(255,240,214,.35); border-radius:999px;
  box-shadow:inset 0 1px 0 rgba(255,250,238,.5), 0 14px 30px -20px rgba(231,199,155,.9);
  transition:translate .4s var(--ease-soft), background-color .4s, box-shadow .4s;
}
.record-button:hover { translate:0 -1px; box-shadow:inset 0 1px 0 rgba(255,250,238,.6), 0 18px 36px -20px rgba(231,199,155,1); }
.record-button:active { translate:0 1px; }

body:has(dialog[open]) { overflow: hidden; }
dialog {
  margin:auto; width:min(100% - 1.25rem, 34rem); max-height:min(90dvh, 48rem); overflow:auto;
  padding:0; overscroll-behavior:contain;
  color:var(--night-ink); color-scheme:dark;
  background:linear-gradient(168deg,#151d2f,#0a101c 78%);
  border:1px solid var(--hairline); border-radius:18px;
  box-shadow:0 34px 100px -30px rgba(0,0,0,.92), inset 0 1px 0 rgba(255,246,232,.05);
  scrollbar-width:thin; scrollbar-color:rgba(231,199,155,.2) transparent;
}
dialog::backdrop { background:rgba(4,6,13,.6); }
.sheet { padding:clamp(1rem,5vw,2rem); }
.sheet-header { display:flex; justify-content:space-between; align-items:center; gap:.7rem; margin-bottom:1rem; }
.sheet h2 { font:400 1.6rem/1.5 var(--serif); letter-spacing:.1em; color:#f4eee5; }
.close {
  width:42px; height:42px; flex:0 0 auto;
  border:1px solid var(--hairline); border-radius:50%; background:transparent; color:inherit; font-size:1.5rem;
  transition:border-color .35s, background-color .35s, color .35s;
}
.close:hover { background:rgba(231,199,155,.08); border-color:var(--hairline-lit); color:var(--champagne); }
.close:focus-visible, #memory-detail .memory-close:focus-visible {
  outline:1px solid rgba(231,199,155,.5); outline-offset:2px;
}

/* ============================================================
   双星 · 命名与介绍
   ============================================================ */
.star-sheet { position:relative; }
.star-eyebrow { margin:0 0 1rem; color:rgba(231,199,155,.72); font:.64rem/1.4 var(--sans); letter-spacing:.34em; }
.star-lead {
  margin:0 0 clamp(1.2rem,3vw,1.6rem); padding-left:.95rem;
  border-left:1px solid rgba(231,199,155,.24);
  color:rgba(228,234,245,.84);
  font:400 clamp(.9rem,1.3vw,.98rem)/2.05 var(--serif); letter-spacing:.05em;
}
.star-fields { gap:1.05rem; margin-bottom:1.1rem; }
.star-field { display:grid; gap:.5rem; }
.star-field .star-label {
  display:flex; align-items:center; gap:.55rem;
  font:.72rem/1 var(--sans); letter-spacing:.2em; color:rgba(176,186,206,.92);
}
.star-label i { width:6px; height:6px; border-radius:50%; flex:0 0 auto; }
.star-field[data-star="silver"] .star-label i { background:#e9effb; box-shadow:0 0 10px rgba(219,229,250,.85); }
.star-field[data-star="gold"] .star-label i { background:#f0d2a4; box-shadow:0 0 10px rgba(231,199,155,.85); }
.star-field input {
  font:400 1rem/1.4 var(--serif); letter-spacing:.1em;
  min-height:48px; padding:.6rem .85rem; border-radius:10px;
}
.star-field input::placeholder { color:rgba(148,160,184,.5); letter-spacing:.1em; }
.star-submit { width:100%; margin-top:.3rem; letter-spacing:.24em; }
.star-note { margin:.9rem 0 0; text-align:center; color:rgba(140,152,178,.68); font:.68rem/1.8 var(--sans); letter-spacing:.12em; }

.star-intro .close { position:absolute; top:.85rem; right:.85rem; width:36px; height:36px; font-size:1.2rem; }
.star-names {
  display:flex; align-items:baseline; gap:.7rem; flex-wrap:wrap;
  margin:.15rem 0 1.15rem;
  font:400 clamp(1.5rem,4vw,1.85rem)/1.4 var(--serif); letter-spacing:.12em; color:#f6f0e6;
}
.star-names span { max-width:9em; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.star-names span:empty, .star-names.is-single i { display:none; }
.star-names i { font-style:normal; color:rgba(231,199,155,.5); font-size:.7em; }
.star-pair {
  list-style:none; margin:0 0 1.5rem; padding:1rem 0;
  border-top:1px solid var(--hairline-soft); border-bottom:1px solid var(--hairline-soft);
  display:grid; gap:.8rem;
}
.star-pair li { display:flex; align-items:center; gap:.65rem; font:.72rem/1 var(--sans); letter-spacing:.18em; color:rgba(160,170,192,.9); }
.star-pair i { width:5px; height:5px; border-radius:50%; flex:0 0 auto; }
.star-pair li[data-star="silver"] i { background:#e9effb; box-shadow:0 0 9px rgba(219,229,250,.8); }
.star-pair li[data-star="gold"] i { background:#f0d2a4; box-shadow:0 0 9px rgba(231,199,155,.8); }
.star-pair strong { margin-left:auto; font:400 .95rem/1 var(--serif); letter-spacing:.1em; color:#f2ecdf; }
.star-pair li[data-star="silver"] strong { color:#f4eee3; }
.star-pair li[data-star="gold"] strong { color:rgba(231,199,155,.95); }
.star-edit {
  width:100%; min-height:46px; border-radius:999px;
  background:var(--glass); border:1px solid var(--hairline); color:rgba(226,232,244,.92);
  font-size:.78rem; letter-spacing:.2em;
  transition:color .4s var(--ease-soft), border-color .4s, background-color .4s, box-shadow .4s;
}
.star-edit:hover {
  color:var(--champagne); border-color:var(--hairline-lit);
  background:rgba(231,199,155,.06); box-shadow:0 0 30px -14px var(--glow-warm);
}
.year-picker { display:flex; align-items:center; gap:.75rem; color:var(--night-muted); font-size:.8rem; letter-spacing:.14em; }
select, input, textarea {
  color:var(--night-ink); background:rgba(8,13,23,.75); border:1px solid rgba(232,214,188,.13); border-radius:8px;
  min-width:0; max-width:100%; padding:.55rem .7rem; min-height:44px;
  transition:border-color .35s, background-color .35s;
}
select:hover, input:hover, textarea:hover { border-color:rgba(232,214,188,.22); }
select:focus, input:focus, textarea:focus { border-color:rgba(231,199,155,.45); background:rgba(10,16,28,.9); }
select:focus-visible, input:focus-visible, textarea:focus-visible { outline:none; border-color:rgba(231,199,155,.5); box-shadow:0 0 0 3px rgba(231,199,155,.1); }
input[type=file]::file-selector-button {
  margin-right:.7rem; padding:.32rem .8rem; min-height:30px;
  font:inherit; font-size:.72rem; letter-spacing:.12em; color:rgba(240,226,203,.9);
  background:rgba(231,199,155,.08); border:1px solid var(--hairline); border-radius:999px; cursor:pointer;
  transition:color .3s, border-color .3s, background-color .3s;
}
input[type=file]::file-selector-button:hover { color:var(--champagne); border-color:var(--hairline-lit); background:rgba(231,199,155,.14); }
.map-list { list-style:none; padding:0; margin:1.2rem 0; border-top:1px solid var(--hairline-soft); }
.map-list li { border-bottom:1px solid var(--hairline-soft); }
.map-list a {
  display:grid; grid-template-columns:1rem minmax(0,1fr); column-gap:.75rem; align-items:baseline;
  padding:.75rem .15rem; min-height:48px; text-decoration:none; overflow-wrap:anywhere;
  transition:color .35s;
}
.map-list a:hover { color:var(--champagne); }
.map-list time { grid-column:2; color:rgba(148,160,184,.8); margin-top:.2rem; font-size:.78rem; letter-spacing:.14em; font-variant-numeric:tabular-nums; }
.map-list .map-icon { color:var(--champagne); font-size:.8rem; }
.form-help, .form-error { line-height:1.7; color:var(--night-muted); margin-bottom:1rem; font-size:.8rem; letter-spacing:.06em; }
.form-error { color:#ffc9ad; }
.form-error:empty { display:none; }
.fields { display:grid; gap:.9rem; margin-bottom:.9rem; }
.fields label { display:grid; gap:.4rem; font-size:.78rem; letter-spacing:.1em; color:rgba(163,174,196,.95); }
.fields textarea { resize:vertical; }
.fields input[type=file] { font-size:.75rem; color:var(--night-muted); }
.space-sheet { width:min(100%, 34rem); }
.space-sheet h3 { font:400 1rem/1.5 var(--serif); color:var(--champagne); }
.space-sheet :is(section, details, #space-picker) { margin-top:1rem; }
.space-sheet details { padding-top:.8rem; border-top:1px solid rgba(231,199,155,.18); }
.space-sheet details .fields { margin-top:.8rem; }
.space-sheet summary { cursor:pointer; }
.space-sheet ul { padding-inline-start:1.25rem; }
.space-sheet li { margin-block:.45rem; overflow-wrap:anywhere; }
.space-sheet button:not(.close,.record-button) { min-height:2.5rem; padding:.3rem .75rem; }
.space-sheet button:disabled,.galaxy .add-memory:disabled { opacity:.55; cursor:default; }
.space-actions { display:flex; flex-wrap:wrap; align-items:center; gap:.5rem; overflow-wrap:anywhere; }
.space-actions #account-email { flex:1 1 12rem; }
.atlas-subject { overflow-wrap:anywhere; }
.atlas-title { max-width:min(58vw, 34rem); }

/* 移动端：卡片变成底部浮起的记忆片 */
@media(max-width:640px) {
  .cover h1 span { display:block; }
  .atlas-tools { flex-direction:column; align-items:flex-end; gap:.35rem; }
  .music-panel { top:calc(max(1.6rem, env(safe-area-inset-top)) + 8.8rem); }
  .atlas-title h2 { letter-spacing:.16em; }
  .galaxy-hint { bottom:calc(var(--foot) + 3.95rem); flex-wrap:wrap; row-gap:.1rem; font-size:.64rem; letter-spacing:.2em; }
  .galaxy-hint span { padding:0 1.05rem; }
  .sky-legend { display:flex; gap:.9rem; bottom:calc(var(--foot) + 6.6rem); font-size:.62rem; letter-spacing:.16em; }
  .sky-legend i { width:3px; height:3px; }
  .sky-legend span:nth-child(2) i { width:4px; height:4px; }
  .sky-legend span:nth-child(3) i { width:5px; height:5px; }
  .memory-caption { bottom:calc(var(--foot) + 9.1rem); padding-inline:1rem; padding-right:1rem; }
  .memory-caption p { width:min(28rem, 86vw); font-size:.9rem; line-height:1.95; letter-spacing:.045em; }
  dialog { margin:auto 0 0; width:100%; max-width:100%; border-radius:18px 18px 0 0; }
  .sheet { padding-bottom:max(1.25rem,env(safe-area-inset-bottom)); }
  #memory-detail .sheet { padding:1rem 1.1rem max(1.1rem,env(safe-area-inset-bottom)); }
}
@media(max-height:480px) {
  .cover-art { width:40vh; }
  .atlas-title h2 { font-size:1.7rem; }
  .sky-legend { display:none; }
}
@media(prefers-reduced-motion:reduce) {
  *,*::before,*::after { animation:none !important; transition:none !important; }
}

/* 中窄屏：面板打开时让图例先退场，避免与底部叙事抢位 */
@media(max-width:1080px) {
  body:has(#memory-detail[open]) .sky-legend { opacity:0; }
  .sky-legend { transition:opacity .45s var(--ease-soft); }
}

/* 记忆卡片的响应式定位 */
@media(max-width:640px) and (orientation:portrait) {
  #memory-detail {
    top:auto; bottom:calc(max(1.4rem,env(safe-area-inset-bottom)) + 3.2rem);
    left:auto; right:.7rem;
    width:calc(100vw - 1.4rem); max-width:calc(100vw - 1.4rem); max-height:48dvh;
    transform:none; border-radius:16px;
  }
  #memory-detail .memory-close { width:32px; height:32px; font-size:1rem; }
  #memory-detail .memory h2 { margin:.7rem 0 1rem; }
  #memory-detail .memory-body { margin-top:1rem; font-size:.95rem; line-height:1.9; }
  #memory-detail .memory-media img { max-height:18dvh; }
  #memory-detail .voices { margin-top:1.4rem; gap:1.1rem; }
  #memory-detail .memory-actions { margin-top:1.5rem; }
  body:has(#memory-detail[open]) .memory-caption { opacity:0; }
  body:has(#memory-detail[open]) .music-panel { right:var(--edge); }
  body:has(#memory-detail[open]) :is(.galaxy-hint,.sky-legend,.camera-controls,.add-memory) { opacity:.18; pointer-events:none; transition:opacity .4s; }
}
@media(max-height:480px) and (orientation:landscape) {
  #memory-detail { max-height:calc(100dvh - 7rem); width:min(38vw,21rem); }
}
