:root {
  --bg: #070b14;
  --bg2: #0b1220;
  --panel: #101826;
  --panel2: #152033;
  --line: rgba(148, 163, 184, 0.18);
  --text: #e8eef8;
  --muted: #94a3b8;
  --amber: #f5a524;
  --amber-dim: rgba(245, 164, 36, 0.18);
  --cyan: #5eead4;
  --danger: #f87171;
  --radius: 14px;
  --font: "Noto Sans TC", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(245, 164, 36, 0.08), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(94, 234, 212, 0.06), transparent 50%),
    var(--bg);
}

.app {
  min-height: 100%;
  display: grid;
  grid-template-columns: 320px 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "top top"
    "side main"
    "foot foot";
  gap: 0;
}

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(11, 18, 32, 0.92);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 12px; }
.mark {
  width: 36px; height: 36px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--amber-dim); color: var(--amber);
  font-size: 18px; border: 1px solid rgba(245,164,36,0.35);
}
.brand h1 { margin: 0; font-size: 1.15rem; font-weight: 700; letter-spacing: 0.02em; }
.brand .sub { margin: 2px 0 0; color: var(--muted); font-size: 0.78rem; }

.sidebar {
  grid-area: side;
  padding: 14px;
  overflow: auto;
  border-right: 1px solid var(--line);
  background: rgba(11, 18, 32, 0.55);
  max-height: calc(100vh - 110px);
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.card h2 {
  margin: 0 0 8px;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}
.hint { margin: 0 0 10px; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.hint.warn { color: #fbbf24; }

.coords {
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--panel2);
  border: 1px solid var(--line);
  margin-bottom: 10px;
  font-size: 0.85rem;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.field > span { font-size: 0.8rem; color: var(--muted); display: flex; justify-content: space-between; }
.field input[type="date"],
.field input[type="time"] {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 10px;
  font-family: var(--mono);
  font-size: 0.9rem;
}
.field input[type="range"] { width: 100%; accent-color: var(--amber); }

.row { display: flex; align-items: center; }
.gap { gap: 8px; }
.wrap { flex-wrap: wrap; }

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  border-radius: 9px;
  padding: 8px 12px;
  font: 500 0.85rem var(--font);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color .15s, background .15s, color .15s;
}
.btn:hover { border-color: rgba(245,164,36,0.45); color: #fff; }
.btn.ghost { background: transparent; }
.btn.amber { background: var(--amber-dim); border-color: rgba(245,164,36,0.45); color: var(--amber); }
.btn.amber:hover { background: rgba(245,164,36,0.28); }
.btn.block { width: 100%; margin-top: 4px; }

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 5px 10px;
  font: 500 0.78rem var(--font);
  cursor: pointer;
}
.chip:hover, .chip.on { color: var(--text); border-color: rgba(94,234,212,0.45); }
.chip.amber { color: var(--amber); border-color: rgba(245,164,36,0.4); }

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0;
}
.stats > div {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.stats dt { margin: 0; font-size: 0.72rem; color: var(--muted); }
.stats dd { margin: 4px 0 0; font-size: 0.95rem; font-weight: 600; }

.sun-times {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(245,164,36,0.08);
  border: 1px solid rgba(245,164,36,0.2);
  color: var(--amber);
  font-size: 0.82rem;
}

.mono { font-family: var(--mono); }

.workspace {
  grid-area: main;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 14px;
  padding: 14px;
  min-height: 0;
  min-width: 0;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { margin: 0; font-size: 0.95rem; }
.badge {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  white-space: nowrap;
}
.panel-foot { margin: 0; padding: 8px 14px 12px; }

#map {
  flex: 1;
  min-height: 420px;
  background: #0a101c;
}
.leaflet-container { background: #0a101c; font-family: var(--font); }
.leaflet-control-attribution {
  background: rgba(11,18,32,0.85) !important;
  color: var(--muted) !important;
  font-size: 10px !important;
}
.leaflet-control-attribution a { color: var(--cyan) !important; }

.pin-icon {
  background: transparent;
  border: none;
}
.pin-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--amber);
  border: 3px solid #fff;
  box-shadow: 0 0 0 4px rgba(245,164,36,0.35), 0 4px 12px rgba(0,0,0,0.45);
}

.look-wrap {
  position: relative;
  flex: 1;
  min-height: 420px;
  background: #05080f;
}
#lookCanvas {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
#lookCanvas:active { cursor: grabbing; }
.look-guide {
  position: absolute;
  left: 12px; right: 12px; bottom: 12px;
  pointer-events: none;
  text-align: center;
  color: rgba(232,238,248,0.7);
  font-size: 0.8rem;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8);
}

.footer {
  grid-area: foot;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
  background: rgba(11, 18, 32, 0.9);
}
.footer a { color: var(--cyan); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 1fr; }
  #map, .look-wrap { min-height: 360px; }
}
@media (max-width: 820px) {
  .app {
    grid-template-columns: 1fr;
    grid-template-areas:
      "top"
      "main"
      "side"
      "foot";
  }
  .sidebar {
    max-height: none;
    border-right: none;
    border-top: 1px solid var(--line);
  }
}
