:root {
  --bg: #0a0a12;
  --tile-bg-1: #1a1a28;
  --tile-bg-2: #14141f;
  --tile-bg-active: #1f1f30;
  --text: #e8e8ee;
  --text-dim: #888;
  --text-muted: #666;
  --border: #2a2a3a;
  --status-new: #555;
  --status-conn: #d49a3a;
  --status-ok: #4ade80;
  --status-off: #c43a3a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overscroll-behavior-y: contain;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  padding: env(safe-area-inset-top, 16px) 16px env(safe-area-inset-bottom, 16px);
}

button { font: inherit; color: inherit; cursor: pointer; }

/* List screen */

.app-header {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-dim);
  padding: 4px 4px 16px;
}

.tile {
  background: linear-gradient(135deg, var(--tile-bg-1) 0%, var(--tile-bg-2) 100%);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s;
}
.tile:active { border-color: var(--border); }

.tile-glow {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.2s, box-shadow 0.2s;
}

.tile-name {
  flex: 1;
  font-size: 14px;
}

.tile-meta {
  font-size: 11px;
  color: var(--text-dim);
}

.tile-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--status-new);
  flex-shrink: 0;
}
.tile-status.connecting { background: var(--status-conn); }
.tile-status.connected { background: var(--status-ok); }
.tile-status.offline { background: var(--status-off); }

.tile.off .tile-name { color: var(--text-muted); }

/* Empty / unsupported state */

.empty, .unsupported {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}
.empty .cta {
  display: inline-block;
  margin-top: 16px;
  padding: 12px 24px;
  background: var(--border);
  color: var(--text);
  border-radius: 24px;
  border: none;
}

.toolbar {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}
.toolbar button {
  flex: 1;
  background: var(--tile-bg-1);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 12px;
  font-size: 13px;
}

/* Detail screen */

.detail-back {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  padding: 8px 0;
}

.detail-title {
  text-align: center;
  font-size: 16px;
  font-weight: 600;
  margin: 8px 0 4px;
}
.detail-sub {
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 20px;
}

.detail-glow {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  margin: 0 auto 24px;
  transition: background 0.2s, box-shadow 0.2s;
}

.wheel-wrap {
  position: relative;
  width: 220px;
  height: 220px;
  margin: 0 auto 20px;
  touch-action: none;
}
.wheel {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, var(--bg) 0, var(--bg) 35%, transparent 35%),
    conic-gradient(from 90deg, red, yellow, lime, cyan, blue, magenta, red);
  cursor: pointer;
}
.wheel-pin {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  border: 3px solid currentColor;
  pointer-events: none;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px rgba(0,0,0,0.5);
}

.swatch-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 20px;
}
.swatch {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 2px solid var(--border);
  cursor: pointer;
}

.label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin: 8px 0 6px;
}

.bright-slider {
  width: 100%;
  height: 8px;
  appearance: none;
  background: var(--border);
  border-radius: 4px;
  outline: none;
}
.bright-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  background: var(--text);
  border-radius: 50%;
  cursor: pointer;
}

.power-toggle {
  display: block;
  margin: 24px auto 0;
  padding: 14px 32px;
  border-radius: 28px;
  border: none;
  background: var(--tile-bg-1);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
}
.power-toggle.on {
  background: var(--status-ok);
  color: #0a0a12;
}

.detail-offline-banner {
  background: var(--status-off);
  color: white;
  padding: 10px;
  text-align: center;
  border-radius: 8px;
  margin-bottom: 16px;
  font-size: 13px;
}

.detail-controls.disabled {
  opacity: 0.4;
  pointer-events: none;
}

/* Modal */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal {
  background: var(--tile-bg-1);
  padding: 20px;
  border-radius: 14px;
  width: 90%;
  max-width: 320px;
  border: 1px solid var(--border);
}
.modal h3 { margin-top: 0; font-size: 15px; }
.modal input {
  width: 100%;
  padding: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 14px;
  margin: 8px 0 16px;
}
.modal-buttons { display: flex; gap: 8px; }
.modal-buttons button {
  flex: 1;
  padding: 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--tile-bg-2);
  color: var(--text);
  font-size: 13px;
}
.modal-buttons button.primary { background: var(--status-ok); color: #0a0a12; border-color: var(--status-ok); }
