:root {
  color-scheme: dark;
  --bg: #000000;
  --page: #030303;
  --panel-bg: #0a0a0a;
  --hairline: rgba(255,255,255,0.14);
  --hairline-soft: rgba(255,255,255,0.08);
  --text: #f4f4f2;
  --text-secondary: #b9b9b3;
  --text-muted: #6f6f6a;
  --accent: #ffb14d;
  --accent-dim: rgba(255,177,77,0.35);
  --critical: #e34948;
  --mono: 'SF Mono', 'Roboto Mono', ui-monospace, Menlo, Consolas, monospace;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  overflow: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  background:
    radial-gradient(ellipse at 20% -10%, rgba(255,177,77,0.05), transparent 45%),
    var(--bg);
}

/* ---------- safety banner ---------- */
#safety-banner {
  flex-shrink: 0;
  background: #1a0e0a;
  border-bottom: 1px solid rgba(227,73,72,0.4);
  color: #ffb8a8;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 6px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.safety-icon { color: var(--critical); font-size: 0.9rem; }

/* ---------- header ---------- */
#app-header {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--hairline);
  flex-shrink: 0;
}

.title-block h1 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.subheader {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 2px;
}

.mode-block {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 20px;
}

.mode-badge {
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  padding: 5px 14px;
  border: 1px solid var(--hairline);
  color: var(--text-muted);
}
body[data-mode="live"] .mode-badge {
  color: #000;
  background: var(--accent);
  border-color: var(--accent);
  animation: pulse 2s infinite;
}
body[data-mode="countdown"] .mode-badge { color: var(--text-secondary); border-color: var(--hairline); }
body[data-mode="replay"] .mode-badge { color: var(--accent); border-color: var(--accent-dim); }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255,177,77,0.45); }
  50% { box-shadow: 0 0 0 7px rgba(255,177,77,0); }
}

.countdown { text-align: right; line-height: 1.15; }
.countdown-value {
  font-family: var(--mono);
  font-size: 1.5rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  display: block;
  letter-spacing: 0.02em;
}
.countdown-caption {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.lang-toggle {
  background: transparent;
  border: 1px solid var(--hairline);
  color: var(--text-muted);
  border-radius: 0;
  padding: 7px 14px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  cursor: pointer;
  font-family: var(--mono);
}
.lang-toggle:hover { color: var(--text); border-color: var(--text-secondary); }

/* ---------- main grid ---------- */
#app-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 2fr 1fr;
  grid-template-rows: 3fr 2fr;
  grid-template-areas:
    "sky data"
    "secondary data";
  gap: 1px;
  padding: 1px;
  background: var(--hairline-soft);
}

#sky-panel { grid-area: sky; }
#secondary-row {
  grid-area: secondary;
  display: flex;
  gap: 1px;
  min-height: 0;
  background: var(--hairline-soft);
}
#secondary-row .panel { flex: 1; min-width: 0; }
#data-column {
  grid-area: data;
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-height: 0;
  overflow-y: auto;
  background: var(--hairline-soft);
}
#data-column .panel { flex-shrink: 0; }
#data-column::-webkit-scrollbar { width: 6px; }
#data-column::-webkit-scrollbar-thumb { background: var(--hairline); }

/* ---------- panel chrome: corner-bracket HUD style ---------- */
.panel {
  position: relative;
  background: var(--panel-bg);
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.panel::before, .panel::after {
  content: '';
  position: absolute;
  width: 10px;
  height: 10px;
  border: 1px solid var(--accent-dim);
  pointer-events: none;
}
.panel::before { top: 4px; left: 4px; border-right: none; border-bottom: none; }
.panel::after { bottom: 4px; right: 4px; border-left: none; border-top: none; }

.panel h2 {
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.panel h3 {
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--text-muted);
  margin: 16px 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border-top: 1px solid var(--hairline-soft);
  padding-top: 12px;
}

#sky-canvas, #orrery-canvas, #chart-canvas {
  width: 100%;
  flex: 1;
  min-height: 0;
}

#weather-timeline-canvas {
  width: 100%;
  height: 70px;
  flex-shrink: 0;
}

.value-accent { color: var(--accent) !important; }

/* ---------- telemetry ---------- */
.telemetry-grid, .contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 16px;
}

.stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 6px 0;
  border-bottom: 1px solid var(--hairline-soft);
}
.stat.wide { grid-column: 1 / -1; }

.stat .label {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.stat .value {
  font-family: var(--mono);
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  color: var(--text);
}
.stat .note {
  font-size: 0.72rem;
  color: var(--accent);
  min-height: 1em;
}

.bar {
  height: 5px;
  background: #1c1c1a;
  margin-top: 4px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 0.3s ease;
}
.bar-fill-blue { background: #3987e5; }

/* ---------- next eclipses ---------- */
.next-eclipses-list { display: flex; flex-direction: column; }
.next-eclipse-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 7px 0;
  border-bottom: 1px solid var(--hairline-soft);
  font-family: var(--mono);
  font-size: 0.82rem;
}
.next-eclipse-date { color: var(--text-secondary); }
.next-eclipse-kind { color: var(--text-muted); font-size: 0.68rem; letter-spacing: 0.06em; }
.next-eclipse-obsc { color: var(--accent); font-weight: 700; text-align: right; min-width: 3.5em; }
.next-eclipse-row-invisible .next-eclipse-obsc { color: var(--text-muted); font-weight: 400; }

/* ---------- comparison ---------- */
.comparison-header, .comparison-row {
  display: grid;
  grid-template-columns: 1.4fr 1fr 0.7fr 0.7fr;
  gap: 8px;
  align-items: center;
}
.comparison-header {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--hairline);
}
.comparison-row {
  padding: 7px 0;
  border-bottom: 1px solid var(--hairline-soft);
  font-family: var(--mono);
  font-size: 0.8rem;
}
.comparison-row-primary { color: var(--accent); font-weight: 700; }
.comparison-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.comparison-peak, .comparison-live { text-align: right; }
.comparison-live { color: var(--accent); }

/* ---------- weather ---------- */
.weather-content {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ---------- mission ticker (bottom bar) ---------- */
#mission-ticker {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  background: #050505;
  border-top: 1px solid var(--hairline);
}
.ticker-item {
  flex: 0 0 auto;
  padding: 8px 22px;
  border-right: 1px solid var(--hairline-soft);
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 130px;
}
.ticker-item-grow { flex: 1 1 auto; min-width: 0; }
.ticker-label {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.ticker-value {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ticker-item-accent .ticker-value { color: var(--accent); }

/* ---------- where-to-look ---------- */
#look-altitude { font-family: var(--mono); font-size: 0.85rem; color: var(--text-secondary); }
#look-horizon-warning {
  font-size: 0.72rem;
  color: var(--accent);
  margin-top: 6px;
  line-height: 1.4;
}

/* ---------- safety methods ---------- */
.safety-method-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--hairline-soft);
}
.safety-method-bullet {
  color: #4fd67a;
  font-weight: 700;
  flex-shrink: 0;
  width: 1em;
}
.safety-method-never-title {
  font-size: 0.64rem;
  font-weight: 700;
  color: var(--critical);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 12px;
}
.safety-method-never { color: #ffb8a8; }
.safety-method-never .safety-method-bullet { color: var(--critical); }

/* ---------- photography guide ---------- */
.photo-filter-warning {
  font-size: 0.76rem;
  color: #ffb8a8;
  background: rgba(227,73,72,0.08);
  border: 1px solid rgba(227,73,72,0.25);
  padding: 8px 10px;
  line-height: 1.4;
  margin-bottom: 10px;
}
.photo-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.photo-settings {
  display: flex;
  gap: 10px;
}
.photo-value {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  border: 1px solid var(--hairline);
  padding: 4px 10px;
}
.photo-bracket-note {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 8px;
  line-height: 1.4;
}

/* ---------- full-screen contact-event alert ---------- */
#event-alert {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, rgba(255,177,77,0.16), rgba(0,0,0,0) 70%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
  z-index: 100;
}
#event-alert.active { opacity: 1; }
#event-alert-text {
  font-size: 3.2rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #fff;
  text-shadow: 0 0 50px rgba(255,177,77,0.9), 0 0 12px rgba(0,0,0,0.8);
  text-align: center;
  padding: 0 40px;
}

/* ---------- solar activity (SDO image + space weather) ---------- */
.sdo-image {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #000;
  border: 1px solid var(--hairline-soft);
}
.sdo-caption {
  font-size: 0.62rem;
  color: var(--text-muted);
  margin: 6px 0 10px;
  line-height: 1.3;
}

/* ---------- citizen science ---------- */
.citizen-science-row {
  padding: 8px 0;
  border-bottom: 1px solid var(--hairline-soft);
}
.citizen-science-name {
  display: block;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  text-decoration: none;
}
.citizen-science-name:hover { text-decoration: underline; }
.citizen-science-desc {
  display: block;
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-top: 2px;
}

/* ---------- Saros family ---------- */
.saros-headline {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--accent);
  margin-bottom: 6px;
}
.saros-explainer {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 10px;
}
.saros-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid var(--hairline-soft);
  font-size: 0.82rem;
}
.saros-row-label { color: var(--text-secondary); }
.saros-row-date { font-family: var(--mono); color: var(--text); }
.saros-row-current .saros-row-label,
.saros-row-current .saros-row-date { color: var(--accent); font-weight: 700; }

/* ---------- world map ---------- */
.world-map-image {
  width: 100%;
  background: #000;
  border: 1px solid var(--hairline-soft);
}
.world-map-caption {
  font-size: 0.62rem;
  color: var(--text-muted);
  margin: 6px 0 4px;
  line-height: 1.3;
}
.world-map-note {
  font-size: 0.72rem;
  color: var(--accent);
  line-height: 1.4;
}

/* ---------- live satellite ---------- */
.satellite-iframe {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--hairline-soft);
}
.satellite-caption {
  font-size: 0.62rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ---------- QR code ---------- */
.qr-code-container {
  display: flex;
  justify-content: center;
  padding: 10px;
  background: #fff;
  width: 148px;
  margin: 0 auto;
}
.qr-caption {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 8px;
}

@media (max-aspect-ratio: 1/1) {
  #app-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    grid-template-areas: "sky" "secondary" "data";
    overflow-y: auto;
  }
  #secondary-row { flex-direction: column; }
  #mission-ticker { flex-wrap: wrap; }
  .ticker-item { flex: 1 1 45%; min-width: 0; }
  #event-alert-text { font-size: 1.8rem; }
}
