* { box-sizing: border-box; }

:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #0b1220;
  --panel: rgba(17, 28, 45, 0.94);
  --panel-2: #152237;
  --line: #293b54;
  --muted: #91a3ba;
  --text: #edf3fb;
  --blue: #67b7ff;
  --orange: #ff8a63;
  --green: #76d2a0;
  --danger: #ff8f91;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 5% 0%, rgba(42, 119, 190, 0.24), transparent 34rem),
    radial-gradient(circle at 100% 18%, rgba(47, 88, 142, 0.12), transparent 28rem),
    var(--bg);
  color: var(--text);
}

button, input { font: inherit; }
button { touch-action: manipulation; }
a { color: #9bd0ff; }

.page-shell {
  width: min(1880px, calc(100% - 28px));
  margin: 0 auto;
  padding: 34px 0 48px;
}

.main-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-top: 32px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--blue);
  font-size: .72rem;
  font-weight: 800;
  letter-spacing: .16em;
}

h1 {
  max-width: 900px;
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: .98;
  letter-spacing: -.05em;
}

.subtitle {
  max-width: 800px;
  margin: 11px 0 0;
  color: #a5b6ca;
  font-size: .98rem;
}

.header-actions, .editor-footer-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.button, .icon-button, .back-button, .tab-button, .mini-button {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.button:hover, .icon-button:hover, .back-button:hover, .tab-button:hover, .mini-button:hover { background: #1c2d47; }
.button:focus-visible, .icon-button:focus-visible, .back-button:focus-visible,
.tab-button:focus-visible, .mini-button:focus-visible, input:focus-visible {
  outline: 3px solid rgba(103, 183, 255, .5);
  outline-offset: 2px;
}
.button-primary { border-color: #397fba; background: #17659d; }
.button-primary:hover { background: #2178b5; }
.button-danger { color: #ffd6d7; border-color: #6d3b45; background: #3b222a; }
.button-add { width: 100%; margin-top: 12px; border-style: dashed; color: #b9d9f7; }
.button[disabled], .mini-button[disabled] { cursor: not-allowed; opacity: .42; }

.notice {
  margin: 0 0 18px;
  padding: 12px 14px;
  border: 1px solid #6f5c2b;
  border-radius: 12px;
  background: #312a18;
  color: #ffe7a9;
}

.dashboard { display: grid; gap: 22px; }
.empty-dashboard {
  padding: 60px 24px;
  border: 1px dashed var(--line);
  border-radius: 18px;
  text-align: center;
  color: var(--muted);
}

.group-card {
  min-width: 0;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid #25364d;
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 16px 45px rgba(0, 0, 0, .18);
}

.group-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.group-heading h2 { margin: 0; font-size: 1.45rem; letter-spacing: -.02em; }
.group-heading p { margin: 4px 0 0; color: var(--muted); font-size: .86rem; }
.provider-badge, .capability-badge {
  display: inline-flex;
  align-items: center;
  color: #bdd6ef;
  background: #1b2a40;
  border: 1px solid #314865;
  border-radius: 999px;
  padding: 5px 9px;
  font-size: .74rem;
  font-weight: 750;
}

.component-grid {
  display: grid;
  gap: 16px;
  overflow-x: hidden;
  align-items: start;
  scrollbar-width: none;
}
.component-grid::-webkit-scrollbar { display: none; }
.layout-single { grid-template-columns: minmax(0, 1fr); }
.layout-row { grid-template-columns: repeat(var(--component-count), minmax(0, 1fr)); }
.layout-column { grid-template-columns: minmax(0, 1fr); }
.layout-lsr { grid-template-columns: minmax(0, 360px) minmax(0, 1fr); }
.layout-lsr > :first-child { grid-row: 1 / span 2; align-self: stretch; }
.layout-t2b1 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.layout-t2b1 > :nth-child(3) { grid-column: 1 / -1; }
.group-provider-H .layout-t2b1 { grid-template-columns: minmax(0, 330px) minmax(0, 1fr); }
.group-provider-F .layout-row:has(.component-gauge) { grid-template-columns: minmax(0, 332px) minmax(0, 1fr); }

.weather-component {
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: rgba(9, 18, 31, .55);
  border: 1px solid #25384f;
  border-radius: 14px;
}
.component-heading { min-height: 58px; padding: 12px 14px 8px; }
.component-heading h3 { margin: 0; font-size: 1rem; }
.component-heading p { margin: 3px 0 0; color: var(--muted); font-size: .79rem; }
.component-body { flex: 1; min-height: 210px; padding: 10px 14px 14px; overflow: hidden; }
.component-loading, .component-error {
  display: grid;
  min-height: 210px;
  place-items: center;
  color: var(--muted);
  text-align: center;
}
.component-error { color: #f2b8b9; }

.group-source {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 13px;
  color: var(--muted);
  font-size: .77rem;
}
.group-source a { text-decoration: none; }

.embed-frame {
  display: block;
  width: 100%;
  min-height: 280px;
  border: 0;
  background: #fff;
  pointer-events: none;
  scrollbar-width: none;
}
.component-rose .component-body,
.component-avg6 .component-body,
.component-graph12 .component-body,
.component-gauge .component-body,
.component-history1h .component-body,
.component-history4h .component-body,
.component-history12h .component-body { flex: none; min-height: 0; }
.component-rose { width: min(330px, 100%); justify-self: start; }
.component-rose .component-body { display: grid; place-items: start center; }
.component-rose .embed-frame { width: 300px; height: 300px; min-height: 300px; }
.component-avg6 { width: min(850px, 100%); justify-self: start; }
.component-avg6 .embed-frame { width: 820px; height: 170px; min-height: 170px; }
.component-graph12 .embed-frame { height: 920px; min-height: 920px; }
.scaled-embed-viewport {
  max-width: 100%;
  overflow: hidden;
  background: #fff;
}
.scaled-embed-frame {
  display: block;
  max-width: none !important;
  transform-origin: top left;
  overflow: hidden;
}
.ffwx-history-image {
  display: block;
  width: auto;
  min-width: 0;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
  background: #fff;
  user-select: none;
  pointer-events: none;
}

@media (max-width: 1200px) {
  .group-provider-H .layout-t2b1,
  .group-provider-F .layout-row:has(.component-gauge) {
    grid-template-columns: minmax(0, 1fr);
  }
  .group-provider-H .layout-t2b1 > :first-child { grid-row: auto; align-self: start; }
  .group-provider-H .layout-t2b1 > :nth-child(3) { grid-column: auto; }
}

.windsock-layout {
  display: flex;
  flex-direction: column;
  gap: 26px;
  align-items: center;
  justify-content: center;
}
.compass {
  position: relative;
  flex: 0 0 auto;
  width: min(330px, 100%);
  height: auto;
  aspect-ratio: 1;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at center, #14233a 0 56%, #203653 57% 100%);
}
.compass-ring { position: absolute; inset: 28px; border: 2px solid #466685; border-radius: 50%; box-shadow: inset 0 0 0 1px #1a2d46; }
.compass-ring::before,
.compass-ring::after { content: ""; position: absolute; background: #2c4665; }
.compass-ring::before { width: 1px; height: 100%; top: 0; left: 50%; }
.compass-ring::after { width: 100%; height: 1px; left: 0; top: 50%; }
.compass-label { position: absolute; z-index: 8; font-size: .78rem; font-weight: 850; color: #c5d5e6; }
.compass-n { top: 5px; left: 50%; transform: translateX(-50%); color: var(--orange); }
.compass-s { bottom: 5px; left: 50%; transform: translateX(-50%); }
.compass-e { right: 8px; top: 50%; transform: translateY(-50%); }
.compass-w { left: 7px; top: 50%; transform: translateY(-50%); }
.windsock-rotor {
  position: absolute;
  z-index: 6;
  width: 190px;
  height: 70px;
  left: 50%;
  top: 50%;
  margin-left: -26px;
  margin-top: -35px;
  transform-origin: 26px 35px;
  transition: transform .3s ease;
}
.windsock-svg { display: block; width: 190px; height: 70px; overflow: visible; filter: drop-shadow(0 4px 5px rgba(0,0,0,.25)); }
.compass-center-dot { position: absolute; z-index: 9; left: 50%; top: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: #d8e5f2; box-shadow: 0 0 0 5px rgba(38, 59, 85, .9); }
.windsock-rotor.calm { opacity: .35; transform: rotate(0deg) scaleX(.72) !important; }
.component-sock .component-body { display: flex; min-height: 650px; flex-direction: column; justify-content: center; }
.current-wind { text-align: center; }
.current-direction { font-size: 2rem; font-weight: 850; line-height: 1; letter-spacing: -.03em; }
.current-speed { margin-top: 14px; color: #b9cce0; }
.current-speed strong { color: var(--text); font-size: 1.8rem; }
.current-gust { margin-top: 6px; color: var(--orange); }
.observation-time { margin: 15px 0 0; color: var(--muted); font-size: .77rem; text-align: center; }

.values-grid { display: grid; grid-template-columns: repeat(2, minmax(115px, 1fr)); gap: 10px; }
.value-tile { padding: 13px; border: 1px solid #293c54; border-radius: 11px; background: #122137; }
.value-tile span { display: block; color: var(--muted); font-size: .72rem; }
.value-tile strong { display: block; margin-top: 4px; font-size: 1.35rem; }

.chart-wrap { min-width: 620px; }
.weather-chart { display: block; width: 100%; height: 285px; }
.component-speed3h .component-body,
.component-dir3h .component-body { min-height: 309px; }

.radar-range-controls,
.radar-loop-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 7px; margin-bottom: 10px; }
.radar-range-controls .mini-button[aria-pressed="true"] { border-color: #4e98d1; background: #17659d; }
.radar-loop-controls { margin: 10px 0 0; }
.radar-loop-controls .mini-button[aria-pressed="true"] { border-color: #4e98d1; background: #17659d; }
.radar-scene { position: relative; width: min(100%, 820px); margin: 0 auto; overflow: hidden; background: #050a10; }
.radar-scene-rain { aspect-ratio: 1024 / 1115; }
.radar-scene-doppler { aspect-ratio: 1; }
.radar-layer { position: absolute; top: 0; left: 0; display: block; width: 100%; max-width: none; pointer-events: none; user-select: none; }
.radar-legend { z-index: 1; }
.radar-scene-rain .radar-legend { height: 100%; }
.radar-scene-rain .radar-background,
.radar-scene-rain .radar-catchments,
.radar-scene-rain .radar-topography,
.radar-scene-rain .radar-frame,
.radar-scene-rain .radar-range,
.radar-scene-rain .radar-locations { height: auto; aspect-ratio: 1; }
.radar-scene-doppler .radar-layer { height: 100%; }
.radar-background { z-index: 2; }
.radar-catchments { z-index: 3; }
.radar-topography { z-index: 4; }
.radar-frame { z-index: 5; }
.radar-range { z-index: 6; }
.radar-locations { z-index: 7; }
.radar-fallback { z-index: 5; height: 100%; background: #050a10; }
.radar-time { margin: 8px 0 0; color: var(--muted); font-size: .75rem; text-align: center; }

.site-footer { margin-top: 28px; color: #6f8299; font-size: .78rem; line-height: 1.5; }

.editor-dialog {
  width: min(1000px, calc(100% - 24px));
  max-height: calc(100vh - 24px);
  padding: 0;
  border: 1px solid #314864;
  border-radius: 18px;
  background: #0f1929;
  color: var(--text);
  box-shadow: 0 30px 90px #000a;
}
.editor-dialog::backdrop { background: rgba(2, 7, 14, .78); backdrop-filter: blur(5px); }
.dialog-shell { padding: 20px; }
.dialog-header { display: flex; justify-content: space-between; align-items: start; gap: 16px; margin-bottom: 8px; }
.dialog-header h2 { margin: 0; font-size: 1.8rem; }
.dialog-intro { margin: 8px 0 18px; color: var(--muted); }
.icon-button { width: 42px; height: 42px; padding: 0; border-radius: 50%; font-size: 1.45rem; }
.editor-groups { display: grid; gap: 10px; }
.editor-group {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(180px, 1.3fr) auto;
  gap: 14px;
  align-items: center;
  padding: 13px;
  border: 1px solid #293d56;
  border-radius: 12px;
  background: #121f33;
}
.editor-group h3 { margin: 0; font-size: .98rem; }
.editor-group p { margin: 4px 0 0; color: var(--muted); font-size: .77rem; }
.editor-group-actions { display: flex; flex-wrap: wrap; justify-content: end; gap: 6px; }
.mini-button { padding: 7px 9px; font-size: .76rem; }
.editor-footer-actions { justify-content: flex-end; margin-top: 16px; }
.back-button { margin-bottom: 14px; padding-left: 10px; border-color: transparent; background: transparent; color: #a9c7e2; }
.editor-status { min-height: 24px; margin-top: 10px; color: #a8c8e5; font-size: .83rem; }

.wizard-step { margin: 0 0 20px; padding: 16px; border: 1px solid #293d56; border-radius: 13px; background: #111e31; }
.wizard-step legend, .wizard-step h3 { margin: 0 0 12px; padding: 0 4px; font-size: 1rem; font-weight: 800; }
.provider-tabs { display: flex; flex-wrap: wrap; gap: 7px; }
.tab-button[aria-selected="true"] { border-color: #4e98d1; background: #17659d; }
.search-label { display: grid; gap: 6px; color: #bdccda; font-size: .82rem; }
.search-input { width: 100%; min-height: 44px; border: 1px solid #38506c; border-radius: 10px; padding: 9px 11px; background: #0b1524; color: var(--text); }
.search-results { display: grid; gap: 8px; max-height: 290px; margin-top: 12px; overflow: auto; }
.search-result { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px; border: 1px solid #293d56; border-radius: 10px; }
.search-result h4 { margin: 0; }
.search-result p { margin: 3px 0 0; color: var(--muted); font-size: .76rem; }
.selected-station { padding: 12px; border: 1px solid #397fba; border-radius: 10px; background: #132940; }
.selected-station strong { display: block; }
.selected-station span { color: var(--muted); font-size: .8rem; }
.component-options { display: grid; gap: 7px; }
.component-option { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; align-items: center; padding: 10px; border: 1px solid #2b3e56; border-radius: 10px; }
.component-option input { width: 19px; height: 19px; accent-color: #54a8e8; }
.component-order { display: flex; gap: 5px; }
.layout-options { display: grid; grid-template-columns: repeat(5, minmax(105px, 1fr)); gap: 8px; }
.layout-option { position: relative; min-height: 78px; }
.layout-option input { position: absolute; opacity: 0; }
.layout-option label { display: grid; height: 100%; place-items: center; gap: 5px; padding: 8px; border: 1px solid #30465f; border-radius: 10px; color: #b6c6d7; cursor: pointer; text-align: center; font-size: .72rem; }
.layout-option input:checked + label { border-color: #67b7ff; background: #15314a; color: #fff; box-shadow: inset 0 0 0 1px #67b7ff; }
.layout-glyph { display: grid; width: 58px; height: 34px; gap: 3px; }
.layout-glyph i { display: block; border-radius: 3px; background: #54708f; }
.glyph-row { grid-template-columns: 1fr 1fr; }
.glyph-column { grid-template-rows: 1fr 1fr; }
.glyph-lsr { grid-template: 1fr 1fr / 1fr 1fr; }
.glyph-lsr i:first-child { grid-row: 1 / 3; }
.glyph-t2b1 { grid-template: 1fr 1fr / 1fr 1fr; }
.glyph-t2b1 i:last-child { grid-column: 1 / 3; }
.layout-preview { display: grid; gap: 7px; min-height: 150px; overflow-x: auto; }
.layout-preview > div { display: grid; min-width: 130px; min-height: 65px; place-items: center; border: 1px solid #3a526c; border-radius: 8px; background: #17283d; color: #bcd0e5; font-size: .78rem; text-align: center; }
.preview-row { grid-template-columns: repeat(var(--component-count), minmax(150px, 1fr)); }
.preview-column { grid-template-columns: 1fr; }
.preview-lsr { grid-template-columns: 1fr 1.35fr; }
.preview-lsr > div:first-child { grid-row: 1 / span 20; }
.preview-t2b1 { grid-template-columns: 1fr 1fr; }
.preview-t2b1 > div:nth-child(3) { grid-column: 1 / -1; }
.wizard-actions { display: flex; justify-content: flex-end; gap: 9px; }
.url-warning { margin: 8px 0 0; color: #ffe09a; font-size: .78rem; }

@media (max-width: 820px) {
  .main-header { align-items: start; flex-direction: column; }
  .header-actions { width: 100%; }
  .header-actions .button { flex: 1; }
  .component-grid { overflow-x: hidden; }
  .layout-single,
  .layout-row,
  .layout-column,
  .layout-lsr,
  .layout-t2b1,
  .group-provider-H .layout-t2b1,
  .group-provider-F .layout-row:has(.component-gauge) {
    min-width: 0;
    grid-template-columns: minmax(0, 1fr);
  }
  .layout-lsr > :first-child { grid-row: auto; align-self: start; }
  .layout-t2b1 > :nth-child(3) { grid-column: auto; }
  .component-sock .component-body { min-height: 0; }
  .chart-wrap { min-width: 0; }
  .editor-group { grid-template-columns: 1fr; }
  .editor-group-actions { justify-content: start; }
  .layout-options { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
}

@media (max-width: 520px) {
  .page-shell { width: min(100% - 18px, 1880px); padding-top: 22px; }
  .group-card { padding: 13px; border-radius: 14px; }
  .dialog-shell { padding: 14px; }
  .editor-footer-actions { display: grid; }
  .layout-options { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
