/* Mon Mode de Vie — styles.css (2026-07-29 v4) */

/* ═══ @font-face — 思源宋体（本地打包，无外部字体 CDN） ═══ */
@font-face {
  font-family: "Source Han Serif CN";
  src: url("./assets/fonts/SourceHanSerifCN-Regular.otf") format("opentype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ═══ Design Tokens ═══
   静态色板即默认主题「钴蓝 cobalt」，保证首帧直出最终色，不依赖 JS；
   切换其他主题/明暗由 script.js 的 at() 以内联变量覆盖。 */
:root {
  color-scheme: light;
  --background: 220 100% 98%;
  --foreground: 224 40% 14%;
  --card: 0 0% 100%;
  --card-foreground: 224 40% 14%;
  --secondary: 218 52% 93%;
  --secondary-foreground: 224 40% 14%;
  --muted: 218 40% 94%;
  --muted-foreground: 224 16% 28%;
  --accent: 223 71% 94%;
  --accent-foreground: 223 63% 28%;
  --border: 218 34% 86%;
  --sidebar-background: 218 100% 93%;
  --sidebar-foreground: 224 40% 14%;
  --sidebar-accent: 0 0% 100%;
  --sidebar-accent-foreground: 223 63% 28%;
  --sidebar-border: 218 34% 82%;
  --story-accent: 223 63% 28%;

  --font-serif: "Times New Roman", "Source Han Serif CN", "Songti SC", "STSong", "Noto Serif CJK SC", serif;
  --font-sans: "Times New Roman", "Source Han Serif CN", "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --font-latin: "Times New Roman", Baskerville, serif;
  --font-display: var(--font-serif);
  --font-body: var(--font-serif);
  --font-ui: var(--font-sans);

  --tracking-brand: 0.08em;
  --tracking-label: 0.08em;
  --tracking-heading: -0.02em;

  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-md: 1rem;
  --text-lead: 1.125rem;
  --text-xl: 1.25rem;
  --text-2xl: clamp(1.65rem, 3vw, 2.45rem);

  --leading-tight: 1.25;
  --leading-ui: 1.45;
  --leading-body: 1.75;
  --leading-prose: 2;
  --leading-letter: 1.95;

  --left-width: 252px;
  --right-width: 268px;
  --radius-sm: 10px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --radius-pill: 999px;

  --glass-rgb: 255 255 255;
  --glass-panel-alpha: 0.48;
  --glass-border: rgb(255 255 255 / 0.72);

  --shadow-float: 0 8px 26px hsl(224 40% 22% / 0.1);
  --shadow-panel: 0 18px 50px hsl(224 40% 22% / 0.08);

  --motion-press: 120ms;
  --motion-fast: 160ms;
  --motion-base: 220ms;
  --motion-slow: 280ms;
  --motion-stagger: 40ms;
  --ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);
  --ease-standard: var(--ease-in-out);
  --ease-enter: var(--ease-out);
}

:root[data-mode="dark"] {
  color-scheme: dark;
  /* 钴蓝暗色完整色板（与 script.js 主题表 cobalt.dark 一致），首帧即暗钴蓝 */
  --background: 225 44% 8%;
  --foreground: 220 35% 96%;
  --card: 224 38% 12%;
  --card-foreground: 220 35% 96%;
  --secondary: 225 30% 17%;
  --secondary-foreground: 220 35% 96%;
  --muted: 225 28% 17%;
  --muted-foreground: 220 17% 72%;
  --accent: 223 44% 22%;
  --accent-foreground: 220 35% 96%;
  --border: 225 25% 23%;
  --sidebar-background: 225 40% 10%;
  --sidebar-foreground: 220 35% 96%;
  --sidebar-accent: 225 30% 16%;
  --sidebar-accent-foreground: 220 35% 96%;
  --sidebar-border: 225 25% 23%;
  --glass-rgb: 19 26 43;
  --glass-panel-alpha: 0.64;
  --glass-border: rgb(191 219 254 / 0.14);
  --shadow-float: 0 10px 32px rgb(0 0 0 / 0.3);
  --shadow-panel: 0 24px 60px rgb(0 0 0 / 0.24);
}

/* ═══ Reset ═══ */
*, *::before, *::after { box-sizing: border-box; }
html, body { width: 100%; min-width: 320px; height: 100%; margin: 0; }
body {
  overflow: hidden;
  color: hsl(var(--foreground));
  background: hsl(var(--background));
  font-family: var(--font-body);
  font-size: var(--text-md);
  line-height: var(--leading-body);
  -webkit-font-smoothing: antialiased;
}
button, input { color: inherit; font: inherit; }
button { border: 0; }
button:not(:disabled) { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }
button:focus-visible, [tabindex]:focus-visible { outline: 2px solid hsl(var(--accent-foreground)); outline-offset: 3px; }
svg { width: 1.25rem; height: 1.25rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
a { color: inherit; text-decoration: none; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ═══ App Shell ═══ */
.app-shell {
  width: 100%; height: 100dvh; overflow: hidden;
  background: radial-gradient(circle at 50% -18%, hsl(var(--card) / 0.92), transparent 42%), hsl(var(--background));
}

/* ═══ Top Bar — floating ═══ */
.topbar { position: static; }

/* left toggle — top-left corner */
.topbar-edge--left {
  position: fixed; z-index: 50; top: 14px; left: 14px;
}
/* right toggle — top-right corner */
.topbar-edge--right {
  position: fixed; z-index: 50; top: 14px; right: 14px;
}

.icon-button {
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border-radius: 50%;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--card) / 0.76);
  backdrop-filter: blur(22px) saturate(1.5);
  box-shadow: 0 2px 10px hsl(var(--foreground) / 0.06), 0 0 0 0.5px hsl(var(--border) / 0.5);
  transition: transform var(--motion-slow) var(--ease-spring), opacity var(--motion-base) ease, color var(--motion-fast) ease, background var(--motion-fast) ease;
}
.icon-button:active { transform: scale(0.96); transition-duration: var(--motion-press); }

.topbar-edge--left.is-hidden,
.topbar-edge--right.is-hidden { transform: translateY(-130%); opacity: 0; pointer-events: none; transition: transform var(--motion-slow) var(--ease-spring), opacity var(--motion-base) ease; }

/* center nav — floating pill at top-center */
.primary-nav {
  position: fixed; z-index: 50; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 2px;
  padding: 5px 7px;
  border-radius: var(--radius-pill);
  background: hsl(var(--card) / 0.76);
  backdrop-filter: blur(22px) saturate(1.5);
  box-shadow: 0 2px 16px hsl(var(--foreground) / 0.07), 0 0 0 0.5px hsl(var(--border) / 0.55);
  transition: transform var(--motion-slow) var(--ease-spring), opacity var(--motion-base) ease;
}
.primary-nav.is-hidden { transform: translateX(-50%) translateY(-130%); opacity: 0; pointer-events: none; }
.nav-item {
  display: grid; place-items: center;
  width: 38px; height: 38px; padding: 0;
  border-radius: 50%;
  color: hsl(var(--muted-foreground)); background: transparent;
  position: relative;
  transition: color var(--motion-fast) ease, background var(--motion-fast) ease, transform var(--motion-fast) var(--ease-out);
}
.nav-item svg { width: 19px; height: 19px; }
.nav-item:active { transform: scale(0.96); transition-duration: var(--motion-press); }
.nav-item.is-active { color: hsl(var(--accent-foreground)); }
.nav-item.is-active::after {
  content: ""; position: absolute; bottom: 5px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: hsl(var(--accent-foreground));
}

/* ═══ Workspace ═══ */
.workspace {
  display: grid;
  grid-template-columns: var(--left-width) 4px minmax(0, 1fr) 4px var(--right-width);
  height: 100dvh;
  overflow: hidden;
  transition: grid-template-columns var(--motion-slow) var(--ease-drawer);
}
.app-shell[data-left-open="false"] { --left-width: 0px !important; }
.app-shell[data-right-open="false"] { --right-width: 0px !important; }

/* ═══ Side Panels — spring transitions ═══ */
.side-panel {
  min-width: 0; overflow: auto;
  color: hsl(var(--sidebar-foreground));
  background: linear-gradient(180deg, hsl(var(--sidebar-accent) / 0.34), transparent 28%), hsl(var(--sidebar-background) / 0.76);
  scrollbar-width: thin;
  opacity: 1;
  transition: opacity var(--motion-base) var(--ease-out), transform var(--motion-base) var(--ease-spring);
}
.side-panel--left { padding: 70px 22px 24px; }
.side-panel--right { padding: 70px 20px 24px; }
.app-shell[data-left-open="false"] .side-panel--left { opacity: 0; transform: translateX(-20px); pointer-events: none; }
.app-shell[data-right-open="false"] .side-panel--right { opacity: 0; transform: translateX(20px); pointer-events: none; }

.resize-handle {
  background: hsl(var(--sidebar-border) / 0.35); cursor: col-resize;
  transition: background var(--motion-fast) ease;
}
.resize-handle.is-dragging { background: hsl(var(--accent-foreground) / 0.35); }
.app-shell[data-left-open="false"] .resize-handle--left,
.app-shell[data-right-open="false"] .resize-handle--right { pointer-events: none; opacity: 0; }

.panel-heading { margin-bottom: 12px; }
.panel-heading h2 { margin: 0; font-family: var(--font-display); font-size: var(--text-sm); font-weight: 500; letter-spacing: var(--tracking-heading); }

/* ═══ Left Panel: Music Box ═══ */
.music-box { margin-top: 24px; }
.music-box__header {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: hsl(var(--accent) / 0.22);
  border: 1px solid hsl(var(--border) / 0.5); border-bottom: 0;
}
.music-box__disc {
  position: relative; width: 44px; height: 44px; flex-shrink: 0;
  border-radius: 50%;
  background: conic-gradient(hsl(var(--foreground)/0.12) 0deg, hsl(var(--accent-foreground)/0.3) 90deg, hsl(var(--foreground)/0.12) 180deg, hsl(var(--accent-foreground)/0.3) 270deg, hsl(var(--foreground)/0.12) 360deg);
  box-shadow: 0 2px 8px hsl(var(--foreground) / 0.1);
  animation: disc-spin 4s linear infinite paused;
}
.music-box__disc-inner {
  position: absolute; inset: 33%; border-radius: 50%;
  background: hsl(var(--card));
  box-shadow: 0 0 0 1px hsl(var(--border) / 0.5);
}
.music-box.is-playing .music-box__disc { animation-play-state: running; }
@keyframes disc-spin { to { transform: rotate(360deg); } }
.music-box__meta {
  display: flex; flex-direction: column; gap: 2px; min-width: 0;
}
.music-box__label {
  font-family: var(--font-sans); font-size: var(--text-xs); font-weight: 700;
  color: hsl(var(--muted-foreground)); text-transform: uppercase; letter-spacing: var(--tracking-label);
}
.music-box__song {
  font-family: var(--font-serif); font-size: var(--text-sm); font-weight: 600;
  color: hsl(var(--foreground)); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-top: 2px;
}
.music-box__player {
  display: flex; align-items: center; gap: 14px;
  padding: 10px 16px 14px;
  background: hsl(var(--card) / 0.7);
  border: 1px solid hsl(var(--border) / 0.55); border-top: 0; border-bottom: 0;
}
.music-box__play {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-width: 80px; height: 38px; padding: 0 16px;
  border-radius: var(--radius-pill);
  background: hsl(var(--accent) / 0.55);
  color: hsl(var(--accent-foreground)); font-family: var(--font-sans); font-size: var(--text-xs); font-weight: 650;
  box-shadow: 0 1px 3px hsl(var(--foreground) / 0.06), inset 0 0 0 0.5px hsl(var(--accent-foreground) / 0.12);
  transition: transform var(--motion-fast) var(--ease-out), background var(--motion-fast) ease, box-shadow var(--motion-fast) ease;
}
.music-box__play:active { transform: scale(0.96); }
.music-box__play.is-playing { background: hsl(var(--accent) / 0.85); }
.music-box__play.is-playing .icon-play { display: none; }
.music-box__play.is-playing .icon-pause { display: block; }
.music-box__play:not(.is-playing) .icon-pause { display: none; }
.music-box__play:not(.is-playing) .icon-play { display: block; }
.music-box__play-label { flex-shrink: 0; }
.music-box__wave {
  display: flex; align-items: flex-end; gap: 3px; height: 28px; flex: 1; min-width: 0;
}
.music-box__wave-bar {
  flex: 1; min-width: 3px; max-width: 6px;
  border-radius: var(--radius-pill);
  background: hsl(var(--accent-foreground) / 0.32);
  animation: wave-bounce 0.9s ease-in-out infinite paused;
  animation-delay: calc(var(--d) * 0.15s);
  height: 20%;
}
.music-box.is-playing .music-box__wave-bar { animation-play-state: running; }
@keyframes wave-bounce {
  0%, 100% { height: 20%; }
  50% { height: 100%; }
}
.music-box__progress {
  height: 4px; border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: hsl(var(--border) / 0.55); overflow: hidden;
}
.music-box__progress-fill {
  height: 100%; width: 0%;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: hsl(var(--accent-foreground) / 0.72);
  transition: width 0.3s linear;
}
.on-this-day { display: grid; gap: 16px; }
.otd-card {
  display: block; border-radius: var(--radius-md); overflow: hidden;
  background: hsl(var(--card) / 0.5); border: 1px solid hsl(var(--border) / 0.5);
  transition: transform var(--motion-fast) var(--ease-out), box-shadow var(--motion-fast) var(--ease-out);
  cursor: pointer;
}
.otd-cover { aspect-ratio: 4/3; overflow: hidden; }
.otd-cover img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--motion-slow) var(--ease-out); }
.otd-body { padding: 14px 16px 16px; }
.otd-date { display: block; font-family: var(--font-serif); font-size: var(--text-xl); font-weight: 600; color: hsl(var(--story-accent)); margin-bottom: 6px; }
.otd-excerpt { margin: 0; font-family: var(--font-serif); font-size: var(--text-xs); line-height: 1.65; color: hsl(var(--muted-foreground)); display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }

/* ═══ Main Stage ═══ */
.main-stage {
  position: relative; min-width: 0; overflow: auto;
  background: radial-gradient(circle at 0 0, hsl(var(--card) / 0.55), transparent 32%), hsl(var(--background));
  padding-top: 64px;
}
.module-view {
  opacity: 0; transform: translate3d(0, 8px, 0); pointer-events: none;
  transition: opacity var(--motion-fast) var(--ease-out), transform var(--motion-base) var(--ease-out);
  position: absolute; inset: 0; overflow: auto; scroll-behavior: smooth;
  scrollbar-width: none;
}
.module-view::-webkit-scrollbar { display: none; }
.module-view.is-active {
  opacity: 1; transform: translate3d(0, 0, 0); pointer-events: auto;
  position: relative;
}
.module-sheet {
  width: min(1180px, calc(100% - 48px)); min-height: calc(100% - 64px);
  margin: 32px auto; padding: 38px 44px;
  border: 1px solid hsl(var(--border) / 0.72); border-radius: var(--radius-lg);
  background: hsl(var(--card) / 0.62);
  box-shadow: 0 22px 70px hsl(var(--foreground) / 0.045);
}

/* ═══ Home Chat ═══ */
.home-chat {
  width: min(840px, calc(100% - 48px));
  margin: clamp(28px, 5.5vh, 56px) auto 0;
  padding: 0 4px;
}
.chat-day { margin: 0 0 14px; color: hsl(var(--muted-foreground)); font-family: var(--font-serif); font-size: var(--text-lead); text-align: center; }
.chat-thread {
  display: flex; flex-direction: column; gap: 18px;
  padding-bottom: 33vh;
}
.chat-opening { display: contents; }

.chat-message {
  display: grid; grid-template-columns: 46px minmax(0, 1fr); align-items: start;
  gap: 12px;
  animation: msg-enter var(--motion-base) var(--ease-enter) both;
}
.chat-avatar { width: 46px; height: 46px; border-radius: 50%; }
.chat-name { display: block; margin-bottom: 5px; font-size: 0.92rem; font-weight: 600; color: hsl(var(--muted-foreground)); }
.chat-bubble {
  padding: 13px 20px; border-radius: 18px;
  background: hsl(var(--card) / 0.72); border: 1px solid hsl(var(--border) / 0.3);
  font-size: clamp(1.16rem, 0.6vw + 1.02rem, 1.28rem); line-height: var(--leading-prose);
  box-shadow: 0 1px 3px hsl(var(--foreground) / 0.03);
  display: inline-block; max-width: 72%;
}
.chat-bubble p { margin: 0; }
.chat-bubble p + p { margin-top: 0.8em; }

.chat-message--guest { grid-template-columns: minmax(0, 1fr) 46px; animation-name: msg-enter-guest; }
.chat-message--guest .chat-avatar { order: 2; }
.chat-message--guest .chat-message__content { order: 1; display: flex; flex-direction: column; align-items: flex-end; }
.chat-message--guest .chat-bubble { border-radius: 18px; background: hsl(var(--accent) / 0.18); }
.chat-message--guest .chat-name { text-align: right; }

.chat-choices {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px;
}
.chat-choice {
  display: inline-flex; align-items: center; gap: 9px;
  min-height: 50px; padding: 11px 20px;
  border: 1px solid hsl(var(--border) / 0.7); border-radius: var(--radius-pill);
  background: hsl(var(--card) / 0.7); font-size: 1.06rem;
  transition: border-color var(--motion-fast) ease, background var(--motion-fast) ease, transform var(--motion-fast) var(--ease-out);
}
.chat-choice:active { transform: scale(0.97); }
.chat-choice--anniversary { border-color: hsl(var(--story-accent) / 0.3); background: hsl(var(--accent) / 0.25); }
.chat-choice__date { display: flex; flex-direction: column; align-items: center; line-height: 1; }
.chat-choice__date b { font-size: var(--text-lead); color: hsl(var(--story-accent)); }
.chat-choice__date small { font-size: 10px; color: hsl(var(--muted-foreground)); }

.chat-typing { display: flex; align-items: center; gap: 10px; padding: 8px 0; color: hsl(var(--muted-foreground)); font-size: var(--text-sm); }
.chat-hint { margin: 0 0 20px; color: hsl(var(--muted-foreground)); font-family: var(--font-serif); font-size: var(--text-lead); text-align: center; opacity: 0.55; user-select: none; animation: hint-breathe 2.4s ease-in-out infinite; }
@keyframes hint-breathe { 0%, 100% { opacity: 0.35; } 50% { opacity: 0.72; } }

@keyframes msg-enter { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes msg-enter-guest { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }

/* ═══ Right Panel: Envelope ═══ */
.envelope-card {
  display: grid; grid-template-columns: 58px minmax(0, 1fr); align-items: center;
  width: 100%; min-height: 92px; padding: 12px 4px; gap: 14px;
  color: hsl(var(--sidebar-foreground)); background: transparent; text-align: left;
  transition: transform var(--motion-fast) var(--ease-out);
}
.envelope-illustration {
  position: relative; display: grid; place-items: center;
  width: 58px; height: 44px; perspective: 180px;
  border: 1px solid hsl(var(--sidebar-foreground) / 0.18); border-radius: 10px;
  color: hsl(var(--accent-foreground)); background: hsl(var(--card) / 0.7);
}
.envelope-illustration svg { width: 34px; height: 34px; stroke-width: 1.2; }
.envelope-flap {
  position: absolute; top: -1px; right: -1px; left: -1px; height: 20px;
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  background: hsl(var(--accent) / 0.66); transform-origin: top;
  transition: transform var(--motion-slow) var(--ease-spring);
}
.envelope-card[aria-expanded="true"] .envelope-flap { transform: rotateX(155deg); }
.envelope-card small { font-family: var(--font-sans); font-size: var(--text-sm); color: hsl(var(--muted-foreground)); text-transform: uppercase; letter-spacing: var(--tracking-label); }
.envelope-card strong { font-family: var(--font-display); font-size: var(--text-sm); font-weight: 500; letter-spacing: var(--tracking-heading); }

.author-letter { margin: 14px 0 0; font-family: var(--font-serif); opacity: 1; transform: translate3d(0, 0, 0); transition: opacity var(--motion-fast) var(--ease-out), transform var(--motion-base) var(--ease-out); }
.author-letter.is-closing { opacity: 0; transform: translate3d(0, -6px, 0); pointer-events: none; }
.letter-paper {
  padding: 18px 16px 14px;
  border: 1px solid hsl(var(--border) / 0.7); border-radius: var(--radius-md);
  color: hsl(var(--card-foreground));
  background: repeating-linear-gradient(180deg, transparent 0 25px, hsl(var(--border) / 0.28) 26px), hsl(var(--card));
  box-shadow: 0 12px 32px hsl(var(--foreground) / 0.08);
}
.letter-paper p { margin: 0; font-family: var(--font-display); font-size: var(--text-md); line-height: var(--leading-letter); }
.letter-paper button { margin-top: 12px; padding: 5px 0; color: hsl(var(--accent-foreground)); background: transparent; font-family: var(--font-sans); font-size: var(--text-sm); }


/* ═══ Right Panel: Game ═══ */
.game-card { margin-top: 24px; }
.game-card header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.game-card header svg { width: 24px; height: 24px; color: hsl(var(--accent-foreground)); }
.game-card h3 { margin: 0; font-family: var(--font-display); font-size: var(--text-md); font-weight: 500; }
.game-frame { width: 100%; height: 420px; border: 0; border-radius: var(--radius-sm); }

/* ═══ Cloud Menu ═══ */
.cloud-menu {
  position: fixed; z-index: 60; top: 66px; left: 50%; transform: translateX(-50%);
  width: min(340px, 92vw); max-height: calc(100dvh - 90px);
  padding: 22px 20px 18px; overflow-y: auto;
  border: 1px solid var(--glass-border); border-radius: var(--radius-lg);
  background: rgb(var(--glass-rgb) / 0.9); box-shadow: 0 24px 64px hsl(var(--foreground) / 0.18);
  backdrop-filter: blur(28px);
  transform-origin: top center;
  opacity: 1; transform: translate3d(-50%, 0, 0) scale(1);
  transition: opacity var(--motion-fast) var(--ease-out), transform var(--motion-base) var(--ease-out);
}
.cloud-menu.is-closing { opacity: 0; transform: translate3d(-50%, -6px, 0) scale(0.98); pointer-events: none; }
.cloud-menu__header { display: flex; justify-content: flex-end; align-items: start; margin-bottom: 8px; }
.cloud-kicker { margin: 0; font-family: var(--font-sans); font-size: var(--text-xs); color: hsl(var(--story-accent)); font-weight: 700; letter-spacing: var(--tracking-label); text-transform: uppercase; }
.cloud-menu h2 { margin: 4px 0 0; font-family: var(--font-display); font-size: var(--text-2xl); font-weight: 500; letter-spacing: var(--tracking-heading); }
.cloud-section { margin-bottom: 20px; }
.cloud-section h3 { margin: 0 0 10px; font-size: var(--text-sm); font-weight: 600; color: hsl(var(--muted-foreground)); }
.cloud-section__heading { display: flex; justify-content: space-between; align-items: center; }
.segmented-control { display: flex; gap: 4px; padding: 3px; border-radius: var(--radius-md); background: hsl(var(--secondary)); }
.motion-segment { position: relative; isolation: isolate; }
.motion-segment::before {
  content: ""; position: absolute; z-index: -1; top: 3px; bottom: 3px; left: 0;
  width: var(--segment-width, 0); border-radius: var(--radius-sm);
  background: hsl(var(--card)); box-shadow: 0 1px 4px hsl(var(--foreground) / 0.08);
  transform: translateX(var(--segment-x, 0));
  transition: transform var(--motion-base) var(--ease-in-out);
}
.segmented-control button {
  display: flex; align-items: center; gap: 5px;
  min-height: 34px; padding: 5px 10px; border-radius: var(--radius-sm);
  font-size: var(--text-xs); background: transparent;
}
.segmented-control button { position: relative; z-index: 1; transition: color var(--motion-fast) ease, transform var(--motion-press) var(--ease-out); }
.segmented-control button:active { transform: scale(0.97); }
.segmented-control button.is-selected { color: hsl(var(--accent-foreground)); background: transparent; box-shadow: none; }

.theme-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.theme-choice {
  display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: center;
  min-height: 42px; padding: 5px 7px; gap: 7px;
  border: 1px solid hsl(var(--border) / 0.6); border-radius: var(--radius-md);
  background: hsl(var(--card) / 0.4); font-size: var(--text-xs); text-align: left;
  transition: border-color var(--motion-fast) ease, transform var(--motion-fast) var(--ease-out);
}
.theme-choice:active { transform: scale(0.97); }
.theme-choice.is-selected { border-color: hsl(var(--accent-foreground) / 0.5); box-shadow: inset 0 0 0 1px hsl(var(--accent-foreground) / 0.16); }
.theme-swatch {
  width: 28px; height: 28px; border-radius: 50%;
  background: conic-gradient(var(--swatch-a, #888) 0deg 120deg, var(--swatch-b, #888) 120deg 240deg, var(--swatch-c, #888) 240deg 360deg);
  border: 1px solid hsl(var(--border) / 0.4);
  flex-shrink: 0;
}
.theme-swatch i { display: none; }

.language-row { display: flex; width: 100%; }
.language-row button {
  flex: 1; min-height: 38px; border: 1px solid hsl(var(--border) / 0.5); border-radius: var(--radius-sm);
  position: relative; z-index: 1; background: transparent; font-size: var(--text-xs);
  transition: color var(--motion-fast) ease, transform var(--motion-press) var(--ease-out);
}
.language-row button:active { transform: scale(0.97); }
.language-row button.is-selected { color: hsl(var(--accent-foreground)); background: transparent; box-shadow: none; }

.cloud-links { display: grid; padding-top: 14px; border-top: 1px solid hsl(var(--border) / 0.7); }
.cloud-links button {
  display: flex; flex-direction: column; align-items: flex-start; justify-content: center;
  min-height: 52px; padding: 9px 11px; border-radius: var(--radius-md);
  background: hsl(var(--secondary) / 0.68); text-align: left; text-decoration: none;
  color: hsl(var(--foreground)); font-size: inherit;
}
.cloud-links button:hover { background: hsl(var(--secondary) / 0.9); }
.cloud-links small { margin-top: 2px; color: hsl(var(--muted-foreground)); font-size: var(--text-xs); opacity: 1; transition: opacity var(--motion-fast) var(--ease-out); }
.cloud-links small.is-changing { opacity: 0; transition-duration: 100ms; }

/* ═══ Journal: hide language switcher ═══ */
.language-switcher { display: none !important; }

/* ═══ Mobile Scrim ═══ */
.mobile-scrim { position: fixed; z-index: 45; inset: 0; opacity: 1; background: rgb(0 0 0 / 0.26); backdrop-filter: blur(2px); transition: opacity var(--motion-fast) var(--ease-out); }
.mobile-scrim[hidden] { display: none !important; }

/* ═══ Responsive ═══ */
@media (max-width: 840px) {
  .workspace { display: block; }
  .main-stage { width: 100%; height: 100%; padding-top: 60px; }
  .side-panel {
    position: fixed; z-index: 48; top: 0; bottom: 0;
    width: min(86vw, 320px);
    padding-top: 80px !important;
    transition: transform var(--motion-slow) var(--ease-spring), opacity var(--motion-base) var(--ease-out);
  }
  .side-panel--left { left: 0; transform: translateX(0); }
  .side-panel--right { right: 0; transform: translateX(0); }
  .app-shell[data-left-open="false"] .side-panel--left { transform: translateX(-105%); opacity: 0; }
  .app-shell[data-right-open="false"] .side-panel--right { transform: translateX(105%); opacity: 0; }
  .resize-handle { display: none; }
  .module-sheet { width: calc(100% - 28px); margin: 14px auto; padding: 24px 20px; }
}

@media (max-width: 520px) {
  .module-sheet { width: calc(100% - 16px); margin: 8px auto; padding: 18px 10px 22px; border-radius: var(--radius-md); }
  .home-chat { width: calc(100% - 28px); }
}

@media (hover: hover) and (pointer: fine) {
  .icon-button:hover { color: hsl(var(--foreground)); background: hsl(var(--secondary) / 0.8); transform: scale(1.06); }
  .nav-item:hover { color: hsl(var(--foreground)); background: hsl(var(--secondary) / 0.5); transform: scale(1.05); }
  .resize-handle:hover { background: hsl(var(--accent-foreground) / 0.35); }
  .music-box__play:hover { transform: scale(1.03); background: hsl(var(--accent) / 0.75); }
  .otd-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-float); }
  .otd-card:hover .otd-cover img { transform: scale(1.03); }
  .chat-choice:hover { border-color: hsl(var(--accent-foreground) / 0.5); background: hsl(var(--accent) / 0.3); transform: translateY(-1px); }
  .envelope-card:hover { transform: translateX(2px); }
  .envelope-card:hover .envelope-flap { transform: rotateX(155deg); }
  .theme-choice:hover { border-color: hsl(var(--accent-foreground) / 0.4); transform: translateY(-1px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important; animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
  .module-view, .side-panel, .primary-nav, .topbar-edge--left, .topbar-edge--right,
  .cloud-menu, .author-letter { transform: none !important; transition: opacity 120ms ease !important; }
  .music-box__disc, .music-box__wave-bar, .chat-hint { animation: none !important; }
  .motion-segment::before { transition: opacity 120ms ease !important; }
}
