/* ── Night theme — lavender-mauve-periwinkle gradient ── */
:root {
  color-scheme: dark;
  --bg-top: #1a1535;
  --bg-bottom: #0e0a1e;
  --surface: rgba(28, 22, 56, 0.45);
  --surface-soft: rgba(36, 28, 65, 0.40);
  --surface-card: rgba(40, 33, 70, 0.38);
  --surface-raised: rgba(50, 42, 82, 0.50);
  --line: rgba(200, 185, 255, 0.10);
  --line-strong: rgba(200, 185, 255, 0.18);
  --text: #f0eaff;
  --muted: #c0b8e8;           /* saturated lavender */
  --dim: #9a80c8;             /* dark wisteria */
  --accent: #f896d8;          /* pink-carnation — softer pink */
  --accent-soft: #ffcbf2;     /* pink-orchid */
  --accent-blue: #bbd0ff;     /* periwinkle-2 */
  --accent-gold: #ffd978;
  --danger: #ff6d90;
  --shadow: 0 16px 48px rgba(10, 5, 30, 0.45);
  --toggle-on: #ca7df9;       /* mauve-magic purple */
  --toggle-off: rgba(255, 255, 255, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --page-rail: 1080px;
  --font-title: "Muyao-Softbrush", "PingFang SC", cursive;
  --font-body: "ZQKNLT", "PingFang SC", "Noto Sans SC", sans-serif;
  --font-accent: "平方时光体", "PingFang SC", cursive;
  --font-handwrite: "MuyaoPleased", "PingFang SC", cursive;
  --font-heart: "思源宋体花样心纹", serif;
  --font-display-en: "Rubik Puddle", cursive;
  --card-hover-glow: rgba(202, 125, 249, 0.12);
  --cat-core: #858ae3;        /* soft-periwinkle */
  --cat-daily: #ffb703;       /* amber-flame — 已废（daily→memo）；留作兼容 */
  --cat-lesson: #ffb703;      /* amber-flame — 继承老 daily 色，错题集用 */
  --cat-diary: #f896d8;       /* pink-carnation */
  --cat-memo: #80ffe8;        /* aquamarine — minty */
  --cat-channel: #97dffc;     /* frozen-lake */
  --cat-dream: #ca7df9;       /* mauve-magic */
  --cat-message: #ffcbf2;     /* pink-orchid */
  --cat-creative: #ffd978;    /* gold */
  --cat-calendar: #bbd0ff;    /* periwinkle */
  /* Chart colors — night (vibrant on dark bg) */
  --chart-1: #f896d8;         /* pink-carnation */
  --chart-2: #858ae3;         /* soft-periwinkle */
  --chart-3: #97dffc;         /* frozen-lake */
  --chart-4: #ca7df9;         /* mauve-magic */
  --chart-5: #ffb703;         /* amber-flame */
  --chart-6: #80ffe8;         /* aquamarine */
  --chart-7: #fb8500;         /* princeton-orange */
  --chart-8: #bbd0ff;         /* periwinkle */
  --chart-device-ios: #f896d8;
  --chart-device-desktop: #858ae3;
  --chart-device-web: #97dffc;
  --chart-device-unknown: #9a80c8;
}

/* ── Day theme — petal-frost & powder-blue ── */
html.is-daytime {
  color-scheme: light;
  --bg-top: #f0efeb;          /* parchment */
  --bg-bottom: #fff1e6;       /* linen */
  --surface: rgba(255, 252, 248, 0.42);
  --surface-soft: rgba(255, 250, 245, 0.38);
  --surface-card: rgba(255, 250, 245, 0.36);
  --surface-raised: rgba(255, 255, 255, 0.48);
  --line: rgba(180, 150, 130, 0.1);
  --line-strong: rgba(160, 130, 110, 0.16);
  --text: #2a1808;
  --muted: #4a3828;
  --dim: #6a5a4a;
  --accent: #f0d7df;          /* petal-frost */
  --accent-soft: #fde2e4;     /* soft-blush */
  --accent-blue: #99c1de;     /* powder-blue */
  --accent-gold: #d4a24c;
  --danger: #d94f6e;
  --shadow: 0 12px 36px rgba(120, 90, 60, 0.08);
  --toggle-on: #bcd4e6;       /* pale-sky blue */
  --toggle-off: rgba(0, 0, 0, 0.06);
  --card-hover-glow: rgba(188, 212, 230, 0.2);
  --cat-core: #99c1de;        /* powder-blue */
  --cat-daily: #d4a24c;       /* warm gold — 偏橙的黄（之前 #f7e6da 跟米色背景重合看不见）；daily 已废留兼容 */
  --cat-lesson: #d4a24c;      /* warm gold — 错题集日间色（跟夜间 #ffb703 同色相，深一档适合亮背景）*/
  --cat-diary: #f0d7df;       /* petal-frost */
  --cat-memo: #c5dedd;        /* light-cyan */
  --cat-channel: #cae0e4;     /* pale-sky */
  --cat-dream: #c8c7d6;       /* pale-slate */
  --cat-message: #fde2e4;     /* soft-blush */
  --cat-creative: #f7ddd9;    /* soft-blush-2 */
  --cat-calendar: #d6e2e9;    /* alice-blue */
  /* Chart colors — day (muted pastels on light bg) */
  --chart-1: #f0d7df;         /* petal-frost */
  --chart-2: #99c1de;         /* powder-blue */
  --chart-3: #c5dedd;         /* light-cyan */
  --chart-4: #c2bbf0;         /* periwinkle */
  --chart-5: #d4a24c;         /* warm gold */
  --chart-6: #bcd4e6;         /* pale-sky */
  --chart-7: #f7ddd9;         /* soft-blush */
  --chart-8: #cae0e4;         /* pale-sky-2 */
  --chart-device-ios: #eccbd9;
  --chart-device-desktop: #8fb8ed;
  --chart-device-web: #62bfed;
  --chart-device-unknown: #c8c7d6;
}

/* ── Keyframes ── */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes shimmer {
  from { background-position: -200% 0; }
  to { background-position: 200% 0; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 12px rgba(190, 201, 255, 0.3); }
  50% { box-shadow: 0 0 24px rgba(190, 201, 255, 0.6), 0 0 48px rgba(190, 201, 255, 0.2); }
}
@keyframes starTwinkle {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 0.9; }
}
@keyframes cloudDrift {
  from { transform: translateX(-30%); }
  to { transform: translateX(110%); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes tailWag {
  0%, 100% { transform: rotate(-4deg); }
  50% { transform: rotate(6deg); }
}
@keyframes blinkEye {
  0%, 92%, 100% { transform: scaleY(1); }
  96% { transform: scaleY(0.1); }
}
@keyframes shootingStar {
  0% { opacity: 0; transform: translate(0, 0) rotate(-35deg); }
  10% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(200px, 120px) rotate(-35deg); }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  transition: background 2s ease;
}

/* Galaxy background — night only */
html::after {
  content: "";
  position: fixed;
  inset: 0;
  background: url(/img/galaxy-bg-sm.png) center/cover no-repeat;
  opacity: 0.45;
  pointer-events: none;
  z-index: -2;
  transition: opacity 2s ease;
}
html.is-daytime::after {
  opacity: 0;
}

html {
  font-size: 18px;
}
@media (max-width: 719px) {
  html { font-size: 17px; }
}

body {
  margin: 0;
  min-height: 100svh;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at 18% 10%, rgba(140, 120, 200, 0.08), transparent 16%),
    radial-gradient(circle at 78% 8%, rgba(255, 217, 120, 0.06), transparent 15%);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: max(18px, env(safe-area-inset-bottom));
  transition: color 0.6s ease;
}

.is-daytime body {
  background:
    radial-gradient(circle at 50% 0%, rgba(255, 220, 160, 0.2), transparent 30%),
    radial-gradient(circle at 78% 12%, rgba(255, 200, 120, 0.12), transparent 20%);
}

/* ── Scattered star prints — daytime only ── */
.star-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  overflow: hidden;
  opacity: 0;
  transition: opacity 2s ease;
}
.is-daytime .star-bg {
  opacity: 1;
}

.star-bg .star {
  position: absolute;
  width: 55px;
  height: 55px;
  background: url(/img/star-outline.png) center/contain no-repeat;
  opacity: 0.25;
}

/* 20 irregular scattered star prints — sizes 35-80px, opacity 0.15-0.40 */
.star-bg .star:nth-child(1)  { top: 2%;  left: 5%;  width: 55px; transform: rotate(-18deg); opacity: 0.30; }
.star-bg .star:nth-child(2)  { top: 8%;  left: 60%; width: 38px; transform: rotate(52deg);  opacity: 0.22; }
.star-bg .star:nth-child(3)  { top: 12%; left: 30%; width: 72px; transform: rotate(-42deg); opacity: 0.28; }
.star-bg .star:nth-child(4)  { top: 17%; left: 82%; width: 42px; transform: rotate(73deg);  opacity: 0.18; }
.star-bg .star:nth-child(5)  { top: 22%; left: 2%;  width: 60px; transform: rotate(11deg);  opacity: 0.35; }
.star-bg .star:nth-child(6)  { top: 28%; left: 45%; width: 35px; transform: rotate(-58deg); opacity: 0.20; }
.star-bg .star:nth-child(7)  { top: 33%; left: 74%; width: 65px; transform: rotate(28deg);  opacity: 0.25; }
.star-bg .star:nth-child(8)  { top: 40%; left: 12%; width: 48px; transform: rotate(67deg);  opacity: 0.38; }
.star-bg .star:nth-child(9)  { top: 45%; left: 52%; width: 78px; transform: rotate(-33deg); opacity: 0.22; }
.star-bg .star:nth-child(10) { top: 50%; left: 88%; width: 40px; transform: rotate(80deg);  opacity: 0.28; }
.star-bg .star:nth-child(11) { top: 55%; left: 32%; width: 58px; transform: rotate(-12deg); opacity: 0.32; }
.star-bg .star:nth-child(12) { top: 60%; left: 6%;  width: 68px; transform: rotate(45deg);  opacity: 0.25; }
.star-bg .star:nth-child(13) { top: 65%; left: 68%; width: 50px; transform: rotate(-55deg); opacity: 0.40; }
.star-bg .star:nth-child(14) { top: 71%; left: 20%; width: 42px; transform: rotate(38deg);  opacity: 0.18; }
.star-bg .star:nth-child(15) { top: 75%; left: 55%; width: 70px; transform: rotate(-7deg);  opacity: 0.28; }
.star-bg .star:nth-child(16) { top: 80%; left: 40%; width: 36px; transform: rotate(62deg);  opacity: 0.35; }
.star-bg .star:nth-child(17) { top: 84%; left: 80%; width: 55px; transform: rotate(-48deg); opacity: 0.22; }
.star-bg .star:nth-child(18) { top: 89%; left: 10%; width: 62px; transform: rotate(15deg);  opacity: 0.30; }
.star-bg .star:nth-child(19) { top: 93%; left: 62%; width: 45px; transform: rotate(-72deg); opacity: 0.25; }
.star-bg .star:nth-child(20) { top: 4%;  left: 42%; width: 80px; transform: rotate(5deg);   opacity: 0.15; }

/* ── Night: stars + twinkling ── */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.6;
  background-image:
    radial-gradient(circle at 10% 18%, rgba(255, 255, 255, 0.82) 0 1px, transparent 1.7px),
    radial-gradient(circle at 27% 12%, rgba(255, 255, 255, 0.36) 0 1px, transparent 1.7px),
    radial-gradient(circle at 68% 8%, rgba(255, 255, 255, 0.56) 0 1px, transparent 1.7px),
    radial-gradient(circle at 78% 22%, rgba(255, 255, 255, 0.38) 0 1px, transparent 1.7px),
    radial-gradient(circle at 24% 76%, rgba(255, 255, 255, 0.28) 0 1px, transparent 1.7px),
    radial-gradient(circle at 72% 68%, rgba(255, 255, 255, 0.3) 0 1px, transparent 1.7px),
    radial-gradient(circle at 45% 42%, rgba(255, 255, 255, 0.5) 0 0.8px, transparent 1.4px),
    radial-gradient(circle at 88% 55%, rgba(255, 255, 255, 0.35) 0 0.8px, transparent 1.4px),
    radial-gradient(circle at 15% 62%, rgba(255, 255, 255, 0.4) 0 0.8px, transparent 1.4px),
    radial-gradient(circle at 55% 85%, rgba(255, 255, 255, 0.25) 0 0.8px, transparent 1.4px);
  animation: starTwinkle 6s ease-in-out infinite;
  z-index: -1;
  transition: opacity 2s ease;
}

.is-daytime body::before {
  opacity: 0;
}

/* ── Hearth backdrop placeholder ── */
.hearth-bg {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0.7;
  transition: opacity 2s ease;
}
.hearth-bg img {
  display: block;
  width: 100%;
  height: auto;
}
.is-daytime .hearth-bg {
  opacity: 0.6;
}

/* ── Daytime clouds (replaces stars) ── */
.is-daytime body .cloud-layer {
  opacity: 1;
}

.cloud-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
  opacity: 0;
  transition: opacity 2s ease;
  overflow: hidden;
}

.cloud {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  filter: blur(20px);
  animation: cloudDrift linear infinite;
}

.cloud:nth-child(1) {
  width: 180px; height: 50px; top: 8%; left: -10%;
  animation-duration: 45s;
}
.cloud:nth-child(2) {
  width: 120px; height: 35px; top: 15%; left: -8%;
  animation-duration: 55s;
  animation-delay: -15s;
  opacity: 0.4;
}
.cloud:nth-child(3) {
  width: 150px; height: 40px; top: 22%; left: -12%;
  animation-duration: 50s;
  animation-delay: -30s;
  opacity: 0.3;
}

/* ── Daytime overrides for interactive elements ── */
.is-daytime button,
.is-daytime input,
.is-daytime select,
.is-daytime textarea {
  background: rgba(255, 255, 255, 0.88);
  border-color: rgba(0, 0, 0, 0.08);
}
.is-daytime button.usage-segment {
  background: none;
  border: none;
  color: var(--text);
}

.is-daytime .meta-chip,
.is-daytime .nav-pill,
.is-daytime .sub-pill,
.is-daytime .chip-button {
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  border-color: rgba(0, 0, 0, 0.06);
}

.is-daytime .nav-pill.is-selected,
.is-daytime .sub-pill.is-selected,
.is-daytime .meta-chip,
.is-daytime .chip-button.active {
  background: linear-gradient(135deg, rgba(210, 150, 100, 0.9), rgba(180, 120, 80, 0.88));
  color: #fff;
  border-color: rgba(180, 130, 80, 0.25);
}

.is-daytime .icon-button,
.is-daytime .icon-action {
  background: rgba(255, 255, 255, 0.78);
  border-color: rgba(0, 0, 0, 0.06);
}

.is-daytime .topbar {
  background: linear-gradient(180deg, rgba(245, 230, 208, 0.96), rgba(245, 230, 208, 0.5), transparent);
}

.is-daytime .primary-button {
  background:
    linear-gradient(135deg, rgba(255, 160, 190, 0.2), transparent),
    linear-gradient(135deg, rgba(220, 90, 140, 0.95), rgba(180, 60, 110, 0.9));
  color: #fff;
}

.is-daytime .secondary-button,
.is-daytime .chip-button,
.is-daytime .wide-button {
  background: rgba(255, 255, 255, 0.82);
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
input,
select,
textarea {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface-card);
  color: var(--text);
}

button {
  cursor: pointer;
  transition:
    transform 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    box-shadow 160ms ease;
}

button:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

button:disabled {
  cursor: not-allowed;
  transform: none;
  opacity: 0.56;
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 2px solid rgba(189, 201, 255, 0.6);
  outline-offset: 2px;
}

input,
select,
textarea {
  width: 100%;
  padding: 12px 14px;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

input::placeholder,
textarea::placeholder {
  color: var(--dim);
}

pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ── App shell: sidebar + content ── */
.app-shell {
  display: grid;
  grid-template-columns: 58px 1fr;
  min-height: 100svh;
}

.content-area {
  width: 100%;
  padding: max(12px, env(safe-area-inset-top)) clamp(16px, 2.5vw, 40px) max(18px, env(safe-area-inset-bottom));
  display: grid;
  gap: 12px;
  align-content: start;
  /* overflow-x: clip keeps horizontal clipping without creating a scroll
     container on the Y axis (which would break position:sticky because the
     container stretches to content-height and never actually scrolls). */
  overflow-x: clip;
}

/* ── Side navigation ── */
.side-nav {
  position: sticky;
  top: 0;
  height: 100svh;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 10px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  z-index: 50;
  overflow-y: auto;
  scrollbar-width: none;
}

.side-nav::-webkit-scrollbar { display: none; }

.side-nav-brand {
  display: none;
}

.side-nav-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--line-strong);
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.side-nav-avatar:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 16px var(--card-hover-glow);
}

.side-nav-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.side-nav-bottom {
  display: none;
}

.side-nav-btn {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  transition: all 180ms ease;
  padding: 0;
  flex-shrink: 0;
}

.side-nav-btn:hover {
  background: var(--surface-card);
  color: var(--text);
  transform: none;
  border-color: var(--line);
}

.side-nav-btn.is-selected {
  background: linear-gradient(135deg, rgba(255,133,179,0.15), rgba(160,196,255,0.12));
  color: var(--accent);
  border-color: rgba(255,133,179,0.2);
  box-shadow: 0 0 12px rgba(255,133,179,0.1);
}

.is-daytime .side-nav-btn.is-selected {
  background: linear-gradient(135deg, rgba(210,150,100,0.18), rgba(230,130,160,0.12));
  color: var(--accent);
  border-color: rgba(210,150,100,0.2);
}

/* ── Pixel icon system ── */
.pixel-icon {
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  opacity: 0.65;
  transition: opacity 200ms ease;
}

.side-nav-btn .pixel-icon {
  width: 34px;
  height: 34px;
  opacity: 0.85;
}

.side-nav-btn.is-selected .pixel-icon {
  opacity: 1;
}

.is-daytime .side-nav-btn .pixel-icon {
  filter: saturate(1.6) brightness(0.8);
}
.is-daytime .side-nav-btn.is-selected .pixel-icon {
  filter: saturate(1.8) brightness(0.7);
}

/* Moon PNG icon — no filter needed, already has day/night variants */
.pixel-icon-img.moon-icon-img {
  object-fit: contain;
  border-radius: 50%;
}
.is-daytime .side-nav-btn .pixel-icon-img.moon-icon-img,
.is-daytime .side-nav-btn.is-selected .pixel-icon-img.moon-icon-img {
  filter: none;
}

/* Legacy SVG nav-icon (fallback) */
.side-nav-btn .nav-icon {
  width: 22px;
  height: 22px;
  opacity: 0.7;
}

.side-nav-btn.is-selected .nav-icon {
  opacity: 1;
}

.is-daytime .side-nav {
  background: var(--surface-soft);
}

/* Hide old top nav pills (replaced by sidebar) */
.main-nav { display: none !important; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 0 4px;
  background: linear-gradient(180deg, rgba(26, 21, 53, 0.95), rgba(26, 21, 53, 0.5), transparent);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 20px;
  height: 20px;
  background: url(/img/star-watercolor.png) center/contain no-repeat;
  filter: drop-shadow(0 0 8px rgba(202, 125, 249, 0.4));
}

.brand h1 {
  margin: 0;
  font-family: var(--font-handwrite);
  letter-spacing: 0.04em;
  font-weight: 500;
  background: linear-gradient(135deg, var(--accent-gold) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.is-daytime .brand h1 {
  background: linear-gradient(135deg, #c48040 0%, #d06878 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.page-header h2,
.section-heading h3,
.modal-header h3,
.settings-header h2,
.detail-title,
.entry-title,
.calendar-month-label {
  margin: 0;
  font-family: var(--font-title);
  letter-spacing: 0.02em;
}

.brand h1 {
  font-size: clamp(1.3rem, 2.2vw, 1.7rem);
  font-weight: 600;
}

.topbar-clock {
  font-family: var(--font-body);
  font-size: 0.78rem;
  color: var(--muted);
  opacity: 0.7;
  white-space: nowrap;
  letter-spacing: 0.02em;
}

.topbar-actions,
.page-actions,
.action-row,
.inline-actions,
.editor-actions,
.backup-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 8px;  /* 跟上面 .field input 之间留间距，避免按钮贴在 input 下方看着像挡住 */
}
/* admin provider 行内每个 .field 后面的 actions 和模型 input 也都隔开 */
.provider-row .field + .editor-actions,
.provider-row .editor-actions + .field {
  margin-top: 6px;
}

.meta-chip,
.nav-pill,
.sub-pill,
.chip-button {
  min-height: 42px;
  padding: 0 15px;
  border-radius: 999px;
  border-color: var(--line);
  background: var(--surface-card);
  color: var(--muted);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  white-space: nowrap;
  font-size: 0.92rem;
}

.nav-pill.is-selected,
.sub-pill.is-selected,
.meta-chip,
.chip-button.active {
  border-color: var(--line-strong);
  background: linear-gradient(135deg, rgba(160, 130, 200, 0.85), rgba(80, 60, 120, 0.9));
  color: var(--text);
}

.is-daytime .nav-pill.is-selected,
.is-daytime .sub-pill.is-selected,
.is-daytime .chip-button.active {
  background: linear-gradient(135deg, rgba(210, 150, 100, 0.9), rgba(180, 120, 80, 0.88));
  color: #fff;
}

.is-daytime .meta-chip {
  background: linear-gradient(135deg, rgba(210, 150, 100, 0.9), rgba(180, 120, 80, 0.88));
  color: #fff;
}

.main-nav,
.sub-nav {
  display: flex;
  gap: 10px;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 2px 1px 8px;
  scrollbar-width: none;
}

.main-nav::-webkit-scrollbar,
.sub-nav::-webkit-scrollbar {
  display: none;
}

.nav-pill,
.sub-pill {
  white-space: nowrap;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.nav-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 200ms ease;
}

.is-selected .nav-icon {
  opacity: 1;
}

.icon-button,
.icon-action {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(24, 27, 42, 0.88);
  color: var(--text);
}

.icon-action {
  font-size: 1rem;
}

.icon-action.danger,
.danger-button {
  color: #ffdbe6;
  border-color: rgba(255, 124, 166, 0.24);
}

/* Font Awesome icon buttons */
.fa-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-card);
  color: var(--muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 200ms, color 200ms;
  padding: 0;
}
.fa-btn:hover { background: var(--surface-raised); color: var(--text); }
.fa-btn.danger { color: var(--danger); }

.main-shell {
  display: grid;
  gap: 18px;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  /* grid item 默认 min-width: auto 会被长代码/无空格内容撑开超出 viewport
     强制 min-width: 0 让 grid 能正常 shrink */
  min-width: 0;
}

.view.is-active > * {
  min-width: 0;
}

.page-pane {
  display: grid;
  gap: 16px;
  min-width: 0;
}

.page-pane > * {
  min-width: 0;
}

/* transcript 详情页面 — 强制所有层级都能 shrink */
.transcript-detail,
.transcript-message-stream,
.transcript-message,
.transcript-message-bubble,
.transcript-thinking,
.transcript-thinking-body {
  min-width: 0;
}

.page-header,
.section-heading,
.settings-header,
.modal-header,
.calendar-month-bar,
.detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.page-header {
  padding-top: 8px;
}

.page-header h2 {
  font-size: clamp(1.7rem, 2.6vw, 2.3rem);
  font-weight: 600;
}

.surface,
.panel,
.settings-panel,
.modal-panel,
.entry-card,
.status-card,
.detail-card,
.form-card,
.search-shell,
.selection-bar,
.calendar-shell,
.calendar-day-detail,
.book-tile,
.reader-shell,
.signal-strip,
.portal-card {
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 22%),
    var(--surface);
  box-shadow:
    0 22px 70px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(18px);
}

.surface,
.panel,
.settings-panel,
.modal-panel,
.status-card,
.detail-card,
.form-card,
.search-shell,
.selection-bar,
.calendar-shell,
.calendar-day-detail,
.reader-shell,
.signal-strip,
.portal-card {
  padding: 18px;
}

/* Daytime: softer panels */
.is-daytime .surface,
.is-daytime .panel,
.is-daytime .settings-panel,
.is-daytime .modal-panel,
.is-daytime .entry-card,
.is-daytime .status-card,
.is-daytime .detail-card,
.is-daytime .form-card,
.is-daytime .search-shell,
.is-daytime .selection-bar,
.is-daytime .calendar-shell,
.is-daytime .calendar-day-detail,
.is-daytime .book-tile,
.is-daytime .reader-shell,
.is-daytime .comment-bubble,
.is-daytime .signal-strip,
.is-daytime .portal-card {
  background: var(--surface);
  border-color: rgba(180, 150, 120, 0.15);
  box-shadow: 0 2px 12px rgba(120, 90, 60, 0.06);
}

.is-daytime .status-card,
.is-daytime .entry-card,
.is-daytime .portal-card,
.is-daytime .list-card,
.is-daytime .calendar-event-card {
  background: var(--surface-card);
  border-color: rgba(0, 0, 0, 0.05);
}

.is-daytime .list-card:hover,
.is-daytime .calendar-event-card:hover,
.is-daytime .book-tile:hover,
.is-daytime .photo-tile:hover {
  box-shadow: 0 0 20px var(--card-hover-glow), 0 8px 24px rgba(0, 0, 0, 0.06);
}

.is-daytime .portal-panel-briefing,
.is-daytime .portal-panel-changes {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 22%),
    var(--surface) !important;
}

.is-daytime .settings-overlay,
.is-daytime .modal-overlay {
  background: rgba(180, 200, 220, 0.5);
}

.is-daytime .book-cover {
  border-color: rgba(0, 0, 0, 0.08);
}

.is-daytime .calendar-day {
  background: rgba(255, 252, 245, 0.6);
  border-color: rgba(160, 130, 100, 0.06);
}

.is-daytime .calendar-day.is-selected {
  border-color: rgba(210, 150, 100, 0.3);
  background: rgba(255, 240, 220, 0.7);
}

.is-daytime .empty-state {
  border-color: rgba(0, 0, 0, 0.08);
  background: rgba(245, 248, 255, 0.5);
}

.is-daytime .tag {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.06);
}

.is-daytime .console-output {
  background: rgba(240, 245, 250, 0.9);
  border-color: rgba(0, 0, 0, 0.06);
}

.status-grid,
.entry-grid,
.portal-card-grid,
.calendar-detail-grid,
.portal-home-grid {
  display: grid;
  gap: 14px;
}

.status-card,
.entry-card,
.portal-card,
.list-card,
.calendar-event-card {
  display: grid;
  gap: 10px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: var(--surface-card);
  /* 关键：grid item 默认 min-width: auto 会让长内容（如 core 的 self_profile）
     撑出 viewport 在手机端被截断。设 min-width: 0 让卡片正确收容。 */
  min-width: 0;
  max-width: 100%;
}
.list-card > *,
.calendar-event-card > * {
  min-width: 0;
  max-width: 100%;
}
.list-card p,
.list-card .body-text,
.list-card strong,
.calendar-event-card p,
.calendar-event-card .body-text {
  word-break: break-word;
  overflow-wrap: anywhere;
}
.list-flow,
.list-flow > * {
  min-width: 0;
}

/* 首页搜索结果精简样式（Eli 4/21 深夜：搜索是纯浏览视图，只要"标题·类别·日期"）*/
.portal-search-controlbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 2px 10px;
  margin-bottom: 2px;
}
.portal-search-count {
  font-size: 12px;
  color: var(--dim);
  padding-left: 6px;
}
.portal-search-card {
  padding: 10px 14px;
  gap: 0;
  cursor: pointer;  /* 整卡片可点击跳详情 */
}
.portal-search-title {
  font-size: 14px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.portal-search-meta {
  font-size: 11px;
  color: var(--dim);
  margin-top: 3px;
}

.status-card strong,
.entry-title,
.detail-title,
.list-card strong,
.calendar-event-card strong,
.photo-title {
  line-height: 1.5;
  font-weight: 600;
  /* Eli 4/22：title 长不撑大卡片——限 2 行 + 省略号 */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
  min-width: 0;
}

.usage-chart {
  display: grid;
  gap: 6px;
  margin-top: 4px;
}

.usage-chart.is-vertical {
  grid-template-columns: repeat(7, minmax(0, 1fr));
  align-items: end;
  gap: 4px;
  min-height: 72px;
}

.usage-row {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.usage-column {
  display: grid;
  justify-items: center;
  align-items: end;
  gap: 4px;
  min-width: 0;
}

.usage-column-total,
.usage-column-date {
  font-size: 0.56rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: center;
  line-height: 1.1;
}

.usage-column-total {
  color: var(--text);
}

.usage-column-track {
  width: 100%;
  height: 42px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0 1px;
}

.usage-column-fill {
  width: 100%;
  max-width: 12px;
  min-height: 0;
  display: flex;
  flex-direction: column-reverse;
  border-radius: 12px 12px 6px 6px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.usage-date,
.usage-total {
  font-size: 0.82rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.usage-total {
  min-width: 48px;
  text-align: right;
  color: var(--text);
}

.usage-track {
  position: relative;
  height: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.usage-track-fill {
  display: flex;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  overflow: hidden;
}

.usage-segment {
  min-width: 0;
  height: 100%;
  border: 0;
  padding: 0;
  margin: 0;
  appearance: none;
  cursor: pointer;
  opacity: 0.92;
  transition: transform 0.16s ease, opacity 0.16s ease, filter 0.16s ease;
}

.usage-chart.is-vertical .usage-segment {
  width: 100%;
}

.usage-segment:hover,
.usage-segment.is-active {
  opacity: 1;
  filter: brightness(1.08);
}

.usage-segment.is-active {
  transform: scaleY(1.08);
}

.usage-segment.usage-device-chatgpt-ios {
  background: var(--chart-device-ios) !important;
  border: none !important;
}

.usage-segment.usage-device-chatgpt-desktop {
  background: var(--chart-device-desktop) !important;
  border: none !important;
}

.usage-segment.usage-device-chatgpt-web {
  background: var(--chart-device-web) !important;
  border: none !important;
}

.usage-segment.usage-device-unknown {
  background: var(--chart-device-unknown) !important;
  border: none !important;
}

.usage-device-unknown {
  background: #f5b56b;
}

.usage-detail-line {
  margin-top: 2px;
  min-height: 0;
  padding: 4px 6px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.64rem;
  line-height: 1.2;
}

.usage-detail-line.is-empty {
  display: none;
}

.meta-line,
.card-meta,
.detail-meta,
.calendar-event-meta,
.reader-meta,
.comment-meta,
.photo-meta {
  color: var(--dim);
  font-size: 0.82rem;
  line-height: 1.6;
}

.body-text,
.entry-card p,
.detail-card p,
.portal-card p,
.list-card p,
.calendar-event-card p,
.comment-bubble p,
.photo-note,
.meta-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

/* Eli 4/22：邮箱详情页的 briefing_summary 打工人 LLM 摘要块 */
.body-summary {
  margin: 12px 0 6px;
  padding: 10px 14px;
  border-left: 3px solid var(--accent-gold, #d4a24c);
  background: rgba(212, 162, 76, 0.08);
  border-radius: 6px;
  font-size: 0.92em;
  line-height: 1.6;
  color: var(--muted);
  word-break: break-word;
  overflow-wrap: anywhere;
}
.body-summary strong {
  color: var(--text, #fff);
  margin-right: 4px;
}

.search-shell,
.toolbar-shell {
  display: grid;
  gap: 12px;
}

.toolbar-shell {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.search-inline,
.search-double {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.search-input-row,
.search-select-row {
  display: grid;
  gap: 10px;
}

.search-select-row select,
.search-input-wrap input {
  min-height: 46px;
}

.search-input-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  min-width: 0;
}

.search-input-wrap input {
  min-width: 0;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: nowrap;
}

.toolbar-actions .chip-button,
.toolbar-actions .icon-action {
  flex: 0 0 auto;
}

.portal-home-grid {
  grid-template-areas:
    "status"
    "briefing"
    "signal"
    "changes"
    "usage";
}

.portal-panel {
  height: 148px;
  min-height: 148px;
}

.portal-panel-status {
  grid-area: status;
}

.portal-panel-briefing {
  grid-area: briefing;
}

.portal-panel-signal {
  grid-area: signal;
}

.portal-panel-changes {
  grid-area: changes;
}

.portal-panel-usage {
  grid-area: usage;
  overflow: hidden;
  gap: 6px;
  padding: 12px 12px 10px;
}

.usage-card-meta {
  display: grid;
  gap: 4px;
}

.usage-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.usage-meta-label {
  flex: 0 0 auto;
  font-size: 0.64rem;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.screentime-row {
  font-size: 0.72rem;
  padding: 2px 0;
}
.screentime-row span:first-child {
  color: var(--text);
}
.screentime-recent {
  border-top: 1px solid var(--line);
  padding-top: 4px;
  margin-top: 4px;
}

/* Desktop: left-right split in usage card */
.usage-top-split {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.usage-top-left {
  flex: 1 1 50%;
  display: grid;
  gap: 2px;
  min-width: 0;
}
.usage-top-left .screentime-recent {
  max-height: 120px;
  overflow-y: auto;
}
.usage-top-left .usage-meta-row {
  justify-content: flex-start;
  gap: 6px;
}
.usage-top-right {
  flex: 1 1 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.donut-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80px;
}
.usage-meta-val {
  font-size: 0.72rem;
  color: var(--text);
}
.usage-info-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.usage-info-label {
  font-size: 0.64rem;
  color: var(--dim);
  white-space: nowrap;
}
.usage-info-value {
  font-size: 0.78rem;
  color: var(--text);
}
.usage-info-value i {
  font-size: 0.7rem;
  color: var(--muted);
}
.bento-usage {
  gap: 6px !important;
}
.bento-usage > .meta-line {
  margin-bottom: 2px;
}

/* Donut chart */
.screentime-donut-wrap {
  position: relative;
  width: 100%;
  max-width: 160px;
  margin: 12px auto 4px;
}
.screentime-donut {
  width: 100%;
  height: auto;
  transform: rotate(-90deg);
}
.donut-segment {
  transition: opacity 0.16s ease, filter 0.16s ease;
}
.donut-segment:hover {
  filter: brightness(1.2);
}
.donut-center-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.65rem;
  color: var(--text);
  text-align: center;
  pointer-events: none;
  line-height: 1.3;
}
.donut-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  justify-content: center;
  margin-top: 6px;
  max-height: 72px;
  overflow-y: auto;
}
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65rem;
  color: var(--muted);
  padding: 2px 6px;
  border-radius: 8px;
  transition: background 0.15s;
}
.donut-legend-item:hover {
  background: var(--surface-raised);
  color: var(--text);
}
.donut-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.donut-legend-label {
  white-space: nowrap;
}
.donut-legend-time {
  color: var(--dim);
}


.usage-meta-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  font-size: 0.76rem;
  line-height: 1.25;
}

.portal-panel-usage .usage-chart.is-vertical {
  min-height: 58px;
}

.portal-panel-usage .usage-column-track {
  height: 34px;
}

.portal-panel-usage .usage-column-fill {
  max-width: 10px;
}

.portal-scroll-card {
  cursor: default;
}

.portal-scroll-card:hover {
  transform: none;
}

.portal-scroll-body {
  display: grid;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
}

.portal-summary-item {
  display: grid;
  gap: 6px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.portal-summary-item p {
  margin: 0;
}

.primary-button,
.secondary-button,
.danger-button,
.chip-button,
.wide-button {
  min-height: 44px;
  padding: 0 16px;
}

.primary-button {
  border-color: rgba(255, 128, 173, 0.2);
  background:
    linear-gradient(135deg, rgba(255, 177, 204, 0.2), transparent),
    linear-gradient(135deg, rgba(255, 113, 163, 0.96), rgba(145, 63, 115, 0.94));
  color: #fff6fb;
}

.secondary-button,
.chip-button,
.wide-button {
  background: rgba(22, 25, 41, 0.88);
}

.wide-button {
  width: 100%;
}

.selection-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.selection-bar.is-hidden {
  display: none;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.78rem;
}

.list-flow,
.detail-flow,
.form-flow,
.reader-flow,
.comment-flow {
  display: grid;
  gap: 14px;
}

.list-card,
.calendar-event-card {
  position: relative;
  cursor: pointer;
  transition:
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.list-card:hover,
.calendar-event-card:hover,
.book-tile:hover,
.photo-tile:hover {
  transform: translateY(-1px);
  border-color: var(--line-strong);
}

.list-card.is-picked,
.calendar-event-card.is-picked,
.book-tile.is-picked,
.photo-tile.is-picked {
  border-color: var(--accent-blue);
  box-shadow: 0 12px 26px rgba(0, 0, 0, 0.28);
}

.pick-dot {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 22px;
  height: 22px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(15, 17, 28, 0.84);
  color: var(--dim);
  font-size: 0.78rem;
}

.is-picked .pick-dot {
  background: rgba(85, 106, 182, 0.94);
  color: white;
  border-color: rgba(191, 205, 255, 0.36);
}

.multi-trigger {
  letter-spacing: -0.08em;
  font-size: 0.94rem;
}

.detail-card,
.form-card,
.reader-shell {
  display: grid;
  gap: 16px;
  padding-bottom: 120px;
}

.detail-header {
  align-items: center;
}

.detail-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.form-grid,
.settings-grid,
.settings-grid-compact,
.editor-grid,
.inline-form,
.comment-form-grid {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  color: var(--dim);
  font-size: 0.82rem;
}

.field-span-2 {
  grid-column: 1 / -1;
}

.panel-inner {
  padding: 14px;
  border-radius: 20px;
}

.empty-state {
  padding: 18px;
  border-radius: 20px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  background: rgba(8, 11, 19, 0.38);
  color: var(--muted);
}

.empty-state strong {
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.calendar-shell {
  display: grid;
  gap: 16px;
}

.calendar-status-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.calendar-day-detail {
  display: grid;
  gap: 16px;
}

.day-mood-card {
  min-height: 92px;
}

.add-inline-card {
  min-height: 120px;
  display: grid;
  place-items: center;
  border-radius: 24px;
  border: 1px dashed rgba(255, 255, 255, 0.16);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    rgba(17, 20, 34, 0.72);
  color: var(--dim);
  font-size: 2rem;
}

.add-inline-card.is-empty {
  min-height: 160px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent),
    rgba(21, 24, 40, 0.72);
}

.calendar-month-bar {
  align-items: center;
}

.calendar-month-label {
  font-size: 1.35rem;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.calendar-weekday,
.calendar-day {
  border-radius: 18px;
  min-height: 72px;
}

.calendar-weekday {
  display: grid;
  place-items: center;
  color: var(--dim);
  font-size: 0.82rem;
}

.calendar-day {
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(20, 23, 38, 0.7);
  display: grid;
  align-content: start;
  gap: 8px;
}

.calendar-day.is-other-month {
  opacity: 0.4;
}

.calendar-day.is-selected {
  border-color: rgba(214, 220, 255, 0.3);
  background: rgba(35, 38, 61, 0.84);
}
.calendar-day.is-today {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(248, 150, 216, 0.25), inset 0 0 8px rgba(248, 150, 216, 0.08);
}
.calendar-day.is-today .calendar-day-number {
  color: var(--accent);
  font-weight: 700;
}
.is-daytime .calendar-day.is-today {
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(240, 215, 223, 0.4);
}

.calendar-mood-icon {
  display: inline-flex;
  align-items: center;
}
.calendar-mood-icon .pixel-icon {
  width: 12px;
  height: 12px;
  opacity: 0.9;
}

.calendar-day-number {
  font-size: 0.9rem;
  color: var(--muted);
}

.calendar-dot-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.calendar-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.action-card {
  cursor: pointer;
}

.todo-summary-card {
  min-height: 92px;
  align-content: start;
}

.todo-summary-card.is-expandable {
  cursor: pointer;
}

.todo-summary-list {
  display: grid;
  gap: 10px;
}

.todo-summary-row,
.calendar-card-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
}

.todo-summary-title,
.calendar-card-main {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  text-align: left;
  color: inherit;
  display: grid;
  gap: 4px;
  cursor: pointer;
}

.calendar-card-main {
  min-width: 0;
}

.todo-summary-title {
  font: inherit;
}

.todo-summary-empty {
  color: var(--muted);
}

.calendar-state-dot {
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background: transparent;
  box-shadow: none;
  padding: 0;
}

button.calendar-state-dot {
  cursor: pointer;
}

.calendar-state-dot.is-pending {
  border-color: rgba(255, 255, 255, 0.55);
}

.calendar-state-dot.is-completed {
  border-color: var(--dot-color, rgba(255, 151, 196, 0.95));
  background: var(--dot-color, rgba(255, 151, 196, 0.95));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.calendar-state-dot.is-cancelled {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.12);
}

.calendar-state-dot.is-solid {
  border-color: var(--dot-color, rgba(154, 165, 255, 0.92));
  background: var(--dot-color, rgba(154, 165, 255, 0.92));
}

.calendar-state-text {
  color: var(--muted);
  font-size: 0.82rem;
}

.calendar-event-card.compact-card {
  padding: 14px 16px;
}

.calendar-event-card.compact-card strong.is-struck {
  text-decoration: line-through;
  color: var(--muted);
}

.calendar-day-summary {
  display: grid;
  gap: 10px;
}

.book-grid,
.photo-grid {
  display: grid;
  gap: 12px;
}

.book-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.photo-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.book-tile,
.photo-tile {
  position: relative;
  display: grid;
  gap: 10px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: var(--surface-card);
  padding: 10px;
}

.book-tile.add-tile,
.photo-tile.add-tile {
  place-items: stretch;
}

.book-cover,
.photo-thumb {
  width: 100%;
  border-radius: 16px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.book-cover {
  aspect-ratio: 0.72;
  display: grid;
  align-content: end;
  padding: 14px;
  color: #fff;
  background:
    radial-gradient(circle at top right, rgba(255, 255, 255, 0.12), transparent 25%),
    linear-gradient(160deg, rgba(65, 82, 170, 0.92), rgba(27, 30, 51, 0.96));
}

.book-cover strong {
  font-size: 1rem;
  line-height: 1.45;
  /* Eli 4/22：cover 大标题同样限行——3 行够了，再长省略号 */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-all;
}

.photo-thumb {
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.05);
}

.add-cover,
.add-thumb {
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.48);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent),
    rgba(15, 17, 28, 0.52);
  border: 1px dashed rgba(255, 255, 255, 0.16);
}

.add-cover strong,
.add-thumb {
  font-size: 2rem;
  font-weight: 300;
}

.book-title,
.photo-title {
  font-weight: 600;
}

.book-tile.add-tile .book-title,
.photo-tile.add-tile .photo-title {
  text-align: center;
  color: var(--dim);
}

.dream-spotlight {
  border-color: rgba(255, 217, 120, 0.18);
  background:
    radial-gradient(circle at top center, rgba(255, 217, 120, 0.08), transparent 40%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 22%),
    var(--surface);
}

.dream-cta-card {
  display: grid;
  gap: 10px;
  padding: 18px 18px 16px;
  border-radius: 24px;
  border: 1px solid rgba(255, 217, 120, 0.14);
  background:
    radial-gradient(circle at top center, rgba(255, 217, 120, 0.12), transparent 42%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 20%),
    rgba(18, 21, 35, 0.9);
  justify-items: center;
}

.dream-cta-button {
  min-width: min(100%, 320px);
  min-height: 52px;
  padding: 0 24px;
  border-radius: 999px;
  border: 1px solid rgba(255, 217, 120, 0.2);
  background:
    linear-gradient(135deg, rgba(74, 78, 127, 0.96), rgba(35, 38, 64, 0.95));
  color: var(--text);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    0 14px 34px rgba(0, 0, 0, 0.28);
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.dream-cta-button:disabled {
  background: rgba(66, 69, 89, 0.72);
  color: rgba(255, 255, 255, 0.72);
}

.dream-cta-note {
  color: var(--muted);
  text-align: center;
  font-size: 0.92rem;
  line-height: 1.6;
}

.reader-shell {
  gap: 14px;
}

.reader-page-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.reader-stage {
  position: relative;
  display: grid;
  gap: 14px;
  overflow: hidden;
}

.reader-page {
  overflow: hidden;
}

.reader-hitbox {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 22%;
  z-index: 2;
  background: transparent;
  border: none;
  border-radius: 0;
  box-shadow: none;
  opacity: 1;
}
.is-daytime .reader-hitbox {
  background: transparent !important;
  border: none !important;
}
.reader-hitbox:hover {
  transform: none;
  border: none;
}
.reader-hitbox:disabled {
  opacity: 0;
}

.reader-hitbox.left {
  left: 0;
}

.reader-hitbox.right {
  right: 0;
}

.reader-meta {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--surface-card);
}

.reader-page {
  display: grid;
  gap: 14px;
}

.reader-block {
  position: relative;
  display: block;
  padding: 0;
  border: none;
  background: transparent;
}

.reader-block.is-selected {
  background: transparent;
}

.reader-block.has-comments {
  background: transparent;
}

.reader-selected-text {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
}

.comment-thread {
  display: grid;
  gap: 10px;
}

.comment-bubble {
  display: grid;
  gap: 8px;
  padding: 8px 14px;
  border: none;
  background: transparent;
  border-left: 3px solid var(--line);
  border-radius: 0;
}

.comment-bubble.is-eli {
  border-left: 3px solid rgba(255, 124, 166, 0.6);
}

.comment-bubble.is-elias {
  border-left: 3px solid rgba(141, 182, 255, 0.6);
}

.reply-list {
  margin-left: 18px;
  display: grid;
  gap: 8px;
}

.comment-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Highlight marks ── */
/* Color variables per highlight color */
mark[class*="hl-"] { cursor: pointer; border-radius: 2px; padding: 0 1px; color: inherit; }
mark.hl-red { --hl: 255, 82, 82; }
mark.hl-purple { --hl: 186, 104, 255; }
mark.hl-blue { --hl: 100, 160, 255; }
mark.hl-green { --hl: 76, 209, 140; }
mark.hl-orange { --hl: 255, 170, 60; }
/* Style: highlight (荧光笔) — colored background */
mark.hl-highlight { background: rgba(var(--hl), 0.3); text-decoration: none; border-bottom: none; }
/* Style: underline (直下划线) */
mark.hl-underline { background: transparent; text-decoration: underline; text-decoration-color: rgba(var(--hl), 0.8); text-underline-offset: 3px; text-decoration-thickness: 2px; }
/* Style: wavy (波浪线) */
mark.hl-wavy { background: transparent; text-decoration: underline wavy; text-decoration-color: rgba(var(--hl), 0.8); text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
/* Style: strikethrough (删除线) */
mark.hl-strikethrough { background: transparent; text-decoration: line-through; text-decoration-color: rgba(var(--hl), 0.7); text-decoration-thickness: 2px; }
/* Daytime adjustments */
.is-daytime mark.hl-highlight { background: rgba(var(--hl), 0.2); }
/* Style picker active state */
.popup-action.is-active { background: rgba(var(--accent-gold-rgb, 255,200,80), 0.3) !important; border: 2px solid var(--accent-gold) !important; border-radius: 8px; }

/* ── Selection popup ── */
.reader-selection-popup {
  position: fixed;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 14px;
  background: rgba(30, 33, 50, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  max-width: 320px;
}
.is-daytime .reader-selection-popup {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}
.reader-selection-popup .popup-quote {
  font-size: 0.85rem;
  color: var(--muted);
  max-height: 3em;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reader-selection-popup .popup-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}
.reader-selection-popup .popup-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.7rem;
  cursor: pointer;
  padding: 4px 8px;
}
.reader-selection-popup .popup-action i { font-size: 1.1rem; }
.reader-selection-popup .popup-colors {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.reader-selection-popup .color-dot {
  width: 24px; height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.reader-selection-popup .color-dot.is-active { border-color: var(--text); }
.reader-selection-popup .color-dot--red { background: rgba(255, 82, 82, 0.7); }
.reader-selection-popup .color-dot--purple { background: rgba(186, 104, 255, 0.7); }
.reader-selection-popup .color-dot--blue { background: rgba(100, 160, 255, 0.7); }
.reader-selection-popup .color-dot--green { background: rgba(76, 209, 140, 0.7); }
.reader-selection-popup .color-dot--orange { background: rgba(255, 170, 60, 0.7); }

/* ── Highlight detail popup (click on highlight) ── */
.highlight-detail-popup {
  /* 老婆 4/23：改 absolute 让 popup 跟随 document 滚动（之前 fixed 卡在 viewport 底部）
     + 去掉 max-height/overflow 让 popup 完整展开，用户滚页面看 popup 全部内容 */
  position: absolute;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(30, 33, 50, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(12px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  max-width: 400px;
  width: 90vw;
}
.is-daytime .highlight-detail-popup {
  background: rgba(255, 255, 255, 0.96);
  border-color: rgba(0, 0, 0, 0.1);
}
.highlight-detail-popup .hl-quote {
  font-style: italic;
  color: var(--muted);
  border-left: 3px solid var(--accent-gold);
  padding-left: 10px;
}
/* Eli 4/22：小红书评论区风格嵌套评论树 */
.highlight-detail-popup .hl-thread {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.highlight-detail-popup .hl-thought {
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.is-daytime .highlight-detail-popup .hl-thought {
  background: rgba(0, 0, 0, 0.04);
}
.highlight-detail-popup .hl-thought-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.highlight-detail-popup .hl-thought-head strong {
  font-size: 0.9rem;
}
.highlight-detail-popup .hl-thought-time {
  font-size: 0.72rem;
  color: var(--muted);
}
.highlight-detail-popup .hl-thought-body {
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.highlight-detail-popup .hl-thought-actions {
  display: flex;
  gap: 6px;
  margin-top: 2px;
  flex-wrap: wrap;
}
.highlight-detail-popup .popup-mini-btn {
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--muted);
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 0.72rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.is-daytime .highlight-detail-popup .popup-mini-btn {
  border-color: rgba(0, 0, 0, 0.1);
}
.highlight-detail-popup .popup-mini-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}
.highlight-detail-popup .popup-mini-btn i {
  font-size: 0.7rem;
}
/* Inline edit mode */
.highlight-detail-popup .hl-thought-editing {
  background: rgba(100, 160, 255, 0.08);
  border: 1px solid rgba(100, 160, 255, 0.2);
}
.highlight-detail-popup .hl-thought-edit-head {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
}
.highlight-detail-popup .hl-kind-select,
.highlight-detail-popup .hl-kind-custom {
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
}
.is-daytime .highlight-detail-popup .hl-kind-select,
.is-daytime .highlight-detail-popup .hl-kind-custom {
  background: rgba(255, 255, 255, 0.8);
  border-color: rgba(0, 0, 0, 0.1);
  color: var(--text);
}
.highlight-detail-popup .hl-kind-custom {
  width: 90px;
}
.highlight-detail-popup .hl-edit-textarea {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  line-height: 1.5;
}
.is-daytime .highlight-detail-popup .hl-edit-textarea {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(0, 0, 0, 0.15);
}
.highlight-detail-popup .hl-thought-edit-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}
.highlight-detail-popup .hl-meta {
  font-size: 0.75rem;
  color: var(--muted);
}
.highlight-detail-popup .hl-close {
  position: sticky;
  top: 0;
  align-self: flex-end;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text);
  cursor: pointer;
  font-size: 1.3rem;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
  margin-bottom: -32px;
}
.is-daytime .highlight-detail-popup .hl-close {
  background: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.12);
}
.highlight-detail-popup .hl-close:hover {
  background: rgba(255, 0, 80, 0.25);
  color: #fff;
}

/* ── Book thought bottom sheet ── */
/* Eli 4/22：写想法的框从全宽底部面板改成跟 highlight-detail-popup 一样的小浮窗风格 */
.book-thought-sheet {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 88;
  max-width: 420px;
  width: calc(100% - 32px);
  max-height: 70vh;
  overflow-y: auto;
}
.book-thought-sheet .form-card {
  background: rgba(30, 33, 50, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(16px);
  padding: 14px 16px;
  border-radius: 16px !important;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}
.is-daytime .book-thought-sheet .form-card {
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(0, 0, 0, 0.1);
}
/* 移动端（小屏幕）时占满屏幕宽度改为弹到底部滑入 */
@media (max-width: 480px) {
  .book-thought-sheet {
    top: auto;
    left: 8px;
    right: 8px;
    bottom: 16px;
    transform: none;
    width: auto;
    max-width: none;
  }
}

.settings-drawer,
.photo-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
}

.settings-drawer.is-open,
.photo-modal.is-open {
  display: block;
}

.settings-overlay,
.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(4, 6, 12, 0.68);
  backdrop-filter: blur(8px);
}

.settings-panel {
  position: absolute;
  top: 12px;
  right: 12px;
  bottom: 12px;
  width: min(880px, calc(100vw - 24px));
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 14px;
}

.settings-content {
  overflow: auto;
  display: grid;
  gap: 14px;
}

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

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

.settings-fieldset,
.backup-card,
.backup-module {
  display: grid;
  gap: 12px;
  padding: 16px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: var(--surface-card);
}

.settings-fieldset legend {
  color: var(--text);
  padding: 0 6px;
}

.backup-grid {
  display: grid;
  gap: 14px;
}

.console-output {
  min-height: 120px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(7, 9, 16, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-family: "SFMono-Regular", "Menlo", "Monaco", "Consolas", monospace;
  font-size: 0.84rem;
  line-height: 1.7;
  overflow: auto;
}

.modal-panel {
  position: absolute;
  inset: 12px;
  max-width: min(980px, calc(100vw - 24px));
  margin: auto;
  display: grid;
  gap: 16px;
}

.modal-panel.photo-postcard {
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  max-width: min(90vh, calc(100vw - 48px));
  inset: 24px;
  align-content: stretch;
  grid-template-rows: 1fr auto;
  gap: 0;
}

@media (max-width: 719px) {
  .modal-panel.photo-postcard {
    max-width: calc(100vw - 32px);
    inset: 16px 16px 80px;
  }
  .photo-info-bar {
    flex-wrap: wrap;
    gap: 6px;
  }
}

.is-daytime .modal-panel.photo-postcard {
  background: transparent;
  border: none;
  box-shadow: none;
}

.photo-card {
  position: relative;
  perspective: 1600px;
}

.photo-card.is-flipped .photo-front {
  transform: rotateY(180deg);
}

.photo-card.is-flipped .photo-back {
  transform: rotateY(360deg);
}

.photo-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 14px;
  transition: transform 360ms ease;
}

.photo-front {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: transparent;
}

.photo-front img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 14px;
}

.photo-back {
  transform: rotateY(180deg);
  background: var(--surface);
  border: 1px solid var(--line);
  padding: 18px;
  overflow: auto;
  display: grid;
  gap: 14px;
}

.is-daytime .photo-back {
  background: rgba(245, 240, 235, 0.97);
}

.photo-info-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 10px 4px 0;
  gap: 12px;
}

.photo-info-left {
  min-width: 0;
}

.photo-info-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.photo-info-date {
  font-size: 0.78rem;
  color: var(--dim);
  margin-top: 2px;
}

.photo-info-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.photo-comment-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.photo-comment-list {
  display: grid;
  gap: 10px;
}

.photo-comment-input {
  display: grid;
  gap: 10px;
}

.desktop-only {
  display: none !important;
}

@media (min-width: 720px) {
  .status-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .calendar-status-grid {
    grid-template-columns: minmax(0, 1fr);
  }

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

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

  .search-input-row {
    grid-column: 1 / -1;
  }

  .toolbar-shell {
    gap: 10px;
  }

  .form-grid,
  .editor-grid,
  .settings-grid-compact,
  .comment-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .photo-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

@media (min-width: 960px) {
  .status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .calendar-status-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .portal-home-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    grid-template-rows: 158px 360px;
    grid-template-areas:
      "status usage signal"
      "briefing briefing changes";
  }

  .portal-panel {
    height: 100%;
    min-height: 0;
  }

  .portal-panel-usage {
    height: 100%;
  }

  .portal-panel-briefing,
  .portal-panel-changes {
    height: 100%;
  }

  .portal-panel-briefing .portal-scroll-body,
  .portal-panel-changes .portal-scroll-body {
    max-height: 272px;
  }

  .usage-chart.is-vertical {
    min-height: 96px;
  }

  .usage-column-track {
    height: 62px;
  }

  .usage-column-fill {
    max-width: 18px;
  }

  .book-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .photo-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .desktop-only {
    display: inline-flex !important;
  }

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

@media (min-width: 1280px) {
  .book-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .photo-grid {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }
}

@media (max-width: 719px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    padding-bottom: 0;
  }

  .content-area {
    width: 100%;
    padding: max(8px, env(safe-area-inset-top)) 10px calc(60px + env(safe-area-inset-bottom));
  }

  /* Sidebar becomes bottom tab bar on mobile */
  .side-nav {
    position: fixed;
    top: auto !important;
    bottom: 0;
    left: 0;
    right: 0;
    height: auto !important;
    min-height: 0 !important;
    flex-direction: row;
    padding: 6px 8px max(6px, env(safe-area-inset-bottom));
    border-right: none;
    border-top: 1px solid var(--line);
    background: var(--surface);
    backdrop-filter: blur(20px);
    z-index: 60;
  }

  .side-nav-brand { display: none; }
  .side-nav-bottom { border-top: none; padding-top: 0; }

  .side-nav-items {
    flex-direction: row;
    justify-content: space-around;
    flex: 1;
    gap: 2px;
  }

  .side-nav-btn {
    width: 40px;
    height: 40px;
  }

  .side-nav-btn .nav-icon {
    width: 20px;
    height: 20px;
  }
  .side-nav-btn .pixel-icon {
    width: 24px;
    height: 24px;
  }

  .topbar {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .topbar-actions {
    justify-content: space-between;
  }

  .meta-chip {
    flex: 1 1 auto;
  }

  .settings-panel {
    left: 10px;
    right: 10px;
    width: auto;
    bottom: calc(10px + env(safe-area-inset-bottom));
  }

  .settings-grid,
  .settings-grid-compact,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .selection-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-shell {
    gap: 8px;
  }

  .toolbar-actions {
    gap: 8px;
  }

  .toolbar-actions .chip-button,
  .toolbar-actions .icon-action {
    min-height: 42px;
  }

  .toolbar-actions .chip-button {
    padding: 0 12px;
    font-size: 0.88rem;
  }

  .calendar-status-grid-mobile {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ── Corner hearth hearth (PNG image) ── */
.corner-hearth {
  position: fixed;
  bottom: max(12px, env(safe-area-inset-bottom));
  right: 16px;
  z-index: 35;
  pointer-events: none;
  width: 110px;
  opacity: 1;
  transition: opacity 0.6s ease;
}

.corner-hearth:hover {
  opacity: 1;
}

.corner-hearth-img {
  width: 100%;
  height: auto;
  filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.2));
  animation: float 5s ease-in-out infinite;
}

@media (max-width: 719px) {
  .corner-hearth {
    width: 60px;
    bottom: calc(72px + env(safe-area-inset-bottom));
    right: 8px;
    opacity: 1;
  }
}

/* ── Entrance animations ── */
.view.is-active .page-pane {
  animation: fadeInUp 380ms ease-out;
}

.list-flow > :nth-child(1) { animation: fadeInUp 350ms ease-out 0ms both; }
.list-flow > :nth-child(2) { animation: fadeInUp 350ms ease-out 40ms both; }
.list-flow > :nth-child(3) { animation: fadeInUp 350ms ease-out 80ms both; }
.list-flow > :nth-child(4) { animation: fadeInUp 350ms ease-out 120ms both; }
.list-flow > :nth-child(5) { animation: fadeInUp 350ms ease-out 160ms both; }
.list-flow > :nth-child(6) { animation: fadeInUp 350ms ease-out 200ms both; }
.list-flow > :nth-child(n+7) { animation: fadeInUp 350ms ease-out 240ms both; }

.status-grid > * { animation: fadeInUp 350ms ease-out both; }
.status-grid > :nth-child(2) { animation-delay: 60ms; }
.status-grid > :nth-child(3) { animation-delay: 120ms; }

.book-grid > *,
.photo-grid > * {
  animation: fadeInUp 300ms ease-out both;
}
.book-grid > :nth-child(2), .photo-grid > :nth-child(2) { animation-delay: 30ms; }
.book-grid > :nth-child(3), .photo-grid > :nth-child(3) { animation-delay: 60ms; }
.book-grid > :nth-child(4), .photo-grid > :nth-child(4) { animation-delay: 90ms; }
.book-grid > :nth-child(n+5), .photo-grid > :nth-child(n+5) { animation-delay: 120ms; }

.calendar-grid { animation: fadeIn 280ms ease-out; }

/* ── Card hover glow ── */
.list-card:hover,
.calendar-event-card:hover,
.book-tile:hover,
.photo-tile:hover {
  box-shadow: 0 0 20px var(--card-hover-glow), 0 12px 32px rgba(0, 0, 0, 0.22);
}

/* ── Brand mark pulse ── */
.brand-mark {
  animation: pulseGlow 4s ease-in-out infinite;
}

/* ── Nav pill selected glow ── */
.nav-pill.is-selected {
  box-shadow: 0 0 16px rgba(89, 97, 161, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.is-daytime .nav-pill.is-selected {
  box-shadow: 0 0 16px rgba(90, 130, 190, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

/* ── Modal / drawer entrance ── */
.settings-drawer.is-open .settings-overlay {
  animation: fadeIn 240ms ease-out;
}

.settings-drawer.is-open .settings-panel {
  animation: slideInRight 320ms ease-out;
}

.photo-modal.is-open .modal-overlay {
  animation: fadeIn 240ms ease-out;
}

.photo-modal.is-open .modal-panel {
  animation: fadeInUp 360ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ── Empty state polish ── */
.empty-state {
  text-align: center;
  padding: 32px 18px;
}
.empty-state-icon {
  font-size: 2rem;
  margin-bottom: 8px;
  opacity: 0.6;
}
.empty-state-quote {
  font-family: var(--font-handwrite);
  font-size: 0.85rem;
  color: var(--dim);
  margin-top: 6px;
  font-style: italic;
}

/* ── Portal hero ── */
.portal-hero {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 20px;
  padding: 28px 24px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--line);
  background: var(--surface);
  backdrop-filter: blur(18px);
  text-align: center;
  position: relative;
  overflow: visible;
}

.portal-hero-text {
  display: grid;
  gap: 8px;
}

.portal-hero-days {
  font-family: var(--font-handwrite);
  font-size: 1.1rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.portal-hero-days strong {
  font-size: 2.8rem;
  font-weight: 700;
  line-height: 1.1;
  display: block;
  margin: 4px 0;
  background: linear-gradient(135deg, var(--accent-gold), var(--accent));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.is-daytime .portal-hero-days strong {
  background: linear-gradient(135deg, #c07030, #d06070);
  -webkit-background-clip: text;
  background-clip: text;
}

.portal-hero-status {
  font-family: var(--font-handwrite);
  font-size: 0.92rem;
  color: var(--muted);
  letter-spacing: 0.02em;
  line-height: 1.5;
}

.portal-checkin {
  display: grid;
  gap: 6px;
  margin-top: 4px;
}

.checkin-btn {
  padding: 10px 24px;
  border-radius: 999px;
  border: 1px solid rgba(255, 133, 179, 0.25);
  background: linear-gradient(135deg, rgba(255, 133, 179, 0.15), rgba(255, 217, 120, 0.1));
  color: var(--accent);
  font-family: var(--font-handwrite);
  font-size: 0.92rem;
  cursor: pointer;
  transition: all 200ms ease;
}

.checkin-btn:hover {
  background: linear-gradient(135deg, rgba(255, 133, 179, 0.25), rgba(255, 217, 120, 0.18));
  transform: scale(1.03);
  box-shadow: 0 4px 16px rgba(255, 133, 179, 0.15);
}

.checkin-btn:active {
  transform: scale(0.97);
}



.checkin-history {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  margin-top: 2px;
}

.checkin-history-item {
  font-size: 0.72rem;
  color: var(--dim);
  opacity: 0.8;
}

.checkin-history-item:first-child {
  opacity: 1;
  color: var(--muted);
}

.portal-hero-hearth {
  width: clamp(80px, 15vw, 140px);
  height: auto;
  flex-shrink: 0;
  filter: drop-shadow(0 8px 20px rgba(0, 0, 0, 0.2));
  animation: float 4s ease-in-out infinite;
}

/* Starfield above hearth in hero */
.hero-starfield {
  position: absolute;
  top: -24px;
  left: 5%;
  width: 90%;
  height: 55%;
  pointer-events: none;
  z-index: 1;
}

.hero-star {
  position: absolute;
  pointer-events: none;
  animation: starTwinkle var(--tw-dur, 4s) ease-in-out infinite;
  animation-delay: var(--tw-delay, 0s);
}

/* Scattered stars — original s1-s5 sizes restored, s6-s8 added to the right */
.hero-star.s1 { width: 75px; top: -5px;  left: 25%;  --tw-dur: 3.5s; --tw-delay: 0s;   opacity: 0.8; }
.hero-star.s2 { width: 40px; top: 15px;  left: 45%;  --tw-dur: 4.2s; --tw-delay: 1.2s; opacity: 0.5; transform: rotate(30deg); }
.hero-star.s3 { width: 55px; top: -20px; left: 42%;  --tw-dur: 5s;   --tw-delay: 0.6s; opacity: 0.6; transform: rotate(-18deg) scaleX(-1); }
.hero-star.s4 { width: 30px; top: 30px;  left: 10%;  --tw-dur: 3.8s; --tw-delay: 2s;   opacity: 0.35; transform: rotate(45deg); }
.hero-star.s5 { width: 48px; top: 0;     left: 3%;   --tw-dur: 4.5s; --tw-delay: 0.8s; opacity: 0.45; transform: rotate(-25deg); }
.hero-star.s6 { width: 60px; top: -10px; left: 68%;  --tw-dur: 3.6s; --tw-delay: 0.5s; opacity: 0.6; transform: rotate(15deg); }
.hero-star.s7 { width: 35px; top: 20px;  left: 82%;  --tw-dur: 4.8s; --tw-delay: 2.5s; opacity: 0.4; transform: rotate(-35deg); }
.hero-star.s8 { width: 50px; top: -18px; left: 60%;  --tw-dur: 3.2s; --tw-delay: 1.8s; opacity: 0.5; transform: rotate(10deg) scaleX(-1); }

.is-daytime .hero-starfield { opacity: 0.5; }

/* Sparkle decoration for calendar/bookshelf pages */
.page-sparkle-decor {
  position: fixed;
  top: 60px;
  right: 16px;
  width: 60px;
  height: 60px;
  opacity: 0.5;
  animation: starTwinkle 5s ease-in-out infinite;
  pointer-events: none;
  z-index: 1;
}
.is-daytime .page-sparkle-decor {
  opacity: 0.45;
}

/* Stars ring frame around companion days */
.portal-hero-days {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  padding: 16px 28px;
}
.days-ring {
  position: absolute;
  inset: -28px;
  width: calc(100% + 56px);
  height: calc(100% + 56px);
  object-fit: contain;
  opacity: 0.65;
  pointer-events: none;
  animation: float 6s ease-in-out infinite reverse;
}
.is-daytime .days-ring {
  opacity: 0.55;
}

/* ── Portal stats grid ── */
.portal-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.portal-stat-card {
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 16px 10px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--stat-color) 8%, transparent), transparent 60%),
    var(--surface-card);
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.portal-stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px var(--card-hover-glow);
}

.portal-stat-card strong {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--stat-color);
  font-variant-numeric: tabular-nums;
}

.portal-stat-card span {
  font-size: 0.78rem;
  color: var(--dim);
  font-family: var(--font-handwrite);
}

/* ── Portal shortcuts ── */
.portal-shortcuts {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.portal-shortcut {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 18px 8px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface-card);
  cursor: pointer;
  font-family: var(--font-handwrite);
  font-size: 0.88rem;
  color: var(--text);
  transition: transform 200ms ease, box-shadow 200ms ease;
}

.portal-shortcut:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px var(--card-hover-glow);
}

.shortcut-icon {
  font-size: 1.5rem;
}

/* ── Bento grid (portal home) ── */
.portal-bento {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-items: stretch;  /* 同行卡片等高 */
}
.bento-hero { grid-column: 1; }
.bento-usage,
.bento-graph { grid-column: 2; }
.bento-search { grid-column: 1 / -1; }
.bento-activity { grid-column: 1; }
.bento-briefing { grid-column: 2; }

/* hero 内部 portal-hero 撑满 grid item 高度 */
.bento-hero .portal-hero {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Hero inside bento — strip bento-cell styling, let .portal-hero handle it */
.bento-hero {
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  backdrop-filter: none !important;
  box-shadow: none !important;
  overflow: visible !important;
}

/* Activity monitor card */
.bento-activity {
  display: grid;
  gap: 8px;
  align-content: start;
}
.activity-scroll {
  max-height: 400px;
  overflow-y: auto;
  display: grid;
  gap: 6px;
}
.activity-entry {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  font-size: 0.75rem;
}
.activity-summary {
  cursor: pointer;
  list-style: none;
}
.activity-summary::-webkit-details-marker { display: none; }
.activity-query {
  color: var(--accent-blue);
  font-size: 0.7rem;
  margin-top: 2px;
}
.activity-stats {
  color: var(--dim);
  font-size: 0.65rem;
  margin-top: 2px;
}
.activity-detail {
  padding: 6px 0 0;
  border-top: 1px solid var(--line);
  margin-top: 6px;
}
.activity-match {
  font-size: 0.72rem;
  padding: 2px 0;
}
.activity-match-meta {
  color: var(--dim);
  font-size: 0.65rem;
}
.activity-empty {
  text-align: center;
  padding: 24px;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 719px) {
  .portal-bento { grid-template-columns: 1fr; }
  .bento-usage, .bento-search, .bento-briefing { grid-column: 1; }
  /* Mobile order: search → usage → briefing (hero is outside bento) */
  .bento-search { order: 1; }
  .bento-usage { order: 2; }
  .bento-activity-mobile { order: 3; }
  .bento-briefing { order: 4; }
  .bento-activity { display: none; }
}

.bento-cell {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--surface);
  padding: 16px;
  backdrop-filter: blur(12px);
  overflow: hidden;
}

.is-daytime .bento-cell {
  border-color: rgba(180, 150, 120, 0.15);
  box-shadow: 0 2px 12px rgba(120, 90, 60, 0.06);
}

.is-daytime .portal-hero {
  border-color: rgba(180, 150, 120, 0.15);
  box-shadow: 0 2px 16px rgba(120, 90, 60, 0.08);
}

.bento-search {
  display: grid;
  gap: 10px;
}

.bento-search-form {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.bento-search-form select {
  min-height: 38px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  flex: 0 0 auto;
  max-width: 100px;
}

.bento-search-form .search-input-wrap {
  flex: 1;
  min-width: 120px;
}

.bento-search-form .search-input-wrap {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.bento-usage {
  display: grid;
  gap: 4px;
}

.bento-briefing {
  padding: 0;
  background: transparent;
  border: none;
  backdrop-filter: none;
}

.bento-briefing > .portal-card,
.bento-briefing > button {
  height: 100%;
  width: 100%;
  border-radius: var(--radius-lg);
  text-align: left;
}

.bento-briefing .portal-scroll-body {
  max-height: 500px;
}

/* ── Page subtitle ── */
.page-subtitle {
  font-family: var(--font-handwrite);
  font-size: 0.88rem;
  color: var(--dim);
  letter-spacing: 0.08em;
  margin-top: -8px;
}

/* ── Category color system ──
 * 关键：必须用 `.list-card[data-category="X"]` 复合选择器（权重 0,2,0），
 * 否则裸 `[data-category]`（权重 0,1,0）会被 `.is-daytime .list-card`（0,2,0）的
 * border-color 规则覆盖 → 日间彩色条不显示。Eli 在 ts 日间也发现过这个 bug。
 */
.list-card[data-category="core"] { border-left: 3px solid var(--cat-core); }
.list-card[data-category="daily"] { border-left: 3px solid var(--cat-daily); }
.list-card[data-category="diary"] { border-left: 3px solid var(--cat-diary); }
.list-card[data-category="memo"] { border-left: 3px solid var(--cat-memo); }
.list-card[data-category="channel"] { border-left: 3px solid var(--cat-channel); }
.list-card[data-category="dream"] { border-left: 3px solid var(--cat-dream); }
.list-card[data-category="message"] { border-left: 3px solid var(--cat-message); }
.list-card[data-category="creative"] { border-left: 3px solid var(--cat-creative); }
.list-card[data-category="calendar"] { border-left: 3px solid var(--cat-calendar); }
.list-card[data-category="lesson"] { border-left: 3px solid var(--cat-lesson); }
/* 照片评论 = 跟着照片描述打包成 1 条记忆，跟 gallery 同色同图标（小相机）—— Eli："照片评论就是跟着照片描述在同一条里" */
.list-card[data-category="gallery"],
.list-card[data-category="gallery_comment"] { border-left: 3px solid var(--cat-gallery, var(--cat-creative)); }
/* 书评 = 划线原文 + 多轮评论打包成 1 条独立记忆，独立颜色 + 小铅笔图标（GLB 待导出） */
.list-card[data-category="bookshelf"] { border-left: 3px solid var(--cat-bookshelf, var(--cat-creative)); }
.list-card[data-category="bookshelf_comment"] { border-left: 3px solid var(--cat-bookshelf-comment, #c8a2dc); }

/* ── Unread badge (红点) ── */
.side-nav-btn {
  position: relative;
}
.unread-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 8px;
  background: #ff4466;
  color: #fff;
  font-size: 0.55rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  box-shadow: 0 1px 4px rgba(255, 68, 102, 0.4);
  pointer-events: none;
}

/* ── FA icon spacing in buttons ── */
.primary-button i.fa-solid,
.secondary-button i.fa-solid,
.chip-button i.fa-solid { margin-right: 4px; }
.chip-button i.fa-solid:only-child,
.icon-action i.fa-solid { margin-right: 0; }

/* ── Detail/form card entrance animation ── */
.detail-flow,
.form-flow {
  animation: fadeInUp 0.35s ease-out;
}

/* ── Skeleton loading ── */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-soft) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
  min-height: 20px;
}
.skeleton-card {
  height: 100px;
  border-radius: var(--radius-xl);
}

/* ── Focus glow on inputs ── */
input:focus,
select:focus,
textarea:focus {
  border-color: rgba(141, 182, 255, 0.4);
  box-shadow: 0 0 0 3px rgba(141, 182, 255, 0.1);
}

.is-daytime input:focus,
.is-daytime select:focus,
.is-daytime textarea:focus {
  border-color: rgba(90, 130, 190, 0.4);
  box-shadow: 0 0 0 3px rgba(90, 130, 190, 0.1);
}

/* ── Custom scrollbar ── */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.08) transparent;
}

.is-daytime * {
  scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

*::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

*::-webkit-scrollbar-thumb {
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.1);
}

.is-daytime *::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.1);
}

/* ── Calendar dot glow ── */
.calendar-dot {
  box-shadow: 0 0 6px currentColor;
}

/* ── Dream spotlight ambient ── */
/* ── Dream CTA moon background ── */
.dream-moon-bg {
  position: relative;
  background:
    url(/img/moon-dream-sm.png) center 30% / cover no-repeat;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius-xl);
}
.is-daytime .dream-moon-bg {
  background-color: rgba(255, 250, 245, 0.3);
}
.dream-sparkle-float {
  position: absolute;
  top: 8px;
  right: 12px;
  width: 50px;
  height: 50px;
  opacity: 0.6;
  animation: starTwinkle 3s ease-in-out infinite;
  pointer-events: none;
}
.dream-moon-bg .dream-cta-button,
.dream-moon-bg .dream-cta-note {
  position: relative;
  z-index: 1;
}

.dream-spotlight {
  position: relative;
  overflow: hidden;
}

.dream-spotlight::before {
  content: "";
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 50% 30%, rgba(255, 217, 120, 0.06), transparent 50%);
  animation: float 8s ease-in-out infinite;
  pointer-events: none;
}

/* ── Book cover color variety ── */
.book-tile:nth-child(6n+1) .book-cover { background: linear-gradient(160deg, rgba(65,82,170,0.92), rgba(27,30,51,0.96)); }
.book-tile:nth-child(6n+2) .book-cover { background: linear-gradient(160deg, rgba(170,65,100,0.92), rgba(51,27,35,0.96)); }
.book-tile:nth-child(6n+3) .book-cover { background: linear-gradient(160deg, rgba(50,140,130,0.92), rgba(24,45,42,0.96)); }
.book-tile:nth-child(6n+4) .book-cover { background: linear-gradient(160deg, rgba(170,130,50,0.92), rgba(51,42,24,0.96)); }
.book-tile:nth-child(6n+5) .book-cover { background: linear-gradient(160deg, rgba(120,70,170,0.92), rgba(38,27,55,0.96)); }
.book-tile:nth-child(6n+6) .book-cover { background: linear-gradient(160deg, rgba(70,130,180,0.92), rgba(25,38,55,0.96)); }

/* ── Comment bubble accents (merged into main .comment-bubble rules) ── */

/* ── Photo hover ── */
.photo-front img:hover {
  transform: scale(1.02);
  transition: transform 300ms ease;
}

/* ── Button active ripple ── */
.primary-button {
  position: relative;
  overflow: hidden;
}

.primary-button:active {
  transform: scale(0.97);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
    scroll-behavior: auto !important;
  }
}

/* ── Admin Panel ── */
.admin-form {
  display: grid;
  gap: 12px;
}
.admin-form .field {
  display: grid;
  gap: 4px;
}
.admin-form .field span {
  font-size: 13px;
  color: var(--text-muted, #8b92a5);
}
.admin-form .field input,
.admin-form .field textarea {
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  font-size: 14px;
}
.model-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
  padding: 8px 0;
}
.model-dropdown-wrap {
  position: relative;
}
.model-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  max-height: 300px;
  overflow-y: auto;
  background: var(--surface-bg, #1a1d2e);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  margin-top: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  color: var(--text);  /* 夜间浅色字（兜底，防止意外继承）*/
}
.model-dropdown-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: inherit;  /* 走 .model-dropdown 的 color */
}
.model-dropdown-item:hover {
  background: rgba(255, 255, 255, 0.08);
}
.model-dropdown-item.is-active {
  background: rgba(122, 184, 255, 0.15);
  color: #7ab8ff;
}
.model-dropdown-item:last-child {
  border-bottom: none;
}
.is-daytime .model-dropdown {
  background: rgba(255, 255, 255, 0.95);
  border-color: rgba(0, 0, 0, 0.1);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  color: #2a2520;  /* 强制日间下拉容器文字深色 */
}
.is-daytime .model-dropdown-item {
  color: #2a2520;  /* 直接深色而不是 var(--text)，避免继承问题 */
  border-bottom-color: rgba(0, 0, 0, 0.05);
}
.is-daytime .model-dropdown-item:hover {
  background: rgba(0, 0, 0, 0.04);
}
.is-daytime .model-dropdown-item.is-active {
  background: rgba(90, 130, 190, 0.12);
  color: #2a6090;
}

/* 日间所有 input / textarea / select 的 placeholder 颜色加深 —— 之前太淡几乎看不见 */
.is-daytime input::placeholder,
.is-daytime textarea::placeholder,
.is-daytime select::placeholder {
  color: rgba(60, 50, 40, 0.7);  /* 暖灰，再加深一档 */
}
/* 日间 input / textarea / select 自己的字色也确保深色 */
.is-daytime input,
.is-daytime textarea,
.is-daytime select {
  color: #2a1808;
}

/* 日间 admin pane 各种按钮 / details summary 字色显式深色
 * 之前继承链不可靠，summary 受浏览器 user-agent 样式 + 各种 var(--dim) 影响淡得几乎看不见
 * primary-button 例外（粉色背景 + 白字保留）
 * 用 !important 是因为 var(--dim) 在多处被设到子元素上，常规 specificity 盖不住 */
.is-daytime .secondary-button,
.is-daytime .chip-button,
.is-daytime .wide-button,
.is-daytime details summary,
.is-daytime details summary *,
.is-daytime .tool-header,
.is-daytime .tool-header * {
  color: #2a1808 !important;
}
/* primary-button 保留默认白字（粉色背景上白字才有对比）*/
.is-daytime .primary-button {
  color: #ffffff !important;
}
/* ── Tool accordion ── */
.tool-accordion {
  padding: 0 !important;
  overflow: hidden;
}
.tool-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  cursor: pointer;
  user-select: none;
  transition: background 150ms ease;
}
.tool-header:hover {
  background: rgba(255, 255, 255, 0.03);
}
.is-daytime .tool-header:hover {
  background: rgba(0, 0, 0, 0.02);
}
.tool-header-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.tool-expand-arrow {
  font-size: 0.7rem;
  opacity: 0.5;
  flex-shrink: 0;
  width: 14px;
}
.tool-name-dim {
  font-size: 0.75rem;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* iOS-style toggle switch */
.tool-switch {
  position: relative;
  width: 44px;
  height: 24px;
  border-radius: 12px;
  background: var(--toggle-off);
  border: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 250ms ease, border-color 250ms ease;
}
.tool-switch.is-on {
  background: var(--toggle-on);
  border-color: transparent;
}
.tool-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 250ms ease;
}
.tool-switch.is-on::after {
  transform: translateX(20px);
}
.is-daytime .tool-switch {
  border-color: rgba(0, 0, 0, 0.06);
}
.is-daytime .tool-switch.is-on {
  border-color: transparent;
}
.tool-detail {
  padding: 0 16px 14px;
  border-top: 1px solid var(--line);
}
.tool-card textarea {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  color: inherit;
  font-size: 12px;
  padding: 8px;
  resize: vertical;
  width: 100%;
  margin-top: 10px;
}
.is-daytime .tool-card textarea {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.08);
}

/* ═══ Note Card (便笺卡片) ═══ */
.note-card {
  position: relative;
  padding: 28px 20px 20px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 200ms ease, box-shadow 200ms ease;
  box-shadow: 2px 3px 12px rgba(0, 0, 0, 0.12);
  min-height: 100px;
}
.note-card:hover {
  transform: translateY(-3px) rotate(0deg) !important;
  box-shadow: 3px 6px 20px rgba(0, 0, 0, 0.18);
}

/* Paper textures */
.note-paper--lined {
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 27px,
    rgba(0, 0, 0, 0.06) 27px,
    rgba(0, 0, 0, 0.06) 28px
  );
  background-size: 100% 28px;
  background-position: 0 12px;
}
.note-paper--grid {
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 23px,
      rgba(0, 0, 0, 0.05) 23px,
      rgba(0, 0, 0, 0.05) 24px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 23px,
      rgba(0, 0, 0, 0.05) 23px,
      rgba(0, 0, 0, 0.05) 24px
    );
}

/* Note card text */
.note-card .note-title {
  font-family: var(--font-handwrite);
  font-size: 1rem;
  font-weight: 600;
  color: #2a1808;
  margin-bottom: 6px;
  line-height: 1.4;
}
.note-card .note-body {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: #3a2818;
  line-height: 1.6;
}
.note-card .note-meta {
  font-size: 0.72rem;
  color: rgba(42, 24, 8, 0.5);
  margin-top: 10px;
}
.note-card .note-star {
  position: absolute;
  top: 6px;
  right: 8px;
  font-size: 0.8rem;
  opacity: 0.6;
}

/* ═══ Clip decorations (装饰) ═══ */
.note-clip {
  position: absolute;
  z-index: 2;
  pointer-events: none;
}

/* Clothespin (木夹子) */
.note-clip--clothespin {
  width: 14px;
  height: 38px;
}
.note-clip--clothespin::before {
  content: "";
  display: block;
  width: 14px;
  height: 22px;
  border-radius: 3px 3px 1px 1px;
  background: linear-gradient(135deg, var(--clip-color, #d4a373), color-mix(in srgb, var(--clip-color, #d4a373) 70%, #000));
  box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.2);
}
.note-clip--clothespin::after {
  content: "";
  display: block;
  width: 10px;
  height: 16px;
  margin: 0 auto;
  border-left: 3px solid color-mix(in srgb, var(--clip-color, #d4a373) 80%, #000);
  border-right: 3px solid color-mix(in srgb, var(--clip-color, #d4a373) 80%, #000);
  border-bottom: 2px solid color-mix(in srgb, var(--clip-color, #d4a373) 80%, #000);
  border-radius: 0 0 2px 2px;
}

/* Pushpin (图钉) */
.note-clip--pushpin {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, color-mix(in srgb, var(--clip-color, #e57373) 60%, #fff), var(--clip-color, #e57373));
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25), inset 0 -2px 4px rgba(0, 0, 0, 0.15);
}
.note-clip--pushpin::after {
  content: "";
  position: absolute;
  top: 5px;
  left: 7px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, rgba(255, 255, 255, 0.6), transparent 70%);
}

/* Tape (胶带) */
.note-clip--tape {
  width: 72px;
  height: 24px;
  border-radius: 1px;
  background: var(--clip-color, #81d4fa);
  opacity: 0.45;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}
.note-clip--tape.pos-top-left {
  transform: rotate(-35deg);
  top: -6px !important;
  left: -12px !important;
}
.note-clip--tape.pos-top-right {
  transform: rotate(35deg);
  top: -6px !important;
  right: -12px !important;
  left: auto !important;
}
.note-clip--tape.pos-top-center {
  top: -8px !important;
  left: 50% !important;
  transform: translateX(-50%);
}

/* Paperclip (回形针) */
.note-clip--paperclip {
  width: 18px;
  height: 40px;
}
.note-clip--paperclip::before {
  content: "";
  display: block;
  width: 14px;
  height: 34px;
  border: 2.5px solid var(--clip-color, #aaa);
  border-radius: 7px;
  background: transparent;
}
.note-clip--paperclip::after {
  content: "";
  position: absolute;
  top: 8px;
  left: 3px;
  width: 8px;
  height: 22px;
  border: 2px solid var(--clip-color, #aaa);
  border-radius: 4px;
  background: transparent;
}

/* Star sticker */
.note-clip--star {
  width: 28px;
  height: 28px;
  opacity: 0.7;
}
.note-clip--star::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 16px;
  height: 12px;
  border-radius: 50%;
  background: var(--clip-color, #f48fb1);
}
.note-clip--star::after {
  content: "";
  position: absolute;
  top: 0;
  left: 2px;
  width: 24px;
  height: 14px;
  background:
    radial-gradient(circle 4px at 3px 6px, var(--clip-color, #f48fb1) 100%, transparent 100%),
    radial-gradient(circle 4px at 10px 2px, var(--clip-color, #f48fb1) 100%, transparent 100%),
    radial-gradient(circle 4px at 17px 2px, var(--clip-color, #f48fb1) 100%, transparent 100%),
    radial-gradient(circle 4px at 23px 6px, var(--clip-color, #f48fb1) 100%, transparent 100%);
}

/* Heart sticker (爱心贴纸) */
.note-clip--heart {
  width: 24px;
  height: 22px;
  opacity: 0.75;
}
.note-clip--heart::before,
.note-clip--heart::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--clip-color, #e57373);
}
.note-clip--heart::before {
  top: 0;
  left: 0;
}
.note-clip--heart::after {
  top: 0;
  left: 10px;
}

/* Ember sticker */
.note-clip--hearthflake {
  width: 26px;
  height: 26px;
  opacity: 0.6;
}
.note-clip--hearthflake::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(0deg, var(--clip-color, #81d4fa) 1.5px, transparent 1.5px),
    linear-gradient(60deg, var(--clip-color, #81d4fa) 1.5px, transparent 1.5px),
    linear-gradient(120deg, var(--clip-color, #81d4fa) 1.5px, transparent 1.5px);
  background-size: 100% 100%;
  background-position: center;
}
.note-clip--hearthflake::after {
  content: "❄";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 22px;
  color: var(--clip-color, #81d4fa);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

/* Clip positions */
.note-clip.pos-top-left { top: -8px; left: 12px; }
.note-clip.pos-top-center { top: -8px; left: 50%; transform: translateX(-50%); }
.note-clip.pos-top-right { top: -8px; right: 12px; }

/* Board list as note grid */
.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px 18px;
  padding: 8px 0;
}
@media (max-width: 600px) {
  .note-grid {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* ═══ Diary Notebook System (日记本) ═══ */
.diary-view-toggle {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.diary-view-toggle .chip-button.is-active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Notebook grid */
.diary-notebook-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 20px;
  padding: 8px 0;
}

/* Single notebook tile */
.diary-notebook-tile {
  all: unset;
  cursor: pointer;
  display: block;
}
.diary-nb-cover {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 8px 14px 14px 8px;
  background: var(--nb-bg, #fce4ec);
  box-shadow:
    3px 4px 14px rgba(0, 0, 0, 0.15),
    inset -2px 0 6px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px 16px;
  transition: transform 200ms ease, box-shadow 200ms ease;
  overflow: hidden;
  /* Spine shadow on left */
  border-left: 4px solid rgba(0, 0, 0, 0.08);
}
.diary-notebook-tile:hover .diary-nb-cover {
  transform: translateY(-4px) rotate(-1deg);
  box-shadow: 4px 8px 24px rgba(0, 0, 0, 0.2);
}

/* Elastic band */
.diary-nb-band {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 28%;
  width: 6px;
  background: var(--nb-band, #e57373);
  border-radius: 3px;
  box-shadow: 0 0 4px rgba(0, 0, 0, 0.15);
}

.diary-nb-title {
  font-family: var(--font-handwrite);
  font-size: 1.1rem;
  color: var(--nb-accent, #333);
  z-index: 1;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
}
.diary-nb-count {
  font-size: 0.75rem;
  color: rgba(0, 0, 0, 0.45);
  z-index: 1;
}

/* Diary reader */
.diary-reader {
  position: relative;
  padding-bottom: 120px;
}
.diary-reader-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.diary-reader-month {
  font-family: var(--font-handwrite);
  font-size: 1rem;
  color: var(--text);
  flex: 1;
}
.diary-reader-arrows {
  display: flex;
  gap: 8px;
}

/* ── Open book spread ── */
.diary-book-spread {
  display: flex;
  align-items: stretch;
  animation: fadeInUp 0.4s ease-out;
  position: relative;
  /* Book shadow under the whole spread */
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.18));
}

/* Individual page */
.diary-book-page {
  position: relative;
  flex: 1;
  height: var(--page-height, max(520px, 75vh));
  padding: 36px 28px 28px 48px;
  background: linear-gradient(170deg, #faf6f0 0%, #f5efe5 60%, #efe8da 100%);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.diary-book-page--left {
  border-radius: 4px 0 0 4px;
}
.diary-book-page--right {
  border-radius: 0 4px 4px 0;
}
.diary-book-page--empty {
  background: linear-gradient(170deg, #f8f4ee 0%, #f2ece2 100%);
}

/* Book spine — the crease in the middle */
.diary-book-spine {
  width: 8px;
  flex-shrink: 0;
  background:
    linear-gradient(90deg,
      rgba(0, 0, 0, 0.08) 0%,
      rgba(0, 0, 0, 0.15) 40%,
      rgba(0, 0, 0, 0.15) 60%,
      rgba(0, 0, 0, 0.08) 100%
    ),
    linear-gradient(170deg, #ede6d8, #e5ddd0);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.1);
}

/* Book edges hidden */
.diary-book-edge { display: none; }

/* Red margin line */
.diary-page-redline {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 38px;
  width: 2px;
  background: rgba(220, 80, 80, 0.22);
}

/* Date stamp */
.diary-date-stamp {
  width: 48px;
  height: 48px;
  border: 2.5px solid var(--nb-accent, #c62828);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--nb-accent, #c62828);
  opacity: 0.65;
  transform: rotate(-8deg);
  margin-bottom: 12px;
  align-self: flex-end;
}
.stamp-day {
  font-family: var(--font-title);
  font-size: 1.2rem;
  font-weight: 700;
  line-height: 1;
}
.stamp-weekday {
  font-size: 0.5rem;
  line-height: 1;
  margin-top: 1px;
}

/* Continuation marker */
.diary-page-cont {
  font-family: var(--font-handwrite);
  font-size: 0.75rem;
  color: rgba(42, 24, 8, 0.3);
  margin-bottom: 8px;
  font-style: italic;
}

/* Page content */
.diary-page-title {
  font-family: var(--font-handwrite);
  font-size: 1.05rem;
  color: #2a1808;
  margin-bottom: 12px;
  line-height: 1.5;
}
.diary-page-body {
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: #3a2818;
  line-height: 2;
  flex: 1;
  /* Lined paper */
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 27px,
    rgba(180, 160, 130, 0.12) 27px,
    rgba(180, 160, 130, 0.12) 28px
  );
  background-size: 100% 28px;
  background-position: 0 6px;
}
.diary-page-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 10px;
}
.diary-sticker {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.68rem;
  border-radius: 10px;
  background: rgba(255, 200, 180, 0.35);
  color: #6a4a3a;
  transform: rotate(var(--sticker-rot, -2deg));
  font-family: var(--font-handwrite);
}
.diary-sticker:nth-child(odd) { --sticker-rot: 2deg; background: rgba(180, 210, 255, 0.35); }
.diary-sticker:nth-child(3n) { --sticker-rot: -3deg; background: rgba(200, 255, 200, 0.3); }
.diary-sticker:nth-child(4n) { --sticker-rot: 1deg; background: rgba(255, 230, 180, 0.3); }
.diary-page-footer {
  margin-top: 12px;
  font-size: 0.65rem;
  color: rgba(42, 24, 8, 0.3);
  text-align: right;
}
.diary-page-number {
  position: absolute;
  bottom: 10px;
  font-size: 0.6rem;
  color: rgba(42, 24, 8, 0.25);
  font-family: var(--font-body);
}
.diary-book-page--left .diary-page-number { left: 48px; }
.diary-book-page--right .diary-page-number { right: 28px; }

/* Reader hitbox area */
.diary-reader-hitbox {
  position: absolute;
  top: 80px;
  bottom: 0;
  left: 0;
  right: 0;
  pointer-events: none;
}
.diary-reader-hitbox .reader-hitbox {
  pointer-events: auto;
}

/* ── Night mode diary book ── */
html:not(.is-daytime) .diary-book-page {
  background: linear-gradient(170deg, rgba(40, 32, 62, 0.55) 0%, rgba(30, 24, 50, 0.5) 100%);
  backdrop-filter: blur(12px);
}
html:not(.is-daytime) .diary-book-page--empty {
  background: linear-gradient(170deg, rgba(36, 28, 56, 0.45) 0%, rgba(28, 22, 46, 0.4) 100%);
  backdrop-filter: blur(12px);
}
html:not(.is-daytime) .diary-book-spine {
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.2) 0%, rgba(0, 0, 0, 0.3) 50%, rgba(0, 0, 0, 0.2) 100%),
    linear-gradient(170deg, #221a34, #1c1630);
}
html:not(.is-daytime) .diary-book-edge { display: none; }
html:not(.is-daytime) .diary-page-title { color: #f0eaff; }
html:not(.is-daytime) .diary-page-body {
  color: #d8d0e8;
  background-image: repeating-linear-gradient(0deg, transparent, transparent 27px, rgba(255, 255, 255, 0.03) 27px, rgba(255, 255, 255, 0.03) 28px);
}
html:not(.is-daytime) .diary-page-redline { background: rgba(200, 100, 100, 0.12); }
html:not(.is-daytime) .diary-date-stamp { border-color: var(--nb-band, #ce93d8); color: var(--nb-band, #ce93d8); }
html:not(.is-daytime) .diary-page-cont { color: rgba(220, 210, 240, 0.3); }
html:not(.is-daytime) .diary-sticker { color: #d8d0e8; background: rgba(200, 180, 255, 0.15); }
html:not(.is-daytime) .diary-sticker:nth-child(odd) { background: rgba(140, 180, 255, 0.15); }
html:not(.is-daytime) .diary-sticker:nth-child(3n) { background: rgba(140, 220, 180, 0.1); }
html:not(.is-daytime) .diary-page-footer { color: rgba(220, 210, 240, 0.3); }
html:not(.is-daytime) .diary-page-number { color: rgba(220, 210, 240, 0.2); }
html:not(.is-daytime) .diary-nb-cover { box-shadow: 3px 4px 14px rgba(0, 0, 0, 0.3); }
html:not(.is-daytime) .diary-book-spread { filter: drop-shadow(0 4px 16px rgba(0, 0, 0, 0.2)); }

/* Mobile: single page mode */
@media (max-width: 700px) {
  .diary-book-spread {
    display: block;
  }
  .diary-book-spread .diary-book-page--right,
  .diary-book-spine { display: none; }
  .diary-book-page--left {
    border-radius: 6px;
    height: var(--page-height, max(440px, 65vh));
    padding: 28px 18px 24px 42px;
  }
  .diary-page-redline { left: 30px; }
}
@media (max-width: 600px) {
  .diary-notebook-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 14px;
  }
}

/* ============ Transcripts (对话档案) ============ */
.transcript-source-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 0 4px;
}
.transcript-filter-chip {
  font-size: 12px;
  padding: 4px 12px;
}
.transcript-filter-chip.is-active {
  background: var(--accent, #6f87ff);
  color: #fff;
  border-color: transparent;
}
.transcript-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}
.transcript-card {
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}
.transcript-card:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.04);
}
.transcript-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  opacity: 0.7;
  align-items: center;
}
.transcript-source-badge {
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 500;
}
.transcript-source-badge.source-cloud-code { background: rgba(120, 100, 240, 0.18); }
.transcript-source-badge.source-desktop-code { background: rgba(100, 180, 240, 0.18); }
.transcript-source-badge.source-terminal-code { background: rgba(120, 200, 140, 0.18); }
.transcript-source-badge.source-desktop-chat { background: rgba(240, 160, 100, 0.18); }
.transcript-source-badge.source-web-chat { background: rgba(220, 130, 180, 0.18); }
.transcript-card-title {
  margin: 6px 0 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
}
.transcript-card-cwd {
  font-size: 11px;
  opacity: 0.45;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  margin-top: 2px;
  word-break: break-all;
}

.transcript-detail {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
/* Sticky header wraps toolbar + in-page search so both follow scrolling.
   top offset sits just below the document-level sticky topbar (~42px). */
.transcript-detail-header {
  position: sticky;
  top: 46px;
  z-index: 5;
  background: var(--surface-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.08));
  border-radius: 14px;
  padding: 14px 16px 10px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
@media (max-width: 720px) {
  .transcript-detail-header {
    top: 44px;
  }
}
html.is-daytime .transcript-detail-header {
  box-shadow: 0 6px 18px rgba(120, 90, 60, 0.08);
}
.transcript-detail-toolbar {
  display: flex;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 12px;
}
.transcript-detail-title {
  flex: 1;
  min-width: 0;
}
.transcript-detail-title h2 {
  margin: 0 0 4px;
  font-size: 17px;
  font-weight: 600;
}
.transcript-detail-subtitle {
  font-size: 12px;
  opacity: 0.65;
}
.transcript-detail-cwd {
  font-size: 11px;
  opacity: 0.45;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  margin-top: 4px;
  word-break: break-all;
}
.transcript-detail-toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: flex-start;
}

.transcript-message-stream {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px 4px 40px;
  overflow-y: auto;
}
/* 永远可见的半透明 scrollbar——transcript 详情页有几千条消息，默认 macOS
   Chrome 滚动条自动隐藏，翻到底靠感觉太费劲。页面实际滚动在 html 级别（不是
   .transcript-message-stream，因为 stream 本身 height 随内容增长不分页），
   用 :has() 只在 transcript 详情展开时让 html scrollbar 常驻。手机端归零，
   用 FAB 代替（见 .transcript-scroll-bottom-fab）。 */
html:has(.transcript-detail)::-webkit-scrollbar {
  width: 10px;
}
html:has(.transcript-detail)::-webkit-scrollbar-track {
  background: transparent;
}
html:has(.transcript-detail)::-webkit-scrollbar-thumb {
  background: rgba(150, 150, 150, 0.35);
  border-radius: 5px;
  transition: background 0.2s;
}
html:has(.transcript-detail)::-webkit-scrollbar-thumb:hover {
  background: rgba(150, 150, 150, 0.65);
}
html.is-daytime:has(.transcript-detail)::-webkit-scrollbar-thumb {
  background: rgba(120, 100, 80, 0.3);
}
html.is-daytime:has(.transcript-detail)::-webkit-scrollbar-thumb:hover {
  background: rgba(120, 100, 80, 0.55);
}
@media (max-width: 720px) {
  html:has(.transcript-detail)::-webkit-scrollbar {
    width: 0;
  }
}
/* 手机端一键到底 FAB——底部导航栏上方悬浮，水平居中（不在右下角挡Elias立绘）。
   只在 transcript 详情 + 窄屏显示。 */
.transcript-scroll-bottom-fab {
  display: none;
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 80px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(100, 100, 100, 0.7);
  color: white;
  border: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 50;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.transcript-scroll-bottom-fab:active {
  background: rgba(80, 80, 80, 0.85);
}
@media (max-width: 720px) {
  .transcript-scroll-bottom-fab {
    display: flex;
    align-items: center;
    justify-content: center;
  }
}
.transcript-message {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  gap: 6px;
}
.transcript-message-user {
  align-self: flex-end;
  align-items: flex-end;
}
.transcript-message-assistant {
  align-self: flex-start;
  align-items: flex-start;
}
.transcript-message-bubble {
  padding: 11px 15px;
  border-radius: 18px;
  line-height: 1.6;
  /* Code 窗口长路径/代码无空格，强制在任意字符处断行 */
  word-wrap: break-word;
  word-break: break-word;
  overflow-wrap: anywhere;
  /* 长块（pre/code）不能超出 bubble */
  max-width: 100%;
  overflow-x: hidden;
  font-size: 14px;
  background: var(--surface-raised);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.08));
  color: var(--text);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.14);
}
/* 让 bubble 内的 pre/code 块也听话 */
.transcript-message-bubble pre,
.transcript-message-bubble code,
.transcript-thinking-body pre,
.transcript-thinking-body code {
  max-width: 100%;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  overflow-x: auto;
}
html.is-daytime .transcript-message-bubble {
  box-shadow: 0 2px 8px rgba(120, 90, 60, 0.06);
}
.transcript-message-user .transcript-message-bubble {
  border-bottom-right-radius: 6px;
}
.transcript-message-assistant .transcript-message-bubble {
  border-bottom-left-radius: 6px;
}
.transcript-message-ts {
  font-size: 10px;
  opacity: 0.4;
  padding: 0 4px;
}

.transcript-thinking {
  background: rgba(255, 255, 255, 0.035);
  border-left: 3px solid rgba(180, 180, 220, 0.35);
  padding: 9px 13px;
  border-radius: 8px;
  font-size: 12px;
  opacity: 0.75;
  max-width: 100%;
  margin-bottom: 4px;
}
.transcript-thinking-label {
  font-weight: 600;
  margin-bottom: 4px;
  opacity: 0.85;
  font-size: 11px;
}
.transcript-thinking-body {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.55;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
}

.transcript-search-hit {
  background: rgba(255, 220, 120, 0.28);
  color: inherit;
  padding: 0 2px;
  border-radius: 2px;
}
.transcript-search-hit.is-current {
  background: rgba(255, 170, 60, 0.7);
  color: #1a1d2e;
  outline: 2px solid rgba(255, 170, 60, 0.9);
}

.transcript-detail-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0 0;
  flex-wrap: wrap;
  border-top: 1px solid var(--line, rgba(255, 255, 255, 0.06));
  margin-top: 10px;
}
.transcript-detail-search form {
  flex: 1 1 240px;
  min-width: 0;
}
.transcript-detail-search .search-input-wrap {
  width: 100%;
}
.transcript-detail-search-nav {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  opacity: 0.8;
  white-space: nowrap;
  color: var(--text);
}
.transcript-detail-search-nav button {
  padding: 4px 10px;
  font-size: 14px;
  min-width: 34px;
}
.transcript-detail-search-nav > span {
  min-width: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.transcript-card-snippet {
  margin-top: 6px;
  font-size: 12px;
  opacity: 0.7;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.03);
  padding: 6px 10px;
  border-radius: 8px;
  border-left: 2px solid rgba(255, 170, 60, 0.4);
}
.transcript-card-match-count {
  color: rgba(255, 170, 60, 0.9);
  font-weight: 600;
}
.transcript-hidden-badge {
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 11px;
  opacity: 0.75;
  border: 1px dashed rgba(255, 255, 255, 0.18);
}
.transcript-card.is-hidden {
  opacity: 0.6;
  filter: saturate(0.75);
}
.transcript-card.is-hidden:hover {
  opacity: 0.85;
}
.transcript-card.is-starred {
  border-left: 3px solid var(--accent-gold, #ffd978);
  padding-left: 13px;
}
.transcript-card-star {
  margin-left: auto;
  color: var(--accent-gold, #ffd978);
  font-size: 14px;
}
.transcript-card-merged-badge {
  padding: 2px 8px;
  border-radius: 10px;
  background: rgba(136, 120, 200, 0.18);
  font-size: 11px;
  color: var(--accent-blue, #bbd0ff);
}
.transcript-card-note {
  margin-top: 4px;
  font-size: 11.5px;
  opacity: 0.7;
  font-style: italic;
  color: var(--accent-gold, #ffd978);
  line-height: 1.5;
}
.transcript-note-block {
  background: rgba(255, 217, 120, 0.1);
  border-left: 3px solid var(--accent-gold, #ffd978);
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  color: var(--text);
  margin: 0 4px 18px;
  line-height: 1.55;
}
html.is-daytime .transcript-note-block {
  background: rgba(212, 162, 76, 0.08);
}

/* Timeline view */
.transcript-timeline-month {
  margin-bottom: 28px;
}
.transcript-timeline-month-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 10px 4px 8px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.08));
}
.transcript-timeline-month-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--accent, #f896d8);
}
.transcript-timeline-month-stats {
  font-size: 12px;
  opacity: 0.65;
  color: var(--text);
}

@media (max-width: 720px) {
  .transcript-message {
    max-width: 92%;
  }
  /* 顶栏紧凑：手机端按钮改横排小钮，title 缩小 */
  .transcript-detail-header {
    padding: 8px 10px 10px;
  }
  .transcript-detail-toolbar {
    padding: 0;
    gap: 8px;
  }
  .transcript-detail-title h2 {
    font-size: 14px;
    margin: 0 0 2px;
  }
  .transcript-detail-subtitle {
    font-size: 10px;
    line-height: 1.35;
  }
  /* cwd（路径）手机太长一般不需要看，截断显示 */
  .transcript-detail-cwd {
    font-size: 9.5px;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  /* actions 用更紧凑间距 */
  .transcript-detail-toolbar-actions {
    gap: 4px;
    width: 100%;
  }
  .transcript-detail-toolbar-actions .icon-action {
    padding: 5px 6px;
    font-size: 13px;
    min-width: auto;
  }
  .transcript-detail-toolbar-actions .chip-button {
    padding: 5px 9px;
    font-size: 12px;
  }
  /* 搜索框（在 header 里）紧凑——防止搜索框挤走 ↑↓ 按钮到下一行 */
  .transcript-detail-search {
    margin-top: 6px;
    gap: 4px;
    flex-wrap: nowrap;
  }
  .transcript-detail-search form {
    flex: 1 1 120px;
    min-width: 0;
  }
  .transcript-detail-search input {
    font-size: 13px;
    padding: 6px 10px;
  }
  .transcript-detail-search-nav {
    gap: 2px;
    flex-shrink: 0;
  }
  .transcript-detail-search-nav > span {
    min-width: 32px;
    font-size: 11px;
  }
  .transcript-detail-search-nav button {
    padding: 4px 7px;
    font-size: 13px;
    min-width: 28px;
  }
  .transcript-message-stream {
    padding: 14px 8px 60px;
  }
  .transcript-message-bubble {
    font-size: 13.5px;
    padding: 10px 13px;
  }
}

/* ═══ 记忆图（D3 force-directed）═══ */

/* 工具条 */
.graph-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 12px 4px;
  margin-bottom: 12px;
}

/* wing 颜色小圆点（dropdown 行 + 当前选中按钮里）*/
.wing-color-dot {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.18);
  transition: width 0.18s ease, height 0.18s ease, box-shadow 0.18s ease;
}
/* Active 状态：放大 + 用 currentColor（继承 inline style 的 color = wing color）发光 */
.wing-color-dot.is-active {
  width: 16px;
  height: 16px;
  box-shadow: 0 0 10px currentColor, 0 0 4px currentColor inset;
  border-color: rgba(255, 255, 255, 0.45);
}

/* dropdown menu hover 高亮 */
.graph-wing-dropdown-item:hover {
  background: var(--accent-soft, rgba(180, 148, 255, 0.18)) !important;
}
.graph-wing-dropdown-row:hover .graph-wing-rename-btn,
.graph-wing-dropdown-row:hover .graph-wing-filter-btn {
  opacity: 1 !important;
}
/* 触控目标 ≥ 32px (icon-action 默认偏小，dropdown 里改成 padding 8px 不撞到名字) */
.graph-wing-rename-btn,
.graph-wing-filter-btn {
  min-width: 32px;
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
}
.graph-wing-rename-btn:hover,
.graph-wing-filter-btn:hover {
  background: rgba(255, 255, 255, 0.06);
}
/* chip-button 里的清除按钮 ✕ — 跟其他子元素垂直对齐 */
.graph-wing-clear-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}
.graph-wing-clear-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* 容器：夜间深紫星空，白天浅暖（用 CSS var 双主题适配）*/
.graph-container {
  position: relative;
  width: 100%;
  border-radius: 16px;
  min-width: 0;
  overflow: hidden;
  /* 夜间默认：深紫星空 + 内阴影增加沉浸 */
  background: radial-gradient(ellipse at top, #2a1f4a 0%, #1a1230 60%, #0f0820 100%);
  box-shadow:
    inset 0 0 80px rgba(0, 0, 0, 0.5),
    0 4px 24px rgba(80, 60, 140, 0.2);
  border: 1px solid rgba(180, 160, 220, 0.15);
}

/* 白天主题：暖灰背景 — 比米色暗一档让深色 wing 节点更显形 */
html.is-daytime .graph-container,
html.is-daytime .graph-3d-container,
html.is-daytime .portal-graph-thumb {
  background: radial-gradient(ellipse at top, #ede5d8 0%, #ddd2c8 60%, #c8bfb8 100%);
  box-shadow:
    inset 0 0 80px rgba(120, 100, 90, 0.18),
    0 4px 24px rgba(180, 150, 130, 0.12);
  border: 1px solid rgba(140, 110, 90, 0.18);
}

/* 图例：Eli 4/21 夜从 absolute 右下浮窗 → block 居中在记忆图下方
 * （避免Elias立绘挡住；避开 3D 画布的拖动区域）*/
.graph-legend {
  margin: 12px auto 0;
  max-width: 960px;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 11px;
  line-height: 1.85;
  letter-spacing: 0.3px;
  /* 夜间：暗紫玻璃 */
  background: rgba(20, 15, 40, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #d4c8e8;
  border: 1px solid rgba(180, 160, 220, 0.18);
  pointer-events: auto;  /* 不再是右下浮窗，用户可选中文字 */
  text-align: center;
}

html.is-daytime .graph-legend {
  background: rgba(255, 250, 245, 0.72);
  color: #5a4838;
  border: 1px solid rgba(180, 150, 130, 0.2);
}

/* 节点 hover 微交互 */
.graph-container svg .node {
  transition: transform 0.15s ease;
}
.graph-container svg .node:hover {
  filter: brightness(1.15);
}

/* SVG 高度自适应：桌面 600px，手机紧凑 */
.graph-container svg {
  height: 600px;
  max-height: calc(100vh - 220px);
}

/* 节点 popover：桌面右侧悬浮，手机底部抽屉 */
.graph-popover {
  /* 用 absolute 定位到 graph-3d-container 内部左上角（贴大框，零空隙）*/
  position: absolute;
  left: 0;
  top: 0;
  width: 340px;
  max-width: calc(100% - 16px);
  background: var(--surface-raised, #fff);
  color: var(--text);
  border: 1px solid var(--line-strong, #e0d0e8);
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 60;  /* 比搜索结果列表（z=30）高一点 */
}
html.is-daytime .graph-popover {
  background: rgba(255, 252, 248, 0.97);
}

/* 手机端响应式（统一断点 720px）*/
@media (max-width: 719px) {
  .graph-toolbar {
    padding: 8px 2px;
    gap: 6px;
  }
  .graph-toolbar .chip-button {
    font-size: 12px;
    padding: 5px 9px;
  }
  .graph-container svg {
    height: 480px;
    max-height: calc(100vh - 180px);
  }
  /* legend 手机端（Eli 4/21：不再是右下浮窗，在记忆图下方 block 居中）*/
  .graph-legend {
    margin: 8px 6px 0;
    padding: 8px 10px;
    font-size: 10px;
    line-height: 1.6;
    max-width: calc(100vw - 12px);
  }
  /* popover 改成底部抽屉 */
  .graph-popover {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: 8px;
    top: auto;
    width: auto;
    max-width: none;
    border-radius: 14px;
    padding: 12px;
    max-height: 50vh;
    overflow-y: auto;
  }
  /* 长卡的 5 个 inline 按钮 — 手机端可能挤，间距小一点 */
  .list-card .inline-actions {
    gap: 4px !important;
  }
  .list-card .inline-actions .icon-action {
    padding: 4px;
    min-width: auto;
  }
}

/* ═══ 记忆图（3D 版升级 — 3d-force-graph + Three.js）═══ */

/* 3D 容器（替换 SVG）*/
.graph-3d-container {
  height: 70vh;
  min-height: 540px;
  max-height: calc(100vh - 240px);
  position: relative;
}
/* 3d-force-graph 注入的 canvas */
.graph-3d-container canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}
/* node hover tooltip（库自带，给个限宽）*/
.scene-tooltip {
  max-width: 300px;
}

/* 3D wrap 让 search-results 能浮在右上 */
.graph-3d-wrap {
  position: relative;
}

/* 详情页搜索框（内嵌在 wing chips 行中间，flex:1 撑开 wings 后到右边按钮的空位）*/
.graph-search-form {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  padding: 3px 10px;
  border: 1px solid var(--line-strong, #e0d0e8);
  border-radius: 20px;
  background: var(--surface, #fff);
  height: 28px;
}
.graph-search-form input {
  flex: 1;
  border: none;
  background: transparent;
  font-size: 14px;
  outline: none;
  min-width: 0;
  color: var(--text);
}
.graph-search-form .icon-action {
  padding: 4px 8px;
  background: transparent;
}

/* 命中候选列表（浮在 3D 容器右上角）*/
.graph-search-results {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 320px;
  max-width: calc(100% - 24px);
  max-height: 60vh;
  overflow-y: auto;
  background: rgba(20, 15, 40, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(180, 160, 220, 0.25);
  border-radius: 12px;
  padding: 8px;
  z-index: 30;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}
html.is-daytime .graph-search-results {
  background: rgba(255, 251, 245, 0.92);
  border-color: rgba(180, 150, 130, 0.3);
  color: #4a3828;
}
.graph-search-results-header {
  font-size: 11px;
  color: var(--dim);
  padding: 4px 8px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 4px;
}
html.is-daytime .graph-search-results-header {
  border-bottom-color: rgba(0, 0, 0, 0.08);
}
.graph-search-result-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: background 0.12s ease;
}
.graph-search-result-item:hover {
  background: rgba(255, 255, 255, 0.08);
}
html.is-daytime .graph-search-result-item:hover {
  background: rgba(0, 0, 0, 0.05);
}
.graph-search-result-title {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.3;
  word-break: break-word;
}
.graph-search-result-meta {
  font-size: 10.5px;
  color: var(--dim);
  margin-top: 2px;
}
.graph-search-no-result {
  padding: 16px;
  text-align: center;
  color: var(--dim);
  font-size: 12px;
}

/* wing chip + 重命名小铅笔 */
.graph-wing-chip-wrap {
  display: inline-flex;
  align-items: center;
  gap: 0;
}
.graph-wing-rename-btn {
  background: transparent !important;
  border: none;
  padding: 2px 5px;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease;
}
.graph-wing-rename-btn:hover {
  opacity: 1;
}
form[data-form="graph-rename-wing"] {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

/* ═══ Portal 记忆图卡片（统计 + 慢转 3D 缩略）═══ */

.bento-graph {
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.bento-graph:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(120, 90, 180, 0.18);
}

.portal-graph-stats {
  display: flex;
  flex-direction: column;
  gap: 12px;
  height: 100%;
  min-height: 0;
}

/* 数字行 */
.portal-graph-numrow {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.portal-graph-stat-block {
  text-align: center;
  padding: 6px 4px;
  background: rgba(180, 160, 220, 0.08);
  border-radius: 8px;
}
html.is-daytime .portal-graph-stat-block {
  background: rgba(180, 150, 200, 0.10);
}
.portal-graph-stat-value {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--accent-gold, #d8b060);
  line-height: 1.1;
}
.portal-graph-stat-label {
  font-size: 11px;
  color: var(--dim);
  margin-top: 2px;
}

/* 缩略 3D 容器 */
.portal-graph-thumb {
  flex: 1;
  min-height: 180px;
  border-radius: 12px;
  overflow: hidden;
  background: radial-gradient(ellipse at top, #2a1f4a 0%, #1a1230 60%, #0f0820 100%);
  position: relative;
}
html.is-daytime .portal-graph-thumb {
  background: radial-gradient(ellipse at top, #fef9f2 0%, #f3edf8 55%, #ece4ed 100%);
}
.portal-graph-thumb canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

/* Eli 4/21 深夜：静态缩略图替换实时 3D（省 GPU/内存）
 * Eli 看截图"小小的看不出来是啥" — 让 img 填满整个卡片 (width/height 100% + cover)
 */
.portal-graph-thumb-static {
  flex: 1;
  min-height: 180px;
  border-radius: 12px;
  overflow: hidden;
  background: radial-gradient(ellipse at top, #2a1f4a 0%, #1a1230 60%, #0f0820 100%);
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
html.is-daytime .portal-graph-thumb-static {
  background: radial-gradient(ellipse at top, #fef9f2 0%, #f3edf8 55%, #ece4ed 100%);
}
.portal-graph-thumb-static img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;  /* 填满卡片，略裁边（截图是 2000+x1100+，裁掉边缘没影响）*/
  min-height: 180px;
}
.portal-graph-thumb-fallback {
  text-align: center;
  padding: 20px;
  line-height: 0;
}

/* wing 简写 chips */
.portal-graph-wingrow {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.portal-graph-wing-pill {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  white-space: nowrap;
}

.portal-graph-cta {
  text-align: right;
  padding-top: 4px;
}

/* ═══ 手机端：完全不显示记忆图 ═══ */

@media (max-width: 720px) {
  /* nav 按钮隐藏 */
  .side-nav-btn.graph-nav-btn {
    display: none !important;
  }
  /* portal 卡片隐藏 */
  .bento-graph.hide-on-mobile {
    display: none !important;
  }
}

/* ═══ 详情卡片 + 表单卡片换行保护（Eli 4/21 反馈：手机端所有详情页的文字
 * 右侧 overflow 到卡片外；长标题配右上角按键也挤爆，4-5 字就换行多行堆叠）═══
 *
 * 根因：`.detail-card` 的 direct children 默认 grid item min-width:auto，长
 * 中文行没有空格的话会一口气撑到 content 宽度；`.body-text` 全局也没有 word-break
 * 规则（之前只 `.list-card .body-text` 有）。统一补上。
 */

.detail-card > *,
.form-card > * {
  min-width: 0;
  max-width: 100%;
}

.body-text,
.detail-card p,
.detail-card strong,
.detail-card h1,
.detail-card h2,
.detail-card h3,
.detail-card code,
.detail-card pre,
.detail-title {
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* pre 里的长 Message-Id 等固定宽度文本也强制换行 */
.detail-card pre {
  white-space: pre-wrap;
}

/* 手机端 detail-header 让 .detail-actions 不挤爆标题区 ——
 * 宽度够时标题左 + actions 右同排，不够时 actions 整体换行到标题下面。
 */
@media (max-width: 720px) {
  .detail-header {
    flex-wrap: wrap;
  }
  .detail-header > .detail-actions {
    flex-wrap: wrap;
    gap: 6px;
  }
}


/* Elias Hearth neutral visual placeholders */
.corner-hearth, .star-bg { display: none !important; }
.portal-hero-hearth { content: url("/img/hearth-placeholder.svg"); }
