/* 月虹暦 — Moonbow Almanac */

@import url('https://fonts.googleapis.com/css2?family=Shippori+Mincho:wght@500;600;800&family=Zen+Kaku+Gothic+New:wght@400;500;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root {
  --ink: #07090f;
  --night: #0c1020;
  --night-2: #121831;
  --panel: #0e1326;
  --line: #232c4e;
  --moon: #ece7d3;
  --moon-dim: #9aa0b8;
  --moon-faint: #5d6480;
  --gold: #d9b96a;
  --gold-dim: #8a7846;
  --hit: #7fd4a8;
  --warn: #e08c8c;
  --bow: linear-gradient(90deg, #b07ce0, #6f8fe8, #6fc6c9, #8fd47f, #e8d56f, #e8a05f, #e0707c);
  --serif: 'Shippori Mincho', 'Hiragino Mincho ProN', serif;
  --sans: 'Zen Kaku Gothic New', 'Hiragino Kaku Gothic ProN', sans-serif;
  --mono: 'IBM Plex Mono', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background:
    radial-gradient(1200px 600px at 80% -10%, #1a2245 0%, transparent 60%),
    radial-gradient(900px 500px at -10% 30%, #131a38 0%, transparent 55%),
    var(--ink);
  color: var(--moon);
  font-size: 14px;
  line-height: 1.6;
}

/* ---------- 全体レイアウト ---------- */
.app {
  display: grid;
  grid-template-rows: auto 1fr;
  height: 100vh;
  height: 100dvh;
}

header.masthead {
  display: flex;
  align-items: baseline;
  gap: 16px;
  padding: 14px 22px 10px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
header.masthead::after {
  content: '';
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 1px;
  background: var(--bow);
  opacity: .55;
}
.masthead h1 {
  font-family: var(--serif);
  font-weight: 800;
  font-size: 26px;
  letter-spacing: .14em;
  color: var(--moon);
}
.masthead h1 .moon-mark { color: var(--gold); }
.masthead .romaji {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: .3em;
  color: var(--moon-faint);
  text-transform: uppercase;
}
.masthead .tagline {
  margin-left: auto;
  font-size: 12px;
  color: var(--moon-dim);
}

.main {
  display: grid;
  grid-template-columns: 400px 1fr;
  min-height: 0;
}

/* ---------- サイドパネル ---------- */
.panel {
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel section { display: flex; flex-direction: column; gap: 10px; }

.panel h2 {
  font-family: var(--serif);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: .18em;
  color: var(--gold);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.panel h2 small {
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: .2em;
  color: var(--moon-faint);
}

label.field {
  display: grid;
  grid-template-columns: 7.5em 1fr;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--moon-dim);
}
label.field > span { white-space: nowrap; }

input, select, button {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--moon);
  background: var(--night);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  width: 100%;
}
input[type="number"], input[type="date"] { font-family: var(--mono); font-size: 12px; }
input:focus, select:focus { outline: none; border-color: var(--gold-dim); }

.row { display: flex; gap: 8px; }
.row > * { flex: 1; }

button { cursor: pointer; transition: border-color .15s, background .15s; }
button:hover { border-color: var(--gold-dim); }
button.primary {
  background: linear-gradient(180deg, #2a2410, #1c1808);
  border-color: var(--gold-dim);
  color: var(--gold);
  font-weight: 700;
  letter-spacing: .12em;
  padding: 12px;
  font-size: 15px;
}
button.primary:hover { background: linear-gradient(180deg, #352d12, #23200c); }
button.ghost { font-size: 12px; color: var(--moon-dim); }
button:disabled { opacity: .45; cursor: wait; }

button.pin-btn.active {
  border-color: var(--gold);
  color: var(--gold);
  background: #1c1808;
}

.coords {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--moon-faint);
  line-height: 1.5;
}
.coords b { color: var(--moon-dim); font-weight: 500; }

.geo-readout {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--moon-dim);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px 14px;
}
.geo-readout b { color: var(--gold); font-weight: 500; }

.note { font-size: 11px; color: var(--moon-faint); }
.note.ok { color: var(--hit); }
.note.warn { color: var(--warn); }

details.advanced summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--moon-faint);
  letter-spacing: .08em;
}
details.advanced[open] summary { color: var(--moon-dim); margin-bottom: 8px; }
details.advanced .fields { display: flex; flex-direction: column; gap: 8px; }

/* 進捗 */
.progress { display: none; flex-direction: column; gap: 6px; }
.progress.on { display: flex; }
.progress .bar {
  height: 4px;
  background: var(--night);
  border-radius: 2px;
  overflow: hidden;
}
.progress .bar i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--bow);
  transition: width .12s linear;
}
.progress .pct { font-family: var(--mono); font-size: 11px; color: var(--moon-faint); }

/* ---------- 結果 ---------- */
.results { display: flex; flex-direction: column; gap: 12px; }

.summary {
  font-family: var(--serif);
  font-size: 13px;
  color: var(--moon-dim);
  letter-spacing: .04em;
}
.summary b { color: var(--gold); font-size: 16px; }

.next-chance {
  border: 1px solid var(--gold-dim);
  border-radius: 10px;
  padding: 10px 14px;
  background: linear-gradient(180deg, #181508, #100e08);
  font-size: 12.5px;
}
.next-chance .nc-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: .3em;
  color: var(--gold-dim);
}
.next-chance .nc-date {
  font-family: var(--serif);
  font-size: 17px;
  color: var(--gold);
  letter-spacing: .06em;
}

.night-card {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--night-2);
  overflow: hidden;
}
.night-card .nc-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  background: rgba(0,0,0,.18);
}
.night-card .nc-head .date {
  font-family: var(--serif);
  font-weight: 600;
  font-size: 14.5px;
  letter-spacing: .05em;
}
.night-card .nc-head .dow { color: var(--moon-faint); font-size: 11px; }
.night-card .nc-head .fm {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--moon-dim);
  white-space: nowrap;
}
.night-card .nc-head svg.phase { flex: none; }

.win {
  padding: 9px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background .15s, border-color .15s;
}
.win + .win { border-top: 1px dashed var(--line); }
.win:hover { background: rgba(217,185,106,.05); }
.win.selected { border-left-color: var(--gold); background: rgba(217,185,106,.08); }

.win .time {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--moon);
}
.win .time .dur { font-size: 11px; color: var(--moon-faint); }
.win .stars { color: var(--gold); letter-spacing: .15em; font-size: 11px; }
.win .meta {
  font-size: 11px;
  color: var(--moon-dim);
  display: flex;
  flex-wrap: wrap;
  gap: 4px 12px;
}
.win .meta .pos { color: var(--hit); }

.empty {
  text-align: center;
  color: var(--moon-faint);
  font-size: 12.5px;
  padding: 24px 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
  line-height: 2;
}

/* ---------- 地図 ---------- */
.map-wrap { position: relative; min-height: 0; }
#map { position: absolute; inset: 0; background: #0a0d18; }

.map-hint {
  position: absolute;
  z-index: 1000;
  top: 10px; left: 50%;
  transform: translateX(-50%);
  background: rgba(12,16,32,.92);
  border: 1px solid var(--gold-dim);
  color: var(--gold);
  border-radius: 999px;
  font-size: 12px;
  padding: 5px 16px;
  pointer-events: none;
  display: none;
}
.map-hint.on { display: block; }

.map-legend {
  position: absolute;
  z-index: 1000;
  bottom: 14px; left: 12px;
  background: rgba(12,16,32,.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 11px;
  color: var(--moon-dim);
  line-height: 1.9;
  display: none;
}
.map-legend.on { display: block; }
.map-legend .sw { display: inline-block; width: 18px; height: 3px; border-radius: 2px; vertical-align: middle; margin-right: 6px; }

/* Leafletの夜間調整 */
.leaflet-container { font-family: var(--sans); }
.leaflet-control-layers, .leaflet-control-zoom a {
  background: var(--night-2) !important;
  color: var(--moon) !important;
  border-color: var(--line) !important;
}
.leaflet-control-layers label { color: var(--moon); }
.leaflet-control-attribution {
  background: rgba(7,9,15,.7) !important;
  color: var(--moon-faint) !important;
  font-size: 9px !important;
}
.leaflet-control-attribution a { color: var(--moon-dim) !important; }

.pin-label {
  background: transparent;
  border: none;
  box-shadow: none;
}
.pin-label .pin {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 50% 50% 50% 4px;
  transform: rotate(-45deg);
  border: 2px solid;
  font-size: 15px;
  background: rgba(10,13,24,.88);
}
.pin-label .pin > span { transform: rotate(45deg); }
.pin-label .pin.falls { border-color: #6fc6c9; }
.pin-label .pin.cam { border-color: var(--gold); }

/* ---------- レスポンシブ ---------- */
@media (max-width: 860px) {
  .main { grid-template-columns: 1fr; grid-template-rows: 46vh 1fr; }
  .map-wrap { order: -1; }
  .panel { border-right: none; border-top: 1px solid var(--line); }
  .masthead .tagline { display: none; }
}

::-webkit-scrollbar { width: 9px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 5px; }
::-webkit-scrollbar-track { background: transparent; }
