/**
 * Flextron web shared theme: light is applied on first paint (inline FOUC + theme.js).
 * Rules under html[data-theme="light"] set light tokens; switching to dark uses each page's
 * existing :root dark palette (no redundant dark block here).
 */

html {
  color-scheme: light;
}

html[data-theme="dark"] {
  color-scheme: dark;
}
html[data-theme="light"] {
  --bg: #eef1f6;
  --surface: #ffffff;
  --surface2: #f4f6fa;
  --surface3: #e8ecf2;
  --border: rgba(15, 20, 30, 0.1);
  --accent: #2e7d32;
  --accent-dark: #1b5e20;
  --accent-d: #1b5e20;
  --accent-warn: #e65100;
  --accent-err: #c62828;
  --amber: #e65100;
  --amber-d: #bf360c;
  --red: #c62828;
  --text: #1a1f2e;
  --text-dim: #5c6478;
  --heading: #0d1117;
  --link: #2e7d32;
  --tag-bg: rgba(46, 125, 50, 0.1);
  --tag-border: rgba(46, 125, 50, 0.22);
  --warn-bg: rgba(245, 124, 0, 0.1);
  --warn-border: rgba(230, 81, 0, 0.28);
  --warn-text: #bf360c;
  --nav-bg: rgba(255, 255, 255, 0.9);
}

/* Pages that expose --nav-bg on :root pick this up in light mode */
html[data-theme="light"] nav {
  background: var(--nav-bg);
}

/* ── Theme toggle button ──────────────────────────────────────────────────── */
.flextron-theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  line-height: 1;
  color: var(--text-dim);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s;
}
.flextron-theme-toggle:hover {
  color: var(--heading);
  border-color: var(--tag-border);
  background: var(--surface);
}
.flextron-theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
.flextron-theme-toggle-icon {
  font-size: 14px;
  line-height: 1;
  opacity: 0.9;
}

/* Legal pages: toggle in header corner + responsive helpers */
.legal-header {
  position: relative;
}
.legal-header .flextron-theme-toggle {
  position: absolute;
  top: clamp(12px, 3vw, 16px);
  right: clamp(12px, 3vw, 20px);
}
.legal-header .logo img {
  max-width: min(100%, 300px);
  height: auto;
  display: block;
  margin: 0 auto;
}
.legal-header .meta {
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.55;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
  overflow-wrap: break-word;
}

@media (max-width: 768px) {
  .legal-header .flextron-theme-toggle {
    position: static;
    margin: 0 auto 16px;
    display: inline-flex;
  }
}

/* Horizontal scroll for wide comparison tables inside legal `<main>` */
.legal-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
  margin: 16px 0;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.legal-table-scroll table {
  margin: 0;
  min-width: 100%;
}

body.legal-doc {
  overflow-x: hidden;
}
body.legal-doc .legal-footer-links {
  display: flex;
  gap: clamp(12px, 4vw, 20px);
  justify-content: center;
  flex-wrap: wrap;
  row-gap: 10px;
  margin-bottom: 12px;
}
@media (max-width: 600px) {
  body.legal-doc main {
    margin-top: 28px;
    padding-left: max(14px, env(safe-area-inset-left, 0px));
    padding-right: max(14px, env(safe-area-inset-right, 0px));
    padding-bottom: 64px;
  }
  body.legal-doc section {
    padding-top: 22px;
    padding-bottom: 22px;
    padding-left: clamp(14px, 5vw, 22px);
    padding-right: clamp(14px, 5vw, 22px);
    margin-bottom: 14px;
  }
  body.legal-doc footer {
    padding-left: max(16px, env(safe-area-inset-left, 0px));
    padding-right: max(16px, env(safe-area-inset-right, 0px));
  }
  body.legal-doc header.legal-header h1 {
    font-size: clamp(1.25rem, 6.2vw, 1.625rem);
    line-height: 1.18;
    word-wrap: break-word;
    overflow-wrap: break-word;
  }
}

/* Index: screenshot overlay in light mode */
html[data-theme="light"] .shot .shot-label {
  background: linear-gradient(
    to top,
    rgba(255, 255, 255, 0.94) 0%,
    transparent 100%
  );
}
html[data-theme="light"] .shot:hover {
  box-shadow: 0 16px 40px rgba(15, 20, 30, 0.12);
}

/* Terms disclaimer callout — light readability */
html[data-theme="light"] .disclaimer-box {
  background: rgba(198, 40, 40, 0.06);
  border-color: rgba(198, 40, 40, 0.22);
  color: #8b1e1e;
}

/* Tables in legal docs */
html[data-theme="light"] main table td {
  border-bottom-color: rgba(15, 20, 30, 0.08);
}

/* Admin license: row hover */
html[data-theme="light"] body .page table tbody tr:hover td {
  background: rgba(0, 0, 0, 0.035);
}

/* Sysinfo diagnostics page */
body.sysinfo-report {
  --si-bg: #1e1e1e;
  --si-text: #d4d4d4;
  --si-h1: #569cd6;
  --si-h2: #9cdcfe;
  --si-border: #444;
  --si-pre-bg: #252526;
  --si-pre-edge: #3c3c3c;
  --si-meta: #6a9955;
  --si-fn-row: #2d2d2d;
  --si-badge-on-bg: #1a4a1a;
  --si-badge-on-fg: #4ec94e;
  --si-badge-off-bg: #4a1a1a;
  --si-badge-off-fg: #f47c7c;
  font-family: monospace, Consolas, 'Courier New', monospace;
  padding: 24px;
  background: var(--si-bg);
  color: var(--si-text);
}
html[data-theme="light"] body.sysinfo-report {
  --si-bg: #fafbfc;
  --si-text: #1e293b;
  --si-h1: #1565c0;
  --si-h2: #0d47a1;
  --si-border: #cbd5e1;
  --si-pre-bg: #f1f5f9;
  --si-pre-edge: #e2e8f0;
  --si-meta: #2e7d32;
  --si-fn-row: #eef2f7;
  --si-badge-on-bg: #dcfce7;
  --si-badge-on-fg: #166534;
  --si-badge-off-bg: #fee2e2;
  --si-badge-off-fg: #991b1b;
}
body.sysinfo-report .sysinfo-theme-bar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}
body.sysinfo-report .section {
  margin-bottom: 24px;
}
body.sysinfo-report .fn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
  margin-top: 8px;
}
body.sysinfo-report h1 {
  color: var(--si-h1);
  margin-bottom: 20px;
  font-size: 1.4rem;
}
body.sysinfo-report .section h2 {
  color: var(--si-h2);
  border-bottom: 1px solid var(--si-border);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding-bottom: 4px;
  margin-bottom: 8px;
}
body.sysinfo-report pre {
  background: var(--si-pre-bg);
  border: 1px solid var(--si-pre-edge);
  color: var(--si-text);
  border-radius: 4px;
  padding: 12px;
  font-size: 0.78rem;
  line-height: 1.5;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  overflow-y: auto;
}
body.sysinfo-report .meta {
  color: var(--si-meta);
  font-size: 0.75rem;
  margin-bottom: 20px;
}
body.sysinfo-report .fn-table th {
  color: var(--si-h2);
  border-bottom: 1px solid var(--si-border);
  text-align: left;
  padding: 4px 8px;
}
body.sysinfo-report .fn-table td {
  padding: 4px 8px;
  border-bottom: 1px solid var(--si-fn-row);
}
body.sysinfo-report .fn-table tr:last-child td {
  border-bottom: none;
}

body.sysinfo-report .badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 3px;
  font-size: 0.72rem;
}
body.sysinfo-report .badge.on {
  background: var(--si-badge-on-bg);
  color: var(--si-badge-on-fg);
}
body.sysinfo-report .badge.off {
  background: var(--si-badge-off-bg);
  color: var(--si-badge-off-fg);
}

/* Admin login card: theme toggle */
.license-login-shell {
  position: relative;
}
.license-login-shell > .license-login-toggle {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 10;
}
