:root {
  --bg: #0b0d12;
  --card: rgba(20, 24, 34, 0.72);
  --card-solid: #141822;
  --card-2: #1a2030;
  --text: #e8ebf2;
  --muted: #8a93a6;
  --accent: #4f8cff;
  --accent-2: #8ab4ff;
  --danger: #ff5f6d;
  --ok: #7ce38b;
  --warn: #ffd479;
  --radius: 16px;
  --border: rgba(255, 255, 255, 0.09);
  --glass-blur: saturate(160%) blur(14px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(79, 140, 255, 0.14), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(138, 180, 255, 0.10), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#app {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
  gap: 16px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  position: sticky;
  top: 8px;
  z-index: 5;
}
h1 { font-size: 22px; font-weight: 800; letter-spacing: 0.02em; }
h1 span { color: var(--accent); }

.chip {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  white-space: nowrap;
  transition: color 0.2s, border-color 0.2s;
}
.chip.on { color: var(--ok); border-color: rgba(124, 227, 139, 0.35); }
.chip.warn { color: var(--warn); border-color: rgba(255, 212, 121, 0.35); }

main { display: flex; flex-direction: column; gap: 16px; flex: 1; }

.card {
  background: linear-gradient(180deg, var(--card), rgba(26, 32, 48, 0.72));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  animation: card-in 0.35s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.card:nth-child(2) { animation-delay: 0.05s; }
.card:nth-child(3) { animation-delay: 0.1s; }
.card:nth-child(4) { animation-delay: 0.15s; }

@keyframes card-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.card h2 { font-size: 15px; font-weight: 700; color: var(--accent-2); }
.card p.sub { font-size: 13px; color: var(--muted); line-height: 1.45; }

.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

input[type="text"], input[type="url"] {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 14px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.18);
}

input.code {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-align: center;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
}

button {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card-2);
  color: var(--text);
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s, border-color 0.15s, box-shadow 0.15s;
}
button:hover { background: #212a3e; border-color: var(--accent); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(79, 140, 255, 0.25);
}

button.primary {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 6px 20px rgba(79, 140, 255, 0.25);
}
button.primary:hover { background: var(--accent-2); box-shadow: 0 6px 24px rgba(79, 140, 255, 0.35); }

button.big { font-size: 17px; padding: 18px; }
button.danger { color: var(--danger); border-color: rgba(255, 95, 109, 0.4); }

button.candidate {
  font-weight: 500;
  font-size: 13px;
  padding: 12px 14px;
  color: var(--muted);
}
button.candidate:hover { color: var(--text); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.remote { display: flex; flex-direction: column; gap: 12px; }
.remote .row button { padding: 14px 0; }

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
  height: 28px;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}
input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  transition: transform 0.1s;
}
input[type="range"]::-webkit-slider-thumb:hover { transform: scale(1.15); }
input[type="range"]::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
}
input[type="range"]::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
}

.now-title {
  font-size: 14px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

footer { padding: 12px 0 env(safe-area-inset-bottom, 8px); }
.limit { font-size: 11px; color: var(--muted); text-align: center; line-height: 1.5; }

.status-msg { font-size: 13px; color: var(--muted); min-height: 18px; }
.status-msg.err { color: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
