:root {
  color-scheme: dark;
  --bg: #0b1120;
  --panel: #111827;
  --panel-strong: #172033;
  --border: #253348;
  --border-strong: #334155;
  --text: #f8fafc;
  --muted: #94a3b8;
  --muted-strong: #cbd5e1;
  --accent: #0ea5e9;
  --accent-strong: #0284c7;
  --danger: #ef4444;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  width: min(420px, 100vw);
  min-width: 320px;
  max-width: 420px;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-busy="true"] {
  cursor: progress;
}

body[data-busy="true"] .status-dot {
  animation: pulse 1s ease-in-out infinite;
}

main {
  display: grid;
  gap: 12px;
  padding: 18px;
}

header {
  display: grid;
  gap: 6px;
}

.logo {
  width: 40px;
  height: 40px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.15;
}

h2 {
  font-size: 17px;
  line-height: 1.25;
}

.eyebrow {
  color: #38bdf8;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.intro,
.hint,
.message {
  color: var(--muted);
}

.intro {
  max-width: 31ch;
}

.status-card,
.flow-card,
.settings {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.status-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
}

.status-dot {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
}

.status-dot[data-status="connected"] {
  background: #22c55e;
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.16);
}

.status-dot[data-status="disconnected"],
.status-dot[data-status="not_paired"] {
  background: #64748b;
  box-shadow: 0 0 0 4px rgba(100, 116, 139, 0.16);
}

.status-dot[data-status="error"] {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.16);
}

.status {
  color: var(--text);
  font-weight: 700;
}

.server-label {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.flow-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  background: var(--panel-strong);
}

.step-label {
  color: #7dd3fc;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

#flowDescription {
  color: var(--muted-strong);
}

.flow-actions,
.settings-actions {
  display: grid;
  gap: 8px;
}

.flow-actions {
  margin-top: 2px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted-strong);
  font-weight: 700;
}

input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  background: #0f172a;
  color: var(--text);
  font: inherit;
}

button {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 9px 12px;
  background: var(--accent);
  color: white;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:focus-visible,
summary:focus-visible,
input:focus-visible {
  outline: 2px solid #7dd3fc;
  outline-offset: 2px;
}

button.secondary,
button.ghost,
.link-button {
  border: 1px solid var(--border-strong);
  background: #1e293b;
  color: var(--text);
}

button.secondary:hover,
button.ghost:hover,
.link-button:hover {
  background: #26364f;
}

button.danger {
  color: #fecaca;
}

button.danger:hover {
  border-color: rgba(239, 68, 68, 0.55);
  background: rgba(127, 29, 29, 0.72);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.88;
}

.link-button {
  text-align: left;
}

.settings {
  padding: 12px;
}

.settings[open] {
  display: grid;
  gap: 12px;
}

.settings summary {
  color: var(--muted-strong);
  cursor: pointer;
  font-weight: 800;
}

.settings[open] summary {
  margin-bottom: 2px;
}

.settings-actions {
  margin-top: 2px;
}

.hint,
.message {
  font-size: 12px;
}

.message {
  min-height: 1.2em;
}

.message[data-tone="error"] {
  color: #fecaca;
}

.message[data-tone="success"] {
  color: #86efac;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    filter: saturate(1);
  }
  50% {
    transform: scale(1.08);
    filter: saturate(1.2);
  }
  100% {
    transform: scale(1);
    filter: saturate(1);
  }
}
