/* Kala Express — phone-first, with wider layouts at the end of the file. Cream paper, indigo ink, marigold accent. */
:root {
  --bg: #f6f0e4;
  --card: #fffdf8;
  --ink: #1f1d30;
  --muted: #6d6678;
  --line: #e4dbc8;
  --brand: #26336f;
  --brand-ink: #fffdf8;
  --accent: #d9731a;
  --accent-soft: #fbe8d0;
  --good: #1c7f55;
  --good-soft: #dff2e8;
  --bad: #bf3b2b;
  --bad-soft: #fbe3de;
  --chip: #ede4d1;
  --nagara: #d9731a;
  --dravida: #3949a3;
  --vesara: #1c7f55;
  --early: #8a5a9e;
  --other: #8c8478;
  --shadow: 0 1px 2px rgb(60 45 20 / 8%), 0 6px 18px rgb(60 45 20 / 6%);
  --serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, 'Segoe UI', Roboto, 'Noto Sans', 'Noto Sans Devanagari', 'Kohinoor Devanagari', sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #15141d;
    --card: #1f1d2a;
    --ink: #f2ecdf;
    --muted: #a8a1b6;
    --line: #34314a;
    --brand: #a9b8ff;
    --brand-ink: #15141d;
    --accent: #f2a654;
    --accent-soft: #3b2c1b;
    --good: #5cc797;
    --good-soft: #17352a;
    --bad: #f28674;
    --bad-soft: #3d1f1b;
    --chip: #2b283a;
    --nagara: #f2a654;
    --dravida: #a9b8ff;
    --vesara: #5cc797;
    --early: #d3a4e6;
    --other: #a8a1b6;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
    color-scheme: dark;
  }
}

:root[data-theme='dark'] {
  --bg: #15141d;
  --card: #1f1d2a;
  --ink: #f2ecdf;
  --muted: #a8a1b6;
  --line: #34314a;
  --brand: #a9b8ff;
  --brand-ink: #15141d;
  --accent: #f2a654;
  --accent-soft: #3b2c1b;
  --good: #5cc797;
  --good-soft: #17352a;
  --bad: #f28674;
  --bad-soft: #3d1f1b;
  --chip: #2b283a;
  --nagara: #f2a654;
  --dravida: #a9b8ff;
  --vesara: #5cc797;
  --early: #d3a4e6;
  --other: #a8a1b6;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, p, ol, ul, dl, dd { margin: 0; }
ol, ul { padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; align-items: center; gap: 10px; font: 700 18px/1 var(--serif); color: var(--brand); letter-spacing: 0.2px; }
/* three coaches on a rail */
.brand-mark {
  width: 34px;
  height: 14px;
  border-bottom: 2px solid var(--brand);
  background:
    linear-gradient(var(--accent), var(--accent)) 0 0 / 9px 10px no-repeat,
    linear-gradient(var(--brand), var(--brand)) 12px 0 / 9px 10px no-repeat,
    linear-gradient(var(--brand), var(--brand)) 24px 0 / 9px 10px no-repeat;
  border-radius: 2px 2px 0 0;
}

#app { max-width: 600px; margin: 0 auto; padding: 16px 16px 24px; }
.view > * + * { margin-top: 16px; }

.tabbar {
  position: fixed;
  inset: auto 0 0;
  z-index: 5;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--card);
  border-top: 1px solid var(--line);
}
.tabbar a { display: grid; justify-items: center; gap: 2px; padding: 6px 0; font-size: 12px; color: var(--muted); border-radius: 12px; }
.tabbar a span { font-size: 20px; line-height: 1; }
.tabbar a.on { color: var(--brand); font-weight: 700; background: var(--chip); }
.in-quiz .tabbar { display: none; }
.in-quiz { padding-bottom: env(safe-area-inset-bottom); }

/* type */
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); }
.page-title { font: 700 28px/1.15 var(--serif); }
h2 { font: 700 17px/1.3 var(--sans); }
h2 small { font-weight: 400; color: var(--muted); font-size: 13px; margin-left: 6px; }
small { color: var(--muted); font-size: 13px; }
.note, .empty { color: var(--muted); font-size: 14px; }
.empty { padding: 24px 0; text-align: center; }
.nm-en { font-weight: 600; }
.nm-hi { color: var(--muted); font-size: 0.92em; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 16px; box-shadow: var(--shadow); }
.card > * + * { margin-top: 10px; }
.block > * + * { margin-top: 10px; }

/* home */
.hero h1 { font: 700 34px/1.1 var(--serif); margin-top: 6px; }
.hero h1 em { color: var(--accent); font-style: italic; }
.lede { margin-top: 10px; color: var(--muted); }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stat-row div { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 10px 8px; text-align: center; }
.card .stat-row { margin-top: 0; }
.card .stat-row div { background: var(--bg); }
.stat-row b { display: block; font: 700 24px/1.1 var(--serif); color: var(--brand); }
.stat-row span { font-size: 12px; color: var(--muted); }

.cta { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-radius: 18px; background: var(--brand); color: var(--brand-ink); box-shadow: var(--shadow); }
.cta b { display: block; font-size: 18px; }
.cta small { color: inherit; opacity: 0.8; }
.cta i { font-style: normal; font-size: 24px; }
.cta.small { padding: 12px 14px; border-radius: 14px; }
.cta.small b { font-size: 15px; }

.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: grid; gap: 2px; }
.card .quick { background: var(--bg); }
.quick b { color: var(--brand); }
.text-link { display: inline-block; color: var(--brand); font-weight: 600; padding: 4px 0; }
.weak-link { display: block; padding: 12px 14px; border-radius: 14px; background: var(--accent-soft); color: var(--ink); }
.how ol { counter-reset: step; display: grid; gap: 10px; }
.how li { counter-increment: step; position: relative; padding-left: 38px; }
.how li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: grid; place-items: center; }

/* lists of dibbe */
.search { width: 100%; padding: 12px 14px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); color: var(--ink); font: inherit; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--chip); font-size: 14px; font-weight: 600; white-space: nowrap; }
.chip.on { background: var(--brand); color: var(--brand-ink); }
.track-sub { color: var(--muted); font-size: 14px; margin: 12px 0 10px; }
#browse > * + * { margin-top: 4px; }

.deck-card { display: flex; gap: 12px; align-items: center; padding: 12px; margin-bottom: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.coach { flex: none; width: 40px; height: 40px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); font: 700 18px/40px var(--serif); text-align: center; }
.deck-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.deck-main b { font-size: 16px; }
.meter { display: flex; height: 6px; border-radius: 3px; background: var(--chip); overflow: hidden; margin-top: 6px; }
.meter i { display: block; height: 100%; }
.meter .strong, .key.strong { background: var(--good); }
.meter .learning, .key.learning { background: var(--accent); }
.key { display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.track-row { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; align-items: baseline; }
.track-row .meter { grid-column: 1 / -1; margin-top: 2px; }

.hit-row { display: flex; gap: 12px; align-items: baseline; padding: 10px 0; border-bottom: 1px solid var(--line); }
.hit-row small { display: block; }
.yr { flex: none; font: 700 14px/1.4 var(--serif); color: var(--accent); min-width: 56px; }

/* one dibba */
.back { color: var(--brand); font-weight: 600; }
.deck-head h1 { font: 700 28px/1.15 var(--serif); margin-top: 4px; }
.deck-head .span { color: var(--accent); font: 700 16px var(--serif); margin-top: 2px; }
.deck-head .about { margin-top: 8px; color: var(--muted); }

.yaad { border-color: var(--accent); background: var(--accent-soft); }
.mnemonic { font: 500 20px/1.75 var(--serif); }
.hit { display: inline; padding: 0 3px; margin: 0; border-radius: 5px; background: var(--accent); color: #fff; font-weight: 700; line-height: 1.3; }
.hit.on { background: var(--brand); color: var(--brand-ink); }
.hit-out { font-size: 15px; min-height: 24px; }
.hit-out .yr { min-width: 0; margin-left: 6px; }
.song p { font: italic 16px/1.6 var(--serif); padding-left: 12px; border-left: 3px solid var(--line); }
.anchor { border-left: 4px solid var(--brand); }

.rail-head { display: flex; align-items: center; justify-content: space-between; }
.rail { position: relative; margin-left: 6px; border-left: 3px solid var(--line); }
.stop { position: relative; padding-left: 18px; }
.stop::before { content: ''; position: absolute; left: -8px; top: 18px; width: 13px; height: 13px; border-radius: 50%; background: var(--bg); border: 3px solid var(--brand); }
.stop summary { display: flex; align-items: flex-start; gap: 10px; padding: 12px 0; cursor: pointer; list-style: none; }
.stop summary::-webkit-details-marker { display: none; }
.stop + .stop summary { border-top: 1px solid var(--line); }
.who { flex: 1; min-width: 0; display: grid; }
.who small { display: block; }
.nm { display: block; line-height: 1.35; }
.star { color: var(--accent); margin-left: 4px; }
.twin { color: var(--accent); font-weight: 700; }
.dots { flex: none; display: inline-flex; gap: 3px; padding-top: 8px; }
.dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--chip); }
.dots i.on { background: var(--good); }
.more { padding: 0 0 14px; display: grid; gap: 8px; font-size: 15px; }
.hook { font-family: var(--serif); font-size: 16px; }
.more dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; }
.more dt { color: var(--muted); font-size: 13px; padding-top: 2px; }
.more li::before { content: '· '; color: var(--accent); }
.source { color: var(--brand); font-size: 13px; font-weight: 600; }
.hide-years .stop:not(.peek) .yr,
.hide-names .stop:not(.peek) .who,
.hide-names .stop:not(.peek) .more { filter: blur(7px); user-select: none; }
.pager { display: flex; justify-content: space-between; gap: 12px; font-weight: 600; color: var(--brand); font-size: 14px; }
.pager a:last-child { text-align: right; }

/* practice setup */
.mode-list { display: grid; gap: 10px; }
.mode { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.mode span { display: grid; }
.mode b { color: var(--brand); font-size: 16px; }
.mode i { flex: none; font-style: normal; font-size: 12px; color: var(--muted); background: var(--chip); padding: 4px 8px; border-radius: 999px; }

/* a question */
.quiz-top { display: flex; align-items: center; gap: 12px; }
.x { font-size: 20px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: var(--chip); }
.bar { flex: 1; height: 8px; border-radius: 4px; background: var(--chip); overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); transition: width 0.25s; }
.count { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.count b { color: var(--bad); }
.q > * + * { margin-top: 14px; }
.q-prompt { font: 700 20px/1.35 var(--serif); }
.q-list { display: grid; gap: 6px; }
.q-list li { display: flex; gap: 8px; padding: 10px 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.q-list b { flex: none; color: var(--accent); min-width: 22px; }
.two-lists { display: grid; gap: 12px; }
.two-lists h3 { font-size: 13px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.5px; }
@media (min-width: 520px) { .two-lists { grid-template-columns: 1fr 1fr; } }
.quote { font: 500 19px/1.7 var(--serif); padding: 12px 14px; background: var(--accent-soft); border-radius: 12px; }
.quote mark { background: var(--accent); color: #fff; padding: 1px 5px; border-radius: 6px; font-weight: 700; }
.blank { color: var(--accent); font-weight: 700; letter-spacing: 1px; }
.statements { display: grid; gap: 8px; }
.statements li { padding: 10px 12px; background: var(--card); border-left: 3px solid var(--brand); border-radius: 0 12px 12px 0; }

.options { display: grid; gap: 10px; }
.opt { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; text-align: left; background: var(--card); border: 2px solid var(--line); border-radius: 14px; min-height: 52px; }
.opt .num { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--chip); font-weight: 700; font-size: 14px; display: grid; place-items: center; }
.opt.picked { border-color: var(--brand); }
.opt.right { border-color: var(--good); background: var(--good-soft); }
.opt.wrong { border-color: var(--bad); background: var(--bad-soft); }
.opt:disabled { cursor: default; color: var(--ink); }
.duel { display: grid; gap: 8px; }
.opt.big { justify-content: center; text-align: center; font-size: 18px; min-height: 84px; }
.vs { text-align: center; color: var(--muted); font-size: 13px; }
.tap-slots { counter-reset: slot; display: grid; gap: 6px; min-height: 8px; }
.tap-slots li { counter-increment: slot; padding: 10px 12px; border-radius: 12px; background: var(--chip); border: 2px solid transparent; }
.tap-slots li::before { content: counter(slot) '. '; font-weight: 700; color: var(--accent); }
.tap-slots li.right { border-color: var(--good); background: var(--good-soft); }
.tap-slots li.wrong { border-color: var(--bad); background: var(--bad-soft); }
.tap-pool { display: grid; gap: 8px; }
.text-btn { color: var(--brand); font-weight: 600; padding: 8px 0; }
.text-btn.danger { color: var(--bad); }

.feedback { padding: 14px; border-radius: 16px; display: grid; gap: 8px; }
.feedback.good { background: var(--good-soft); }
.feedback.bad { background: var(--bad-soft); }
.verdict { font: 700 18px var(--serif); }
.good .verdict { color: var(--good); }
.bad .verdict { color: var(--bad); }
.explain { display: grid; gap: 2px; font-size: 15px; }
.explain li::before { content: '› '; color: var(--accent); font-weight: 700; }
.primary, .ghost { display: inline-flex; justify-content: center; align-items: center; padding: 14px 18px; border-radius: 14px; font-weight: 700; min-height: 50px; }
.primary { background: var(--brand); color: var(--brand-ink); width: 100%; }
.ghost { border: 2px solid var(--line); width: 100%; }
.mock-nav { margin-top: 14px; }

/* result */
.result { text-align: center; padding: 16px 0; }
.result > * + * { margin-top: 10px; }
.result h1 { font: 700 64px/1 var(--serif); color: var(--brand); }
.result h1 small { font-size: 22px; }
.actions { display: grid; gap: 10px; margin-top: 16px; }
.review { display: grid; gap: 8px; }
.review li { background: var(--card); border: 1px solid var(--line); border-left-width: 4px; border-radius: 12px; padding: 4px 12px; }
.review li.good { border-left-color: var(--good); }
.review li.bad { border-left-color: var(--bad); }
.review summary { display: flex; gap: 10px; padding: 8px 0; cursor: pointer; list-style: none; }
.review summary::-webkit-details-marker { display: none; }
.review summary small { display: block; }
.review details > * + * { margin-top: 8px; }
.review details[open] { padding-bottom: 10px; }
.mark { flex: none; font-weight: 700; }
.good .mark { color: var(--good); }
.bad .mark { color: var(--bad); }

/* settings */
.label { font-size: 13px; color: var(--muted); }
.segment { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--chip); border-radius: 12px; padding: 3px; }
.segment button { padding: 9px 6px; border-radius: 10px; font-weight: 600; font-size: 14px; }
.segment button.on { background: var(--card); box-shadow: var(--shadow); color: var(--brand); }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* accounts */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.account { flex: none; min-height: 32px; padding: 6px 12px; border-radius: 999px; background: var(--chip); color: var(--brand); font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; }
.account:has(.avatar) { padding: 0; background: none; }
.avatar { flex: none; width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: var(--brand); color: var(--brand-ink); font: 700 18px/44px var(--serif); text-align: center; display: inline-block; }
.avatar.small { width: 32px; height: 32px; font-size: 14px; line-height: 32px; }
.who-row { display: flex; align-items: center; gap: 12px; }
.who-row > span { display: grid; min-width: 0; }
.who-row small { overflow-wrap: anywhere; }
.who-row.big b { font: 700 20px/1.2 var(--serif); }
.gbtn { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 50px; padding: 12px 16px; border-radius: 14px; background: var(--card); border: 2px solid var(--line); font-weight: 700; }
.gbtn .g { width: 26px; height: 26px; border-radius: 50%; background: #fff; color: #4285f4; font: 700 16px/26px Arial, sans-serif; text-align: center; border: 1px solid var(--line); }
.account-card { border-color: var(--brand); }
.bad-note { color: var(--bad); }

/* insights */
h3.sub { font-size: 13px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); margin-top: 16px; }
h3.sub small { text-transform: none; letter-spacing: 0; margin-left: 4px; }
.steps { counter-reset: step; display: grid; gap: 12px; }
.steps li { counter-increment: step; position: relative; padding-left: 38px; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-weight: 700; display: grid; place-items: center; }
.steps a { color: var(--brand); font-weight: 700; text-decoration: underline; }
.session-row { display: flex; align-items: baseline; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.session-row > span:nth-child(2) { flex: 1; min-width: 0; display: grid; }
.session-row b { font-variant-numeric: tabular-nums; }

/* all learners (admin) */
.learner-list { display: grid; gap: 16px; }
.learner { display: grid; gap: 10px; padding: 14px; background: var(--card); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.mini-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 12px; font-size: 14px; color: var(--muted); }
.mini-stats b { color: var(--ink); }


/* architecture ------------------------------------------------------------- */
.arch-card { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 18px; background: var(--card); border: 2px solid var(--accent); box-shadow: var(--shadow); }
.arch-card > span:nth-child(2) { flex: 1; display: grid; gap: 2px; }
.arch-card b { font-size: 17px; color: var(--brand); }
.arch-card > i { font-style: normal; font-size: 22px; color: var(--accent); }
/* three little towers: northern, southern, Deccan */
.arch-card-art { flex: none; display: flex; align-items: flex-end; gap: 3px; height: 40px; }
.arch-card-art i { display: block; width: 12px; border-radius: 6px 6px 1px 1px; }
.arch-card-art i:nth-child(1) { height: 24px; background: var(--nagara); }
.arch-card-art i:nth-child(2) { height: 38px; width: 16px; background: var(--dravida); border-radius: 2px 2px 1px 1px; clip-path: polygon(10% 100%, 28% 0, 72% 0, 90% 100%); }
.arch-card-art i:nth-child(3) { height: 28px; background: var(--vesara); }
.arch-banner { margin-top: 10px; }

.tag { display: inline-block; padding: 2px 8px; margin: 0 4px 4px 0; border-radius: 999px; background: var(--chip); font-size: 12px; font-weight: 600; line-height: 1.5; vertical-align: middle; }
.tag:empty { display: none; }
.tag.deity { background: var(--accent-soft); color: var(--ink); }
.tag.style-nagara { background: var(--nagara); color: #fff; }
.tag.style-dravida { background: var(--dravida); color: var(--brand-ink); }
.tag.style-vesara { background: var(--vesara); color: #fff; }
:root[data-theme='dark'] .tag.style-nagara, :root[data-theme='dark'] .tag.style-vesara { color: var(--brand-ink); }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) .tag.style-nagara, :root:not([data-theme='light']) .tag.style-vesara { color: var(--brand-ink); } }
.panel-tags { line-height: 1.9; }
.nm-hi.big { font-size: 18px; margin-top: 2px; }
.coach.dyn { background: var(--accent); color: #fff; }
.link-list { display: grid; gap: 4px; font-size: 15px; }
.link-list a { color: var(--brand); font-weight: 600; }
.link-list small { margin-left: 4px; }
.info-box { background: var(--bg); border-radius: 12px; padding: 12px; display: grid; gap: 8px; }
.info-box h3.sub { margin-top: 0; }
.k { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 4px 0 10px; vertical-align: -1px; background: var(--other); }
.k:first-child { margin-left: 0; }
.k.early { background: var(--early); }
.k.nagara { background: var(--nagara); }
.k.dravida { background: var(--dravida); }
.k.vesara { background: var(--vesara); }
.map-key { font-size: 13px; color: var(--muted); line-height: 1.9; }
.map-key span { white-space: nowrap; margin-right: 10px; }
.map-key .k { margin-left: 0; }

/* photographs, always with their credit */
.photo { margin: 0; display: grid; gap: 6px; }
.photo img { display: block; width: 100%; height: auto; border-radius: 14px; background: var(--chip); }
.photo.small img { max-height: 220px; object-fit: cover; }
.photo figcaption { display: grid; gap: 2px; font-size: 14px; }
.credit { font-size: 11.5px; color: var(--muted); }
.credit a { color: inherit; text-decoration: underline; }
.q-photo img { max-height: 46vh; width: auto; max-width: 100%; margin: 0 auto; object-fit: contain; }

/* one monument */
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; font-size: 15px; }
.facts dt { color: var(--muted); font-size: 13px; padding-top: 2px; }
.feature-list li::before { content: '· '; color: var(--accent); font-weight: 700; }
.panel-list { display: grid; gap: 12px; }
.panel-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 8px; box-shadow: var(--shadow); }
.panel-name b { font-family: var(--serif); font-size: 17px; }
.panel-about { font-size: 15px; }

/* diagrams */
.diagram { display: block; width: 100%; height: auto; font-family: var(--sans); }
.diagram.system { max-width: 460px; margin: 0 auto; }
.diagram.anatomy { max-width: 480px; margin: 0 auto; }
.diagram text { fill: var(--ink); }
.sys-box rect { fill: var(--bg); stroke: var(--line); stroke-width: 1.5; }
.sys-box.root rect { fill: var(--brand); stroke: none; }
.sys-box.root text { fill: var(--brand-ink); }
.sys-box.nagara rect { stroke: var(--nagara); stroke-width: 2.5; }
.sys-box.dravida rect { stroke: var(--dravida); stroke-width: 2.5; }
.sys-box.vesara rect { stroke: var(--vesara); stroke-width: 2.5; }
.sys-title { font-size: 13px; font-weight: 700; text-anchor: middle; }
.diagram .sys-sub, .diagram .sys-note { fill: var(--muted); }
.sys-sub { font-size: 9.5px; text-anchor: middle; }
.sys-note { font-size: 10px; text-anchor: middle; font-style: italic; }
.sys-link, .sys-arrow { fill: none; stroke: var(--muted); stroke-width: 1.2; }
.sys-list text { font-size: 10.5px; text-anchor: middle; }
.sys-chain rect { fill: var(--accent-soft); stroke: var(--accent); }
.sys-chain text { font-size: 10.5px; font-weight: 700; text-anchor: middle; }

.tree { display: grid; gap: 6px; }
.tree-node summary { display: flex; justify-content: space-between; gap: 8px; padding: 7px 10px; border-radius: 10px; cursor: pointer; list-style: none; }
.tree-node summary::-webkit-details-marker { display: none; }
.tree-node summary::before { content: '▸'; color: var(--accent); transition: transform 0.15s; }
.tree-node[open] > summary::before { transform: rotate(90deg); }
.tree-node summary > span { flex: 1; }
.tree-node > :not(summary) { margin-left: 12px; padding-left: 10px; border-left: 2px solid var(--line); }
.tree-node.lvl-1 > summary { background: var(--brand); color: var(--brand-ink); font-weight: 700; }
.tree-node.lvl-1 > summary small, .tree-node.lvl-1 > summary::before { color: inherit; }
.tree-node.lvl-2 > summary { background: var(--chip); font-weight: 700; margin-top: 6px; }
.tree-node.lvl-3 > summary { font-weight: 700; color: var(--brand); }
.tree-node.lvl-4 > summary { font-weight: 600; }
.tree-node.lvl-5 > summary { font-size: 14px; color: var(--muted); }
.tree-leaves { display: grid; gap: 6px; padding: 4px 0 8px; font-size: 15px; }
.tree-leaves a { color: var(--brand); font-weight: 600; }
.tree-panels { margin: 2px 0 0 10px; font-size: 13px; color: var(--muted); display: grid; gap: 2px; }

/* the timeline scrolls sideways inside its card, never the page */
.tl-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px 6px; -webkit-overflow-scrolling: touch; }
.diagram.timeline { width: auto; max-width: none; }
.tl-grid { stroke: var(--line); stroke-width: 1; }
.tl-grid.major { stroke: var(--muted); stroke-dasharray: 2 3; }
.diagram .tl-year { font-size: 10px; fill: var(--muted); }
.diagram .tl-lane { font-size: 10px; font-weight: 700; letter-spacing: 0.6px; text-transform: uppercase; fill: var(--accent); }
.tl-bar { cursor: pointer; }
.tl-bar rect { fill: var(--chip); stroke: var(--line); }
.tl-bar text { font-size: 10.5px; font-weight: 600; }
.tl-bar.lane-north rect { fill: color-mix(in srgb, var(--dravida) 22%, var(--card)); }
.tl-bar.lane-west rect { fill: color-mix(in srgb, var(--nagara) 25%, var(--card)); }
.tl-bar.lane-east rect { fill: color-mix(in srgb, var(--early) 25%, var(--card)); }
.tl-bar.lane-deccan rect { fill: color-mix(in srgb, var(--vesara) 25%, var(--card)); }
.tl-bar.lane-south rect { fill: color-mix(in srgb, var(--bad) 18%, var(--card)); }
.tl-bar.on rect, .tl-bar:focus-visible rect { stroke: var(--ink); stroke-width: 2; }
.tl-mon circle { fill: var(--other); }
.tl-mon.style-nagara circle { fill: var(--nagara); }
.tl-mon.style-dravida circle { fill: var(--dravida); }
.tl-mon.style-vesara circle { fill: var(--vesara); }
.tl-mon text { font-size: 9.5px; }

.map-wrap { max-width: 520px; margin: 0 auto; }
.map-wrap.small { max-width: 300px; }
.map-india { fill: var(--card); stroke: var(--muted); stroke-width: 1.4; }
.map-neighbours { fill: var(--chip); stroke: var(--line); stroke-width: 0.8; opacity: 0.7; }
.map-dot { cursor: pointer; }
.map-dot circle { fill: var(--other); stroke: var(--card); stroke-width: 2; }
.map-dot.kind-early circle { fill: var(--early); }
.map-dot.kind-nagara circle { fill: var(--nagara); }
.map-dot.kind-dravida circle { fill: var(--dravida); }
.map-dot.kind-vesara circle { fill: var(--vesara); }
.map-dot circle.hit { fill: transparent; stroke: none; }
.map-dot.on circle:not(.hit), .map-dot:focus-visible circle:not(.hit) { stroke: var(--ink); stroke-width: 4; }
.map-label { font-size: 16px; font-weight: 600; paint-order: stroke; stroke: var(--card); stroke-width: 4px; stroke-linejoin: round; }
.map-label.on { font-weight: 800; }

.anatomy-wrap { background: var(--bg); border-radius: 14px; padding: 8px 4px; }
.an-ground, .an-lead { stroke: var(--muted); stroke-width: 1; }
.an-lead.strong { stroke: var(--ink); stroke-width: 2; }
.an-base, .an-fill, .an-wall, .an-roof, .an-tower, .an-floor { stroke: var(--ink); stroke-width: 1.2; stroke-linejoin: round; }
.an-base { fill: var(--chip); }
.an-fill { fill: var(--card); }
.an-wall { fill: color-mix(in srgb, var(--accent) 22%, var(--card)); }
.an-roof { fill: color-mix(in srgb, var(--brand) 16%, var(--card)); }
.an-tower { fill: color-mix(in srgb, var(--accent) 38%, var(--card)); }
.an-tower.minor { fill: color-mix(in srgb, var(--accent) 24%, var(--card)); }
.an-floor { fill: var(--bg); }
.an-rib, .an-band { stroke: var(--ink); stroke-width: 0.8; opacity: 0.45; }
.an-dash { fill: none; stroke: var(--brand); stroke-width: 1.4; stroke-dasharray: 4 3; }
.an-door, .an-post, .an-pillar { fill: none; stroke: var(--ink); stroke-width: 1.5; }
.an-pillar-dot { fill: var(--ink); }
.an-mark { cursor: pointer; }
.an-mark circle { fill: var(--brand); }
.diagram .an-mark text { fill: var(--brand-ink); font-size: 10px; font-weight: 800; text-anchor: middle; }
.an-mark.on circle { fill: var(--accent); }
.an-legend { display: grid; gap: 4px; }
.an-legend li { display: flex; gap: 10px; align-items: flex-start; padding: 6px 8px; border-radius: 10px; cursor: pointer; }
.an-legend li > b { flex: none; width: 22px; height: 22px; border-radius: 50%; background: var(--brand); color: var(--brand-ink); font-size: 12px; display: grid; place-items: center; }
.an-legend li > span { display: grid; }
.an-legend li.on { background: var(--accent-soft); }
.an-legend li.on > b { background: var(--accent); }

/* words page */
.table-scroll { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
.compare { border-collapse: collapse; width: 100%; min-width: 520px; font-size: 14px; }
.compare th, .compare td { text-align: left; vertical-align: top; padding: 8px; border-bottom: 1px solid var(--line); }
.compare thead th { font-size: 15px; }
.compare thead .nagara { color: var(--nagara); }
.compare thead .dravida { color: var(--dravida); }
.compare thead .vesara { color: var(--vesara); }
.compare tbody th { color: var(--muted); font-size: 13px; font-weight: 600; width: 1%; white-space: nowrap; }
.sequences { display: grid; gap: 10px; }
.sequences li { display: grid; gap: 2px; }
.sequences span { color: var(--muted); font-size: 14px; }
.glossary { display: grid; gap: 2px; }
.glossary dt { font-weight: 700; margin-top: 8px; }
.glossary dd { font-size: 15px; }
.split-auto > * + * { margin-top: 16px; }

/* ---------------------------------------------------------------------------
   Wider screens. A phone never reaches these rules.

   .split and .col wrap groups of cards. On a phone they only keep the usual
   spacing; from 1040px they become two columns.
   --------------------------------------------------------------------------- */
.split > * + *, .col > * + * { margin-top: 16px; }
#account-card:empty { display: none; }
.keys-hint { display: none; }

@media (hover: hover) {
  .deck-card, .mode, .quick, .learner, .opt, .gbtn, .ghost { transition: border-color 0.15s; }
  .deck-card:hover, .mode:hover, .quick:hover, .learner:hover, .gbtn:hover, .ghost:hover, .opt:not(:disabled):hover { border-color: var(--brand); }
  .cta:hover, .primary:hover, .chip.on:hover { filter: brightness(1.1); }
  .chip:not(.on):hover, .segment button:not(.on):hover, .x:hover, .account:not(:has(.avatar)):hover { color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
  .tabbar a:hover { color: var(--brand); }
  .text-link:hover, .back:hover, .pager a:hover, .source:hover, .text-btn:hover, .hit-row:hover .nm-en, .stop summary:hover .nm-en { text-decoration: underline; }
}

/* Tablet and up: navigation moves into the header, the page gets room to breathe. */
@media (min-width: 760px) {
  html { scrollbar-gutter: stable; }
  body, .in-quiz { padding-bottom: 0; }
  #app { max-width: 760px; padding: 28px 24px 64px; }

  .topbar { min-height: 64px; padding: 12px max(24px, calc(50% - 560px)); }
  .brand { width: 190px; font-size: 20px; }
  /* The same four links, now sitting in the header just right of the name. */
  .tabbar { inset: 0 auto auto calc(max(24px, 50% - 560px) + 206px); z-index: 6; height: 64px; display: flex; align-items: center; gap: 4px; padding: 0; background: none; border: 0; }
  .tabbar a { display: block; padding: 8px 14px; font-size: 15px; border-radius: 999px; }
  .tabbar a span { display: none; }

  .page-title, .deck-head h1 { font-size: 36px; }
  .hero h1 { font-size: 46px; }
  .lede { font-size: 18px; }
  .card { padding: 20px; }
  .search { max-width: 520px; }
  .chips.scroll { flex-wrap: wrap; overflow: visible; margin: 0; padding: 0; }

  #deck-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  #deck-list .track-sub { grid-column: 1 / -1; margin-bottom: 0; }
  #deck-list .deck-card { margin-bottom: 0; }
  #results { max-width: 720px; }
  .mode-list, .learner-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .quick-grid.wide { grid-template-columns: repeat(4, minmax(0, 1fr)); }

  /* a question reads best in a narrow column, however wide the window */
  .view-play { max-width: 720px; margin: 0 auto; }
  .q-prompt { font-size: 24px; }
  .actions { grid-template-columns: 1fr 1fr; }
  .result h1 { font-size: 80px; }
}

@media (min-width: 760px) and (hover: hover) and (pointer: fine) {
  .keys-hint { display: block; margin-top: 20px; text-align: center; color: var(--muted); font-size: 13px; }
  .keys-hint kbd { font: 600 12px var(--sans); padding: 2px 6px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; background: var(--card); }
}

/* Desktop: two columns. */
@media (min-width: 1040px) {
  #app { max-width: 1168px; padding: 36px 24px 80px; }
  .view > * + * { margin-top: 24px; }
  .view-play > * + * { margin-top: 16px; }

  .split { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 24px 32px; align-items: start; }
  .split.aside-first { grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr); }
  .col { display: flex; flex-direction: column; gap: 20px; }
  .split > * + *, .col > * + * { margin-top: 0; }

  .hero h1 { font-size: 58px; }
  .hero .lede { max-width: 34em; }
  .mnemonic { font-size: 22px; }
  #deck-list, .mode-list, .learner-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* The memory line stays beside the timeline while it scrolls, when the window is tall enough to hold it. */
@media (min-width: 1040px) and (min-height: 760px) {
  .split.aside-first > .col { position: sticky; top: 88px; }
}

/* Architecture on wider screens. */
@media (min-width: 760px) {
  .deck-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .deck-grid .deck-card { margin-bottom: 0; }
  .panel-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .split-auto { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
  .split-auto > * + * { margin-top: 0; }
  .tl-scroll, .table-scroll { margin: 0 -20px; padding: 0 20px 6px; }
  .q-photo img { max-height: 52vh; }
}

@media (min-width: 1040px) {
  .col .deck-grid, .col .panel-list { grid-template-columns: minmax(0, 1fr); }
}
