:root {
  --green-900: #15291c;
  --green-700: #24503a;
  --green-500: #3c7a55;
  --green-100: #e8f2ec;
  --accent: #ffd166;
  --ink: #15291c;
  --muted: #6b7f73;
  --line: #dfe8e2;
  --glass: rgba(255,255,255,.92);
  --glass-dark: rgba(21,41,28,.78);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: var(--ink); background: #1b2f38; font-family: Manrope, Inter, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; }
#scene { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

header { position: fixed; top: 0; left: 0; right: 0; z-index: 10; display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 14px 30px; background: linear-gradient(rgba(12,24,18,.72), rgba(12,24,18,0)); pointer-events: none; }
header a { flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; color: white; background: var(--glass-dark); border: 1px solid rgba(255,255,255,.22); border-radius: 999px; font-size: 12px; font-weight: 800; text-decoration: none; pointer-events: auto; backdrop-filter: blur(8px); }
header a:hover { background: var(--green-700); }
header h1 { margin: 0; color: white; font-size: 15px; font-weight: 800; letter-spacing: -.01em; text-shadow: 0 1px 8px rgba(0,0,0,.5); }
header h1 small { display: block; margin-top: 2px; font-size: 10.5px; font-weight: 600; opacity: .85; letter-spacing: 0; }

.controls { position: fixed; top: 84px; left: 14px; z-index: 11; display: grid; gap: 6px; }
.controls button { width: 38px; height: 38px; display: grid; place-items: center; padding: 0; color: var(--ink); background: var(--glass); border: 0; border-radius: 10px; box-shadow: 0 2px 10px rgba(0,0,0,.2); font-size: 20px; font-weight: 800; backdrop-filter: blur(8px); }
.controls button:hover { background: var(--green-100); }
.controls svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

#north { position: fixed; top: 86px; right: 16px; z-index: 11; display: grid; justify-items: center; color: white; font-size: 11px; font-weight: 800; transform-origin: center 19px; pointer-events: none; }
#north i { width: 0; height: 0; margin-top: 2px; border-right: 6px solid transparent; border-bottom: 17px solid white; border-left: 6px solid transparent; }
#north.is-replaced { display: none; }

#hint { position: fixed; top: 60px; left: 50%; z-index: 10; margin: 0; padding: 7px 14px; color: white; background: var(--glass-dark); border-radius: 999px; font-size: 11px; font-weight: 700; white-space: nowrap; transform: translateX(-50%); pointer-events: none; backdrop-filter: blur(8px); transition: opacity .8s; }
#hint.is-faded { opacity: 0; }

#selection { position: fixed; right: 14px; bottom: 36px; z-index: 12; width: min(250px, calc(100% - 28px)); padding: 12px 14px; background: var(--glass); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.3); backdrop-filter: blur(10px); }
#selection .eyebrow { margin: 0 0 3px; color: var(--green-500); font-size: 9px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
#selection h2 { margin: 0; font-size: 22px; letter-spacing: -.02em; }
#selection p:last-child { margin: 4px 0 0; color: var(--muted); font-size: 11px; font-weight: 700; }
#close-selection { position: absolute; top: 9px; right: 9px; width: 28px; height: 28px; padding: 0; color: var(--ink); background: var(--green-100); border: 0; border-radius: 8px; font-size: 19px; }

#sources { position: fixed; right: 14px; bottom: 9px; z-index: 10; max-width: min(560px, calc(100% - 340px)); margin: 0; padding: 0; color: rgba(255,255,255,.72); font-size: 9px; line-height: 1.35; text-align: right; text-shadow: 0 1px 3px rgba(0,0,0,.6); pointer-events: none; }
#sources strong, #sources span { display: inline; }
#sources strong::after { content: " · "; }

#loading { position: fixed; inset: 0; z-index: 30; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: white; background: var(--green-900); font-size: 14px; font-weight: 700; transition: opacity .45s; }
#loading.done { display: none; }
#loading .bar { width: 180px; height: 4px; overflow: hidden; background: rgba(255,255,255,.2); border-radius: 2px; }
#loading .bar i { width: 35%; height: 100%; display: block; background: var(--accent); border-radius: 2px; animation: plano-loading 1.1s infinite; }
@keyframes plano-loading { from { transform: translateX(-100%); } to { transform: translateX(520%); } }

/* ---- sun & shadows panel (injected by app.js) ---- */
.sun-panel { position: fixed; left: 14px; bottom: 14px; z-index: 13; width: 312px; max-width: calc(100% - 28px); padding: 9px 12px 12px; color: var(--ink); background: var(--glass); border-radius: 14px; box-shadow: 0 10px 30px rgba(0,0,0,.28); backdrop-filter: blur(10px); transition: background .5s, color .5s; }
.sun-head { display: flex; align-items: center; gap: 8px; }
.sun-eyebrow { font-size: 9px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--green-500); }
.sun-clock { margin-left: auto; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.02em; line-height: 1; }
.sun-toggle { width: 26px; height: 26px; display: grid; place-items: center; padding: 0; color: var(--ink); background: var(--green-100); border: 0; border-radius: 8px; }
.sun-toggle svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; transition: transform .25s; }
.sun-panel.is-collapsed .sun-body { display: none; }
.sun-panel.is-collapsed .sun-toggle svg { transform: rotate(180deg); }
.sun-body { display: grid; gap: 8px; margin-top: 8px; }
.sun-row { display: flex; gap: 5px; flex-wrap: wrap; }
.chip { display: inline-block; padding: 5px 9px; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; font-weight: 700; line-height: 1.1; white-space: nowrap; transition: background .15s, color .15s; }
.chip:hover { background: var(--green-100); }
.chip.is-active { color: white; background: var(--ink); border-color: var(--ink); }
.sun-seasons .chip { flex: 1 1 0; display: grid; gap: 2px; padding: 5px 4px; text-align: center; }
.sun-seasons .chip small { font-size: 9px; font-weight: 600; opacity: .65; }
.sun-time { align-items: center; flex-wrap: nowrap; gap: 8px; }
.sun-play { flex: none; width: 30px; height: 30px; display: grid; place-items: center; padding: 0; color: white; background: var(--ink); border: 0; border-radius: 50%; }
.sun-play svg { width: 14px; height: 14px; fill: currentColor; }
.sun-play .ico-pause { display: none; }
.sun-play.is-playing .ico-pause { display: block; }
.sun-play.is-playing .ico-play { display: none; }
#sun-time { flex: 1; height: 26px; margin: 0; accent-color: var(--ink); }
.sun-presets .chip { padding: 4px 8px; font-size: 10.5px; }
.sun-ui.is-night .sun-panel { color: white; background: rgba(14,22,34,.88); }
.sun-ui.is-night .sun-eyebrow { color: var(--accent); }
.sun-ui.is-night .chip { color: white; background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.16); }
.sun-ui.is-night .chip:hover { background: rgba(255,255,255,.18); }
.sun-ui.is-night .chip.is-active { color: var(--ink); background: var(--accent); border-color: var(--accent); }
.sun-ui.is-night .sun-play { color: var(--ink); background: var(--accent); }
.sun-ui.is-night .sun-toggle { color: white; background: rgba(255,255,255,.12); }
.sun-ui.is-night #sun-time { accent-color: var(--accent); }

.sun-widget { position: fixed; top: 84px; right: 14px; z-index: 11; width: 100px; display: grid; justify-items: center; gap: 4px; pointer-events: none; }
.sun-widget svg { width: 100px; height: 100px; background: var(--glass-dark); border-radius: 50%; box-shadow: 0 4px 14px rgba(0,0,0,.28); backdrop-filter: blur(6px); overflow: visible; }
.sw-horizon { fill: none; stroke: rgba(255,255,255,.6); stroke-width: 1.2; }
.sw-ring { fill: none; stroke: rgba(255,255,255,.18); stroke-width: .8; }
.sw-axis { stroke: rgba(255,255,255,.14); stroke-width: .8; }
.sw-path { fill: none; stroke: var(--accent); stroke-width: 1.7; stroke-linecap: round; opacity: .9; }
.sw-label { fill: white; font-size: 8px; font-weight: 800; text-anchor: middle; dominant-baseline: middle; font-family: inherit; }
.sw-sun { fill: var(--accent); stroke: rgba(255,255,255,.9); stroke-width: 1; filter: drop-shadow(0 0 3px rgba(255,209,102,.95)); }
.sw-moon { fill: #dfe7ff; stroke: rgba(255,255,255,.5); stroke-width: .6; }
.sun-caption { color: white; font-size: 10px; font-weight: 600; line-height: 1.3; text-align: center; text-shadow: 0 1px 4px rgba(0,0,0,.7); }
.sun-caption b { font-weight: 800; }

.plano-legend { position: fixed; top: 226px; right: 14px; z-index: 10; display: grid; gap: 3px; padding: 7px 9px; background: var(--glass); border-radius: 10px; font-size: 10px; font-weight: 700; pointer-events: none; backdrop-filter: blur(8px); }
.plano-legend span { display: flex; align-items: center; gap: 6px; }
.plano-legend i { width: 12px; height: 12px; border: 1px solid rgba(0,0,0,.15); border-radius: 3px; }

.plano-tip { position: absolute; z-index: 14; display: grid; padding: 6px 9px; background: white; border-radius: 8px; box-shadow: 0 4px 16px rgba(0,0,0,.25); font-size: 11px; line-height: 1.25; pointer-events: none; }
.plano-tip b { font-size: 12px; }
.plano-tip span { color: var(--muted); font-weight: 600; }

@media (max-width: 640px) {
  header { padding: 8px 10px 22px; gap: 8px; }
  header a { padding: 7px 10px; font-size: 11px; }
  header h1 { max-width: calc(100vw - 105px); font-size: 12px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  header h1 small { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  #hint { top: 54px; left: 60px; right: 84px; padding: 5px 8px; font-size: 9px; line-height: 1.3; white-space: normal; text-align: center; transform: none; }
  #sources { display: none; }
  #selection { left: 62px; right: 86px; top: 84px; bottom: auto; width: auto; padding: 10px 12px; }
  #selection h2 { font-size: 18px; }
  .sun-panel { left: 10px; right: 10px; bottom: 10px; width: auto; padding: 8px 10px 10px; }
  .sun-body { gap: 6px; }
  .sun-seasons .chip small { display: none; }
  .sun-presets { flex-wrap: nowrap; overflow-x: auto; margin: 0 -10px; padding: 0 10px; scrollbar-width: none; }
  .sun-presets::-webkit-scrollbar { display: none; }
  .sun-presets .chip { flex: none; }
  .sun-widget { width: 66px; top: 72px; right: 10px; }
  .sun-widget svg { width: 66px; height: 66px; }
  .sun-caption { display: none; }
  .plano-legend { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
