:root {
  --bg: #090d12;
  --panel: #111922;
  --panel-2: #151f2a;
  --text: #eef4f8;
  --muted: #8fa1af;
  --line: #253342;
  --line-soft: rgba(255, 255, 255, 0.06);
  --sst: #ff6b6b;
  --at: #f6bd60;
  --korea: #5dd6b6;
  --ice: #7cc8ff;
  --red: #ff3434;
  --darkred: #9f1d2b;
  --blue: #6ea8ff;
  --orange: #ff9f45;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.025) 1px, transparent 1px),
    var(--bg);
  background-size: 48px 48px;
  color: var(--text);
  font-family: "Noto Sans KR", system-ui, sans-serif;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 26px 30px 16px;
}

.eyebrow,
.panel-kicker {
  color: var(--ice);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  margin: 4px 0 0;
  font-family: "IBM Plex Mono", "Noto Sans KR", monospace;
  font-size: 28px;
  line-height: 1.15;
  letter-spacing: 0;
}

.app-header p,
.controls p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.now {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(17, 25, 34, 0.8);
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
  white-space: nowrap;
}

.metric-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  padding: 0 30px 16px;
}

.metric-card {
  position: relative;
  overflow: hidden;
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.045), rgba(255,255,255,0.015)), var(--panel);
  padding: 16px;
}

.metric-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--ice);
}

.metric-sst::before { background: var(--sst); }
.metric-at::before { background: var(--at); }
.metric-nino::before { background: #f472b6; }
.metric-korea::before { background: var(--korea); }

.metric-card span {
  display: block;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.metric-card strong {
  display: block;
  margin-top: 10px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 30px;
  line-height: 1;
}

.metric-card small {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  line-height: 1.4;
}

.tabs {
  display: flex;
  gap: 6px;
  padding: 12px 30px;
  border-top: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  background: rgba(9, 13, 18, 0.72);
  overflow-x: auto;
}

.tab {
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  padding: 9px 13px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
}

.tab.active {
  background: var(--panel-2);
  border-color: var(--line);
  color: var(--text);
}

main {
  padding: 18px 30px 30px;
}

.panel {
  display: none;
  grid-template-columns: minmax(0, 1fr) 324px;
  gap: 14px;
}

.panel.active {
  display: grid;
}

.chart-shell,
.controls,
.summary {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 25, 34, 0.92);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.22);
}

.chart-shell {
  overflow: hidden;
}

.chart {
  width: 100%;
  height: 680px;
}

.chart-message {
  display: grid;
  min-height: 680px;
  place-items: center;
  padding: 28px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.6;
  text-align: center;
}

.chart-message.error {
  color: #ffb4b8;
}

.controls {
  align-self: start;
  position: sticky;
  top: 12px;
  padding: 18px;
}

.controls h2 {
  margin: 6px 0 12px;
  font-size: 18px;
}

.accent {
  display: block;
  color: var(--text);
  line-height: 1.5;
}

.legend-copy {
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 12px 0;
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
}

fieldset {
  border: 0;
  padding: 18px 0 0;
  margin: 0;
}

legend {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.slider-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 8px;
}

fieldset label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  margin: 0 5px 7px 0;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.025);
  color: #dbe5ec;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

fieldset label:has(input:checked) {
  border-color: rgba(124, 200, 255, 0.65);
  background: rgba(124, 200, 255, 0.16);
  color: var(--text);
}

input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.month-select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-2);
  color: var(--text);
  padding: 0 10px;
  font: inherit;
}

.slider-label {
  margin-top: 14px;
}

.blue { color: var(--blue); }
.orange { color: var(--orange); }
.darkred { color: var(--darkred); }
.red { color: var(--red); }
.pink { color: pink; }

.note {
  font-size: 13px;
}

.summary-panel {
  grid-template-columns: minmax(0, 1fr);
}

.summary {
  padding: 24px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.summary-item {
  min-height: 154px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.012)), rgba(9, 13, 18, 0.55);
  padding: 16px;
}

.summary-item span,
.summary-item small {
  display: block;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.45;
}

.summary-item strong {
  display: block;
  margin-top: 10px;
  color: var(--text);
  font-family: "IBM Plex Mono", monospace;
  font-size: 30px;
  line-height: 1;
}

.summary-item em {
  display: block;
  margin-top: 8px;
  color: #cbd7df;
  font-style: normal;
  font-size: 15px;
}

.summary-item small {
  margin-top: 12px;
}

.polar-section {
  margin-top: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(17, 25, 34, 0.92);
  padding: 18px;
}

.polar-section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.polar-section h2 {
  margin: 6px 0 0;
  font-size: 18px;
}

.polar-section p {
  margin: 0;
  color: var(--muted);
}

.polar-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.polar-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111922;
}

.polar-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.polar-card-header strong {
  font-family: "IBM Plex Mono", monospace;
  font-size: 13px;
}

.download-link {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--text);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
}

.download-link:hover {
  border-color: var(--ice);
  background: rgba(124, 200, 255, 0.12);
}

.polar-card svg {
  display: block;
  width: 100%;
  height: auto;
}

.site-credit {
  padding: 0 30px 30px;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.site-credit a {
  color: var(--muted);
  text-decoration: none;
}

.site-credit a:hover {
  color: var(--text);
}

@media (max-width: 1080px) {
  .metric-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel.active {
    grid-template-columns: 1fr;
  }

  .controls {
    position: static;
    order: -1;
  }
}

@media (max-width: 620px) {
  .app-header,
  .tabs,
  main,
  .metric-strip,
  .site-credit {
    padding-left: 14px;
    padding-right: 14px;
  }

  .app-header {
    display: block;
  }

  .now {
    display: inline-block;
    margin-top: 12px;
  }

  h1 {
    font-size: 22px;
  }

  .metric-strip {
    grid-template-columns: 1fr;
  }

  .polar-grid {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .chart {
    height: 500px;
  }
}
