/* Transparent is an additional theme. Every rule is isolated from dark/light. */
:root[data-theme="glass"] {
  color-scheme: light;
  --bg: #d4dfe9;
  --bg-soft: #cbd7e3;
  --panel: rgba(249, 252, 255, .48);
  --panel-strong: rgba(249, 252, 255, .70);
  --panel-soft: rgba(247, 250, 254, .36);
  --panel-lift: rgba(255, 255, 255, .75);
  --text: #344353;
  --text-strong: #182735;
  --muted: #536579;
  --muted-strong: #3b4e61;
  --line: rgba(50, 73, 96, .16);
  --line-strong: rgba(50, 73, 96, .27);
  --accent: #263b4e;
  --accent-strong: #152a3b;
  --accent-soft: rgba(40, 64, 85, .07);
  --text-on-accent: #ffffff;
  --green: #15803d;
  --red: #c93636;
  --amber: #946514;
  --surface-card: rgba(249, 252, 255, .48);
  --surface-input: rgba(255, 255, 255, .55);
  --surface-raised: rgba(246, 250, 255, .57);
  --surface-mid: rgba(248, 251, 255, .34);
  --surface-hover: rgba(255, 255, 255, .72);
  --surface-high: rgba(239, 246, 252, .76);
  --surface-night: rgba(248, 252, 255, .70);
  --sidebar-bg: rgba(244, 249, 254, .48);
  --shadow: 0 24px 70px rgba(41, 61, 83, .15);
  --shadow-soft: 0 6px 24px rgba(41, 61, 83, .07);
  --silver-edge: rgba(255, 255, 255, .76);
  --silver-wash: rgba(255, 255, 255, .15);
  --control-color-scheme: light;
  --glass-blur: 22px;
  --glass-panel: linear-gradient(145deg, rgba(255, 255, 255, .53), rgba(244, 249, 255, .30));
  --glass-border: rgba(255, 255, 255, .66);
  --glass-shadow: inset 0 1px 0 rgba(255, 255, 255, .78), 0 8px 32px rgba(47, 69, 92, .075);
}

:root[data-theme="glass"] .app {
  --muted: #536579;
  --muted-strong: #3b4e61;
  --ui-border: rgba(53, 77, 101, .17);
  --ui-card: rgba(249, 252, 255, .48);
  --ui-inset: rgba(247, 251, 255, .34);
  --ui-grid: rgba(39, 65, 89, .23);
  isolation: isolate;
  background: var(--bg);
}

/* One still wallpaper sits behind the whole workspace, including its rail.
   Only the wallpaper is softened; numbers, text and charts remain sharp. */
:root[data-theme="glass"] .app::before,
:root[data-theme="glass"] #authScreen::before {
  content: "";
  position: fixed;
  z-index: -1;
  inset: -50px;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 75% 5%, rgba(250, 252, 255, .92), transparent 56%),
    linear-gradient(135deg, rgba(209, 223, 237, .66), rgba(235, 242, 249, .36) 55%, rgba(186, 205, 222, .60)),
    url("../images/silver-ribbon.png") 18% 64% / min(1000px, 95vw) auto no-repeat,
    linear-gradient(135deg, #e5edf4, #afc2d4 56%, #dce7f1);
  filter: blur(16px) saturate(.55);
}

:root[data-theme="glass"] .app .app-main { background: transparent; }
:root[data-theme="glass"] .app .app-main > .topbar { border-bottom-color: rgba(49, 72, 96, .18); }

:root[data-theme="glass"] .app .app-sidebar {
  background: linear-gradient(155deg, rgba(255, 255, 255, .58), rgba(236, 245, 254, .35));
  border-right-color: var(--glass-border);
  box-shadow: inset -1px 0 0 rgba(255, 255, 255, .24), 8px 0 40px rgba(40, 64, 85, .035);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.15);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.15);
}

:root[data-theme="glass"] .app .app-sidebar :is(.nav-tab, .sidebar-action).active {
  color: #ffffff;
  border-color: rgba(29, 51, 71, .50);
  background: linear-gradient(145deg, rgba(53, 77, 99, .96), rgba(27, 48, 68, .96));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .19), 0 5px 15px rgba(37, 58, 79, .13);
}

:root[data-theme="glass"] .app .app-sidebar :is(.nav-tab, .sidebar-action).active .nav-icon { color: inherit; }
:root[data-theme="glass"] .app .sidebar-logout:hover { color: #b4232b; }

/* Frost the outer panels once. Rows and form fields inside them use simple
   translucent fills instead of adding more layers of backdrop blur. */
:root[data-theme="glass"] .app .card:not(.roi-dashboard-shell),
:root[data-theme="glass"] #roiPage :is(.roi-summary-strip article, .roi-entry-panel, .roi-table-card),
:root[data-theme="glass"] #adminPage :is(.admin-intro, .admin-stat, .admin-section),
:root[data-theme="glass"] #settingsPage :is(.settings-intro, .settings-card),
:root[data-theme="glass"] #fcMillionPage :is(.fc-club-header, .fc-goal-card, .fc-bench-panel, .fc-scoreboard-panel),
:root[data-theme="glass"] .app :is(.onboarding-card, .workspace-unavailable) {
  background: var(--glass-panel);
  border-color: var(--glass-border);
  box-shadow: var(--glass-shadow);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.12);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.12);
}

:root[data-theme="glass"] .app #roiPage .roi-dashboard-shell { background: transparent; border: 0; box-shadow: none; }

:root[data-theme="glass"] .app :is(.sidebar-menu-button, .sidebar-collapse-button, .theme-toggle-button, .storage-status) {
  background: rgba(250, 253, 255, .58);
  border-color: rgba(255, 255, 255, .72);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .8), 0 3px 12px rgba(47, 69, 92, .05);
}

:root[data-theme="glass"] .app :is(input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]), select, textarea) {
  background: var(--surface-input);
  border-color: rgba(49, 73, 97, .19);
  color: var(--text-strong);
  color-scheme: light;
  box-shadow: inset 0 1px 2px rgba(46, 69, 90, .025), 0 1px 0 rgba(255, 255, 255, .50);
}

:root[data-theme="glass"] :is(.app, #authScreen) select option { background: #edf3f8; color: #182735; }
:root[data-theme="glass"] .app :is(.primary-btn),
:root[data-theme="glass"] #authScreen .auth-submit {
  color: #ffffff;
  border-color: #263b4e;
  background: linear-gradient(145deg, #3a5269, #253b4e);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18), 0 4px 14px rgba(31, 51, 71, .13);
}
:root[data-theme="glass"] .app .primary-btn:hover,
:root[data-theme="glass"] #authScreen .auth-submit:hover { background: #20364a; border-color: #20364a; }

:root[data-theme="glass"] .app :is(.secondary-btn, .mini-action, .edit-btn):hover {
  background: rgba(255, 255, 255, .76);
  border-color: rgba(49, 73, 97, .3);
}

/* Popovers need a stronger glass surface when they overlap a chart or table. */
:root[data-theme="glass"] .app .workspace-popover,
:root[data-theme="glass"] .app #tradingPage .journal-period-panel {
  background: rgba(242, 248, 254, .91);
  border-color: rgba(255, 255, 255, .87);
  box-shadow: inset 0 1px 0 #ffffff, 0 22px 60px rgba(38, 60, 83, .20);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}
:root[data-theme="glass"] .app .announcements-panel > header { background: #edf4fa; }
:root[data-theme="glass"] .app .announcement-banner { background: rgba(246, 251, 255, .54); border-color: var(--glass-border); }
:root[data-theme="glass"] .app .announcement-kind.is-maintenance { color: #7f570d; }
:root[data-theme="glass"] #adminPage .admin-report-state.is-in-progress { color: var(--text-strong); }

/* Maintain the chart detail that would otherwise disappear against light glass. */
:root[data-theme="glass"] #tradingPage :is(.summary-metrics, .dashboard-visuals) {
  --green: #15803d;
  --red: #c93636;
  --amber: #946514;
}
:root[data-theme="glass"] .app #tradingPage :is(.snowflake-ring, .snowflake-axis) {
  stroke: rgba(37, 64, 88, .27);
  stroke-width: 1.25;
}
:root[data-theme="glass"] .app #tradingPage .snowflake-label { fill: #344b60; }
:root[data-theme="glass"] .app #tradingPage .snowflake-value-shape { fill: rgba(31, 145, 75, .16); stroke: #188348; stroke-width: 2.75; }
:root[data-theme="glass"] .app #tradingPage .snowflake-point { fill: #188348; stroke: #f4f9fe; stroke-width: 1.75; }
:root[data-theme="glass"] .app #tradingPage .gauge-track { stroke: rgba(41, 66, 90, .15); }
:root[data-theme="glass"] .app #tradingPage .edge-score-track span { border-right-color: #21384d; filter: none; }
:root[data-theme="glass"] .app #tradingPage .calendar-day.selected { border-color: #3b5873; box-shadow: inset 0 0 0 1px rgba(59, 88, 115, .34); }

/* Cut a real hole in the doughnut so its centre also reveals the wallpaper. */
:root[data-theme="glass"] .app #tradingPage .distribution-chart { background: transparent; }
:root[data-theme="glass"] .app #tradingPage .distribution-chart::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--pie-bg);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(58% - 1px), #000 58%);
  mask: radial-gradient(farthest-side, transparent calc(58% - 1px), #000 58%);
}
:root[data-theme="glass"] .app #tradingPage .distribution-chart::after { background: transparent; }

:root[data-theme="glass"] #roiPage { --roi-positive: #15803d; --roi-negative: #c93636; --roi-warning: #946514; }

/* Pitch and player geometry stay intact; its dark cards keep their light ink. */
:root[data-theme="glass"] #fcMillionPage .fc-slot-main { --text-strong: #f4f4f5; --muted-strong: #a1a1aa; color: #f4f4f5; }
:root[data-theme="glass"] #fcMillionPage .fc-player-size { color: #f4f4f5; }
:root[data-theme="glass"] #fcMillionPage .fc-slot-placeholder { color: #a1a1aa; }

/* Authentication shares the wallpaper without changing the public landing. */
:root[data-theme="glass"] #authScreen { isolation: isolate; background: var(--bg); }
:root[data-theme="glass"] #authScreen .auth-card {
  background: linear-gradient(145deg, rgba(255, 255, 255, .67), rgba(241, 248, 255, .47));
  border-color: rgba(255, 255, 255, .8);
  box-shadow: inset 0 1px 0 #ffffff, var(--shadow);
  backdrop-filter: blur(26px) saturate(1.1);
  -webkit-backdrop-filter: blur(26px) saturate(1.1);
}

:root[data-theme="glass"] :is(#tradeImageDialog, #payoutCertificateDialog) {
  background: rgba(244, 250, 255, .94);
  border-color: rgba(255, 255, 255, .85);
  box-shadow: inset 0 1px 0 #ffffff, 0 24px 80px rgba(21, 42, 61, .24);
}
:root[data-theme="glass"] :is(#tradeImageDialog, #payoutCertificateDialog)::backdrop {
  background: rgba(48, 72, 96, .33);
  backdrop-filter: blur(13px);
  -webkit-backdrop-filter: blur(13px);
}

@media (max-width: 760px) {
  :root[data-theme="glass"] { --glass-blur: 12px; }
  :root[data-theme="glass"] .app::before,
  :root[data-theme="glass"] #authScreen::before {
    inset: 0;
    background:
      radial-gradient(ellipse at 10% 36%, rgba(162, 185, 207, .6), transparent 48%),
      radial-gradient(ellipse at 90% 70%, rgba(183, 205, 226, .6), transparent 52%),
      linear-gradient(145deg, #e8eff5, #cedce9 60%, #e2ecf4);
    filter: none;
  }
  :root[data-theme="glass"] .app .app-sidebar { background: rgba(236, 245, 253, .91); }
}

/* A readable surface remains when blur is unsupported or transparency is reduced. */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root[data-theme="glass"] { --glass-panel: #edf3f8; --sidebar-bg: #e7eff6; }
  :root[data-theme="glass"] .app .app-sidebar { background: #e7eff6; }
  :root[data-theme="glass"] #authScreen .auth-card { background: #edf3f8; }
}

@media (prefers-reduced-transparency: reduce) {
  :root[data-theme="glass"] {
    --glass-blur: 0px;
    --glass-panel: #edf3f8;
    --surface-card: #edf3f8;
    --surface-input: #f8fbfe;
    --surface-raised: #e7eff6;
    --surface-mid: #e7eff6;
    --surface-hover: #f8fbfe;
  }
  :root[data-theme="glass"] .app { --ui-card: #edf3f8; --ui-inset: #e7eff6; }
  :root[data-theme="glass"] .app::before,
  :root[data-theme="glass"] #authScreen::before { display: none; }
  :root[data-theme="glass"] .app .app-sidebar,
  :root[data-theme="glass"] #authScreen .auth-card { background: #edf3f8; backdrop-filter: none; -webkit-backdrop-filter: none; }
  :root[data-theme="glass"] .app .workspace-popover,
  :root[data-theme="glass"] .app #tradingPage .journal-period-panel,
  :root[data-theme="glass"] :is(#tradeImageDialog, #payoutCertificateDialog) { background: #f1f6fb; backdrop-filter: none; -webkit-backdrop-filter: none; }
}
