:root {
  --bg: #0b1020;
  --fg: #e8ecf6;
  --muted: #8a93ab;
  --danger: #ff4d4d;
  --ok: #3ddc84;
  --warn: #ffb020;
  --surface: #151b30;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 16px env(safe-area-inset-bottom);
  overscroll-behavior: none;
}

main {
  min-height: 100dvh;
  max-width: 420px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

[hidden] { display: none !important; }

.status {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 16px 0;
  color: var(--muted);
  font-size: 14px;
}

.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); }
.dot.off { background: var(--danger); }

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding-bottom: 48px;
  text-align: center;
}

h1 { margin: 0; font-size: 28px; }
.hint { margin: 0; color: var(--muted); }
code { background: var(--surface); padding: 1px 6px; border-radius: 4px; }

form { width: 100%; display: flex; flex-direction: column; gap: 12px; }

input {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 1px solid #2a3350;
  background: var(--surface);
  color: var(--fg);
  font-size: 16px; /* 16px evita o zoom automático do iOS ao focar */
}

button { font: inherit; touch-action: manipulation; }

.secondary {
  padding: 14px 20px;
  border-radius: 12px;
  border: 1px solid #2a3350;
  background: var(--surface);
  color: var(--fg);
  cursor: pointer;
}

.link {
  background: none;
  border: 0;
  color: var(--muted);
  text-decoration: underline;
  cursor: pointer;
  padding: 8px;
}

.error { margin: 0; color: var(--danger); }

.power {
  width: min(72vw, 280px);
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--surface);
  color: var(--danger);
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
  transition: transform 120ms ease-out;
}

.power:active:not(:disabled) { transform: scale(0.97); }
.power:disabled { color: var(--muted); cursor: not-allowed; }
.power:focus-visible { outline: 3px solid var(--fg); outline-offset: 4px; }

.power svg { width: 100%; height: 100%; display: block; }

.track, .progress { fill: none; stroke-width: 5; }
.track { stroke: #232b47; }
.progress {
  stroke: var(--danger);
  stroke-linecap: round;
  stroke-dasharray: 339.292; /* 2 * PI * 54 */
  stroke-dashoffset: calc(339.292 * (1 - var(--p, 0)));
  transform: rotate(-90deg);
  transform-origin: 60px 60px;
}

.icon path { fill: none; stroke: currentColor; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }

.message { margin: 0; min-height: 3em; color: var(--muted); }
.message.ok { color: var(--ok); }
.message.warn { color: var(--warn); }
.message.err { color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .power { transition: none; }
}
