/* ── Tokens ─────────────────────────────────────────────────────────── */
:root {
  --paper: #f3f5f8;
  --surface: #ffffff;
  --ink: #18202b;
  --ink-2: #445063;
  --ink-3: #626c7c;
  --rule: #dde2e8;
  --hci: #5847d6;
  --hci-soft: #ebe8fc;
  --nlp: #0b7f73;
  --nlp-soft: #ddf2ee;
  --urgent: #c2255c;
  --urgent-soft: #fce7ee;
  --focus: #1f6feb;

  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Atkinson Hyperlegible", "Segoe UI", system-ui, -apple-system, sans-serif;

  --r-panel: 16px;
  --r-btn: 9px;

  color-scheme: light;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #14181e;
    --surface: #1b2029;
    --ink: #e8ecf1;
    --ink-2: #b6bfcb;
    --ink-3: #8f99a8;
    --rule: #2c3440;
    --hci: #ab9fff;
    --hci-soft: #2a2552;
    --nlp: #52d3c3;
    --nlp-soft: #123a36;
    --urgent: #ff7da5;
    --urgent-soft: #46192b;
    --focus: #7cb3ff;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: inherit; }

html { scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 16px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.55 var(--body);
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.wrap { width: min(1120px, 100% - 2.5rem); margin-inline: auto; }

.skip {
  position: absolute; left: 1rem; top: -3rem;
  background: var(--ink); color: var(--paper);
  padding: .5rem .8rem; border-radius: var(--r-btn); z-index: 10;
}
.skip:focus { top: 1rem; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ── Header ─────────────────────────────────────────────────────────── */
.top {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 2.5rem;
  align-items: end;
  padding: 3.5rem 0 2rem;
}

h1 {
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2.6rem, 6.4vw, 5rem);
  line-height: .92;
  letter-spacing: -0.035em;
  margin: 0 0 1.1rem;
  max-width: 9ch;
}

.lede { margin: 0; max-width: 46ch; color: var(--ink-2); font-size: 1.05rem; }
.lede strong { color: var(--ink); }

/* Next deadline panel */
.next {
  background: var(--ink);
  color: var(--paper);
  border-radius: var(--r-panel);
  padding: 1.4rem 1.5rem 1.3rem;
  min-height: 11rem;
}
.next-kicker { margin: 0 0 .35rem; font-size: .95rem; opacity: .78; }
.next-name {
  font-family: var(--display); font-weight: 700;
  font-size: 1.55rem; line-height: 1.15; margin: 0;
}
.next-name a { text-decoration: none; }
.next-name a:hover { text-decoration: underline; text-underline-offset: 3px; }
.next-label { margin: .1rem 0 .9rem; opacity: .85; }
.next-cd {
  display: flex; flex-wrap: wrap; gap: .2rem 1rem;
  font-family: var(--display);
  font-variant-numeric: tabular-nums;
  margin: 0 0 .7rem;
}
.next-cd span { display: inline-flex; align-items: baseline; gap: .2rem; }
.next-cd b { font-size: clamp(2.2rem, 4.4vw, 3.1rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1; }
.next-cd i { font-style: normal; font-size: .95rem; opacity: .7; }
.next-when { margin: 0; font-size: .9rem; opacity: .8; line-height: 1.45; }
.next.is-urgent { background: var(--urgent); color: #fff; }
@media (prefers-color-scheme: dark) { .next.is-urgent { color: var(--paper); } }
.next.is-empty { background: var(--surface); color: var(--ink-2); border: 1px solid var(--rule); }

/* ── Timeline ───────────────────────────────────────────────────────── */
.section-title {
  font-family: var(--display); font-weight: 700;
  font-size: 1.15rem; margin: 0 0 .75rem; letter-spacing: -0.01em;
}

.tl-section { margin-bottom: 2rem; }
.tl-scroll {
  overflow-x: auto;
  background: var(--surface);
  border-radius: var(--r-panel);
  border: 1px solid var(--rule);
  padding: .75rem 1rem 1rem 0;
}
.tl { min-width: 780px; }

.tl-months, .tl-lane { display: grid; grid-template-columns: 4.4rem 1fr; }
.tl-months { height: 2.5rem; }
.tl-months .tl-axis { position: relative; }
.tl-month {
  position: absolute; top: 1.15rem;
  font-size: .8rem; color: var(--ink-3);
  padding-left: .3rem; white-space: nowrap;
}
.tl-today-tag {
  position: absolute; top: 0;
  font-size: .75rem; font-weight: 700; line-height: 1.3; color: #fff;
  background: var(--urgent); padding: 0 .4rem; border-radius: 999px; z-index: 6;
}
@media (prefers-color-scheme: dark) { .tl-today-tag { color: var(--paper); } }

.tl-lane { height: 6.4rem; }
.tl-lane + .tl-lane { margin-top: .4rem; }
.tl-lane-name, .tl-months > span:first-child {
  position: sticky; left: 0; z-index: 7; background: var(--surface);
}
.tl-lane-name {
  align-self: stretch; display: flex; align-items: flex-end; padding: 0 0 .55rem 1rem;
  font-family: var(--display); font-weight: 700; font-size: .95rem;
}
.tl-lane[data-field="hci"] .tl-lane-name { color: var(--hci); }
.tl-lane[data-field="nlp"] .tl-lane-name { color: var(--nlp); }

.tl-track { position: relative; border-radius: 10px; }
.tl-lane[data-field="hci"] .tl-track { background: var(--hci-soft); }
.tl-lane[data-field="nlp"] .tl-track { background: var(--nlp-soft); }

.tl-grid { position: absolute; top: 0; bottom: 0; width: 1px; background: var(--paper); opacity: .9; }
.tl-today { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--urgent); z-index: 2; }

/* Each marker spans abstract → final deadline; the dot sits on the final date. */
.tl-item {
  position: absolute; bottom: 0; height: 100%;
  text-decoration: none; color: var(--ink);
  pointer-events: none; z-index: 3;
}
.tl-item > * { pointer-events: auto; }
.tl-dot {
  position: absolute; bottom: 12px; right: -6px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--fc); border: 2px solid var(--fc);
}
.tl-bar {
  position: absolute; bottom: 16px; left: 0; right: 0; height: 4px;
  background: var(--fc); border-radius: 2px; opacity: .5;
}
.tl-stem { position: absolute; bottom: 24px; right: -.5px; width: 1px; background: var(--fc); opacity: .6; }
.tl-label {
  position: absolute; left: calc(100% - 2px); white-space: nowrap;
  font-family: var(--display); font-weight: 500; font-size: .82rem; line-height: 1;
  padding: .22rem .4rem; border-radius: 6px;
  background: var(--surface); color: var(--ink);
  box-shadow: 0 0 0 1px var(--rule);
}
.tl-label.flip { left: auto; right: -2px; }
.tl-item[data-field="hci"] { --fc: var(--hci); }
.tl-item[data-field="nlp"] { --fc: var(--nlp); }
.tl-item.est .tl-dot { background: var(--surface); }
.tl-item.est .tl-bar { background: none; border-top: 2px dashed var(--fc); height: 0; bottom: 17px; }
.tl-item.est .tl-label { font-style: italic; }
.tl-item:hover .tl-label, .tl-item:focus-visible .tl-label { background: var(--fc); color: var(--surface); box-shadow: none; }
.tl-item:hover, .tl-item:focus-visible { z-index: 5; }
.tl-item:focus-visible { outline: none; }
.tl-item:focus-visible .tl-label { outline: 2px solid var(--focus); outline-offset: 2px; }

.tl-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.4rem; margin: .6rem 0 0; font-size: .85rem; color: var(--ink-3); }
.tl-legend span { display: inline-flex; align-items: center; gap: .4rem; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink-3); display: inline-block; }
.lg-dot.hollow { background: transparent; border: 2px solid var(--ink-3); }

/* ── Controls ───────────────────────────────────────────────────────── */
.controls {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.1rem;
  margin-bottom: 1.25rem;
}
.seg { display: inline-flex; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-btn); padding: 3px; }
.seg button {
  font: inherit; font-weight: 700; color: var(--ink-2);
  background: none; border: 0; border-radius: 6px;
  padding: .35rem .9rem; cursor: pointer;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.seg button[data-field="hci"][aria-pressed="true"] { background: var(--hci); color: #fff; }
.seg button[data-field="nlp"][aria-pressed="true"] { background: var(--nlp); color: #fff; }
@media (prefers-color-scheme: dark) {
  .seg button[data-field="hci"][aria-pressed="true"],
  .seg button[data-field="nlp"][aria-pressed="true"] { color: var(--paper); }
}

.search { flex: 1 1 14rem; max-width: 22rem; }
.search input {
  width: 100%; font: inherit; color: var(--ink);
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-btn);
  padding: .5rem .8rem;
}
.search input::placeholder { color: var(--ink-3); }

.check { display: inline-flex; align-items: center; gap: .45rem; color: var(--ink-2); cursor: pointer; }
.check input { width: 1.05rem; height: 1.05rem; accent-color: var(--ink); }

.btn {
  font: inherit; font-weight: 700; font-size: .92rem;
  color: var(--ink); background: var(--surface);
  border: 1px solid var(--rule); border-radius: var(--r-btn);
  padding: .45rem .8rem; cursor: pointer; text-decoration: none;
  display: inline-flex; align-items: center; gap: .35rem;
}
.btn:hover { border-color: var(--ink-3); }
#ics-all { margin-left: auto; }

/* ── List ───────────────────────────────────────────────────────────── */
.month { margin: 0 0 1.6rem; }
.month-title {
  font-family: var(--display); font-weight: 700;
  font-size: 1.35rem; letter-spacing: -0.015em;
  margin: 0 0 .6rem;
}
.month-title small { font-family: var(--body); font-weight: 400; font-size: .9rem; color: var(--ink-3); margin-left: .5rem; }

.rows {
  list-style: none; margin: 0; padding: 0;
  background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-panel);
  overflow: hidden;
}

.row {
  --fc: var(--ink-3);
  display: grid;
  grid-template-columns: 4.2rem minmax(0, 1fr) auto;
  gap: 1.1rem;
  padding: 1.1rem 1.2rem 1.1rem 1rem;
  border-left: 5px solid var(--fc);
  scroll-margin-top: 1rem;
}
.row + .row { border-top: 1px solid var(--rule); }
.row[data-field="hci"] { --fc: var(--hci); }
.row[data-field="nlp"] { --fc: var(--nlp); }
.row.est { border-left-style: dashed; }
.row:target { animation: flash 1.6s ease-out; }
@keyframes flash { from { background: var(--urgent-soft); } to { background: transparent; } }
@media (prefers-reduced-motion: reduce) { .row:target { animation: none; background: var(--urgent-soft); } }

.row-date { text-align: center; line-height: 1; padding-top: .15rem; }
.row-day { display: block; font-family: var(--display); font-weight: 800; font-size: 2.1rem; letter-spacing: -0.03em; }
.row-wd { display: block; margin-top: .3rem; font-size: .85rem; color: var(--ink-3); }
.row-date.is-est .row-day::before { content: "≈"; font-weight: 500; font-size: 1.2rem; vertical-align: top; margin-right: 1px; color: var(--ink-3); }

.row-head { display: flex; flex-wrap: wrap; align-items: center; gap: .35rem .5rem; }
.row-name {
  font-family: var(--display); font-weight: 700; font-size: 1.3rem;
  margin: 0; letter-spacing: -0.01em; line-height: 1.2;
}
.row-name a { text-decoration: none; }
.row-name a:hover { text-decoration: underline; text-underline-offset: 3px; }

.pill {
  display: inline-block; font-size: .78rem; font-weight: 700; line-height: 1;
  padding: .28rem .5rem; border-radius: 999px;
}
.pill-field { color: var(--fc); background: color-mix(in srgb, var(--fc) 13%, transparent); }
.pill-rank { color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--rule); }
.pill-est { color: var(--ink-2); border: 1px dashed var(--ink-3); padding: .22rem .45rem; font-weight: 400; }
.pill-track { color: var(--ink-2); background: var(--paper); font-weight: 400; }

.row-full { margin: .15rem 0 .55rem; color: var(--ink-2); font-size: .95rem; }
.row-due { margin: 0; }
.row-due strong { font-weight: 700; }
.row-local { display: block; color: var(--ink-3); font-size: .9rem; }
.row-meta { margin: .45rem 0 0; color: var(--ink-2); font-size: .92rem; }

.row-more { margin-top: .55rem; font-size: .92rem; }
.row-more summary { cursor: pointer; color: var(--ink-2); width: max-content; }
.row-more summary:hover { color: var(--ink); }
.row-more ul { list-style: none; padding: 0; margin: .5rem 0 0; display: grid; gap: .25rem; }
.row-more li { display: grid; grid-template-columns: minmax(9rem, 13rem) 1fr; gap: .8rem; }
.row-more li.past { color: var(--ink-3); }
.row-more li.past .d-label { text-decoration: line-through; }
.row-more .d-when { font-variant-numeric: tabular-nums; }
.row-note { margin: .5rem 0 0; color: var(--ink-2); max-width: 62ch; }

.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: .7rem; text-align: right; }
.cd { font-family: var(--display); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cd b { font-weight: 800; font-size: 1.45rem; letter-spacing: -0.02em; }
.cd i { font-style: normal; color: var(--ink-3); margin: 0 .35rem 0 .12rem; font-size: .9rem; }
.cd i:last-child { margin-right: 0; }
.cd-sub { display: block; font-family: var(--body); font-size: .82rem; color: var(--ink-3); }
.row.soon .cd b { color: var(--ink); }
.row.urgent .cd b { color: var(--urgent); }
.row.urgent .cd-sub { color: var(--urgent); }

.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; justify-content: flex-end; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 2.25rem; height: 2.25rem;
  color: var(--ink-2); background: none;
  border: 1px solid var(--rule); border-radius: var(--r-btn);
  cursor: pointer; text-decoration: none;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-3); }
.icon-btn svg { width: 1.1rem; height: 1.1rem; }
.star[aria-pressed="true"] { color: #b7791f; border-color: #e7c27a; background: #fdf5e3; }
@media (prefers-color-scheme: dark) {
  .star[aria-pressed="true"] { color: #f6c453; border-color: #6e5520; background: #2e2510; }
}

/* Rolling + closed groups */
.group { margin: 2.2rem 0 1.6rem; }
.group > summary {
  cursor: pointer; list-style: none;
  font-family: var(--display); font-weight: 700; font-size: 1.15rem;
  margin-bottom: .6rem;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::before { content: "▸"; display: inline-block; width: 1rem; margin-right: .2rem; text-align: center; color: var(--ink-3); transition: transform .15s; }
.group[open] > summary::before { transform: rotate(90deg); }
.group > summary small { font-family: var(--body); font-weight: 400; font-size: .9rem; color: var(--ink-3); margin-left: .4rem; }
.row.closed .row-day { color: var(--ink-3); font-size: 1.5rem; }

.empty {
  background: var(--surface); border: 1px dashed var(--rule); border-radius: var(--r-panel);
  padding: 1.6rem 1.4rem; color: var(--ink-2);
}
.empty strong { color: var(--ink); }
.empty button { margin-top: .8rem; }

.error {
  background: var(--urgent-soft); color: var(--ink);
  border-radius: var(--r-panel); padding: 1.3rem 1.4rem;
}
.error code { font-size: .92em; background: var(--surface); padding: .1rem .35rem; border-radius: 5px; }

/* ── Footer ─────────────────────────────────────────────────────────── */
.foot {
  border-top: 1px solid var(--rule);
  margin-top: 2.5rem; padding: 1.4rem 0 3rem;
  color: var(--ink-3); font-size: .9rem;
}
.foot p { margin: 0 0 .5rem; max-width: 72ch; }
.foot a { color: var(--ink-2); }

/* ── Small screens ──────────────────────────────────────────────────── */
@media (max-width: 820px) {
  .top { grid-template-columns: 1fr; gap: 1.6rem; padding-top: 2.2rem; }
  h1 { max-width: none; }
  #ics-all { margin-left: 0; }
}
@media (max-width: 620px) {
  .wrap { width: min(1120px, 100% - 1.5rem); }
  .row { grid-template-columns: 3rem minmax(0, 1fr); gap: .8rem; padding: 1rem .9rem 1rem .75rem; }
  .row-day { font-size: 1.7rem; }
  .row-side { grid-column: 2; flex-direction: row; align-items: center; justify-content: space-between; text-align: left; }
  .row-more li { grid-template-columns: 1fr; gap: 0; margin-bottom: .3rem; }
  .search { max-width: none; }
  .next-cd { gap: .2rem .7rem; }
  .next-cd b { font-size: 2.1rem; }
  .next-cd i { font-size: .85rem; }
}
