/* ============================================================
   PatternLocks Pro — styles.css
   Full design system, dark/light theme, all components
   ============================================================ */

/* ---- RESET & BASE ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background .3s, color .3s;
  font-size: 14px;
  line-height: 1.5;
}

/* ---- THEME VARIABLES ---- */
:root {
  --bg: #070b14;
  --bg2: #0d1320;
  --bg3: #111a2c;
  --bg4: #172238;
  --bg5: #1d2c46;
  --card: #0f1929;
  --card2: #132035;
  --border: #1a2e4a;
  --border2: #203860;
  --text: #e2e8f0;
  --text2: #94a3b8;
  --text3: #64748b;
  --text4: #3f5068;
  --acc: #00d4ff;
  --acc2: #7c3aed;
  --acc3: #10b981;
  --acc4: #f59e0b;
  --acc5: #f43f5e;
  --red: #ef4444;
  --green: #10b981;
  --yellow: #f59e0b;
  --blue: #3b82f6;
  --purple: #a78bfa;
  --r: 12px;
  --r2: 8px;
  --r3: 20px;
  --r4: 16px;
  --shadow: 0 4px 24px rgba(0,0,0,.5);
  --shadow2: 0 2px 8px rgba(0,0,0,.3);
  --glow: 0 0 20px rgba(124,58,237,.3);
}
[data-theme="light"] {
  --bg: #f0f4fa;
  --bg2: #e8edf5;
  --bg3: #dde4f0;
  --bg4: #d0d9ec;
  --bg5: #c3cfe0;
  --card: #ffffff;
  --card2: #f8faff;
  --border: #c8d5e8;
  --border2: #b0c2dc;
  --text: #0f172a;
  --text2: #334155;
  --text3: #64748b;
  --text4: #94a3b8;
  --shadow: 0 4px 24px rgba(0,0,0,.1);
  --shadow2: 0 2px 8px rgba(0,0,0,.08);
  --glow: 0 0 20px rgba(124,58,237,.15);
}

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg2); }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--acc2); }

/* ---- APP SHELL ---- */
.app-shell {
  display: grid;
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

/* ---- TOPBAR ---- */
.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow2);
}
.topbar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--acc2), var(--acc));
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glow);
}
.logo-text {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -.5px;
  color: var(--text);
}
.logo-text span { color: var(--acc2); }
.logo-version {
  font-size: 10px;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text3);
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.topbar-tabs {
  display: flex;
  gap: 2px;
  flex: 1;
  justify-content: center;
}
.topbar-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  background: transparent;
  color: var(--text3);
  transition: all .2s;
  white-space: nowrap;
}
.topbar-tab:hover { background: var(--bg3); color: var(--text); }
.topbar-tab.active { background: var(--acc2); color: #fff; box-shadow: 0 2px 8px rgba(124,58,237,.4); }
.topbar-tab .tab-icon { font-size: 14px; }
.topbar-tab .tab-badge {
  background: var(--acc4);
  color: #000;
  font-size: 9px;
  font-weight: 800;
  padding: 1px 5px;
  border-radius: 8px;
  min-width: 16px;
  text-align: center;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.icon-btn {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: var(--r2);
  background: var(--bg2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  font-size: 14px;
  transition: all .2s;
}
.icon-btn:hover { border-color: var(--acc); color: var(--acc); background: var(--bg3); }
.icon-btn.active { border-color: var(--acc2); color: var(--acc2); background: rgba(124,58,237,.1); }

/* ---- MAIN CONTENT ---- */
.main-content {
  overflow-y: auto;
  height: calc(100vh - 56px);
}
.panel { display: none; }
.panel.active { display: block; }

/* ---- ANALYZER LAYOUT ---- */
.analyzer-layout {
  display: grid;
  grid-template-columns: 300px 1fr 280px;
  gap: 0;
  height: 100%;
  min-height: calc(100vh - 56px);
}
.analyzer-left {
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--card);
  overflow-y: auto;
}
.analyzer-center {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: var(--bg);
}
.analyzer-right {
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--card);
  overflow-y: auto;
}

/* ---- SECTION HEADERS ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
  font-weight: 700;
}
.section-body { padding: 14px 16px; }
.section-divider { height: 1px; background: var(--border); margin: 0; }

/* ---- CANVAS AREA ---- */
.canvas-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.canvas-wrap {
  position: relative;
  display: inline-block;
}
#patternCanvas {
  display: block;
  cursor: crosshair;
  border-radius: var(--r);
  box-shadow: var(--shadow), var(--glow);
  max-width: 100%;
  height: auto;
}
.canvas-overlay-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: rgba(0,0,0,.7);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 10px;
  color: var(--text2);
  backdrop-filter: blur(4px);
  pointer-events: none;
}
.canvas-overlay-badge.score-overlay {
  left: auto;
  right: 8px;
  font-size: 13px;
  font-weight: 800;
}
.canvas-replay-btn {
  position: absolute;
  bottom: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(0,0,0,.7);
  border: 1px solid var(--border2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text2);
  font-size: 12px;
  transition: all .2s;
  backdrop-filter: blur(4px);
}
.canvas-replay-btn:hover { border-color: var(--acc); color: var(--acc); }
.canvas-status {
  font-size: 12px;
  color: var(--text3);
  margin-top: 10px;
  min-height: 18px;
  text-align: center;
  display: flex;
  align-items: center;
  gap: 6px;
}
.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text3);
  flex-shrink: 0;
}
.status-dot.active { background: var(--green); box-shadow: 0 0 8px var(--green); animation: pulse 1.5s infinite; }
.status-dot.done { background: var(--acc2); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }
.canvas-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 14px;
  border-radius: var(--r2);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  letter-spacing: .2px;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--acc2); border-color: var(--acc2); color: #fff; }
.btn-primary:hover { background: #6d28d9; box-shadow: 0 0 12px rgba(124,58,237,.4); }
.btn-ghost { background: transparent; border-color: var(--border2); color: var(--text2); }
.btn-ghost:hover { border-color: var(--acc2); color: var(--acc2); background: rgba(124,58,237,.08); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger { background: transparent; border-color: #7f1d1d; color: var(--red); }
.btn-danger:hover { background: #450a0a; }
.btn-amber { background: transparent; border-color: #78350f; color: var(--yellow); }
.btn-amber:hover { background: #451a03; }
.btn-cyan { background: transparent; border-color: #0e7490; color: var(--acc); }
.btn-cyan:hover { background: #083344; }
.btn-lg { padding: 9px 20px; font-size: 13px; }
.btn-sm { padding: 4px 10px; font-size: 10px; }
.btn-icon { padding: 6px 10px; }

/* ---- SCORE DISPLAY ---- */
.score-display {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.score-number-wrap { flex-shrink: 0; }
.score-number {
  font-size: 52px;
  font-weight: 900;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: color .3s;
  letter-spacing: -2px;
}
.score-of { font-size: 11px; color: var(--text3); margin-top: 2px; }
.grade-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 800;
  margin-top: 6px;
  border: 1px solid;
}
.grade-A { background: #052e16; color: #4ade80; border-color: #166534; }
.grade-B { background: #1c3d5a; color: #60cdff; border-color: #1e40af; }
.grade-C { background: #3d2a00; color: #fbbf24; border-color: #78350f; }
.grade-D { background: #3d0a0a; color: #f87171; border-color: #991b1b; }
.grade-F { background: #2d0a0a; color: #fca5a5; border-color: #7f1d1d; }
.score-right { flex: 1; }
.tier-bar { display: flex; gap: 3px; margin-bottom: 6px; }
.tier-seg { height: 4px; flex: 1; border-radius: 2px; background: var(--border); transition: all .4s; }
.tier-seg.lit-green { background: var(--green); }
.tier-seg.lit-cyan { background: var(--acc); }
.tier-seg.lit-red { background: var(--red); }
.tier-label { font-size: 11px; color: var(--text3); }

/* ---- METRICS GRID ---- */
.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.metric-box {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 10px 12px;
  transition: border-color .2s;
}
.metric-box:hover { border-color: var(--border2); }
.metric-val {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.metric-val.highlight { color: var(--acc); }
.metric-lbl {
  font-size: 10px;
  color: var(--text3);
  margin-top: 2px;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 600;
}

/* ---- PROGRESS BARS ---- */
.progress-item { margin-bottom: 8px; }
.progress-row {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text2);
  margin-bottom: 4px;
}
.progress-track {
  height: 5px;
  background: var(--bg2);
  border-radius: 3px;
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 3px;
  transition: width .5s cubic-bezier(.4,0,.2,1);
}

/* ---- INSIGHTS ---- */
.insight-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--r2);
  font-size: 12px;
  margin-bottom: 6px;
  border-left: 3px solid;
  line-height: 1.4;
}
.insight-icon { font-size: 13px; flex-shrink: 0; margin-top: 1px; }
.insight-good { background: rgba(16,185,129,.1); border-color: var(--green); color: #86efac; }
.insight-bad { background: rgba(239,68,68,.1); border-color: var(--red); color: #fca5a5; }
.insight-warn { background: rgba(245,158,11,.1); border-color: var(--yellow); color: #fde68a; }
.insight-info { background: rgba(59,130,246,.1); border-color: var(--blue); color: #93c5fd; }

/* ---- HEATMAP ---- */
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.hm-cell {
  aspect-ratio: 1;
  border-radius: var(--r2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  transition: all .3s;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--text4);
  cursor: default;
  position: relative;
}
.hm-cell .hm-num {
  font-size: 16px;
  font-weight: 800;
}
.hm-cell .hm-sub {
  position: absolute;
  bottom: 4px;
  font-size: 9px;
  color: inherit;
  opacity: .7;
}

/* ---- CHARTS (inline in analyzer) ---- */
.charts-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.charts-grid-2x5 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}
.chart-mini-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 10px;
  position: relative;
}
.chart-mini-num {
  position: absolute;
  top: 7px;
  left: 9px;
  width: 18px;
  height: 18px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 9px;
  font-weight: 800;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
}
.chart-mini-title {
  font-size: 9px;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text3);
  margin-bottom: 7px;
  padding-left: 24px;
  font-weight: 700;
}
.chart-mini-wrap {
  position: relative;
  width: 100%;
  height: 90px;
}
.chart-mini-wrap canvas { width: 100% !important; }

/* ---- WEAK BADGE ---- */
.weak-alert {
  background: rgba(239,68,68,.1);
  border: 1px solid #7f1d1d;
  color: #fca5a5;
  border-radius: var(--r2);
  padding: 7px 10px;
  font-size: 11px;
  margin-top: 8px;
  display: none;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 320px;
}
.weak-alert.show { display: flex; }

/* ---- SHARE BOX ---- */
.share-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 8px 12px;
  margin-top: 8px;
}
.share-link {
  flex: 1;
  font-size: 11px;
  color: var(--acc);
  font-family: monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: .3px;
}

/* ---- PIN COMPARISON ---- */
.pin-compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.pin-compare-item {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 10px;
  text-align: center;
}
.pin-compare-val {
  font-size: 15px;
  font-weight: 800;
  color: var(--acc2);
  font-variant-numeric: tabular-nums;
}
.pin-compare-lbl { font-size: 10px; color: var(--text3); margin-top: 2px; text-transform: uppercase; }
.pin-equiv-badge {
  display: inline-block;
  background: rgba(124,58,237,.15);
  border: 1px solid rgba(124,58,237,.3);
  color: var(--purple);
  font-size: 11px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 20px;
  margin-top: 8px;
}

/* ---- GENERATOR PANEL ---- */
.generator-layout {
  padding: 20px;
  max-width: 1100px;
  margin: 0 auto;
}
.generator-filters {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
.filter-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
}
.filter-title {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text3);
  margin-bottom: 10px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}
.fopt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--r2);
  cursor: pointer;
  transition: .15s;
  font-size: 12px;
  color: var(--text2);
}
.fopt:hover { background: var(--bg3); color: var(--text); }
.fopt input[type=radio] { accent-color: var(--acc2); }
.gen-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
}
.gen-results {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}
.gen-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  cursor: pointer;
  transition: all .2s;
  text-align: center;
  position: relative;
}
.gen-card:hover { border-color: var(--acc2); transform: translateY(-3px); box-shadow: var(--glow); }
.gen-card canvas { display: block; margin: 0 auto 10px; }
.gen-card-score { font-size: 20px; font-weight: 800; }
.gen-card-meta { font-size: 10px; color: var(--text3); margin-top: 3px; }
.gen-card-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 8px;
  font-weight: 800;
}
.badge-best { background: #052e16; color: #4ade80; border: 1px solid #166534; }
.badge-weak { background: #2d0a0a; color: #fca5a5; border: 1px solid #7f1d1d; }

/* ---- SAVED PANEL ---- */
.saved-layout { padding: 20px; max-width: 1100px; margin: 0 auto; }
.saved-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.saved-search {
  flex: 1;
  min-width: 200px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 7px 12px;
  font-size: 12px;
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}
.saved-search:focus { border-color: var(--acc2); }
.saved-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.saved-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  cursor: pointer;
  transition: all .2s;
  position: relative;
}
.saved-card:hover { border-color: var(--acc2); box-shadow: var(--glow); }
.saved-card canvas { display: block; margin: 0 auto 8px; }
.saved-card-name { font-size: 12px; font-weight: 700; text-align: center; }
.saved-card-score {
  font-size: 22px;
  font-weight: 900;
  text-align: center;
  margin: 4px 0 2px;
}
.saved-card-meta { font-size: 10px; color: var(--text3); text-align: center; }
.saved-card-del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bg2);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text3);
  transition: all .2s;
}
.saved-card-del:hover { background: #450a0a; color: var(--red); border-color: var(--red); }
.saved-empty { text-align: center; padding: 60px 20px; color: var(--text3); font-size: 14px; }
.saved-empty-icon { font-size: 48px; margin-bottom: 12px; opacity: .4; }

/* ---- STATS PANEL ---- */
.stats-layout { padding: 20px; max-width: 1100px; margin: 0 auto; }
.stats-hero {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat-hero-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.stat-hero-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-hero-card.purple::before { background: var(--acc2); }
.stat-hero-card.cyan::before { background: var(--acc); }
.stat-hero-card.green::before { background: var(--green); }
.stat-hero-card.amber::before { background: var(--yellow); }
.stat-hero-val { font-size: 36px; font-weight: 900; font-variant-numeric: tabular-nums; }
.stat-hero-lbl { font-size: 11px; color: var(--text3); margin-top: 4px; text-transform: uppercase; letter-spacing: .5px; }
.stats-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
.stats-chart-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
}
.stats-chart-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text3); margin-bottom: 12px; font-weight: 700; }
.stats-chart-wrap { position: relative; width: 100%; height: 180px; }

/* ---- WEAK LIBRARY PANEL ---- */
.weaklib-layout { padding: 20px; max-width: 1100px; margin: 0 auto; }
.weaklib-intro {
  background: rgba(239,68,68,.08);
  border: 1px solid #7f1d1d;
  border-radius: var(--r);
  padding: 14px 16px;
  margin-bottom: 20px;
  color: #fca5a5;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.weaklib-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
}
.weak-card {
  background: var(--card);
  border: 1px solid #7f1d1d;
  border-radius: var(--r);
  padding: 12px;
  text-align: center;
  transition: all .2s;
  cursor: pointer;
}
.weak-card:hover { border-color: var(--red); box-shadow: 0 0 12px rgba(239,68,68,.2); }
.weak-card canvas { display: block; margin: 0 auto 8px; }
.weak-card-name { font-size: 11px; color: #f87171; font-weight: 700; }
.weak-card-nodes { font-size: 10px; color: var(--text3); margin-top: 2px; }
.weak-card-risk {
  display: inline-block;
  margin-top: 5px;
  font-size: 9px;
  padding: 2px 7px;
  border-radius: 8px;
  font-weight: 800;
}
.risk-critical { background: #2d0a0a; color: #fca5a5; border: 1px solid #7f1d1d; }
.risk-high { background: #3d2a00; color: #fde68a; border: 1px solid #78350f; }

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--card2);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text);
  z-index: 9999;
  transform: translateY(60px);
  opacity: 0;
  transition: all .3s cubic-bezier(.34,1.56,.64,1);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 320px;
  box-shadow: var(--shadow);
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }
.toast.info { border-color: var(--acc); }
.toast-icon { font-size: 14px; }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.7);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--r4);
  padding: 24px;
  width: 90%;
  max-width: 480px;
  box-shadow: var(--shadow);
  animation: modalIn .2s ease;
}
@keyframes modalIn { from{transform:scale(.95);opacity:0} to{transform:scale(1);opacity:1} }
.modal-title { font-size: 16px; font-weight: 800; margin-bottom: 6px; }
.modal-sub { font-size: 12px; color: var(--text2); margin-bottom: 16px; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.modal-input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text);
  outline: none;
  margin-bottom: 10px;
}
.modal-input:focus { border-color: var(--acc2); }

/* ---- KEYBOARD SHORTCUT PILL ---- */
.kbd {
  display: inline-flex;
  align-items: center;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: monospace;
  color: var(--text3);
}

/* ---- TOPBAR EMAIL ---- */
.topbar-email {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text2);
  text-decoration: none;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: var(--r2);
  border: 1px solid var(--border);
  background: var(--bg2);
  transition: all .2s;
}
.topbar-email:hover { border-color: var(--acc); color: var(--acc); }
.email-icon { font-size: 13px; }
.email-text { font-size: 11px; }

/* ---- MOBILE BOTTOM NAV ---- */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--card);
  border-top: 1px solid var(--border);
  z-index: 200;
  padding: 0 4px;
  box-shadow: 0 -4px 20px rgba(0,0,0,.3);
}
.mob-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex: 1;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--text3);
  cursor: pointer;
  border-radius: var(--r2);
  transition: all .2s;
  position: relative;
  padding: 6px 2px;
}
.mob-nav-btn.active { color: var(--acc2); }
.mob-nav-btn.active .mob-nav-icon { color: var(--acc2); }
.mob-nav-icon { font-size: 18px; line-height: 1; }
.mob-nav-label { font-size: 9px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; }
.mob-nav-badge {
  position: absolute;
  top: 6px;
  right: 12px;
  background: var(--acc4);
  color: #000;
  font-size: 8px;
  font-weight: 800;
  padding: 1px 4px;
  border-radius: 8px;
  min-width: 14px;
  text-align: center;
}
.mob-email-btn {
  text-decoration: none;
  color: var(--acc);
}
.mob-email-btn:hover, .mob-email-btn:focus { color: var(--acc); opacity: .8; }

/* ---- RESPONSIVE ---- */
@media (max-width: 1100px) {
  .analyzer-layout { grid-template-columns: 270px 1fr 250px; }
}
@media (max-width: 960px) {
  .analyzer-layout { grid-template-columns: 250px 1fr; }
  .analyzer-right { display: none; }
}
@media (max-width: 768px) {
  /* Topbar */
  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-tabs { display: none; }
  .topbar-logo .logo-text { font-size: 14px; }
  .email-text { display: none; }
  .topbar-email { padding: 4px 6px; }
  .logo-version { display: none; }

  /* App shell — leave room for bottom nav */
  .app-shell { grid-template-rows: 52px 1fr; }
  .main-content { height: calc(100vh - 52px - 60px); }

  /* Bottom nav visible */
  .mobile-bottom-nav { display: flex; }

  /* Analyzer: single column stack */
  .analyzer-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto;
    height: auto;
    min-height: unset;
  }
  .analyzer-left { border-right: none; border-bottom: 1px solid var(--border); }
  .analyzer-right { display: flex; border-left: none; border-top: 1px solid var(--border); }

  /* Canvas sizing */
  .canvas-container { padding: 16px 12px; }
  .canvas-wrap { width: 100%; max-width: 300px; }

  /* Canvas actions wrap nicely */
  .canvas-actions { gap: 5px; }
  .canvas-actions .btn { padding: 5px 10px; font-size: 10px; }

  /* Score display */
  .score-display { flex-direction: column; gap: 10px; }
  .score-number { font-size: 42px; }

  /* Metrics grid: 2 cols */
  .metrics-grid { grid-template-columns: 1fr 1fr; }

  /* Generator */
  .generator-layout { padding: 16px 12px; }
  .generator-filters { grid-template-columns: 1fr 1fr; }
  .gen-results { grid-template-columns: repeat(3, 1fr); }
  .gen-actions { flex-wrap: wrap; }

  /* Saved */
  .saved-layout { padding: 16px 12px; }
  .saved-toolbar { gap: 8px; }

  /* Stats */
  .stats-layout { padding: 16px 12px; }
  .stats-hero { grid-template-columns: 1fr 1fr; }
  .stats-charts { grid-template-columns: 1fr; }
  .stat-hero-val { font-size: 28px; }

  /* Weak lib */
  .weaklib-layout { padding: 16px 12px; }
  .weaklib-grid { grid-template-columns: repeat(3, 1fr); }

  /* Charts */
  .charts-grid-2x5 { grid-template-columns: 1fr 1fr; }

  /* Toast — above bottom nav */
  .toast { bottom: 72px; right: 12px; left: 12px; max-width: unset; }
}

@media (max-width: 480px) {
  /* Topbar: tighter */
  .topbar { padding: 0 10px; gap: 6px; }
  .topbar-email { display: none; }

  /* Generator */
  .generator-filters { grid-template-columns: 1fr; }
  .gen-results { grid-template-columns: 1fr 1fr; }

  /* Stats */
  .stats-hero { grid-template-columns: 1fr 1fr; }

  /* Weak lib */
  .weaklib-grid { grid-template-columns: repeat(2, 1fr); }

  /* Charts 1-col on tiny screens */
  .charts-grid-2x5 { grid-template-columns: 1fr; }

  /* Score display compact */
  .score-number { font-size: 36px; }

  /* Saved grid: 2 col */
  .saved-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 360px) {
  .gen-results { grid-template-columns: 1fr; }
  .weaklib-grid { grid-template-columns: 1fr 1fr; }
  .mob-nav-label { display: none; }
  .mob-nav-btn { justify-content: center; }
  .mob-nav-icon { font-size: 20px; }
}
