:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #14171f;
  --muted: #5a6372;
  --border: #e1e4ea;
  --accent: #1d3a8a;
  --focus: #2f6fed;
  --prep: #475569;
  --gmat: #6d28d9;
  --opens: #1d4ed8;
  --deadline: #b91c1c;
  --result: #15803d;
  --tint: 12%;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 1px 3px rgb(16 24 40 / 8%);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1015;
    --surface: #161a22;
    --surface-2: #1d222c;
    --text: #e8eaef;
    --muted: #9aa3b2;
    --border: #2a303c;
    --accent: #9db4ff;
    --focus: #7aa2ff;
    --prep: #a3adbd;
    --gmat: #b794f6;
    --opens: #7aa7ff;
    --deadline: #f87171;
    --result: #4ade80;
    --tint: 18%;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0e1015;
  --surface: #161a22;
  --surface-2: #1d222c;
  --text: #e8eaef;
  --muted: #9aa3b2;
  --border: #2a303c;
  --accent: #9db4ff;
  --focus: #7aa2ff;
  --prep: #a3adbd;
  --gmat: #b794f6;
  --opens: #7aa7ff;
  --deadline: #f87171;
  --result: #4ade80;
  --tint: 18%;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
a:focus-visible, button:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; }
.skip:focus { left: 16px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 8px; z-index: 10; }

h1, h2, h3 { line-height: 1.2; margin: 0; }
h2 { font-size: 1.25rem; margin: 40px 0 6px; }
.hint { color: var(--muted); font-size: 0.9rem; margin: 0 0 16px; }

/* Header */
.hero { padding-top: 40px; padding-bottom: 8px; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; font-weight: 600; color: var(--muted); margin: 0 0 8px; }
.hero h1 { font-size: clamp(1.9rem, 5vw, 2.8rem); letter-spacing: -0.02em; }
.lede { max-width: 640px; color: var(--muted); font-size: 1.05rem; margin: 12px 0 8px; }
.meta { font-size: 0.85rem; color: var(--muted); margin: 0; }

/* Stats */
.stats { display: grid; gap: 12px; grid-template-columns: repeat(4, 1fr); margin-top: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat-label { font-size: 0.8rem; color: var(--muted); }
.stat-value { font-size: clamp(1.1rem, 4.6vw, 1.35rem); font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; margin-top: 16px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 12px; }

.next { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.next li { display: grid; grid-template-columns: 96px 1fr auto; gap: 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.next li:first-child { border-top: 0; }
.next-date { font-weight: 600; font-variant-numeric: tabular-nums; }
.next-title { font-weight: 600; }
.next-sub { color: var(--muted); font-size: 0.85rem; }
.countdown { font-size: 0.85rem; font-weight: 600; white-space: nowrap; padding: 4px 10px; border-radius: 999px; background: var(--surface-2); }

/* Type colours */
[data-type="prep"] { --c: var(--prep); }
[data-type="gmat"] { --c: var(--gmat); }
[data-type="opens"] { --c: var(--opens); }
[data-type="deadline"] { --c: var(--deadline); }
[data-type="result"] { --c: var(--result); }

.tag { display: inline-block; font-size: 0.72rem; font-weight: 600; letter-spacing: 0.02em; padding: 2px 8px; border-radius: 999px; color: var(--c, var(--muted)); background: color-mix(in srgb, var(--c, var(--muted)) var(--tint), transparent); }
.tag-tentative { --c: var(--muted); border: 1px dashed var(--muted); background: transparent; }

/* Filters */
.toolbar { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 12px; margin-top: 24px; padding: 10px 0; background: var(--bg); border-bottom: 1px solid var(--border); }
.toolbar-label { font-size: 0.85rem; color: var(--muted); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chip { flex: none; font: inherit; font-size: 0.85rem; font-weight: 600; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 6px 12px; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--text)); }
.chip[aria-pressed="true"] { border-color: var(--text); background: var(--surface-2); }

/* Month grids */
.months { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.month { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.month h3 { font-size: 0.95rem; margin-bottom: 10px; }
.grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.dow { font-size: 0.7rem; color: var(--muted); padding-bottom: 4px; }
.day { position: relative; aspect-ratio: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 0.8rem; border-radius: 8px; border: 0; background: none; color: var(--text); font: inherit; font-size: 0.8rem; padding: 0; }
.day.empty { visibility: hidden; }
.day.has { cursor: pointer; font-weight: 700; background: color-mix(in srgb, var(--c) var(--tint), transparent); color: var(--c); }
.day.has:hover { outline: 1px solid var(--c); }
.day.today { box-shadow: inset 0 0 0 2px var(--text); }
.day.past { opacity: 0.45; }
.dots { display: flex; gap: 2px; position: absolute; bottom: 3px; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--c); }

/* Agenda */
.month-group h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 24px 0 8px; }
.event { display: grid; grid-template-columns: 64px 1fr; gap: 16px; background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--c); border-radius: 12px; padding: 14px 16px; margin-bottom: 10px; scroll-margin-top: 72px; transition: box-shadow 0.3s; }
.event.past { opacity: 0.55; }
.event.flash { box-shadow: 0 0 0 3px var(--c); }
.event-date { text-align: center; }
.event-day { font-size: 1.5rem; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }
.event-dow { font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 4px; }
.event-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 4px; }
.event h4 { font-size: 1rem; margin: 0; }
.event-prog { color: var(--muted); font-size: 0.85rem; margin: 2px 0 0; }
.event-detail { margin: 6px 0 0; font-size: 0.92rem; }
.event-link { display: inline-block; margin-top: 6px; font-size: 0.85rem; }
.empty-state { color: var(--muted); padding: 16px 0; }

/* Programmes */
.programmes { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.prog { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 10px; }
.prog-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.prog h3 { font-size: 1.02rem; }
.prog-sub { color: var(--muted); font-size: 0.88rem; margin: 2px 0 0; }
.rank { flex: none; font-size: 0.75rem; font-weight: 700; padding: 3px 8px; border-radius: 8px; background: var(--surface-2); white-space: nowrap; }
.prog dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 0; font-size: 0.88rem; }
.prog dt { color: var(--muted); }
.prog dd { margin: 0; }
.prog-note { font-size: 0.85rem; color: var(--muted); margin: 0; }
.prog a { font-size: 0.85rem; margin-top: auto; }
.tier { --c: var(--accent); }
.tier-reach { --c: var(--gmat); }
.tier-safety { --c: var(--result); }
.tier-india { --c: var(--opens); }

.foot { padding-top: 40px; padding-bottom: 48px; color: var(--muted); font-size: 0.85rem; }

@media (max-width: 760px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .next li { grid-template-columns: 1fr auto; }
  .next-date { grid-column: 1 / -1; font-size: 0.85rem; color: var(--muted); }
}

@media (max-width: 420px) {
  .event { grid-template-columns: 48px 1fr; gap: 12px; padding: 12px; }
  .programmes { grid-template-columns: 1fr; }
}

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