:root {
  color-scheme: dark;

  --bg: #0b1220;
  --panel: #111827;
  --panel-2: #172033;

  --text: #eef2f7;
  --muted: #9ca3af;

  --border: #293548;

  --blue: #0072B2;
  --light-blue: #56B4E9;

  --orange: #E69F00;

  --usable: #009E73;
  --usable-dark: #006F55;

  --gray: #374151;

  --danger: #ef8a8a;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;

  background:
    radial-gradient(
      circle at top left,
      #172554 0,
      transparent 34rem
    ),
    var(--bg);

  color: var(--text);

  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button,
input,
select,
.button-link {
  min-height: 42px;

  border:
    1px solid
    #3a4659;

  border-radius: 9px;
}

input,
select {
  width: 100%;

  padding:
    8px 10px;

  color: var(--text);
  background: #0f172a;
}

button,
.button-link {
  padding:
    8px 14px;

  color: var(--text);
  background: #273449;

  cursor: pointer;
}

button:hover:not(:disabled),
.button-link:hover {
  filter: brightness(1.12);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

a {
  color: #8ecdf0;
}

.app-header {
  display: flex;

  align-items: center;
  justify-content: space-between;

  max-width: 1500px;

  margin:
    0 auto;

  padding:
    22px 20px 10px;
}

h1 {
  margin: 0;

  font-size:
    clamp(
      1.6rem,
      4vw,
      2.4rem
    );
}

h2 {
  margin:
    0 0 14px;

  font-size: 1.15rem;
}

.subtitle {
  margin:
    4px 0 0;

  color: var(--muted);
}

.header-right {
  display: flex;

  align-items: center;

  gap: 14px;
}

.back-link {
  text-decoration: none;
}

.version {
  color: var(--muted);
  font-size: 0.8rem;
}

main {
  max-width: 1500px;

  margin:
    0 auto;

  padding:
    10px 16px 40px;
}

.panel {
  margin-bottom: 16px;

  padding: 18px;

  background:
    rgba(
      17,
      24,
      39,
      0.95
    );

  border:
    1px solid
    var(--border);

  border-radius: 14px;

  box-shadow:
    0 12px 35px
    rgba(
      0,
      0,
      0,
      0.18
    );
}

.section-head {
  display: flex;

  align-items: flex-start;
  justify-content: space-between;

  gap: 14px;
}

.section-description {
  margin:
    -7px 0 14px;

  color: var(--muted);
  font-size: 0.86rem;
}

.section-actions {
  display: flex;
  gap: 8px;
}

.button-link {
  display: inline-flex;

  align-items: center;

  text-decoration: none;
}

.primary {
  color: #fff;

  background: #2563eb;
  border-color: #3b82f6;

  font-weight: 700;
}

.secondary {
  background: #1f2937;
}

.big-button {
  margin-top: 16px;
}

.hint {
  color: var(--muted);
  font-size: 0.8rem;
}

.context-grid {
  display: grid;

  grid-template-columns:
    repeat(
      5,
      minmax(130px, 1fr)
    );

  gap: 10px;
}

.context-card,
.detail-card {
  padding: 12px;

  background: var(--panel-2);

  border:
    1px solid
    var(--border);

  border-radius: 10px;
}

.card-label,
.detail-label {
  margin-bottom: 4px;

  color: var(--muted);
  font-size: 0.73rem;
}

.card-value,
.detail-value {
  font-weight: 700;
}

.object-grid {
  display: grid;

  grid-template-columns:
    1.4fr 1fr;

  gap: 18px;
}

.object-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.object-column > label {
  font-weight: 650;
}

.search-row,
.favorite-row {
  display: grid;

  grid-template-columns:
    1fr auto;

  gap: 8px;
}

.search-results {
  max-height: 310px;

  overflow-y: auto;

  background: #0f172a;

  border:
    1px solid
    var(--border);

  border-radius: 10px;
}

.search-result {
  display: block;

  width: 100%;
  min-height: 0;

  padding:
    10px 12px;

  text-align: left;

  color: var(--text);
  background: transparent;

  border: 0;
  border-bottom:
    1px solid
    rgba(
      255,
      255,
      255,
      0.07
    );

  border-radius: 0;
}

.search-result:last-child {
  border-bottom: 0;
}

.search-result:hover {
  background:
    rgba(
      86,
      180,
      233,
      0.12
    );
}

.search-name {
  display: block;
  font-weight: 750;
}

.search-meta {
  display: block;

  margin-top: 3px;

  color: var(--muted);
  font-size: 0.75rem;
}

.selected-object {
  margin-top: 16px;

  padding: 14px;

  background:
    rgba(
      0,
      114,
      178,
      0.13
    );

  border:
    1px solid
    rgba(
      86,
      180,
      233,
      0.45
    );

  border-radius: 10px;
}

.selected-object.empty {
  color: var(--muted);

  background: #141c2a;

  border-color:
    var(--border);
}

.selected-title {
  font-size: 1.05rem;
  font-weight: 800;
}

.selected-meta {
  margin-top: 5px;

  color: #cbd5e1;
  font-size: 0.82rem;
}

.custom-object {
  margin-top: 14px;

  padding: 12px;

  background: #0f172a;

  border:
    1px solid
    var(--border);

  border-radius: 10px;
}

.custom-object summary {
  cursor: pointer;
  font-weight: 650;
}

.custom-grid {
  display: grid;

  grid-template-columns:
    1.3fr 1fr 1fr auto;

  align-items: end;

  gap: 10px;

  margin-top: 14px;
}

.custom-grid label {
  color: var(--muted);
  font-size: 0.8rem;
}

.custom-grid input {
  margin-top: 4px;
}

.field-help {
  display: block;

  margin-top: 3px;

  color: #7d8999;
  font-size: 0.68rem;
}

.custom-button {
  align-self: center;
}

.catalog-credit {
  margin:
    14px 0 0;

  color: var(--muted);
  font-size: 0.68rem;
}

.criteria-grid {
  display: grid;

  grid-template-columns:
    repeat(
      2,
      minmax(220px, 320px)
    );

  gap: 16px;
}

.criteria-grid label {
  font-weight: 650;
}

.number-unit {
  display: grid;

  grid-template-columns:
    1fr auto;

  align-items: center;

  gap: 8px;

  margin-top: 6px;
}

.number-unit span {
  color: var(--muted);
}

.rule-info {
  margin-top: 14px;

  padding: 12px;

  color: #cbd5e1;
  background: #0f172a;

  border:
    1px solid
    var(--border);

  border-radius: 9px;

  font-size: 0.84rem;
  line-height: 1.5;
}

.table-scroll {
  overflow-x: auto;
}

.result-table {
  width: 100%;

  min-width: 850px;

  border-collapse: collapse;

  font-variant-numeric:
    tabular-nums;
}

.result-table th {
  padding:
    10px 9px;

  color: var(--muted);

  border-bottom:
    1px solid
    #3a4659;

  text-align: left;

  font-size: 0.75rem;
}

.result-table td {
  padding:
    9px;

  border-bottom:
    1px solid
    rgba(
      255,
      255,
      255,
      0.07
    );
}

.result-row {
  cursor: pointer;
}

.result-row:hover {
  background:
    rgba(
      86,
      180,
      233,
      0.07
    );
}

.result-row:focus-visible { outline: 2px solid #f0bc65; outline-offset: -2px; }
.result-row.is-selected { background: #243a59; box-shadow: inset 4px 0 #f0bc65; }
.result-row.is-selected td:first-child::before { content: '▶ '; color: #f0bc65; font-weight: 700; }
.astro-event-section { margin: 18px 0; }
.astro-event-section h3 { margin: 0 0 12px; font-size: 1.05rem; }
.astro-event-section .details-grid { grid-template-columns: repeat(auto-fit,minmax(150px,1fr)); }
.astro-event-note { color: #cbd8e8; font-size: .87rem; line-height: 1.45; margin: 10px 0 0; }
.night-analysis {min-width:0;grid-template-columns:minmax(0,1fr);}
.night-analysis > .analysis-section {min-width:0;}

.empty-table {
  padding: 24px !important;

  color: var(--muted);

  text-align: center !important;
}

.window-bar {
  position: relative;

  width: 155px;
  max-width: 100%;

  min-height: 30px;

  display: flex;

  align-items: center;
  justify-content: center;

  overflow: hidden;

  color: #fff;
  background: var(--gray);

  border:
    1px solid
    rgba(
      255,
      255,
      255,
      0.18
    );

  border-radius: 7px;

  font-weight: 750;

  text-shadow:
    0 1px 2px
    rgba(
      0,
      0,
      0,
      0.95
    );
}

.window-fill {
  position: absolute;

  inset:
    0 auto 0 0;

  width:
    var(
      --window-percent,
      0%
    );

  background:
    repeating-linear-gradient(
      135deg,
      rgba(
        255,
        255,
        255,
        0.24
      ) 0,
      rgba(
        255,
        255,
        255,
        0.24
      ) 3px,
      transparent 3px,
      transparent 7px
    ),
    var(--usable);
}

.window-text {
  position: relative;
  z-index: 2;
}

.details-grid {
  display: grid;

  grid-template-columns:
    repeat(
      4,
      minmax(140px, 1fr)
    );

  gap: 10px;
}

.detail-wide {
  grid-column:
    1 / -1;
}

.detail-intervals {
  line-height: 1.5;

  font-variant-numeric:
    tabular-nums;
}

.error {
  color: var(--danger);
}

@media (max-width: 900px) {

  .context-grid {
    grid-template-columns:
      repeat(
        2,
        1fr
      );
  }

  .object-grid {
    grid-template-columns: 1fr;
  }

  .custom-grid {
    grid-template-columns:
      1fr 1fr;
  }

  .details-grid {
    grid-template-columns:
      repeat(
        2,
        1fr
      );
  }

}

@media (max-width: 600px) {

  main {
    padding-left: 8px;
    padding-right: 8px;
  }

  .panel {
    padding: 12px;

    border-radius: 10px;
  }

  .app-header {
    align-items: flex-start;
  }

  .header-right {
    flex-direction: column-reverse;
    align-items: flex-end;

    gap: 5px;
  }

  .section-head {
    flex-direction: column;
  }

  .section-actions {
    width: 100%;

    flex-wrap: wrap;
  }

  .context-grid {
    grid-template-columns:
      1fr 1fr;
  }

  .criteria-grid {
    grid-template-columns: 1fr;
  }

  .custom-grid {
    grid-template-columns: 1fr;
  }

  .details-grid {
    grid-template-columns:
      1fr 1fr;
  }

}


/* =========================================================
   Verbesserte Zielauswahl v0.1.1
   ========================================================= */

.selected-object {
  position: relative;
}

.selected-badge {
  display: inline-block;

  margin-bottom: 8px;

  padding:
    3px 8px;

  color: #ffffff;

  background: #0072B2;

  border:
    1px solid
    #56B4E9;

  border-radius: 999px;

  font-size: 0.72rem;
  font-weight: 800;
}

.search-action {
  display: block;

  margin-top: 5px;

  color: #8ecdf0;

  font-size: 0.72rem;
  font-weight: 700;
}

.calculation-hint {
  margin-top: 14px;

  padding: 11px 12px;

  color: #cbd5e1;

  background:
    rgba(
      0,
      114,
      178,
      0.10
    );

  border:
    1px solid
    rgba(
      86,
      180,
      233,
      0.32
    );

  border-radius: 9px;

  font-size: 0.82rem;
  line-height: 1.45;
}


/* =========================================================
   Einheitliche Astro-Navigation v0.3.0
   ========================================================= */

.back-link {
  display: inline-flex;
  align-items: center;

  min-height: 36px;

  padding:
    6px 11px;

  color: #eef2f7;

  background: #1f2937;

  border:
    1px solid
    #3a4659;

  border-radius: 9px;

  text-decoration: none;

  font-size: 0.82rem;
}

.back-link:hover {
  color: #ffffff;

  background: #273449;

  border-color: #56B4E9;
}


/* =========================================================
   Einheitliche Astro-Navigation v0.4.0
   ========================================================= */

.header-nav-link {
  display: inline-flex;
  align-items: center;

  min-height: 36px;

  padding:
    6px 11px;

  color: #eef2f7;
  background: #1f2937;

  border:
    1px solid
    #3a4659;

  border-radius: 9px;

  text-decoration: none;

  font-size: 0.82rem;
}

.header-nav-link:hover {
  color: #ffffff;

  background: #273449;

  border-color: #56B4E9;
}


/* =========================================================
   Grafische Nachtanalyse v0.5.0
   ========================================================= */

.night-analysis {
  margin-top: 14px;

  display: grid;
  gap: 14px;
}

.analysis-section {
  padding: 14px;

  background: #0f172a;

  border:
    1px solid
    var(--border);

  border-radius: 11px;
}

.analysis-title {
  margin-bottom: 10px;

  font-weight: 750;
  font-size: 0.95rem;
}

.analysis-subtitle {
  margin-top: -5px;
  margin-bottom: 10px;

  color: var(--muted);
  font-size: 0.73rem;
}


/* ---------- Zeitachse ---------- */

.timeline {
  display: grid;
  gap: 8px;
}

.timeline-row {
  display: grid;

  grid-template-columns:
    105px 1fr;

  align-items: center;

  gap: 9px;
}

.timeline-label {
  color: #cbd5e1;

  font-size: 0.74rem;
  font-weight: 650;

  text-align: right;
}

.timeline-track {
  position: relative;

  height: 24px;

  overflow: hidden;

  background: #273244;

  border:
    1px solid
    #39475b;

  border-radius: 7px;
}

.timeline-segment {
  position: absolute;

  top: 0;
  bottom: 0;

  min-width: 2px;
}


/* Farbe + Muster, damit Farbe nicht allein informiert */

.segment-dark {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(255,255,255,0.16) 0,
      rgba(255,255,255,0.16) 3px,
      transparent 3px,
      transparent 8px
    ),
    #5d6675;
}

.segment-target {
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255,255,255,0.18) 0,
      rgba(255,255,255,0.18) 2px,
      transparent 2px,
      transparent 8px
    ),
    #0072B2;
}

.segment-moon {
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255,255,255,0.18) 0,
      rgba(255,255,255,0.18) 3px,
      transparent 3px,
      transparent 8px
    ),
    #CC79A7;
}

.segment-usable {
  background:
    repeating-linear-gradient(
      135deg,
      rgba(255,255,255,0.28) 0,
      rgba(255,255,255,0.28) 3px,
      transparent 3px,
      transparent 7px
    ),
    #009E73;
}

.timeline-axis {
  display: flex;

  justify-content: space-between;

  padding-left: 114px;

  margin-top: -2px;

  color: var(--muted);

  font-size: 0.68rem;

  font-variant-numeric:
    tabular-nums;
}


/* ---------- Kurven ---------- */

.analysis-chart-wrap {
  width: 100%;

  overflow-x: auto;
}

.analysis-svg {
  display: block;

  width: 100%;
  min-width: 650px;

  height: 250px;

  background: #0b1322;

  border:
    1px solid
    #2c394c;

  border-radius: 9px;
}

.chart-grid-line {
  stroke: #2e3a4d;
  stroke-width: 1;
}

.chart-axis-text {
  fill: #9ca3af;

  font-size: 11px;

  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
}

.chart-object-line {
  fill: none;

  stroke: #56B4E9;

  stroke-width: 3;

  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-moon-line {
  fill: none;

  stroke: #CC79A7;

  stroke-width: 3;

  stroke-dasharray: 8 5;

  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-threshold {
  stroke: #E69F00;

  stroke-width: 2;

  stroke-dasharray: 4 5;
}

.chart-legend {
  display: flex;

  flex-wrap: wrap;

  gap: 8px 18px;

  margin-top: 8px;

  color: #cbd5e1;

  font-size: 0.72rem;
}

.chart-key {
  display: inline-flex;

  align-items: center;

  gap: 6px;
}

.chart-line-sample {
  width: 24px;

  border-top:
    3px solid
    #56B4E9;
}

.chart-line-sample.moon {
  border-color: #CC79A7;

  border-top-style: dashed;
}

.chart-line-sample.threshold {
  border-color: #E69F00;

  border-top-style: dashed;

  border-top-width: 2px;
}


/* ---------- Kennzahlen ---------- */

.analysis-stats {
  display: grid;

  grid-template-columns:
    repeat(
      4,
      minmax(130px, 1fr)
    );

  gap: 8px;
}

.analysis-stat {
  padding: 10px;

  background: #172033;

  border:
    1px solid
    #293548;

  border-radius: 9px;
}

.analysis-stat-label {
  color: var(--muted);

  font-size: 0.69rem;
}

.analysis-stat-value {
  margin-top: 3px;

  font-size: 0.92rem;
  font-weight: 750;
}


@media (max-width: 750px) {

  .timeline-row {
    grid-template-columns:
      82px 1fr;
  }

  .timeline-label {
    font-size: 0.68rem;
  }

  .timeline-axis {
    padding-left: 91px;
  }

  .analysis-stats {
    grid-template-columns:
      1fr 1fr;
  }

}

/* Compact planner controls; keep charts and result tables at their readable size. */
.app-header{padding:14px 16px 8px}
main{padding-top:6px}
.panel{padding:14px;margin-bottom:12px}
.panel h2{margin-bottom:8px}
.planner-nav{display:flex;align-items:center;gap:6px;flex-wrap:wrap}
.header-right{gap:10px}
.planning-panel{max-width:1000px}
.planning-panel .section-description{margin:0 0 8px}
.context-grid{grid-template-columns:repeat(4,minmax(0,1fr));gap:6px}
.context-card,.detail-card{padding:8px 10px}
.card-label,.detail-label{margin-bottom:2px}
.card-subvalue{margin-top:2px;color:#cbd5e1;font-size:.83rem;font-weight:600}
.object-grid{gap:10px}
.object-column{gap:4px}
.selected-object{margin-top:10px;padding:10px}
.custom-object{margin-top:8px;padding:8px 10px}
.catalog-credit{margin-top:8px}
.criteria-grid{gap:10px}
.number-unit{margin-top:4px}
.criteria-panel .capture-help:empty{display:none}
.criteria-panel .capture-help:not(:empty){margin:0 0 8px}
.rule-info{margin-top:9px;padding:8px 10px}
.rule-info summary{cursor:pointer;color:#a9d3ff}
.rule-info p{margin:6px 0 0}
.big-button{margin-top:10px}
.details-grid{grid-template-columns:repeat(5,minmax(0,1fr));gap:7px}
@media(max-width:900px){.context-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.details-grid{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:600px){
  .app-header{flex-wrap:wrap;gap:6px;padding:10px 12px 6px}
  .subtitle{display:none}
  .header-right{width:100%;flex-direction:row;align-items:center;justify-content:space-between;gap:8px}
  .header-right .version{margin-left:auto}
  .panel{padding:10px;margin-bottom:10px}
  .context-grid{gap:6px}
  .context-card,.detail-card{padding:7px 8px}
  .details-grid{grid-template-columns:repeat(2,minmax(0,1fr));gap:6px}
}

/* Die Nächteübersicht bleibt gut anklickbar, benötigt aber weniger Höhe. */
.result-table th{padding:7px 8px}
.result-table td{padding:4px 8px;line-height:1.3}
.result-table .window-bar{min-height:26px}


/* =========================================================
   Einheitliche Zeitachse v0.5.1
   ========================================================= */

:root {
  --analysis-left: 11.56%;
  --analysis-right: 2%;
}


/*
 * Alle grafischen Nachtbereiche besitzen dieselbe
 * Mindestbreite. Auf kleinen Displays wird horizontal
 * gescrollt.
 */
.analysis-visual-wrap {
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;

  padding-bottom: 3px;
}

.analysis-visual {
  width: 100%;
  min-width: 900px;
}


/* ---------- Zeitfenster ---------- */

.timeline-row {
  display: grid;

  grid-template-columns:
    var(--analysis-left)
    calc(
      100% -
      var(--analysis-left) -
      var(--analysis-right)
    )
    var(--analysis-right);

  gap: 0;

  align-items: center;
}

.timeline-label {
  padding-right: 9px;

  color: #cbd5e1;

  font-size: 0.74rem;
  font-weight: 650;

  text-align: right;
}

.timeline-track {
  position: relative;

  grid-column: 2;

  height: 28px;

  overflow: visible;

  background: #273244;

  border:
    1px solid
    #39475b;

  border-radius: 7px;
}


/*
 * Senkrechte Zeitrasterlinie.
 * Sie liegt unter den farbigen Segmenten.
 */
.timeline-time-grid {
  position: absolute;

  top: 0;
  bottom: 0;

  width: 1px;

  z-index: 1;

  background:
    rgba(
      203,
      213,
      225,
      0.14
    );

  pointer-events: none;
}

.timeline-time-grid.boundary {
  background:
    rgba(
      203,
      213,
      225,
      0.24
    );
}


.timeline-segment {
  z-index: 2;
}


/*
 * Text innerhalb eines ausreichend breiten
 * nutzbaren Segments.
 */
.usable-segment-label {
  position: absolute;

  inset: 0;

  z-index: 3;

  display: flex;

  align-items: center;
  justify-content: center;

  padding:
    0 5px;

  color: #ffffff;

  white-space: nowrap;

  overflow: hidden;

  font-size: 0.70rem;
  font-weight: 750;

  font-variant-numeric:
    tabular-nums;

  text-shadow:
    0 1px 2px
    rgba(
      0,
      0,
      0,
      0.95
    );

  pointer-events: none;
}


/* ---------- intelligente Zeitachse ---------- */

.timeline-axis-smart {
  position: relative;

  height: 29px;

  margin-left:
    var(--analysis-left);

  margin-right:
    var(--analysis-right);

  margin-top: 3px;

  color: var(--muted);

  font-size: 0.68rem;

  font-variant-numeric:
    tabular-nums;
}

.timeline-axis-tick {
  position: absolute;

  top: 2px;

  transform:
    translateX(-50%);

  white-space: nowrap;
}

.timeline-axis-tick.first {
  transform:
    translateX(0);
}

.timeline-axis-tick.last {
  transform:
    translateX(-100%);
}


/*
 * Kurze Aufnahmefenster, für die Text im Balken
 * zu eng wäre.
 */
.short-usable-list {
  display: flex;

  flex-wrap: wrap;

  gap: 6px;

  margin:
    3px
    var(--analysis-right)
    0
    var(--analysis-left);
}

.short-usable-chip {
  padding:
    3px 7px;

  color: #e5eef8;

  background:
    rgba(
      0,
      158,
      115,
      0.14
    );

  border:
    1px solid
    rgba(
      0,
      158,
      115,
      0.48
    );

  border-radius: 6px;

  font-size: 0.67rem;

  font-variant-numeric:
    tabular-nums;
}


/* ---------- Kurven ---------- */

.analysis-svg {
  width: 100%;
  min-width: 900px;

  height: auto;

  aspect-ratio:
    900 / 200;

  background: #0b1322;

  border:
    1px solid
    #2c394c;

  border-radius: 9px;
}


/*
 * Die bestehende Mindestbreite wird damit ebenfalls
 * auf die gleiche Breite wie die Timeline gebracht.
 */
.analysis-chart-wrap {
  width: 100%;

  overflow-x: auto;
  overflow-y: hidden;
}


@media (max-width: 750px) {

  /*
   * Auch auf dem Handy bleibt dieselbe Geometrie erhalten.
   * Die Grafik darf horizontal gescrollt werden.
   */
  .timeline-row {
    grid-template-columns:
      var(--analysis-left)
      calc(
        100% -
        var(--analysis-left) -
        var(--analysis-right)
      )
      var(--analysis-right);
  }

  .timeline-label {
    font-size: 0.68rem;
  }

}
