html[data-theme="dark"] {
  color-scheme: dark;
}

html[data-theme="light"] {
  color-scheme: light;
  background: #eeebe3;
}

.topbar__actions,
.tool-nav__actions,
.toolbox-nav__actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--tool-line, var(--drp-line, var(--line, rgba(255, 255, 255, 0.14))));
  border-radius: 999px;
  color: var(--tool-muted, var(--drp-muted, var(--muted, rgba(244, 241, 234, 0.68))));
  background: var(--tool-surface, var(--drp-panel, var(--panel, rgba(255, 255, 255, 0.045))));
  font: 700 0.72rem/1 Inter, "Avenir Next", "Helvetica Neue", "PingFang SC", sans-serif;
  white-space: nowrap;
  cursor: pointer;
  transition: color 160ms ease, border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.theme-toggle:hover {
  transform: translateY(-1px);
  border-color: var(--tool-line-strong, var(--drp-line-strong, var(--line-strong, currentColor)));
  color: var(--tool-text, var(--drp-text, var(--text, inherit)));
}

.theme-toggle:focus-visible {
  outline: 2px solid var(--tool-accent, var(--drp-accent, var(--amber, #d79a3a)));
  outline-offset: 2px;
}

.theme-toggle__icon {
  display: inline-grid;
  place-items: center;
  width: 1rem;
  height: 1rem;
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1;
}

/* Home and redirect pages: warm paper, ink typography, and restrained print-like depth. */
html[data-theme="light"] body:not([data-tool]) {
  --bg: #efede6;
  --panel: rgba(255, 253, 248, 0.84);
  --panel-hover: #fffdf8;
  --line: rgba(41, 38, 31, 0.14);
  --line-strong: rgba(41, 38, 31, 0.28);
  --text: #1d201c;
  --muted: rgba(29, 32, 28, 0.68);
  --subtle: rgba(29, 32, 28, 0.48);
  --amber: #9b5b10;
  --red: #b74840;
  --green: #237953;
  --purple: #6450b5;
  --cyan: #167b6c;
  --accent: #5968bf;
  --accent-rgb: 89, 104, 191;
  --shadow: 0 18px 44px rgba(65, 55, 40, 0.1);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.64), transparent 34%),
    radial-gradient(circle at 14% 0%, rgba(184, 121, 38, 0.11), transparent 25rem),
    radial-gradient(circle at 88% 2%, rgba(48, 125, 91, 0.07), transparent 23rem),
    var(--bg);
}

html[data-theme="light"] body:not([data-tool])::before {
  background-image: radial-gradient(rgba(34, 39, 35, 0.17) 0.55px, transparent 0.55px);
  opacity: 0.065;
}

html[data-theme="light"] body:not([data-tool]) .tool-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.66), rgba(250, 247, 239, 0.74)),
    var(--panel);
}

html[data-theme="light"] body:not([data-tool]) .tool-card:hover,
html[data-theme="light"] body:not([data-tool]) .tool-card:focus-visible {
  background: var(--panel-hover);
  box-shadow: 0 20px 48px rgba(65, 55, 40, 0.13);
}

/* Shared tool pages: the light palette is a separate editorial workbench, not an inversion. */
body[data-tool] {
  --tool-waveform-grid: rgba(244, 241, 234, 0.12);
  --tool-waveform-rest: rgba(244, 241, 234, 0.35);
  --tool-waveform-canvas: rgba(0, 0, 0, 0.18);
}

html[data-theme="light"] body[data-tool] {
  --tool-bg: #efede7;
  --tool-surface: rgba(255, 254, 250, 0.76);
  --tool-surface-strong: #fffefa;
  --tool-line: rgba(34, 39, 34, 0.14);
  --tool-line-strong: rgba(34, 39, 34, 0.27);
  --tool-text: #1b211c;
  --tool-muted: rgba(27, 33, 28, 0.67);
  --tool-subtle: rgba(27, 33, 28, 0.46);
  --tool-success: #1d7650;
  --tool-danger: #b6433d;
  --tool-shadow: 0 20px 54px rgba(57, 53, 43, 0.11);
  --tool-waveform-grid: rgba(38, 43, 38, 0.13);
  --tool-waveform-rest: rgba(38, 43, 38, 0.34);
  --tool-waveform-canvas: rgba(255, 255, 255, 0.52);
  background:
    radial-gradient(circle at 12% 0%, rgba(var(--tool-accent-rgb), 0.1), transparent 30rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), transparent 35rem),
    var(--tool-bg);
}

html[data-theme="light"] body[data-tool="audio"] {
  --tool-accent: #14786a;
  --tool-accent-rgb: 20, 120, 106;
}

html[data-theme="light"] body[data-tool="pr"] {
  --tool-accent: #6550b7;
  --tool-accent-rgb: 101, 80, 183;
}

html[data-theme="light"] body[data-tool="music-analysis"] {
  --tool-accent: #5966bd;
  --tool-accent-rgb: 89, 102, 189;
}

html[data-theme="light"] body[data-tool] .workspace,
html[data-theme="light"] body[data-tool] .music-intake {
  background: rgba(255, 254, 250, 0.78);
  box-shadow: var(--tool-shadow);
}

html[data-theme="light"] body[data-tool] .workspace__side {
  background: rgba(224, 222, 213, 0.38);
}

html[data-theme="light"] body[data-tool] .dropzone {
  background:
    linear-gradient(135deg, rgba(var(--tool-accent-rgb), 0.085), transparent 46%),
    rgba(255, 255, 255, 0.46);
}

html[data-theme="light"] body[data-tool] .dropzone:hover,
html[data-theme="light"] body[data-tool] .dropzone:focus-visible,
html[data-theme="light"] body[data-tool] .dropzone.is-dragging {
  background:
    linear-gradient(135deg, rgba(var(--tool-accent-rgb), 0.14), transparent 52%),
    rgba(255, 255, 255, 0.76);
}

html[data-theme="light"] body[data-tool] .control-group select {
  color: var(--tool-text);
  background: #fdfcf8;
}

html[data-theme="light"] body[data-tool] .primary-button {
  color: #fff;
}

html[data-theme="light"] body[data-tool] .secondary-button {
  background: rgba(255, 255, 255, 0.6);
}

html[data-theme="light"] body[data-tool] .progress {
  background: rgba(30, 36, 31, 0.1);
}

html[data-theme="light"] body[data-tool] .result-panel {
  background: rgba(var(--tool-accent-rgb), 0.065);
}

html[data-theme="light"] body[data-tool] .source-preview {
  background: rgba(255, 255, 255, 0.48);
}

html[data-theme="light"] body[data-tool] .waveform-canvas {
  background:
    linear-gradient(90deg, transparent 24.8%, rgba(34, 39, 34, 0.045) 25%, transparent 25.2%),
    linear-gradient(90deg, transparent 49.8%, rgba(34, 39, 34, 0.065) 50%, transparent 50.2%),
    linear-gradient(90deg, transparent 74.8%, rgba(34, 39, 34, 0.045) 75%, transparent 75.2%),
    var(--tool-waveform-canvas);
}

/* AI music analysis keeps the report airy while retaining analysis hierarchy. */
html[data-theme="light"] body[data-tool="music-analysis"] .music-intake {
  background:
    linear-gradient(120deg, rgba(var(--tool-accent-rgb), 0.045), transparent 44%),
    rgba(255, 254, 250, 0.84);
}

html[data-theme="light"] body[data-tool="music-analysis"] .music-dropzone.is-error {
  background: rgba(182, 67, 61, 0.045);
}

html[data-theme="light"] body[data-tool="music-analysis"] .processing-panel {
  background: rgba(var(--tool-accent-rgb), 0.065);
}

html[data-theme="light"] body[data-tool="music-analysis"] .progress.is-active .progress__bar::after {
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.82), transparent);
}

html[data-theme="light"] body[data-tool="music-analysis"] .signal-item,
html[data-theme="light"] body[data-tool="music-analysis"] .structure-item,
html[data-theme="light"] body[data-tool="music-analysis"] .fit-item {
  border-top-color: rgba(32, 37, 33, 0.09);
}

html[data-theme="light"] body[data-tool="music-analysis"] .energy-chart {
  background:
    linear-gradient(180deg, transparent 49.5%, rgba(32, 37, 33, 0.055) 50%, transparent 50.5%),
    linear-gradient(90deg, transparent 24.8%, rgba(32, 37, 33, 0.045) 25%, transparent 25.2%),
    linear-gradient(90deg, transparent 49.8%, rgba(32, 37, 33, 0.045) 50%, transparent 50.2%),
    linear-gradient(90deg, transparent 74.8%, rgba(32, 37, 33, 0.045) 75%, transparent 75.2%);
}

html[data-theme="light"] body[data-tool="music-analysis"] .energy-chart__point {
  fill: #efede7;
}

html[data-theme="light"] body[data-tool="music-analysis"] .tag-item {
  background: rgba(var(--tool-accent-rgb), 0.07);
}

html[data-theme="light"] body[data-tool="music-analysis"] .music-player-dock {
  background: rgba(248, 247, 241, 0.94);
  box-shadow: 0 -14px 38px rgba(57, 53, 43, 0.13);
}

html[data-theme="light"] body[data-tool="music-analysis"] .music-player-dock__toggle {
  color: #fff;
}

html[data-theme="light"] body[data-tool="music-analysis"] .music-player-dock__waveform {
  background:
    linear-gradient(90deg, transparent 24.8%, rgba(34, 39, 34, 0.045) 25%, transparent 25.2%),
    linear-gradient(90deg, transparent 49.8%, rgba(34, 39, 34, 0.065) 50%, transparent 50.2%),
    linear-gradient(90deg, transparent 74.8%, rgba(34, 39, 34, 0.045) 75%, transparent 75.2%),
    var(--tool-waveform-canvas);
}

html[data-theme="light"] body[data-tool="music-analysis"] .music-player-dock__wave-message {
  background: rgba(248, 247, 241, 0.82);
}

/* FCPXML: a pale proofing desk with muted red markup accents. */
html[data-theme="light"] body[data-tool="fcpxml"] {
  --bg: #f1ede7;
  --panel: rgba(255, 253, 249, 0.82);
  --panel-soft: rgba(255, 255, 255, 0.54);
  --line: rgba(59, 45, 40, 0.14);
  --line-strong: rgba(167, 67, 59, 0.34);
  --text: #241d1b;
  --muted: rgba(36, 29, 27, 0.67);
  --subtle: rgba(36, 29, 27, 0.46);
  --red: #a9473f;
  --red-hot: #bd5047;
  --amber: #9a5c1d;
  --danger: #a63f39;
  --success: #8b541d;
  --shadow: 0 18px 48px rgba(76, 54, 44, 0.1);
  background:
    radial-gradient(circle at 12% 0%, rgba(169, 71, 63, 0.09), transparent 27rem),
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), transparent 34rem),
    var(--bg);
}

html[data-theme="light"] body[data-tool="fcpxml"] .toolbox-nav {
  color: rgba(36, 29, 27, 0.7);
}

html[data-theme="light"] body[data-tool="fcpxml"] .toolbox-nav__current {
  color: var(--subtle);
}

html[data-theme="light"] body[data-tool="fcpxml"] .panel {
  background: var(--panel);
  box-shadow: var(--shadow);
}

html[data-theme="light"] body[data-tool="fcpxml"] .dropzone,
html[data-theme="light"] body[data-tool="fcpxml"] .meta-card,
html[data-theme="light"] body[data-tool="fcpxml"] .target-select-trigger,
html[data-theme="light"] body[data-tool="fcpxml"] .summary-list li,
html[data-theme="light"] body[data-tool="fcpxml"] .rule-item {
  background: var(--panel-soft);
}

html[data-theme="light"] body[data-tool="fcpxml"] .dropzone:hover,
html[data-theme="light"] body[data-tool="fcpxml"] .dropzone.is-dragging,
html[data-theme="light"] body[data-tool="fcpxml"] .target-select-trigger:hover:not(:disabled),
html[data-theme="light"] body[data-tool="fcpxml"] .target-select-trigger.is-open,
html[data-theme="light"] body[data-tool="fcpxml"] .button-secondary:hover {
  background: rgba(169, 71, 63, 0.075);
}

html[data-theme="light"] body[data-tool="fcpxml"] .target-select-menu {
  border-color: var(--line);
  background: rgba(255, 253, 249, 0.98);
  box-shadow: 0 20px 48px rgba(76, 54, 44, 0.14);
}

html[data-theme="light"] body[data-tool="fcpxml"] .target-option {
  background: rgba(255, 255, 255, 0.56);
}

html[data-theme="light"] body[data-tool="fcpxml"] .target-option:hover:not(:disabled),
html[data-theme="light"] body[data-tool="fcpxml"] .target-option.is-selected {
  background: rgba(169, 71, 63, 0.08);
}

html[data-theme="light"] body[data-tool="fcpxml"] .target-select-arrow {
  border-color: rgba(36, 29, 27, 0.68);
}

html[data-theme="light"] body[data-tool="fcpxml"] .summary-route {
  color: var(--red);
  background: rgba(169, 71, 63, 0.09);
}

html[data-theme="light"] body[data-tool="fcpxml"] .chip,
html[data-theme="light"] body[data-tool="fcpxml"] .button-secondary {
  background: rgba(36, 29, 27, 0.055);
}

html[data-theme="light"] body[data-tool="fcpxml"] .chip.warn {
  color: #7f4b18;
  background: rgba(154, 92, 29, 0.11);
}

html[data-theme="light"] body[data-tool="fcpxml"] .chip.danger {
  color: #923c36;
  background: rgba(169, 71, 63, 0.1);
}

html[data-theme="light"] body[data-tool="fcpxml"] .status.info {
  color: #744c22;
  background: rgba(154, 92, 29, 0.08);
}

html[data-theme="light"] body[data-tool="fcpxml"] .status.success {
  color: #76501f;
  background: rgba(154, 92, 29, 0.09);
}

html[data-theme="light"] body[data-tool="fcpxml"] .status.error {
  color: #963d37;
  background: rgba(169, 71, 63, 0.08);
}

/* DRP: bridge the compiled token set into a warm Resolve project desk. */
html[data-theme="light"] body[data-tool="drp"] {
  --drp-soft-bg: #efede6;
  --drp-soft-text: #211f1a;
  --drp-soft-muted: rgba(33, 31, 26, 0.66);
  --drp-soft-accent: #a86712;
  --drp-soft-border: rgba(48, 43, 34, 0.14);
  --drp-soft-border-strong: rgba(48, 43, 34, 0.27);
  --drp-bg: #efede6;
  --drp-panel: rgba(255, 254, 250, 0.8);
  --drp-panel-soft: rgba(255, 255, 255, 0.52);
  --drp-line: rgba(48, 43, 34, 0.14);
  --drp-line-strong: rgba(48, 43, 34, 0.27);
  --drp-text: #211f1a;
  --drp-muted: rgba(33, 31, 26, 0.66);
  --drp-subtle: rgba(33, 31, 26, 0.46);
  --drp-accent: #a86712;
  --drp-accent-strong: #8d550e;
  --drp-teal: #197d77;
  --bg-base: #efede6;
  --bg-surface: #f8f6ef;
  --bg-elevated: #fffdf8;
  --border: #d7d1c4;
  --border-accent: #a86712;
  --text-primary: #211f1a;
  --text-secondary: #6c685f;
  --accent: #a86712;
  --success: #2b794b;
  --error: #b4473f;
  --warning: #a16b18;
  color: var(--drp-text);
  background:
    radial-gradient(circle at 12% 0%, rgba(168, 103, 18, 0.09), transparent 28rem),
    radial-gradient(circle at 88% 8%, rgba(25, 125, 119, 0.06), transparent 24rem),
    var(--drp-bg);
}

html[data-theme="light"] body[data-tool="drp"]::after {
  background-image: radial-gradient(rgba(38, 35, 29, 0.12) 0.7px, transparent 0.7px);
  opacity: 0.12;
}

html[data-theme="light"] body[data-tool="drp"] .toolbox-nav {
  color: rgba(33, 31, 26, 0.7);
}

html[data-theme="light"] body[data-tool="drp"] .toolbox-nav__current {
  color: var(--drp-subtle);
}

html[data-theme="light"] body[data-tool="drp"] #root,
html[data-theme="light"] body[data-tool="drp"] #root .min-h-screen {
  color: var(--drp-text) !important;
}

html[data-theme="light"] body[data-tool="drp"] #root .industrial-shell,
html[data-theme="light"] body[data-tool="drp"] #root .hero-meter,
html[data-theme="light"] body[data-tool="drp"] #root [data-drp-row="file"],
html[data-theme="light"] body[data-tool="drp"] #root [data-drp-role="upload"],
html[data-theme="light"] body[data-tool="drp"] #root [data-drp-role="operations"],
html[data-theme="light"] body[data-tool="drp"] #root [data-drp-role="results"] {
  border-color: var(--drp-line) !important;
  background: var(--drp-panel) !important;
  box-shadow: 0 16px 44px rgba(62, 53, 38, 0.09) !important;
}

html[data-theme="light"] body[data-tool="drp"] #root [data-drp-role="upload"] {
  background: var(--drp-panel-soft) !important;
}

html[data-theme="light"] body[data-tool="drp"] #root [data-drp-role="upload"] > div.relative > div:first-child {
  background: rgba(33, 31, 26, 0.055) !important;
}

html[data-theme="light"] body[data-tool="drp"] #root [data-drp-click="file"],
html[data-theme="light"] body[data-tool="drp"] #root [data-drp-click="secondary"],
html[data-theme="light"] body[data-tool="drp"] #root [data-drp-click="target"],
html[data-theme="light"] body[data-tool="drp"] #root summary {
  border-color: var(--drp-line-strong) !important;
  color: var(--drp-text) !important;
  background: rgba(255, 255, 255, 0.68) !important;
}

html[data-theme="light"] body[data-tool="drp"] #root [data-drp-click="download"],
html[data-theme="light"] body[data-tool="drp"] #root [data-drp-click="primary"] {
  color: #fff !important;
  background: var(--drp-accent) !important;
}

html[data-theme="light"] body[data-tool="drp"] #root .bg-background,
html[data-theme="light"] body[data-tool="drp"] #root [class~="bg-[#101010]"],
html[data-theme="light"] body[data-tool="drp"] #root [class~="bg-[#111111]"] {
  background-color: var(--bg-base) !important;
}

html[data-theme="light"] body[data-tool="drp"] #root .bg-surface {
  background-color: var(--bg-surface) !important;
}

html[data-theme="light"] body[data-tool="drp"] #root .bg-elevated {
  background-color: var(--bg-elevated) !important;
}

html[data-theme="light"] body[data-tool="drp"] #root .bg-panel,
html[data-theme="light"] body[data-tool="drp"] #root [class*="bg-[rgba(255,255,255"] {
  background-color: rgba(33, 31, 26, 0.045) !important;
}

html[data-theme="light"] body[data-tool="drp"] #root [class*="border-[rgba(255,255,255"] {
  border-color: var(--drp-line) !important;
}

html[data-theme="light"] body[data-tool="drp"] #root [class*="text-[rgba(245,245,245"] {
  color: var(--drp-muted) !important;
}

html[data-theme="light"] body[data-tool="drp"] #root .hero-band,
html[data-theme="light"] body[data-tool="drp"] #root .hero-meter {
  background:
    linear-gradient(135deg, rgba(168, 103, 18, 0.075), transparent 38%),
    rgba(255, 254, 250, 0.82) !important;
}

/* Internal verification and redirect surfaces also respect the chosen mode. */
html[data-theme="light"] body[data-tool="fcpxml-verify"] {
  color: #241d1b !important;
  background: #f1ede7 !important;
}

html[data-theme="light"] body[data-tool="fcpxml-verify"] p {
  color: rgba(36, 29, 27, 0.68) !important;
}

html[data-theme="light"] body[data-tool="fcpxml-verify"] pre {
  border-color: rgba(169, 71, 63, 0.18) !important;
  background: rgba(255, 255, 255, 0.62) !important;
}

.verify-theme-toggle {
  position: fixed;
  z-index: 20;
  top: 18px;
  right: 18px;
}

body[data-page="redirect"] {
  display: grid;
  place-items: center;
  min-height: 100vh;
  margin: 0;
  padding: 24px;
  color: var(--text, #f4f0e8);
  background: var(--bg, #090a09);
  font-family: Inter, "Avenir Next", "Helvetica Neue", "PingFang SC", sans-serif;
}

@media (max-width: 620px) {
  .toolbox-nav {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbox-nav__crumb {
    width: 100%;
  }

  .topbar__actions,
  .tool-nav__actions,
  .toolbox-nav__actions {
    width: 100%;
    justify-content: space-between;
  }

  .theme-toggle {
    min-height: 32px;
    padding: 5px 9px;
  }
}

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