:root {
  color-scheme: light;

  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e2e5ea;
  --text: #1a1d21;
  --muted: #5c6470;
  --accent: #1f6feb;
  --urgent: #c2410c;
  --past: #8b929c;
  --chip-bg: #eef1f5;
  --chip-on: #1f6feb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06);

  /* One hue per CORE rank, used by both the badge and the card's edge. */
  --rank-astar: #7c3aed;
  --rank-a: #1f6feb;
  --rank-b: #0d9488;
  --rank-c: #b45309;
  --rank-none: #8b929c;

  /* Countdown urgency. */
  --due-now: #dc2626;
  --due-soon: #ea580c;
  --due-near: #b45309;
}

/* Dark applies when the system asks for it and the user has not forced
   light, or whenever the user has explicitly chosen dark. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0d1117;
    --surface: #161b22;
    --border: #2a313c;
    --text: #e6edf3;
    --muted: #9aa4b2;
    --accent: #58a6ff;
    --urgent: #fb923c;
    --past: #6b7480;
    --chip-bg: #21262d;
    --chip-on: #1f6feb;
    --shadow: none;

    --rank-astar: #a78bfa;
    --rank-a: #58a6ff;
    --rank-b: #2dd4bf;
    --rank-c: #fbbf24;
    --rank-none: #6b7480;

    --due-now: #f87171;
    --due-soon: #fb923c;
    --due-near: #fbbf24;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0d1117;
  --surface: #161b22;
  --border: #2a313c;
  --text: #e6edf3;
  --muted: #9aa4b2;
  --accent: #58a6ff;
  --urgent: #fb923c;
  --past: #6b7480;
  --chip-bg: #21262d;
  --chip-on: #1f6feb;
  --shadow: none;

  --rank-astar: #a78bfa;
  --rank-a: #58a6ff;
  --rank-b: #2dd4bf;
  --rank-c: #fbbf24;
  --rank-none: #6b7480;

  --due-now: #f87171;
  --due-soon: #fb923c;
  --due-near: #fbbf24;
}

* { box-sizing: border-box; }

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

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

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- masthead ---------- */

.masthead {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 26px 0 24px;
  margin-bottom: 24px;
}

.masthead h1 { margin: 0 0 6px; font-size: 28px; letter-spacing: -.02em; }
.tagline { margin: 0 0 12px; font-size: 16px; color: var(--muted); }
.meta { margin: 4px 0; font-size: 13px; color: var(--muted); }

/* ---------- utility bar ---------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.utility-bar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.utility-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px 18px;
  min-height: 42px;
  padding-top: 6px;
  padding-bottom: 6px;
}

.pref { display: flex; align-items: center; gap: 6px; min-width: 0; }

/* Push the preference controls to the right, star button to the left. */
.utility-inner .pref:first-of-type { margin-left: auto; }

.gh-star {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.gh-star:hover { text-decoration: none; border-color: var(--muted); }
.gh-star:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.gh-count {
  padding-left: 7px;
  border-left: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.gh-count[hidden] { display: none; }

.pref-icon { font-size: 14px; line-height: 1; opacity: .7; }

#tz-select {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 330px;
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

#tz-select:focus-visible,
.segmented button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.segmented {
  display: inline-flex;
  background: var(--chip-bg);
  border-radius: 999px;
  padding: 2px;
}

.segmented button {
  padding: 3px 11px;
  font: inherit;
  font-size: 12px;
  color: var(--muted);
  background: none;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
}

.segmented button:hover { color: var(--text); }

.segmented button[aria-pressed="true"] {
  background: var(--chip-on);
  color: #fff;
}

/* ---------- controls ---------- */

.controls {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

#search {
  flex: 1 1 260px;
  min-width: 0;
  padding: 8px 12px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
}

#search:focus, .reset:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

#country-select {
  padding: 8px 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  max-width: 220px;
}

#country-select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.toggle { font-size: 14px; color: var(--muted); white-space: nowrap; cursor: pointer; }
.toggle input { margin-right: 5px; vertical-align: -1px; }

.reset {
  padding: 8px 14px;
  font: inherit;
  font-size: 13px;
  color: var(--muted);
  background: var(--chip-bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
}
.reset:hover { color: var(--text); }

.filter-group {
  border: 0;
  padding: 0;
  margin: 0 0 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
}

.filter-group legend { display: contents; }

.filter-group legend,
.filter-group > legend {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 13px;
  background: var(--chip-bg);
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
}

.chip:hover { border-color: var(--border); }
.chip:has(input:checked) { background: var(--chip-on); color: #fff; }
.chip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 1px; }

/* The chip fill is the state indicator, so the native box is hidden rather
   than removed -- it stays focusable and screen-reader visible. */
.chip input {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: 11px;
  height: 11px;
  border: 1.5px solid var(--muted);
  border-radius: 3px;
  flex: none;
}

.chip:has(input:checked)::before {
  background: #fff;
  border-color: #fff;
  box-shadow: inset 0 0 0 2px var(--chip-on);
}

.result-count {
  margin: 10px 0 0;
  font-size: 13px;
  color: var(--muted);
}

/* ---------- conference cards ---------- */

.conf-list { display: flex; flex-direction: column; gap: 8px; }

.conf {
  --rank: var(--rank-none);
  border-left: 4px solid var(--rank);
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  transition: border-color .15s ease, transform .15s ease;
}

.conf:hover { border-color: var(--muted); }

@media (prefers-reduced-motion: no-preference) {
  .conf:hover { transform: translateY(-1px); }
}

.conf.rank-astar { --rank: var(--rank-astar); }
.conf.rank-a     { --rank: var(--rank-a); }
.conf.rank-b     { --rank: var(--rank-b); }
.conf.rank-c     { --rank: var(--rank-c); }
.conf.rank-none  { --rank: var(--border); }

.conf[hidden] { display: none; }
.conf.past { opacity: .55; }

.conf-main { flex: 1 1 380px; min-width: 0; }

.conf h2 {
  margin: 0 0 6px;
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -.01em;
}

.cycle {
  margin-left: 8px;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
}

.badges { margin: 0 0 6px; display: flex; flex-wrap: wrap; gap: 5px; }

.badge {
  display: inline-block;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  border-radius: 4px;
  background: var(--chip-bg);
  color: var(--muted);
}

.badge.core { background: var(--rank, var(--rank-none)); color: #fff; }
.badge.core-astar { --rank: var(--rank-astar); }
.badge.core-a     { --rank: var(--rank-a); }
.badge.core-b     { --rank: var(--rank-b); }
.badge.core-c     { --rank: var(--rank-c); }
.badge.core-none  { --rank: transparent; color: var(--muted); border: 1px solid var(--border); }

.desc { margin: 0 0 4px; font-size: 14px; color: var(--text); }
.conf .meta { margin: 0; font-size: 13px; }
.comment { font-style: italic; }

/* ---------- deadline column ---------- */

.conf-times {
  flex: 0 1 300px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

.dl {
  display: grid;
  grid-template-columns: 82px 1fr;
  grid-template-areas: "label timer" "label date";
  gap: 0 10px;
  align-items: baseline;
  padding: 6px 10px;
  border-radius: 7px;
  background: var(--bg);
}

.dl-abstract { border-left: 3px solid var(--muted); }
.dl-tba { border-left: 3px dashed var(--muted); }

.dl-timer.tba {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .06em;
  color: var(--muted);
}

.conf[data-state="tba"] { opacity: .82; }
.conf[data-state="tba"]:hover { opacity: 1; }
.dl-paper { border-left: 3px solid var(--rank); }

.dl-label {
  grid-area: label;
  align-self: center;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--muted);
}

.dl-timer {
  grid-area: timer;
  font-size: 16px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}

.dl-timer.due-now  { color: var(--due-now); }
.dl-timer.due-soon { color: var(--due-soon); }
.dl-timer.due-near { color: var(--due-near); }
.dl-timer.passed { font-size: 14px; font-weight: 400; color: var(--past); }

.dl-date {
  grid-area: date;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

/* ---------- footer ---------- */

.empty {
  padding: 32px;
  text-align: center;
  color: var(--muted);
}

footer {
  margin: 36px 0 48px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
  font-size: 13px;
  color: var(--muted);
}

footer p { margin: 6px 0; }

.stats { font-variant-numeric: tabular-nums; }
.stats[hidden] { display: none; }

@media (max-width: 640px) {
  .masthead { padding: 18px 0 18px; }
  .utility-inner { justify-content: space-between; }
  #tz-select { max-width: 100%; }
  .masthead h1 { font-size: 22px; }
  .conf { padding: 12px 14px; }
  .conf-times { flex: 1 1 100%; }
}

/* ---------- update banner ---------- */

.update-banner {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: calc(100vw - 32px);
  padding: 10px 12px 10px 16px;
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .18);
}

.update-banner[hidden] { display: none; }

.update-banner button {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
}

#update-reload {
  padding: 5px 14px;
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  background: var(--accent);
  border: 0;
}

#update-dismiss {
  padding: 2px 8px;
  font-size: 18px;
  line-height: 1;
  color: var(--muted);
  background: none;
  border: 0;
}

#update-dismiss:hover { color: var(--text); }

#update-reload:focus-visible,
#update-dismiss:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
