:root {
  --bg: #f4f5f9; --bg2: #e9ecf5; --card: rgba(255,255,255,.72); --line: rgba(15,23,42,.08);
  --text: #0f172a; --muted: #5b6474; --soft: rgba(15,23,42,.05);
  --on: #10b981; --on-glow: rgba(16,185,129,.28); --warn: #f59e0b; --warn-glow: rgba(245,158,11,.25);
  --off: #94a3b8; --accent: #6366f1; --no: #ef4444;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 12px 32px -12px rgba(15,23,42,.12);
  --radius: 22px; color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d12; --bg2: #11141b; --card: rgba(22,26,34,.66); --line: rgba(255,255,255,.07);
    --text: #e8ebf2; --muted: #8b93a3; --soft: rgba(255,255,255,.05);
    --on: #34d399; --on-glow: rgba(52,211,153,.30); --warn: #fbbf24; --warn-glow: rgba(251,191,36,.22);
    --off: #64748b; --accent: #818cf8; --no: #f87171;
    --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 20px 40px -20px rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d12; --bg2: #11141b; --card: rgba(22,26,34,.66); --line: rgba(255,255,255,.07);
  --text: #e8ebf2; --muted: #8b93a3; --soft: rgba(255,255,255,.05);
  --on: #34d399; --on-glow: rgba(52,211,153,.30); --warn: #fbbf24; --warn-glow: rgba(251,191,36,.22);
  --off: #64748b; --accent: #818cf8; --no: #f87171;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 20px 40px -20px rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
html { background: var(--bg2); }
body {
  background: linear-gradient(180deg, var(--bg), var(--bg2)) fixed; color: var(--text);
  font: 15px/1.55 "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", sans-serif;
  min-height: 100vh; -webkit-font-smoothing: antialiased; transition: background .4s, color .4s;
}
.glow {
  position: fixed; inset: -20vh -10vw auto; height: 70vh; pointer-events: none; z-index: 0;
  background: radial-gradient(40% 50% at 50% 30%, var(--soft), transparent 70%);
  transition: background .8s;
}
body[data-state="on"] .glow { background: radial-gradient(40% 50% at 50% 30%, var(--on-glow), transparent 70%); }
body[data-state="paused"] .glow { background: radial-gradient(40% 50% at 50% 30%, var(--warn-glow), transparent 70%); }

.wrap { position: relative; z-index: 1; max-width: 620px; margin: 0 auto; padding: 20px 16px 48px; display: grid; gap: 16px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 2px 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em; }
.brand img { border-radius: 8px; }
.actions { display: flex; gap: 8px; }
.pill {
  font: inherit; font-size: .8rem; font-weight: 600; color: var(--text); cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 7px 13px;
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); transition: border-color .2s, transform .1s;
  display: inline-flex; align-items: center; gap: 6px;
}
.pill:hover { border-color: var(--accent); }
.pill .l { color: var(--muted); }
.pill .l.cur { color: var(--text); }
.pill .sep { width: 1px; height: 12px; background: var(--line); }
.pill:active { transform: scale(.96); }
.pill svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px;
  box-shadow: var(--shadow); backdrop-filter: blur(18px) saturate(1.2); -webkit-backdrop-filter: blur(18px) saturate(1.2);
}
h2 { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 14px; font-weight: 650; }

/* Hero */
.hero { display: grid; justify-items: center; text-align: center; padding: 36px 22px 30px; }
.ring { position: relative; width: 188px; height: 188px; margin-bottom: 18px; }
.ring > svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 4; }
.track { stroke: var(--soft); }
.progress { opacity: 0; stroke: var(--off); stroke-linecap: round; stroke-dasharray: 0 100; transition: stroke-dasharray .9s linear, stroke .4s; }
body:not([data-state="off"]) .progress { opacity: 1; }
body[data-state="on"] .progress { stroke: var(--on); }
body[data-state="paused"] .progress { stroke: var(--warn); }
body[data-mode="spin"] .ring > svg { animation: spin 2.4s linear infinite; }
body[data-mode="spin"] .progress { stroke-dasharray: 22 78; }
@keyframes spin { to { transform: rotate(270deg); } }
.power {
  position: absolute; inset: 18px; border-radius: 50%; cursor: pointer; border: 1px solid var(--line);
  background: var(--card); color: var(--off); display: grid; place-items: center;
  box-shadow: var(--shadow); transition: color .3s, box-shadow .4s, transform .15s;
}
.power svg { width: 52px; height: 52px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.power:hover { transform: scale(1.02); }
.power:active { transform: scale(.97); }
.power:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.power:disabled { cursor: not-allowed; opacity: .5; }
body[data-state="on"] .power { color: var(--on); box-shadow: 0 0 0 1px var(--on), 0 0 48px var(--on-glow); animation: breathe 3.2s ease-in-out infinite; }
body[data-state="paused"] .power { color: var(--warn); box-shadow: 0 0 0 1px var(--warn), 0 0 36px var(--warn-glow); }
@keyframes breathe { 50% { box-shadow: 0 0 0 1px var(--on), 0 0 72px var(--on-glow); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

.state { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; margin: 0; line-height: 1.2; }
body[data-state="on"] .state { color: var(--on); }
body[data-state="paused"] .state { color: var(--warn); }
.detail { margin: 6px 0 0; color: var(--muted); max-width: 30rem; }
.chips { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 16px; }
.chips[hidden], .chip[hidden] { display: none; }
.cta {
  margin-top: 18px; font: inherit; font-weight: 600; cursor: pointer; color: #fff; background: #6366f1;
  border: 0; border-radius: 999px; padding: 10px 20px; box-shadow: 0 8px 24px -8px var(--accent); transition: transform .1s, filter .2s;
}
.cta:hover { filter: brightness(1.08); }
.cta:active { transform: scale(.97); }
.cta[hidden] { display: none; }
.chip { font-variant-numeric: tabular-nums; font-size: .85rem; padding: 5px 12px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); }

/* Settings */
.seg { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; padding: 4px; background: var(--soft); border-radius: 14px; border: 1px solid var(--line); }
.seg button {
  font: inherit; font-size: .85rem; font-weight: 600; color: var(--muted); background: transparent; border: 0;
  border-radius: 10px; padding: 8px 4px; cursor: pointer; transition: background .2s, color .2s; white-space: nowrap;
}
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"] { background: var(--card); color: var(--text); box-shadow: var(--shadow); }
.opts { display: grid; gap: 12px; margin: 18px 0 4px; }
.switch { display: flex; align-items: center; gap: 12px; cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.knob { flex: none; width: 40px; height: 24px; border-radius: 999px; background: var(--soft); border: 1px solid var(--line); position: relative; transition: background .2s; }
.knob::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch input:checked + .knob { background: var(--accent); }
.switch input:checked + .knob::after { transform: translateX(16px); }
.switch input:focus-visible + .knob { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn {
  margin-top: 14px; width: 100%; font: inherit; font-weight: 600; color: var(--text); cursor: pointer;
  background: var(--soft); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; transition: border-color .2s;
}
.btn:hover { border-color: var(--accent); }
.btn.active { color: var(--on); border-color: var(--on); }

/* Info */
.steps { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; counter-reset: s; }
.steps li { display: grid; grid-template-columns: 28px 1fr; gap: 2px 12px; counter-increment: s; }
.steps li::before {
  content: counter(s); grid-row: span 2; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  font-size: .8rem; font-weight: 700; background: var(--soft); border: 1px solid var(--line);
}
.steps span { color: var(--muted); }
details { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; }
summary::-webkit-details-marker { display: none; }
summary::after { content: "+"; font-size: 1.2rem; color: var(--muted); transition: transform .2s; }
details[open] summary::after { transform: rotate(45deg); }
details p { color: var(--muted); }
table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: .9rem; }
td { padding: 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
td:last-child { text-align: right; font-weight: 600; padding-left: 12px; }
.ok { color: var(--on); } .no { color: var(--no); } .warn { color: var(--warn); }
code { font-family: "Cascadia Code", Consolas, ui-monospace, monospace; font-size: .85em; background: var(--soft); padding: 1px 6px; border-radius: 6px; }
a { color: var(--accent); text-decoration: none; font-weight: 600; }
a:hover { text-decoration: underline; }
.dl { padding: 0; list-style: none; display: grid; gap: 10px; }
.dl span { display: block; color: var(--muted); font-size: .85rem; }

.log { list-style: none; margin: 0; padding: 0; font-size: .85rem; max-height: 200px; overflow: auto; display: grid; gap: 4px; }
.log li { display: flex; gap: 12px; color: var(--muted); }
.log time { font-variant-numeric: tabular-nums; color: var(--text); flex: none; }
.log:empty::after { content: attr(data-empty); color: var(--muted); }
.foot { color: var(--muted); font-size: .8rem; text-align: center; margin-top: 4px; }

@media (max-width: 520px) {
  .seg { grid-template-columns: repeat(3, 1fr); }
  .ring { width: 164px; height: 164px; }
  .state { font-size: 1.7rem; }
  .card { padding: 18px; }
}
