:root {
  color-scheme: light dark;
  --color-bg: #f2f4f1;
  --color-surface: #f8faf7;
  --color-surface-strong: #ffffff;
  --color-text: #27302e;
  --color-text-secondary: #6f7974;
  --color-text-faint: #89928e;
  --color-line: rgba(39, 48, 46, 0.13);
  --color-fog-light: #dce9e9;
  --color-fog: #ccdeda;
  --color-sage: #91b3a8;
  --color-sage-deep: #759b91;
  --color-warm: #ddc0ae;
  --color-primary: #2f514c;
  --color-primary-strong: #25433f;
  --color-primary-soft: #e1ece8;
  --color-danger: #995b4b;
  --color-danger-soft: #f1e2dc;
  --shadow-soft: 0 18px 50px rgba(47, 81, 76, 0.08);
  --shadow-float: 0 16px 36px rgba(37, 67, 63, 0.2);
  --radius-control: 13px;
  --radius-section: 22px;
  --radius-landscape: 28px;
  --motion-fast: 160ms;
  --motion-base: 210ms;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-bg: #151c1a;
    --color-surface: #1d2724;
    --color-surface-strong: #24302d;
    --color-text: #e8eeeb;
    --color-text-secondary: #aab5b0;
    --color-text-faint: #82908a;
    --color-line: rgba(226, 236, 231, 0.13);
    --color-fog-light: #293b39;
    --color-fog: #213431;
    --color-sage: #6f968b;
    --color-sage-deep: #97bdb3;
    --color-warm: #8f7467;
    --color-primary: #9bc1b7;
    --color-primary-strong: #b8d7cf;
    --color-primary-soft: #273d38;
    --color-danger: #e1a08e;
    --color-danger-soft: #422e29;
    --shadow-soft: 0 20px 54px rgba(0, 0, 0, 0.24);
    --shadow-float: 0 18px 38px rgba(0, 0, 0, 0.36);
  }
}

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

html {
  min-height: 100%;
  background: var(--color-bg);
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body[data-current-view="today"] {
  background:
    radial-gradient(circle at 84% 4%, color-mix(in srgb, var(--color-fog) 72%, transparent), transparent 24rem),
    linear-gradient(180deg, color-mix(in srgb, var(--color-fog-light) 58%, var(--color-bg)) 0, var(--color-bg) 23rem);
}

button, input, textarea, select { font: inherit; }
button { color: inherit; touch-action: manipulation; }
button, a, input, textarea, select { -webkit-tap-highlight-color: transparent; }
textarea { resize: vertical; }
[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--color-sage-deep) 64%, transparent);
  outline-offset: 3px;
}

.offline-banner {
  position: fixed;
  inset: 0 0 auto;
  z-index: 90;
  padding: calc(8px + var(--safe-top)) 16px 8px;
  border-bottom: 1px solid var(--color-line);
  background: color-mix(in srgb, var(--color-warm) 58%, var(--color-bg));
  color: var(--color-text);
  font-size: 13px;
  font-weight: 650;
  text-align: center;
}

.offline-banner:not([hidden]) ~ .app-shell { padding-top: calc(60px + var(--safe-top)); }

.app-shell {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: calc(22px + var(--safe-top)) 20px calc(186px + var(--safe-bottom));
}

.top-bar {
  position: relative;
  z-index: 4;
  display: flex;
  min-height: 72px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 3px 12px;
}

.eyebrow, .section-kicker {
  margin: 0 0 4px;
  color: var(--color-text-secondary);
  font-size: 11px;
  font-weight: 760;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}

.top-bar h1 {
  margin: 0;
  font-size: clamp(30px, 8vw, 39px);
  font-weight: 740;
  line-height: 1.08;
  letter-spacing: -0.045em;
}

body:not([data-current-view="today"]) .top-bar h1 { font-size: 34px; }

.icon-button {
  display: inline-grid;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  place-items: center;
  padding: 0;
  border: 1px solid var(--color-line);
  border-radius: 50%;
  background: color-mix(in srgb, var(--color-surface) 48%, transparent);
  cursor: pointer;
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  transition: background var(--motion-fast) ease, transform var(--motion-fast) ease;
}

.icon-button:active { transform: scale(0.96); }

.line-icon {
  position: relative;
  display: inline-block;
  width: 22px;
  height: 22px;
  color: currentColor;
}

.icon-plus::before, .icon-plus::after, .icon-close::before, .icon-close::after {
  position: absolute;
  top: 10px;
  left: 4px;
  width: 14px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
}
.icon-plus::after { transform: rotate(90deg); }
.icon-close::before { transform: rotate(45deg); }
.icon-close::after { transform: rotate(-45deg); }

.icon-settings::before {
  position: absolute;
  inset: 4px;
  border: 2px solid currentColor;
  border-radius: 50%;
  content: "";
}
.icon-settings::after {
  position: absolute;
  inset: 8px;
  border: 2px solid currentColor;
  border-radius: 50%;
  content: "";
}

.icon-today::before {
  position: absolute;
  inset: 3px;
  border: 2px solid currentColor;
  border-radius: 50%;
  content: "";
}
.icon-today::after {
  position: absolute;
  left: 7px;
  bottom: 6px;
  width: 9px;
  height: 5px;
  border-radius: 50% 50% 30% 30%;
  background: currentColor;
  content: "";
  opacity: 0.72;
}

.icon-inbox::before {
  position: absolute;
  inset: 4px 3px 3px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 5px 5px;
  content: "";
}
.icon-inbox::after {
  position: absolute;
  top: 4px;
  left: 7px;
  width: 8px;
  height: 8px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: rotate(45deg);
}

.icon-review::before {
  position: absolute;
  left: 3px;
  bottom: 4px;
  width: 3px;
  height: 7px;
  border-radius: 2px 2px 0 0;
  background: currentColor;
  box-shadow: 6px -4px 0 currentColor, 12px -9px 0 currentColor;
  content: "";
}
.icon-review::after {
  position: absolute;
  right: 2px;
  bottom: 3px;
  left: 2px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  content: "";
  opacity: 0.56;
}

.sync-strip {
  position: relative;
  z-index: 4;
  display: flex;
  min-height: 34px;
  align-items: center;
  gap: 8px;
  margin: 2px 0 14px;
  padding: 6px 3px;
  color: var(--color-text-secondary);
  font-size: 12px;
}

.sync-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--color-sage-deep);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--color-sage) 20%, transparent);
}
.sync-strip[data-state="offline"] .sync-dot,
.sync-strip[data-state="pending"] .sync-dot { background: var(--color-warm); }
.sync-strip[data-state="conflict"] .sync-dot,
.sync-strip[data-state="error"] .sync-dot { background: var(--color-danger); }
.sync-strip[data-state="syncing"] .sync-dot { animation: sync-breathe 1.4s ease-in-out infinite; }
.sync-action { margin-left: auto; }

.view { animation: view-enter var(--motion-base) ease-out; }
@keyframes view-enter { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.status-landscape {
  position: relative;
  min-height: 318px;
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--color-line) 72%, white);
  border-radius: var(--radius-landscape);
  background:
    linear-gradient(154deg, color-mix(in srgb, var(--color-fog-light) 94%, white) 0%, var(--color-fog) 52%, color-mix(in srgb, var(--color-warm) 34%, var(--color-fog)) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.48), var(--shadow-soft);
  isolation: isolate;
}

[data-today-layout="blend"] body[data-current-view="today"] .top-bar,
[data-today-layout="blend"] body[data-current-view="today"] .sync-strip { margin-inline: 3px; }

[data-today-layout="blend"] body[data-current-view="today"] .status-landscape { margin-top: -3px; }

[data-today-layout="separate"] body[data-current-view="today"] { background: var(--color-bg); }
[data-today-layout="separate"] body[data-current-view="today"] .status-landscape {
  margin-top: 8px;
  background: linear-gradient(154deg, var(--color-fog-light), var(--color-fog) 56%, color-mix(in srgb, var(--color-warm) 34%, var(--color-fog)));
}

.landscape-glow {
  position: absolute;
  z-index: -1;
  top: 28px;
  right: -38px;
  width: 210px;
  height: 210px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 42%, rgba(255,255,255,.76), color-mix(in srgb, var(--color-fog-light) 55%, transparent) 49%, transparent 72%);
  transition: opacity var(--motion-base) ease, transform var(--motion-base) ease;
  animation: landscape-breathe 10s ease-in-out infinite;
}

.status-landscape[data-energy="1"] .landscape-glow,
.status-landscape[data-energy="2"] .landscape-glow,
.status-landscape[data-energy="3"] .landscape-glow { opacity: 0.62; transform: scale(0.92); }
.status-landscape[data-energy="8"] .landscape-glow,
.status-landscape[data-energy="9"] .landscape-glow,
.status-landscape[data-energy="10"] .landscape-glow { opacity: 0.96; transform: scale(1.08); }
.status-landscape[data-mood="anxious"] .landscape-middle,
.status-landscape[data-mood="irritable"] .landscape-middle { border-radius: 42% 58% 0 0; }
.status-landscape[data-mood="low"] .landscape-near,
.status-landscape[data-mood="tired"] .landscape-near { background: color-mix(in srgb, var(--color-warm) 42%, var(--color-sage)); }

.landscape-layer {
  position: absolute;
  z-index: -2;
  right: -12%;
  bottom: 0;
  left: -12%;
  border-radius: 52% 48% 0 0;
}
.landscape-far {
  height: 145px;
  bottom: 34px;
  background: color-mix(in srgb, var(--color-sage) 34%, transparent);
  clip-path: polygon(0 54%, 22% 32%, 46% 49%, 70% 18%, 100% 48%, 100% 100%, 0 100%);
}
.landscape-middle {
  height: 122px;
  bottom: 0;
  background: color-mix(in srgb, var(--color-sage) 57%, transparent);
  clip-path: polygon(0 46%, 27% 18%, 52% 53%, 77% 27%, 100% 42%, 100% 100%, 0 100%);
}
.landscape-near {
  height: 78px;
  background: color-mix(in srgb, var(--color-warm) 58%, transparent);
  clip-path: polygon(0 59%, 24% 35%, 48% 57%, 74% 25%, 100% 46%, 100% 100%, 0 100%);
}
.landscape-line {
  position: absolute;
  right: 28px;
  bottom: 48px;
  left: 36px;
  height: 1px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.66);
  transform: rotate(-4deg);
}

.landscape-content { position: relative; z-index: 2; padding: 25px; }
.status-landscape:has(#state-form:not([hidden])) { min-height: 610px; }
.status-landscape:has(#state-form:not([hidden])) .landscape-layer { opacity: 0.5; }

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}
.section-heading.compact { margin-bottom: 15px; }
.section-heading h2 {
  margin: 0;
  font-size: 21px;
  line-height: 1.22;
  letter-spacing: -0.025em;
}

.saved-mark, .status-pill {
  display: inline-flex;
  min-height: 28px;
  flex: 0 0 auto;
  align-items: center;
  padding: 4px 10px;
  border: 1px solid color-mix(in srgb, var(--color-primary) 16%, transparent);
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-surface) 55%, transparent);
  color: var(--color-primary-strong);
  font-size: 12px;
  font-weight: 720;
}
.status-pill.experiment { color: color-mix(in srgb, var(--color-warm) 72%, var(--color-text)); }

.state-summary { padding-top: 3px; }
.state-reading { display: flex; align-items: flex-end; gap: 7px; }
.state-reading strong { font-size: 68px; font-weight: 450; line-height: 0.95; letter-spacing: -0.075em; }
.state-reading span { padding-bottom: 7px; color: var(--color-text-secondary); font-size: 13px; font-weight: 700; }
.state-mood { margin: 19px 0 5px; font-size: 20px; font-weight: 720; letter-spacing: -0.02em; }
.state-note-summary { max-width: 82%; margin: 0; color: var(--color-text-secondary); font-size: 13px; white-space: pre-wrap; }
.landscape-action {
  position: absolute;
  right: 22px;
  bottom: 22px;
  min-height: 44px;
  padding: 9px 16px;
  border: 0;
  border-radius: var(--radius-control);
  background: var(--color-primary-strong);
  color: var(--color-surface-strong);
  font-size: 13px;
  font-weight: 760;
  cursor: pointer;
}

.energy-line { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; }
.energy-line label { font-weight: 700; }
.energy-line output {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(255,255,255,.38);
  border-radius: 15px;
  background: color-mix(in srgb, var(--color-surface) 48%, transparent);
  color: var(--color-primary-strong);
  font-size: 22px;
  font-weight: 800;
}
.energy-range { width: 100%; height: 44px; margin: 7px 0 0; accent-color: var(--color-primary); cursor: pointer; }
.range-labels { display: flex; justify-content: space-between; margin-top: -7px; color: var(--color-text-secondary); font-size: 11px; }

.mood-fieldset, .attempt-field { margin: 20px 0; padding: 0; border: 0; }
.mood-fieldset legend, .field-label, .attempt-field legend {
  display: block;
  margin-bottom: 8px;
  color: var(--color-text-secondary);
  font-size: 13px;
  font-weight: 700;
}
.mood-grid { display: flex; flex-wrap: wrap; gap: 8px; }

.mood-choice, .filter-chip, .radio-choice span {
  min-height: 44px;
  padding: 9px 15px;
  border: 1px solid var(--color-line);
  border-radius: 999px;
  background: color-mix(in srgb, var(--color-surface) 58%, transparent);
  color: var(--color-text-secondary);
  font-size: 14px;
  font-weight: 650;
  cursor: pointer;
}
.mood-choice[aria-pressed="true"], .filter-chip[aria-pressed="true"], .radio-choice input:checked + span {
  border-color: var(--color-sage-deep);
  background: var(--color-primary-soft);
  color: var(--color-primary-strong);
}

input[type="text"], input[type="password"], input[type="number"], textarea, select {
  width: 100%;
  min-height: 48px;
  margin: 0 0 16px;
  padding: 13px 14px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-control);
  background: color-mix(in srgb, var(--color-surface) 76%, transparent);
  color: var(--color-text);
  font-size: 16px;
}
textarea::placeholder, input::placeholder { color: var(--color-text-faint); }

.primary-button, .secondary-button, .quiet-button, .danger-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
  border-radius: var(--radius-control);
  font-weight: 750;
  cursor: pointer;
  transition: transform var(--motion-fast) ease, background var(--motion-fast) ease, opacity var(--motion-fast) ease;
}
.primary-button { width: 100%; border: 1px solid var(--color-primary-strong); background: var(--color-primary-strong); color: var(--color-surface-strong); }
.secondary-button { border: 1px solid color-mix(in srgb, var(--color-primary) 48%, var(--color-line)); background: var(--color-primary-soft); color: var(--color-primary-strong); }
.quiet-button { border: 1px solid var(--color-line); background: transparent; color: var(--color-text-secondary); }
.danger-button { width: 100%; border: 1px solid var(--color-danger); background: var(--color-danger); color: #fff; }
.primary-button:disabled, .secondary-button:disabled, .quiet-button:disabled, .danger-button:disabled { opacity: 0.42; cursor: not-allowed; }
.primary-button:not(:disabled):active, .secondary-button:not(:disabled):active, .quiet-button:not(:disabled):active, .danger-button:not(:disabled):active { transform: scale(0.985); }
.text-button { min-height: 44px; padding: 5px 2px; border: 0; background: transparent; color: var(--color-primary); font-weight: 700; cursor: pointer; }
.danger-text { color: var(--color-danger); }

.flow-section {
  margin: 0 4px;
  padding: 28px 0 26px;
  border-bottom: 1px solid var(--color-line);
}
.flow-section:last-of-type { border-bottom: 0; }
.flow-section h3 { margin: 0 0 6px; font-size: 18px; }
.flow-section > div > p, .experiment-section p { color: var(--color-text-secondary); }
.gentle-empty p, .support-copy, .settings-section p, .settings-muted {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 14px;
  line-height: 1.65;
}
.gentle-empty .secondary-button, .gentle-empty .quiet-button { width: 100%; margin-top: 16px; }
.source-summary { margin-bottom: 15px; padding: 12px 14px; border-radius: 15px; background: var(--color-primary-soft); }
.source-summary span { color: var(--color-text-secondary); font-size: 10px; font-weight: 760; letter-spacing: .06em; text-transform: uppercase; }
.source-summary p { margin: 4px 0 0; color: var(--color-text); font-size: 13px; }
.session-name { margin: 0 0 14px; font-size: 20px; font-weight: 760; }
.next-step-box { padding: 15px 16px; border-left: 3px solid var(--color-sage-deep); border-radius: 0 14px 14px 0; background: var(--color-primary-soft); }
.next-step-box span { display: block; color: var(--color-text-secondary); font-size: 10px; font-weight: 740; letter-spacing: .06em; text-transform: uppercase; }
.next-step-box strong { display: block; margin-top: 5px; font-size: 16px; }
.session-time, .experiment-count { margin: 12px 0 0; color: var(--color-text-faint); font-size: 12px; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.button-row > * { flex: 1 1 116px; }
.experiment-steps { margin: 15px 0 0; padding-left: 22px; }
.experiment-steps li { margin: 7px 0; padding-left: 4px; color: var(--color-text-secondary); }

.positive-note { display: flex; gap: 12px; padding: 22px 4px 3px; color: var(--color-text-secondary); }
.positive-note p { margin: 0; font-size: 14px; line-height: 1.65; }
.positive-mark { position: relative; width: 20px; height: 20px; flex: 0 0 auto; margin-top: 1px; border-radius: 50%; background: color-mix(in srgb, var(--color-warm) 68%, transparent); }
.positive-mark::before { position: absolute; width: 8px; height: 4px; top: 6px; left: 5px; border-left: 2px solid var(--color-primary-strong); border-bottom: 2px solid var(--color-primary-strong); content: ""; transform: rotate(-45deg); }

.inbox-intro { margin: 3px 0 20px; padding: 15px 16px; border-left: 3px solid var(--color-sage); border-radius: 0 16px 16px 0; background: color-mix(in srgb, var(--color-fog-light) 46%, transparent); color: var(--color-text-secondary); font-size: 14px; }
.inbox-intro p { margin: 0; }
.filter-row { display: flex; gap: 8px; margin-bottom: 18px; overflow-x: auto; scrollbar-width: none; }
.filter-row::-webkit-scrollbar { display: none; }
.filter-chip { flex: 0 0 auto; white-space: nowrap; }
.inbox-list, .summary-list { display: grid; gap: 12px; }

.inbox-item, .summary-item {
  padding: 18px;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-section);
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
}
.inbox-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 9px; color: var(--color-text-faint); font-size: 11px; }
.inbox-item p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.inbox-item.processed .inbox-body { color: var(--color-text-secondary); }
.processing-block { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--color-line); color: var(--color-text-secondary); font-size: 13px; }
.processing-block > strong { display: block; margin-bottom: 4px; color: var(--color-text); }
.codex-question { color: var(--color-text) !important; font-weight: 650; }
.processing-summary { margin-top: 4px !important; }
.destination-summary, .summary-destination { display: block; margin-top: 8px !important; color: var(--color-primary); font-size: 12px; }
.clarification-form { margin-top: 14px; }
.clarification-form textarea { margin-bottom: 4px; background: var(--color-surface-strong); }
.clarification-form .secondary-button { width: 100%; }
.sync-badge { color: var(--color-primary); font-weight: 700; }
.sync-badge.pending, .sync-badge.local_only { color: color-mix(in srgb, var(--color-warm) 70%, var(--color-text)); }
.sync-badge.conflict, .sync-badge.rejected { color: var(--color-danger); }
.empty-list { padding: 46px 16px; color: var(--color-text-secondary); text-align: center; }
.empty-list strong { display: block; margin-bottom: 7px; color: var(--color-text); }

.review-overview { margin: 4px 0 10px; padding: 22px 3px 12px; border-bottom: 1px solid var(--color-line); }
.review-overview > p { margin: 0 0 18px; font-size: 18px; font-weight: 700; letter-spacing: -.015em; }
.review-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.review-metrics article { min-width: 0; }
.review-metrics span { display: block; color: var(--color-text-secondary); font-size: 11px; }
.review-metrics strong { display: block; margin-top: 4px; font-size: 20px; }
.energy-chart { display: grid; height: 140px; grid-template-columns: repeat(7, 1fr); align-items: end; gap: 8px; padding: 10px 2px 0; }
.chart-bar-wrap { display: flex; height: 100%; align-items: end; }
.chart-bar { width: 100%; min-height: 5px; border-radius: 9px 9px 4px 4px; background: linear-gradient(180deg, var(--color-fog), var(--color-sage-deep)); }
.chart-bar.empty { height: 5%; background: var(--color-line); }
.chart-bar.level-1 { height: 10%; } .chart-bar.level-2 { height: 20%; } .chart-bar.level-3 { height: 30%; }
.chart-bar.level-4 { height: 40%; } .chart-bar.level-5 { height: 50%; } .chart-bar.level-6 { height: 60%; }
.chart-bar.level-7 { height: 70%; } .chart-bar.level-8 { height: 80%; } .chart-bar.level-9 { height: 90%; } .chart-bar.level-10 { height: 100%; }
.chart-labels { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-top: 8px; color: var(--color-text-faint); font-size: 10px; text-align: center; }
.summary-item p { margin: 0; color: var(--color-text-secondary); font-size: 14px; }
.summary-item time { display: block; margin-top: 8px; color: var(--color-text-faint); font-size: 11px; }

.capture-button {
  position: fixed;
  z-index: 50;
  right: max(18px, calc((100vw - 520px) / 2 + 18px));
  bottom: calc(82px + var(--safe-bottom));
  display: flex;
  min-height: 50px;
  align-items: center;
  gap: 8px;
  padding: 8px 16px 8px 9px;
  border: 1px solid color-mix(in srgb, var(--color-primary-strong) 70%, transparent);
  border-radius: 14px;
  background: var(--color-primary-strong);
  color: var(--color-surface-strong);
  box-shadow: var(--shadow-float);
  font-size: 14px;
  font-weight: 760;
  cursor: pointer;
  transition: transform var(--motion-fast) ease;
}
.capture-button:active { transform: scale(.98); }
.capture-button .icon-plus { display: grid; width: 32px; height: 32px; place-items: center; border-radius: 10px; background: rgba(255,255,255,.13); }

.tab-bar {
  position: fixed;
  z-index: 40;
  inset: auto 0 0;
  display: flex;
  justify-content: center;
  padding: 7px max(12px, calc((100vw - 520px) / 2)) calc(7px + var(--safe-bottom));
  border-top: 1px solid var(--color-line);
  background: color-mix(in srgb, var(--color-bg) 88%, transparent);
  -webkit-backdrop-filter: blur(20px);
  backdrop-filter: blur(20px);
}
.tab-item { position: relative; display: grid; min-width: 84px; min-height: 54px; flex: 0 1 150px; place-items: center; gap: 1px; border: 0; border-radius: 14px; background: transparent; color: var(--color-text-faint); font-size: 11px; font-weight: 700; cursor: pointer; }
.tab-item.active { color: var(--color-primary); }
.tab-item .line-icon { width: 24px; height: 24px; }
.tab-item.active::after { position: absolute; width: 26px; height: 2px; margin-top: -52px; border-radius: 999px; background: var(--color-sage-deep); content: ""; }

dialog { color: var(--color-text); }
dialog::backdrop { background: rgba(18, 26, 23, 0.42); -webkit-backdrop-filter: blur(7px); backdrop-filter: blur(7px); }
.sheet-dialog { width: min(100%, 520px); max-width: none; margin: auto auto 0; padding: 0; border: 0; background: transparent; }
.sheet-card { max-height: min(90vh, 780px); overflow-y: auto; padding: 12px 22px calc(28px + var(--safe-bottom)); border: 1px solid var(--color-line); border-radius: 28px 28px 0 0; background: var(--color-surface); box-shadow: var(--shadow-soft); }
.sheet-handle { width: 38px; height: 5px; margin: 0 auto 20px; border-radius: 999px; background: var(--color-line); }
.sheet-card .section-heading { margin-bottom: 16px; }
.sheet-card .icon-button { width: 40px; height: 40px; }
.support-copy { margin: -5px 0 20px; }

.experiment-catalog { display: grid; gap: 10px; margin-bottom: 18px; }
.experiment-option { position: relative; display: block; cursor: pointer; }
.experiment-option > input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.experiment-option-copy { display: block; padding: 15px 16px; border: 1px solid var(--color-line); border-radius: 17px; background: color-mix(in srgb, var(--color-surface-strong) 62%, transparent); transition: border var(--motion-fast) ease, background var(--motion-fast) ease; }
.experiment-option input:checked + .experiment-option-copy { border-color: var(--color-sage-deep); background: var(--color-primary-soft); box-shadow: inset 3px 0 0 var(--color-sage-deep); }
.experiment-option-copy strong, .experiment-option-copy span, .experiment-option-copy small { display: block; }
.experiment-option-copy span { margin-top: 5px; color: var(--color-text-secondary); font-size: 13px; }
.experiment-option-copy small { margin-top: 9px; color: var(--color-text-faint); font-size: 11px; }
.attempt-field { margin: 0 0 20px; }
.attempt-choice-row, .attempt-scale { display: flex; gap: 8px; }
.attempt-scale { justify-content: space-between; }
.radio-choice { flex: 1; cursor: pointer; }
.radio-choice { position: relative; }
.radio-choice input { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.radio-choice span { display: grid; place-items: center; padding-inline: 10px; }
.attempt-scale-labels { display: flex; justify-content: space-between; margin-top: 5px; color: var(--color-text-faint); font-size: 10px; }

.page-dialog { width: min(100%, 520px); max-width: none; height: 100%; max-height: none; margin: 0 auto; padding: 0; border: 0; background: var(--color-bg); }
.dialog-page { min-height: 100%; }
.dialog-header { position: sticky; top: 0; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: calc(12px + var(--safe-top)) 20px 12px; border-bottom: 1px solid var(--color-line); background: color-mix(in srgb, var(--color-bg) 90%, transparent); -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.dialog-header h2 { margin: 0; font-size: 17px; }
.dialog-header .text-button { justify-self: start; }
.settings-content { display: grid; gap: 14px; padding: 20px 20px calc(40px + var(--safe-bottom)); }
.settings-section { padding: 20px; border: 1px solid var(--color-line); border-radius: var(--radius-section); background: var(--color-surface); }
.settings-section h3 { margin: 0 0 14px; font-size: 18px; }
.settings-section h4 { margin: 0 0 9px; font-size: 14px; }
.settings-section > p { margin-bottom: 14px; }
.settings-section > button { width: 100%; margin-top: 9px; }
.settings-subsection { margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--color-line); }
.settings-subsection:first-of-type { margin-top: 4px; }
.settings-subsection > button { width: 100%; margin-top: 10px; }
.settings-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-bottom: 1px solid var(--color-line); }
.settings-row strong { text-align: right; }
.security-list { display: grid; gap: 8px; }
.security-item { display: flex; min-height: 52px; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--color-line); }
.security-item > div { min-width: 0; }
.security-item strong, .security-item span { display: block; }
.security-item span { margin-top: 2px; color: var(--color-text-faint); font-size: 11px; }
.security-item .text-button { flex: 0 0 auto; }
.conflict-list, .failed-operation-list { display: grid; gap: 10px; margin-top: 14px; }
.conflict-item, .failed-operation { padding: 13px; border: 1px solid color-mix(in srgb, var(--color-danger) 35%, var(--color-line)); border-radius: var(--radius-control); background: var(--color-danger-soft); }
.conflict-item p, .failed-operation p { margin: 0 0 8px; color: var(--color-text); font-size: 13px; }
.failed-operation strong { display: block; margin-bottom: 4px; font-size: 13px; }
.conflict-item .button-row { margin-top: 6px; }
.danger-zone { border-color: color-mix(in srgb, var(--color-danger) 28%, var(--color-line)); }
.secret-output { display: block; margin-top: 12px; padding: 12px; border-radius: var(--radius-control); background: var(--color-surface-strong); overflow-wrap: anywhere; font-family: ui-monospace, monospace; font-size: 12px; user-select: all; }
.build-label { margin: 8px 0; color: var(--color-text-faint); font-size: 11px; text-align: center; }
.site-filing { margin: 24px 0 0; text-align: center; font-size: 12px; }
.site-filing a { display: inline-flex; min-height: 44px; align-items: center; color: var(--color-text-secondary); text-underline-offset: 3px; }
.auth-dialog > .site-filing { margin: 0 20px calc(24px + var(--safe-bottom)); }

.auth-dialog { background: var(--color-bg); }
.auth-card { width: min(calc(100% - 40px), 420px); margin: max(54px, 12vh) auto 40px; padding: 28px; border: 1px solid var(--color-line); border-radius: var(--radius-landscape); background: var(--color-surface); box-shadow: var(--shadow-soft); text-align: center; }
.auth-card h2 { margin: 2px 0 7px; font-size: 26px; }
.auth-card > p:not(.section-kicker):not(.form-error) { margin: 0 0 24px; color: var(--color-text-secondary); }
.auth-mark { position: relative; width: 64px; height: 64px; margin: 0 auto 17px; overflow: hidden; border-radius: 21px; background: linear-gradient(155deg, var(--color-fog-light), var(--color-fog)); }
.auth-mark::before, .auth-mark::after, .auth-mark span { position: absolute; right: -12px; bottom: -6px; left: -12px; height: 30px; border-radius: 50% 50% 0 0; content: ""; }
.auth-mark::before { bottom: 13px; background: color-mix(in srgb, var(--color-sage) 54%, transparent); }
.auth-mark::after { background: color-mix(in srgb, var(--color-warm) 64%, transparent); }
.auth-mark span { bottom: 4px; background: color-mix(in srgb, var(--color-sage-deep) 68%, transparent); transform: translateX(12px); }
.auth-card form { margin-top: 20px; text-align: left; }
.auth-card > button { width: 100%; margin-top: 10px; }
.form-error { min-height: 20px; margin: 8px 0; color: var(--color-danger); font-size: 13px; }
.form-error:empty { min-height: 0; margin-block: 0 8px; }
.recovery-panel { margin-top: 20px; text-align: left; }
.recovery-panel h2, .recovery-panel h3 { margin: 0 0 6px; }
.recovery-panel > p { color: var(--color-text-secondary); }
.recovery-panel pre { padding: 14px; border-radius: var(--radius-control); background: var(--color-surface-strong); white-space: pre-wrap; user-select: all; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: calc(148px + var(--safe-bottom)); width: max-content; max-width: calc(100% - 40px); transform: translateX(-50%); padding: 12px 16px; border: 1px solid var(--color-line); border-radius: 999px; background: var(--color-text); color: var(--color-bg); box-shadow: var(--shadow-soft); font-size: 13px; font-weight: 700; text-align: center; animation: toast-enter var(--motion-base) ease-out; }
@keyframes toast-enter { from { opacity: 0; transform: translate(-50%, 8px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes sync-breathe { 50% { transform: scale(1.38); opacity: .48; } }
@keyframes landscape-breathe { 0%, 100% { translate: 0 0; } 50% { translate: -5px 3px; } }

@media (prefers-color-scheme: dark) {
  .status-landscape { border-color: rgba(224, 235, 230, .1); box-shadow: inset 0 1px 0 rgba(255,255,255,.08), var(--shadow-soft); }
  .landscape-glow { background: radial-gradient(circle at 40% 42%, rgba(211,229,224,.28), rgba(87,126,118,.2) 49%, transparent 72%); }
  .landscape-line { background: rgba(232, 238, 235, .24); }
  .landscape-action, .primary-button, .capture-button { color: #17211f; }
}

@media (min-width: 760px) {
  .app-shell { padding-top: 38px; }
  .sheet-dialog { margin-bottom: 3vh; }
  .sheet-card { border-radius: 28px; }
  .page-dialog { height: min(90vh, 850px); margin: auto; border: 1px solid var(--color-line); border-radius: 28px; overflow: hidden; }
}

@media (max-width: 390px) {
  .app-shell { padding-inline: 16px; }
  .landscape-content { padding: 22px; }
  .status-landscape { min-height: 306px; }
  .status-landscape:has(#state-form:not([hidden])) { min-height: 625px; }
  .capture-button { right: 14px; gap: 6px; padding-right: 13px; font-size: 13px; }
  .session-section #session-actions { padding-right: 154px; }
  .session-section #session-actions > * { flex-basis: 100%; }
  .state-reading strong { font-size: 62px; }
}

@media (max-width: 350px) {
  .app-shell { padding-inline: 12px; }
  .landscape-content { padding: 19px; }
  .section-heading { gap: 9px; }
  .mood-choice, .filter-chip { padding-inline: 12px; }
  .capture-button { right: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

@media (prefers-contrast: more) {
  :root { --color-line: currentColor; }
  .status-landscape, .inbox-item, .summary-item, .settings-section, .experiment-option-copy { border-width: 2px; }
  .section-kicker, .eyebrow, .session-time, .experiment-count, .settings-muted { color: var(--color-text); }
}
