:root {
  --bg: #0b1020;
  --panel: #141c33;
  --line: #2a365c;
  --text: #e8eefc;
  --muted: #9aa8c7;
  --lime: #9dff7a;
  --cyan: #6ce0ff;
  --amber: #ffd166;
  --red: #ff6b8a;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(1200px 600px at 10% -10%, #1a2750, var(--bg));
  color: var(--text);
}
header {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 40;
  background: #0d1428;
}
h1 { margin: 0; font-size: 1.4rem; letter-spacing: 0.04em; }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo {
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  filter: drop-shadow(0 0 12px rgba(108, 224, 255, 0.28));
}
header p { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }
body:not([data-collapsible-filters="true"]) .sidebar-toggle,
body:not([data-collapsible-filters="true"]) .filter-backdrop { display: none; }
.filter-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 25;
  border: 0;
  border-radius: 0;
  padding: 0;
  background: rgba(5, 8, 18, 0.55);
}
.sidebar {
  position: relative;
  z-index: 5;
  min-width: 0;
  min-height: 0;
  height: 100%;
}
.sidebar-clip {
  height: 100%;
  overflow: hidden;
}
.sidebar-toggle {
  position: absolute;
  z-index: 6;
  top: 50%;
  right: 0;
  width: 22px;
  height: 56px;
  margin: 0;
  padding: 0;
  display: grid;
  place-items: center;
  transform: translate(50%, -50%);
  border-radius: 0 8px 8px 0;
  border: 1px solid var(--line);
  border-left: 0;
  background: #162244;
  color: var(--cyan);
  box-shadow: 2px 0 14px rgba(0, 0, 0, 0.28);
  transition: transform 0.32s ease, background 0.15s ease, color 0.15s ease;
}
.sidebar-toggle svg { display: block; transition: transform 0.32s ease; }
.sidebar-toggle:hover { background: #22325f; color: var(--text); }
.sidebar-toggle:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
body.filters-collapsed .sidebar-toggle { transform: translate(100%, -50%); }
body.filters-collapsed .sidebar-toggle svg { transform: rotate(180deg); }
main {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 520px minmax(0, 1fr);
  transition: grid-template-columns 0.32s ease;
  overflow: hidden;
}
body.filters-collapsed main { grid-template-columns: 0px minmax(0, 1fr); }
aside {
  width: 520px;
  height: 100%;
  min-height: 0;
  padding: 8px 12px;
  border-right: 1px solid var(--line);
  background: rgba(10, 14, 28, 0.55);
  overflow-x: hidden;
  overflow-y: auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 14px;
  align-content: start;
}
aside > section:not(.aperture) { grid-column: 1 / -1; }
aside section.moon-names {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 12px;
}
aside section.moon-names h2,
aside section.moon-names .hint { grid-column: 1 / -1; }
aside section { margin-bottom: 10px; }
aside h2 {
  margin: 16px 0 10px;
  line-height: 1.45;
}
aside > section:first-child > h2 { margin-top: 4px; }
aside label { margin: 1px 0; }
aside .hint { margin: 0 0 2px; }
section { margin-bottom: 18px; }
h2 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--cyan); margin: 0 0 8px; }
label { display: block; margin: 8px 0; font-size: 0.85rem; color: var(--muted); }
select, input[type="range"], input[type="text"] { width: 100%; margin-top: 4px; }
select {
  appearance: none;
  color-scheme: dark;
  background-color: #10182c;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath fill='%236ce0ff' d='M1.2 1.4 6 6.2 10.8 1.4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 8px;
  color: #c9d4ee;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 32px 7px 10px;
  font: inherit;
  font-size: 0.84rem;
  line-height: 1.3;
}
select:hover { border-color: #3d528c; }
select:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(108, 224, 255, 0.18);
}
select option {
  background-color: #10182c;
  color: #c9d4ee;
}
select option:checked {
  background-color: #24345c;
  color: #d7e2f8;
}
input[type="text"] {
  background: #0e1628;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 0.85rem;
}
.check { display: flex; gap: 8px; align-items: center; }
.modes { display: flex; flex-wrap: wrap; gap: 6px; }
button {
  background: #2b3d72;
  color: var(--text);
  border: 0;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
}
button.active { background: #3a6b3a; color: var(--lime); }
button.secondary { width: 100%; margin-top: 8px; background: #1e2d55; }
.hint { font-size: 0.75rem; color: var(--muted); line-height: 1.35; }
.stage { padding: 16px; display: grid; grid-template-rows: 1fr auto; gap: 12px; }
.canvas-wrap {
  position: relative;
  background: #05070f;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: auto;
  min-height: 420px;
}
canvas { display: block; max-width: 100%; cursor: crosshair; }
.loupe {
  position: fixed;
  left: 0;
  top: 0;
  width: 196px;
  height: 196px;
  box-sizing: border-box;
  pointer-events: none;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 12px 28px rgba(0, 0, 0, 0.55);
  background: #05070f;
  z-index: 30;
  display: none;
}
#status {
  position: absolute;
  left: 12px;
  top: 12px;
  background: rgba(0,0,0,0.55);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
}
#results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
}
.card strong { display: block; font-size: 1.15rem; color: var(--lime); }
.card span { color: var(--muted); font-size: 0.8rem; }
.moon-card { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.moon-card strong { font-size: 0.95rem; }
.remove-moon { flex: 0 0 auto; padding: 6px 9px; background: #49283b; color: #ffd4df; }
.remove-moon:hover { background: #71334d; }
.delta { color: var(--amber); }
code { color: var(--cyan); }

/* Header-Infos der beiden FITS-Dateien */
.headers {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 10px;
}
.header-card { display: flex; flex-direction: column; align-items: stretch; gap: 6px; }
.hdr-rows { display: grid; gap: 2px; }
.hdr-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.85rem;
}
.hdr-row em { font-style: normal; color: var(--muted); }
.hdr-row.hdr-missing b { color: var(--red); }

/* Warnungen (fehlende Header-Keys, Annulus-Kollision) */
.warn {
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid #b58900;
  border-radius: 10px;
  background: rgba(255, 200, 60, 0.12);
  color: var(--amber);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* Erklär-Hinweise (Info, keine Warnung) */
.info {
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid var(--cyan);
  border-radius: 10px;
  background: rgba(108, 224, 255, 0.08);
  color: var(--cyan);
  font-size: 0.85rem;
  line-height: 1.5;
}

/* ===== Zwei-Panel-Layout (Referenz + Transit nebeneinander) ===== */
.panels {
  min-height: 0;
  overflow: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(420px, 100%), 1fr));
  gap: 14px;
  align-items: start;
  align-content: start;
}
.panel {
  background: rgba(10, 14, 28, 0.55);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  min-width: 0;
}
.panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.panel-head h2 { margin: 0; }
.panel .canvas-wrap { margin-bottom: 10px; }
.panel-results { margin-top: 6px; }
.results {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
}
.status {
  position: absolute;
  left: 12px;
  top: 12px;
  background: rgba(0, 0, 0, 0.55);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.8rem;
}
.compare-panel,
.headers-panel {
  grid-column: 1 / -1;
}
.header-card .hdr-rows { max-height: 320px; overflow: auto; }

/* Mond-Liste pro Panel (einzelne Monde loeschen) */
.moon-list {
  margin: 8px 0 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 0.8rem;
  color: var(--muted);
}
.moon-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(10, 14, 28, 0.55);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 4px 8px;
}
.moon-item em {
  font-style: normal;
  color: var(--muted);
  font-size: 0.75rem;
}
.moon-tag {
  display: inline-block;
  min-width: 16px;
  text-align: center;
  border-radius: 4px;
  color: #0b1020;
  font-weight: bold;
  font-size: 0.72rem;
  padding: 1px 3px;
}
.moon-del {
  background: #3a1f2b;
  color: var(--red);
  border: 1px solid var(--red);
  border-radius: 6px;
  padding: 0 7px;
  font-size: 0.95rem;
  line-height: 1.4;
  cursor: pointer;
}
.moon-del:hover {
  background: var(--red);
  color: #0b1020;
}

@media (prefers-reduced-motion: reduce) {
  main, .sidebar, .sidebar-toggle, .sidebar-toggle svg { transition: none; }
}

/* Schmale Breite: Filter als Schublade von links, Griff bleibt am Rand sichtbar. */
@media (max-width: 1100px) {
  body[data-collapsible-filters="true"] header { padding: 12px 16px; }
  body[data-collapsible-filters="true"] main {
    display: block;
    transition: none;
  }
  body[data-collapsible-filters="true"] .sidebar {
    position: fixed;
    z-index: 30;
    top: var(--header-h, 72px);
    left: 0;
    bottom: 0;
    width: min(520px, 92vw);
    height: auto;
    transform: translateX(-100%);
    transition: transform 0.32s ease;
  }
  body[data-collapsible-filters="true"] .sidebar-toggle { transform: translate(100%, -50%); }
  body[data-collapsible-filters="true"] .sidebar-toggle svg { transform: rotate(180deg); }
  body[data-collapsible-filters="true"].filters-open .sidebar {
    transform: translateX(0);
    box-shadow: 12px 0 36px rgba(0, 0, 0, 0.45);
  }
  body[data-collapsible-filters="true"].filters-open .sidebar-toggle { transform: translate(50%, -50%); }
  body[data-collapsible-filters="true"].filters-open .sidebar-toggle svg { transform: none; }
  body[data-collapsible-filters="true"] #filters {
    width: 100%;
    background: #0d1428;
  }
  body[data-collapsible-filters="true"].filters-open .filter-backdrop { display: block; }
}
