:root {
  --bg: #fafaf9;
  --surface: #ffffff;
  --surface-2: #f4f4f3;
  --text: #1c1917;
  --muted: #6b6560;
  --border: #e5e3e0;
  --link: #1d4ed8;
  --systems: #2563eb;
  --security: #7c3aed;
  --se: #059669;
  --urgent: #dc2626;
  --soon: #d97706;
  --today: #dc2626;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.04), 0 1px 1px rgb(0 0 0 / 0.03);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111110;
    --surface: #1a1918;
    --surface-2: #232220;
    --text: #edece9;
    --muted: #a19d97;
    --border: #2f2d2a;
    --link: #93b4ff;
    --systems: #60a5fa;
    --security: #a78bfa;
    --se: #34d399;
    --urgent: #f87171;
    --soon: #fbbf24;
    --today: #f87171;
    --shadow: none;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #111110;
  --surface: #1a1918;
  --surface-2: #232220;
  --text: #edece9;
  --muted: #a19d97;
  --border: #2f2d2a;
  --link: #93b4ff;
  --systems: #60a5fa;
  --security: #a78bfa;
  --se: #34d399;
  --urgent: #f87171;
  --soon: #fbbf24;
  --today: #f87171;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 1180px; margin: 0 auto; padding: 0 16px; }

.site-header { padding: 36px 0 20px; }
.site-header h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -0.02em; }
.lede { margin: 0 0 6px; color: var(--muted); max-width: 60ch; }
.meta { margin: 0; color: var(--muted); font-size: 13px; }
.meta a { margin-left: 4px; }

h2 { font-size: 18px; margin: 36px 0 12px; letter-spacing: -0.01em; }

/* ---------- Controls ---------- */
.controls {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}
.controls-inner { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; padding-top: 10px; padding-bottom: 10px; }
.chips { display: flex; gap: 4px; background: var(--surface-2); padding: 3px; border-radius: 9px; }
.chips button {
  font: inherit; font-size: 13px; border: 0; background: transparent; color: var(--muted);
  padding: 5px 12px; border-radius: 7px; cursor: pointer;
}
.chips button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow); font-weight: 600; }
.toggle { font-size: 13px; color: var(--muted); display: flex; gap: 6px; align-items: center; cursor: pointer; }
#query {
  font: inherit; font-size: 13px; margin-left: auto; min-width: 0; width: 220px; max-width: 100%;
  padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text);
}
@media (max-width: 640px) {
  #query { margin-left: 0; width: 100%; }
  .controls { position: static; }
  .timeline-scroll .timeline { --label-w: 104px; }
}

/* ---------- Area colors ---------- */
.area-systems { --area: var(--systems); }
.area-security { --area: var(--security); }
.area-se { --area: var(--se); }

/* ---------- Timeline ---------- */
.timeline-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.timeline { --label-w: 128px; position: relative; min-width: 860px; padding: 0 12px 8px 0; }
.tl-head, .tl-row, .tl-group { display: grid; grid-template-columns: var(--label-w) 1fr; }
.tl-head { position: relative; height: 32px; border-bottom: 1px solid var(--border); }
.tl-months { position: relative; }
.tl-month { position: absolute; top: 8px; font-size: 11px; color: var(--muted); padding-left: 4px; white-space: nowrap; }
.tl-month.year { color: var(--text); font-weight: 600; }
.tl-group-label {
  grid-column: 1 / -1; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--area); padding: 12px 12px 2px;
}
.tl-row { height: 28px; }
.tl-label { font-size: 13px; font-weight: 600; padding: 0 12px; display: flex; align-items: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tl-track { position: relative; }
.tl-track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px dashed var(--border); }
.tl-grid { position: absolute; top: 0; bottom: 0; left: var(--label-w); right: 12px; pointer-events: none; }
.tl-gridline { position: absolute; top: 0; bottom: 0; border-left: 1px solid var(--border); opacity: 0.6; }
.tl-gridline.year { opacity: 1; }
.tl-today { position: absolute; top: 0; bottom: 0; border-left: 2px solid var(--today); }
.tl-today span {
  position: absolute; top: 34px; left: 4px; font-size: 10px; font-weight: 600; color: var(--today);
  background: var(--surface); padding: 0 3px; border-radius: 3px; text-transform: uppercase; letter-spacing: 0.05em;
}

.tl-review {
  position: absolute; top: 50%; height: 2px; margin-top: -1px;
  background: color-mix(in srgb, var(--area, var(--muted)) 45%, transparent);
}
.tl-conf {
  position: absolute; top: 50%; height: 14px; margin-top: -7px; min-width: 6px; border-radius: 4px;
  background: color-mix(in srgb, var(--area, var(--muted)) 30%, transparent);
  border: 1.5px solid var(--area, var(--muted));
  cursor: default;
}
.mk {
  position: absolute; top: 50%; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  border: 2px solid var(--area, var(--muted)); background: var(--surface); cursor: default;
}
.mk-paper { width: 12px; height: 12px; margin: -6px 0 0 -6px; background: var(--area, var(--muted)); }
.mk-notif { border-radius: 2px; transform: rotate(45deg); width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; background: var(--surface); }
.mk.est, .tl-conf.est { border-style: dashed; opacity: 0.6; }
.mk-paper.est { background: color-mix(in srgb, var(--area, var(--muted)) 35%, var(--surface)); }
.tl-review.est { opacity: 0.5; }
.is-past { opacity: 0.4; }
.mk:focus-visible, .tl-conf:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.mk:hover, .tl-conf:hover { z-index: 2; filter: brightness(1.1); }

.legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 0; margin: 10px 2px 0; font-size: 12px; color: var(--muted); }
.legend li { display: flex; align-items: center; gap: 6px; }
.legend .mk, .legend .tl-review, .legend .tl-conf { position: relative; top: auto; margin: 0; --area: var(--muted); }
.legend .mk-notif { margin: 0 2px; }
.legend-review { display: inline-block; width: 22px; }
.legend-conf { display: inline-block; width: 22px; }

.tl-empty { padding: 24px 16px; color: var(--muted); font-size: 14px; }

/* ---------- Tooltip ---------- */
.tip {
  position: fixed; z-index: 50; max-width: 280px; pointer-events: none;
  background: var(--text); color: var(--bg); border-radius: 8px; padding: 8px 10px;
  font-size: 12px; line-height: 1.45; box-shadow: 0 6px 20px rgb(0 0 0 / 0.2);
}
.tip strong { display: block; font-size: 13px; }
.tip .tip-est { opacity: 0.75; font-style: italic; }

/* ---------- Cards ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 14px; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  padding: 14px 16px 14px 19px; box-shadow: var(--shadow); overflow: hidden;
  display: flex; flex-direction: column;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--area); }
.card.est { border-style: dashed; }
.card.est::before { opacity: 0.5; }
.card-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.card h3 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.card h3 a { color: var(--text); }
.cycle-name { font-size: 13px; color: var(--muted); font-weight: 500; }
.badges { margin-left: auto; display: flex; gap: 4px; }
.badge {
  font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; white-space: nowrap;
  color: var(--area); background: color-mix(in srgb, var(--area) 12%, transparent);
}
.badge.est-badge { color: var(--muted); background: var(--surface-2); }
.full-name { margin: 2px 0 10px; font-size: 12px; color: var(--muted); }

.countdown { font-variant-numeric: tabular-nums; font-size: 24px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.1; }
.countdown small { font-size: 13px; font-weight: 500; color: var(--muted); margin: 0 5px 0 1px; }
.card.soon .countdown { color: var(--soon); }
.card.urgent .countdown { color: var(--urgent); }
.countdown-label { font-size: 12px; color: var(--muted); margin: 2px 0 10px; }

.dates { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; font-size: 13px; }
.dates dt { color: var(--muted); }
.dates dd { margin: 0; font-variant-numeric: tabular-nums; }
.dates dd small { display: block; color: var(--muted); font-size: 11px; }
.dates .done { color: var(--muted); }
.dates dd.done { text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--muted) 60%, transparent); }
.dates dd.next { font-weight: 600; }

.notes { font-size: 12px; color: var(--muted); margin: 10px 0 0; }
.links { margin-top: auto; padding-top: 12px; display: flex; gap: 14px; font-size: 13px; }

.empty { color: var(--muted); font-size: 14px; }

/* ---------- Conferences table ---------- */
.table-scroll { overflow-x: auto; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.confs { width: 100%; border-collapse: collapse; font-size: 14px; }
.confs th, .confs td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.confs tr:last-child td { border-bottom: 0; }
.confs th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); }
.confs .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--area); margin-right: 8px; }
.confs .rel { color: var(--muted); font-size: 12px; }
.confs .now { color: var(--se); font-weight: 600; }

/* ---------- Past ---------- */
details.past summary { cursor: pointer; list-style: none; }
details.past summary::-webkit-details-marker { display: none; }
details.past summary h2 { display: inline-block; }
details.past summary h2::before { content: "▸ "; color: var(--muted); }
details.past[open] summary h2::before { content: "▾ "; }
details.past .card { opacity: 0.8; }

.site-footer { color: var(--muted); font-size: 12px; padding-top: 32px; padding-bottom: 40px; }
