/* 枕边换装底座：主题只覆写视觉变量，不触碰页面结构和业务数据。 */
:root {
  --font-body: 'Noto Sans SC', sans-serif;
  --font-display: 'ZCOOL XiaoWei', serif;
  --nav-bg: rgba(26,22,18,.85);
  --status-bg: rgba(26,22,18,.6);
  --input-bar-bg: rgba(26,22,18,.9);
  --overlay-bg: rgba(0,0,0,.6);
  --accent-soft: rgba(212,165,116,.12);
  --accent-border: rgba(212,165,116,.3);
  --card-shadow: none;
  --particle-opacity: 1;
  color-scheme: dark;
}

:root[data-theme='mist-blue'] {
  --bg-main: #edf5fa;
  --bg-card: #f8fbfd;
  --bg-hover: #fff;
  --accent: #6f9ec1;
  --accent-sub: #648eae;
  --accent-glow: rgba(111,158,193,.18);
  --text-main: #385064;
  --text-secondary: #6d8292;
  --text-weak: #91a4b2;
  --border: #d3e1ea;
  --income: #6c9b70;
  --expense: #c97979;
  --tag-milestone: #779fbd;
  --tag-anniversary: #c9859a;
  --tag-skill: #75a17b;
  --tag-setting: #718fba;
  --tag-daily: #8599a8;
  --nav-bg: rgba(237,245,250,.86);
  --status-bg: rgba(237,245,250,.74);
  --input-bar-bg: rgba(237,245,250,.92);
  --overlay-bg: rgba(68,87,103,.24);
  --accent-soft: rgba(111,158,193,.13);
  --accent-border: rgba(111,158,193,.32);
  --card-shadow: 0 14px 42px rgba(83,119,143,.12);
  --particle-opacity: .36;
  color-scheme: light;
}

:root[data-theme='cream-note'] {
  --bg-main: #fbf4eb;
  --bg-card: #fffaf3;
  --bg-hover: #fffdf9;
  --accent: #b98768;
  --accent-sub: #a87760;
  --accent-glow: rgba(185,135,104,.17);
  --text-main: #5d4a40;
  --text-secondary: #8b7468;
  --text-weak: #aa9689;
  --border: #e7d8ca;
  --income: #739769;
  --expense: #bf7770;
  --tag-milestone: #b98768;
  --tag-anniversary: #bd7f91;
  --tag-skill: #77966e;
  --tag-setting: #748da1;
  --tag-daily: #968277;
  --nav-bg: rgba(251,244,235,.88);
  --status-bg: rgba(251,244,235,.76);
  --input-bar-bg: rgba(251,244,235,.93);
  --overlay-bg: rgba(83,65,54,.24);
  --accent-soft: rgba(185,135,104,.13);
  --accent-border: rgba(185,135,104,.32);
  --card-shadow: 0 14px 42px rgba(117,85,65,.11);
  --particle-opacity: .3;
  color-scheme: light;
}

:root[data-font='rounded'] {
  --font-body: ui-rounded, 'Arial Rounded MT Bold', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  --font-display: ui-rounded, 'Arial Rounded MT Bold', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

html, body, .subtitle-names, .nav-back, .room-tab, .chat-input,
.add-record-btn, .record-edit-btn, .timeline-card-header h4,
.modal-field input, .modal-field textarea, .modal-cancel, .modal-confirm,
.prompt-add-btn, .prompt-entry textarea, .type-btn, .tag-option, .test-btn {
  font-family: var(--font-body);
}

.main-title, .card-content h3, .nav-title, .records-header h3,
.memory-title, .empty-state p:first-child, .modal h3, .appearance-panel h3 {
  font-family: var(--font-display);
}

#particles { opacity: var(--particle-opacity); }
.top-nav { background: var(--nav-bg); }
.chat-status { background: var(--status-bg); }
.chat-input-area { background: var(--input-bar-bg); }
.modal-overlay { background: var(--overlay-bg); }
.feature-card, .balance-card, .timeline-card, .modal { box-shadow: var(--card-shadow); }

.feature-card:hover, .feature-card:active, .timeline-card:hover,
.chat-input:focus, .modal-field input:focus, .modal-field textarea:focus,
.prompt-entry textarea:focus, .test-btn:hover, .room-tab.active,
.room-tab.add-room:hover { border-color: var(--accent-border); }

:root[data-theme] .message.ashi .bubble,
:root[data-theme] .room-tab.active,
:root[data-theme] .add-record-btn,
:root[data-theme] .add-memory-btn,
:root[data-theme] .record-edit-btn,
:root[data-theme] .prompt-add-btn:hover { background: var(--accent-soft); }

.appearance-trigger {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 20;
  min-width: 48px;
  height: 42px;
  padding: 0 14px;
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  background: var(--nav-bg);
  color: var(--accent);
  font: 500 13px/1 var(--font-body);
  letter-spacing: .04em;
  box-shadow: var(--card-shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  cursor: pointer;
  transition: transform .2s ease, background .2s ease;
}

.appearance-trigger:hover, .appearance-trigger:active {
  background: var(--bg-hover);
  transform: translateY(-2px);
}

.appearance-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 20px;
  background: var(--overlay-bg);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
}
.appearance-overlay.is-open { display: flex; }

.appearance-panel {
  width: min(100%, 460px);
  max-height: min(82vh, 680px);
  overflow-y: auto;
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: 0 24px 70px rgba(31,24,21,.28);
  animation: appearanceRise .24s ease both;
}

.appearance-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.appearance-panel h3 { margin: 0; font-size: 21px; font-weight: 400; }
.appearance-close {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: transparent;
  color: var(--text-secondary);
  font: 400 20px/1 var(--font-body);
  cursor: pointer;
}

.appearance-group + .appearance-group {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.appearance-label {
  margin-bottom: 10px;
  color: var(--text-secondary);
  font-size: 12px;
  letter-spacing: .08em;
}
.theme-options {
  display: grid;
  grid-template-columns: repeat(3,minmax(0,1fr));
  gap: 9px;
}

.theme-option, .font-option {
  border: 1px solid var(--border);
  background: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-body);
  cursor: pointer;
  transition: border-color .2s ease, transform .2s ease;
}
.theme-option {
  min-height: 106px;
  padding: 10px;
  border-radius: 16px;
  text-align: left;
}
.theme-option:hover, .theme-option.is-active,
.font-option:hover, .font-option.is-active { border-color: var(--accent); }
.theme-option.is-active, .font-option.is-active { box-shadow: 0 0 0 2px var(--accent-glow); }
.theme-option:hover { transform: translateY(-2px); }
.theme-swatch {
  display: grid;
  grid-template-columns: 1fr 1fr .7fr;
  height: 42px;
  margin-bottom: 9px;
  overflow: hidden;
  border: 1px solid rgba(80,70,64,.1);
  border-radius: 10px;
}
.theme-swatch span:nth-child(1) { background: var(--swatch-bg); }
.theme-swatch span:nth-child(2) { background: var(--swatch-card); }
.theme-swatch span:nth-child(3) { background: var(--swatch-accent); }
.theme-option strong { display: block; font-size: 12px; font-weight: 500; }
.theme-option small { display: block; margin-top: 3px; color: var(--text-weak); font-size: 10px; }
.font-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.font-option { padding: 13px 12px; border-radius: 14px; font-size: 14px; }
.font-option[data-font-choice='original'] { font-family: 'ZCOOL XiaoWei', serif; }
.font-option[data-font-choice='rounded'] {
  font-family: ui-rounded, 'Arial Rounded MT Bold', 'PingFang SC', 'Microsoft YaHei', sans-serif;
}
.appearance-note {
  margin-top: 16px;
  color: var(--text-weak);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

@keyframes appearanceRise {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
@media (min-width: 640px) { .appearance-overlay { align-items: center; } }
@media (max-width: 390px) {
  .appearance-panel { padding: 20px 16px; }
  .theme-options { gap: 7px; }
  .theme-option { padding: 8px; }
}

/* 将旧样式里的暖棕常量也接到主题变量上。 */
:root[data-theme] .main-title {
  text-shadow: 0 0 40px var(--accent-glow), 0 0 80px var(--accent-glow);
}
:root[data-theme] .feature-card::before {
  box-shadow: 0 4px 30px var(--accent-glow), inset 0 0 30px var(--accent-glow);
}
:root[data-theme] .balance-glow {
  background: radial-gradient(circle, var(--accent-glow), transparent 70%);
}
:root[data-theme] .add-record-btn,
:root[data-theme] .add-memory-btn,
:root[data-theme] .record-edit-btn {
  border-color: var(--accent-border);
}
:root[data-theme] .add-record-btn:hover,
:root[data-theme] .add-memory-btn:hover,
:root[data-theme] .record-edit-btn:hover {
  background: var(--accent-soft);
}
:root[data-theme] .toggle-label input[type="checkbox"]:checked {
  background: var(--accent-border);
}


/* 统一客厅布局：结构固定，三套主题只改变材质、色彩和字体。 */
.living-room {
  width: min(100%, 620px);
  min-height: 100%;
  margin: 0 auto;
  padding: 18px 18px 112px;
  position: relative;
  z-index: 1;
}

.living-topbar {
  height: 48px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
}

.living-brand {
  font-family: var(--font-display);
  color: var(--text-main);
  font-size: 20px;
  letter-spacing: .18em;
  text-align: center;
}

.living-icon-btn {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 0;
  border-radius: 50%;
  color: var(--text-main);
  cursor: pointer;
}

.living-icon-btn:active {
  background: var(--accent-soft);
}

.menu-lines {
  justify-self: start;
  align-content: center;
  gap: 4px;
}

.menu-lines span {
  width: 17px;
  height: 1px;
  display: block;
  background: currentColor;
  border-radius: 1px;
}

.menu-lines span:nth-child(2) {
  width: 12px;
}

.theme-orbit {
  justify-self: end;
  position: relative;
}

.theme-orbit::before {
  content: '';
  width: 16px;
  height: 16px;
  border: 1px solid currentColor;
  border-radius: 50%;
  opacity: .8;
}

.theme-orbit::after {
  content: '';
  width: 25px;
  height: 9px;
  position: absolute;
  border: 1px solid var(--accent);
  border-top-color: transparent;
  border-left-color: transparent;
  border-radius: 50%;
  transform: rotate(-28deg);
}

.living-hero {
  padding: 24px 0 20px;
  text-align: center;
}

.home-avatars {
  width: 134px;
  height: 70px;
  display: flex;
  justify-content: center;
  position: relative;
  margin: 0 auto 13px;
}

.home-avatar {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  position: relative;
  z-index: 2;
  border: 2px solid var(--bg-main);
  border-radius: 50%;
  box-shadow: var(--card-shadow);
  font-family: var(--font-display);
  font-size: 22px;
}

.avatar-ashi {
  margin-right: -7px;
  color: #f7fbff;
  background: linear-gradient(145deg, #8aafd2, #bdd3e8);
}

.avatar-zhiyu {
  margin-left: -7px;
  color: #fffaff;
  background: linear-gradient(145deg, #998ec8, #c8bce5);
}

.avatar-orbit {
  width: 126px;
  height: 34px;
  position: absolute;
  left: 4px;
  top: 22px;
  border: 1px solid var(--accent-border);
  border-radius: 50%;
  transform: rotate(-10deg);
  opacity: .55;
}

.avatar-orbit::after {
  content: '';
  width: 7px;
  height: 7px;
  position: absolute;
  right: 11px;
  top: 0;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 14px var(--accent);
}

.living-greeting {
  color: var(--text-weak);
  font-size: 11px;
  letter-spacing: .08em;
}

.living-days {
  margin-top: 6px;
  color: var(--text-secondary);
  font-size: 13px;
  letter-spacing: .08em;
}

.living-days strong {
  margin: 0 7px;
  color: var(--text-main);
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 400;
  letter-spacing: .04em;
}

.living-dashboard {
  display: grid;
  gap: 10px;
}

.living-card {
  position: relative;
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 17px;
  box-shadow: var(--card-shadow);
  color: var(--text-main);
}

.latest-note-card {
  min-height: 128px;
  padding: 17px 18px;
}

.living-card-heading {
  display: flex;
  align-items: center;
  gap: 9px;
}

.living-card-heading h2 {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 400;
  letter-spacing: .08em;
}

.latest-note-card > p {
  max-width: 82%;
  margin-top: 14px;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.8;
}

.latest-note-card > small {
  display: block;
  margin-top: 10px;
  color: var(--text-weak);
  font-size: 9px;
}

.card-more {
  margin-left: auto;
  background: transparent;
  border: 0;
  color: var(--text-weak);
  font-size: 20px;
  font-weight: 300;
  cursor: pointer;
}

.note-orbit {
  width: 86px;
  height: 26px;
  position: absolute;
  right: 10px;
  bottom: 8px;
  border: 1px solid var(--accent-border);
  border-radius: 50%;
  transform: rotate(-15deg);
  opacity: .35;
}

.note-orbit::after {
  content: '';
  width: 5px;
  height: 5px;
  position: absolute;
  right: 12px;
  top: -2px;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: 0 0 10px var(--accent);
}

.living-card-row {
  display: grid;
  grid-template-columns: .88fr 1.12fr;
  gap: 10px;
}

.weather-card,
.today-card {
  min-height: 120px;
  padding: 16px;
}

.weather-card > strong {
  display: block;
  margin-top: 15px;
  color: var(--text-main);
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 400;
}

.weather-card > p {
  margin-top: 7px;
  color: var(--text-weak);
  font-size: 10px;
}

.today-card ul {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  padding: 0;
  list-style: none;
}

.today-card li {
  position: relative;
  padding-left: 13px;
  color: var(--text-secondary);
  font-size: 10px;
}

.today-card li::before {
  content: '';
  width: 5px;
  height: 5px;
  position: absolute;
  left: 0;
  top: .45em;
  background: var(--accent);
  border-radius: 50%;
  opacity: .8;
}

.living-wide-card {
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto 14px;
  align-items: center;
  gap: 9px;
  padding: 12px 16px;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.living-wide-card > span:nth-child(2) {
  min-width: 0;
}

.living-wide-card strong {
  display: block;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: .08em;
}

.living-wide-card small {
  display: block;
  margin-top: 3px;
  color: var(--text-weak);
  font-size: 9px;
}

.wide-copy {
  color: var(--text-weak);
  font-size: 9px;
  white-space: nowrap;
}

.line-icon {
  width: 17px;
  height: 17px;
  display: inline-block;
  position: relative;
  flex: 0 0 auto;
  color: var(--accent);
}

.note-icon,
.calendar-icon,
.today-icon {
  border: 1px solid currentColor;
  border-radius: 3px;
}

.note-icon::after {
  content: '';
  width: 7px;
  height: 1px;
  position: absolute;
  left: 4px;
  top: 5px;
  background: currentColor;
  box-shadow: 0 4px 0 currentColor;
}

.calendar-icon::before,
.today-icon::before {
  content: '';
  position: absolute;
  left: 2px;
  right: 2px;
  top: 4px;
  border-top: 1px solid currentColor;
}

.weather-icon {
  border: 1px solid currentColor;
  border-radius: 50%;
  box-shadow: 7px -6px 0 -5px currentColor, -7px 6px 0 -5px currentColor;
}

.capsule-icon {
  width: 13px;
  height: 19px;
  margin-left: 2px;
  border: 1px solid currentColor;
  border-radius: 7px;
}

.capsule-icon::after {
  content: '';
  position: absolute;
  left: 2px;
  right: 2px;
  top: 6px;
  border-top: 1px solid currentColor;
}

.living-room .home-footer {
  margin-top: 24px;
  text-align: center;
  opacity: .75;
}

.house-bottom-nav {
  min-height: 72px;
  width: min(100%, 620px);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  align-items: end;
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 80;
  transform: translateX(-50%);
  padding: 8px 10px calc(7px + env(safe-area-inset-bottom));
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 30px rgba(0,0,0,.08);
  backdrop-filter: blur(18px);
}

.bottom-nav-item {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 3px;
  position: relative;
  padding: 5px 2px;
  background: transparent;
  border: 0;
  color: var(--text-weak);
  font-family: var(--font-body);
  font-size: 9px;
  cursor: pointer;
}

.bottom-nav-item svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.35;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.bottom-nav-item.active {
  color: var(--accent);
}

.bottom-nav-chat {
  align-self: center;
  margin-top: -30px;
}

.chat-orb {
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin-bottom: 1px;
  background: var(--accent);
  border: 5px solid var(--bg-card);
  border-radius: 50%;
  box-shadow: 0 6px 20px var(--accent-glow);
}

.chat-orb i {
  width: 3px;
  height: 3px;
  background: var(--bg-main);
  border-radius: 50%;
}

.house-drawer-layer {
  position: fixed;
  inset: 0;
  z-index: 180;
  visibility: hidden;
  pointer-events: none;
}

.house-drawer-layer.active {
  visibility: visible;
  pointer-events: auto;
}

.house-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 9, 18, .55);
  border: 0;
  opacity: 0;
  transition: opacity .28s ease;
}

.house-drawer-layer.active .house-drawer-backdrop {
  opacity: 1;
}

.house-drawer {
  width: min(84vw, 360px);
  height: 100%;
  overflow-y: auto;
  position: relative;
  z-index: 1;
  padding: 42px 24px 36px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  box-shadow: 18px 0 60px rgba(0,0,0,.24);
  transform: translateX(-102%);
  transition: transform .32s cubic-bezier(.2,.8,.2,1);
}

.house-drawer-layer.active .house-drawer {
  transform: translateX(0);
}

.drawer-profile {
  padding-bottom: 21px;
  border-bottom: 1px solid var(--border);
}

.drawer-avatars {
  display: flex;
  margin-bottom: 14px;
}

.drawer-avatar {
  width: 45px;
  height: 45px;
  display: grid;
  place-items: center;
  margin-right: -8px;
  background: linear-gradient(145deg, #8aafd2, #bdaedc);
  border: 2px solid var(--bg-card);
  border-radius: 50%;
  color: white;
  font-family: var(--font-display);
  font-size: 16px;
}

.drawer-profile h2 {
  font-family: var(--font-display);
  color: var(--text-main);
  font-size: 18px;
  font-weight: 400;
  letter-spacing: .06em;
}

.drawer-profile p {
  margin-top: 6px;
  color: var(--text-weak);
  font-size: 10px;
}

.drawer-section-label {
  margin: 22px 0 8px;
  color: var(--text-weak);
  font-size: 9px;
  letter-spacing: .15em;
}

.drawer-list {
  display: grid;
}

.drawer-list button {
  min-height: 44px;
  display: grid;
  grid-template-columns: 25px 1fr 14px;
  align-items: center;
  gap: 9px;
  padding: 0 4px;
  background: transparent;
  border: 0;
  color: var(--text-secondary);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.drawer-list button:active {
  color: var(--accent);
}

.drawer-list b {
  color: var(--text-weak);
  font-size: 18px;
  font-weight: 300;
  text-align: right;
}

.drawer-icon {
  color: var(--accent);
  font-family: serif;
  font-size: 17px;
  text-align: center;
}

.house-toast {
  max-width: calc(100% - 40px);
  position: fixed;
  left: 50%;
  bottom: calc(92px + env(safe-area-inset-bottom));
  z-index: 220;
  padding: 11px 16px;
  background: var(--bg-hover);
  border: 1px solid var(--accent-border);
  border-radius: 999px;
  box-shadow: var(--card-shadow);
  color: var(--text-secondary);
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity .22s ease, transform .22s ease;
}

.house-toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

#page-chat .chat-container {
  height: calc(100% - 57px - 72px - env(safe-area-inset-bottom));
}

#page-treasury .treasury-container,
#page-memory .memory-container {
  padding-bottom: calc(110px + env(safe-area-inset-bottom));
}

@media (min-width: 700px) {
  .living-room {
    padding-top: 28px;
  }

  .house-drawer {
    width: 380px;
  }
}

@media (max-width: 390px) {
  .living-room {
    padding-left: 14px;
    padding-right: 14px;
  }

  .living-card-row {
    grid-template-columns: 1fr 1fr;
  }

  .wide-copy {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .house-drawer,
  .house-drawer-backdrop,
  .house-toast {
    transition: none;
  }
}
