:root {
  color-scheme: dark;
  --bg: #0f1f2e;
  --panel: #162b3a;
  --panel-2: #203847;
  --panel-3: #102837;
  --text: #edf5f7;
  --muted: #9db1ba;
  --line: #385360;
  --accent: #78d5b7;
  --accent-2: #f3c969;
  --chart-bg: #163246;
  --danger: #ec7b6f;
  --button: #274350;
  --shadow: rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--button);
  color: var(--text);
  cursor: pointer;
  font: inherit;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand-block {
  min-width: 0;
}

.brand-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 4px;
}

.brand-logo {
  display: block;
  flex: 0 0 auto;
  object-fit: contain;
}

.brand-logo-wind {
  width: 26px;
  height: 26px;
  border-radius: 7px;
}

.brand-logo-surf {
  width: 34px;
  height: 34px;
  opacity: 0.92;
}

.brand-plus {
  color: var(--text);
  font-size: 16px;
  font-weight: 900;
  line-height: 1;
  opacity: 0.84;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.brand-love {
  color: #ff6f73;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 34px;
  line-height: 1.05;
}

.wind-headline {
  color: var(--text);
}

.wind-word {
  position: relative;
  display: inline-block;
  text-decoration-color: transparent;
  text-decoration-line: none;
  text-decoration-thickness: 0.08em;
  transition: color 180ms ease, text-decoration-color 180ms ease;
}

.wind-word::after {
  content: "";
  position: absolute;
  left: -0.08em;
  right: -0.08em;
  top: 57%;
  height: 0.12em;
  border-radius: 999px;
  background: transparent;
  transform: translateY(-50%);
  transition: background 180ms ease;
}

.wind-blows-word {
  display: none;
}

.wind-headline.wind-active .wind-blows-word {
  display: inline;
}

.wind-headline.wind-calm .wind-word {
  color: var(--text);
}

.wind-headline.wind-calm .wind-word::after {
  background: #ff6f73;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--accent);
}

.status.warning .status-dot {
  background: var(--accent-2);
}

.status.error .status-dot {
  background: var(--danger);
}

.controls {
  display: grid;
  grid-template-columns: minmax(150px, auto) 1fr;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 14px;
}

.control-group {
  min-width: 0;
}

.control-label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 12px;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #102634;
}

.ranges {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.segmented button {
  min-width: 58px;
  height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  flex: 0 0 auto;
}

.ranges button {
  min-width: 52px;
  height: 36px;
  padding: 0 12px;
  border-color: rgba(56, 83, 96, 0.72);
  background: rgba(39, 67, 80, 0.58);
  color: var(--muted);
  flex: 0 0 auto;
}

.segmented button.active {
  background: var(--accent);
  color: #0b201a;
  font-weight: 800;
}

.ranges button.active {
  border-color: rgba(120, 213, 183, 0.86);
  background: rgba(120, 213, 183, 0.16);
  color: var(--text);
  font-weight: 800;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.metric {
  min-height: 98px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px var(--shadow);
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.metric strong {
  display: block;
  font-size: 34px;
  line-height: 1;
  white-space: nowrap;
}

.direction-metric strong {
  font-size: 31px;
  line-height: 1.12;
  white-space: nowrap;
}

.chart-panel,
.details,
.log-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 8px 24px var(--shadow);
}

.chart-panel {
  padding: 14px;
  margin-bottom: 14px;
}

.chart-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.chart-head h2 {
  font-size: 20px;
}

.chart-head p {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

#refreshButton {
  height: 38px;
  padding: 0 12px;
}

.chart-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

.auto-refresh {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.auto-refresh input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
}

.toggle-track {
  position: relative;
  width: 40px;
  height: 22px;
  border: 1px solid rgba(157, 177, 186, 0.35);
  border-radius: 999px;
  background: rgba(39, 67, 80, 0.78);
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--muted);
  transition: transform 160ms ease, background 160ms ease;
}

.auto-refresh input:checked + .toggle-track {
  border-color: rgba(120, 213, 183, 0.7);
  background: rgba(120, 213, 183, 0.22);
}

.auto-refresh input:checked + .toggle-track::after {
  transform: translateX(18px);
  background: var(--accent);
}

.auto-refresh input:focus-visible + .toggle-track {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#windChart {
  width: 100%;
  height: clamp(280px, 40vh, 460px);
  display: block;
  border-radius: 6px;
  background: var(--chart-bg);
  cursor: crosshair;
  touch-action: none;
}

.details {
  padding: 4px 14px;
}

.details dl {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  margin: 0;
}

.details div {
  min-width: 0;
  padding: 12px 10px;
}

.details dt {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 5px;
}

.details dd {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-panel {
  padding: 14px;
}

.log-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.log-head h2 {
  font-size: 20px;
}

.log-head p,
#logMeta {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.event-log {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.event-item {
  display: grid;
  grid-template-columns: 78px 92px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 9px 10px;
  border: 1px solid rgba(56, 83, 96, 0.72);
  border-radius: 8px;
  background: var(--panel-2);
}

.event-item.warning {
  border-color: rgba(243, 201, 105, 0.62);
}

.event-item.error {
  border-color: rgba(236, 123, 111, 0.72);
}

.event-time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.event-badge {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 78px;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 999px;
  background: rgba(120, 213, 183, 0.16);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
}

.event-badge.badge-receive {
  background: rgba(120, 213, 183, 0.15);
  color: #86e7c9;
}

.event-badge.badge-forward {
  background: rgba(119, 200, 232, 0.16);
  color: #89d5ef;
}

.event-badge.badge-probe {
  background: rgba(167, 148, 255, 0.15);
  color: #b9adff;
}

.event-badge.badge-warning {
  background: rgba(243, 201, 105, 0.16);
  color: var(--accent-2);
}

.event-badge.badge-error {
  background: rgba(236, 123, 111, 0.14);
  color: var(--danger);
}

.event-badge.badge-event {
  background: rgba(157, 177, 186, 0.14);
  color: var(--muted);
}

.event-main {
  min-width: 0;
}

.event-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-sub {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.event-wind {
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.event-log-empty {
  color: var(--muted);
  padding: 16px 4px 4px;
}

@media (max-width: 760px) {
  .app {
    width: min(100% - 18px, 640px);
    padding-top: 14px;
  }

  .topbar {
    align-items: flex-start;
  }

  .brand-row {
    gap: 7px;
  }

  .brand-logo-wind {
    width: 24px;
    height: 24px;
  }

  .brand-logo-surf {
    width: 30px;
    height: 30px;
  }

  h1 {
    font-size: 30px;
  }

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

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

  .metric {
    min-height: 86px;
  }

  .metric strong {
    font-size: 28px;
  }

  .direction-metric strong {
    font-size: 28px;
  }

  .details dl {
    grid-template-columns: 1fr 1fr;
  }

  .event-item {
    grid-template-columns: 68px 82px 1fr;
  }

  .event-wind {
    grid-column: 3;
  }
}

@media (max-width: 430px) {
  .topbar {
    flex-direction: column;
  }

  .status {
    width: 100%;
    justify-content: center;
  }

  .details dl {
    grid-template-columns: 1fr;
  }

  .log-head {
    flex-direction: column;
  }

  .event-item {
    grid-template-columns: 1fr auto;
    align-items: flex-start;
  }

  .event-time,
  .event-badge,
  .event-main,
  .event-wind {
    grid-column: auto;
  }

  .event-main {
    grid-column: 1 / -1;
  }
}
