:root {
  --bg: #05070d;
  --panel: #0d1220;
  --line: #1d2437;
  --fg: #c8d2e8;
  --dim: #7c88a3;
  --accent: #6ea8ff;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg); color: var(--fg);
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
body { display: flex; flex-direction: column; min-height: 100%; }

/* ---- 共通ヘッダ・フッター ---- */

#site-header {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 14px;
  padding: 0 12px; height: 40px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
#site-header .brand {
  font-weight: 700; font-size: 15px; color: var(--fg); text-decoration: none;
  letter-spacing: 0.04em;
}
#site-header nav { display: flex; gap: 12px; }
#site-header nav a {
  color: var(--dim); text-decoration: none; font-size: 13px;
  padding: 4px 2px; border-bottom: 2px solid transparent;
}
#site-header nav a:hover { color: var(--fg); }
#site-header nav a.active { color: var(--fg); border-bottom-color: var(--accent); }

#site-footer {
  flex: 0 0 auto;
  padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
  background: var(--bg); border-top: 1px solid var(--line);
  color: var(--dim); font-size: 11px; line-height: 1.6;
}
#site-footer a { color: var(--dim); }

/* 早見盤のページは盤面を最優先にするので、フッターは一行に抑える */
.sky-page #site-footer { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---- 文書ページ ---- */

.doc {
  flex: 1 1 auto;
  max-width: 760px; width: 100%; margin: 0 auto; padding: 24px 16px 40px;
  line-height: 1.8;
}
.doc h1 { font-size: 22px; margin: 0 0 20px; }
.doc h2 { font-size: 16px; margin: 32px 0 10px; color: #dbe4f7; }
.doc p, .doc li { color: var(--fg); font-size: 14px; }
.doc a { color: var(--accent); }
.doc code { background: #131b30; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.doc table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: 13px; }
.doc th, .doc td {
  border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top;
}
.doc th { background: var(--panel); color: var(--dim); font-weight: 600; }
.doc pre {
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  padding: 12px; overflow-x: auto; font-size: 11px; line-height: 1.5; color: var(--dim);
}

#sky-wrap {
  flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 8px;
}
#sky { display: block; touch-action: manipulation; }
#panel {
  flex: 0 0 auto;
  background: var(--panel);
  border-top: 1px solid var(--line);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  font-size: 13px;
}
.row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.row:last-child { margin-bottom: 0; }
.info { color: var(--dim); font-variant-numeric: tabular-nums; }
.grow { flex: 1 1 auto; }

button, select, input[type="date"], input[type="number"] {
  background: #17203a; color: var(--fg);
  border: 1px solid var(--line); border-radius: 6px;
  padding: 6px 9px; font: inherit; font-size: 13px;
  min-height: 34px;
}
button { cursor: pointer; }
button:hover { background: #1e2a4b; }
button:active { background: #27365e; }
button.primary { background: #23407a; border-color: #35589c; color: #e6eeff; }
button.on { background: #23407a; border-color: #35589c; }
#now { font-weight: 600; }
#clock { font-size: 15px; color: var(--fg); }
input[type="range"] { flex: 1 1 140px; min-width: 120px; accent-color: var(--accent); }
input[type="number"] { width: 88px; }

.toggles { display: flex; flex-wrap: wrap; gap: 6px; }
.toggles label {
  display: inline-flex; align-items: center; gap: 5px;
  background: #131b30; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; cursor: pointer; user-select: none;
  color: var(--dim); font-size: 12px;
}
.toggles input { accent-color: var(--accent); margin: 0; }
.toggles label:has(input:checked) { color: var(--fg); border-color: #35589c; background: #17233f; }

details summary { color: var(--dim); cursor: pointer; font-size: 12px; padding: 2px 0; }
details[open] summary { margin-bottom: 6px; }

#popup {
  position: fixed; display: none; z-index: 10;
  background: rgba(16,24,44,0.95);
  border: 1px solid #35589c; border-radius: 8px;
  padding: 8px 11px; font-size: 12px; line-height: 1.5;
  color: var(--fg); pointer-events: none;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5);
  white-space: nowrap;
}
#popup b { color: #fff; font-size: 13px; }

/* 赤色ナイトモード: 暗順応を壊さないよう全体を赤単色にして落とす */
body.night { filter: grayscale(1) sepia(1) hue-rotate(-38deg) saturate(5) brightness(0.72); }

/* スマホ (縦持ち): 盤面を目一杯、コントロールは下に詰める */
@media (max-width: 560px) {
  #panel { padding: 8px 8px calc(8px + env(safe-area-inset-bottom)); font-size: 12px; }
  .row { gap: 6px; margin-bottom: 6px; }
  button, select, input[type="date"] { padding: 5px 7px; font-size: 12px; min-height: 32px; }
  .toggles label { padding: 4px 8px; font-size: 11px; }
  #clock { font-size: 14px; }
  #sky-wrap { padding: 4px; }
}

/* ---- 今夜の空 ---- */

.tonight .controls {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 18px;
}
.tonight .controls label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--dim); }
/* [hidden] は display:inline-flex に負けるので明示的に消す */
.tonight .controls label[hidden] { display: none; }
.tonight .controls input[type="number"] { width: 84px; }
.tonight .lead { font-size: 15px; line-height: 1.9; }
.tonight .lead b { color: #fff; }
.tonight table th { width: 42%; font-weight: 500; }
.tonight #planet-table th { width: auto; }
.tonight #planet-table thead th { color: var(--dim); }
.tonight .note { color: var(--dim); font-size: 12px; line-height: 1.7; }
.tonight .moon-row { display: flex; gap: 18px; align-items: flex-start; flex-wrap: wrap; }
.tonight .moon-row table { flex: 1 1 260px; }
#moon-canvas { flex: 0 0 auto; background: #080d18; border-radius: 8px; border: 1px solid var(--line); }

/* ---- 天文現象カレンダー ---- */

.calendar .controls {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; margin-bottom: 18px;
}
.calendar .controls label { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--dim); }
#month-label { font-size: 15px; font-weight: 600; min-width: 8em; text-align: center; }

.event {
  display: flex; gap: 14px;
  border-bottom: 1px solid var(--line); padding: 14px 4px;
}
.event:last-child { border-bottom: none; }
.event .when {
  flex: 0 0 62px; text-align: right;
  font-variant-numeric: tabular-nums; line-height: 1.4;
}
.event .when b { font-size: 15px; color: #fff; display: block; }
.event .when span { font-size: 11px; color: var(--dim); }
.event .what { flex: 1 1 auto; min-width: 0; }
.event .title { font-size: 14px; font-weight: 600; margin-bottom: 3px; }
.event .body { font-size: 13px; color: var(--fg); line-height: 1.7; }
.event .body b { color: #fff; }
.event .link { margin-top: 5px; font-size: 12px; }
.event .link a { color: var(--accent); }
.event .dim { color: var(--dim); }

/* 種類ごとに左の色帯で区別する */
.event { border-left: 3px solid transparent; padding-left: 10px; }
.event.moon { border-left-color: #6d7ba0; }
.event.planet { border-left-color: #d8a657; }
.event.meteor { border-left-color: #57b6d8; }
.event.eclipse { border-left-color: #c85a5a; }
