/* ==========================================================================
   SatPass Tracker
   An observation console: dark night-sky ground, amber for sunlit geometry,
   slate blue for eclipse, and monospaced figures wherever numbers must align.
   ========================================================================== */

:root {
  color-scheme: light;

  --bg: #EFF2F7;
  --bg-grad: radial-gradient(120% 80% at 50% 0%, #FFFFFF 0%, #EFF2F7 55%);
  --surface: #FFFFFF;
  --surface-2: #F5F7FB;
  --surface-3: #E9EDF5;
  --ink: #121926;
  --ink-strong: #060B14;
  --muted: #5A6577;
  --faint: #8A94A6;
  --line: #D6DCE7;
  --line-strong: #BFC8D8;

  --accent: #9A6A0C;          /* sunlit / glint */
  --accent-bright: #C98A18;
  --accent-wash: #FBF0D9;
  --cool: #3B5C8C;            /* eclipse / shadow */
  --cool-wash: #E4EAF4;
  --good: #1E7A56;
  --good-wash: #DDF0E8;
  --warn: #9A5312;
  --warn-wash: #FBEADA;
  --danger: #A32D28;

  --track-lit: #C98A18;
  --track-shadow: #6E80A0;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .05);
  --shadow-md: 0 4px 16px rgba(16, 24, 40, .08), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 18px 48px rgba(16, 24, 40, .18);

  --font-display: "Zen Kaku Gothic New", "Hiragino Sans", "Yu Gothic", sans-serif;
  --font-body: "IBM Plex Sans JP", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --radius: 10px;
  --radius-sm: 6px;
  --gutter: clamp(1rem, 3vw, 2rem);
  --topbar-h: 58px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #080B12;
    --bg-grad: radial-gradient(130% 90% at 50% -10%, #131B2B 0%, #080B12 60%);
    --surface: #10161F;
    --surface-2: #161E2B;
    --surface-3: #1D2735;
    --ink: #E6EBF4;
    --ink-strong: #FFFFFF;
    --muted: #8E9BB0;
    --faint: #67748A;
    --line: #232D3D;
    --line-strong: #334054;

    --accent: #F0B44A;
    --accent-bright: #FFC968;
    --accent-wash: #2C2211;
    --cool: #7FA0CE;
    --cool-wash: #17202E;
    --good: #52BE95;
    --good-wash: #12241D;
    --warn: #E0954C;
    --warn-wash: #291D10;
    --danger: #E5716B;

    --track-lit: #FFC968;
    --track-shadow: #55688A;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, .45);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;

  --bg: #080B12;
  --bg-grad: radial-gradient(130% 90% at 50% -10%, #131B2B 0%, #080B12 60%);
  --surface: #10161F;
  --surface-2: #161E2B;
  --surface-3: #1D2735;
  --ink: #E6EBF4;
  --ink-strong: #FFFFFF;
  --muted: #8E9BB0;
  --faint: #67748A;
  --line: #232D3D;
  --line-strong: #334054;

  --accent: #F0B44A;
  --accent-bright: #FFC968;
  --accent-wash: #2C2211;
  --cool: #7FA0CE;
  --cool-wash: #17202E;
  --good: #52BE95;
  --good-wash: #12241D;
  --warn: #E0954C;
  --warn-wash: #291D10;
  --danger: #E5716B;

  --track-lit: #FFC968;
  --track-shadow: #55688A;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, .45);
  --shadow-lg: 0 24px 60px rgba(0, 0, 0, .6);
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: var(--bg-grad);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  color: var(--ink-strong);
  text-wrap: balance;
  line-height: 1.3;
  margin: 0;
}

a { color: var(--accent); text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent); }
a:hover { text-decoration-color: currentColor; }

:where(button, input, select, textarea, a):focus-visible {
  outline: 2px solid var(--accent-bright);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--surface); padding: .6rem 1rem; border-radius: 0 0 var(--radius) 0;
}
.skip-link:focus { left: 0; }

/* Browsers give figure a 40px side margin by default, which quietly stole a
   fifth of every chart's width. */
figure { margin: 0; }
figcaption { margin: 0; }

/* Any class that sets `display` outranks the browser's own [hidden] rule, so
   the attribute silently stops working - which is how the display-name field
   ended up showing on the sign-in form. Assert it once, for everything. */
[hidden] { display: none !important; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.num  { font-family: var(--font-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }

/* --------------------------------------------------------------------------
   Top bar
   -------------------------------------------------------------------------- */

.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 1320px; margin: 0 auto;
  padding: 0 var(--gutter);
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 1.25rem;
}

.brand {
  display: flex; align-items: center; gap: .6rem;
  color: var(--ink-strong); text-decoration: none;
  font-family: var(--font-display); font-weight: 900;
  font-size: 1.22rem; letter-spacing: .01em; white-space: nowrap;
}
.brand-mark { width: 32px; height: 32px; color: var(--accent); flex: none; }
.brand-thin { font-weight: 500; color: var(--muted); margin-left: .3em; }

.topnav { display: flex; gap: .15rem; margin-left: .5rem; overflow-x: auto; }
.topnav a {
  padding: .4rem .7rem; border-radius: var(--radius-sm);
  color: var(--muted); text-decoration: none; font-size: .88rem; font-weight: 500;
  white-space: nowrap;
}
.topnav a:hover { color: var(--ink); background: var(--surface-2); }
.topnav a[aria-current="page"] {
  color: var(--ink-strong); background: var(--surface-3);
}

.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .5rem; }

.lang-switch {
  display: flex; border: 1px solid var(--line); border-radius: var(--radius-sm);
  overflow: hidden;
}
.lang-btn {
  border: none; background: transparent; color: var(--muted);
  font-family: inherit; font-size: .78rem; font-weight: 600;
  padding: .3rem .55rem; cursor: pointer;
}
.lang-btn[aria-pressed="true"] { background: var(--accent); color: #14100A; }
:root[data-theme="dark"] .lang-btn[aria-pressed="true"] { color: #1A1204; }

.icon-btn, .ghost-btn, .primary-btn, .link-btn {
  font-family: inherit; cursor: pointer; border-radius: var(--radius-sm);
  transition: background-color .15s, border-color .15s, color .15s;
}
.icon-btn {
  border: 1px solid var(--line); background: transparent; color: var(--muted);
  width: 32px; height: 32px; display: grid; place-items: center;
}
.icon-btn:hover { color: var(--ink); border-color: var(--line-strong); }

.ghost-btn {
  border: 1px solid var(--line); background: transparent; color: var(--ink);
  padding: .38rem .8rem; font-size: .85rem; font-weight: 500;
}
.ghost-btn:hover { background: var(--surface-2); border-color: var(--line-strong); }

.primary-btn {
  border: 1px solid transparent; background: var(--accent); color: #16110A;
  padding: .42rem .95rem; font-size: .88rem; font-weight: 600;
}
:root[data-theme="dark"] .primary-btn { color: #1A1204; }
.primary-btn:hover { background: var(--accent-bright); }
.primary-btn:disabled, .ghost-btn:disabled { opacity: .5; cursor: not-allowed; }

.link-btn {
  border: none; background: none; color: var(--accent);
  font-size: .85rem; padding: .3rem 0; text-decoration: underline;
  text-underline-offset: 3px;
}

/* Context bar --------------------------------------------------------------- */

.context-bar {
  max-width: 1320px; margin: 0 auto;
  padding: .45rem var(--gutter) .55rem;
  display: flex; align-items: center; gap: .5rem; flex-wrap: wrap;
  border-top: 1px solid color-mix(in srgb, var(--line) 60%, transparent);
}

.context-chip {
  display: flex; align-items: baseline; gap: .5rem;
  border: 1px solid var(--line); background: var(--surface-2);
  border-radius: 999px; padding: .22rem .8rem;
  font-family: inherit; font-size: .82rem; color: var(--ink); cursor: pointer;
}
.context-chip:hover { border-color: var(--accent); }
.chip-label { color: var(--faint); font-size: .72rem; letter-spacing: .04em; }
.chip-value { font-family: var(--font-mono); font-weight: 500; }
.context-spacer { flex: 1; }
.context-note { color: var(--faint); font-size: .76rem; font-family: var(--font-mono); }

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */

.main {
  flex: 1;
  max-width: 1320px; width: 100%; margin: 0 auto;
  padding: 1.6rem var(--gutter) 3rem;
}

.page-head { margin-bottom: 1.4rem; }
.eyebrow {
  font-size: .72rem; letter-spacing: .16em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin-bottom: .2rem;
}
.page-head h1 { font-size: clamp(1.45rem, 3.5vw, 1.95rem); font-weight: 900; }
/* 62ch holds only ~31 CJK characters, which broke Japanese one-line ledes
   into an awkward short second line. 56em fits a full Japanese sentence;
   text-wrap: balance evens out anything that still wraps. */
.page-head p { color: var(--muted); margin: .35rem 0 0; max-width: 56em; text-wrap: balance; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.card-head {
  display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
  padding: .85rem 1.1rem; border-bottom: 1px solid var(--line);
}
.card-head h2 { font-size: 1rem; font-weight: 700; }
.card-head .spacer { flex: 1; }
.card-body { padding: 1.1rem; }
.card-body.tight { padding: .5rem; }

.grid { display: grid; gap: 1.1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1000px) {
  .grid-side { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
}

.stack { display: flex; flex-direction: column; gap: 1.1rem; }
.row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */

.field-grid {
  display: grid; gap: .8rem;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}
.field { display: flex; flex-direction: column; gap: .25rem; min-width: 0; }
.field-wide { grid-column: 1 / -1; }
.field-label {
  font-size: .74rem; letter-spacing: .05em; color: var(--muted);
  font-weight: 600; text-transform: uppercase;
}

input[type="text"], input[type="number"], input[type="email"],
input[type="password"], input[type="date"], select {
  font-family: var(--font-mono); font-size: .9rem;
  padding: .45rem .6rem;
  background: var(--surface-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  width: 100%; min-width: 0;
}
input:focus, select:focus { border-color: var(--accent); }
select { font-family: var(--font-body); }

.checkbox {
  display: inline-flex; align-items: center; gap: .45rem;
  font-size: .85rem; color: var(--ink); cursor: pointer;
}
.checkbox input { width: auto; accent-color: var(--accent); }

.form-error {
  color: var(--danger); font-size: .85rem; margin: .6rem 0 0;
  padding: .5rem .7rem; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

/* --------------------------------------------------------------------------
   Pass list
   -------------------------------------------------------------------------- */

.pass-list { display: flex; flex-direction: column; }

.pass-row {
  display: grid; align-items: center; gap: .9rem;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  padding: .75rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: none; border-left: none; border-right: none; border-top: none;
  width: 100%; text-align: left; font: inherit; color: inherit; cursor: pointer;
}
.pass-row:last-child { border-bottom: none; }
.pass-row:hover { background: var(--surface-2); }
.pass-row[aria-current="true"] {
  background: var(--accent-wash);
  box-shadow: inset 3px 0 0 var(--accent);
}

.pass-date {
  text-align: center; font-family: var(--font-mono); line-height: 1.25;
}
.pass-date .dow { font-size: .68rem; color: var(--faint); letter-spacing: .08em; }
.pass-date .dm { font-size: 1.02rem; font-weight: 600; color: var(--ink-strong); }

.pass-main { min-width: 0; }
.pass-times {
  display: flex; align-items: baseline; gap: .45rem; flex-wrap: wrap;
  font-family: var(--font-mono); font-variant-numeric: tabular-nums;
}
.pass-times .t-main { font-size: 1.02rem; font-weight: 600; color: var(--ink-strong); }
.pass-times .t-sep { color: var(--faint); }
.pass-times .t-dur { color: var(--muted); font-size: .8rem; }
.pass-meta {
  display: flex; gap: .5rem 1rem; flex-wrap: wrap;
  font-size: .8rem; color: var(--muted); margin-top: .1rem;
}
.pass-meta b { font-family: var(--font-mono); font-weight: 600; color: var(--ink); }

.pass-side { display: flex; align-items: center; gap: .8rem; }

.mag-badge {
  font-family: var(--font-mono); font-weight: 600; font-size: .95rem;
  padding: .12rem .5rem; border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--ink-strong);
  border: 1px solid var(--line);
}
.mag-badge.bright { background: var(--accent-wash); border-color: var(--accent); color: var(--accent); }

.pill {
  display: inline-flex; align-items: center; gap: .3rem;
  font-size: .72rem; font-weight: 600; letter-spacing: .03em;
  padding: .1rem .55rem; border-radius: 999px;
  border: 1px solid transparent; white-space: nowrap;
}
.pill.sunlit  { background: var(--accent-wash); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 40%, transparent); }
.pill.umbra   { background: var(--cool-wash);   color: var(--cool);   border-color: color-mix(in srgb, var(--cool) 40%, transparent); }
.pill.penumbra{ background: var(--warn-wash);   color: var(--warn);   border-color: color-mix(in srgb, var(--warn) 40%, transparent); }
.pill.visible { background: var(--good-wash);   color: var(--good);   border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.pill.daylight{ background: var(--surface-3);   color: var(--muted);  border-color: var(--line); }

.spark { width: 56px; height: 30px; flex: none; }

/* --------------------------------------------------------------------------
   Charts
   -------------------------------------------------------------------------- */

/* The sky chart carries the stars and the whole pass geometry at once, so it
   gets a row of its own rather than competing for width with the plots. */
.chart-layout { display: flex; flex-direction: column; gap: 1.1rem; }

.chart-card.hero { display: flex; flex-direction: column; align-items: center; }
.chart-card.hero > * { width: 100%; max-width: 780px; }
.chart-card.hero svg { max-width: 780px; margin: 0 auto; }

/* Two columns on a desktop width: four plots then land as a tidy 2x2 and each
   gets roughly half the page instead of a third. */
.chart-grid {
  display: grid; gap: .7rem; align-items: start;
  /* min() keeps the track from forcing a column wider than the screen, which
     would otherwise make the whole page scroll sideways on a phone. */
  grid-template-columns: repeat(auto-fit, minmax(min(440px, 100%), 1fr));
}
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .8rem; }
.avail-btn { min-width: 2.4rem; text-align: center; font-family: var(--font-mono); }
.avail-line { font-size: .76rem; line-height: 1.5; white-space: normal; }
.avail-line.yes  { color: var(--good); }
.avail-line.no   { color: var(--danger); }
.avail-line.none { color: var(--faint); }

.suggest-list {
  position: absolute; left: 0; right: 0; z-index: 30;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  max-height: 260px; overflow-y: auto;
}
.suggest-list:empty { display: none; }
.suggest-item {
  display: flex; gap: .6rem; align-items: baseline; width: 100%;
  text-align: left; font: inherit; color: inherit; cursor: pointer;
  background: none; border: none; border-bottom: 1px solid var(--line);
  padding: .45rem .6rem; font-size: .85rem;
}
.suggest-item:last-child { border-bottom: none; }
.suggest-item:hover { background: var(--surface-2); }
.suggest-item .coords {
  margin-left: auto; font-family: var(--font-mono); font-size: .74rem;
  color: var(--muted); white-space: nowrap;
}
.avail-btn.yes { color: var(--good); border-color: var(--good); }
.avail-btn.no  { color: var(--danger); border-color: var(--danger); }

.png-btn {
  font-family: var(--font-mono); font-size: .68rem; font-weight: 600;
  letter-spacing: .06em; padding: .12rem .45rem; flex: none;
}
.chart-card h3 {
  font-size: .78rem; font-weight: 600; letter-spacing: .05em;
  text-transform: uppercase; color: var(--muted); margin-bottom: .35rem;
}
.chart-card svg { display: block; width: 100%; height: auto; }
.chart-note { font-size: .76rem; color: var(--faint); margin: .4rem 0 0; line-height: 1.5; }

.chart-legend { display: flex; gap: .9rem; flex-wrap: wrap; font-size: .75rem; color: var(--muted); margin-top: .4rem; }
.chart-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.swatch { width: 14px; height: 3px; border-radius: 2px; display: inline-block; }

/* SVG primitives */
.axis      { stroke: var(--line-strong); fill: none; stroke-width: 1; }
.gridline  { stroke: var(--line); fill: none; stroke-width: 1; }
.gridline.dashed { stroke-dasharray: 2 4; }
.axis-text { fill: var(--faint); font-family: var(--font-mono); font-size: 10px; }
.axis-title{ fill: var(--muted); font-family: var(--font-body); font-size: 11px; }
.track-lit    { stroke: var(--track-lit); fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.track-shadow { stroke: var(--track-shadow); fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 5 4; }
.marker-start { fill: var(--good); }
.marker-end   { fill: var(--danger); }
.marker-peak  { fill: var(--accent); }
.marker-text  { fill: var(--muted); font-family: var(--font-mono); font-size: 9.5px; }
/* Globe. The Earth keeps a night-sky palette in both themes: a pale ocean
   would bleach out the satellite markers and the terminator. */
:root {
  --globe-ocean: #0D1729;
  --globe-land: #22355A;
  --globe-land-edge: #35507E;
  --globe-graticule: #1C2B49;
  --globe-limb: #3A5182;
  --globe-night: rgba(2, 5, 14, .55);
  --globe-label: #C9D6EE;
}

/* Globe hero: the sphere on one side, a live readout on the other, so the
   card fills a desktop width instead of stranding a circle in whitespace. */
.globe-hero {
  display: grid; gap: 1.4rem; align-items: center;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 860px) {
  .globe-hero { grid-template-columns: minmax(320px, 520px) minmax(0, 1fr); }
}

.globe-wrap { position: relative; display: flex; justify-content: center; }
.globe-canvas {
  width: 100%; max-width: 520px; aspect-ratio: 1 / 1;
  display: block; cursor: grab; touch-action: none;
}

.globe-roster { display: flex; flex-direction: column; }
.globe-roster-row {
  display: grid; align-items: center; gap: .3rem .7rem;
  grid-template-columns: auto minmax(0, 1fr) auto auto auto;
  padding: .38rem .2rem; border-bottom: 1px solid var(--line);
}
.globe-roster-row:last-child { border-bottom: none; }
.globe-roster-row:hover { background: var(--surface-2); }
/* Switched off: dimmed but still readable, so the figures stay available. */
.globe-roster-row.is-off .globe-roster-name,
.globe-roster-row.is-off .globe-roster-values { opacity: .42; }
.globe-roster-row.is-off .pill { opacity: .35; }

.globe-roster-toggle { display: flex; align-items: center; cursor: pointer; }
.globe-roster-toggle input { width: auto; accent-color: var(--accent); margin: 0; }

.globe-roster-name {
  font-weight: 600; color: var(--ink-strong); font-size: .9rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  text-decoration: none;
}
.globe-roster-name:hover { text-decoration: underline; }

.globe-roster-actions {
  display: flex; gap: .9rem; justify-content: flex-end; padding-top: .5rem;
}
.globe-roster-values { font-size: .8rem; color: var(--muted); }
.globe-canvas:active { cursor: grabbing; }
.globe-legend {
  display: flex; gap: .9rem; flex-wrap: wrap; justify-content: center;
  font-size: .74rem; color: var(--muted); margin-top: .5rem;
}
.globe-legend i {
  width: 9px; height: 9px; border-radius: 50%; display: inline-block;
  margin-right: .3rem; vertical-align: -1px;
}

.sky-disc     { fill: color-mix(in srgb, var(--cool) 8%, transparent); stroke: var(--line-strong); }

/* The sky chart works in an 800-unit square while the cartesian plots are much
   smaller, so its strokes and type are sized here rather than sharing the
   defaults - otherwise everything on it renders roughly twice too heavy. */
.sky-chart .track-lit,
.sky-chart .track-shadow { stroke-width: 2.6; }
.sky-chart .track-shadow { stroke-dasharray: 7 6; }
.sky-chart .gridline     { stroke-width: 1; }
.sky-chart .gridline.dashed { stroke-dasharray: 3 6; }
.sky-chart .axis-text    { font-size: 11px; }
.sky-chart .cursor-dot   { r: 5; stroke-width: 2; }

.cardinal-major {
  fill: var(--muted); font-family: var(--font-body); font-size: 15px;
  font-weight: 600;
}
.cardinal-minor {
  fill: var(--faint); font-family: var(--font-body); font-size: 11px;
}

.time-tick  { stroke: var(--ink-strong); stroke-width: 1.6; opacity: .75; }
.time-label {
  fill: var(--ink-strong); font-family: var(--font-mono); font-size: 13px;
  font-weight: 600; paint-order: stroke;
  stroke: var(--surface); stroke-width: 3.5px; stroke-linejoin: round;
}

/* With the star field on, the disc becomes an actual night sky in both themes:
   stars need a dark ground to read at all, so the grid and labels invert with
   it rather than following the page. */
.sky-night .sky-disc  { fill: #0A1120; stroke: #2A3550; }
.sky-night .gridline  { stroke: #1E2942; }
.sky-night .axis-text { fill: #6E7C96; }
.sky-night .cardinal-major { fill: #A9B8D4; }
.sky-night .cardinal-minor { fill: #6E7C96; }
.sky-night .constellation-line {
  stroke: #33486F; fill: none; stroke-width: 0.9; stroke-linecap: round;
}
.sky-night .star      { fill: #EAF0FC; }
.sky-night .star-name {
  fill: #8FA3C6; font-family: var(--font-mono); font-size: 10px;
  paint-order: stroke; stroke: #0A1120; stroke-width: 2.5px;
}
.sky-night .time-tick  { stroke: #FFFFFF; opacity: .85; }
.sky-night .time-label { fill: #FFFFFF; stroke: #0A1120; }
.cursor-dot   { fill: var(--ink-strong); stroke: var(--surface); stroke-width: 1.5; }
.cursor-line  { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 3 3; }

/* Twilight timeline -------------------------------------------------------- */

.twilight { margin-top: .4rem; }
.twilight svg { display: block; width: 100%; height: auto; }
.tw-night  { fill: #0B1220; }
.tw-astro  { fill: #16233C; }
.tw-naut   { fill: #24375C; }
.tw-civil  { fill: #3E5A85; }
.tw-day    { fill: #86A9D6; }
:root[data-theme="dark"] .tw-day { fill: #4E7CB4; }
.tw-label  { fill: var(--faint); font-family: var(--font-mono); font-size: 9.5px; }
.tw-pass   { fill: var(--accent); }

.sun-table { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: .7rem; margin-top: 1rem; }
.sun-item { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: .55rem .7rem; background: var(--surface-2); }
.sun-item .k { font-size: .72rem; color: var(--muted); letter-spacing: .03em; }
.sun-item .v { font-family: var(--font-mono); font-size: 1rem; font-weight: 600; color: var(--ink-strong); }
.sun-item .v.none { color: var(--faint); font-weight: 400; font-size: .85rem; }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); }
table.data { border-collapse: collapse; width: 100%; font-size: .84rem; }
table.data th, table.data td {
  padding: .38rem .6rem; text-align: right; white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.data th {
  position: sticky; top: 0; background: var(--surface-2);
  font-size: .7rem; letter-spacing: .05em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; z-index: 1;
}
table.data th:first-child, table.data td:first-child { text-align: left; }
table.data td { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tr.shadowed td { color: var(--muted); }
table.data tr.shadowed td:first-child { box-shadow: inset 2px 0 0 var(--track-shadow); }

.table-scroll { max-height: 420px; overflow-y: auto; }

/* --------------------------------------------------------------------------
   Search results
   -------------------------------------------------------------------------- */

.result-list { display: flex; flex-direction: column; }
.result-row {
  display: grid; gap: .3rem 1rem; align-items: center;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: .65rem 1.1rem; border-bottom: 1px solid var(--line);
  cursor: pointer; background: none; border-left: 0; border-right: 0; border-top: 0;
  width: 100%; text-align: left; font: inherit; color: inherit;
}
.result-row:last-child { border-bottom: none; }
.result-row:hover { background: var(--surface-2); }
.result-name { font-weight: 600; color: var(--ink-strong); font-size: .95rem; }
.result-name .decayed { color: var(--faint); font-weight: 400; font-size: .8rem; margin-left: .4rem; }
.result-ids {
  display: flex; gap: .8rem; flex-wrap: wrap;
  font-family: var(--font-mono); font-size: .78rem; color: var(--muted);
}
.result-tags { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: flex-end; }

.tag {
  font-size: .68rem; font-weight: 600; letter-spacing: .04em;
  padding: .05rem .45rem; border-radius: var(--radius-sm);
  background: var(--surface-3); color: var(--muted); border: 1px solid var(--line);
}
.tag.pay { color: var(--good); border-color: color-mix(in srgb, var(--good) 35%, transparent); background: var(--good-wash); }
.tag.deb { color: var(--faint); }

/* --------------------------------------------------------------------------
   Detail header, definition lists, misc
   -------------------------------------------------------------------------- */

.detail-head { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; margin-bottom: 1.2rem; }
.detail-head h1 { font-size: clamp(1.4rem, 3.4vw, 1.9rem); }
.detail-ids { display: flex; gap: .9rem; flex-wrap: wrap; font-family: var(--font-mono); font-size: .84rem; color: var(--muted); margin-top: .25rem; }

dl.spec { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .75rem 1.2rem; margin: 0; }
dl.spec div { min-width: 0; }
dl.spec dt { font-size: .72rem; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
dl.spec dd { margin: .1rem 0 0; font-family: var(--font-mono); font-size: .92rem; color: var(--ink-strong); font-variant-numeric: tabular-nums; }

.notice {
  display: flex; gap: .6rem; align-items: flex-start;
  padding: .7rem .9rem; border-radius: var(--radius-sm);
  font-size: .85rem; line-height: 1.55;
  border: 1px solid var(--line); background: var(--surface-2);
}
.notice.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); background: var(--warn-wash); color: var(--warn); }
.notice.info { border-color: color-mix(in srgb, var(--cool) 40%, transparent); background: var(--cool-wash); color: var(--cool); }
.notice strong { font-weight: 700; }

.empty {
  text-align: center; padding: 2.6rem 1.2rem; color: var(--muted);
}
.empty h3 { font-size: 1.02rem; margin-bottom: .35rem; color: var(--ink); }
.empty p { margin: 0 auto; max-width: 46ch; font-size: .9rem; }

.loading { display: flex; align-items: center; gap: .6rem; color: var(--muted); font-size: .88rem; padding: 1.6rem 1.1rem; }
.spinner {
  width: 15px; height: 15px; border-radius: 50%; flex: none;
  border: 2px solid var(--line-strong); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.fav-btn { display: inline-flex; align-items: center; gap: .35rem; }
.fav-btn[aria-pressed="true"] { color: var(--accent); border-color: var(--accent); }

.site-item {
  display: flex; align-items: center; gap: .45rem .7rem; flex-wrap: wrap;
  padding: .55rem .7rem; border: 1px solid var(--line);
  border-radius: var(--radius-sm); background: var(--surface-2); margin-bottom: .4rem;
}
.site-item .checkbox { white-space: nowrap; }
.site-item .name { font-weight: 600; }
.site-item .coords { font-family: var(--font-mono); font-size: .78rem; color: var(--muted); }
.site-item.is-default { border-color: var(--accent); }

.saved-site-list { display: flex; flex-direction: column; margin-bottom: .9rem; }
.saved-site-btn {
  display: flex; gap: .6rem; align-items: baseline; width: 100%; text-align: left;
  font: inherit; color: inherit; cursor: pointer;
  padding: .4rem .6rem; border: 1px solid var(--line); background: var(--surface-2);
  border-radius: var(--radius-sm); margin-bottom: .3rem;
}
.saved-site-btn:hover { border-color: var(--accent); }
.saved-site-btn .coords { font-family: var(--font-mono); font-size: .76rem; color: var(--muted); margin-left: auto; }

/* --------------------------------------------------------------------------
   Dialogs and toasts
   -------------------------------------------------------------------------- */

.dialog {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  padding: 0; max-width: 520px; width: calc(100vw - 2rem);
  box-shadow: var(--shadow-lg);
}
.dialog::backdrop { background: rgba(4, 8, 16, .58); backdrop-filter: blur(3px); }
.dialog-body { padding: 1.3rem; display: flex; flex-direction: column; gap: 1rem; }
.dialog-body h2 { font-size: 1.1rem; font-weight: 700; }
.dialog-hint { font-size: .82rem; color: var(--muted); margin: 0; }
.dialog-actions { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

.toast-stack {
  position: fixed; bottom: 1.2rem; right: 1.2rem; z-index: 60;
  display: flex; flex-direction: column; gap: .5rem; pointer-events: none;
}
.toast {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-md);
  padding: .6rem .9rem; font-size: .86rem; max-width: 340px;
  animation: toast-in .2s ease-out;
}
.toast.error { border-left-color: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* --------------------------------------------------------------------------
   Footer
   -------------------------------------------------------------------------- */

.footer {
  border-top: 1px solid var(--line);
  padding: 1.2rem var(--gutter) 2rem;
  max-width: 1320px; margin: 0 auto; width: 100%;
  color: var(--muted); font-size: .8rem;
}
.footer p { margin: .2rem 0; }
.footer-fine { color: var(--faint); }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 780px) {
  /* Nav and account controls fight for the same row on a phone, so the nav
     drops to a scrollable second row of its own. */
  .topbar-inner {
    height: auto; flex-wrap: wrap; gap: .5rem;
    padding-top: .5rem; padding-bottom: .1rem;
  }
  .brand { font-size: 1.02rem; }
  .brand-mark { width: 26px; height: 26px; }
  .brand-by { font-size: .54rem; }
  .topnav {
    order: 3; width: 100%; margin: 0;
    padding-bottom: .3rem;
    /* Every item stays visible: wrap onto extra rows rather than hiding
       entries behind a horizontal scroll edge. */
    flex-wrap: wrap; overflow-x: visible; row-gap: .1rem;
  }
  .topnav a { padding: .3rem .55rem; font-size: .84rem; }
  .topnav::-webkit-scrollbar { display: none; }
  .lang-btn { padding: .28rem .5rem; white-space: nowrap; font-size: .74rem; }
  .ghost-btn { padding: .34rem .6rem; }

  .context-bar { padding-top: .35rem; padding-bottom: .45rem; }
  .context-note { width: 100%; }

  .pass-row { grid-template-columns: 54px minmax(0, 1fr); gap: .6rem; }
  .pass-side { grid-column: 1 / -1; justify-content: flex-start; padding-left: .1rem; }
  .spark { display: none; }
  table.data { font-size: .78rem; }
  .sun-table { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); }
}

/* -- all-satellite map ---------------------------------------------------- */
.map-toolbar {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: .6rem 1rem; margin-bottom: .6rem;
}
.map-toolbar .field { margin: 0; }
.map-canvas {
  max-width: none; aspect-ratio: auto;
  height: clamp(420px, 66vh, 820px);
  border-radius: 14px;
}
.map-legend {
  display: flex; flex-wrap: wrap; gap: .25rem 1.1rem;
  margin-top: .55rem;
}
.seg {
  display: inline-flex; border: 1px solid var(--line);
  border-radius: 9px; overflow: hidden;
}
.seg button {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: .82rem; padding: .38rem .7rem; cursor: pointer;
}
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--surface-3); color: var(--text); }
.zoom-controls { display: inline-flex; gap: .3rem; }
.zoom-controls button {
  width: 2rem; height: 2rem; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface-2);
  color: var(--text); font-size: 1rem; line-height: 1; cursor: pointer;
}
.zoom-controls button:hover { border-color: var(--accent); }
.map-popup {
  position: absolute; z-index: 5; min-width: 200px; max-width: 280px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 12px; padding: .6rem .75rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, .35);
  font-size: .84rem; pointer-events: auto;
}
.map-popup .name { font-weight: 600; padding-right: 1.4rem; overflow-wrap: anywhere; }
.map-popup .meta { color: var(--muted); font-family: var(--font-mono); font-size: .76rem; margin: .2rem 0 .45rem; }
.map-popup a { font-size: .82rem; }
.map-popup .close {
  position: absolute; top: .3rem; right: .35rem;
  border: 0; background: transparent; color: var(--muted);
  font-size: 1rem; cursor: pointer; padding: .1rem .3rem;
}

.footer-links { margin-top: .45rem; }
.footer-links a { color: var(--muted); }
.footer-links a:hover { color: var(--text); }

/* Name fields: one row of Japanese names, one row of English names. */
.name-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

/* Pass page: globe column tops out; the forecast list runs long beside it. */
.pass-hero { align-items: start; }

.avail-line.maybe { color: var(--warn); }
.avail-btn.maybe { color: var(--warn); border-color: var(--warn); }

/* Search rows inside a dropdown suggestion list sit a little tighter. */
.suggest-list .result-row { padding: .5rem .7rem; }
.suggest-list .result-name { font-size: .88rem; }

/* A shift assignment that contradicts the member's own x answer. */
.tag.against-no {
  color: var(--danger); border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

/* A shift assignment whose member answered "maybe". */
.tag.against-maybe {
  color: var(--warn); border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, transparent);
}

/* The group's watched-satellite list: search-style rows inside the card. */
.sat-list { border: 1px solid var(--line); border-radius: var(--radius-sm); }
.sat-row { grid-template-columns: minmax(0, 1fr) auto auto; padding: .55rem .7rem; cursor: pointer; }

.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-by {
  font-size: .62rem; font-weight: 600; letter-spacing: .08em;
  color: var(--faint); font-family: var(--font-body, inherit);
}

/* Legal pages: phrase-aware Japanese line breaking where the browser has it,
   so names and terms are not split mid-word. */
.legal-body { line-height: 1.85; }
.legal-body p:lang(ja) { word-break: auto-phrase; }

/* An informational (non-error) notice inside the auth dialog. */
.form-error.is-info { color: var(--good); }

/* Member names in the availability lines double as admin edit buttons. */
.avail-name {
  border: none; background: none; padding: 0; font: inherit;
  color: inherit; text-decoration: underline dotted; cursor: pointer;
}
.avail-name:hover { color: var(--accent); }
