:root {
  --bg: #14161a;
  --panel: #1e2127;
  --text: #eef0f3;
  --muted: #8b919c;
  --accent: #f5b301;
  --ok: #3ccf7a;
  --bad: #ef5350;
  color-scheme: dark;
}

* { box-sizing: border-box; }

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

main {
  max-width: 480px;
  margin: 0 auto;
  padding: calc(16px + env(safe-area-inset-top)) 20px calc(16px + env(safe-area-inset-bottom));
}

h1 { font-size: 1.4rem; margin: 0; letter-spacing: .02em; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.device { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .9rem; }
.device .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--muted); }
.device.online .dot { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.device.offline .dot { background: var(--bad); }

.gates { display: grid; gap: 28px; }

.gate { text-align: center; }

.gate .open {
  width: min(64vw, 240px);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 6px solid var(--accent);
  background: radial-gradient(circle at 50% 35%, #2a2e36, var(--panel));
  color: var(--text);
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: transform .08s ease, border-color .2s ease, opacity .2s;
  user-select: none;
}
.gate .open:active { transform: scale(.96); }
.gate .open:disabled { opacity: .6; cursor: progress; }
.gate .open .name { font-size: 1.6rem; font-weight: 700; }
.gate .open .hint { color: var(--muted); text-transform: uppercase; font-size: .8rem; letter-spacing: .12em; }

.gate.busy .open { border-color: var(--muted); animation: pulse 1s ease-in-out infinite; }
.gate.ok .open { border-color: var(--ok); }
.gate.fail .open { border-color: var(--bad); }

@keyframes pulse { 50% { border-color: var(--accent); } }

.gate .status { min-height: 1.4em; margin: 10px 0 0; color: var(--muted); }
.gate.ok .status { color: var(--ok); }
.gate.fail .status { color: var(--bad); }

form { display: grid; gap: 16px; margin-top: 32px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: .9rem; }
input {
  font: inherit;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid #333842;
  background: var(--panel);
  color: var(--text);
}
button.primary {
  font: inherit;
  font-weight: 600;
  padding: 14px;
  border: 0;
  border-radius: 10px;
  background: var(--accent);
  color: #1b1b1b;
}
.error { color: var(--bad); min-height: 1.4em; margin: 0; }

details { margin-top: 40px; background: var(--panel); border-radius: 12px; padding: 12px 16px; }
summary { cursor: pointer; color: var(--muted); }
#history { list-style: none; padding: 0; margin: 12px 0 0; font-size: .9rem; }
#history li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-top: 1px solid #2b2f37; }
#history .st-done { color: var(--ok); }
#history .st-failed, #history .st-expired, #history .st-unconfirmed { color: var(--bad); }

footer { display: flex; justify-content: space-between; align-items: center; margin-top: 24px; color: var(--muted); font-size: .9rem; }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; font: inherit; cursor: pointer; }
