:root {
  --page-background: #f5f2ec;
  --text: #252621;
  --muted: #73756a;
  --subtle: #898a7f;
  --border: #cecec2;
  --border-strong: #b9bcad;
  --surface: #eeeae280;
  --hover: #e9e7de;
  --action: #272a23;
  --action-text: #f5f2ec;
  --action-hover: #42463c;
  --error: #975044;
  --accent: #636b56;
  --focus: #737c61;
  --grain: rgba(73, 62, 45, 0.06);
  --landscape-base: #acc5c5;
  --field-text: #2e2d33;
  --field-border: #d8d5df;
  --field-fill: rgba(224, 222, 227, 0.25);
  --field-highlight: rgba(255, 255, 255, 0.9);
  --field-focus: #aaa4b5;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --page-background: #101923;
  --text: #e6e9ec;
  --muted: #a2acb6;
  --subtle: #8e9ba8;
  --border: #33404c;
  --border-strong: #52616e;
  --surface: #1b293680;
  --hover: #22313f;
  --action: #dce3e8;
  --action-text: #101923;
  --action-hover: #fff;
  --error: #e6a296;
  --accent: #b5c6b0;
  --focus: #bacbd9;
  --grain: rgba(207, 224, 241, 0.06);
  --landscape-base: #071528;
  --field-text: #edf2f7;
  --field-border: #8797a780;
  --field-fill: rgba(27, 43, 62, 0.25);
  --field-highlight: rgba(255, 255, 255, 0.2);
  --field-focus: #bacbd9;
}

.theme-toggle {
  position: fixed;
  top: max(15px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  z-index: 30;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 10px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--field-text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.theme-toggle:hover { background: rgba(128, 144, 156, 0.12); }
.theme-toggle:focus-visible { outline: 1px solid currentColor; outline-offset: 3px; }
.theme-toggle:disabled { cursor: progress; }
.theme-toggle svg {
  grid-area: 1 / 1;
  width: 20px;
  height: 20px;
  transition: opacity 450ms ease, transform 750ms cubic-bezier(0.22, 1, 0.36, 1);
}
.theme-toggle .theme-sun { opacity: 0; transform: rotate(-90deg) scale(0.65); }
.theme-toggle .theme-moon { opacity: 1; transform: rotate(0) scale(1); }
[data-theme="dark"] .theme-toggle .theme-sun { opacity: 1; transform: rotate(0) scale(1); }
[data-theme="dark"] .theme-toggle .theme-moon { opacity: 0; transform: rotate(60deg) scale(0.65); }
.call-handler-page .theme-toggle { color: var(--text); }
.call-nav, .notes-nav { padding-right: max(76px, calc(4vw + 44px)); }

[data-theme="dark"] .note-folder.is-drop-target > summary {
  background: rgba(181, 198, 176, 0.12);
}

[data-theme="dark"] .save-note:hover { background: rgba(230, 233, 236, 0.06); }

.theme-transition-layer {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
}

.theme-transition-layer.is-visible { opacity: 1; }
.theme-transition-layer.is-finishing { opacity: 0; transition: opacity 220ms ease; }
.theme-transition-layer video,
.theme-transition-layer canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.theme-transition-layer canvas { opacity: 0.25; image-rendering: pixelated; }
.notes-workspace { z-index: 1; }

.scene-page .call-workspace,
.scene-page .spend-workspace {
  position: relative;
  z-index: 1;
}

.theme-changing body,
.theme-changing .tools-textbox textarea,
.theme-changing .orb-surface,
.theme-changing .orb-feedback,
.theme-changing .text-field,
.theme-changing .text-input,
.theme-changing .call-workspace,
.theme-changing .notes-workspace,
.theme-changing .spend-workspace,
.theme-changing .calendar-workspace,
.theme-changing .scene-view button,
.theme-changing .scene-view input,
.theme-changing .scene-view textarea,
.theme-changing .scene-view p,
.theme-changing .scene-view label,
.theme-changing .scene-view summary,
.theme-changing .scene-view h2,
.theme-changing .scene-view h3,
.theme-changing .theme-toggle {
  transition-property: background-color, color, border-color, box-shadow;
  transition-duration: 950ms;
  transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
}

@media (prefers-reduced-motion: reduce) {
  .theme-toggle svg { transition: none; }
}

@media (max-width: 600px) {
  .theme-toggle { top: max(9px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); }
  .notes-nav { padding-top: max(18px, env(safe-area-inset-top)); }
}
