/* ==========================================================================
   放课后，另一个世界 — design system
   One source of truth: color, type, spacing, radius, elevation, motion.
   ========================================================================== */

:root {
  /* Brand / neutral scale */
  --ink:        #17222f;
  --ink-2:      #3a4a5e;
  --ink-3:      #6c7d92;
  --muted:      #8b9aad;
  --paper:      #ffffff;
  --canvas:     #eef3fa;
  --line:       #e3eaf4;
  --line-2:     #cfdaea;
  --tint:       #f4f8fd;

  /* Status */
  --rose:  #e8617a;
  --sun:   #eda33f;
  --mint:  #34b3a0;
  --sky:   #4c8ede;

  /* Unit accents (default: Leo/need) */
  --accent:      #4b62d8;
  --accent-ink:  #33409c;
  --accent-soft: #eef0fe;
  --accent-wash: #f6f7ff;

  /* Shape */
  --r-sm: 14px;
  --r-md: 20px;
  --r-lg: 28px;
  --r-xl: 36px;

  /* Elevation */
  --sh-1: 0 1px 2px rgba(23, 40, 66, .05), 0 4px 12px -6px rgba(23, 40, 66, .12);
  --sh-2: 0 2px 6px rgba(23, 40, 66, .06), 0 14px 34px -18px rgba(23, 40, 66, .28);
  --sh-3: 0 6px 16px rgba(23, 40, 66, .08), 0 30px 70px -34px rgba(23, 40, 66, .42);

  /* Motion */
  --ease: cubic-bezier(.22, .68, .36, 1);
  --fast: .16s var(--ease);
  --base: .26s var(--ease);

  --font: "Hiragino Sans", "PingFang SC", "Noto Sans SC", "Yu Gothic UI", system-ui, -apple-system, sans-serif;
}

[data-unit="ln"]  { --accent: #4b62d8; --accent-ink: #2f3e9e; --accent-soft: #e9ecfe; --accent-wash: #f5f6ff; }
[data-unit="mmj"] { --accent: #eda33f; --accent-ink: #a5691a; --accent-soft: #fdf0da; --accent-wash: #fffaf1; }
[data-unit="vbs"] { --accent: #e2556c; --accent-ink: #a12c42; --accent-soft: #fde7eb; --accent-wash: #fff6f7; }
[data-unit="wxs"] { --accent: #2fb7a6; --accent-ink: #14786c; --accent-soft: #dff7f2; --accent-wash: #f3fdfa; }
[data-unit="n25"] { --accent: #9579ca; --accent-ink: #614690; --accent-soft: #efe8fa; --accent-wash: #f9f6fe; }
[data-unit="vs"]  { --accent: #3aa8bd; --accent-ink: #1a6f80; --accent-soft: #e0f4f7; --accent-wash: #f4fdff; }

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.7;
  color: var(--ink);
  background:
    radial-gradient(1100px 620px at 8% -12%, #ffffff 0%, rgba(255,255,255,0) 62%),
    radial-gradient(900px 560px at 96% 4%, #e7f2ff 0%, rgba(231,242,255,0) 58%),
    linear-gradient(180deg, var(--canvas) 0%, #f6f9fd 48%, var(--canvas) 100%);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
img { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; line-height: 1.32; letter-spacing: -.01em; }
p { margin: 0; }
a { color: var(--accent-ink); }
button { font: inherit; color: inherit; }
::selection { background: var(--accent-soft); }

/* ---------- app shell ---------- */
.app { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 22px;
  padding: 12px clamp(16px, 3vw, 34px);
  background: rgba(252, 254, 255, .82);
  backdrop-filter: saturate(150%) blur(14px);
  border-bottom: 1px solid rgba(207, 218, 234, .7);
}
.brand { display: flex; align-items: center; gap: 11px; text-decoration: none; color: inherit; flex-shrink: 0; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 13px; font-size: 19px; color: #fff;
  background: linear-gradient(145deg, #5a72e0, #8f6fd8 55%, #48b6c6);
  box-shadow: 0 8px 18px -10px rgba(74, 98, 216, .85);
}
.brand-text { display: flex; flex-direction: column; line-height: 1.12; }
.brand-text b { font-size: 16px; letter-spacing: .02em; }
.brand-text i { font-style: normal; font-size: 11.5px; color: var(--ink-3); letter-spacing: .16em; }

.tabs { display: flex; gap: 2px; margin-left: 6px; }
.tabs button {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 15px; border: 0; border-radius: 12px;
  background: transparent; color: var(--ink-3); font-size: 14.5px; font-weight: 600;
  cursor: pointer; transition: color var(--fast), background var(--fast), transform var(--fast);
}
.tabs button i { font-style: normal; font-size: 15px; opacity: .8; }
.tabs button:hover { color: var(--ink); background: rgba(255,255,255,.9); }
.tabs button:active { transform: scale(.97); }
.tabs button.active { color: var(--accent-ink); background: var(--accent-soft); }
.tabs button.active i { opacity: 1; }

.topbar-side { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.now-chip {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: rgba(255,255,255,.86);
  transition: border-color var(--fast), box-shadow var(--fast);
}
.now-chip:hover { border-color: var(--line-2); box-shadow: var(--sh-1); }
.now-chip b { font-size: 13px; color: var(--accent-ink); }
.now-chip span { font-size: 12.5px; color: var(--ink-3); max-width: 9em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.ghost-btn {
  padding: 8px 15px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font-size: 13.5px; font-weight: 600; transition: all var(--fast);
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-wash); }
.ghost-btn:active { transform: translateY(1px); }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 12px; border: 1px solid transparent; background: transparent;
  color: var(--ink-3); font-size: 16px; cursor: pointer; transition: all var(--fast);
}
.icon-btn:hover { background: #fff; border-color: var(--line); color: var(--ink); }

.page { flex: 1; width: 100%; max-width: 1220px; margin: 0 auto; padding: 26px clamp(16px, 3vw, 34px) 84px; }

/* ---------- generic surfaces ---------- */
.panel {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--sh-1);
}
.card {
  background: var(--paper); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 18px 20px; box-shadow: var(--sh-1);
}
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.muted { color: var(--ink-3); font-size: 13.5px; line-height: 1.65; }
.divider { height: 1px; background: var(--line); border: 0; margin: 18px 0; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.section-head h3 { font-size: 19px; }
.section-head p { color: var(--ink-3); font-size: 13.5px; margin-top: 3px; }
.empty-state { color: var(--ink-3); font-size: 14px; padding: 28px; text-align: center; }

/* ---------- buttons ---------- */
button.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 22px; border: 0; border-radius: 999px; cursor: pointer;
  font-size: 14.5px; font-weight: 700; color: #fff; letter-spacing: .02em;
  background: linear-gradient(135deg, var(--accent), #7a6bd8);
  box-shadow: 0 10px 22px -14px var(--accent), inset 0 1px 0 rgba(255,255,255,.28);
  transition: transform var(--fast), box-shadow var(--base), filter var(--fast);
}
button.primary:hover { filter: brightness(1.05); transform: translateY(-1px); box-shadow: 0 14px 26px -14px var(--accent); }
button.primary:active { transform: translateY(0) scale(.985); }
button.primary:disabled { opacity: .5; cursor: not-allowed; transform: none; filter: grayscale(.2); }

button.glass-button {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 20px; border-radius: 999px; cursor: pointer;
  border: 1px solid rgba(255,255,255,.6); background: rgba(255,255,255,.16);
  color: #fff; font-size: 14.5px; font-weight: 600;
  backdrop-filter: blur(10px) saturate(140%);
  box-shadow: 0 8px 20px -14px rgba(0,0,0,.5);
  transition: background var(--fast), transform var(--fast);
}
button.glass-button:hover { background: rgba(255,255,255,.3); }
button.glass-button:active { transform: scale(.98); }

.soft {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  font-size: 13.8px; font-weight: 600; transition: all var(--fast);
}
.soft:hover { border-color: var(--accent); color: var(--accent-ink); background: var(--accent-wash); }
.soft:active { transform: translateY(1px); }
.soft.active { border-color: transparent; background: var(--accent-soft); color: var(--accent-ink); }
.soft.danger-border:hover { border-color: #e08a8a; background: #fff3f3; color: #b3454a; }
button:disabled { opacity: .55; cursor: progress; }

.text-btn { border: 0; background: none; color: var(--accent-ink); font-size: 13.5px; font-weight: 600; cursor: pointer; padding: 6px 2px; }
.text-btn:hover { text-decoration: underline; }

/* ---------- chips / tags ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  background: rgba(255,255,255,.9); border: 1px solid var(--line);
  font-size: 12.5px; font-weight: 600; color: var(--ink-2);
}
.chip.accent { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.tag {
  display: inline-block; padding: 3px 10px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent-ink);
  font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); display: inline-block; }

/* ---------- avatars ---------- */
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; object-position: center 18%; background: var(--tint); flex-shrink: 0; }
.avatar-row { display: flex; align-items: center; }
.avatar-row img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; object-position: center 15%; border: 2px solid #fff; background: var(--tint); margin-left: -9px; box-shadow: 0 2px 6px -2px rgba(23,40,66,.25); }
.avatar-row img:first-child { margin-left: 0; }
.avatar-row span { margin-left: 6px; font-size: 12.5px; color: var(--ink-3); }

/* ---------- segmented control ---------- */
.segmented { display: inline-flex; padding: 4px; gap: 2px; background: #eef2f9; border-radius: 999px; }
.segmented button {
  padding: 7px 16px; border: 0; border-radius: 999px; background: transparent;
  color: var(--ink-3); font-size: 13.5px; font-weight: 600; cursor: pointer; transition: all var(--fast);
}
.segmented button.active { background: #fff; color: var(--accent-ink); box-shadow: var(--sh-1); }

/* ---------- forms ---------- */
input, select, textarea {
  font: inherit; font-size: 14px; color: var(--ink);
  padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--line-2); background: #fff;
  transition: border-color var(--fast), box-shadow var(--fast);
  max-width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(75, 98, 216, .12);
}
input::placeholder, textarea::placeholder { color: var(--muted); }
select { cursor: pointer; appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--ink-3) 50%), linear-gradient(135deg, var(--ink-3) 50%, transparent 50%); background-position: calc(100% - 17px) 55%, calc(100% - 12px) 55%; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; padding-right: 34px; }
textarea { resize: vertical; line-height: 1.6; }
.field { display: flex; flex-direction: column; gap: 7px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field > input, .field > select { font-weight: 400; }
label.checkbox-row { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; padding: 4px 0; }
label.checkbox-row input { width: 16px; height: 16px; accent-color: var(--accent); padding: 0; }

/* ---------- dialogs ---------- */
dialog.sheet {
  border: 0; padding: 0; color: var(--ink);
  width: min(560px, calc(100vw - 32px));
  max-height: min(88vh, 900px);
  border-radius: var(--r-xl);
  background: var(--paper);
  box-shadow: var(--sh-3);
  overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: sheet-in .28s var(--ease); }
dialog.sheet::backdrop { background: rgba(20, 32, 48, .42); backdrop-filter: blur(6px); }
@keyframes sheet-in { from { opacity: 0; transform: translateY(14px) scale(.985); } }
dialog.sheet.wide-sheet { width: min(1080px, calc(100vw - 32px)); }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 18px 22px 14px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: rgba(255,255,255,.94); backdrop-filter: blur(8px); z-index: 3;
}
.sheet-head h2 { font-size: 17px; }
.sheet-body { padding: 20px 22px 26px; overflow-y: auto; overscroll-behavior: contain; }
.close-btn {
  width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line);
  background: #fff; color: var(--ink-3); font-size: 19px; line-height: 1; cursor: pointer;
  display: grid; place-items: center; transition: all var(--fast); flex-shrink: 0;
}
.close-btn:hover { background: var(--tint); color: var(--ink); border-color: var(--line-2); }

/* ---------- welcome ---------- */
.welcome-sheet[open] { display: flex; flex-direction: row; gap: 0; }
.welcome-sheet { position: relative; }
.welcome-form { flex: 1.1; padding: 30px 30px 28px; display: flex; flex-direction: column; gap: 14px; }
.welcome-form h2 { font-size: 24px; }
.welcome-form .lead { color: var(--ink-3); font-size: 13.5px; line-height: 1.7; }
.welcome-form button.primary { margin-top: 6px; align-self: flex-start; }
.welcome-saves { flex: 1; padding: 30px 26px; background: var(--tint); border-left: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.welcome-saves h3 { font-size: 14px; color: var(--ink-2); }
.welcome-saves button { text-align: left; justify-content: flex-start; width: 100%; }
.save-row { display: flex; align-items: stretch; gap: 8px; }
.save-row .save-open-btn { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 3px; border-radius: 14px; padding: 11px 15px; }
.save-row .save-open-btn b { font-size: 13.8px; }
.save-row .save-open-btn small { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.save-row.current .save-open-btn { border-color: var(--accent); background: var(--accent-wash); color: var(--accent-ink); }
.save-row .save-del {
  flex: 0 0 auto; width: auto; justify-content: center; text-align: center;
  padding: 9px 13px; border-radius: 12px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line); background: #fff; color: var(--ink-3); cursor: pointer;
  transition: all var(--fast);
}
.save-row .save-del:hover { border-color: #e08a8a; background: #fff3f3; color: #b3454a; }
.save-row .save-del:disabled { opacity: .5; cursor: progress; }
.welcome-saves .restore-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; color: var(--ink-3); margin-top: 8px; }
.welcome-saves .restore-row input { max-width: 150px; font-size: 12px; padding: 6px 8px; }
#welcome-close { position: absolute; top: 16px; right: 16px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: 32px; z-index: 200;
  transform: translate(-50%, 18px); opacity: 0; pointer-events: none;
  padding: 11px 20px; border-radius: 999px;
  background: rgba(23, 34, 47, .93); color: #fff;
  font-size: 13.5px; font-weight: 500; max-width: min(86vw, 560px);
  box-shadow: 0 18px 40px -22px rgba(0,0,0,.7);
  transition: opacity .22s var(--ease), transform .22s var(--ease);
}
#toast.visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------- chat ---------- */
.chat-shell { display: flex; flex-direction: column; min-height: 0; height: min(70vh, 680px); }
.chat-log { flex: 1; overflow-y: auto; padding: 4px 2px 14px; display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth; }
.bubble {
  display: flex; flex-direction: column; gap: 6px; max-width: 86%;
  background: var(--tint); border: 1px solid var(--line);
  border-radius: 6px 18px 18px 18px; padding: 11px 15px;
  animation: bubble-in .26s var(--ease);
}
@keyframes bubble-in { from { opacity: 0; transform: translateY(6px); } }
.bubble.mine {
  align-self: flex-end; background: var(--accent-soft); border-color: transparent;
  border-radius: 18px 6px 18px 18px; color: var(--accent-ink);
}
.bubble-head { display: flex; align-items: center; gap: 8px; }
.bubble-head img { width: 26px; height: 26px; border-radius: 50%; object-fit: cover; object-position: center 15%; background: #fff; }
.bubble-head small { font-size: 11.5px; font-weight: 700; color: var(--ink-3); letter-spacing: .02em; }
.bubble.mine .bubble-head small { color: var(--accent-ink); opacity: .78; }
.bubble .zh { font-size: 13px; color: var(--ink-3); }
.bubble > div { font-size: 14.5px; line-height: 1.72; }
.bubble > button { align-self: flex-start; margin-top: 2px; font-size: 12px; }
.chat-form { display: flex; gap: 10px; align-items: flex-end; border-top: 1px solid var(--line); padding-top: 14px; }
.chat-form textarea { flex: 1; min-height: 46px; max-height: 130px; border-radius: 16px; }
.chat-form button.primary { height: 46px; flex-shrink: 0; }
.chat-options { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 10px; }
.chat-options select { padding: 7px 30px 7px 12px; font-size: 12.5px; border-radius: 10px; }
.chat-options label.checkbox-row { font-size: 12.5px; }
.chat-dialog-layout { display: grid; grid-template-columns: minmax(0, 1fr) 232px; gap: 20px; align-items: start; }
.chat-dialog-layout[data-mode="simple"] { grid-template-columns: minmax(0, 1fr); }
.chat-dialog-layout[data-mode="simple"] .chat-visual { display: none; }
.chat-visual { height: 460px; border-radius: var(--r-md); background: linear-gradient(180deg, var(--accent-wash), var(--accent-soft)); overflow: hidden; position: relative; }
.chat-visual > img { width: 100%; height: 100%; object-fit: contain; object-position: center bottom; }
.chat-visual .character-art { height: 100%; }

/* ---------- journal ---------- */
.journal-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; }
.room-art { height: 190px; border-radius: var(--r-md); overflow: hidden; position: relative; background: var(--tint); margin: 14px 0; }
.room-art .illustration { position: absolute; inset: 0; }
.room-art img { width: 100%; height: 100%; object-fit: cover; }
.achievement { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink-2); padding: 7px 0; border-bottom: 1px dashed var(--line); }
.achievement:last-of-type { border-bottom: 0; }
.timeline { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.timeline article time { font-size: 11.5px; font-weight: 700; color: var(--accent-ink); letter-spacing: .04em; }
.timeline article h3 { font-size: 15px; margin: 5px 0 6px; }
.timeline article p { font-size: 13.5px; color: var(--ink-2); }
.timeline article small { display: block; margin-top: 8px; font-size: 11.5px; color: var(--muted); }

/* ---------- music ---------- */
.music-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 18px; align-items: start; }
.rhythm-stage { position: relative; border-radius: var(--r-lg); overflow: hidden; background: linear-gradient(160deg, #1d2a44, #2b3f63 60%, #35406b); box-shadow: var(--sh-2); padding: 14px; }
.rhythm-stage canvas { width: 100%; display: block; border-radius: var(--r-md); touch-action: manipulation; }
.music-score { position: absolute; top: 26px; left: 50%; transform: translateX(-50%); color: #fff; font-size: 15px; font-weight: 700; letter-spacing: .12em; z-index: 2; text-shadow: 0 2px 12px rgba(0,0,0,.4); }
.keys { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.keys button {
  height: 56px; border-radius: 16px; border: 1px solid rgba(255,255,255,.18);
  background: rgba(255,255,255,.1); color: #fff; font-size: 17px; font-weight: 700;
  cursor: pointer; transition: background .1s, transform .1s; backdrop-filter: blur(6px);
}
.keys button:active { background: rgba(255,255,255,.32); transform: scale(.97); }

/* ---------- settings ---------- */
dialog.sheet.settings-sheet { width: min(880px, calc(100vw - 32px)); }
.settings-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 16px; }
.settings-tabs button {
  padding: 8px 15px; border-radius: 999px; border: 1px solid var(--line);
  background: #fff; color: var(--ink-3); font-size: 13px; font-weight: 600; cursor: pointer; transition: all var(--fast);
}
.settings-tabs button.active { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.config-grid { display: grid; gap: 16px; }
.config-grid > section[hidden] { display: none !important; }
.config-grid > section label.checkbox-row { flex-direction: row; align-items: center; }
.close-btn:focus { outline: none; }
.close-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.config-grid > section { display: flex; flex-direction: column; gap: 11px; }
.config-grid > section h3 { font-size: 15px; }
.config-grid > section label { font-size: 12.5px; font-weight: 600; color: var(--ink-2); display: flex; flex-direction: column; gap: 6px; }
.config-grid > section p { font-size: 12.5px; color: var(--ink-3); line-height: 1.65; }
.config-grid > section button { align-self: flex-start; }
.dev-list { display: flex; flex-direction: column; gap: 8px; font-size: 12.5px; color: var(--ink-3); }
.dev-list b { color: var(--ink-2); font-weight: 600; }
.dev-list code { background: var(--tint); border: 1px solid var(--line); padding: 2px 7px; border-radius: 7px; font-size: 12px; }

/* ---------- illustration helper ---------- */
.illustration { position: absolute; inset: 0; overflow: hidden; }
.illustration > img { width: 100%; height: 100%; object-fit: cover; display: block; }
.illustration[data-period="3"] > img { filter: brightness(.8) saturate(.92) hue-rotate(-6deg); }
.illustration[data-period="2"] > img { filter: sepia(.12) saturate(1.04) brightness(.98); }
.illustration.missing-art { background: linear-gradient(150deg, #dfe9f6, #eef3fa); }
.fallback-title { position: absolute; inset: 0; display: grid; place-items: center; font-size: 13px; color: var(--ink-3); }

/* ---------- responsive ---------- */
@media (max-width: 1024px) {
  .chat-dialog-layout { grid-template-columns: 1fr; }
  .chat-visual { height: 220px; }
  .music-layout { grid-template-columns: 1fr; }
  .journal-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  /* backdrop-filter would create a containing block and break the fixed tab bar */
  .topbar { padding: 10px 14px; gap: 10px; backdrop-filter: none; background: rgba(252,254,255,.97); }
  .brand-text i { display: none; }
  .brand-mark { width: 34px; height: 34px; border-radius: 11px; font-size: 17px; }
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
    margin: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: rgba(255,255,255,.96); backdrop-filter: blur(16px);
    border-top: 1px solid var(--line);
    justify-content: space-around; gap: 0;
  }
  .tabs button {
    flex: 1; flex-direction: column; gap: 2px; padding: 7px 2px;
    font-size: 11px; font-weight: 600; border-radius: 12px;
  }
  .tabs button i { font-size: 17px; }
  .tabs button.active { background: transparent; color: var(--accent); }
  .tabs button.active i { transform: translateY(-1px); }
  .topbar-side { gap: 5px; }
  .now-chip { padding: 7px 12px; line-height: 1.25; }
  .now-chip b { font-size: 12.5px; }
  .now-chip span { display: none; }
  .ghost-btn { display: none; }
  .icon-btn { width: 32px; height: 32px; border-radius: 10px; }
  .page { padding: 14px 13px calc(86px + env(safe-area-inset-bottom, 0px)); }
  dialog.sheet { width: calc(100vw - 16px); max-height: 92vh; border-radius: 24px; }
  .wide-sheet { width: calc(100vw - 12px); }
  .sheet-body { padding: 16px 14px 22px; }
  .sheet-head { padding: 14px 16px 12px; }
  .welcome-sheet { flex-direction: column; overflow-y: auto; }
  .welcome-saves { border-left: 0; border-top: 1px solid var(--line); }
  .welcome-form { padding: 24px 20px 18px; }
  .welcome-saves { padding: 20px; }
  .chat-shell { height: min(64vh, 560px); }
  .bubble { max-width: 94%; }
  .card { padding: 15px 16px; }
  .section-head h3 { font-size: 17px; }
  .timeline { grid-template-columns: 1fr; }
}

/* ---------- practice history ---------- */
.practice-spark { margin: 8px 0 14px; color: var(--accent); }
.practice-spark svg { display: block; width: 100%; height: 52px; overflow: visible; }
.practice-spark span { display: block; margin-top: 4px; font-size: 11.5px; color: var(--ink-3); }
