/* TOAD Mobile 2.2 — DarkTheme-v3 + Light */

:root,
html[data-theme="dark"] {
  --bg: #000000;
  --card: #0A0A0A;
  --elevated: #121212;
  --border: #FFFFFF;
  --border-strong: #FFFFFF;
  --border-soft: #8A8A8A;
  --text: #FFFFFF;
  --text-2: #FFFFFF;
  --text-3: #F0F0F0;
  --muted: #D0D0D0;
  --placeholder: #A8A8A8;
  --primary: #FFC107;
  --primary-text: #000000;
  --primary-dim: rgba(255, 193, 7, 0.22);
  --label: #FFE08A;
  --ok: #69F0AE;
  --danger: #FF5252;
  --bar: #FF9800;
  --header-bg: rgba(0, 0, 0, 0.97);
  --input-bg: #000000;
  --nav-h: 64px;
  --footer-h: 58px;
  --radius: 14px;
  color-scheme: dark;
}

html[data-theme="light"] {
  --bg: #F3F0E8;
  --card: #FFFFFF;
  --elevated: #F7F4EC;
  --border: #C9C2B4;
  --border-strong: #5C564C;
  --border-soft: #A39E92;
  --text: #12100C;
  --text-2: #2A261F;
  --text-3: #3F3A32;
  --muted: #5C564C;
  --placeholder: #7A7368;
  --primary: #B8860B;
  --primary-text: #1A1200;
  --primary-dim: rgba(184, 134, 11, 0.16);
  --label: #6B5500;
  --ok: #15803D;
  --danger: #B91C1C;
  --bar: #EA580C;
  --header-bg: rgba(243, 240, 232, 0.97);
  --input-bg: #FFFFFF;
  color-scheme: light;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  min-height: 100%;
  height: auto;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  font-weight: 500;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--primary); font-weight: 700; }

#app { max-width: 430px; margin: 0 auto; min-height: 100dvh; background: var(--bg); }
.screen { display: none; padding: 14px; min-height: 100%; }
.screen.active { display: block; }
.hidden { display: none !important; }
.subnav-btn.hidden { display: none !important; }
.godmode-badge {
  flex-shrink: 0;
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #111;
  background: #e8c547;
  border: 2px solid #111;
  border-radius: 999px;
  padding: 3px 7px;
}

/* Theme logo swap */
html[data-theme="dark"] .logo-theme-light { display: none !important; }
html[data-theme="light"] .logo-theme-dark { display: none !important; }
html[data-theme="dark"] .logo-theme-dark { display: block; }
html[data-theme="light"] .logo-theme-light { display: block; }

/* Auth */
.auth-wrap { max-width: 360px; margin: 24px auto; }
.auth-wrap-col { display: flex; flex-direction: column; min-height: calc(100vh - 48px); }
.auth-logo { text-align: center; margin-bottom: 18px; padding-top: 12px; }
.auth-logo-img {
  max-width: 260px; width: 78%; height: auto; object-fit: contain;
  border-radius: 14px; margin: 0 auto 14px; display: block;
}
.auth-logo h1 { font-size: 28px; font-weight: 900; letter-spacing: -0.03em; color: var(--text); }
.auth-logo h1 em { font-style: normal; color: var(--primary); }
.auth-logo p, .hint {
  color: var(--text-2); font-size: 13px; margin: 8px 0 14px; line-height: 1.45; font-weight: 700;
}
.hint.consent { font-size: 14px; font-weight: 500; line-height: 1.5; color: var(--text); }
.hint.consent a { color: var(--text); font-weight: 600; text-decoration: underline; text-underline-offset: 2px; }
.auth-spacer { flex: 1; min-height: 24px; }
.foot-hint { font-size: 10px; color: var(--muted); text-align: center; margin-top: 8px; font-weight: 600; }

.theme-row, .settings-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px; margin-bottom: 12px;
  background: var(--card); border: 2px solid var(--border-soft);
  border-radius: 14px;
}
.theme-row-secondary { border-color: var(--border-soft); opacity: 0.95; }
.theme-row .t, .settings-row .t { font-size: 14px; font-weight: 800; color: var(--text); }
.theme-row .m, .settings-row .m { font-size: 12px; color: var(--muted); margin-top: 3px; font-weight: 600; }

.form-group { margin-bottom: 12px; }
.form-group label {
  display: block; font-size: 12px; color: var(--label); margin-bottom: 6px;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 900;
}
.form-group input, .form-group select, .form-group textarea, .search-row input, .search-row select {
  width: 100%; background: var(--input-bg); color: var(--text);
  border: 3px solid var(--border-strong); border-radius: 12px;
  padding: 12px 14px; outline: none; font-weight: 700; font-size: 15px;
}
.form-group input::placeholder, .search-row input::placeholder, .form-group textarea::placeholder {
  color: var(--placeholder); opacity: 1; font-weight: 500;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus, .search-row input:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-dim);
}
.code-inputs { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.code-inputs input {
  text-align: center; font-size: 18px; font-weight: 900; padding: 12px 0;
  border: 3px solid var(--border-strong); background: var(--input-bg); color: var(--text); border-radius: 12px;
}

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 100%; padding: 14px 16px; border-radius: 12px; font-weight: 900; font-size: 15px;
}
.btn-primary { background: var(--primary); color: var(--primary-text); }
.btn-outline {
  background: transparent; border: 3px solid var(--border-strong);
  color: var(--text); margin-top: 12px; font-weight: 800;
}
.btn-sm { width: auto; padding: 8px 12px; font-size: 12px; border-radius: 10px; }
.muted { color: var(--muted); font-size: 12px; text-align: center; padding: 12px; font-weight: 600; }

/* Shell */
#shell { display: none; flex-direction: column; min-height: 100dvh; background: var(--bg); }
#shell.open { display: flex; }
.header {
  height: 60px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; border-bottom: 2px solid var(--border-soft);
  background: var(--header-bg); position: sticky; top: 0; z-index: 20; gap: 8px;
}
.brand { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; }
.hdr-logo {
  height: 36px; width: auto; max-width: 130px; object-fit: contain;
  border-radius: 8px; flex-shrink: 0;
}
.brand-text {
  font-size: 13px; font-weight: 900; line-height: 1.15; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand-text em {
  display: block; font-style: normal; color: var(--primary);
  font-size: 9px; font-weight: 800; letter-spacing: 0.02em;
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--primary-dim); color: var(--primary);
  display: grid; place-items: center; font-size: 11px; font-weight: 900;
  border: 2px solid var(--primary); flex-shrink: 0;
}
.main { padding: 14px 14px calc(var(--nav-h) + var(--footer-h) + 12px); flex: 1; }
.tab { display: none; }
.tab.active { display: block; }

.page-title { font-size: 22px; font-weight: 900; color: var(--text); margin: 0 0 2px; }
.page-sub { font-size: 13px; font-weight: 700; color: var(--muted); margin: 0 0 12px; }

/* Sub-nav pills */
.subnav {
  display: flex; gap: 6px; overflow-x: auto; padding-bottom: 10px; margin-bottom: 12px;
  border-bottom: 2px solid var(--border-soft); -webkit-overflow-scrolling: touch;
}
#subnav-safety {
  gap: 3px;
  padding-bottom: 8px;
}
#subnav-safety .subnav-btn {
  padding: 6px 8px;
  font-size: 10px;
  border-width: 1.5px;
}
#subnav-safety .help-bubble {
  flex: 0 0 26px !important;
  width: 26px; min-width: 26px; height: 26px;
  font-size: 10px;
}
.panel ul.lms-list, .panel ol.lms-list, .panel ul, .panel ol {
  margin: 0 0 10px 1.25em;
  padding: 0;
}
.panel ul, .panel ul.lms-list { list-style: disc; }
.panel ol, .panel ol.lms-list { list-style: decimal; }
.panel li { margin: 0 0 4px; line-height: 1.4; }
.quiz-progress {
  font-size: 14px; font-weight: 900; color: var(--primary); margin: 4px 0 8px;
}
.lesson-nav {
  display: flex; flex-direction: column; gap: 8px; margin-top: 12px;
}
.lesson-nav .btn { width: 100%; }
.subnav-btn {
  flex: 0 0 auto; padding: 8px 12px; border-radius: 999px;
  border: 2px solid var(--border-soft); background: var(--card);
  color: var(--text); font-size: 11px; font-weight: 900; white-space: nowrap;
}
.subnav-btn.on {
  background: var(--primary); color: var(--primary-text); border-color: var(--primary);
}
.subpanel { display: none; }
.subpanel.on { display: block; }

.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: var(--footer-h);
  width: 100%; max-width: 430px;
  padding: 8px 10px;
  background: linear-gradient(180deg, transparent, var(--bg) 28%); z-index: 30;
}
.nav-tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px;
  background: var(--card); border: 2px solid var(--border-soft);
  border-radius: 16px; padding: 6px;
}
.nav-tabs.nav-3 { grid-template-columns: repeat(3, 1fr); }
.nav-item {
  padding: 10px 4px; border-radius: 12px; color: var(--muted);
  font-size: 11px; font-weight: 800;
}
.nav-item.active {
  background: var(--primary); color: var(--primary-text);
}

.section-label {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--label); font-weight: 900; margin: 16px 0 10px;
}
.greeting h1 { font-size: 22px; font-weight: 900; color: var(--text); }
.greeting p { font-size: 13px; color: var(--text-2); margin: 4px 0 14px; font-weight: 700; }

.scoreboard {
  background: var(--card); border: 3px solid var(--primary);
  border-radius: 16px; padding: 16px; margin-bottom: 14px;
}
.score-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--primary); font-weight: 900; margin-bottom: 4px;
}
.score-value {
  font-size: 30px; font-weight: 900; letter-spacing: -0.03em;
  margin-bottom: 14px; font-variant-numeric: tabular-nums; color: var(--text);
}
.score-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.score-tile {
  background: var(--elevated); border: 2px solid var(--border-soft);
  border-radius: 10px; padding: 10px 12px;
}
.score-tile .l { font-size: 11px; color: var(--label); font-weight: 800; text-transform: uppercase; }
.score-tile .v { font-size: 16px; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--text); }
.score-tile .s { font-size: 11px; color: var(--muted); margin-top: 2px; font-weight: 600; }

.card {
  background: var(--card); border: 2px solid var(--border-soft);
  border-radius: var(--radius); overflow: visible; margin-bottom: 12px;
}
.card.list-item, .course-card {
  overflow: visible;
  border: 2px solid var(--border-soft);
  border-bottom: 2px solid var(--border-soft);
}
.list-item {
  display: block; width: 100%; text-align: left; padding: 12px 14px;
  color: inherit;
}
.list-item:last-child { border-bottom: 2px solid var(--border-soft); }
.list-item .t { font-size: 14px; font-weight: 800; color: var(--text); }
.list-item .m { font-size: 12px; color: var(--text-2); margin-top: 3px; font-weight: 600; line-height: 1.4; }
.list-item .row { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }

.badge {
  display: inline-flex; font-size: 10px; font-weight: 900; padding: 2px 7px;
  border-radius: 999px; text-transform: uppercase; border: 2px solid transparent;
}
.badge.urgent { background: transparent; color: var(--danger); border-color: var(--danger); }
.badge.warn { background: transparent; color: var(--primary); border-color: var(--primary); }
.badge.ok { background: transparent; color: var(--ok); border-color: var(--ok); }

.search-row { margin-bottom: 10px; }
.search-row label { display: block; font-size: 11px; font-weight: 800; margin-bottom: 6px; color: var(--label); }

.load {
  display: block; width: 100%; padding: 12px 0;
  border-bottom: 1px solid var(--border-soft); color: inherit; text-align: left;
}
.load .top { display: flex; justify-content: space-between; gap: 10px; }
.load .journey { font-size: 13px; font-weight: 800; color: var(--text); }
.load .pay { font-size: 14px; font-weight: 900; color: var(--primary); white-space: nowrap; }
.load .details {
  display: flex; flex-wrap: wrap; gap: 8px 12px; margin-top: 6px;
  font-size: 11px; color: var(--text-2); font-weight: 600;
}

.chart-card {
  background: var(--card); border: 2px solid var(--border-soft);
  border-radius: 16px; padding: 14px 12px 10px; margin-bottom: 14px;
}
.chart-head { display: flex; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.chart-head h3 { font-size: 13px; font-weight: 900; color: var(--text); }
.chart-head p { font-size: 11px; color: var(--muted); margin-top: 2px; font-weight: 600; }
.chart-legend { display: flex; gap: 12px; font-size: 11px; color: var(--text-2); font-weight: 650; }
.swatch-bar { display: inline-block; width: 10px; height: 10px; border-radius: 2px; background: var(--bar); margin-right: 4px; }
.swatch-line { display: inline-block; width: 14px; height: 3px; border-radius: 2px; background: var(--ok); margin-right: 4px; vertical-align: middle; }
.chart-wrap svg { display: block; width: 100%; height: auto; }

.resources-html { padding: 12px; font-size: 13px; line-height: 1.5; color: var(--text-2); overflow-x: auto; font-weight: 600; }
.resources-html a { color: var(--primary); }

.toggle {
  width: 50px; height: 30px; border-radius: 999px;
  background: var(--elevated); border: 2px solid var(--border-soft);
  position: relative; flex-shrink: 0;
}
.toggle.on { background: var(--primary-dim); border-color: var(--primary); }
.toggle i {
  position: absolute; top: 3px; left: 3px; width: 20px; height: 20px;
  border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s;
}
.toggle.on i { transform: translateX(18px); background: var(--primary); }

.info-card { padding: 14px; }
.info-card .lbl {
  font-size: 11px; color: var(--label); text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 4px; font-weight: 900;
}
.info-card .val { font-size: 14px; font-weight: 700; line-height: 1.45; white-space: pre-wrap; color: var(--text); }

.form-card { padding: 14px; }
.form-help { font-size: 12px; color: var(--text-2); margin-bottom: 12px; line-height: 1.45; font-weight: 600; }
.form-card .form-group { margin-bottom: 10px; }
.form-card select, .form-card textarea {
  width: 100%; background: var(--input-bg); border: 3px solid var(--border-strong);
  border-radius: 12px; padding: 11px 12px; outline: none; color: var(--text); font-weight: 700;
}
.form-card input[type="file"] { width: 100%; font-size: 12px; color: var(--text-2); font-weight: 600; }

.loc-row { display: flex; gap: 8px; align-items: stretch; }
.loc-row input { flex: 1; }
.loc-btn {
  flex: 0 0 48px; border: 3px solid var(--primary); border-radius: 12px;
  background: var(--elevated); color: var(--primary);
  display: grid; place-items: center;
}
.loc-btn:active { opacity: 0.85; }

.thumb-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.bol-card .btn { margin-top: 8px; }
.bol-frame {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 8px 0 4px;
}
.bol-preview {
  width: 90%;
  max-width: 90%;
  height: auto;
  max-height: 90dvh;
  object-fit: contain;
  border-radius: 8px;
  background: #111;
  cursor: zoom-in;
  display: block;
}
.bol-frame-full .bol-preview {
  width: 90vw;
  max-width: 90%;
  max-height: 90dvh;
}

.overlay {
  position: fixed; left: 0; right: 0; top: 0;
  bottom: var(--footer-h);
  background: rgba(0,0,0,.72); z-index: 50;
  display: none; align-items: flex-end; justify-content: center;
}
.overlay.open { display: flex; }
.panel {
  width: 100%; max-width: 430px; max-height: 100%; overflow: auto;
  background: var(--card); border-radius: 18px 18px 12px 12px;
  border: 2px solid var(--border-soft);
  padding: 12px 14px 20px; color: var(--text);
}
.panel .back { color: var(--primary); font-weight: 900; font-size: 13px; margin-bottom: 10px; }
.panel h2 { font-size: 18px; font-weight: 900; margin-bottom: 4px; color: var(--text); }
.panel .sub { font-size: 12px; color: var(--text-2); margin-bottom: 12px; font-weight: 600; }
.site-block {
  background: var(--elevated); border: 1.5px solid var(--border-soft);
  border-radius: 12px; padding: 12px; font-size: 13px; line-height: 1.5;
  white-space: pre-wrap; color: var(--text-2); margin-bottom: 12px; font-weight: 600;
}

.site-block.html { white-space: normal; }
.site-block.html p { margin: 0 0 8px; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--footer-h) + 12px);
  transform: translateX(-50%);
  background: var(--elevated); border: 2px solid var(--border-soft);
  color: var(--text); padding: 10px 14px; border-radius: 999px;
  font-size: 12px; font-weight: 800; z-index: 60; display: none; max-width: 90%; text-align: center;
}
.toast.show { display: block; }


/* 2.3 logo no clip — square edges */
.hdr-logo,
.auth-logo-img,
.logo-theme-dark,
.logo-theme-light {
  border-radius: 0 !important;
  object-fit: contain;
}
.hdr-logo {
  height: 40px;
  max-width: 148px;
  width: auto;
}
.auth-logo-img {
  border-radius: 0 !important;
  max-width: 280px;
}


/* Dual photo pickers (gallery + camera) */
.file-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  overflow: hidden !important;
  clip: rect(0,0,0,0);
}
.photo-actions {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.photo-actions .photo-btn {
  flex: 1;
  margin-top: 0 !important;
  width: auto;
  padding: 12px 10px;
  font-size: 13px;
}

.site-footer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: 100%;
  max-width: 430px;
  z-index: 55;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-top: 1px solid var(--border);
  font-weight: 650;
  line-height: 1.35;
}
.site-footer p { margin: 0; }
.site-footer a { color: var(--text-2); font-weight: 800; }
.help-bubble {
  flex: 0 0 34px !important;
  width: 34px; min-width: 34px; height: 34px;
  padding: 0 !important;
  border-radius: 999px !important;
  font-size: 12px; font-weight: 900;
}
.badge-mark { font-size: 12px; font-weight: 800; }
.badge-mark.pass { color: var(--ok); }
.badge-mark.fail { color: var(--danger); }
.quiz-opt {
  display: flex; align-items: flex-start; gap: 10px;
  margin: 8px 0; font-weight: 650; text-transform: none;
}
.lms-photo img { width: 100%; border-radius: 12px; aspect-ratio: 3/2; object-fit: cover; }
.bol-preview { width: 90%; max-width: 90%; max-height: 90dvh; object-fit: contain; border-radius: 12px; margin-top: 8px; background: #111; }
.lms-photo figcaption { font-size: 12px; color: var(--muted); margin-top: 6px; }
.callout {
  border-left: 4px solid var(--primary);
  padding: 10px 12px;
  background: var(--elevated);
  border-radius: 8px;
  margin: 8px 0;
}
.banner-kicker { font-weight: 800; margin: 12px 0 6px; }
.panel ol.lms-list { margin: 0 0 12px 1.2em; list-style: decimal; }
.panel h3 { margin: 12px 0 6px; font-size: 15px; }

