/* ── Smooth theme morph (respect reduced motion) ───────────────── */
@media (prefers-reduced-motion: no-preference) {
  body {
    transition: background-color 0.24s ease-out, color 0.2s ease-out;
  }
  #toolbar,
  #sidebar,
  .header,
  .auth-card,
  .settings-card,
  .card,
  .cfg-box,
  .compare-col,
  .landing-nav-bar,
  .waitlist-top-bar,
  #splash,
  #loading,
  .user-pill,
  .filter-bar,
  .stats-bar,
  .page-header,
  .rpt-nav,
  .rpt-basic-card,
  .shell nav,
  .shell main,
  .top-bar,
  .page,
  .form-wrap,
  .drop-zone,
  .cfg-run-btn,
  .tb-brand {
    transition:
      background-color 0.24s ease-out,
      color 0.18s ease-out,
      border-color 0.24s ease-out,
      box-shadow 0.24s ease-out;
  }
}

/* Shared light palette — load after each page’s :root dark tokens */
html[data-theme="light"] {
  --bg:       #f0f0f4;
  --surface:  #ffffff;
  --card:     #f7f7fa;
  --border:   #e0e0ea;
  --border2:  #d0d0dc;

  --text:     #14141c;
  --muted:    #5c5c6e;
  --faint:    #e8e8f0;

  --green:    #00c96b;
  --green-d:  #00a855;
  --green-bg: rgba(0,201,107,.1);
  --red:      #e03d4d;
  --red-bg:   rgba(255,77,94,.1);
  --gold:     #c49a2a;
  --gold-d:   #a67d1f;
  --gold-bg:  rgba(196,154,42,.12);
  --blue:     #3d8ae6;
  --blue-bg:  rgba(77,159,255,.12);

  --ink:      #14141c;
  --ink2:     #d0d0dc;
  --ink3:     #5c5c6e;
  --ink4:     #3a3a48;
  --paper:    #f0f0f4;
  --cream:    #f7f7fa;
  --rule:     #e0e0ea;
  --rule2:    #d0d0dc;
  --green-l:  rgba(0,201,107,.1);
  --red-l:    rgba(255,77,94,.1);
  --gold-l:   rgba(196,154,42,.12);
  --blue-l:   rgba(77,159,255,.12);

  --radius:   6px;
  --chart-grid: rgba(0,0,0,.08);
  --chart-tick: #5c5c6e;
}

html[data-theme="light"] pre {
  background: #eef0f6;
  border-color: var(--border2);
  color: #2a2a38;
}
html[data-theme="light"] code {
  background: #e4e6ee;
  border-color: var(--border2);
  color: #1a1a24;
}

/* ── Theme switch (toggle) ───────────────────────────────────── */
.edgeable-theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: var(--muted, #72728a);
  -webkit-tap-highlight-color: transparent;
}
.edgeable-theme-switch:hover {
  color: var(--gold, #e8b84b);
}
.edgeable-theme-switch:focus-visible {
  outline: 2px solid var(--gold, #e8b84b);
  outline-offset: 3px;
  border-radius: 4px;
}

.edgeable-theme-switch__track {
  position: relative;
  width: 42px;
  height: 24px;
  flex-shrink: 0;
  border-radius: 999px;
  background: var(--border, #252530);
  border: 1px solid var(--border2, #30303e);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.18);
}
.edgeable-theme-switch__thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--text, #e4e4ee), var(--muted, #72728a));
  box-shadow: 0 1px 4px rgba(0,0,0,.35);
}
.edgeable-theme-switch__label {
  font-family: var(--mono, 'DM Mono', monospace);
  font-size: 0.62rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

/* Dark theme = switch on (thumb right, gold accent) */
.edgeable-theme-switch[aria-checked="true"] .edgeable-theme-switch__thumb {
  transform: translateX(18px);
  background: linear-gradient(145deg, #fff8e8, #e8b84b);
  box-shadow: 0 1px 5px rgba(232, 184, 75, 0.45);
}
.edgeable-theme-switch[aria-checked="true"] .edgeable-theme-switch__track {
  background: rgba(232, 184, 75, 0.14);
  border-color: rgba(232, 184, 75, 0.45);
  box-shadow: inset 0 1px 3px rgba(0,0,0,.12), 0 0 0 1px rgba(232, 184, 75, 0.08);
}

html[data-theme="light"] .edgeable-theme-switch:not([aria-checked="true"]) .edgeable-theme-switch__track {
  background: #dfe1ea;
  border-color: #c8cad6;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.06);
}
html[data-theme="light"] .edgeable-theme-switch:not([aria-checked="true"]) .edgeable-theme-switch__thumb {
  background: linear-gradient(145deg, #ffffff, #e8e9f0);
  box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
html[data-theme="light"] .edgeable-theme-switch[aria-checked="true"] .edgeable-theme-switch__track {
  background: rgba(196, 154, 42, 0.2);
  border-color: rgba(196, 154, 42, 0.45);
}

@media (prefers-reduced-motion: no-preference) {
  .edgeable-theme-switch__thumb {
    transition: transform 0.22s cubic-bezier(0.34, 1.25, 0.64, 1), background 0.2s ease, box-shadow 0.2s ease;
  }
  .edgeable-theme-switch__track {
    transition: background-color 0.22s ease-out, border-color 0.22s ease-out, box-shadow 0.22s ease-out;
  }
  .edgeable-theme-switch__label {
    transition: color 0.18s ease-out;
  }
}

/* Sidebar row */
.edgeable-theme-switch--sidebar {
  width: 100%;
  padding: 0.75rem 1.25rem;
  border-left: 3px solid transparent;
  justify-content: flex-start;
  text-align: left;
}
.edgeable-theme-switch--sidebar:hover {
  background: var(--card, #18181f);
  border-left-color: var(--gold, #e8b84b);
}

/* App header (replaces .btn) */
.edgeable-theme-switch--header .edgeable-theme-switch__label {
  font-size: 0.58rem;
}

/* Landing / waitlist / guide nav */
.edgeable-theme-switch--nav .edgeable-theme-switch__label {
  font-size: 0.58rem;
}

/* Compare toolbar */
.edgeable-theme-switch--compact {
  gap: 0.45rem;
}
.edgeable-theme-switch--compact .edgeable-theme-switch__track {
  width: 38px;
  height: 22px;
}
.edgeable-theme-switch--compact .edgeable-theme-switch__thumb {
  width: 16px;
  height: 16px;
}
.edgeable-theme-switch--compact[aria-checked="true"] .edgeable-theme-switch__thumb {
  transform: translateX(18px);
}

/* Auth pages — fixed corner */
.edgeable-theme-switch--float {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10000;
  padding: 0.4rem 0.65rem;
  background: var(--surface, #111116);
  border: 1px solid var(--border2, #30303e);
  border-radius: 999px;
  box-shadow: 0 4px 24px rgba(0,0,0,.35);
}
.edgeable-theme-switch--float:hover {
  border-color: var(--gold, #e8b84b);
}
html[data-theme="light"] .edgeable-theme-switch--float {
  box-shadow: 0 4px 20px rgba(0,0,0,.1);
}

html[data-theme="light"] .landing-nav-bar {
  background: rgba(255,255,255,.92) !important;
  border-bottom-color: var(--border) !important;
}
html[data-theme="light"] .waitlist-top-bar {
  background: rgba(255,255,255,.9) !important;
  border-bottom-color: var(--border) !important;
}

/* Nav profile avatar (landing + waitlist) */
.edgeable-nav-profile-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.edgeable-nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border2, #30303e);
  vertical-align: middle;
}
.edgeable-nav-avatar-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display, "Bebas Neue", sans-serif);
  font-size: 0.85rem;
  color: var(--gold, #e8b84b);
  background: var(--gold-bg, rgba(232, 184, 75, 0.12));
  border: 1px solid rgba(232, 184, 75, 0.35);
}
.edgeable-waitlist-avatar {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid var(--border2, #30303e);
}
.edgeable-waitlist-avatar-placeholder {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display, "Bebas Neue", sans-serif);
  font-size: 0.65rem;
  color: var(--gold, #e8b84b);
  background: var(--gold-bg, rgba(232, 184, 75, 0.12));
  border: 1px solid rgba(232, 184, 75, 0.35);
}

/* ── Collapsible app sidebar (Dashboard, Analyses, etc.) ───────────────── */
.edgeable-sidebar-collapse-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.45rem 0.5rem 0.65rem;
  margin-bottom: 0.15rem;
  border: none;
  border-bottom: 1px solid var(--border, #252530);
  background: transparent;
  color: var(--muted, #72728a);
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
}
.edgeable-sidebar-collapse-btn:hover {
  color: var(--gold, #e8b84b);
  background: var(--card, #18181f);
}

#sidebar.collapsed {
  width: 56px;
  min-width: 56px;
}
#sidebar.collapsed .sidebar-divider {
  margin: 0.4rem 0.5rem;
}
#sidebar.collapsed .sidebar-link {
  justify-content: center;
  padding: 0.72rem 0.35rem;
  gap: 0;
  font-size: 0;
  letter-spacing: 0;
}
#sidebar.collapsed .sidebar-link svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
#sidebar.collapsed .edgeable-theme-switch__label {
  display: none;
}
#sidebar.collapsed .edgeable-theme-switch {
  justify-content: center;
  padding: 0.5rem 0.35rem;
  width: 100%;
}
