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

html, body {
  width: 600px;
  height: 600px;
  background: #000;          /* additive display: black = transparent */
  color: #fff;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 8px;
}
.hidden { display: none !important; }

/* ===================== BRAND / HEADER ===================== */
.hue-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font-size: 22px;
  background: radial-gradient(circle at 50% 38%, #fff3c4 0%, #ffb000 55%, #ff7a00 100%);
  flex: none;
}

.header {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 8px;
  margin-top: 16px;
  flex: none;
}
.header-title {
  font-size: 24px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.back-btn {
  width: 56px;
  height: 56px;
  font-size: 26px;
  background: #1c1e21;
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  flex: none;
}

/* ===================== CONTENT / LISTS ===================== */
.content {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.list-container {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: max-content;
  align-content: start;
  align-items: start;
  gap: 12px;
}

/* ===================== FOCUS STATE ===================== */
.focusable {
  outline: none;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  opacity: .9;
}
.focusable:focus {
  opacity: 1;
  transform: scale(1.03);
  box-shadow: 0 0 0 3px #00e5ff, 0 0 16px rgba(0,229,255,.6);
}

/* ===================== TILE CARDS (rooms / lights) ===================== */
.tile {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 100%;
  min-height: 120px;
  padding: 14px 14px 12px;
  background: #1c1e21;
  border: none;
  border-radius: 16px;
  color: #fff;
  text-align: left;
  cursor: pointer;
}
.tile.on {
  background: linear-gradient(150deg, #3a2a08 0%, #241c10 100%);
  box-shadow: inset 0 0 0 2px #ffb000;
}
.tile-icon { font-size: 30px; line-height: 1; }
.tile.on .tile-icon { filter: drop-shadow(0 0 8px rgba(255,176,0,.8)); }
.tile-name {
  font-size: 17px;
  font-weight: 700;
  margin-top: 10px;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-sub {
  font-size: 13px;
  color: #b0b3b8;
  margin-top: 4px;
}
.tile.on .tile-sub { color: #ffcf70; }

/* ===================== MENU / LOGOUT ===================== */
.menu-item {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  min-height: 72px;
  padding: 0 20px;
  background: #1c1e21;
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 20px;
  text-align: left;
  cursor: pointer;
  flex: none;
}
.menu-icon { font-size: 24px; flex: none; }
.menu-label { flex: 1; font-weight: 600; }
.menu-logout { background: #2a1416; }
.menu-logout .menu-label { color: #ff6b6b; }

/* ===================== ALL BAR (home) ===================== */
.all-bar { display: flex; gap: 10px; flex: none; }
.all-btn {
  flex: 1;
  height: 64px;
  border: none;
  border-radius: 14px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
}
.all-on { background: #3a2a08; box-shadow: inset 0 0 0 2px #ffb000; color: #ffcf70; }
.all-off { background: #1c1e21; }

/* ===================== CONTROL PANEL (group / light) ===================== */
.ctrl-panel {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 8px 8px;
}
.ctrl-toggle {
  height: 64px;
  border: none;
  border-radius: 14px;
  background: #1c1e21;
  color: #fff;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
}
.ctrl-toggle.on { background: #3a2a08; box-shadow: inset 0 0 0 2px #ffb000; color: #ffcf70; }
.ctrl-toggle.big { height: 96px; font-size: 26px; }

.dim-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.dim-btn {
  width: 72px;
  height: 64px;
  border: none;
  border-radius: 14px;
  background: #2a2d31;
  color: #fff;
  font-size: 34px;
  font-weight: 700;
  cursor: pointer;
  flex: none;
}
.dim-val {
  flex: 1;
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.dim-row.big .dim-btn { height: 84px; }
.dim-row.big .dim-val { font-size: 34px; }

.ctrl-extra { display: flex; gap: 10px; }
.ctrl-pill {
  flex: 1;
  height: 56px;
  border: none;
  border-radius: 14px;
  background: #2a2d31;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
}
.ctrl-pill.wide { width: 100%; height: 64px; font-size: 19px; }

/* ===================== PALETTE ===================== */
.swatch-label {
  font-size: 14px;
  color: #b0b3b8;
  font-weight: 600;
  margin: 4px 2px 0;
  flex: none;
}
.swatch-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  flex: none;
}
.swatch {
  height: 76px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
  font-size: 11px;
  font-weight: 700;
  color: rgba(0,0,0,.78);
  text-shadow: 0 1px 1px rgba(255,255,255,.35);
}

/* ===================== SCENES ===================== */
.scene-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 72px;
  padding: 0 18px;
  background: #1c1e21;
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 19px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  flex: none;
}
.scene-item .scene-icon { font-size: 24px; }

/* ===================== AUTH / KEYPAD ===================== */
.auth-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 12px 16px;
  overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 12px; margin: 8px 0 14px; }
.brand-name { font-size: 28px; font-weight: 700; }
.auth-hint { font-size: 15px; color: #b0b3b8; text-align: center; line-height: 1.45; margin-bottom: 8px; }
.auth-url { color: #ffb000; font-weight: 600; }

.code-display { display: flex; gap: 8px; margin: 14px 0; }
.code-cell {
  width: 52px;
  height: 64px;
  background: #1c1e21;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  font-weight: 700;
  color: #fff;
}
.code-cell.filled { background: #2a2d31; box-shadow: inset 0 0 0 2px #ffb000; }

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 84px);
  gap: 10px;
  margin-top: 6px;
}
.key {
  height: 64px;
  background: #1c1e21;
  border: none;
  border-radius: 12px;
  color: #fff;
  font-size: 26px;
  font-weight: 600;
  cursor: pointer;
}
.key-go { background: #ffb000; color: #1a1300; }
.key-alt { background: #2a2d31; }
.auth-status { margin-top: 12px; font-size: 14px; min-height: 18px; color: #ff6b6b; text-align: center; }
.auth-status.ok { color: #4ade80; }

/* ===================== STATES ===================== */
.state {
  position: absolute;
  inset: 80px 8px 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #b0b3b8;
  text-align: center;
  padding: 0 24px;
}
.spinner {
  width: 44px; height: 44px;
  border: 4px solid #2a2d31;
  border-top-color: #ffb000;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===================== TOAST ===================== */
.toast {
  position: absolute;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #1c1e21;
  color: #fff;
  padding: 12px 22px;
  border-radius: 999px;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  max-width: 520px;
  text-align: center;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { background: #3a1416; }
.toast.success { background: #14331f; }
