:root {
  --bg: #0f1720;
  --panel: #17212c;
  --line: #263344;
  --text: #e8eef5;
  --muted: #8fa1b5;
  --accent: #f5b83d;
  --accent-ink: #1b1405;
  --ok: #4cc38a;
  --bad: #ef6b6b;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; letter-spacing: 0.02em; }
.header-actions { display: flex; gap: 4px; }

.pending {
  display: grid;
  gap: 10px;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.pending .meta { color: var(--muted); font-size: 14px; }
.pending .meta strong { color: var(--text); font-family: ui-monospace, monospace; font-size: 16px; }
.pending form { grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.pending input { text-transform: uppercase; letter-spacing: 0.15em; font-family: ui-monospace, monospace; }
.brand span { color: var(--muted); font-weight: 400; margin-left: 6px; }

main { max-width: 480px; margin: 0 auto; padding: 18px 18px 48px; }

.steps {
  display: flex;
  gap: 4px;
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  font-size: 12px;
  color: var(--muted);
}
.steps li { flex: 1; text-align: center; padding-top: 8px; border-top: 3px solid var(--line); }
.steps li.done { border-color: var(--ok); color: var(--text); }
.steps li.current { border-color: var(--accent); color: var(--text); font-weight: 600; }

h1 { font-size: 22px; margin: 0 0 6px; }
.hint { color: var(--muted); margin: 0 0 18px; }

form { display: grid; gap: 14px; }
label { display: grid; gap: 6px; font-size: 14px; color: var(--muted); }
label.inline { display: flex; align-items: center; gap: 8px; }

input {
  font: inherit;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
}
input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
input[name="code"] { text-transform: uppercase; letter-spacing: 0.2em; font-family: ui-monospace, monospace; }

button {
  font: inherit;
  font-weight: 600;
  border: 0;
  border-radius: 10px;
  padding: 13px 16px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
}
button:disabled { opacity: 0.5; cursor: progress; }
button.secondary { background: var(--panel); color: var(--text); border: 1px solid var(--line); width: 100%; margin-top: 18px; }
button.link { background: none; color: var(--muted); padding: 4px 6px; font-weight: 400; }

.choices { display: grid; gap: 8px; margin-bottom: 18px; }
.choice {
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: left;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  font-weight: 500;
}
.choice small { color: var(--muted); font-weight: 400; }

.notice { background: #2a2312; border: 1px solid #5a4a1f; color: #f3dca4; border-radius: 10px; padding: 12px 14px; }
.notice.ok { background: #12291f; border-color: #1f5a3f; color: #b5ecd0; }
.error { background: #2c1717; border: 1px solid #6b2a2a; color: #ffc9c9; border-radius: 10px; padding: 12px 14px; margin-top: 18px; }
.progress { color: var(--muted); }
.progress::before { content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 8px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

.confirm-actions { display: grid; gap: 10px; margin-top: 16px; }
.confirm-actions .secondary { margin-top: 0; }

.device-line { color: var(--muted); font-family: ui-monospace, monospace; font-size: 14px; margin: 0 0 16px; }

.code-card {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 22px;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
}
.code-card span, .code-card small { color: var(--muted); font-size: 13px; }
.code-card strong { font: 700 40px/1.2 ui-monospace, monospace; letter-spacing: 0.12em; color: var(--accent); }

.channel {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px 12px;
  align-items: center;
  padding: 14px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
}
.channel .number { font-weight: 700; color: var(--muted); }
.channel .label-row { display: flex; gap: 8px; }
.channel .label-row input { flex: 1; min-width: 0; padding: 10px 12px; }
.channel .label-row button { padding: 10px 12px; min-width: 96px; }
.channel .actions { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr 56px; gap: 8px; align-items: center; }
.channel .actions button { padding: 10px; min-width: 0; }
.channel .actions .off { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.state { font-size: 13px; color: var(--muted); text-align: right; }
.state.on { color: var(--ok); }
