:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --fg: #1f1e1d;
  --fg2: #5f5e5a;
  --fg3: #888780;
  --line: #d3d1c7;
  --red: #e24b4a;
  --red-d: #a32d2d;
  --err: #a32d2d;
  --acc: #185fa5;
  --ok-bg: #eaf3de;
  --ok-fg: #27500a;
  --mid-bg: #faeeda;
  --mid-fg: #633806;
  --bad-bg: #fcebeb;
  --bad-fg: #791f1f;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1b19;
    --card: #262522;
    --fg: #f1efe8;
    --fg2: #b4b2a9;
    --fg3: #888780;
    --line: #3d3c38;
    --err: #f09595;
    --acc: #85b7eb;
    --ok-bg: #27500a;
    --ok-fg: #c0dd97;
    --mid-bg: #633806;
    --mid-fg: #fac775;
    --bad-bg: #791f1f;
    --bad-fg: #f7c1c1;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--acc); outline-offset: 2px; }

.app { max-width: 440px; margin: 0 auto; min-height: 100dvh; }
.screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 18px calc(20px + env(safe-area-inset-bottom));
}

.logo { width: 44px; height: 44px; margin-top: 36px; }
h1 { font-size: 26px; font-weight: 500; margin: 8px 0 36px; }
.hint { font-size: 13px; color: var(--fg3); margin: 26px 0 10px; }
.sub { font-size: 14px; color: var(--fg2); text-align: center; margin: 6px 0 24px; }
.err { min-height: 22px; font-size: 14px; color: var(--err); margin: 12px 0 0; text-align: center; }

.btn {
  width: 100%;
  border: 0.5px solid var(--line);
  background: var(--card);
  color: var(--fg);
  border-radius: 10px;
  font: inherit;
  font-weight: 500;
  padding: 12px 0;
  cursor: pointer;
}
.btn:active { background: var(--line); }
.pri { background: var(--fg); color: var(--bg); border-color: var(--fg); }
.pri:active { background: var(--fg); opacity: 0.85; }
.btn.busy { opacity: 0.55; pointer-events: none; }
.link {
  background: none;
  border: 0;
  color: var(--fg2);
  font: inherit;
  font-size: 14px;
  text-decoration: underline;
  padding: 8px 12px;
  cursor: pointer;
}

.code {
  width: 100%;
  text-align: center;
  font: inherit;
  font-size: 30px;
  font-weight: 500;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  padding: 10px 0 10px 0.35em;
  border: 0.5px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  color: var(--fg);
  margin-bottom: 14px;
}
.code::placeholder { color: var(--line); }
.bigcode { font-size: 56px; font-weight: 500; letter-spacing: 0.2em; margin: 4px 0 8px; padding-left: 0.2em; }

.row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  font-size: 12px;
  color: var(--fg2);
}
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: var(--fg3); }
.dot.on { background: #639922; }
.dot.warn { background: #ba7517; }
.stat { display: inline-flex; align-items: center; }

.state { font-size: 14px; color: var(--fg2); margin: 24px 0 0; min-height: 22px; text-align: center; }
.state.hot { color: var(--err); font-weight: 500; }
.center { flex: 1; display: flex; align-items: center; justify-content: center; width: 100%; }

.buzz {
  width: min(68vw, 260px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 0;
  background: var(--red);
  color: #fff;
  font: inherit;
  font-size: 24px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.buzz:active { background: var(--red-d); }

.target { display: flex; align-items: center; gap: 8px; margin-top: 22px; font-size: 13px; color: var(--fg2); }
.mini {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 0.5px solid var(--line);
  background: var(--card);
  color: var(--fg);
  font: inherit;
  font-size: 18px;
  cursor: pointer;
}
.mini:active { background: var(--line); }

.num { font-size: 76px; font-weight: 500; margin: 18px 0 0; line-height: 1.1; font-variant-numeric: tabular-nums; }
.unit { font-size: 22px; color: var(--fg2); }
.blink { animation: blink 1s ease-in-out infinite; }

.delta { font-size: 14px; border-radius: 8px; padding: 4px 12px; margin: 8px 0 16px; min-height: 30px; min-width: 120px; text-align: center; white-space: nowrap; }
.delta.ok { background: var(--ok-bg); color: var(--ok-fg); }
.delta.mid { background: var(--mid-bg); color: var(--mid-fg); }
.delta.bad { background: var(--bad-bg); color: var(--bad-fg); }
.delta.pop { animation: pop 0.45s cubic-bezier(0.3, 1.6, 0.5, 1); }

.hist { list-style: none; padding: 0; margin: 0; width: 100%; flex: 1; }
.hist li { display: flex; justify-content: space-between; font-size: 14px; color: var(--fg2); padding: 8px 0; border-top: 0.5px solid var(--line); }
.hist li.slide { animation: slide 0.4s ease-out; }

.actions { display: flex; gap: 10px; width: 100%; margin-top: 12px; }
.btn.icon { width: 52px; padding: 0; display: flex; align-items: center; justify-content: center; flex: none; }
.icon svg { width: 22px; height: 22px; }
#eye .on { display: none; }
#eye[aria-pressed="true"] .on { display: block; }
#eye[aria-pressed="true"] .off { display: none; }
.links { display: flex; justify-content: center; gap: 8px; margin-top: 8px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: 90vw;
  background: var(--fg);
  color: var(--bg);
  font-size: 14px;
  padding: 10px 16px;
  border-radius: 10px;
  margin: 0;
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes slide { 0% { transform: translateY(-10px); opacity: 0; } 100% { transform: translateY(0); opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
