:root {
  --bg: #f3edf9;
  --bg-soft: #eef3ec;
  --card: rgba(255, 253, 255, 0.9);
  --card-solid: #fffefe;
  --text: #51475a;
  --text-strong: #302839;
  --muted: #8e8198;
  --line: rgba(104, 88, 124, 0.16);
  --accent: #c6b0e2;
  --accent-strong: #876ca8;
  --sage: #b8c5b2;
  --cream: #fff9ef;
  --rose: #eadff5;
  --shadow: 0 18px 50px rgba(85, 64, 106, 0.13);
  --shadow-soft: 0 10px 26px rgba(85, 64, 106, 0.1);
  --radius: 26px;
  --radius-sm: 18px;
  --sidebar-width: 274px;
  color-scheme: light;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", Arial, sans-serif;
}

/* Model center */
.runtime-logs-page {
  display: grid;
  gap: 20px;
  padding-bottom: calc(44px + env(safe-area-inset-bottom));
}

.runtime-logs-intro {
  max-width: 800px;
  margin: -8px 0 0;
  color: var(--muted);
  line-height: 1.75;
}

.runtime-summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.runtime-summary-grid > div {
  display: grid;
  gap: 6px;
  min-height: 92px;
  align-content: center;
  padding: 15px;
  border: 1px solid rgba(112, 88, 139, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.58);
  text-align: center;
}

.runtime-summary-grid span,
.runtime-log-card header p,
.runtime-maintenance-band p {
  color: var(--muted);
}

.runtime-summary-grid strong {
  color: var(--text-strong);
  font-size: 1.55rem;
}

.runtime-summary-grid .summary-time {
  font-size: 0.9rem;
  line-height: 1.4;
}

.runtime-toolbar {
  display: grid;
  gap: 14px;
  padding: 18px 0;
  border-block: 1px solid rgba(112, 88, 139, 0.13);
}

.runtime-level-filter {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.runtime-level-filter button {
  flex: 0 0 auto;
  border: 1px solid rgba(112, 88, 139, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  color: var(--muted);
  padding: 8px 13px;
}

.runtime-level-filter button.active {
  border-color: rgba(112, 88, 139, 0.3);
  background: var(--accent);
  color: var(--text-strong);
}

.runtime-filter-grid {
  display: grid;
  grid-template-columns: minmax(130px, 0.8fr) repeat(2, minmax(145px, 0.7fr)) minmax(220px, 1.5fr);
  gap: 10px;
}

.runtime-filter-grid .form-field,
.runtime-controls-band .form-field,
.runtime-maintenance-band .form-field {
  margin: 0;
}

.runtime-unresolved-field {
  max-width: 390px;
}

.runtime-controls-band {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
}

.runtime-controls-band .form-field {
  min-width: 150px;
}

.runtime-log-list {
  display: grid;
  gap: 10px;
}

.runtime-log-card {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 17px 18px;
  border: 1px solid rgba(112, 88, 139, 0.13);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 7px 22px rgba(82, 63, 105, 0.045);
}

.runtime-log-card.level-success { border-left-color: #a9c6ae; }
.runtime-log-card.level-info { border-left-color: #b8a7d1; }
.runtime-log-card.level-warning { border-left-color: #d9c890; }
.runtime-log-card.level-error { border-left-color: #d5a4ad; }
.runtime-log-card.resolved { opacity: 0.68; }

.runtime-log-card header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 11px;
}

.runtime-log-card h3,
.runtime-maintenance-band h2 {
  margin: 0;
}

.runtime-log-card header p,
.runtime-log-summary,
.runtime-maintenance-band p {
  margin: 4px 0 0;
  line-height: 1.55;
}

.runtime-level-badge,
.runtime-occurrence-count {
  padding: 4px 8px;
  border-radius: 999px;
  font-size: 0.74rem;
  white-space: nowrap;
}

.runtime-level-badge.success { background: rgba(140, 181, 148, 0.17); color: #56745d; }
.runtime-level-badge.info { background: rgba(156, 133, 185, 0.15); color: #715e89; }
.runtime-level-badge.warning { background: rgba(206, 181, 101, 0.17); color: #806f3c; }
.runtime-level-badge.error { background: rgba(190, 111, 126, 0.14); color: #965969; }
.runtime-occurrence-count { background: rgba(112, 88, 139, 0.08); color: var(--muted); }

.runtime-log-details {
  border-top: 1px solid rgba(112, 88, 139, 0.09);
  padding-top: 10px;
}

.runtime-log-details summary {
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 0.84rem;
}

.runtime-log-details pre {
  max-height: 320px;
  overflow: auto;
  margin: 10px 0 0;
  padding: 12px;
  border-radius: 10px;
  background: rgba(244, 239, 248, 0.82);
  color: var(--text);
  font: 0.78rem/1.55 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.runtime-log-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.runtime-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--muted);
}

.runtime-empty-state {
  padding: 48px 18px;
  text-align: center;
  color: var(--muted);
}

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

.runtime-maintenance-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(170px, 0.45fr) auto auto;
  align-items: end;
  gap: 12px;
  padding: 22px 0;
  border-top: 1px solid rgba(112, 88, 139, 0.13);
}

.diagnostic-modal-card {
  max-width: 700px;
  max-height: min(88dvh, 760px);
  overflow-y: auto;
}

.diagnostic-scope-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.diagnostic-scope-grid > div {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(247, 243, 250, 0.75);
}

.diagnostic-scope-grid ul {
  margin: 9px 0 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 760px) {
  .runtime-summary-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .runtime-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .runtime-search-field { grid-column: 1 / -1; }
  .runtime-maintenance-band { grid-template-columns: 1fr; align-items: stretch; }
}

@media (max-width: 520px) {
  .runtime-filter-grid,
  .diagnostic-scope-grid { grid-template-columns: 1fr; }
  .runtime-log-card header { grid-template-columns: auto minmax(0, 1fr); }
  .runtime-occurrence-count { grid-column: 2; justify-self: start; }
  .runtime-controls-band { align-items: stretch; }
  .runtime-controls-band > * { width: 100%; }
}

.model-hub-page {
  display: grid;
  gap: 22px;
  padding-bottom: calc(44px + env(safe-area-inset-bottom));
}

.model-hub-intro {
  max-width: 760px;
  margin: -8px 0 0;
  color: var(--muted);
  line-height: 1.75;
}

.model-hub-status {
  min-height: 22px;
  margin: 0;
}

.model-hub-section {
  display: grid;
  gap: 16px;
  padding: 22px 0;
  border-top: 1px solid rgba(112, 88, 139, 0.14);
}

.model-hub-section h2,
.model-hub-section h3 {
  margin: 0;
}

.active-model-section {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  align-items: center;
}

.active-model-display {
  display: grid;
  gap: 4px;
  padding: 18px 20px;
  border: 1px solid rgba(112, 88, 139, 0.15);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.62);
}

.active-model-display strong {
  color: var(--text);
  font-size: 1.08rem;
}

.active-model-display span,
.model-profile-row code,
.usage-model-row span {
  color: var(--muted);
  overflow-wrap: anywhere;
}

.task-model-grid,
.provider-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.task-model-field {
  display: grid;
  gap: 10px;
  padding: 15px;
  border: 1px solid rgba(112, 88, 139, 0.13);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.48);
}

.task-model-field > span {
  display: grid;
  gap: 3px;
}

.task-model-field small,
.model-profile-row p,
.provider-card dd,
.security-panel p {
  color: var(--muted);
  line-height: 1.55;
}

.task-model-field select,
.chat-model-bar select {
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(112, 88, 139, 0.2);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  padding: 10px 34px 10px 11px;
}

.provider-card {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 18px;
  border: 1px solid rgba(112, 88, 139, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.6);
  box-shadow: 0 8px 24px rgba(92, 69, 118, 0.05);
}

.provider-card header,
.model-profile-row,
.usage-model-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.provider-card dl {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 7px 12px;
  margin: 0;
  font-size: 0.88rem;
}

.provider-card dt {
  color: var(--muted);
}

.provider-card dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.status-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(126, 113, 140, 0.1);
  color: var(--muted);
  font-size: 0.76rem;
}

.status-badge.available {
  background: rgba(110, 145, 119, 0.14);
  color: #51725b;
}

.status-badge.failed {
  background: rgba(174, 94, 110, 0.12);
  color: #9b5363;
}

.model-profile-list,
.usage-model-list {
  display: grid;
  gap: 10px;
}

.model-profile-row,
.usage-model-row {
  padding: 16px 0;
  border-bottom: 1px solid rgba(112, 88, 139, 0.1);
}

.model-profile-row.disabled {
  opacity: 0.62;
}

.model-profile-row > div:first-child {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.model-profile-row p {
  margin: 0;
  font-size: 0.88rem;
}

.model-row-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.usage-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.usage-summary > div {
  display: grid;
  gap: 4px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.55);
  text-align: center;
}

.usage-summary strong {
  font-size: 1.35rem;
}

.usage-summary span {
  color: var(--muted);
  font-size: 0.8rem;
}

.security-panel {
  color: var(--muted);
}

.security-panel p,
.empty-copy {
  margin: 0;
}

.model-editor-card {
  max-height: min(88dvh, 760px);
  overflow-y: auto;
}

.chat-model-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  border-bottom: 1px solid rgba(112, 88, 139, 0.1);
  background: rgba(250, 247, 252, 0.78);
}

.chat-model-bar label,
.chat-model-bar a,
.message-model-meta {
  color: var(--muted);
  font-size: 0.76rem;
}

.chat-model-bar a {
  white-space: nowrap;
}

.chat-model-bar select {
  padding-top: 7px;
  padding-bottom: 7px;
  font-size: 0.82rem;
}

.message-model-meta {
  display: block;
  padding: 0 8px;
  overflow-wrap: anywhere;
}

@media (max-width: 720px) {
  .active-model-section,
  .task-model-grid,
  .provider-grid {
    grid-template-columns: 1fr;
  }

  .model-profile-row,
  .usage-model-row {
    align-items: stretch;
    flex-direction: column;
  }

  .model-row-actions {
    justify-content: flex-start;
  }

  .chat-model-bar {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .chat-model-bar label {
    display: none;
  }
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 12% 8%, rgba(255, 255, 255, 0.7), transparent 30%),
    radial-gradient(circle at 88% 18%, rgba(198, 176, 226, 0.28), transparent 28%),
    linear-gradient(145deg, var(--bg) 0%, var(--bg-soft) 100%);
}

body[data-background-style="soft pink"] {
  --bg: #f8ebe8;
  --bg-soft: #f6f0ea;
  --rose: #f3d4d4;
}

body[data-background-style="cream sage"] {
  --bg: #f6f1e7;
  --bg-soft: #edf3ea;
  --rose: #e5eddc;
}

body[data-font-mode="simple"] {
  font-family: "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif;
}

body[data-font-mode="soft"] {
  font-family: "Segoe UI", "Noto Sans TC", "Microsoft JhengHei", Arial, sans-serif;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  color: rgba(135, 108, 168, 0.14);
  content: "";
  font-family: Georgia, serif;
  font-size: 24px;
  line-height: 1;
  background-image:
    radial-gradient(circle at 22% 24%, currentColor 0 1px, transparent 1.5px),
    radial-gradient(circle at 78% 42%, currentColor 0 1px, transparent 1.5px),
    radial-gradient(circle at 48% 82%, currentColor 0 1px, transparent 1.5px);
  pointer-events: none;
}

body.hide-hearts::before {
  display: none;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
  text-decoration: none;
}

.app-shell {
  min-height: 100vh;
}

.page {
  width: min(1040px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 16px 28px;
}

.topbar,
.chat-header {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 58px;
  margin-bottom: 18px;
}

.topbar h1,
.chat-header h1 {
  margin: 2px 0 0;
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(28px, 8vw, 44px);
  font-weight: 500;
  letter-spacing: 0;
}

.chat-header h1 {
  font-size: 28px;
}

.eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.soft-copy {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.75;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 253, 250, 0.82);
  box-shadow: var(--shadow-soft);
  cursor: pointer;
}

.menu-button span {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 99px;
  background: currentColor;
}

.menu-button span + span {
  margin-top: 5px;
}

.primary-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 0;
  border-radius: 999px;
  color: #fffdfa;
  background: linear-gradient(135deg, #aa8dcc, #8065a2);
  box-shadow: 0 12px 28px rgba(128, 101, 162, 0.22);
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.primary-pill.subtle {
  color: var(--text);
  background: var(--cream);
  border: 1px solid var(--line);
  box-shadow: none;
}

.hero-panel,
.settings-intro,
.toolbar-card {
  position: relative;
  overflow: hidden;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius);
  background: linear-gradient(145deg, rgba(255, 253, 255, 0.94), rgba(245, 238, 252, 0.88));
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  gap: 20px;
  margin-bottom: 16px;
}

.hero-panel.small {
  min-height: 260px;
  align-content: center;
}

.hero-panel::after {
  position: absolute;
  right: 18px;
  top: 16px;
  color: rgba(135, 108, 168, 0.14);
  content: "♡";
  font-family: Georgia, serif;
  font-size: 86px;
}

.hero-panel h2,
.settings-intro h2,
.section-heading h2 {
  margin: 6px 0 0;
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(26px, 8vw, 46px);
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: 0;
}

.stats-grid {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: 12px;
  margin: 16px 0 24px;
}

.stat-card,
.quote-card,
.feature-card,
.memory-card,
.settings-panel {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: var(--shadow-soft);
}

.stat-card {
  min-height: 134px;
  padding: 18px;
  background: linear-gradient(145deg, #fffefe, #e7ddf4);
}

.stat-card span,
.stat-card small {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.stat-card strong {
  display: block;
  margin-top: 8px;
  color: var(--text-strong);
  font-family: Georgia, serif;
  font-size: 48px;
  font-weight: 500;
  line-height: 0.95;
}

.quote-card {
  min-height: 134px;
  padding: 18px;
}

.quote-card p {
  margin: 8px 0 0;
  color: var(--text);
  line-height: 1.65;
}

.section-heading {
  margin: 20px 0 12px;
}

.section-heading h2 {
  font-size: 30px;
}

.feature-grid {
  display: grid;
  gap: 12px;
}

.feature-card {
  display: grid;
  gap: 8px;
  min-height: 126px;
  padding: 18px;
}

.feature-card h3,
.memory-card h3,
.settings-panel h3 {
  margin: 0;
  color: var(--text-strong);
  font-size: 18px;
}

.feature-card p,
.memory-card p,
.settings-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.feature-meta,
.memory-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: min(var(--sidebar-width), calc(100vw - 44px));
  padding: calc(18px + env(safe-area-inset-top)) 14px 18px;
  background: rgba(255, 253, 249, 0.96);
  border-right: 1px solid var(--line);
  box-shadow: 22px 0 60px rgba(94, 69, 62, 0.16);
  transform: translateX(-104%);
  transition: transform 180ms ease;
}

.drawer-open .sidebar {
  transform: translateX(0);
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: rgba(59, 43, 39, 0.2);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.drawer-open .drawer-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 18px;
}

.brand-icon,
.companion-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 16px;
  color: #fffdfa;
  background: linear-gradient(145deg, #bca3dc, #b8c5b2);
  font-family: Georgia, serif;
  font-size: 22px;
  box-shadow: var(--shadow-soft);
}

.brand-lockup strong {
  display: block;
  color: var(--text-strong);
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 500;
}

.brand-lockup span {
  color: var(--muted);
  font-size: 12px;
}

.nav-list {
  display: grid;
  gap: 4px;
  max-height: calc(100vh - 110px);
  overflow-y: auto;
  padding-right: 2px;
}

.nav-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 14px;
  color: var(--muted);
  font-size: 14px;
}

.nav-link::after {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: transparent;
  content: "";
}

.nav-link.active {
  color: var(--text-strong);
  background: #f1e8f8;
}

.nav-link.active::after {
  background: var(--accent);
}

.chat-shell {
  height: 100vh;
  overflow: hidden;
}

.chat-page {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr auto;
  width: min(920px, 100%);
  height: 100vh;
  margin: 0 auto;
  padding-top: env(safe-area-inset-top);
  background: rgba(255, 250, 247, 0.42);
}

.chat-header {
  margin: 0;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.7);
  background: rgba(255, 253, 250, 0.76);
  backdrop-filter: blur(18px);
}

.chat-room {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  padding: 18px 16px 20px;
}

.message-row {
  display: flex;
  width: 100%;
}

.message-row.user {
  justify-content: flex-end;
}

.message-stack {
  display: grid;
  justify-items: start;
  gap: 3px;
  max-width: min(78vw, 620px);
}

.message-row.user .message-stack {
  justify-items: end;
}

.message-bubble {
  max-width: 100%;
  padding: 13px 15px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: 22px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.72;
  box-shadow: var(--shadow-soft);
}

.memory-save-action {
  min-height: 28px;
  padding: 2px 7px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 11px;
  cursor: pointer;
  opacity: 0.72;
}

.memory-save-action:focus-visible,
.memory-save-action:hover {
  color: var(--accent-strong);
  opacity: 1;
}

.message-row.assistant .message-bubble {
  border-bottom-left-radius: 8px;
  color: var(--text);
  background: rgba(255, 253, 250, 0.92);
}

.message-row.user .message-bubble {
  border-bottom-right-radius: 8px;
  color: #fffdfa;
  background: linear-gradient(145deg, #a989cf, #876ca8);
}

.message-row.system .message-bubble {
  color: #765f91;
  background: #fff9ef;
}

.composer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 14px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.78);
  background: rgba(255, 253, 250, 0.82);
  backdrop-filter: blur(18px);
}

.composer textarea {
  width: 100%;
  max-height: 128px;
  min-height: 46px;
  overflow-y: hidden;
  resize: none;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  outline: none;
  color: var(--text);
  background: #fffdfa;
  line-height: 1.45;
}

.composer textarea:focus,
.search-field input:focus {
  border-color: rgba(200, 121, 130, 0.55);
  box-shadow: 0 0 0 4px rgba(198, 176, 226, 0.2);
}

.send-button {
  min-width: 66px;
  min-height: 46px;
  border: 0;
  border-radius: 18px;
  color: #fffdfa;
  background: linear-gradient(145deg, #8f72b2, #a9b79f);
  box-shadow: 0 12px 26px rgba(104, 83, 132, 0.18);
  font-weight: 700;
  cursor: pointer;
}

.send-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.toolbar-card {
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
}

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

.search-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.search-field input {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: none;
  color: var(--text);
  background: #fffdfa;
}

.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar {
  display: none;
}

.chip {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(255, 253, 250, 0.7);
  cursor: pointer;
}

.chip.active {
  color: var(--text-strong);
  background: var(--rose);
}

.memory-list,
.settings-stack {
  display: grid;
  gap: 12px;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.memory-card {
  padding: 18px;
}

.memory-card.pinned {
  border-color: color-mix(in srgb, var(--accent-strong) 32%, transparent);
}

.memory-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.memory-card time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.memory-title-group {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.memory-pin-badge {
  padding: 3px 7px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--rose);
  font-size: 11px;
  font-weight: 700;
}

.memory-content {
  white-space: pre-wrap;
  word-break: break-word;
}

.memory-card-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.text-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.6);
  font-weight: 700;
  cursor: pointer;
}

.text-button.danger {
  color: #9f4f5c;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 14px;
}

.tag {
  padding: 5px 9px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: rgba(243, 212, 212, 0.58);
  font-size: 12px;
}

.settings-intro {
  margin-bottom: 16px;
}

.settings-panel {
  overflow: hidden;
}

.editable-panel {
  padding: 18px;
}

.settings-panel-header {
  margin-bottom: 16px;
}

.settings-panel-header h3 {
  margin: 0;
  color: var(--text-strong);
  font-size: 18px;
}

.settings-panel-header p {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.field-grid {
  display: grid;
  gap: 13px;
}

.form-field {
  display: grid;
  gap: 7px;
}

.form-field strong {
  color: var(--text-strong);
  font-size: 14px;
}

.form-field small {
  color: var(--muted);
  line-height: 1.55;
}

.form-field input,
.form-field textarea,
.form-field select {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  color: var(--text);
  background: #fffefe;
  line-height: 1.5;
}

.form-field textarea {
  resize: vertical;
}

.form-field input[type="color"] {
  min-height: 48px;
  padding: 6px;
}

.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  border-color: var(--accent-strong);
  box-shadow: 0 0 0 4px rgba(135, 108, 168, 0.13);
}

.checkbox-field {
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.48);
}

.checkbox-field input {
  width: 22px;
  min-height: 22px;
  accent-color: var(--accent-strong);
}

.settings-actions {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(243, 237, 249, 0), var(--bg) 22%);
}

.ghost-button {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 253, 255, 0.72);
  font-weight: 700;
  cursor: pointer;
}

.save-status {
  min-height: 22px;
  margin: 0;
  color: var(--accent-strong);
  text-align: center;
  font-weight: 700;
}

.save-status.error {
  color: #9f4f5c;
}

.page-message,
.form-message {
  min-height: 20px;
  margin: 0;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 700;
}

.page-message.error,
.form-message.error {
  color: #9f4f5c;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  align-items: end;
  justify-items: stretch;
}

.modal-layer[hidden] {
  display: none;
}

.modal-scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: rgba(48, 40, 57, 0.3);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-height: min(88vh, 760px);
  overflow-y: auto;
  padding: 20px 18px calc(18px + env(safe-area-inset-bottom));
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 26px 26px 0 0;
  background: rgba(255, 253, 255, 0.98);
  box-shadow: 0 -18px 60px rgba(48, 40, 57, 0.2);
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.modal-header h2 {
  margin: 4px 0 0;
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 28px;
  font-weight: 500;
}

.modal-close {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: #fff;
  font-size: 25px;
  line-height: 1;
  cursor: pointer;
}

.memory-editor form {
  display: grid;
  gap: 14px;
}

.memory-source-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  color: var(--muted);
  background: var(--rose);
  font-size: 12px;
}

.field-label-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.field-label-row output {
  color: var(--accent-strong);
  font-weight: 700;
}

.weight-field input[type="range"] {
  width: 100%;
  min-height: 28px;
  accent-color: var(--accent-strong);
}

.memory-pin-field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(243, 237, 249, 0.5);
}

.memory-pin-field strong,
.memory-pin-field small {
  display: block;
}

.memory-pin-field strong {
  color: var(--text-strong);
  font-size: 14px;
}

.memory-pin-field small {
  margin-top: 4px;
  color: var(--muted);
}

.memory-pin-field input {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  accent-color: var(--accent-strong);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.chat-notice {
  position: fixed;
  left: 50%;
  bottom: calc(82px + env(safe-area-inset-bottom));
  z-index: 80;
  max-width: calc(100vw - 32px);
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text-strong);
  background: rgba(255, 253, 255, 0.96);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.chat-notice.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.chat-notice.error {
  color: #9f4f5c;
}

body.modal-open {
  overflow: hidden;
}

.settings-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 70px;
  padding: 16px 18px;
  border: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.settings-toggle span {
  color: var(--muted);
  font-size: 13px;
}

.settings-toggle::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: 0 0 auto;
  border-radius: 999px;
  color: var(--accent-strong);
  background: #f1e8f8;
  font-size: 20px;
}

.settings-panel.open .settings-toggle::after {
  content: "-";
}

.settings-body {
  display: none;
  padding: 0 18px 18px;
}

.settings-panel.open .settings-body {
  display: grid;
  gap: 12px;
}

.setting-row {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 247, 236, 0.45);
}

.setting-row label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text-strong);
  font-weight: 700;
}

.fake-input {
  min-height: 38px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--muted);
  background: #fffdfa;
}

.switch {
  position: relative;
  width: 44px;
  height: 26px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: var(--sage);
}

.switch::after {
  position: absolute;
  top: 4px;
  left: 22px;
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #fffdfa;
  box-shadow: 0 2px 8px rgba(70, 49, 43, 0.16);
  content: "";
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  text-align: center;
}

.dream-topbar {
  align-items: center;
}

.topbar-title {
  min-width: 0;
  flex: 1;
}

.dream-new-button {
  min-width: 68px;
  min-height: 42px;
  padding-inline: 15px;
}

.dream-toolbar {
  margin-bottom: 16px;
}

.dream-list {
  display: grid;
  gap: 12px;
}

.dream-card {
  position: relative;
  display: grid;
  gap: 12px;
  overflow: hidden;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, rgba(255, 254, 255, 0.96), rgba(246, 240, 252, 0.86));
  box-shadow: var(--shadow-soft);
}

.dream-card.pinned {
  border-color: rgba(135, 108, 168, 0.28);
}

.dream-card header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.dream-card-meta,
.dream-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.dream-card h2 {
  margin: 0;
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  font-weight: 500;
  line-height: 1.25;
}

.dream-card-content {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--text);
  line-height: 1.72;
  white-space: pre-wrap;
  word-break: break-word;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.dream-mood {
  color: var(--accent-strong);
  font-weight: 700;
}

.dream-pin-button,
.dream-open-button {
  border: 0;
  color: var(--accent-strong);
  background: transparent;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.dream-pin-button {
  min-height: 30px;
  flex: 0 0 auto;
  padding: 0 4px;
}

.dream-open-button {
  justify-self: end;
  min-height: 36px;
  padding: 0 8px;
}

.dream-empty-state {
  display: grid;
  justify-items: center;
  gap: 15px;
  min-height: 220px;
  align-content: center;
  background: rgba(255, 253, 255, 0.52);
}

.dream-empty-state p {
  max-width: 420px;
  margin: 0;
  line-height: 1.7;
}

.dream-editor form {
  display: grid;
  gap: 14px;
}

.dream-time-note {
  margin: 0;
  padding: 10px 12px;
  border-radius: 14px;
  color: var(--muted);
  background: var(--rose);
  font-size: 12px;
}

.dream-time-note time {
  margin-left: 5px;
  color: var(--accent-strong);
  font-weight: 700;
}

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

.dream-detail-content {
  max-height: 45vh;
  overflow-y: auto;
  margin: 0;
  color: var(--text);
  font-size: 16px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
}

.dream-detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.dream-detail-actions .ghost-button,
.dream-detail-actions .text-button {
  width: 100%;
}

.scene-topbar {
  align-items: center;
}

.scene-new-button {
  min-width: 68px;
  min-height: 42px;
  padding-inline: 15px;
}

.scene-intro,
.scene-detail-description {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.75;
}

.scene-grid,
.scene-memory-list {
  display: grid;
  gap: 12px;
}

.scene-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px 14px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, rgba(255, 254, 255, 0.96), rgba(246, 240, 252, 0.86));
  box-shadow: var(--shadow-soft);
}

.scene-card.pinned {
  border-color: rgba(135, 108, 168, 0.3);
}

.scene-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 16px;
  color: var(--accent-strong);
  background: var(--rose);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
}

.scene-card-heading {
  min-width: 0;
}

.scene-card-heading h2,
.scene-detail-identity h1 {
  margin: 5px 0 0;
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  line-height: 1.2;
}

.scene-card-heading h2 {
  font-size: 23px;
}

.scene-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.scene-card-description {
  grid-column: 1 / -1;
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.scene-card-actions {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding-top: 11px;
  border-top: 1px solid var(--line);
}

.scene-card-actions .text-button {
  min-width: 0;
  padding-inline: 6px;
}

.scene-empty-state {
  display: grid;
  justify-items: center;
  gap: 15px;
  min-height: 250px;
  align-content: center;
  background: rgba(255, 253, 255, 0.54);
}

.scene-empty-state p {
  max-width: 420px;
  margin: 0;
  line-height: 1.7;
}

.scene-detail-header {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 14px;
}

.scene-detail-identity {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 12px;
}

.scene-detail-identity h1 {
  font-size: clamp(27px, 8vw, 42px);
}

.scene-detail-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

.scene-detail-actions .primary-pill,
.scene-detail-actions .ghost-button,
.scene-detail-actions .text-button {
  width: 100%;
}

.scene-detail-actions .text-button {
  grid-column: span 2;
}

.scene-memory-toolbar {
  grid-template-columns: 1fr;
}

.scene-sort-field {
  display: grid;
  gap: 8px;
}

.scene-sort-field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.scene-sort-field select {
  width: 100%;
  min-height: 46px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: none;
  color: var(--text);
  background: #fffdfa;
}

.scene-memory-card {
  display: grid;
  gap: 11px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: var(--shadow-soft);
}

.scene-memory-card header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.scene-memory-card h3 {
  margin: 5px 0 0;
  color: var(--text-strong);
  font-size: 18px;
}

.scene-memory-card time {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.scene-memory-summary {
  display: -webkit-box;
  overflow: hidden;
  margin: 0;
  color: var(--text);
  line-height: 1.7;
  white-space: pre-wrap;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.scene-memory-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.scene-editor form {
  display: grid;
  gap: 14px;
}

.scene-manager {
  display: grid;
  gap: 14px;
}

.scene-manager-list {
  display: grid;
  gap: 8px;
}

.scene-manager-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 13px;
  padding: 12px 0;
  border-top: 1px solid var(--line);
}

.scene-manager-row > div {
  min-width: 0;
}

.scene-manager-row strong,
.scene-manager-row small {
  display: block;
}

.scene-manager-row strong {
  overflow: hidden;
  color: var(--text-strong);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.scene-manager-row small {
  margin-top: 4px;
  color: var(--muted);
}

.scene-memory-detail {
  display: grid;
  gap: 15px;
}

.scene-memory-detail-content {
  max-height: 50vh;
  overflow-y: auto;
  margin: 0;
  color: var(--text);
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
}

.data-count-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}

.data-count-item {
  display: grid;
  gap: 5px;
  min-height: 92px;
  align-content: center;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 255, 0.82);
  box-shadow: var(--shadow-soft);
}

.data-count-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.data-count-item strong {
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 30px;
  font-weight: 500;
}

.data-stack {
  display: grid;
  gap: 14px;
}

.data-panel {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: var(--radius);
  background: rgba(255, 253, 255, 0.86);
  box-shadow: var(--shadow-soft);
}

.data-panel-header h2 {
  margin: 4px 0 0;
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 27px;
  font-weight: 500;
}

.data-panel > p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.data-panel .primary-pill {
  justify-self: start;
}

.data-safety-note {
  padding: 10px 12px;
  border-left: 3px solid var(--sage);
  color: var(--text) !important;
  background: rgba(238, 243, 236, 0.64);
  font-size: 13px;
}

.data-file-button {
  display: grid;
  place-items: center;
  min-height: 48px;
  padding: 0 16px;
  border: 1px dashed var(--accent-strong);
  border-radius: 15px;
  color: var(--accent-strong);
  background: rgba(243, 237, 249, 0.5);
  font-weight: 700;
  cursor: pointer;
}

.data-file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.import-preview {
  display: grid;
  gap: 15px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.import-preview[hidden] {
  display: none;
}

.import-preview-heading strong,
.import-preview-heading span {
  display: block;
}

.import-preview-heading strong {
  color: var(--text-strong);
  word-break: break-word;
}

.import-preview-heading span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

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

.import-count-grid span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.import-count-grid strong {
  color: var(--text-strong);
}

.import-mode {
  display: grid;
  gap: 9px;
  margin: 0;
  padding: 0;
  border: 0;
}

.import-mode legend {
  margin-bottom: 8px;
  color: var(--text-strong);
  font-size: 14px;
  font-weight: 700;
}

.import-mode p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(238, 243, 236, 0.6);
}

.segmented-control label {
  position: relative;
  cursor: pointer;
}

.segmented-control input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segmented-control span {
  display: grid;
  place-items: center;
  min-height: 38px;
  border-radius: 11px;
  color: var(--muted);
  font-weight: 700;
}

.segmented-control input:checked + span {
  color: var(--text-strong);
  background: #fff;
  box-shadow: 0 5px 14px rgba(85, 64, 106, 0.1);
}

.danger-zone {
  border-color: rgba(159, 79, 92, 0.16);
}

.clear-data-list {
  display: grid;
}

.clear-data-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.clear-data-row > span {
  min-width: 0;
}

.clear-data-row strong,
.clear-data-row small {
  display: block;
}

.clear-data-row strong {
  color: var(--text-strong);
  font-size: 14px;
}

.clear-data-row small {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.5;
}

.clear-data-row .text-button {
  flex: 0 0 auto;
}

.clear-all-row {
  margin-top: 4px;
  border-top-color: rgba(159, 79, 92, 0.28);
}

.data-operation {
  display: grid;
  gap: 7px;
  margin-top: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: rgba(255, 253, 255, 0.94);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.data-operation p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.data-operation progress {
  width: 100%;
  height: 5px;
  border: 0;
  accent-color: var(--accent-strong);
}

.data-operation[data-state="success"] p {
  color: #55705d;
}

.data-operation[data-state="error"] p {
  color: #9f4f5c;
}

.data-clear-confirm form {
  display: grid;
  gap: 14px;
}

.data-clear-confirm form > p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.data-clear-confirm code {
  display: block;
  padding: 12px 14px;
  border: 1px dashed rgba(159, 79, 92, 0.34);
  border-radius: 14px;
  color: #8e4350;
  background: rgba(249, 235, 239, 0.7);
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}

.data-clear-confirm .text-button {
  min-height: 46px;
}

.persona-topbar {
  align-items: center;
}

.persona-new-button {
  min-width: 68px;
  min-height: 42px;
  padding-inline: 15px;
}

.persona-intro {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.75;
}

.persona-grid {
  display: grid;
  gap: 12px;
}

.persona-card {
  display: grid;
  gap: 11px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.74);
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, rgba(255, 254, 255, 0.96), rgba(246, 240, 252, 0.86));
  box-shadow: var(--shadow-soft);
}

.persona-card.active {
  border-color: rgba(135, 108, 168, 0.34);
  box-shadow: 0 14px 32px rgba(108, 82, 137, 0.12);
}

.persona-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.persona-active-badge {
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--rose);
  font-weight: 700;
}

.persona-card h2,
.persona-editor-header h1,
.persona-section-heading h2 {
  margin: 0;
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 500;
  letter-spacing: 0;
}

.persona-card h2 {
  font-size: 23px;
}

.persona-card > p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.persona-card-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
}

.persona-card-actions .text-button {
  min-width: 0;
  padding-inline: 5px;
}

.persona-card-actions .muted,
.persona-card-actions button:disabled {
  color: var(--muted);
  cursor: default;
  opacity: 0.7;
}

.persona-empty-state {
  display: grid;
  min-height: 250px;
  align-content: center;
  justify-items: center;
  gap: 15px;
  background: rgba(255, 253, 255, 0.54);
}

.persona-empty-state p {
  max-width: 430px;
  margin: 0;
  line-height: 1.7;
}

.persona-editor-header {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 18px;
}

.persona-editor-header h1 {
  margin-top: 3px;
  font-size: 32px;
}

#persona-form,
.persona-sections {
  display: grid;
  gap: 14px;
}

.persona-basics,
.persona-section,
.persona-scenes,
.persona-preview {
  display: grid;
  gap: 15px;
  padding: 19px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 255, 0.84);
  box-shadow: var(--shadow-soft);
}

.persona-section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.persona-section-heading h2 {
  margin-top: 4px;
  font-size: 22px;
}

.persona-section-heading p,
.persona-scenes > p,
.persona-preview > p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.persona-section-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(246, 240, 252, 0.76);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.persona-section-toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent-strong);
}

.persona-field-grid {
  display: grid;
  gap: 13px;
  transition: opacity 160ms ease;
}

.persona-field-grid.disabled {
  opacity: 0.42;
}

.persona-field-grid .form-field small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.5;
}

.persona-range-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px;
  align-items: center;
  gap: 10px;
  min-height: 46px;
}

.persona-range-row input {
  width: 100%;
  accent-color: var(--accent-strong);
}

.persona-range-row output {
  display: grid;
  place-items: center;
  min-height: 36px;
  border-radius: 12px;
  color: var(--accent-strong);
  background: var(--rose);
  font-weight: 700;
}

.persona-scene-options {
  display: grid;
  gap: 8px;
}

.persona-scene-option {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(246, 240, 252, 0.48);
  cursor: pointer;
}

.persona-scene-option input {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--accent-strong);
}

.persona-scene-option strong,
.persona-scene-option small {
  display: block;
}

.persona-scene-option strong {
  color: var(--text-strong);
}

.persona-scene-option small,
.persona-scenes-empty {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.persona-preview pre {
  max-height: 420px;
  overflow: auto;
  margin: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: rgba(247, 243, 250, 0.76);
  font-family: "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  font-size: 13px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.persona-save-bar {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: var(--radius-sm);
  background: rgba(252, 249, 253, 0.94);
  box-shadow: 0 14px 36px rgba(84, 63, 105, 0.14);
  backdrop-filter: blur(14px);
}

.persona-save-bar > div {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.persona-save-bar button {
  width: 100%;
}

@media (min-width: 720px) {
  .app-shell {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr;
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    transform: none;
    box-shadow: none;
  }

  .drawer-backdrop,
  .menu-button {
    display: none;
  }

  .page {
    padding: 30px clamp(28px, 5vw, 56px) 46px;
  }

  .hero-panel {
    grid-template-columns: 1fr auto;
    align-items: end;
    padding: 32px;
  }

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

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

  .form-field:has(textarea),
  .checkbox-field {
    grid-column: span 2;
  }

  .settings-actions {
    grid-template-columns: auto auto 1fr;
    align-items: center;
  }

  .save-status {
    text-align: left;
  }

  .chat-shell {
    grid-template-columns: var(--sidebar-width) 1fr;
  }

  .chat-page {
    width: 100%;
    padding-top: 0;
  }

  .chat-header {
    padding: 22px 32px;
  }

  .chat-room {
    padding: 28px 32px;
  }

  .composer {
    padding: 16px 32px 20px;
  }

  .modal-layer {
    place-items: center;
    padding: 24px;
  }

  .modal-card {
    width: min(560px, 100%);
    padding: 24px;
    border-radius: var(--radius-sm);
  }

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

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

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

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

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

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

  .persona-wide-field {
    grid-column: span 2;
  }

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

  .persona-save-bar > div {
    grid-template-columns: auto auto;
  }

  .scene-detail-actions {
    grid-template-columns: auto auto auto;
    justify-content: start;
  }

  .scene-detail-actions .text-button {
    grid-column: auto;
  }

  .scene-memory-toolbar {
    grid-template-columns: minmax(0, 1fr) minmax(180px, 0.42fr);
    align-items: end;
  }

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

  .data-panel {
    padding: 24px;
  }

  .data-operation {
    position: sticky;
    bottom: 12px;
    z-index: 5;
  }
}

/* Reminders */
.reminders-page {
  max-width: 960px;
}

.reminders-topbar {
  align-items: center;
}

.reminders-new-button {
  min-width: 66px;
  min-height: 42px;
  margin-left: auto;
}

.notification-permission {
  display: grid;
  gap: 12px;
  margin-bottom: 15px;
  padding: 16px;
  border: 1px solid rgba(95, 125, 100, 0.18);
  border-radius: var(--radius-sm);
  background: rgba(237, 244, 234, 0.75);
}

.notification-permission strong {
  color: #55705d;
}

.notification-permission p {
  margin: 5px 0 0;
  color: #718078;
  font-size: 12px;
  line-height: 1.65;
}

.due-reminder-stack {
  display: grid;
  gap: 10px;
  margin-bottom: 15px;
}

.due-reminder-card {
  display: grid;
  gap: 15px;
  padding: 18px;
  border: 1px solid rgba(197, 141, 165, 0.3);
  border-left: 4px solid #c58da5;
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, rgba(255, 253, 255, 0.96), rgba(250, 240, 245, 0.88));
  box-shadow: var(--shadow-soft);
}

.due-reminder-card h2 {
  margin: 4px 0 0;
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 24px;
  font-weight: 500;
  letter-spacing: 0;
}

.due-reminder-card p:not(.eyebrow) {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.65;
}

.due-reminder-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.due-reminder-actions button {
  min-width: 0;
  min-height: 42px;
}

.reminder-toolbar {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 255, 0.68);
}

.reminder-groups {
  display: grid;
  gap: 15px;
}

.reminder-group {
  min-width: 0;
}

.reminder-group > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  padding-inline: 3px;
}

.reminder-group h2 {
  margin: 3px 0 0;
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 500;
  letter-spacing: 0;
}

.reminder-group > header > span {
  display: grid;
  min-width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 50%;
  color: var(--accent-strong);
  background: var(--rose);
  font-size: 12px;
  font-weight: 800;
}

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

.reminder-card {
  display: grid;
  gap: 11px;
  padding: 17px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 255, 0.88);
  box-shadow: var(--shadow-soft);
}

.reminder-card.overdue {
  border-color: rgba(197, 141, 165, 0.28);
}

.reminder-card.completed {
  background: rgba(241, 245, 239, 0.76);
  box-shadow: none;
}

.reminder-card.paused {
  opacity: 0.68;
}

.reminder-card-meta,
.reminder-tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.reminder-card-meta span,
.reminder-tag-row span {
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--muted);
  background: rgba(240, 233, 248, 0.72);
  font-size: 10px;
  font-weight: 700;
}

.reminder-card-meta .reminder-status.overdue {
  color: #8f5260;
  background: #f6e4e9;
}

.reminder-card-meta .reminder-status.completed {
  color: #55705d;
  background: #e8f0e6;
}

.reminder-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.reminder-card h3 {
  margin: 0;
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  font-weight: 500;
  letter-spacing: 0;
}

.reminder-card-content {
  margin: 0;
  color: var(--muted);
  line-height: 1.68;
  white-space: pre-wrap;
}

.reminder-card-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  padding-top: 7px;
  border-top: 1px solid var(--line);
}

.reminder-card-actions button {
  min-width: 0;
  padding-inline: 4px;
}

.reminder-empty {
  margin: 0;
  padding: 20px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 253, 255, 0.42);
  text-align: center;
}

.reminder-editor-dialog form,
.reminder-delete-options {
  display: grid;
  gap: 12px;
}

.reminder-time-grid {
  display: grid;
  gap: 12px;
}

.reminder-delete-dialog > p {
  margin: -5px 0 14px;
  color: var(--muted);
  line-height: 1.65;
}

.reminder-delete-options button {
  min-height: 46px;
}

@media (min-width: 720px) {
  .notification-permission {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .reminder-toolbar,
  .reminder-time-grid {
    grid-template-columns: minmax(0, 1fr) minmax(180px, 0.4fr);
    align-items: end;
  }

  .reminder-groups {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .due-reminder-card {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.6fr);
    align-items: center;
  }

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

  .reminder-editor-dialog,
  .reminder-delete-dialog {
    width: min(650px, 100%);
  }
}

/* Private cycle records */
.cycle-calendar,
.cycle-daily-panel {
  margin-bottom: 15px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 255, 0.76);
  box-shadow: var(--shadow-soft);
}

.cycle-calendar-header,
.cycle-daily-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.cycle-calendar-header {
  text-align: center;
}

.cycle-calendar-header h2,
.cycle-daily-heading h2,
.cycle-settings-section h3 {
  margin: 3px 0 0;
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", "Noto Serif TC", serif;
  font-weight: 500;
  letter-spacing: 0;
}

.cycle-calendar-header h2,
.cycle-daily-heading h2 {
  font-size: 23px;
}

.cycle-weekdays,
.cycle-month-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 3px;
}

.cycle-weekdays {
  margin-top: 16px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-align: center;
}

.cycle-month-grid {
  margin-top: 6px;
}

.cycle-day,
.cycle-day-blank {
  position: relative;
  display: grid;
  width: 100%;
  min-width: 0;
  aspect-ratio: 1 / 1;
  place-items: center;
}

.cycle-day {
  border: 1px solid transparent;
  border-radius: 12px;
  color: var(--text);
  background: transparent;
  font-size: 13px;
  cursor: pointer;
}

.cycle-day:hover,
.cycle-day.selected {
  color: var(--accent-strong);
  background: var(--rose);
}

.cycle-day.selected {
  border-color: rgba(135, 108, 168, 0.3);
  font-weight: 800;
}

.cycle-day.estimated::before {
  position: absolute;
  inset: 4px;
  border: 1px dashed rgba(135, 108, 168, 0.34);
  border-radius: 10px;
  content: "";
  pointer-events: none;
}

.cycle-day i,
.cycle-calendar-legend i {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.cycle-day i {
  position: absolute;
  bottom: 4px;
}

.period-dot {
  background: #c58da5;
}

.spotting-dot {
  background: #b7a0c9;
}

.cycle-calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 10px;
}

.cycle-calendar-legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.cycle-calendar-legend .estimate-ring {
  border: 1px dashed rgba(135, 108, 168, 0.55);
  background: transparent;
}

.cycle-privacy-copy {
  margin: 10px 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.cycle-daily-summary,
.cycle-estimate,
.cycle-reminder {
  padding: 14px;
  border-radius: 14px;
}

.cycle-daily-summary {
  border: 1px solid var(--line);
  background: rgba(246, 240, 252, 0.58);
}

.cycle-daily-summary strong,
.cycle-estimate strong,
.cycle-reminder strong {
  color: var(--text-strong);
}

.cycle-daily-summary p,
.cycle-estimate p {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

.cycle-estimate {
  margin-top: 10px;
  border: 1px solid rgba(135, 108, 168, 0.15);
  background: rgba(255, 249, 239, 0.72);
}

.cycle-estimate small,
.cycle-reminder small {
  display: block;
  margin-top: 7px;
  color: #8f6571;
  line-height: 1.55;
}

.cycle-reminder {
  display: grid;
  gap: 2px;
  margin-top: 10px;
  border-left: 3px solid var(--sage);
  background: rgba(237, 244, 234, 0.85);
}

.cycle-daily-panel > .primary-pill {
  width: 100%;
  min-height: 46px;
  margin-top: 12px;
}

.cycle-source-option {
  border-color: rgba(197, 141, 165, 0.23);
  background: rgba(250, 240, 245, 0.65);
}

.calendar-reminder-panel {
  display: grid;
  gap: 11px;
  margin-bottom: 15px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 255, 0.76);
  box-shadow: var(--shadow-soft);
}

.calendar-reminder-panel > header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.calendar-reminder-panel h2 {
  margin: 3px 0 0;
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 23px;
  font-weight: 500;
  letter-spacing: 0;
}

.calendar-reminder-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.calendar-reminder-counts span {
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--rose);
  font-size: 11px;
  font-weight: 700;
}

.calendar-reminder-counts .completed {
  color: #55705d;
  background: #e8f0e6;
}

.calendar-reminder-counts .overdue {
  color: #8f5260;
  background: #f6e4e9;
}

.calendar-reminder-list {
  display: grid;
  gap: 7px;
}

.calendar-reminder-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.58);
}

.calendar-reminder-item p,
.calendar-reminder-empty {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.calendar-reminder-item > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.calendar-reminder-item.completed > span {
  color: #55705d;
}

.calendar-reminder-item.overdue > span,
.calendar-reminder-empty.error {
  color: #8f5260;
}

.cycle-modal-privacy,
.cycle-medical-note {
  padding: 12px 14px;
  color: #765b68;
  background: rgba(250, 240, 245, 0.68);
  font-size: 12px;
  line-height: 1.65;
}

.cycle-record-dialog form,
.cycle-settings-dialog form,
.cycle-settings-toggles {
  display: grid;
  gap: 12px;
}

.cycle-choice-group {
  margin: 0;
  padding: 0;
  border: 0;
}

.cycle-choice-group legend {
  margin-bottom: 7px;
  color: var(--text-strong);
  font-size: 13px;
  font-weight: 700;
}

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

.cycle-record-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.cycle-record-actions .danger:not([hidden]) {
  grid-column: 1 / -1;
}

.cycle-settings-section {
  display: grid;
  gap: 11px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--line);
}

.cycle-settings-section h3 {
  font-size: 20px;
}

.cycle-settings-section > p {
  margin: -5px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
}

@media (min-width: 720px) {
  .cycle-calendar,
  .cycle-daily-panel {
    padding: 22px;
  }

  .cycle-calendar {
    max-width: 650px;
  }

  .cycle-day {
    max-height: 58px;
  }

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

  .cycle-record-dialog,
  .cycle-settings-dialog {
    width: min(620px, 100%);
  }
}

/* Calendar and companion diary */
.calendar-page {
  max-width: 920px;
}

.diary-day-header {
  display: grid;
  gap: 18px;
  padding: 20px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 253, 255, 0.38);
}

.diary-day-header h2,
.diary-entry h2,
.diary-empty-state h2,
.diary-version-card h3 {
  margin: 4px 0 0;
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", "Noto Serif TC", serif;
  font-weight: 500;
  letter-spacing: 0;
}

.diary-day-header h2 {
  font-size: 29px;
}

.diary-day-header p:not(.eyebrow) {
  max-width: 620px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.diary-date-field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.diary-date-field input {
  min-height: 45px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 13px;
  color: var(--text);
  background: var(--card-solid);
}

.diary-day-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  margin: 16px 0 10px;
}

.diary-day-actions button {
  min-height: 46px;
}

.diary-entry-list {
  display: grid;
  gap: 13px;
}

.diary-entry {
  display: grid;
  gap: 14px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: var(--radius-sm);
  background: linear-gradient(145deg, rgba(255, 254, 255, 0.96), rgba(246, 240, 252, 0.82));
  box-shadow: var(--shadow-soft);
}

.diary-entry.locked {
  border-color: rgba(135, 108, 168, 0.28);
}

.diary-entry-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.diary-entry h2 {
  font-size: 24px;
}

.diary-entry-meta,
.diary-tag-row,
.diary-source-summary-items {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.diary-entry-meta span,
.diary-tag-row span,
#diary-source-summary-items span {
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--rose);
  font-size: 11px;
  font-weight: 700;
}

.diary-entry-meta .diary-lock-badge {
  color: #8f5260;
  background: #f6e4e9;
}

.diary-entry-content {
  color: var(--text);
  line-height: 1.85;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.diary-entry-sources,
.diary-draft-sources {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
  color: var(--muted);
  font-size: 12px;
}

.diary-entry-sources summary,
.diary-draft-sources summary {
  color: var(--accent-strong);
  font-weight: 700;
  cursor: pointer;
}

.diary-source-detail-list {
  margin-top: 10px;
}

.diary-source-detail-list p {
  margin: 5px 0;
  line-height: 1.6;
}

.diary-source-detail-list small {
  display: block;
  margin-top: 8px;
  color: #8f5260;
}

.diary-entry-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.diary-entry-actions button {
  min-width: 0;
  padding-inline: 4px;
}

.diary-empty-state {
  grid-column: 1 / -1;
  display: grid;
  min-height: 300px;
  place-content: center;
  gap: 10px;
  padding: 30px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 255, 0.5);
  text-align: center;
}

.diary-empty-state h2 {
  font-size: 25px;
}

.diary-empty-state p:not(.eyebrow) {
  max-width: 430px;
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.diary-modal-intro {
  margin: -5px 0 15px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
}

.diary-source-options,
.diary-editor-dialog form,
.diary-version-list {
  display: grid;
  gap: 11px;
}

.diary-scene-picker {
  margin: 15px 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 15px;
}

.diary-scene-picker legend {
  padding: 0 7px;
  color: var(--text-strong);
  font-weight: 700;
}

#diary-scene-options {
  display: grid;
  gap: 8px;
}

.diary-scene-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(246, 240, 252, 0.74);
}

.diary-scene-option input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-strong);
}

.diary-scene-option span {
  display: grid;
  gap: 2px;
}

.diary-scene-option small,
.diary-scenes-empty {
  color: var(--muted);
}

.diary-privacy-note,
.diary-generated-notice {
  padding: 12px 14px;
  border-left: 3px solid var(--accent);
  color: #715f82;
  background: rgba(240, 233, 248, 0.72);
  font-size: 12px;
  line-height: 1.7;
}

.diary-source-summary {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid rgba(95, 125, 100, 0.18);
  border-radius: 14px;
  color: #55705d;
  background: rgba(237, 244, 234, 0.82);
}

#diary-source-summary-items {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 9px;
}

#diary-source-summary-items span {
  color: #55705d;
  background: rgba(255, 255, 255, 0.7);
}

#diary-source-summary-items .muted {
  line-height: 1.5;
  white-space: normal;
}

.diary-source-actions {
  margin-top: 12px;
}

.diary-meta-grid {
  display: grid;
  gap: 12px;
}

.diary-editor-dialog textarea {
  min-height: 230px;
  line-height: 1.75;
}

.diary-version-card {
  display: grid;
  gap: 9px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(246, 240, 252, 0.62);
}

.diary-version-card h3 {
  font-size: 20px;
}

.diary-version-card > p:not(.eyebrow) {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  line-height: 1.65;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 5;
}

.diary-loading {
  color: var(--muted);
  text-align: center;
}

@media (min-width: 720px) {
  .diary-day-header {
    grid-template-columns: minmax(0, 1fr) 180px;
    align-items: end;
    padding: 24px;
  }

  .diary-day-actions {
    grid-template-columns: auto auto;
    justify-content: start;
  }

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

  .diary-meta-grid,
  #diary-scene-options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .diary-source-dialog,
  .diary-editor-dialog,
  .diary-versions-dialog {
    width: min(680px, 100%);
  }
}

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

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

/* User profile */
.user-profile-page {
  max-width: 920px;
}

.profile-intro {
  max-width: 680px;
  margin: -6px 0 18px;
  color: var(--muted);
  line-height: 1.75;
}

.profile-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-bottom: 16px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 255, 0.62);
}

.profile-tabs button {
  min-width: 0;
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  background: transparent;
  font-weight: 700;
  cursor: pointer;
}

.profile-tabs button[aria-selected="true"] {
  color: var(--accent-strong);
  background: var(--card-solid);
  box-shadow: 0 5px 16px rgba(85, 64, 106, 0.1);
}

.profile-section-list,
#user-profile-form,
.timeline-list {
  display: grid;
  gap: 13px;
}

.user-profile-section,
.profile-preview,
.photo-safety-note,
.photo-upload-form,
.life-event-card {
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: var(--radius-sm);
  background: rgba(255, 253, 255, 0.86);
  box-shadow: var(--shadow-soft);
}

.profile-section-heading,
.profile-view-header,
.life-event-card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.profile-section-heading h2,
.profile-view-header h2,
.life-event-card h3,
.profile-empty-state h3 {
  margin: 0;
  color: var(--text-strong);
  font-family: Georgia, "Times New Roman", "Noto Serif TC", serif;
  font-weight: 500;
  letter-spacing: 0;
}

.profile-section-heading h2 {
  font-size: 21px;
}

.profile-section-heading p,
.profile-preview > p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.profile-section-toggle {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: var(--rose);
  font-size: 12px;
  font-weight: 700;
}

.profile-section-toggle input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent-strong);
}

.user-profile-section textarea {
  width: 100%;
  margin-top: 14px;
  padding: 13px 14px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: 0;
  color: var(--text);
  background: rgba(255, 255, 255, 0.72);
  line-height: 1.7;
}

.user-profile-section textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(198, 176, 226, 0.2);
}

.user-profile-section.disabled textarea {
  opacity: 0.45;
}

.profile-preview {
  display: grid;
  gap: 12px;
  background: linear-gradient(145deg, rgba(255, 254, 255, 0.95), rgba(240, 233, 248, 0.88));
}

.profile-preview pre {
  max-height: 420px;
  margin: 0;
  padding: 16px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.62);
  font: 14px/1.75 "Noto Sans TC", "Microsoft JhengHei", sans-serif;
}

.profile-save-bar {
  display: grid;
  gap: 8px;
  padding: 5px 2px calc(4px + env(safe-area-inset-bottom));
}

.profile-save-bar .primary-pill {
  min-height: 48px;
}

.profile-view-header {
  align-items: center;
  margin: 8px 0 14px;
}

.profile-view-header h2 {
  margin-top: 4px;
  font-size: 28px;
}

.timeline-toolbar {
  margin-bottom: 12px;
}

.life-event-card {
  display: grid;
  gap: 11px;
}

.life-event-period,
.life-event-meta {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.life-event-card h3 {
  margin-top: 4px;
  font-size: 21px;
}

.life-event-content {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  line-height: 1.7;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
}

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

.profile-tag-row span {
  padding: 4px 9px;
  border-radius: 999px;
  color: var(--accent-strong);
  background: var(--rose);
  font-size: 11px;
  font-weight: 700;
}

.profile-tag-row .privacy-badge,
.profile-tag-row .preview-excluded {
  color: #8f5260;
  background: #f6e4e9;
}

.profile-tag-row .preview-included {
  color: #55705d;
  background: #e8f0e6;
}

.profile-empty-state {
  grid-column: 1 / -1;
  display: grid;
  min-height: 220px;
  place-content: center;
  gap: 9px;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: rgba(255, 253, 255, 0.54);
  text-align: center;
}

.profile-empty-state p {
  max-width: 380px;
  margin: 0;
  line-height: 1.7;
}

.life-event-editor form,
.life-event-permissions,
.photo-upload-form,
.photo-editor form {
  display: grid;
  gap: 13px;
}

.life-event-range-grid {
  display: grid;
  gap: 12px;
}

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

.profile-range-row input {
  width: 100%;
  accent-color: var(--accent-strong);
}

.profile-range-row output {
  color: var(--accent-strong);
  font-weight: 700;
  text-align: right;
}

.photo-safety-note {
  margin-bottom: 13px;
  border-color: rgba(95, 125, 100, 0.18);
  color: #55705d;
  background: rgba(237, 244, 234, 0.86);
}

.photo-safety-note p {
  margin: 7px 0 0;
  font-size: 13px;
  line-height: 1.7;
}

.photo-upload-form {
  margin-bottom: 12px;
}

.user-photo-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.user-photo-card {
  min-width: 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 16px;
  color: var(--text);
  background: var(--card-solid);
  box-shadow: var(--shadow-soft);
  text-align: left;
  cursor: pointer;
}

.user-photo-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--rose);
}

.user-photo-copy {
  display: grid;
  gap: 4px;
  padding: 11px;
}

.user-photo-copy strong,
.user-photo-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-photo-copy small {
  color: var(--muted);
  font-size: 11px;
}

.photo-editor img {
  display: block;
  width: min(100%, 420px);
  max-height: 45vh;
  margin: 0 auto 14px;
  object-fit: contain;
  border-radius: 14px;
  background: var(--rose);
}

.photo-editor-actions {
  display: grid;
  gap: 8px;
}

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

  .profile-preview,
  .profile-save-bar {
    grid-column: 1 / -1;
  }

  .timeline-list,
  .user-photo-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .life-event-range-grid,
  .photo-editor-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .photo-editor-actions .primary-pill {
    grid-column: 1 / -1;
  }

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

/* Tools & MCP */
.tools-mcp-page {
  display: grid;
  gap: 22px;
  padding-bottom: calc(42px + env(safe-area-inset-bottom));
}

.tools-mcp-intro {
  max-width: 760px;
  margin: -8px 0 0;
  color: var(--muted);
  line-height: 1.8;
}

.tools-mcp-status {
  min-height: 22px;
  margin: -8px 0 0;
}

.mcp-section {
  display: grid;
  gap: 15px;
  min-width: 0;
  padding: 4px 0 25px;
  border-bottom: 1px solid rgba(116, 92, 137, 0.13);
}

.mcp-section h2,
.mcp-server-card h3,
.mcp-tool-card h3 {
  margin: 0;
}

.mcp-summary-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mcp-summary-item {
  display: grid;
  gap: 8px;
  min-height: 96px;
  padding: 16px;
  border: 1px solid rgba(129, 102, 151, 0.13);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 9px 28px rgba(87, 65, 107, 0.06);
}

.mcp-summary-item span {
  color: var(--muted);
  font-size: 12px;
}

.mcp-summary-item strong {
  align-self: end;
  color: var(--accent-deep);
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 500;
}

.mcp-heading-actions,
.mcp-card-actions,
.mcp-tool-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.mcp-server-list,
.mcp-tool-list,
.mcp-permission-list,
.mcp-call-list,
.notion-scope-list,
.notion-activity-list {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.mcp-tools-content {
  display: grid;
  gap: 12px;
}

.mcp-tools-content[hidden] {
  display: none;
}

.mcp-server-card,
.mcp-tool-card,
.mcp-call-card,
.notion-scope-card {
  display: grid;
  gap: 13px;
  min-width: 0;
  padding: 17px;
  border: 1px solid rgba(129, 102, 151, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 10px 30px rgba(87, 65, 107, 0.06);
}

.mcp-server-card > header,
.mcp-tool-card > header,
.mcp-call-card > header,
.notion-scope-card > header {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  justify-content: space-between;
}

.mcp-server-card > header > div,
.mcp-tool-card > header > div,
.mcp-call-card > header > div,
.notion-scope-card > header > div {
  min-width: 0;
}

.mcp-server-card header p,
.mcp-tool-card header p,
.mcp-call-card p,
.mcp-tool-card > p,
.notion-scope-card header p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.mcp-call-card p {
  overflow-wrap: anywhere;
}

.mcp-status-badge,
.mcp-risk-badge,
.mcp-call-status {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.notion-mode-badge {
  flex: 0 0 auto;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
}

.notion-mode-badge.mode-autonomous_scoped {
  color: #496d5d;
  background: #e1efe8;
}

.notion-mode-badge.mode-session {
  color: #6b5689;
  background: #eee7f7;
}

.notion-mode-badge.mode-ask {
  color: #80672f;
  background: #f6efd9;
}

.notion-mode-badge.mode-deny {
  color: #92575d;
  background: #f7e4e6;
}

.mcp-status-badge.connected,
.mcp-call-status.completed,
.mcp-call-status.succeeded {
  color: #3f6d58;
  background: #e2f0e8;
}

.mcp-status-badge.connecting,
.mcp-call-status.pending,
.mcp-call-status.running {
  color: #6d5790;
  background: #eee7f8;
}

.mcp-status-badge.disconnected,
.mcp-call-status.cancelled,
.mcp-call-status.denied {
  color: #6f6875;
  background: #efedf0;
}

.mcp-status-badge.error,
.mcp-call-status.failed,
.mcp-call-status.timeout {
  color: #98595e;
  background: #f8e5e6;
}

.mcp-risk-badge.risk-read {
  color: #477064;
  background: #e4f1eb;
}

.mcp-risk-badge.risk-write {
  color: #886928;
  background: #f7efd9;
}

.mcp-risk-badge.risk-destructive {
  color: #97575c;
  background: #f8e4e5;
}

.mcp-risk-badge.risk-unknown {
  color: #695b78;
  background: #ede8f2;
}

.mcp-server-meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 7px 14px;
  margin: 0;
  font-size: 12px;
}

.mcp-server-meta dt {
  color: var(--muted);
}

.mcp-server-meta dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.mcp-server-flags,
.mcp-tool-state {
  margin: 0;
  color: var(--accent-deep);
  font-size: 12px;
}

.mcp-tool-card details {
  border-top: 1px solid rgba(129, 102, 151, 0.12);
  padding-top: 11px;
}

.mcp-tool-card summary {
  color: var(--accent-deep);
  cursor: pointer;
  font-size: 12px;
}

.mcp-tool-card pre,
.mcp-test-card pre,
.tool-permission-card pre {
  max-height: 260px;
  margin: 10px 0 0;
  padding: 12px;
  overflow: auto;
  border-radius: 8px;
  color: var(--text);
  background: rgba(238, 232, 244, 0.64);
  font: 12px/1.65 ui-monospace, SFMono-Regular, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.mcp-inline-control {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.mcp-tool-controls select,
.mcp-permission-row select,
.notion-scope-editor select {
  min-height: 38px;
  padding: 7px 30px 7px 10px;
  border: 1px solid rgba(129, 102, 151, 0.2);
  border-radius: 8px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.84);
}

.mcp-permission-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid rgba(129, 102, 151, 0.1);
}

.mcp-permission-row:last-child {
  border-bottom: 0;
}

.mcp-permission-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.notion-autonomy-section {
  gap: 18px;
}

.notion-scope-card h3,
.notion-autonomy-toolbar h3 {
  margin: 0;
}

.notion-scope-target,
.notion-capability-summary {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.notion-capability-summary {
  color: var(--accent-deep);
}

.notion-autonomy-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding-top: 5px;
}

.notion-activity-card {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  padding: 13px 15px;
  border: 1px solid rgba(129, 102, 151, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.64);
}

.notion-activity-card > div {
  min-width: 0;
}

.notion-activity-card strong,
.notion-activity-card small {
  display: block;
  overflow-wrap: anywhere;
}

.notion-activity-card small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

.notion-activity-card.status-undone {
  opacity: 0.65;
}

.notion-scope-editor {
  width: min(calc(100vw - 24px), 720px);
}

.notion-capability-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 9px;
  margin: 14px 0;
}

.mcp-future-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 9px 18px;
  padding: 14px 0;
  color: var(--muted);
  font-size: 12px;
}

.mcp-future-row strong {
  color: var(--accent-deep);
  font-weight: 600;
}

.mcp-empty-state {
  padding: 28px 10px;
  border-block: 1px dashed rgba(129, 102, 151, 0.22);
  color: var(--muted);
  text-align: center;
  line-height: 1.75;
}

.mcp-security {
  border-bottom: 0;
  padding: 18px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: rgba(239, 235, 245, 0.65);
}

.mcp-security p {
  margin: 0;
  line-height: 1.8;
}

.mcp-editor-card,
.mcp-test-card {
  width: min(calc(100vw - 24px), 680px);
}

.mcp-test-card {
  width: min(calc(100vw - 24px), 760px);
}

.mcp-test-confirm,
.mcp-test-result,
.mcp-test-context {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.mcp-test-confirm[hidden],
.mcp-test-result[hidden] {
  display: none;
}

.tool-permission-card,
.chat-tool-permission {
  width: min(100%, 700px);
  padding: 16px;
  border: 1px solid rgba(126, 96, 153, 0.2);
  border-radius: var(--radius-sm);
  background: rgba(247, 243, 251, 0.96);
  box-shadow: 0 12px 34px rgba(82, 59, 104, 0.08);
}

.tool-permission-card h3,
.tool-permission-card p,
.chat-tool-permission h3,
.chat-tool-permission p {
  margin: 0 0 8px;
}

.tool-permission-card p,
.chat-tool-permission p {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.tool-permission-actions,
.chat-tool-permission-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
}

.chat-tool-permission-heading {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-bottom: 13px;
}

.chat-tool-permission-heading .mcp-risk-badge {
  color: #695b78;
  background: #ede8f2;
}

.chat-tool-permission.risk-read .mcp-risk-badge {
  color: #477064;
  background: #e4f1eb;
}

.chat-tool-permission.risk-write .mcp-risk-badge {
  color: #886928;
  background: #f7efd9;
}

.chat-tool-permission.risk-destructive .mcp-risk-badge {
  color: #97575c;
  background: #f8e4e5;
}

.chat-tool-permission-meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 7px 12px;
  margin: 0 0 13px;
  font-size: 12px;
}

.chat-tool-permission-meta dt {
  color: var(--muted);
}

.chat-tool-permission-meta dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.chat-tool-policy-note {
  padding: 10px 12px;
  border-left: 3px solid rgba(135, 108, 168, 0.42);
  border-radius: 0 8px 8px 0;
  background: rgba(239, 233, 247, 0.68);
}

.chat-autonomous-notice {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  width: min(100%, 700px);
  padding: 13px 15px;
  border: 1px solid rgba(91, 128, 106, 0.18);
  border-radius: 8px;
  color: #4f6758;
  background: rgba(230, 241, 233, 0.86);
}

.chat-autonomous-notice p {
  margin: 4px 0 0;
  font-size: 12px;
  line-height: 1.6;
}

.chat-autonomous-notice a {
  flex: 0 0 auto;
  color: #4f6758;
  font-size: 12px;
  font-weight: 700;
}

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

  .mcp-permission-row {
    grid-template-columns: minmax(220px, 1fr) 180px auto;
  }

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

@media (max-width: 620px) {
  .mcp-summary-item {
    min-height: 84px;
    padding: 14px;
  }

  .mcp-summary-item strong {
    font-size: 26px;
  }

  .mcp-heading-actions,
  .mcp-heading-actions > button,
  .mcp-tool-controls,
  .mcp-tool-controls > button,
  .mcp-tool-controls > select {
    width: 100%;
  }

  .mcp-card-actions > button,
  .tool-permission-actions > button,
  .chat-tool-permission-actions > button {
    flex: 1 1 130px;
  }

  .mcp-server-card > header,
  .mcp-tool-card > header,
  .notion-scope-card > header {
    align-items: flex-start;
  }

  .notion-autonomy-toolbar,
  .notion-activity-card {
    align-items: stretch;
  }

  .notion-autonomy-toolbar {
    flex-direction: column;
  }

  .notion-autonomy-toolbar > button,
  .notion-activity-card > a {
    width: 100%;
    text-align: center;
  }

  .notion-activity-card {
    flex-direction: column;
  }

  .chat-autonomous-notice {
    align-items: flex-start;
    flex-direction: column;
  }
}
/* Authentication */
.login-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(24px, env(safe-area-inset-top)) 20px max(24px, env(safe-area-inset-bottom));
  background:
    linear-gradient(rgba(247, 242, 251, 0.82), rgba(251, 248, 255, 0.94)),
    var(--bg);
}

.login-shell {
  width: min(100%, 440px);
}

.login-panel {
  padding: 34px 26px 30px;
  border: 1px solid rgba(133, 104, 159, 0.16);
  border-radius: min(var(--radius, 26px), 28px);
  background: rgba(255, 253, 255, 0.94);
  box-shadow: 0 22px 60px rgba(75, 55, 91, 0.13);
}

.login-mark {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 22px;
  border-radius: 50%;
  background: #e7ddf4;
  color: #654d78;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
}

.login-panel h1 {
  margin: 8px 0 10px;
  font-size: 2rem;
  line-height: 1.18;
}

.login-copy {
  margin: 0 0 26px;
  color: var(--muted);
  line-height: 1.7;
}

.login-form {
  display: grid;
  gap: 17px;
}

.login-form label {
  display: grid;
  gap: 8px;
  color: var(--text);
  font-size: 0.92rem;
}

.login-form input {
  width: 100%;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid rgba(119, 91, 141, 0.2);
  border-radius: 12px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.login-form input:focus {
  border-color: var(--accent-strong);
  outline: 3px solid rgba(135, 108, 168, 0.12);
}

.login-submit {
  min-height: 48px;
  margin-top: 4px;
}

.form-status {
  min-height: 1.4em;
  margin: 0;
  color: #985c6e;
  font-size: 0.9rem;
}

.nav-footer {
  margin-top: auto;
  padding-top: 16px;
}

.nav-logout {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(119, 91, 141, 0.14);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  cursor: pointer;
}

.nav-logout:hover {
  background: rgba(231, 221, 244, 0.5);
  color: var(--text);
}
