:root {
  --bg: #0d1117;
  --panel: #161b22;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #58a6ff;
  --umbra: #ff5c5c;
  --penumbra: #ffd75c;
  --uncertainty: rgba(255, 92, 92, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 13px;
}

body {
  display: grid;
  grid-template-columns: 320px 1fr;
  height: 100dvh;
  overflow: hidden;
}

#sidebar {
  background: var(--panel);
  border-right: 1px solid var(--border);
  padding: 16px;
  overflow-y: auto;
}

#sidebar h1 {
  font-size: 16px;
  margin: 0 0 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mobile-buttons,
#more-backdrop,
.more-header { display: none; }   /* mobile-only constructs */

.control {
  margin-bottom: 18px;
}

.control label {
  display: block;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 6px;
}

.control .row {
  display: flex;
  gap: 6px;
  align-items: center;
}

.control .row > input[type="date"],
.control .row > input[type="number"]#year-input {
  flex: 1;
  min-width: 0;
}

.date-part {
  flex: 0 0 auto;
  padding: 6px 6px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.control .row > button {
  width: auto;
  flex: 0 0 auto;
}

.control .hint,
#date-hint {
  font-size: 11px;
  color: var(--muted);
  margin: 6px 0 0;
  line-height: 1.4;
}
#date-hint { margin: 0 0 14px; }

input, button {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 6px 8px;
  border-radius: 4px;
  font: inherit;
  width: 100%;
}

input[type="range"] {
  padding: 0;
  background: transparent;
  border: none;
  height: 24px;
}

input[type="checkbox"] {
  /* Undo the dark-input styling above so we get a normal native checkbox
     with a visible tick mark and reliable click handling. */
  appearance: auto;
  -webkit-appearance: auto;
  -moz-appearance: auto;
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0 8px 0 0;
  background: none;
  border: 0;
  border-radius: 0;
  flex-shrink: 0;
  cursor: pointer;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  text-transform: none !important;
  letter-spacing: 0 !important;
  color: var(--text) !important;
  font-size: 13px !important;
  cursor: pointer;
  margin-bottom: 0 !important;
}

#time-control {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

#time-display {
  font-size: 11px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex: 0 0 auto;
}

#time-slider {
  flex: 1 1 0;
  width: auto;
  min-width: 0;
}

button {
  cursor: pointer;
  background: #21262d;
}
button:hover { background: #30363d; }

#info {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

footer {
  margin-top: 24px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}
footer a { color: var(--accent); }

main {
  display: grid;
  grid-template-rows: 1.2fr auto 1fr;
  grid-template-columns: 1fr 1fr;
  grid-template-areas:
    "map  map"
    "time time"
    "scene local";
  gap: 0;
  height: 100dvh;
  overflow: hidden;
}

#map-panel    { grid-area: map; }
#time-control { grid-area: time; }
#scene-panel  { grid-area: scene; }
#local-panel  { grid-area: local; }

.panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#map-panel    { border-bottom: 1px solid var(--border); }
#scene-panel  { border-right: 1px solid var(--border); }

.panel > header {
  padding: 6px 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.header-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  cursor: pointer;
  font-size: 11px;
}
.header-toggle input[type="checkbox"] {
  width: 13px;
  height: 13px;
  margin: 0;
}

#map, #scene, #local {
  flex: 1;
  min-height: 0;
  background: #000;
}

#local { position: relative; }
#local svg { width: 100%; height: 100%; display: block; }

#local .alt-inset {
  position: absolute;
  left: 6px;
  top: 10px;
  bottom: 10px;
  width: 18px;
  pointer-events: none;
}
#local .alt-inset .alt-sky,
#local .alt-inset .alt-ground {
  position: absolute;
  left: 0;
  right: 0;
}
#local .alt-inset .alt-horizon {
  position: absolute;
  left: 0;
  right: 0;
  height: 1px;
  background: #dcb070;
}
#local .alt-inset .alt-tick {
  position: absolute;
  left: 0;
  width: 6px;
  height: 1px;
  background: rgba(255, 255, 255, 0.35);
}
#local .alt-inset .alt-marker {
  position: absolute;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  left: 50%;
}
#local .alt-inset .alt-sun  { width: 10px; height: 10px; background: #ffd95c; }
#local .alt-inset .alt-moon { width:  8px; height:  8px; background: #bbb; }
#local .alt-inset .alt-label {
  position: absolute;
  left: calc(100% + 4px);
  font-size: 10px;
  color: #dcb070;
  white-space: nowrap;
}
#local .alt-inset .alt-label.top { color: #aab; top: -2px; }


/* Permanent label next to the moving shadow-center marker. */
.shadow-time-tip {
  background: rgba(13, 17, 23, 0.85);
  color: #fff;
  border: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  padding: 2px 10px;
  border-radius: 3px;
  white-space: nowrap;
  width: auto;
  max-width: none;
}
.shadow-time-tip::before { display: none; }   /* hide the default tooltip arrow */

/* --- mobile / narrow viewport ---
   Sidebar becomes a slim always-visible top bar holding the date controls
   and three icon buttons (Map / 3D+Local / Details). Details opens a modal
   over the panels instead of expanding inline. */
@media (max-width: 760px) {
  body {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: 100dvh;
  }

  #sidebar {
    border-right: none;
    border-bottom: 1px solid var(--border);
    overflow: visible;
    padding: 6px 8px;
  }

  #sidebar h1 { display: none; }
  .control.date-control { margin-bottom: 0; }
  .control.date-control > label { display: none; }
  .date-control .row { gap: 4px; }
  .date-part { padding: 4px 2px; font-size: 12px; }
  #year-input { padding: 4px 6px; }
  #prev-eclipse,
  #next-eclipse {
    flex: 0 0 auto;
    padding: 4px 8px;
  }

  /* Icon buttons (tabs + details) live at the right end of the top-bar row. */
  .mobile-buttons {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 4px;
    flex-shrink: 0;
  }
  .icon-btn {
    width: 32px; height: 32px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    color: var(--muted);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    /* Force text-style (monochrome) presentation of emoji glyphs. */
    font-variant-emoji: text;
  }
  .icon-btn.view-toggle.active {
    color: var(--text);
    border-color: var(--accent);
  }
  /* The original tab-nav strip inside <main> is replaced by the icon
     buttons in the top bar. */
  #tab-nav { display: none; }

  /* "Details" modal: full-screen sheet over the panels. */
  #more-controls {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    z-index: 1001;
    background: var(--panel);
    overflow-y: auto;
    padding: 12px 16px 24px;
  }
  body.more-expanded #more-controls { display: block; }
  body.more-expanded #more-backdrop {
    display: block;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
  }
  body.more-expanded .icon-btn#more-toggle {
    color: var(--text);
    border-color: var(--accent);
  }
  .more-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
  }
  #more-close {
    width: 28px; height: 28px;
    padding: 0;
    font-size: 18px;
    line-height: 1;
  }

  /* Main column: scrubber pinned under the top bar, then the active panel. */
  main {
    display: flex;
    flex-direction: column;
    height: auto;
    min-height: 0;
    overflow: hidden;
  }
  #time-control { flex: 0 0 auto; }
  .panel { flex: 1; min-height: 0; }

  body:not(.show-map)   #map-panel,
  body:not(.show-scene) #scene-panel,
  body:not(.show-local) #local-panel { display: none; }

  /* In mobile flex-column layout the scene/local row stacks vertically, so
     turn the desktop right-border into a bottom-border when the local panel
     is showing beneath it. */
  #scene-panel { border-right: none; }
  body.show-scene.show-local #scene-panel { border-bottom: 1px solid var(--border); }

  .panel > header {
    font-size: 10px;
    padding: 4px 10px;
  }
}

