:root {
  --bg: #0a0b0e;
  --surface: #12141a;
  --surface-2: #181b23;
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: #eceef2;
  --muted: #8b919d;
  --accent: #7fa982;
  --accent-bg: rgba(127, 169, 130, 0.16);
  --danger: #a63a3a;
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --font-sans: 'Plus Jakarta Sans', 'Inter', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
}

/* Login */
.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-mark {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
}

.login-brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-label {
  font-size: 13px;
  color: var(--muted);
}

.login-error {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(166, 58, 58, 0.18);
  border: 1px solid rgba(166, 58, 58, 0.45);
  color: #f3c4c4;
  font-size: 13px;
}

.login-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* App Shell */
.app-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 18px 42px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 20px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.topbar-left h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: #5a626a;
  transition: background 0.3s var(--ease);
}

.status-dot.is-awake {
  background: var(--accent);
}

.status-dot.is-sleep {
  background: #7c6a8a;
}

.status-dot.is-offline {
  background: var(--danger);
}

.status-pill,
.app-pill {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--muted);
}

.app-pill {
  color: var(--text);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Grid */
.studio-grid {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  .studio-grid {
    grid-template-columns: 1fr;
  }
}

.col-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.card {
  padding: 18px;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.card-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.subhead {
  margin-bottom: 10px;
}

.inline-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Buttons & Inputs */
.btn {
  appearance: none;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.18s var(--ease), transform 0.14s var(--ease), border-color 0.18s var(--ease);
}

.btn:hover {
  background: #20242f;
}

.btn:active {
  transform: scale(0.97);
}

.btn--primary {
  background: var(--text);
  color: #0a0b0e;
  border-color: var(--text);
}

.btn--primary:hover {
  background: #ffffff;
}

.btn--secondary {
  background: var(--surface-2);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}

.btn--ghost:hover,
.btn--ghost[aria-pressed="true"] {
  color: var(--text);
  background: var(--surface-2);
  border-color: var(--border-strong);
}

.btn--sm {
  padding: 6px 11px;
  font-size: 12px;
  border-radius: 8px;
}

.btn--full {
  width: 100%;
}

.input {
  width: 100%;
  background: #0d0f14;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border-radius: 10px;
  outline: none;
  transition: border-color 0.2s var(--ease);
}

.input:focus {
  border-color: rgba(236, 238, 242, 0.45);
}

/* Segmented */
.segmented {
  display: inline-flex;
  background: #0d0f14;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px;
  gap: 2px;
}

.seg-btn {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 0.18s var(--ease), color 0.18s var(--ease);
}

.seg-btn.active {
  background: var(--surface-2);
  color: var(--text);
}

/* Now Playing / Lyrics */
.np-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.np-cover {
  width: 52px;
  height: 52px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

.np-meta {
  flex: 1;
  min-width: 140px;
}

.np-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.np-artist {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Remote Control */
.remote-stage {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.dpad {
  position: relative;
  width: 176px;
  height: 176px;
  border-radius: 999px;
  background: #0d0f14;
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
  margin: 0 auto;
}

.dpad-btn {
  position: absolute;
  width: 48px;
  height: 48px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  border-radius: 999px;
  display: grid;
  place-items: center;
  transition: color 0.15s var(--ease), background 0.15s var(--ease), transform 0.12s var(--ease);
}

.dpad-btn:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

.dpad-btn:active {
  transform: scale(0.92);
}

.dpad-up { top: 8px; left: 50%; transform: translateX(-50%); }
.dpad-down { bottom: 8px; left: 50%; transform: translateX(-50%); }
.dpad-left { left: 8px; top: 50%; transform: translateY(-50%); }
.dpad-right { right: 8px; top: 50%; transform: translateY(-50%); }

.dpad-ok {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 62px;
  height: 62px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.16s var(--ease), transform 0.12s var(--ease);
}

.dpad-ok:hover {
  background: #232734;
}

.dpad-ok:active {
  transform: translate(-50%, -50%) scale(0.94);
}

.remote-side {
  flex: 1;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.nav-row,
.media-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.slider-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.slider-row {
  display: flex;
  justify-content: space-between;
  font-size: 12.5px;
}

.slider-label {
  color: var(--muted);
}

.slider-val {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.range {
  width: 100%;
  accent-color: var(--text);
  cursor: pointer;
}

/* Text / URL */
.text-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.text-row .input {
  flex: 1;
  min-width: 180px;
}

/* Screen Preview */
.screen-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  background: #07080c;
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
}

.screen-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.screen-empty {
  color: var(--muted);
  font-size: 13px;
}

/* Apps & Inputs */
.chip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.chip-grid--4 {
  grid-template-columns: repeat(4, 1fr);
}

@media (max-width: 520px) {
  .chip-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .chip-grid--4 {
    grid-template-columns: repeat(2, 1fr);
  }
}

.chip-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 11px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.16s var(--ease), border-color 0.16s var(--ease), transform 0.12s var(--ease);
}

.chip-btn:hover {
  background: #20242f;
  border-color: var(--border-strong);
}

.chip-btn:active {
  transform: scale(0.97);
}

.divider {
  height: 1px;
  background: var(--border);
  margin: 14px 0;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  padding: 10px 16px;
  border-radius: 999px;
  background: #1b1f29;
  border: 1px solid var(--border-strong);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}
