:root {
  --bg: #050508;
  --surface: rgba(14, 14, 22, 0.72);
  --line: rgba(240, 199, 94, 0.14);
  --gold: #f0c75e;
  --gold-bright: #ffd97a;
  --solar: #b3902f;
  --solar-ink: #e5c96a;
  --lunar: #c65d78;
  --lunar-ink: #f0a4b8;
  --ink: #ece7db;
  --ink-2: #a39dab;
  --ink-3: #6a6472;
  --mono: "Inter", ui-monospace, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, sans-serif;
  font-size: 14px;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 1fr;
}

h1, .display { font-family: "Cinzel", serif; }

button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
button:focus-visible, .row:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

/* ---------- header ---------- */
header {
  display: flex;
  align-items: baseline;
  gap: 18px;
  padding: 14px 22px 12px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(240, 199, 94, 0.05), transparent);
}

h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.22em;
  background: linear-gradient(105deg, #8a6d1f, var(--gold-bright) 40%, #fff2cf 50%, var(--gold-bright) 60%, #8a6d1f);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.tagline { color: var(--ink-2); letter-spacing: 0.12em; font-size: 11px; text-transform: uppercase; }
#stats { margin-left: auto; color: var(--ink-2); font-size: 12px; letter-spacing: 0.05em; }
#stats b { color: var(--gold); font-weight: 600; }

/* ---------- layout ---------- */
main { display: grid; grid-template-columns: 350px 1fr; min-height: 0; }

aside {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line);
  background: rgba(8, 8, 13, 0.6);
}

/* ---------- next-eclipse hero ---------- */
#hero { padding: 16px 18px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
#hero .label { font-size: 10px; letter-spacing: 0.28em; color: var(--gold); text-transform: uppercase; }
#hero .name { font-size: 16px; margin: 6px 0 2px; font-weight: 600; }
#hero .when { color: var(--ink-2); font-size: 12px; }
#hero .count {
  font-variant-numeric: tabular-nums;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--gold-bright);
  text-shadow: 0 0 24px rgba(240, 199, 94, 0.45);
  margin-top: 8px;
}
#hero .count small { font-size: 11px; color: var(--ink-3); letter-spacing: 0.1em; margin-right: 10px; }

/* ---------- filters ---------- */
#chips { display: flex; gap: 8px; padding: 12px 18px; }
.chip {
  padding: 5px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  font-size: 12px;
  letter-spacing: 0.06em;
  transition: all 0.15s;
}
.chip:hover { border-color: var(--gold); color: var(--ink); }
.chip.on { background: rgba(240, 199, 94, 0.12); border-color: var(--gold); color: var(--gold); }

/* ---------- eclipse list ---------- */
#list { overflow-y: auto; flex: 1; padding-bottom: 30px; }
#list::-webkit-scrollbar { width: 8px; }
#list::-webkit-scrollbar-thumb { background: rgba(240, 199, 94, 0.15); border-radius: 4px; }

.year {
  position: sticky;
  top: 0;
  padding: 8px 18px 4px;
  font-family: "Cinzel", serif;
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--gold);
  background: linear-gradient(180deg, #08080d 75%, transparent);
  z-index: 1;
}

.row {
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  padding: 8px 18px;
  text-align: left;
  border-left: 2px solid transparent;
  transition: background 0.12s;
}
.row:hover { background: rgba(240, 199, 94, 0.06); }
.row.sel { background: rgba(240, 199, 94, 0.1); border-left-color: var(--gold); }
.row.past { opacity: 0.45; }
.row .d { color: var(--ink-2); font-size: 12px; font-variant-numeric: tabular-nums; }
.row .meta { color: var(--ink-3); font-size: 11px; font-variant-numeric: tabular-nums; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  border: 1px solid;
  width: fit-content;
}
.badge.solar { color: var(--solar-ink); border-color: rgba(179, 144, 47, 0.55); background: rgba(179, 144, 47, 0.13); }
.badge.lunar { color: var(--lunar-ink); border-color: rgba(198, 93, 120, 0.55); background: rgba(198, 93, 120, 0.13); }

/* ---------- stage ---------- */
#stage { position: relative; min-width: 0; }
#stage canvas { display: block; }

#timebar {
  position: absolute;
  left: 16px;
  bottom: 14px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  backdrop-filter: blur(10px);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
#timebar b { color: var(--gold); font-weight: 600; }

#hint {
  position: absolute;
  right: 16px;
  bottom: 14px;
  color: var(--ink-3);
  font-size: 11px;
  letter-spacing: 0.06em;
}

/* ---------- detail card ---------- */
#detail {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 320px;
  max-height: calc(100% - 32px);
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  backdrop-filter: blur(14px);
  padding: 16px 18px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}
#detail[hidden] { display: none; }
#detail .close { position: absolute; top: 10px; right: 12px; color: var(--ink-3); font-size: 15px; }
#detail .close:hover { color: var(--ink); }
#detail h2 { font-size: 17px; font-weight: 700; letter-spacing: 0.03em; margin: 2px 40px 2px 0; }
#detail .date { color: var(--ink-2); font-size: 12px; margin-bottom: 10px; }
#detail .soon {
  display: inline-block;
  margin-left: 8px;
  color: var(--gold);
  font-size: 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
}
#detail table { width: 100%; border-collapse: collapse; margin: 8px 0; }
#detail td { padding: 4px 0; font-size: 12.5px; vertical-align: top; }
#detail td:first-child { color: var(--ink-3); width: 42%; }
#detail td:last-child { color: var(--ink); font-variant-numeric: tabular-nums; }
#detail .note { color: var(--ink-3); font-size: 11.5px; line-height: 1.5; margin-top: 8px; }

#detail .play {
  margin-top: 10px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--gold);
  border-radius: 8px;
  color: var(--gold);
  letter-spacing: 0.12em;
  font-size: 12px;
  font-weight: 600;
  transition: all 0.15s;
}
#detail .play:hover { background: rgba(240, 199, 94, 0.14); box-shadow: 0 0 18px rgba(240, 199, 94, 0.25); }

#detail svg { display: block; margin: 10px auto 2px; }
#detail .svgcap { text-align: center; color: var(--ink-3); font-size: 10.5px; letter-spacing: 0.08em; }

/* ---------- loading ---------- */
#loading {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  transition: opacity 0.7s;
}
#loading.done { opacity: 0; pointer-events: none; }

.corona {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  background: #030305;
  box-shadow: 0 0 24px 6px rgba(240, 199, 94, 0.55), 0 0 90px 30px rgba(240, 199, 94, 0.18);
  animation: breathe 2.4s ease-in-out infinite;
}
@keyframes breathe {
  50% { box-shadow: 0 0 34px 10px rgba(240, 199, 94, 0.75), 0 0 120px 44px rgba(240, 199, 94, 0.26); }
}

#loading .display { letter-spacing: 0.3em; font-size: 14px; color: var(--gold); }
#loadmsg { color: var(--ink-3); font-size: 12px; letter-spacing: 0.1em; font-variant-numeric: tabular-nums; }
#loadbar { width: 240px; height: 2px; background: rgba(240, 199, 94, 0.12); border-radius: 2px; overflow: hidden; }
#loadbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #8a6d1f, var(--gold-bright)); transition: width 0.2s; }

#bootfail {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 11;
  padding: 12px 20px;
  background: #2a1515;
  color: #f0b9b9;
  font-size: 13px;
  text-align: center;
}
