:root {
  --bg: #050c12;
  --bg2: #091523;
  --bg3: #0e1d2b;
  --accent: #00d4aa;
  --blue: #0096ff;
  --text: #ddeef5;
  --muted: #4a6878;
  --card: #0c1b28;
  --border: #183044;
  --danger: #ff6b6b;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
}

.grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 212, 170, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 212, 170, 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
}

.wrap {
  width: 100%;
  max-width: 760px;
  position: relative;
  z-index: 1;
}

.top {
  text-align: center;
  margin-bottom: 1rem;
}

.logo {
  margin: 0;
  font-family: "Chakra Petch", monospace;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.logo b {
  color: var(--accent);
}

.subtitle {
  margin-top: 0.5rem;
  color: var(--muted);
}

.mode-switch {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.mode-btn {
  background: var(--card);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
}

.mode-btn.active {
  border-color: var(--accent);
  color: var(--accent);
}

.lan-config {
  margin-bottom: 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.lan-config label {
  display: block;
  font-size: 12px;
  margin-bottom: 8px;
  color: var(--muted);
}

.lan-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.lan-row input,
.lan-row button {
  background: var(--bg2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

.lan-row button {
  cursor: pointer;
}

.hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.infobar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 1rem;
}

.infobar-item,
.stat,
.result-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.infobar-item {
  padding: 10px;
  text-align: center;
}

.infobar-lbl {
  color: var(--muted);
  font-size: 11px;
  margin-bottom: 4px;
}

.infobar-val {
  font-family: "Chakra Petch", monospace;
  font-size: 13px;
}

.loading {
  opacity: 0.7;
}

.gauge-outer {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gauge-svg {
  width: 320px;
  height: 200px;
}

.gauge-track {
  fill: none;
  stroke: var(--bg3);
  stroke-width: 16;
  stroke-linecap: round;
}

.gauge-fill {
  fill: none;
  stroke: url(#gg);
  stroke-width: 16;
  stroke-linecap: round;
  stroke-dasharray: 536;
  stroke-dashoffset: 536;
  transition: stroke-dashoffset 0.2s ease;
}

.g-num,
.g-unit,
.g-phase {
  font-family: "Chakra Petch", monospace;
  text-anchor: middle;
}

.g-unit,
.g-phase {
  fill: var(--muted);
}

.go-btn {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  color: var(--accent);
  background: transparent;
  cursor: pointer;
  margin-top: -6px;
  font-family: "Chakra Petch", monospace;
}

.go-btn.running .btn-t {
  display: none;
}

.spin {
  display: none;
  width: 20px;
  height: 20px;
  margin: 0 auto;
  border: 2px solid rgba(0, 212, 170, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.go-btn.running .spin {
  display: block;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.prog-wrap {
  margin: 14px 0;
  height: 4px;
  background: var(--bg3);
  border-radius: 3px;
  overflow: hidden;
}

.prog-bar {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--blue));
  transition: width 0.2s ease;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.stat {
  text-align: center;
  padding: 12px;
}

.stat-lbl,
.stat-unit {
  color: var(--muted);
  font-size: 11px;
}

.stat-val {
  font-family: "Chakra Petch", monospace;
  font-size: 24px;
  margin: 6px 0;
}

.result-box {
  margin-top: 12px;
  overflow: hidden;
}

.result-head {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
}

.result-grid div {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
}

.result-grid div:nth-child(odd) {
  border-right: 1px solid var(--border);
}

.result-grid b {
  font-family: "Chakra Petch", monospace;
}

.actions {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.actions button {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  cursor: pointer;
}

.actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.history {
  margin-top: 12px;
}

.history h2 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.history-item {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 12px;
  align-items: center;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  margin-bottom: 6px;
}

.history-time {
  color: var(--muted);
  font-family: "Chakra Petch", monospace;
  font-size: 11px;
}

.history-values {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-family: "Chakra Petch", monospace;
  font-size: 12px;
}

.toast {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f1c27;
  border: 1px solid var(--accent);
  color: var(--accent);
  padding: 10px 14px;
  border-radius: 10px;
  opacity: 0;
  transition: opacity 0.3s;
}

.toast.show {
  opacity: 1;
}

.toast.error {
  color: var(--danger);
  border-color: var(--danger);
}

@media (max-width: 640px) {
  .infobar {
    grid-template-columns: repeat(2, 1fr);
  }

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

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

  .result-grid div:nth-child(odd) {
    border-right: none;
  }

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