/* Indian History Timeline Explorer */
:root {
  --bg: #faf7f2;
  --surface: #ffffff;
  --surface-2: #f3eee6;
  --border: #e4ddd2;
  --text: #2a2521;
  --muted: #6f665d;
  --accent: #c2410c;
  --accent-soft: #fde8dc;
  --link: #9a3412;
  --ok: #15803d;
  --err: #b91c1c;
  --shadow: 0 1px 2px rgba(40, 30, 20, .06), 0 4px 16px rgba(40, 30, 20, .06);
  --radius: 10px;
  --header-h: 56px;
  /* System fonts only — no web-font downloads. */
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Noto Serif", Georgia, serif;
  --sea: #dbe7ee;
  --land: #f4efe6;
  --land-far: #e7e2da;
  --land-stroke: #b9ad9b;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #171412;
    --surface: #211d1a;
    --surface-2: #2a2521;
    --border: #3a332d;
    --text: #efe8df;
    --muted: #a89d91;
    --accent: #f97316;
    --accent-soft: #3b2415;
    --link: #fdba74;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.3);
    --sea: #16222b;
    --land: #2b2621;
    --land-far: #221e1b;
    --land-stroke: #5a5047;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.2; margin: 0 0 .5em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.4rem; margin-top: 1.6em; }
h3 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.tabular { font-variant-numeric: tabular-nums; }

/* Header */
.site-header {
  position: sticky; top: 0; z-index: 1000; height: var(--header-h);
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle, transparent 5px, #fff 5px 7px, var(--accent) 7px); }
.brand-text em { font-style: normal; font-weight: 500; color: var(--muted); }
.site-nav { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.site-nav > a { padding: 6px 12px; border-radius: 8px; color: var(--text); font-weight: 500; }
.site-nav > a:hover { background: var(--surface-2); text-decoration: none; }
.site-nav > a.active { background: var(--accent-soft); color: var(--accent); }
.nav-search input { width: 220px; padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
.nav-toggle { display: none; margin-left: auto; background: none; border: 1px solid var(--border); border-radius: 8px; font-size: 18px; padding: 4px 10px; color: var(--text); }
@media (max-width: 1440px) {
  .brand-text em { display: none; }
  .nav-toggle { display: block; }
  .site-nav { display: none; position: absolute; top: var(--header-h); left: 0; right: 0; flex-direction: column; align-items: stretch; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); box-shadow: var(--shadow); }
  body.nav-open .site-nav { display: flex; }
  .nav-search input { width: 100%; }
}

.container { max-width: 1180px; margin: 0 auto; padding: 28px 16px 48px; }
.site-footer { border-top: 1px solid var(--border); padding: 20px 16px; text-align: center; color: var(--muted); font-size: .85rem; }
.site-footer p { margin: .3em 0; }

.flash { max-width: 1180px; margin: 12px auto 0; padding: 10px 14px; border-radius: 8px; }
.flash-success { background: #dcfce7; color: #14532d; }
.flash-error { background: #fee2e2; color: #7f1d1d; }

/* Generic components */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge-major { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; flex: none; }
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-weight: 500; cursor: pointer; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { color: var(--err); }
.btn-sm { padding: 4px 10px; font-size: .85rem; }
table.data { width: 100%; border-collapse: collapse; background: var(--surface); }
table.data th, table.data td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); background: var(--surface-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin: 16px 0; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: .8rem; color: var(--muted); }
input[type=text], input[type=search], input[type=number], input[type=password], select, textarea {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 100px; width: 100%; }
.pager { display: flex; gap: 6px; margin-top: 16px; flex-wrap: wrap; }
.pager a, .pager span { padding: 5px 11px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); }
.pager .current { background: var(--accent); color: #fff; border-color: var(--accent); }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: 8px; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.kv dt { color: var(--muted); font-size: .85rem; }
.kv dd { margin: 0; }
.empty { padding: 24px; text-align: center; color: var(--muted); }

/* ===================================================================
   Explorer
   =================================================================== */
body.full-bleed { height: 100vh; overflow: hidden; }
.main-bleed { height: calc(100vh - var(--header-h)); }
.explorer { display: grid; grid-template-columns: 1fr 380px; grid-template-rows: 1fr auto; height: 100%; }
.explorer-map { position: relative; grid-column: 1; grid-row: 1; min-height: 0; }
#map { position: absolute; inset: 0; }
.explorer-panel { grid-column: 2; grid-row: 1 / span 2; border-left: 1px solid var(--border); background: var(--surface); overflow-y: auto; display: flex; flex-direction: column; }
.explorer-controls { grid-column: 1; grid-row: 2; background: var(--surface); border-top: 1px solid var(--border); padding: 10px 16px 12px; }

.year-overlay {
  position: absolute; top: 14px; left: 14px; z-index: 500; pointer-events: none;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(6px);
  border: 1px solid var(--border); border-radius: 12px; padding: 8px 16px; box-shadow: var(--shadow);
}
.year-overlay .region-kicker { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.year-overlay .y { font: 700 2rem/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.year-overlay .p { color: var(--muted); font-size: .85rem; max-width: 420px; }
.map-toggles { position: absolute; top: 14px; right: 14px; z-index: 500; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 8px 12px; box-shadow: var(--shadow); font-size: .85rem; display: flex; flex-direction: column; gap: 3px; }
.map-toggles summary { cursor: pointer; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.map-toggles[open] summary { margin-bottom: 4px; }
.map-toggles label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.map-note { position: absolute; left: 12px; bottom: 22px; z-index: 500; font-size: .72rem; color: var(--muted); background: color-mix(in srgb, var(--surface) 85%, transparent); padding: 3px 8px; border-radius: 6px; }

.control-row { display: flex; align-items: center; gap: 10px; }
.year-input { display: flex; gap: 4px; align-items: center; }
.year-input input { width: 84px; text-align: right; font-variant-numeric: tabular-nums; }
.play-btn { width: 38px; height: 38px; justify-content: center; padding: 0; border-radius: 50%; font-size: 14px; }
.presets { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: thin; }
.presets button { flex: none; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-size: .8rem; cursor: pointer; }
.presets button:hover { border-color: var(--accent); color: var(--accent); }

.track { position: relative; flex: 1; }
.bands { position: relative; height: 44px; margin-bottom: 4px; }
.band { position: absolute; height: 12px; border-radius: 3px; opacity: .55; cursor: pointer; overflow: hidden; font-size: 9px; line-height: 12px; color: #fff; padding: 0 3px; white-space: nowrap; transition: opacity .15s; }
.band:hover, .band.on { opacity: 1; }
.event-rail { position: relative; height: 16px; margin: 2px 0 0; border-top: 1px solid var(--border); }
.rail-tick { position: absolute; top: 3px; width: 2px; height: 7px; margin-left: -1px; padding: 0; border: 0; border-radius: 1px; background: var(--muted); opacity: .45; cursor: pointer; }
.rail-tick.major { top: 0; height: 13px; background: var(--accent); opacity: .8; }
.rail-tick.near { opacity: 1; box-shadow: 0 0 0 1px var(--surface); }
.rail-tick:hover, .rail-tick:focus-visible { opacity: 1; transform: scaleX(2); outline: none; }
.rail-legend { margin-top: 4px; }
.rail-key { display: inline-block; width: 3px; height: 9px; background: var(--muted); vertical-align: -1px; margin: 0 3px 0 8px; }
.rail-key.major { background: var(--accent); height: 12px; margin-left: 0; }
.panel-subhead { margin: 18px 18px 6px; font: 600 .72rem/1 var(--font); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.slider { width: 100%; margin: 0; accent-color: var(--accent); height: 22px; cursor: pointer; }
.ticks { position: relative; height: 16px; font-size: .68rem; color: var(--muted); }
.ticks span { position: absolute; transform: translateX(-50%); white-space: nowrap; font-variant-numeric: tabular-nums; }

.panel-head { padding: 16px 18px 10px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--surface); z-index: 2; }
.panel-head h2 { margin: 0; font-size: 1.25rem; }
.period-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.period-chip { font-size: .75rem; padding: 2px 8px; border-radius: 999px; color: #fff; font-weight: 600; }
.panel-filter { margin-top: 10px; width: 100%; }
.panel-body { padding: 6px 0 20px; }
.region-group h3 { font: 600 .72rem/1 var(--font); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 14px 18px 6px; }
.pol { display: flex; gap: 10px; padding: 8px 18px; cursor: pointer; border-left: 3px solid transparent; }
.pol:hover, .pol.hl { background: var(--surface-2); border-left-color: var(--accent); }
.pol .swatch { margin-top: 5px; }
.pol-name { font-weight: 600; }
.pol-name a { color: var(--text); }
.pol-meta { font-size: .8rem; color: var(--muted); }
.pol-phase { font-size: .8rem; color: var(--accent); font-weight: 500; }
.pol.minor .pol-name { font-weight: 500; font-size: .92rem; }
.ev-list { list-style: none; margin: 0; padding: 0 18px; }
.ev-list li { padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: .88rem; cursor: pointer; }
.ev-list .when { font-weight: 700; font-variant-numeric: tabular-nums; margin-right: 6px; }
.ev-list .major { color: var(--accent); }

.loading-bar { position: absolute; top: 0; left: 0; height: 3px; background: var(--accent); z-index: 600; width: 0; transition: width .3s; }
.loading-bar.on { width: 70%; }

@media (max-width: 900px) {
  body.full-bleed { height: auto; overflow: auto; }
  .main-bleed { height: auto; }
  .explorer { display: flex; flex-direction: column; }
  .explorer-controls { order: 1; border-top: 0; border-bottom: 1px solid var(--border); }
  .control-row { flex-wrap: wrap; justify-content: space-between; }
  .control-row .track { order: 3; flex-basis: 100%; }
  .explorer-map { order: 2; height: 58vh; }
  .explorer-panel { order: 3; border-left: 0; overflow: visible; }
  .panel-head { position: static; }
  .year-overlay { left: 10px; top: 10px; padding: 6px 12px; }
  .year-overlay .region-kicker { display: none; }
  .year-overlay .region-kicker { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.year-overlay .y { font-size: 1.4rem; }
  .year-overlay .p { display: none; }
  .map-toggles { top: auto; bottom: 26px; right: 10px; }
}

/* ===================================================================
   Timeline (swimlane chart)
   =================================================================== */
.tl { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.tl-inner { min-width: 960px; position: relative; padding: 0 0 10px; }
.tl-axis { position: sticky; top: 0; height: 28px; background: var(--surface); border-bottom: 1px solid var(--border); z-index: 3; margin-left: 200px; }
.tl-axis span { position: absolute; top: 7px; transform: translateX(-50%); font-size: .7rem; color: var(--muted); white-space: nowrap; }
.tl-grid { position: absolute; top: 0; bottom: 0; left: 200px; right: 0; pointer-events: none; }
.tl-grid i { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--border); opacity: .6; }
.tl-group { padding: 10px 12px 2px; font: 600 .72rem/1 var(--font); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); position: relative; z-index: 1; }
.tl-row { display: flex; align-items: center; height: 22px; position: relative; z-index: 1; }
.tl-row:hover { background: var(--surface-2); }
.tl-label { width: 200px; flex: none; padding: 0 12px; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-label a { color: var(--text); }
.tl-lane { position: relative; flex: 1; height: 100%; }
.tl-bar { position: absolute; top: 4px; height: 14px; border-radius: 4px; min-width: 3px; opacity: .85; }
.tl-bar:hover { opacity: 1; outline: 2px solid var(--text); }
.tl-bar.circa { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.25) 0 4px, transparent 4px 8px); }
.tl-periods { margin-left: 200px; position: relative; height: 26px; margin-top: 6px; }
.tl-periods a { position: absolute; top: 2px; height: 20px; border-radius: 4px; color: #fff; font-size: .68rem; line-height: 20px; padding: 0 5px; overflow: hidden; white-space: nowrap; opacity: .9; }

/* Polity page */
.polity-hero { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.polity-hero .swatch { width: 18px; height: 56px; border-radius: 5px; }
.polity-hero h1 { margin-bottom: 6px; }
.mini-map { height: 320px; border-radius: var(--radius); border: 1px solid var(--border); }
.ruler-list { list-style: none; padding: 0; margin: 0; }
.ruler-list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.ruler-list .years { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: .88rem; }
.ruler-list .notes { font-size: .82rem; color: var(--muted); }
.phase-head { margin: 14px 0 2px; font-weight: 700; color: var(--accent); font-size: .9rem; }

/* Period timeline on home of timeline page */
.era-strip { display: flex; flex-direction: column; gap: 10px; }
.era { display: grid; grid-template-columns: 170px 1fr; gap: 14px; align-items: start; padding: 12px 16px; border-left: 5px solid; background: var(--surface); border-radius: 0 var(--radius) var(--radius) 0; box-shadow: var(--shadow); }
.era .when { font-weight: 700; font-variant-numeric: tabular-nums; }
@media (max-width: 640px) { .era { grid-template-columns: 1fr; } }

.callout { border-left: 4px solid var(--accent); background: var(--accent-soft); padding: 14px 18px; border-radius: 0 var(--radius) var(--radius) 0; }
.prose { max-width: 760px; }
.prose p, .prose li { line-height: 1.7; }

/* Admin */
.admin-nav { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-nav a { padding: 6px 12px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.admin-nav a.active { background: var(--accent); color: #fff; border-color: var(--accent); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.field label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: 4px; }
.field input:not([type=checkbox]), .field select, .field textarea { width: 100%; }
.field .help { font-size: .78rem; color: var(--muted); margin-top: 3px; }
.field.error input, .field.error select { border-color: var(--err); }
.field .err { color: var(--err); font-size: .8rem; }
.auth-box { max-width: 380px; margin: 60px auto; }
.stat { font: 700 2rem/1 var(--serif); }

/* ===================================================================
   SVG map engine (assets/js/svgmap.js)
   =================================================================== */
.map-canvas { position: relative; overflow: hidden; background: var(--sea); touch-action: none; outline: none; }
.svgmap svg { display: block; width: 100%; height: 100%; cursor: grab; user-select: none; -webkit-user-select: none; }
.svgmap svg.sm-dragging { cursor: grabbing; }
.sm-sea { fill: var(--sea); }
.sm-country { stroke: var(--land-stroke); stroke-width: .6; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.sm-neighbour { fill: var(--land-far); }
.sm-saarc { fill: var(--land); }
.sm-border { fill: none; stroke: var(--text); stroke-opacity: .35; stroke-width: 1; stroke-dasharray: 3 3; vector-effect: non-scaling-stroke; pointer-events: none; }
.sm-country-label { fill: var(--text); fill-opacity: .28; font-family: var(--font); font-weight: 700; letter-spacing: .15em; text-anchor: middle; pointer-events: none; }
.sm-capital { fill: var(--text); fill-opacity: .45; pointer-events: none; }
.sm-capital-label { fill: var(--text); fill-opacity: .45; font-family: var(--font); pointer-events: none; }
.sm-polity { stroke-linejoin: round; transition: fill-opacity .12s; }
.sm-polity:hover { fill-opacity: .4; }
.sm-label { font-family: var(--font); font-weight: 600; fill: #2a2521; text-anchor: middle; dominant-baseline: middle; pointer-events: none;
  paint-order: stroke; stroke: #fff; stroke-width: calc(3px * var(--sm-unit, 1)); stroke-linejoin: round; }
.sm-label.major { font-weight: 800; }
.sm-label.hl { fill: var(--accent); }
.sm-event { fill: #c2410c; stroke: #fff; stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sm-event.minor { fill: #f59e0b; }
.sm-site { fill: #2a2521; stroke: #fff; stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.sm-dot { stroke: #fff; stroke-width: 1; vector-effect: non-scaling-stroke; }
.sm-tip { position: absolute; z-index: 20; pointer-events: none; opacity: 0; background: var(--text); color: var(--surface); font-size: .75rem; padding: 3px 8px; border-radius: 5px; white-space: nowrap; transition: opacity .1s; }
.sm-tip.on { opacity: .92; }
.sm-popup { position: absolute; z-index: 30; display: none; width: 280px; max-width: calc(100% - 16px); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); padding: 12px 14px; font-size: 13px; line-height: 1.45; }
.sm-popup.on { display: block; }
.sm-popup h4 { margin: 0 22px 4px 0; font: 700 15px/1.2 var(--serif); }
.sm-popup p { margin: 6px 0; }
.sm-popup-close { position: absolute; top: 6px; right: 8px; border: 0; background: none; font-size: 18px; line-height: 1; color: var(--muted); cursor: pointer; }
.sm-controls { position: absolute; left: 12px; bottom: 44px; z-index: 10; display: flex; flex-direction: column; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); }
.sm-controls button { width: 34px; height: 32px; border: 0; border-bottom: 1px solid var(--border); background: var(--surface); color: var(--text); font-size: 17px; cursor: pointer; }
.sm-controls button:last-child { border-bottom: 0; }
.sm-controls button:hover { background: var(--surface-2); }
.mini-map .sm-controls { bottom: 12px; }
@media (prefers-color-scheme: dark) {
  .sm-label { fill: #f5efe6; stroke: #1b1714; }
}

/* ===================================================================
   Quiz
   =================================================================== */
.quiz-wrap { max-width: 820px; margin: 0 auto; }
.quiz-card { padding: 26px 28px; }
.quiz-hero h1 { margin-bottom: 6px; }
.quiz-field { border: 0; padding: 0; margin: 18px 0 0; min-width: 0; }
.quiz-field legend { font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 8px; }
.quiz-field select { width: 100%; }
.quiz-row { display: flex; gap: 24px; flex-wrap: wrap; }
.chip-group { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: .9rem; cursor: pointer; }
.chip span { color: var(--muted); font-size: .78rem; margin-left: 4px; font-variant-numeric: tabular-nums; }
.chip:hover { border-color: var(--accent); }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on span { color: rgba(255,255,255,.8); }
.quiz-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 22px; }
.btn-lg { padding: 12px 26px; font-size: 1.05rem; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.quiz-top { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.quiz-count { margin-left: auto; color: var(--muted); font-size: .88rem; }
.quiz-score { font-weight: 700; font-size: .88rem; }
.badge.diff-easy { color: var(--ok); }
.badge.diff-hard { color: var(--err); }
.quiz-bar { height: 5px; background: var(--surface-2); border-radius: 3px; margin: 12px 0 18px; overflow: hidden; }
.quiz-bar div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.quiz-question { font-size: 1.35rem; line-height: 1.35; margin: 0 0 18px; outline: none; }
.quiz-options { display: grid; gap: 10px; }
.quiz-opt { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; padding: 12px 14px; border: 1.5px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; cursor: pointer; transition: border-color .12s, background .12s; }
.quiz-opt:hover:not([disabled]) { border-color: var(--accent); background: var(--accent-soft); }
.quiz-opt[disabled] { cursor: default; }
.quiz-letter { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: .8rem; background: var(--surface-2); }
.quiz-opt.correct { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 12%, var(--surface)); }
.quiz-opt.correct .quiz-letter { background: var(--ok); color: #fff; }
.quiz-opt.wrong { border-color: var(--err); background: color-mix(in srgb, var(--err) 10%, var(--surface)); }
.quiz-opt.wrong .quiz-letter { background: var(--err); color: #fff; }
.quiz-feedback { margin-top: 16px; padding: 12px 16px; border-radius: 10px; display: flex; flex-direction: column; gap: 6px; font-size: .94rem; }
.quiz-feedback.ok { background: color-mix(in srgb, var(--ok) 10%, var(--surface)); border: 1px solid color-mix(in srgb, var(--ok) 35%, transparent); }
.quiz-feedback.bad { background: color-mix(in srgb, var(--err) 8%, var(--surface)); border: 1px solid color-mix(in srgb, var(--err) 30%, transparent); }
.quiz-keys { margin: 14px 0 0; }
.quiz-bigscore { font: 700 2.6rem/1.1 var(--serif); color: var(--accent); margin: 6px 0; }
.quiz-review { padding-left: 20px; }
.quiz-review li { padding: 12px 0; border-bottom: 1px solid var(--border); }
.quiz-review .rq { font-weight: 600; margin-bottom: 4px; }
.quiz-review .ra.bad { color: var(--err); }
.quiz-review .ra.ok { color: var(--ok); }
@media (max-width: 640px) { .quiz-card { padding: 18px 16px; } .quiz-question { font-size: 1.15rem; } }

/* Personalities */
.person-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.person-card { display: block; color: inherit; padding: 14px 16px; }
.person-card:hover { text-decoration: none; border-color: var(--accent); }
.person-card .life { font-size: .82rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.person-card .kf { font-size: .9rem; margin-top: 4px; }
.people-list { list-style: none; margin: 0; padding: 0 18px; }
.people-list li { padding: 6px 0; border-bottom: 1px dashed var(--border); font-size: .88rem; }
.people-list .kf { color: var(--muted); font-size: .8rem; }
.outcome { margin-top: 4px; font-size: .85rem; }
.outcome::before { content: "Result: "; font-weight: 700; color: var(--accent); }

/* Books */
.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.book-card { display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; }
.book-kind { font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }
.book-title { font-size: 1.02rem; margin: 0; }
.book-author { font-size: .88rem; }
.book-note { font-size: .88rem; margin: 2px 0; color: var(--text); flex: 1; }
.book-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.book-buy { display: flex; gap: 8px; margin-top: 6px; }
.book-buy .btn { flex: 1; justify-content: center; }
.books-box { margin-top: 28px; }
.affiliate-note { margin-top: 8px; }
.affiliate-banner { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px; color: var(--muted); }
.book-filters { display: flex; flex-direction: column; gap: 12px; margin: 18px 0 8px; }
.filter-label { display: block; font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-bottom: 6px; }
a.chip:hover { text-decoration: none; }

/* Report a problem */
.report-wrap { margin-top: 8px; }
.report-link { background: none; border: 0; padding: 0; color: var(--muted); font: inherit; font-size: .82rem; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.report-link:hover { color: var(--err); }
.report-done { font-size: .82rem; color: var(--ok); }
.report-form { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.report-form label { display: flex; flex-direction: column; gap: 4px; font-size: .82rem; font-weight: 600; }
.report-form select, .report-form textarea { font-weight: 400; min-height: 0; }
.report-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.report-msg { font-size: .8rem; color: var(--muted); }
.report-card { margin-bottom: 14px; }
.report-head { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.report-options { margin: 0 0 8px; padding-left: 22px; }
.report-options .is-answer { color: var(--ok); font-weight: 600; }
.report-list { margin: 8px 0; padding-left: 18px; font-size: .9rem; }
.report-list li { margin: 4px 0; }

/* Accounts */
.nav-account { display: inline-flex; gap: 6px; align-items: center; margin-left: 6px; }
.nav-account > a:not(.btn) { padding: 6px 10px; border-radius: 8px; color: var(--text); font-weight: 500; white-space: nowrap; }
.nav-account > a:not(.btn):hover { background: var(--surface-2); text-decoration: none; }
.nav-account > a.active { background: var(--accent-soft); color: var(--accent); }
.badge-pro { background: linear-gradient(135deg, #f59e0b, #c2410c); color: #fff; border: 0; font-size: .65rem; }
@media (max-width: 1440px) { .nav-account { margin: 6px 0; } }
.form-stack { display: flex; flex-direction: column; gap: 12px; }
.form-stack .field input { width: 100%; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: .9rem; }
.auth-links { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: .9rem; margin-top: 14px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin: 14px 0; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .v { font: 700 1.6rem/1.1 var(--serif); font-variant-numeric: tabular-nums; }
.kpi .l { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi .s { font-size: .78rem; color: var(--muted); }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin: 18px 0; }
.plan { text-align: center; padding: 22px 18px; position: relative; }
.plan.best { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow); }
.plan .price { font: 700 2.2rem/1 var(--serif); margin: 10px 0 4px; }
.plan .per { color: var(--muted); font-size: .85rem; }
.plan .ribbon { position: absolute; top: -11px; left: 50%; transform: translateX(-50%); background: var(--accent); color: #fff; font-size: .7rem; font-weight: 700; padding: 3px 10px; border-radius: 999px; }
.benefits { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 20px; }
.benefits li::before { content: "✓ "; color: var(--ok); font-weight: 700; }
.quota-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--border); font-size: .9rem; margin-top: 16px; }
.quota-bar.empty { background: var(--accent-soft); border-color: var(--accent); }
.lb-table td:first-child { width: 48px; font-weight: 700; }
.lb-me { background: var(--accent-soft); }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 14px 0; }
.chart { width: 100%; height: auto; display: block; }
.chart .bar { fill: var(--accent); opacity: .85; }
.chart .bar:hover { opacity: 1; }
.chart text { fill: var(--muted); font-size: 10px; font-family: var(--font); }
.chart .grid { stroke: var(--border); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem; }
pre.trace { white-space: pre-wrap; font-size: .75rem; background: var(--surface-2); padding: 10px; border-radius: 8px; max-height: 320px; overflow: auto; }
.quiz-opt.pending { border-color: var(--accent); opacity: .7; }
.admin-nav-content { margin-top: -12px; padding-top: 8px; border-top: 1px dashed var(--border); align-items: center; }
.admin-nav-content a { font-size: .85rem; padding: 4px 10px; }
a.kpi:hover { border-color: var(--accent); text-decoration: none; }

/* Hindi / Devanagari */
.lang-hi, .lang-hi input, .lang-hi select, .lang-hi textarea, .lang-hi button {
  font-family: "Noto Sans Devanagari", "Kohinoor Devanagari", "Nirmala UI", "Mangal", var(--font);
}
.lang-hi h1, .lang-hi h2, .lang-hi h3, .lang-hi .stat, .lang-hi .year-overlay .y, .lang-hi .quiz-bigscore, .lang-hi .kpi .v, .lang-hi .plan .price {
  font-family: "Noto Serif Devanagari", "Kohinoor Devanagari", "Nirmala UI", "Mangal", var(--serif);
}
.lang-hi { line-height: 1.65; }
.lang-hi .outcome::before { content: "परिणाम: "; }
.lang-switch { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-left: 6px; flex: none; }
.lang-switch a { padding: 5px 9px; font-size: .82rem; font-weight: 600; color: var(--muted); }
.lang-switch a:hover { text-decoration: none; background: var(--surface-2); }
.lang-switch a.on { background: var(--accent); color: #fff; }
@media (max-width: 1440px) { .lang-switch { margin: 6px 0; align-self: flex-start; } }
