@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;1,9..40,400&family=DM+Mono:wght@400;500&display=swap');


:root {
  --space-black: #03070d;
  --navy-abyss: #07111D;
  --navy-deep: #050B14;
  --navy-base: #0B1726;
  --navy-raised: #102036;
  --navy-surface: #132A45;
  --navy-border: #29405E;
  --navy-rim: #3A587C;
  --amber: #D97706;
  --amber-bright: #F59E0B;
  --amber-hot: #FCD34D;
  --brand-warm-white: #FEFCF3;
  --brand-cool-gray: #F7FAFC;
  --brand-night-navy: #1E3A5F;
  --brand-slate-dark: #2D3E50;
  --brand-slate-mid: #4A5568;
  --brand-slate-light: #718096;
  --brand-amber: #D97706;
  --brand-copper: #B45309;
  --brand-amber-light: #F59E0B;
  --brand-cream: #FFFBEB;
  --text-hi: #F6F1E8;
  --text: #D9E2EF;
  --text-mid: #9AA8BA;
  --text-dim: #6E7F93;
  --scroll-track: #050B14;
  --scroll-thumb: #3A587C;
  --scroll-thumb-hover: #4A688C;
  --radius-lg: 18px;
  --radius-md: 13px;
  --radius-sm: 9px;
}

/* ── Semantic tokens (dark default = design reference) ───── */
:root {
  --bg-page:          #03070d;
  --bg-chassis:       #07111D;
  --bg-panel:         #0B1726;
  --bg-panel-hi:      #102036;
  --bg-input:         #050B14;
  --bg-well:          #050B14;
  --bg-well-strong:   #02060B;
  --bg-rail:          linear-gradient(180deg, #102036, #050B14);
  --surface-raised:   linear-gradient(180deg, #102036, #0B1726);
  --surface-pressed:  linear-gradient(180deg, #081321, #0B1726);
  --surface-inset:    linear-gradient(180deg, #02060B, #050B14);
  --face:             #132A45;
  --face-pressed:     #081321;
  --rim-color:        rgba(74,104,138,.74);
  --seam-color:       rgba(255,255,255,.10);
  --focus-ring:       0 0 0 3px rgba(245,158,11,.48);
  --disabled-face:    rgba(110,127,147,.45);
  --status-success:   #7EE0B0;
  --status-warning:   var(--amber-bright);
  --status-error:     #FFD3D3;
  --status-info:      #60A5FA;
  --border-color:     #29405E;
  --border-strong:    #3A587C;
  --text-primary:     #F6F1E8;
  --text-secondary:   #D9E2EF;
  --text-muted:       #9AA8BA;
  --text-faint:       #6E7F93;
  --scroll-track-color:      var(--scroll-track);
  --scroll-thumb-color:      var(--scroll-thumb);
  --scroll-thumb-hover-color: var(--scroll-thumb-hover);
  --header-bg:        linear-gradient(180deg, #102036, #0B1726);
  --card-bg:          linear-gradient(180deg, #102036, #0B1726);
  --card-border:      #29405E;
  --input-bg:         #050B14;
  --input-border:     #29405E;
  --modal-bg:         rgba(3,7,13,.72);
  --shadow-card:      0 12px 28px rgba(0,0,0,.24);
  --shadow-deep:      rgba(0,0,0,.42);
  --shadow-soft:      rgba(0,0,0,.24);
  --link-color:       var(--amber-bright);
  --link-hover:       var(--amber-hot);

  /* Compatibility aliases for page-local CSS */
  --bg:               var(--bg-page);
  --panel:            var(--bg-panel);
  --panel-hi:         var(--bg-panel-hi);
  --line:             var(--border-color);
  --line-hi:          var(--border-strong);
  --accent:           var(--amber);
  --accent-hi:        var(--amber-bright);
  --muted:            var(--text-muted);
}

/* ── Light theme overrides (physical inverse) ────────────── */
html[data-theme="light"] {
  --bg-page:          #EFE3D0;
  --bg-chassis:       #FEFCF3;
  --bg-panel:         #FFFBEB;
  --bg-panel-hi:      #FFF7E8;
  --bg-input:         #F7FAFC;
  --bg-well:          #F7FAFC;
  --bg-well-strong:   #EDE5D7;
  --bg-rail:          linear-gradient(180deg, #1E3A5F, #102036);
  --surface-raised:   linear-gradient(180deg, #FFF7E8, #FFFBEB);
  --surface-pressed:  linear-gradient(180deg, #EADCC8, #FEFCF3);
  --surface-inset:    linear-gradient(180deg, #EDE5D7, #F7FAFC);
  --face:             #FEFCF3;
  --face-pressed:     #EADCC8;
  --rim-color:        rgba(115,90,61,.42);
  --seam-color:       rgba(255,255,255,.88);
  --focus-ring:       0 0 0 3px rgba(245,158,11,.28);
  --disabled-face:    rgba(113,128,150,.35);
  --status-success:   #0B684D;
  --status-warning:   var(--brand-amber);
  --status-error:     #8E1A1A;
  --status-info:      #2563EB;
  --border-color:     #D8CAB5;
  --border-strong:    #BFAE97;
  --text-primary:     #1E3A5F;
  --text-secondary:   #2D3E50;
  --text-muted:       #4A5568;
  --text-faint:       #718096;
  --scroll-track-color:      #EDE5D7;
  --scroll-thumb-color:      #BFAE97;
  --scroll-thumb-hover-color: #A89880;
  --header-bg:        linear-gradient(180deg, #1E3A5F, #102036);
  --card-bg:          linear-gradient(180deg, #FFF7E8, #FFFBEB);
  --card-border:      #D8CAB5;
  --input-bg:         #F7FAFC;
  --input-border:     #D8CAB5;
  --modal-bg:         rgba(30,58,95,.45);
  --shadow-card:      0 12px 28px rgba(41,50,58,.12);
  --shadow-deep:      rgba(41,50,58,.18);
  --shadow-soft:      rgba(41,50,58,.12);
  --link-color:       var(--brand-copper);
  --link-hover:       var(--brand-amber);

  --navy-abyss:       #FEFCF3;
  --navy-deep:        #F7FAFC;
  --navy-base:        #FFFBEB;
  --navy-raised:      #FFF7E8;
  --navy-surface:     #FEFCF3;
  --navy-border:      #D8CAB5;
  --navy-rim:         #BFAE97;
  --text-hi:          #1E3A5F;
  --text:             #2D3E50;
  --text-mid:         #4A5568;
  --text-dim:         #718096;
  --scroll-track:     #EDE5D7;
  --scroll-thumb:     #BFAE97;
  --scroll-thumb-hover: #A89880;
}

/* ── Body background — theme-aware ──────────────────────── */
html[data-theme="light"] body,
html[data-theme="light"] body.rb-theme-body {
  background-color: var(--bg-page) !important;
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 35%, rgba(254,252,243,0.92) 0%, transparent 70%),
    radial-gradient(ellipse 42% 30% at 50% 52%, rgba(217,119,6,0.05) 0%, transparent 60%),
    linear-gradient(165deg, var(--bg-page) 0%, var(--bg-chassis) 55%, var(--bg-chassis) 100%) !important;
  background-repeat: no-repeat !important;
  background-size: 100% 100% !important;
  background-attachment: fixed !important;
  color: var(--text-secondary) !important;
}

/* ── Header — theme-aware ────────────────────────────────── */
html[data-theme="light"] header {
  background: linear-gradient(180deg, rgba(240,237,230,0.98) 0%, rgba(254,252,243,0.99) 100%) !important;
  border-bottom: 1px solid #D4CFC6 !important;
  box-shadow:
    0 1px 0 rgba(255,255,255,0.9),
    0 4px 24px rgba(30,58,95,0.08),
    inset 0 1px 0 rgba(255,255,255,0.95) !important;
}

html[data-theme="light"] header .brand,
html[data-theme="light"] header .header-left,
html[data-theme="light"] header .page-title {
  color: #1E3A5F !important;
}

/* ── Buttons — light theme ───────────────────────────────── */
html[data-theme="light"] .btn-ghost,
html[data-theme="light"] .btn-secondary {
  background: rgba(240,237,230,0.8) !important;
  border: 1px solid #D4CFC6 !important;
  color: #5A6E82 !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9);
}

html[data-theme="light"] .btn-ghost:hover,
html[data-theme="light"] .btn-secondary:hover {
  background: rgba(232,228,220,0.9) !important;
  color: #2D3E50 !important;
  border-color: #C4BDB3 !important;
}

/* ── Form inputs — light theme ───────────────────────────── */
html[data-theme="light"] :where(
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]),
  textarea,
  select
) {
  border: 1px solid rgba(180,172,162,0.8) !important;
  background-color: #FAF8F3 !important;
  color: #1E3A5F !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.9);
}

html[data-theme="light"] :where(
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]),
  textarea,
  select
):focus {
  border-color: rgba(217,119,6,0.85) !important;
  box-shadow: 0 0 0 3px rgba(217,119,6,0.18), inset 0 1px 0 rgba(255,255,255,0.9) !important;
}

/* ── Cards — light theme ─────────────────────────────────── */
html[data-theme="light"] .chain-card,
html[data-theme="light"] .stat-pill,
html[data-theme="light"] .group,
html[data-theme="light"] .doc-card,
html[data-theme="light"] .progress-panel,
html[data-theme="light"] .upload-panel,
html[data-theme="light"] .modal {
  background: var(--card-bg) !important;
  border: 1px solid var(--card-border) !important;
  box-shadow:
    inset 0 1px 0 var(--seam-color),
    inset 0 -1px 0 rgba(30,58,95,0.06),
    0 6px 18px var(--shadow-soft) !important;
}

/* Light-mode readability for common content text */
html[data-theme="light"] .desc,
html[data-theme="light"] .section-copy,
html[data-theme="light"] .muted,
html[data-theme="light"] .helper-btn,
html[data-theme="light"] .manage a,
html[data-theme="light"] .manage button,
html[data-theme="light"] .empty,
html[data-theme="light"] .no-results {
  color: var(--text-muted) !important;
}

html[data-theme="light"] .main-content .name,
html[data-theme="light"] .main-content .title-row h2,
html[data-theme="light"] .main-content .usage-value,
html[data-theme="light"] .main-content h1,
html[data-theme="light"] .main-content h2,
html[data-theme="light"] .main-content h3,
html[data-theme="light"] .panel .name,
html[data-theme="light"] .panel .title-row h2,
html[data-theme="light"] .panel h2,
html[data-theme="light"] .panel h3 {
  color: var(--text-primary) !important;
}

html[data-theme="light"] .chat-link,
html[data-theme="light"] .profile-signout,
html[data-theme="light"] .admin-item-signout,
html[data-theme="light"] .count,
html[data-theme="light"] .badge-soft,
html[data-theme="light"] .welcome-kicker {
  color: var(--link-color) !important;
}

html[data-theme="light"] .chat-link:hover,
html[data-theme="light"] .profile-signout:hover,
html[data-theme="light"] .admin-item-signout:hover {
  color: var(--link-hover) !important;
}

html[data-theme="light"] .badge-soft.archie-badge {
  color: #111827 !important;
}

/* Left rail stays dark in light mode — keep labels/copy light */
html[data-theme="light"] .left-stack .toolbar-title,
html[data-theme="light"] .left-stack .brand-card-title,
html[data-theme="light"] .left-stack h2,
html[data-theme="light"] .left-stack h3 {
  color: #F6F1E8 !important;
}

html[data-theme="light"] .left-stack .toolbar-copy,
html[data-theme="light"] .left-stack .brand-card-copy,
html[data-theme="light"] .left-stack .sidebar-ai-notice,
html[data-theme="light"] .left-stack .sidebar-ai-notice p,
html[data-theme="light"] .left-stack .sidebar-ai-notice a {
  color: #D9E2EF !important;
}

html[data-theme="light"] .left-stack .sidebar-ai-notice a {
  color: #F59E0B !important;
}

/* ── Scrollbars — light theme ────────────────────────────── */
html[data-theme="light"] * {
  scrollbar-color: #C4BDB3 #E8E4DC;
}

html[data-theme="light"] *::-webkit-scrollbar-track {
  background: #E8E4DC;
}

html[data-theme="light"] *::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #D4CFC6, #C4BDB3);
  border: 2px solid #E8E4DC;
}

html[data-theme="light"] *::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #C4BDB3, #A8A09A);
}

/* ── Select arrow — theme-aware chevron (never fill the control) ─ */
select {
  appearance: none !important;
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  padding-right: 36px !important;
  background-color: var(--bg-well) !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23F59E0B' d='M1.1 1.2a1 1 0 0 1 1.4 0L6 4.7l3.5-3.5a1 1 0 1 1 1.4 1.4L6.7 6.9a1 1 0 0 1-1.4 0L1.1 2.6a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 12px 8px !important;
}

html[data-theme="light"] select {
  background-color: #FAF8F3 !important;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23B45309' d='M1.1 1.2a1 1 0 0 1 1.4 0L6 4.7l3.5-3.5a1 1 0 1 1 1.4 1.4L6.7 6.9a1 1 0 0 1-1.4 0L1.1 2.6a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 12px 8px !important;
}

select option,
select optgroup {
  background: #ffffff !important;
  color: #0f172a !important;
}

/* ── Theme toggle button ─────────────────────────────────── */
.theme-toggle-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--navy-border) !important;
  background: rgba(27,50,80,0.45) !important;
  color: var(--text-mid) !important;
  cursor: pointer;
  transition: all 150ms ease;
  flex-shrink: 0;
  padding: 0 !important;
  font-size: 0 !important;
  line-height: 1 !important;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.07) !important;
}

.theme-toggle-btn:hover {
  border-color: var(--amber) !important;
  color: var(--amber) !important;
  background: rgba(217,119,6,0.12) !important;
}

html[data-theme="light"] .theme-toggle-btn {
  background: rgba(240,237,230,0.8) !important;
  border-color: #D4CFC6 !important;
  color: #5A6E82 !important;
}

html[data-theme="light"] .theme-toggle-btn:hover {
  border-color: var(--amber) !important;
  color: var(--amber) !important;
  background: rgba(217,119,6,0.08) !important;
}

.theme-toggle-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

/* Show correct icon per theme */
.theme-toggle-btn .icon-sun { display: none; }
.theme-toggle-btn .icon-moon { display: block; }
html[data-theme="light"] .theme-toggle-btn .icon-sun { display: block; }
html[data-theme="light"] .theme-toggle-btn .icon-moon { display: none; }

.theme-toggle-btn .glyph-sun,
.theme-toggle-btn .glyph-moon {
  display: none;
  font-size: 18px !important;
  line-height: 1 !important;
  font-weight: 700;
}

.theme-toggle-btn.glyph-toggle svg {
  display: none !important;
}

.theme-toggle-btn.glyph-toggle .glyph-moon {
  display: inline-block;
}

html[data-theme="light"] .theme-toggle-btn.glyph-toggle .glyph-moon {
  display: none;
}

html[data-theme="light"] .theme-toggle-btn.glyph-toggle .glyph-sun {
  display: inline-block;
}

.top .theme-toggle-btn,
.top-links .theme-toggle-btn,
.top-actions .theme-toggle-btn,
.nav-links .theme-toggle-btn,
.header-actions .theme-toggle-btn,
.actions .theme-toggle-btn,
.header-right .theme-toggle-btn {
  display: inline-flex !important;
  visibility: visible !important;
  opacity: 1 !important;
}

/* Temporarily hide legacy standalone theme toggles — Appearance lives in account menus */
.theme-toggle-btn,
.top .theme-toggle-btn,
.top-links .theme-toggle-btn,
.top-actions .theme-toggle-btn,
.nav-links .theme-toggle-btn,
.header-actions .theme-toggle-btn,
.actions .theme-toggle-btn,
.header-right .theme-toggle-btn {
  display: none !important;
  visibility: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* ── Shared account / profile menu chrome ─────────────────── */
.profile-menu,
.admin-menu.rb-account-menu {
  position: relative;
}

.profile-trigger,
.rb-account-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--surface-raised);
  color: var(--text-primary);
  cursor: pointer;
  box-shadow: inset 0 1px 0 var(--seam-color);
}

.profile-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
  font-weight: 700;
  transform-origin: center;
}

.profile-dropdown,
.rb-account-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 220px;
  padding: 8px;
  border-radius: 12px;
  border: 1px solid var(--rim-color);
  background: var(--surface-raised);
  box-shadow: var(--shadow-card);
  z-index: 200;
}

.profile-menu.open .profile-dropdown,
.admin-menu.open .admin-dropdown,
.rb-account-menu.open .rb-account-dropdown {
  display: block;
}

.profile-menu-item,
.rb-account-item,
.admin-item {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text-secondary) !important;
  text-decoration: none;
  background: transparent;
  border: 0;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}

.profile-menu-item:hover,
.rb-account-item:hover,
.admin-item:hover {
  background: rgba(217, 119, 6, 0.12);
  color: var(--text-primary) !important;
}

.profile-signout,
.admin-item-signout {
  color: var(--link-color) !important;
  font-weight: 700;
}

.profile-signout:hover,
.admin-item-signout:hover {
  color: var(--link-hover) !important;
  background: rgba(217, 119, 6, 0.12);
}

.profile-divider,
.rb-account-divider {
  border: 0;
  border-top: 1px solid var(--border-color);
  margin: 8px 4px;
}

/* ── Account Appearance control (shared physical toggle) ─── */
.rb-appearance {
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rb-appearance-label {
  display: block;
  margin: 0;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.rb-appearance-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.rb-appearance-state {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-secondary);
}

.rb-theme-toggle,
[data-theme-toggle] {
  position: relative;
  width: 68px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 999px;
  border: 1px solid var(--border-strong) !important;
  background: var(--bg-well) !important;
  background-image: none !important;
  box-shadow:
    inset 0 4px 12px rgba(0,0,0,.18),
    inset 0 1px 0 var(--seam-color) !important;
  cursor: pointer;
  padding: 0 !important;
  min-width: 68px !important;
  min-height: 34px !important;
  color: transparent !important;
}

.rb-theme-toggle::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 8px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--brand-amber-light), var(--brand-amber));
  box-shadow:
    0 4px 12px rgba(217,119,6,.32),
    inset 0 1px 0 rgba(255,255,255,.45);
  transition: left 140ms ease;
}

html[data-theme="light"] .rb-theme-toggle::after {
  left: 32px;
}

.rb-theme-toggle:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring), inset 0 4px 12px rgba(0,0,0,.18);
}

[data-theme-feedback] {
  display: block;
  min-height: 1.1em;
  font-size: 11px;
  color: var(--status-error);
}

[data-theme-feedback=""]:empty {
  display: none;
}

.rb-surface-raised {
  background: var(--surface-raised);
  border: 1px solid var(--rim-color);
  box-shadow: inset 0 1px 0 var(--seam-color), var(--shadow-card);
}

.rb-surface-well {
  background: var(--bg-well);
  border: 1px solid var(--border-color);
  box-shadow: inset 0 1px 0 rgba(0,0,0,0.25);
}

.rb-surface-rail {
  background: var(--bg-rail);
  border-right: 1px solid var(--rim-color);
}

html {
  background-color: var(--bg-page);
}

body.rb-theme-body {
  font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif !important;
  min-height: 100vh;
  background-color: var(--bg-chassis) !important;
  background-image:
    radial-gradient(ellipse 70% 42% at 12% 0%, rgba(217,119,6,.12), transparent 55%),
    linear-gradient(165deg, var(--bg-page) 0%, var(--bg-chassis) 48%, var(--bg-chassis) 100%) !important;
  background-repeat: no-repeat !important;
  background-size: 100% 100% !important;
  background-attachment: fixed !important;
  color: var(--text-secondary) !important;
}

body.rb-theme-body header {
  background: var(--header-bg) !important;
  border-bottom: 1px solid var(--border-color) !important;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.06),
    0 4px 24px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(20px);
}

body.rb-theme-body header .brand,
body.rb-theme-body header .header-left,
body.rb-theme-body header .page-title {
  color: var(--text-primary);
}

.btn,
button.btn,
button[type="submit"].btn,
.rb-physical-btn,
a.btn {
  min-height: 38px;
  border-radius: var(--radius-sm) !important;
  padding: 0 14px !important;
  font-size: 12px !important;
  font-weight: 900 !important;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease !important;
  text-decoration: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  cursor: pointer;
}

.btn-primary,
.btn:not(.btn-ghost):not(.btn-danger):not(.btn-secondary),
button[type="submit"]:not(.btn-ghost):not(.profile-menu-item):not(.admin-item) {
  color: #120b04 !important;
  border: 1px solid rgba(180,83,9,.86) !important;
  background: linear-gradient(180deg, var(--brand-amber-light), var(--brand-amber)) !important;
  box-shadow:
    0 9px 18px rgba(217,119,6,.24),
    inset 0 1px 0 rgba(255,255,255,.45),
    inset 0 -3px 0 rgba(111,52,7,.35) !important;
}

.btn-primary:hover,
.btn:not(.btn-ghost):not(.btn-danger):not(.btn-secondary):hover,
button[type="submit"]:not(.btn-ghost):not(.profile-menu-item):not(.admin-item):hover {
  background: linear-gradient(180deg, var(--amber-hot), var(--brand-amber-light)) !important;
  transform: translateY(-1px);
}

.btn-primary:active,
.btn:not(.btn-ghost):not(.btn-danger):not(.btn-secondary):active {
  transform: translateY(1px);
  box-shadow: inset 0 3px 10px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.16) !important;
}

.btn-ghost,
.btn-secondary {
  color: var(--text-muted) !important;
  border: 1px solid var(--border-strong) !important;
  background: linear-gradient(180deg, var(--face), var(--face-pressed)) !important;
  box-shadow:
    0 8px 16px var(--shadow-soft),
    inset 0 1px 0 var(--seam-color),
    inset 0 -2px 0 rgba(0,0,0,.20) !important;
}

.btn-ghost:hover,
.btn-secondary:hover {
  color: var(--text-primary) !important;
  border-color: var(--accent) !important;
}

.btn-danger {
  color: #fff !important;
  border: 1px solid rgba(185,28,28,.75) !important;
  background: linear-gradient(180deg, #ef4444, #b91c1c) !important;
  box-shadow:
    0 8px 16px rgba(185,28,28,.28),
    inset 0 1px 0 rgba(255,255,255,.28),
    inset 0 -2px 0 rgba(80,10,10,.35) !important;
}

.btn-danger:hover {
  background: linear-gradient(180deg, #f87171, #dc2626) !important;
  transform: translateY(-1px);
}

.btn-danger:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

.btn:focus-visible,
button.btn:focus-visible {
  outline: none !important;
  box-shadow: var(--focus-ring) !important;
}

/* Global form-control treatment — recessed wells */
:where(
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]),
  textarea,
  select
) {
  border-radius: var(--radius-sm) !important;
  border: 1px solid var(--input-border) !important;
  background-color: var(--bg-well) !important;
  color: var(--text-primary) !important;
  box-shadow:
    inset 0 4px 12px rgba(0,0,0,.14),
    inset 0 1px 0 var(--seam-color) !important;
}

:where(
  input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):not([type="color"]):not([type="submit"]):not([type="button"]),
  textarea,
  select
):focus {
  outline: none !important;
  border-color: var(--brand-amber-light) !important;
  box-shadow:
    0 0 0 3px rgba(245,158,11,.18),
    inset 0 4px 12px rgba(0,0,0,.14) !important;
}

textarea {
  resize: vertical;
  min-height: 88px;
}

* {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb-color) var(--scroll-track-color);
}

html,
body {
  scrollbar-width: thin;
  scrollbar-color: var(--scroll-thumb-color) var(--scroll-track-color);
}

*::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

*::-webkit-scrollbar-track {
  background: var(--scroll-track-color);
  border-radius: 999px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
  background: var(--scroll-track-color);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #3f6796, var(--scroll-thumb-color));
  border-radius: 999px;
  border: 2px solid var(--scroll-track-color);
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #3f6796, var(--scroll-thumb-color));
  border-radius: 999px;
  border: 2px solid var(--scroll-track-color);
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #4f7eb6, var(--scroll-thumb-hover-color));
}

html::-webkit-scrollbar-thumb:hover,
body::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #4f7eb6, var(--scroll-thumb-hover-color));
}

*::-webkit-scrollbar-corner {
  background: var(--scroll-track-color);
}

html::-webkit-scrollbar-corner,
body::-webkit-scrollbar-corner {
  background: var(--scroll-track-color);
}

.chain-card,
.stat-pill,
.group,
.doc-card,
.progress-panel,
.upload-panel,
.modal,
.profile-dropdown,
.rb-account-dropdown,
.admin-dropdown {
  background: var(--card-bg) !important;
  border: 1px solid var(--card-border) !important;
  border-radius: var(--radius-md);
  box-shadow:
    0 12px 28px var(--shadow-soft),
    inset 0 1px 0 var(--seam-color),
    inset 0 -1px 0 rgba(0,0,0,.10) !important;
}

/* Panels/forms are layout shells — do not force nested card chrome */
.panel,
form {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.group summary,
.section-label,
.page-subtitle,
.doc-desc,
.count,
.date,
.chain-date,
.progress-meta {
  color: var(--text-muted) !important;
}

/* ── Terms of Service Page ─────────────────────────────────── */

.terms-container {
  max-width: 800px;
  margin: 0 auto;
  padding: 48px 24px 80px;
  font-family: inherit;
}

.terms-header {
  margin-bottom: 40px;
}

.terms-company {
  font-size: 13px;
  color: #718096;
  margin-bottom: 8px;
  letter-spacing: 0.02em;
}

.terms-header h1 {
  font-size: 32px;
  font-weight: 700;
  color: #1E3A5F;
  margin: 0 0 8px;
}

.terms-meta {
  font-size: 13px;
  color: #718096;
}

.terms-body {
  color: #2D3E50;
  font-size: 15px;
  line-height: 1.7;
}

.terms-body h2 {
  font-size: 18px;
  font-weight: 700;
  color: #1E3A5F;
  margin: 36px 0 12px;
}

.terms-body h3 {
  font-size: 15px;
  font-weight: 600;
  color: #1E3A5F;
  margin: 24px 0 8px;
}

.terms-body p {
  margin: 0 0 16px;
}

.terms-body ul {
  padding-left: 24px;
  margin: 0 0 16px;
}

.terms-body ul li {
  margin-bottom: 6px;
}

.terms-body a {
  color: #D97706;
  text-decoration: none;
}

.terms-body a:hover {
  text-decoration: underline;
}

.terms-body hr {
  border: none;
  border-top: 1px solid #E2E8F0;
  margin: 32px 0;
}

.terms-body address {
  font-style: normal;
  line-height: 1.8;
}

.terms-footer {
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid #E2E8F0;
  text-align: center;
  font-size: 13px;
  color: #718096;
  font-style: italic;
}

/* ── Sidebar AI Notice ─────────────────────────────────────── */

.sidebar-ai-notice {
  padding: 12px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  margin-top: auto;
}

.sidebar-ai-notice p {
  font-size: 11px;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.38);
  margin: 0;
}

.sidebar-ai-notice a {
  color: rgba(255, 255, 255, 0.38);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.sidebar-ai-notice a:hover {
  color: rgba(255, 255, 255, 0.55);
}

/* Archie daily briefing modal */
.ab-modal.modal-backdrop {
  z-index: 120;
}

.ab-card.modal {
  width: min(560px, 94vw);
  border-left: 3px solid var(--amber) !important;
  animation: ab-rise 200ms ease-out;
}

.ab-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.ab-brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.ab-owl {
  flex: 0 0 auto;
  font-size: 34px;
  line-height: 1;
  filter: drop-shadow(0 2px 8px rgba(217, 119, 6, 0.28));
}

.ab-eyebrow {
  color: var(--amber);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 1;
  margin-bottom: 6px;
}

.ab-title {
  margin: 0;
  font-size: 21px;
  line-height: 1.15;
}

.ab-close.close {
  position: static;
  flex: 0 0 auto;
}

.ab-loading {
  padding: 10px 0 4px;
}

.ab-loading p,
.ab-error p {
  margin: 12px 0 0;
  color: var(--text-muted);
}

.ab-scan-track {
  height: 4px;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(42, 74, 116, 0.72);
}

.ab-scan-bar {
  width: 36%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--amber), var(--amber-bright));
  animation: ab-scan 1.1s ease-in-out infinite;
}

.ab-body {
  max-height: min(58vh, 520px);
  overflow: auto;
  padding-right: 4px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.ab-body strong {
  color: var(--text-primary);
}

.ab-body code {
  color: var(--amber-bright);
  font-family: "DM Mono", "Consolas", monospace;
}

.ab-body pre {
  overflow: auto;
  margin: 12px 0;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--navy-deep);
}

.ab-body pre code {
  color: var(--amber-bright);
  white-space: pre-wrap;
}

.ab-actions {
  margin-top: 16px;
}

@keyframes ab-scan {
  0% { transform: translateX(-105%); }
  100% { transform: translateX(285%); }
}

@keyframes ab-rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 600px) {
  .ab-card.modal {
    padding: 14px;
  }

  .ab-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .ab-actions .btn {
    width: 100%;
  }

  .ab-title {
    font-size: 18px;
  }

  .ab-owl {
    font-size: 30px;
  }
}
