/* styles.css — frosted alpine UI over a full-bleed WebGPU canvas. */
:root {
  --bg: #0a0f15;
  --glass: rgba(17, 25, 34, 0.72);
  --glass-2: rgba(24, 34, 46, 0.66);
  --stroke: rgba(140, 170, 200, 0.16);
  --stroke-strong: rgba(140, 170, 200, 0.32);
  --text: #dde7f1;
  --muted: #8ea2b6;
  --accent: #58c6f5;
  --accent-2: #7ef0d0;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); }
body {
  font-family: var(--sans);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- top bar ---------- */
#topbar {
  position: fixed; top: 0; left: 0; right: 0; height: 52px; z-index: 20;
  display: flex; align-items: center; gap: 18px; padding: 0 18px;
  background: linear-gradient(180deg, rgba(10, 15, 21, 0.92), rgba(10, 15, 21, 0.35));
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--stroke);
}
.wa-title { font-weight: 650; font-size: 15px; letter-spacing: 0.3px; display: flex; align-items: center; gap: 8px; }
.wa-logo { color: var(--accent); filter: drop-shadow(0 0 6px rgba(88, 198, 245, 0.6)); }
.wa-hint { color: var(--muted); font-size: 12.5px; margin-left: 4px; }
.wa-hint b { color: var(--accent-2); font-weight: 600; }
.wa-backend {
  margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--accent-2);
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--stroke-strong); padding: 3px 9px; border-radius: 20px;
  background: rgba(126, 240, 208, 0.06);
  cursor: pointer; transition: background 0.15s, border-color 0.15s;
}
.wa-backend:hover { background: rgba(126, 240, 208, 0.13); border-color: var(--accent-2); }
.wa-backend-active { color: var(--accent-2); font-weight: 600; }
.wa-backend-arrow { color: var(--muted); font-size: 10px; }
.wa-backend-alt { color: var(--muted); }
.wa-backend:hover .wa-backend-alt { color: var(--text); }
.wa-toast {
  position: fixed; top: 62px; left: 50%; transform: translate(-50%, -8px);
  background: var(--glass); border: 1px solid var(--stroke-strong); color: var(--text);
  padding: 8px 16px; border-radius: 10px; font-size: 13px; backdrop-filter: blur(8px);
  opacity: 0; pointer-events: none; transition: opacity 0.25s, transform 0.25s; z-index: 30;
}
.wa-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- buttons ---------- */
.wa-btn {
  font-family: var(--sans); font-size: 13px; color: var(--text);
  background: linear-gradient(180deg, rgba(88, 198, 245, 0.16), rgba(88, 198, 245, 0.06));
  border: 1px solid var(--stroke-strong); border-radius: 8px; padding: 7px 14px;
  cursor: pointer; transition: background 0.15s, border-color 0.15s, transform 0.05s;
  width: 100%;
}
.wa-btn:hover { background: rgba(88, 198, 245, 0.22); border-color: var(--accent); }
.wa-btn:active { transform: translateY(1px); }
.wa-play { width: auto; min-width: 92px; }
/* top-bar action buttons (auto width, no wrap) + a muted "ghost" variant for reset */
.wa-topbtn { width: auto; white-space: nowrap; }
.wa-btn-ghost { background: linear-gradient(180deg, rgba(140, 170, 200, 0.12), rgba(140, 170, 200, 0.05)); color: var(--muted); }
.wa-btn-ghost:hover { background: rgba(140, 170, 200, 0.18); border-color: var(--stroke-strong); color: var(--text); }

/* segmented color-mode control (top bar) */
.wa-seg { display: flex; align-items: center; gap: 2px; padding: 3px; border: 1px solid var(--stroke); border-radius: 9px; background: rgba(10, 15, 21, 0.5); }
.wa-seg-label { font-size: 10px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); padding: 0 7px 0 4px; }
.wa-seg-btn { font-family: var(--sans); font-size: 12px; color: var(--muted); background: transparent; border: 0; border-radius: 6px; padding: 5px 11px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.wa-seg-btn:hover { color: var(--text); }
.wa-seg-btn.active { color: #0a0f15; background: var(--accent); font-weight: 600; }

/* ---------- control panel ---------- */
#panel-wrap {
  position: fixed; top: 52px; bottom: 0; left: 0; width: 312px; z-index: 15;
  overflow-y: auto; overflow-x: hidden;
  background: var(--glass); backdrop-filter: blur(14px);
  border-right: 1px solid var(--stroke);
  padding: 10px 10px 40px;
  scrollbar-width: thin; scrollbar-color: var(--stroke-strong) transparent;
}
#panel-wrap::-webkit-scrollbar { width: 8px; }
#panel-wrap::-webkit-scrollbar-thumb { background: var(--stroke-strong); border-radius: 8px; }

.wa-section { border: 1px solid var(--stroke); border-radius: 10px; margin-bottom: 8px; background: var(--glass-2); overflow: hidden; }
.wa-section-head {
  display: flex; align-items: center; gap: 8px; padding: 11px 12px; cursor: pointer;
  font-size: 12px; font-weight: 600; letter-spacing: 0.4px; text-transform: uppercase; color: #b9c9d8;
}
.wa-section-head:hover { color: #fff; }
.wa-caret { color: var(--accent); transition: transform 0.18s; display: inline-block; }
.wa-section.open .wa-caret { transform: rotate(90deg); }
.wa-section-body { display: none; padding: 4px 12px 12px; }
.wa-section.open .wa-section-body { display: block; }

.wa-row { margin: 12px 0; }
.wa-label { display: flex; justify-content: space-between; align-items: baseline; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; gap: 8px; }
.wa-value { font-family: var(--mono); font-size: 12px; color: var(--accent-2); }

/* range — transparent 16px hit area with a thin styled track + centered thumb */
.wa-range { -webkit-appearance: none; appearance: none; width: 100%; height: 16px; margin: 2px 0; background: transparent; outline: none; cursor: pointer; }
.wa-range::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: rgba(140, 170, 200, 0.22); }
.wa-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; margin-top: -5.5px; width: 15px; height: 15px; border-radius: 50%;
  background: var(--accent); border: 2px solid #0a0f15; cursor: pointer;
  box-shadow: 0 0 0 1px var(--accent), 0 0 8px rgba(88, 198, 245, 0.6);
}
.wa-range::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(140, 170, 200, 0.22); }
.wa-range::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--accent); border: 2px solid #0a0f15; cursor: pointer; box-shadow: 0 0 6px rgba(88, 198, 245, 0.6); }

/* select */
.wa-select {
  width: 100%; font-family: var(--sans); font-size: 13px; color: var(--text);
  background: rgba(10, 15, 21, 0.7); border: 1px solid var(--stroke-strong);
  border-radius: 8px; padding: 7px 9px; cursor: pointer;
}
.wa-select:focus { border-color: var(--accent); outline: none; }

/* checkbox */
.wa-row-checkbox .wa-label { justify-content: flex-start; align-items: center; margin-bottom: 0; color: var(--text); cursor: pointer; }
.wa-check { width: 15px; height: 15px; accent-color: var(--accent); margin-right: 9px; cursor: pointer; flex: none; }

/* ---------- HUD ---------- */
#hud-wrap { position: fixed; top: 60px; right: 12px; width: 286px; z-index: 15; display: flex; flex-direction: column; gap: 10px; }
#hud { background: var(--glass); backdrop-filter: blur(14px); border: 1px solid var(--stroke); border-radius: 12px; padding: 14px; }

.wa-danger { display: flex; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--stroke); }
.wa-danger-num {
  width: 46px; height: 46px; flex: none; border-radius: 10px; display: grid; place-items: center;
  font-size: 24px; font-weight: 700; color: #0a0f15; background: var(--dc);
  box-shadow: 0 0 16px color-mix(in srgb, var(--dc) 55%, transparent);
}
.wa-danger-label { font-size: 15px; font-weight: 650; color: var(--dc); }
.wa-danger-rat { font-size: 11.5px; color: var(--muted); margin-top: 2px; line-height: 1.35; }

.wa-stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px 14px; padding: 12px 0; }
.wa-stat { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.wa-stat-l { font-size: 10.5px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.3px; }
.wa-stat-v { font-family: var(--mono); font-size: 12.5px; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.wa-problems { border-top: 1px solid var(--stroke); padding-top: 10px; }
.wa-problems-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); margin-bottom: 7px; }
.wa-problems ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.wa-problems li { display: grid; grid-template-columns: 1fr auto; gap: 1px 8px; font-size: 12.5px; }
.wa-problems li b { color: #e9f1f8; font-weight: 600; }
.wa-prob-meta { font-family: var(--mono); font-size: 10.5px; color: var(--accent-2); text-align: right; align-self: center; }
.wa-prob-note { grid-column: 1 / -1; font-size: 11px; color: var(--muted); line-height: 1.35; }

/* legend */
#legend { background: var(--glass); backdrop-filter: blur(14px); border: 1px solid var(--stroke); border-radius: 12px; padding: 12px 14px; display: none; }
.wa-legend-title { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--muted); margin-bottom: 7px; }
.wa-legend-bar { height: 10px; border-radius: 5px; border: 1px solid var(--stroke); }
.wa-legend-ticks { display: flex; justify-content: space-between; margin-top: 4px; font-family: var(--mono); font-size: 10px; color: var(--muted); }

/* ---------- loading / error ---------- */
#loading {
  position: fixed; inset: 0; z-index: 50; display: flex; flex-direction: column; gap: 16px;
  align-items: center; justify-content: center; background: var(--bg); color: var(--muted); font-size: 14px;
}
.wa-spinner { width: 38px; height: 38px; border-radius: 50%; border: 3px solid var(--stroke-strong); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.wa-error { color: #ff8a8a; text-align: center; line-height: 1.6; max-width: 420px; }

/* ---------- responsive ---------- */
@media (max-width: 880px) {
  #panel-wrap { width: 260px; }
  #hud-wrap { display: none; }
  .wa-hint, .wa-seg-label { display: none; }
  .wa-backend-arrow, .wa-backend-alt { display: none; }
}
