:root {
  --bg: #010407;
  --panel: rgba(7, 18, 26, .84);
  --panel-deep: rgba(4, 12, 18, .92);
  --text: #f8fbff;
  --muted: #9aa7b3;
  --soft: rgba(255,255,255,.08);
  --blue: #0b8cff;
  --green: #16e13d;
  --orange: #ff8a00;
  --red: #ff111b;
  --purple: #7a00d8;
  --white: #f4f4f0;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(circle at 50% -20%, #08131f 0%, #02060b 42%, #000 100%);
  color: var(--text);
  font-family: Inter, ui-rounded, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input {
  font: inherit;
}

.app {
  width: min(430px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
}

.header {
  position: relative;
  padding: 8px 4px 18px;
}

.clock {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -.04em;
}

.status-icons {
  position: absolute;
  right: 4px;
  top: 10px;
  color: #fff;
  font-size: 12px;
  opacity: .92;
}

.brand {
  margin-top: 22px;
}

h1 {
  margin: 0;
  font-size: 34px;
  line-height: .95;
  letter-spacing: -.07em;
}

.brand p {
  margin: 7px 0 8px;
  color: var(--muted);
  font-size: 17px;
  font-weight: 700;
}

.api-dot {
  font-size: 17px;
  font-weight: 900;
  color: var(--green);
}

.api-dot.off {
  color: #ffcc38;
}

.header-actions {
  position: absolute;
  right: 2px;
  bottom: 24px;
  display: flex;
  gap: 18px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 34px;
  line-height: 1;
}

.cards {
  display: grid;
  gap: 13px;
}

.card {
  --accent: var(--blue);
  border: 1.5px solid color-mix(in srgb, var(--accent), transparent 16%);
  border-radius: 18px;
  padding: 14px;
  background:
    radial-gradient(circle at 18% 18%, color-mix(in srgb, var(--accent), transparent 78%), transparent 38%),
    linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.012)),
    var(--panel);
  box-shadow:
    inset 0 0 34px color-mix(in srgb, var(--accent), transparent 86%),
    0 0 18px color-mix(in srgb, var(--accent), transparent 82%),
    0 20px 50px rgba(0,0,0,.38);
}

.card.office { --accent: var(--green); }
.card.kitchen { --accent: var(--orange); }

.card-top {
  display: grid;
  grid-template-columns: 66px 1fr auto;
  gap: 14px;
  align-items: center;
}

.card-icon {
  width: 62px;
  height: 62px;
  border-radius: 17px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent), #fff 10%), color-mix(in srgb, var(--accent), #000 20%));
  box-shadow: 0 0 26px color-mix(in srgb, var(--accent), transparent 55%);
  font-size: 31px;
}

.card h2 {
  margin: 0;
  font-size: 25px;
  letter-spacing: -.04em;
}

.device-count {
  margin-top: 3px;
  color: var(--muted);
  font-size: 18px;
  font-weight: 800;
}

.switch {
  width: 76px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  padding: 4px;
  background: color-mix(in srgb, var(--accent), #000 8%);
  box-shadow: inset 0 0 20px rgba(255,255,255,.16), 0 0 22px color-mix(in srgb, var(--accent), transparent 62%);
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.switch .knob {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0,0,0,.35);
}

.switch.excluded {
  justify-content: flex-start;
  filter: grayscale(.85) brightness(.62);
}

.slider-row {
  margin-top: 14px;
  display: grid;
  grid-template-columns: 48px 1fr 54px;
  gap: 12px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.035);
}

.sun {
  color: var(--accent);
  font-size: 27px;
  text-align: center;
  text-shadow: 0 0 12px var(--accent);
}

.percent {
  text-align: right;
  font-size: 20px;
  font-weight: 900;
}

input[type="range"] {
  width: 100%;
  appearance: none;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent) var(--pct, 70%), rgba(255,255,255,.16) var(--pct, 70%));
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid color-mix(in srgb, var(--accent), white 30%);
  box-shadow: 0 0 15px color-mix(in srgb, var(--accent), transparent 35%);
}

.preset-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.preset {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  color: #fff;
  font-size: 15px;
  font-weight: 900;
  box-shadow: 0 0 18px rgba(255,255,255,.10);
}

.preset.red { background: linear-gradient(145deg, #ff171d, #9d0007); }
.preset.green { background: linear-gradient(145deg, #14ed3b, #006a11); }
.preset.blue { background: linear-gradient(145deg, #0e65ff, #002aaf); }
.preset.purple { background: linear-gradient(145deg, #9f18ff, #5a0088); }
.preset.white { background: linear-gradient(145deg, #fff, #cfcfcf); color: #111; }

.bottom {
  margin-top: 14px;
  padding: 10px 12px 8px;
  border-radius: 18px;
  background: rgba(255,255,255,.035);
  box-shadow: inset 0 0 24px rgba(255,255,255,.035);
}

.last-line {
  min-height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.08);
  display: grid;
  grid-template-columns: 24px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

#lastCommand strong,
.last-line .hot {
  color: var(--blue);
}

.tabs {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}

.tab {
  text-align: center;
  color: #9aa0a8;
  font-size: 26px;
  font-weight: 800;
}

.tab span {
  display: block;
  margin-top: 2px;
  font-size: 12px;
}

.tab.active {
  color: var(--blue);
}

@media (max-height: 760px) {
  .brand { margin-top: 12px; }
  h1 { font-size: 30px; }
  .card { padding: 12px; }
  .card-icon { width: 54px; height: 54px; }
  .card-top { grid-template-columns: 58px 1fr auto; }
  .slider-row { margin-top: 10px; }
  .preset-row { margin-top: 10px; }
}


/* Phase 4B: dead chrome removed */
.header,
.clock,
.status-icons,
.brand,
.header-actions,
.tabs,
.tab {
  display: none !important;
}

.cards {
  padding-top: 0;
}

.card:first-child {
  margin-top: 0;
}

.bottom {
  margin-top: 12px;
}

.last-line {
  font-size: 14px;
}

.top-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 12px;
}

.top-tab {
  border: 1px solid rgba(255,255,255,.09);
  border-radius: 14px;
  min-height: 42px;
  background: rgba(255,255,255,.045);
  color: #9aa7b3;
  font-size: 13px;
  font-weight: 900;
}

.top-tab.active {
  color: #fff;
  border-color: rgba(11,140,255,.95);
  background: linear-gradient(145deg, rgba(11,140,255,.28), rgba(11,140,255,.08));
  box-shadow: 0 0 18px rgba(11,140,255,.22);
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.edit-list {
  display: grid;
  gap: 12px;
}

.editor-card {
  border: 1.5px solid rgba(11,140,255,.75);
  border-radius: 18px;
  padding: 14px;
  background: rgba(7,18,26,.84);
  box-shadow: inset 0 0 34px rgba(11,140,255,.12), 0 20px 50px rgba(0,0,0,.38);
}

.editor-card h2 {
  margin: 0 0 8px;
  font-size: 22px;
}

.editor-row {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.editor-row label {
  color: #9aa7b3;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.editor-row input,
.editor-row select {
  width: 100%;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 12px;
  background: rgba(0,0,0,.32);
  color: #fff;
  padding: 11px 12px;
  font-weight: 800;
}

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

.action-btn {
  border: 0;
  border-radius: 12px;
  min-height: 42px;
  color: #fff;
  background: linear-gradient(145deg, #0b8cff, #004eb3);
  font-weight: 950;
}

.action-btn.secondary {
  background: rgba(255,255,255,.08);
}

.member-list {
  display: grid;
  gap: 7px;
  margin-top: 10px;
}

.member {
  display: grid;
  grid-template-columns: 26px 1fr;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  color: #dce8f4;
  font-weight: 800;
}

.muted {
  color: #9aa7b3;
  font-weight: 700;
}
