:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #30363d;
  --text: #c9d1d9;
  --muted: #8b949e;
  --accent: #58a6ff;
  --ok: #3fb950;
  --err: #f85149;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

/* Header condiviso: brand + menu + riepilogo di sessione */
.app-header {
  padding: 0.7rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 1.2rem;
}
.app-nav { display: flex; gap: 0.3rem; flex-wrap: wrap; }
.app-nav a {
  color: var(--text);
  text-decoration: none;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  font-size: 0.9rem;
}
.app-nav a:hover { background: rgba(255, 255, 255, 0.06); }
.app-nav a.active { background: var(--accent); color: #0d1117; font-weight: 600; }
.session-bar {
  flex: 1 1 100%;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-top: 0.2rem;
}
.brand-block { display: flex; flex-direction: column; align-items: center; gap: 0.2rem; flex: 0 0 auto; }
.brand-block .brand-logo { height: 6rem; width: auto; display: block; }
.brand-block .brand-version { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.05em; }
.session-summary {
  flex: 1 1 auto;
  color: var(--muted);
  font-size: 0.82rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.hint { color: var(--muted); font-size: 0.82rem; margin: 0.8rem 0 0; }
.hint a { color: var(--accent); }

main {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.5rem;
  padding: 1.5rem;
  align-items: start;
}
@media (max-width: 800px) { main { grid-template-columns: 1fr; } }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.2rem;
}
.panel h2 { margin: 0 0 1rem; font-size: 1.1rem; }

label { display: block; margin-bottom: 0.8rem; font-size: 0.88rem; color: var(--muted); }
label.check { display: flex; align-items: center; gap: 0.5rem; }

input[type=text], input[type=number], input[type=datetime-local] {
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.45rem 0.6rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.9rem;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 6px;
  margin: 0 0 0.8rem;
  padding: 0.8rem;
}

/* Settori di input: il settore modificato si evidenzia, i fratelli si attenuano.
   Pattern riusabile per ogni gruppo (location, time, …). */
.sector {
  padding: 0.5rem 0.6rem;
  margin-bottom: 0.5rem;
  border: 1px solid transparent;
  border-radius: 6px;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.sector label { margin-bottom: 0; }
.sector.active {
  background: rgba(88, 166, 255, 0.10);
  border-color: rgba(88, 166, 255, 0.45);
}
.sector.inactive { opacity: 0.45; }
.sector-sep {
  text-align: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin: 0.1rem 0 0.3rem;
}

/* Campi datetime per unità: ordine YYYY/MM/DD hh:mm:ss */
.dt-label { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.3rem; }
.dt-row { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
/* ogni gruppo (data | ora) è indivisibile: l'a-capo avviene solo tra i due */
.dt-group { display: inline-flex; align-items: center; gap: 0.2rem; flex-wrap: nowrap; }
.dt-row span { color: var(--muted); }
.dt-row input { margin-top: 0; padding: 0.4rem 0.25rem; text-align: center; }
.dt-row input.dt-y { width: 3.6rem; }
.dt-row input.dt-u { width: 2.4rem; }
/* niente freccine spinner: campi più compatti (restano digitabili) */
.dt-row input[type=number] { -moz-appearance: textfield; appearance: textfield; }
.dt-row input::-webkit-outer-spin-button,
.dt-row input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.dt-row select {
  margin: 0;
  padding: 0.4rem 0.3rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
}

.now-btn {
  width: auto;
  margin-top: 0.2rem;
  padding: 0.35rem 0.9rem;
  background: #3b7dd8;        /* azzurro più tenue/scuro del Compute (--accent) */
  color: #0d1117;
  border: none;
  font-weight: 600;
  font-size: 0.85rem;
}
.now-btn:hover { filter: brightness(1.1); }
legend { color: var(--muted); padding: 0 0.4rem; font-size: 0.85rem; }
.row { display: flex; gap: 0.6rem; }
.row label { flex: 1; margin-bottom: 0; }

button {
  width: 100%;
  padding: 0.6rem;
  background: var(--accent);
  color: #0d1117;
  border: none;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
}
button:hover { filter: brightness(1.1); }
/* Compute idle = output aggiornato (attenuato); senza .idle = armato (accent pieno) */
#compute { transition: background 0.15s, color 0.15s; }
#compute.idle { background: #2b3340; color: var(--muted); }

.status { margin-top: 0.7rem; font-size: 0.85rem; min-height: 1.2em; }
.status.busy { color: var(--accent); }
.status.ok   { color: var(--ok); }
.status.error{ color: var(--err); }

.empty { color: var(--muted); }

/* commento sul tipo di calendario (~proleptic gregorian calendar~ ecc.): arancione, salta all'occhio */
.cal-comment { color: #e08a3c; }

.result-section { margin-bottom: 1.5rem; }
.result-section h3 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.3rem;
}

.obs-name {
  font-size: 0.98rem;
  font-weight: 600;
  color: #d2a8ff;            /* viola tenue: nome località trovata */
  margin-bottom: 0.5rem;
}
.obs-name.not-found {
  color: #d29922;            /* ambra: località non trovata (default) */
  font-weight: 500;
  font-style: italic;
}

table { border-collapse: collapse; width: 100%; }
td, th { padding: 0.3rem 0.6rem; text-align: left; vertical-align: top; font-size: 0.88rem; }
th { color: var(--muted); font-weight: 500; white-space: nowrap; width: 1%; }
tr:not(:last-child) td, tr:not(:last-child) th { border-bottom: 1px solid #21262d; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* tabelle annidate (es. coordinate → ra/dec) senza bordi pesanti */
td table { background: rgba(255,255,255,0.02); border-radius: 4px; }
td table th { color: #6e7681; }

/* Coordinate: un blocco per frame, simboli greci come etichette */
.coord-frame { margin-bottom: 0.8rem; }
.coord-frame:last-child { margin-bottom: 0; }
.coord-title { color: var(--muted); font-size: 0.82rem; margin-bottom: 0.2rem; }
.coord-frame th { font-style: italic; color: var(--text); width: 1.6rem; text-align: center; }

/* ── Sky map ──────────────────────────────────────────────── */
/* La sfera è l'elemento principale: barra di controlli in alto, SVG a tutta
   larghezza (override del layout a due colonne; meglio anche su tablet/telefono). */
.skymap-main { display: block; padding: 1rem 1.5rem 1.5rem; }
.skymap-bar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 1.2rem; margin-bottom: 0.8rem;
}
.skymap-svg {
  display: block;
  width: 100%;
  height: auto;
  max-width: min(760px, 92vmin);   /* resta quadrato e non sfora in altezza */
  margin: 0 auto;
  background: transparent;          /* il disco interno è illuminato via radialGradient SVG */
}
/* gruppo di toggle orientamento (Top: N/S — View: inside/outside) */
.orient-group { display: flex; align-items: center; gap: 0.4rem; font-size: 0.85rem; color: var(--muted); }
.bar-sep { width: 1px; align-self: stretch; background: var(--border); margin: 0 0.2rem; }

/* cross-pad: esplorazione parallela di tempo (←/→) e latitudine (↑/↓), reset al centro */
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 1.7rem);
  grid-template-rows: repeat(3, 1.7rem);
  gap: 2px;
}
.dpad button {
  width: 100%; height: 100%;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
}
.dpad button:hover { filter: brightness(1.4); }
.dpad-up    { grid-area: 1 / 2; }
.dpad-left  { grid-area: 2 / 1; }
.dpad-reset { grid-area: 2 / 2; border-radius: 50%; color: var(--accent); }
.dpad-right { grid-area: 2 / 3; }
.dpad-down  { grid-area: 3 / 2; }

.step-sel { display: flex; flex-direction: column; gap: 2px; }
.skymap-bar select {
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1rem 0.2rem;
  font-size: 0.78rem;
}
.explore-readout {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.35;
}
.lbl-check { display: flex; align-items: center; gap: 0.25rem; margin: 0; font-size: 0.82rem; }
.lbl-check input { margin: 0; }
.seg { display: inline-flex; border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.seg button {
  width: auto;
  padding: 0.3rem 0.8rem;
  background: var(--bg);
  color: var(--text);
  border: none;
  border-radius: 0;
  font-size: 0.85rem;
  font-weight: 500;
}
.seg button.on { background: var(--accent); color: #0d1117; font-weight: 600; }
.orient-view { color: var(--muted); font-size: 0.82rem; font-style: italic; }
