/* R121: route isolation, complete Light/Dark/System styling, and button/navigation repair. */
:root {
  --r121-canvas: #05050a;
  --r121-canvas-soft: #0b0a13;
  --r121-surface: rgba(18,18,29,.66);
  --r121-surface-solid: #11111b;
  --r121-surface-hover: rgba(255,255,255,.07);
  --r121-text: #f7f6f3;
  --r121-muted: rgba(247,246,243,.56);
  --r121-faint: rgba(247,246,243,.34);
  --r121-line: rgba(255,255,255,.095);
  --r121-line-strong: rgba(255,255,255,.15);
  --r121-control: rgba(255,255,255,.045);
  --r121-control-hover: rgba(255,255,255,.09);
  --r121-shadow: 0 26px 80px -42px rgba(82,39,205,.62), inset 0 1px 0 rgba(255,255,255,.045);
  --r121-purple: #8a4fff;
  --r121-amber: #ffb067;
  --r121-sky: #5bcef7;
  --r121-green: #74e3b1;
  color-scheme: dark;
}

html[data-theme="light"] {
  --r121-canvas: #f5f3f8;
  --r121-canvas-soft: #ebe8f1;
  --r121-surface: rgba(255,255,255,.80);
  --r121-surface-solid: #ffffff;
  --r121-surface-hover: rgba(92,55,169,.075);
  --r121-text: #17131f;
  --r121-muted: rgba(23,19,31,.62);
  --r121-faint: rgba(23,19,31,.43);
  --r121-line: rgba(40,28,62,.115);
  --r121-line-strong: rgba(40,28,62,.18);
  --r121-control: rgba(255,255,255,.82);
  --r121-control-hover: #ffffff;
  --r121-shadow: 0 28px 76px -46px rgba(75,45,139,.34), inset 0 1px 0 rgba(255,255,255,.82);
  color-scheme: light;
}

html { background: var(--r121-canvas) !important; }
html[data-theme="dark"] body.r120-rice-ui,
html[data-theme="light"] body.r120-rice-ui {
  color: var(--r121-text) !important;
  background:
    radial-gradient(850px 600px at 88% -6%, color-mix(in srgb, var(--r121-purple) 18%, transparent), transparent 62%),
    radial-gradient(760px 560px at -12% 108%, color-mix(in srgb, var(--r121-amber) 10%, transparent), transparent 63%),
    var(--r121-canvas) !important;
}

/* The dashboard is a real route, not a permanent overlay. */
body.r120-rice-ui:not([data-active-page="dashboard"]) #dashboardHome,
body.r120-rice-ui #dashboardHome.app-page-hidden,
body.r120-rice-ui [data-app-page="dashboard"].app-page-hidden {
  display: none !important;
}
body.r120-rice-ui[data-active-page="dashboard"] #dashboardHome:not(.app-page-hidden) {
  display: block !important;
}

/* Keep the RICE rail fixed to the viewport and prevent background content bleeding beside it. */
body.r120-rice-ui .section-nav.canva-rail {
  left: 0 !important;
  top: 0 !important;
  bottom: 0 !important;
  width: 88px !important;
  overflow: visible !important;
  background: color-mix(in srgb, var(--r121-canvas) 91%, transparent) !important;
  border-right: 1px solid var(--r121-line) !important;
  box-shadow: 18px 0 50px -44px rgba(68,31,143,.42) !important;
}
body.r120-rice-ui .section-nav.canva-rail .nav-item,
body.r120-rice-ui .rail-create,
body.r120-rice-ui .rail-footer-button {
  color: var(--r121-muted) !important;
}
body.r120-rice-ui .section-nav.canva-rail .nav-item:hover,
body.r120-rice-ui .rail-create:hover,
body.r120-rice-ui .rail-footer-button:hover {
  color: var(--r121-text) !important;
  background: var(--r121-surface-hover) !important;
  border-color: var(--r121-line) !important;
}
body.r120-rice-ui .section-nav.canva-rail .nav-item.active {
  color: var(--r121-text) !important;
  background: var(--r121-surface) !important;
  border-color: color-mix(in srgb, var(--r121-purple) 40%, var(--r121-line)) !important;
  box-shadow: 0 16px 46px -24px color-mix(in srgb, var(--r121-purple) 75%, transparent), inset 0 0 0 1px color-mix(in srgb, var(--r121-purple) 18%, transparent) !important;
}
html[data-theme="light"] body.r120-rice-ui .rail-logo,
html[data-theme="light"] body.r120-rice-ui .rail-avatar {
  color: #211a2d !important;
  background: rgba(255,255,255,.90) !important;
  border-color: rgba(40,28,62,.13) !important;
}
html[data-theme="light"] body.r120-rice-ui .section-nav.canva-rail .nav-item > span:last-child {
  color: #fff !important;
  background: rgba(24,18,34,.94) !important;
}

/* Top command bar: one appearance control, no duplicate sun button. */
body.r120-rice-ui .app-header {
  background: linear-gradient(180deg, color-mix(in srgb, var(--r121-canvas) 96%, transparent), color-mix(in srgb, var(--r121-canvas) 78%, transparent) 74%, transparent) !important;
  border-bottom: 1px solid color-mix(in srgb, var(--r121-line) 55%, transparent) !important;
}
body.r120-rice-ui .app-header .eyebrow { color: var(--r121-muted) !important; }
body.r120-rice-ui .r119-command-trigger,
body.r120-rice-ui .topbar-health,
body.r120-rice-ui .premium-theme-switcher,
body.r120-rice-ui .r120-notification {
  color: var(--r121-text) !important;
  background: var(--r121-control) !important;
  border-color: var(--r121-line) !important;
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 8%, transparent) !important;
}
body.r120-rice-ui .r119-command-trigger span,
body.r120-rice-ui .r119-command-trigger kbd,
body.r120-rice-ui .topbar-health span { color: var(--r121-muted) !important; }
body.r120-rice-ui .premium-theme-switcher {
  display: inline-grid !important;
  grid-template-columns: repeat(3, 36px) !important;
  align-items: center !important;
  gap: 2px !important;
  min-width: 116px !important;
  width: 116px !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 3px !important;
  border-radius: 15px !important;
  overflow: hidden !important;
}
body.r120-rice-ui .premium-theme-switcher button {
  display: grid !important;
  place-items: center !important;
  width: 36px !important;
  min-width: 36px !important;
  height: 36px !important;
  min-height: 36px !important;
  padding: 0 !important;
  color: var(--r121-muted) !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 11px !important;
  box-shadow: none !important;
  transform: none !important;
}
body.r120-rice-ui .premium-theme-switcher button:hover {
  color: var(--r121-text) !important;
  background: var(--r121-surface-hover) !important;
}
body.r120-rice-ui .premium-theme-switcher button.active {
  color: var(--r121-text) !important;
  background: var(--r121-surface-solid) !important;
  box-shadow: 0 7px 18px rgba(17,10,30,.14), inset 0 0 0 1px var(--r121-line) !important;
}
body.r120-rice-ui .app-header #themeButton { display: none !important; }
body.r120-rice-ui .r120-notification {
  display: grid !important;
  place-items: center !important;
  width: 44px !important;
  min-width: 44px !important;
  height: 44px !important;
  min-height: 44px !important;
  padding: 0 !important;
  border-radius: 50% !important;
}
body.r120-rice-ui .r120-notification:hover { background: var(--r121-control-hover) !important; }
body.r120-rice-ui .topbar-health strong { color: #20b777 !important; }
html[data-theme="light"] .r120-ready-switch i { background: #fff !important; box-shadow: 0 2px 8px rgba(30,18,48,.24); }

/* Dashboard palette. */
.r120-dashboard { color: var(--r121-text) !important; }
.r120-overview-heading h2,
.r120-overview-heading h2 span,
.r120-kpi-value,
.r120-card-heading h3,
.r120-quick-launch h3 { color: var(--r121-text) !important; }
.r120-overview-heading p,
.r120-kpi-head,
.r120-kpi-card p,
.r120-card-heading span,
.r120-chart-footer,
.r120-terminal-title,
.r120-pipeline-summary,
.r120-quick-launch header span,
.r120-module-grid small { color: var(--r121-muted) !important; }
.r120-kpi-card,
.r120-glass-card,
.r120-quick-launch {
  color: var(--r121-text) !important;
  background: var(--r121-surface) !important;
  border-color: var(--r121-line) !important;
  box-shadow: var(--r121-shadow) !important;
}
.r120-kpi-card.pink { background: linear-gradient(135deg, color-mix(in srgb, var(--r121-purple) 28%, var(--r121-surface-solid)), color-mix(in srgb, #6e2ac0 22%, var(--r121-surface-solid))) !important; }
.r120-kpi-icon,
.r120-live-pill { color: var(--r121-text) !important; background: var(--r121-control) !important; border-color: var(--r121-line) !important; }
.r120-chart-grid path { stroke: color-mix(in srgb, var(--r121-text) 7%, transparent) !important; }

/* High-specificity repair for the white blank dashboard buttons shown in R120. */
body.r120-rice-ui .r120-pipeline-card .r120-pipeline-list > button,
body.r120-rice-ui .r120-quick-launch .r120-module-grid > button {
  color: var(--r121-text) !important;
  background: var(--r121-control) !important;
  border: 1px solid var(--r121-line) !important;
  box-shadow: none !important;
  opacity: 1 !important;
}
body.r120-rice-ui .r120-pipeline-card .r120-pipeline-list > button:hover,
body.r120-rice-ui .r120-quick-launch .r120-module-grid > button:hover {
  color: var(--r121-text) !important;
  background: var(--r121-control-hover) !important;
  border-color: color-mix(in srgb, var(--r121-purple) 35%, var(--r121-line)) !important;
}
body.r120-rice-ui .r120-pipeline-list button b,
body.r120-rice-ui .r120-module-grid button b { color: var(--r121-text) !important; }
body.r120-rice-ui .r120-pipeline-list button small,
body.r120-rice-ui .r120-module-grid button small { color: var(--r121-muted) !important; }
body.r120-rice-ui .r120-chart-footer button,
body.r120-rice-ui .r120-quick-launch header button {
  color: var(--r121-muted) !important;
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
}
body.r120-rice-ui .r120-chart-footer button:hover,
body.r120-rice-ui .r120-quick-launch header button:hover { color: var(--r121-text) !important; }

/* Complete light mode for the original R103 workspace pages. */
html[data-theme="light"] body.r120-rice-ui .card,
html[data-theme="light"] body.r120-rice-ui .workspace-card,
html[data-theme="light"] body.r120-rice-ui .subpanel,
html[data-theme="light"] body.r120-rice-ui .automation-preflight-shell,
html[data-theme="light"] body.r120-rice-ui .workflow-choice-panel,
html[data-theme="light"] body.r120-rice-ui .reference-examples-panel,
html[data-theme="light"] body.r120-rice-ui .competitor-research-panel,
html[data-theme="light"] body.r120-rice-ui .api-setup-card,
html[data-theme="light"] body.r120-rice-ui .deployment-card,
html[data-theme="light"] body.r120-rice-ui .results-card,
html[data-theme="light"] body.r120-rice-ui .batch-results-card,
html[data-theme="light"] body.r120-rice-ui .digital-template-builder,
html[data-theme="light"] body.r120-rice-ui .variation-analysis-card,
html[data-theme="light"] body.r120-rice-ui .product-history-card,
html[data-theme="light"] body.r120-rice-ui .batch-result-card,
html[data-theme="light"] body.r120-rice-ui .approval-product-card,
html[data-theme="light"] body.r120-rice-ui .variation-result-card {
  color: var(--r121-text) !important;
  background: rgba(255,255,255,.84) !important;
  border-color: var(--r121-line) !important;
  box-shadow: 0 24px 64px -46px rgba(63,37,119,.28), inset 0 1px 0 rgba(255,255,255,.96) !important;
}
html[data-theme="light"] body.r120-rice-ui h1,
html[data-theme="light"] body.r120-rice-ui h2,
html[data-theme="light"] body.r120-rice-ui h3,
html[data-theme="light"] body.r120-rice-ui h4,
html[data-theme="light"] body.r120-rice-ui strong,
html[data-theme="light"] body.r120-rice-ui label { color: var(--r121-text) !important; }
html[data-theme="light"] body.r120-rice-ui p,
html[data-theme="light"] body.r120-rice-ui small,
html[data-theme="light"] body.r120-rice-ui .help,
html[data-theme="light"] body.r120-rice-ui .field-help { color: var(--r121-muted) !important; }
html[data-theme="light"] body.r120-rice-ui input,
html[data-theme="light"] body.r120-rice-ui textarea,
html[data-theme="light"] body.r120-rice-ui select {
  color: var(--r121-text) !important;
  background: rgba(255,255,255,.92) !important;
  border-color: var(--r121-line-strong) !important;
  box-shadow: inset 0 1px 2px rgba(31,18,53,.035) !important;
}
html[data-theme="light"] body.r120-rice-ui input::placeholder,
html[data-theme="light"] body.r120-rice-ui textarea::placeholder { color: rgba(23,19,31,.40) !important; }
html[data-theme="light"] body.r120-rice-ui button.secondary,
html[data-theme="light"] body.r120-rice-ui button.ghost,
html[data-theme="light"] body.r120-rice-ui a.button.secondary,
html[data-theme="light"] body.r120-rice-ui .icon-button.secondary {
  color: #241b31 !important;
  background: rgba(255,255,255,.86) !important;
  border-color: rgba(40,28,62,.14) !important;
}
html[data-theme="light"] body.r120-rice-ui button.secondary:hover,
html[data-theme="light"] body.r120-rice-ui button.ghost:hover { background: #fff !important; }
html[data-theme="light"] body.r120-rice-ui .status,
html[data-theme="light"] body.r120-rice-ui .pill,
html[data-theme="light"] body.r120-rice-ui .tag,
html[data-theme="light"] body.r120-rice-ui .history-status {
  color: #43384f !important;
  background: rgba(255,255,255,.78) !important;
  border-color: rgba(40,28,62,.12) !important;
}
html[data-theme="light"] body.r120-rice-ui .drop-zone,
html[data-theme="light"] body.r120-rice-ui .csv-drop-card,
html[data-theme="light"] body.r120-rice-ui .reference-drop-card,
html[data-theme="light"] body.r120-rice-ui .digital-file-drop-card,
html[data-theme="light"] body.r120-rice-ui .variation-keyword-drop-zone,
html[data-theme="light"] body.r120-rice-ui .upload-zone {
  color: #51465d !important;
  background: rgba(255,255,255,.55) !important;
  border-color: rgba(40,28,62,.16) !important;
}
html[data-theme="light"] body.r120-rice-ui table {
  color: var(--r121-text) !important;
  background: rgba(255,255,255,.85) !important;
  border-color: var(--r121-line) !important;
}
html[data-theme="light"] body.r120-rice-ui thead th,
html[data-theme="light"] body.r120-rice-ui table th {
  color: #584b66 !important;
  background: rgba(79,58,112,.055) !important;
  border-color: var(--r121-line) !important;
}
html[data-theme="light"] body.r120-rice-ui tbody td { border-color: rgba(40,28,62,.08) !important; }
html[data-theme="light"] body.r120-rice-ui tbody tr:nth-child(even) { background: rgba(72,48,113,.025) !important; }
html[data-theme="light"] body.r120-rice-ui tbody tr:hover { background: rgba(138,79,255,.065) !important; }

/* Light mode dock and command palette. */
body.r120-rice-ui .r119-dock-inner {
  background: color-mix(in srgb, var(--r121-surface-solid) 87%, transparent) !important;
  border-color: var(--r121-line) !important;
  box-shadow: 0 24px 70px rgba(12,8,22,.18), inset 0 1px 0 color-mix(in srgb, #fff 28%, transparent) !important;
}
body.r120-rice-ui .r119-dock-button { color: var(--r121-muted) !important; }
body.r120-rice-ui .r119-dock-icon { color: var(--r121-text) !important; background: var(--r121-control) !important; border-color: var(--r121-line) !important; }
body.r120-rice-ui .r119-dock-button:hover { color: var(--r121-text) !important; }
html[data-theme="light"] .r119-command-overlay { background: rgba(28,20,40,.30) !important; }
html[data-theme="light"] .r119-command-panel {
  color: var(--r121-text) !important;
  background: rgba(255,255,255,.96) !important;
  border-color: rgba(40,28,62,.15) !important;
  box-shadow: 0 42px 120px rgba(45,29,72,.24) !important;
}
html[data-theme="light"] .r119-command-search { border-color: rgba(40,28,62,.10) !important; }
html[data-theme="light"] .r119-command-search input { color: var(--r121-text) !important; }
html[data-theme="light"] .r119-command-search svg,
html[data-theme="light"] .r119-command-search kbd,
html[data-theme="light"] .r119-command-group-label,
html[data-theme="light"] .r119-command-item small { color: var(--r121-muted) !important; }
html[data-theme="light"] .r119-command-item { color: #3d324a !important; }
html[data-theme="light"] .r119-command-item:hover { color: #17131f !important; background: rgba(138,79,255,.075) !important; }

/* Preserve responsive behavior without hiding the Home route or clipping the rail. */
@media (max-width: 880px) and (min-width: 621px) {
  body.r120-rice-ui .section-nav.canva-rail { width: 68px !important; }
}
@media (max-width: 620px) {
  body.r120-rice-ui .premium-theme-switcher { display: none !important; }
  body.r120-rice-ui .r120-notification { display: none !important; }
}
