:root {
  color-scheme: light;
  --bg-1: #10131d;
  --bg-2: #1c2334;
  --bg-3: #2c2f3f;
  --accent: #f8b74a;
  --accent-2: #63d0ff;
  --accent-3: #8c72ff;
  --text: #f3f4f7;
  --muted: #c2c7d6;
  --card: rgba(19, 23, 34, 0.75);
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 20px 60px rgba(3, 6, 16, 0.45);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Space Grotesk', sans-serif;
  /* Background theme lives in bg-studio.css */
  background: radial-gradient(circle at top, #2c3c5c 0%, #151823 45%, #0c0f17 100%);
  color: var(--text);
  min-height: 100vh;
}

.backdrop {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(60% 60% at 15% 20%, rgba(99, 208, 255, 0.18), transparent 60%),
    radial-gradient(50% 50% at 80% 10%, rgba(248, 183, 74, 0.2), transparent 55%),
    radial-gradient(40% 40% at 70% 80%, rgba(140, 114, 255, 0.12), transparent 60%);
  z-index: -1;
}

.app {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--border);
  padding: 18px 22px;
  border-radius: 20px;
  box-shadow: var(--shadow);
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-family: 'Unbounded', sans-serif;
  font-weight: 700;
  background: linear-gradient(140deg, var(--accent), #ffde8a);
  color: #2b2004;
}

.brand-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 18px;
}

.brand-subtitle {
  color: var(--muted);
  font-size: 14px;
}

.connect {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.obs-connect-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.manual-connect {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.helper-bridge {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid rgba(99, 208, 255, 0.18);
  background: rgba(13, 21, 37, 0.88);
}

.helper-bridge-copy {
  display: grid;
  gap: 3px;
  min-width: min(360px, 100%);
}

.helper-bridge-title {
  font-size: 13px;
  font-weight: 700;
}

.helper-bridge-subtitle {
  color: var(--muted);
  font-size: 12px;
  max-width: 420px;
}

/* When Stream Control manages OBS, hide connect buttons/fields */
body.managed .connect #autoConnectBtn,
body.managed .connect #manualConnectToggle,
body.managed .connect #manualConnect {
  display: none !important;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.field input,
.field select {
  background: rgba(15, 18, 28, 0.85);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 210px;
}

.btn {
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 18px;
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 600;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.btn.primary {
  background: linear-gradient(130deg, var(--accent), #ffda7b);
  color: #2c2106;
}

.btn.ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text);
}

.btn.subtle {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.1);
}

.btn.danger {
  background: rgba(248, 94, 74, 0.16);
  border-color: rgba(248, 94, 74, 0.4);
  color: #ffd9d2;
}

.btn.small {
  padding: 6px 10px;
  font-size: 12px;
}

.file-btn input {
  display: none;
}

.status {
  font-size: 13px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
}

.status.connected {
  background: rgba(88, 255, 140, 0.16);
  border-color: rgba(88, 255, 140, 0.55);
  box-shadow:
    0 0 0 1px rgba(88, 255, 140, 0.14),
    0 0 16px rgba(88, 255, 140, 0.16);
  color: rgba(210, 255, 226, 0.95);
}

.panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
}

.panel-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
}

.panel-label {
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.panel-value {
  font-size: 18px;
  margin-top: 6px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

.deck-panel,
.editor {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow);
}

/* Put the editor below the deck */
.editor {
  order: 2;
}

.deck-panel {
  order: 1;
}

.deck-header,
.editor-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.section-title {
  font-family: 'Unbounded', sans-serif;
  font-size: 16px;
}

.section-subtitle {
  color: var(--muted);
  font-size: 13px;
}

.deck-controls,
.editor-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

body.hosted-deck .obs-connect-controls {
  display: none !important;
}

body.hosted-deck .helper-bridge {
  display: flex !important;
}

body.hosted-deck #refreshObsBtn {
  display: none;
}

.mode-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(0, 0, 0, 0.2);
}

.mode-toggle-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 54px;
  height: 30px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  transition: 0.2s;
  border-radius: 999px;
}

.slider:before {
  position: absolute;
  content: "";
  height: 22px;
  width: 22px;
  left: 4px;
  top: 3px;
  background: rgba(255, 255, 255, 0.92);
  transition: 0.2s;
  border-radius: 999px;
}

/* Live (unchecked) = red */
.mode-live .mode-toggle {
  border-color: rgba(248, 94, 74, 0.5);
  box-shadow: 0 0 0 2px rgba(248, 94, 74, 0.15);
}

.mode-live .mode-toggle-label:first-child {
  color: #ffd9d2;
}

.mode-live .slider {
  background: rgba(248, 94, 74, 0.25);
  border-color: rgba(248, 94, 74, 0.55);
}

/* Edit (checked) = accent */
.mode-edit .mode-toggle {
  border-color: rgba(99, 208, 255, 0.45);
  box-shadow: 0 0 0 2px rgba(99, 208, 255, 0.12);
}

.mode-edit .mode-toggle-label:last-child {
  color: rgba(99, 208, 255, 0.95);
}

.mode-edit .slider {
  background: rgba(99, 208, 255, 0.25);
  border-color: rgba(99, 208, 255, 0.55);
}

.switch input:checked + .slider:before {
  transform: translateX(24px);
}

.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-columns, 4), minmax(140px, 1fr));
  gap: 16px;
}

.deck-layout-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.deck-layout-card {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.22);
}

.deck-layout-fields {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.field.compact {
  min-width: unset;
}

.field.compact select {
  min-width: 76px;
  padding: 8px 10px;
}

.deck-btn.placeholder {
  background: rgba(18, 22, 34, 0.35);
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.22);
}

.deck-btn.placeholder:hover {
  transform: none;
  border-color: rgba(99, 208, 255, 0.55);
  box-shadow: 0 0 0 2px rgba(99, 208, 255, 0.15);
}

.deck-btn.placeholder .label {
  top: 10px;
  left: 10px;
  right: auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  font-size: 26px;
  padding: 0;
}

.deck-btn.placeholder .hotkey {
  left: auto;
  right: 10px;
  bottom: 10px;
}

.deck-btn {
  position: relative;
  border: 3px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px;
  aspect-ratio: 1 / 1;
  width: 100%;

  /* hover shimmer only (no cursor tracking) */

  /* Base "hardware" look (embossed / inset into the deck) */
  background: rgba(18, 22, 34, 0.82);
  color: var(--text);
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;

  box-shadow:
    /* subtle outer drop */
    0 14px 30px rgba(0, 0, 0, 0.45),
    /* subtle purple glow (round, visible but not huge) */
    0 0 0 1px rgba(140, 114, 255, 0.10),
    0 0 16px rgba(140, 114, 255, 0.18),
    0 0 28px rgba(140, 114, 255, 0.10),
    /* rim highlight */
    0 1px 0 rgba(255, 255, 255, 0.10),
    /* inset emboss */
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    /* edge shading (like the placeholder tiles) */
    inset 0 -16px 34px rgba(0, 0, 0, 0.32),
    inset 14px 0 26px rgba(0, 0, 0, 0.16),
    inset -14px 0 26px rgba(0, 0, 0, 0.12);

  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.2s ease;
}

.deck-btn.has-image {
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

/* Hover shimmer (diagonal glimmer) */
.deck-btn::after {
  content: '';
  position: absolute;
  inset: -60%;
  z-index: 1;
  pointer-events: none;

  opacity: 0;

  /* wider, softer diagonal glimmer band */
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.00) 30%,
    rgba(255, 255, 255, 0.10) 42%,
    rgba(255, 255, 255, 0.28) 50%,
    rgba(255, 255, 255, 0.10) 58%,
    rgba(255, 255, 255, 0.00) 70%
  );

  transform: translateX(-85%) translateY(-75%) rotate(0deg);
  mix-blend-mode: screen;
}

.deck-btn:hover::after {
  opacity: 1;
  /* normal through mid, then ease-out feel */
  animation: deck-shimmer 900ms linear both;
}

@keyframes deck-shimmer {
  0% {
    transform: translateX(-85%) translateY(-75%);
    opacity: 0.75;
  }
  /* start immediately */
  6% {
    transform: translateX(-68%) translateY(-58%);
    opacity: 1;
  }
  /* "normal" mid travel */
  60% {
    transform: translateX(40%) translateY(34%);
    opacity: 0.55;
  }
  /* ease-out: smaller moves near the end */
  78% {
    transform: translateX(62%) translateY(54%);
    opacity: 0.22;
  }
  90% {
    transform: translateX(74%) translateY(66%);
    opacity: 0.10;
  }
  100% {
    transform: translateX(85%) translateY(75%);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .deck-btn:hover::after { animation: none; opacity: 0.25; transform: translateX(0) translateY(0); }
}

.deck-btn.has-image::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    /* base darkening for readability */
    linear-gradient(
      180deg,
      rgba(0, 0, 0, 0.55) 0%,
      rgba(0, 0, 0, 0.2) 45%,
      rgba(0, 0, 0, 0.6) 100%
    );
  pointer-events: none;
  transition: filter 0.15s ease, opacity 0.15s ease;
}

/* (removed) extra hover sheen for image buttons — cursor-follow sheen handles hover feedback */

/* Default "glass" style for buttons without an uploaded image */
.deck-btn.no-image {
  /* Gradient + subtle white center glow */
  background:
    radial-gradient(55% 55% at 50% 45%, rgba(255, 255, 255, 0.20), transparent 62%),
    radial-gradient(120% 120% at 20% 15%, rgba(255, 255, 255, 0.16), transparent 40%),
    radial-gradient(120% 120% at 80% 90%, rgba(255, 255, 255, 0.10), transparent 45%),
    linear-gradient(135deg, var(--deck-grad-1, #63d0ff), var(--deck-grad-2, #8c72ff) 55%, var(--deck-grad-3, #f8b74a));
}

/* Glass overlay: single arced shine + sheen */
.deck-btn.no-image::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    /* top-left glass sheen */
    linear-gradient(155deg, rgba(255, 255, 255, 0.26) 0%, rgba(255, 255, 255, 0.08) 36%, rgba(0, 0, 0, 0.12) 100%),
    /* one arced highlight ("shine line") */
    radial-gradient(120% 70% at 35% 10%, rgba(255, 255, 255, 0.35) 0%, rgba(255, 255, 255, 0.18) 14%, rgba(255, 255, 255, 0.00) 30%),
    radial-gradient(60% 40% at 25% 20%, rgba(255, 255, 255, 0.14), transparent 60%),
    radial-gradient(60% 40% at 80% 85%, rgba(0, 0, 0, 0.18), transparent 60%);

  /* thicker border w/ ~30% opacity */
  border: 2px solid rgba(255, 255, 255, 0.30);

  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -16px 34px rgba(0, 0, 0, 0.20);

  pointer-events: none;
  transition: filter 0.15s ease;
}

/* (removed) extra hover sheen for no-image buttons — cursor-follow sheen handles hover feedback */

/* Big label used as the "graphic" (solid, readable) */
.deck-btn .bg-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  z-index: 0;

  font-family: 'Arial Narrow', 'Roboto Condensed', 'Unbounded', sans-serif;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.0;
  text-wrap: balance;

  /* big, but stays within the button */
  font-size: clamp(18px, 3.4vw, 36px);

  color: rgba(255, 255, 255, 0.92);
  text-shadow:
    0 10px 28px rgba(0, 0, 0, 0.40),
    0 1px 0 rgba(255, 255, 255, 0.10);

  opacity: 0.92;
  transform: translateY(-4px);

  /* keep it inside */
  overflow: hidden;
  white-space: nowrap;
  word-break: normal;
  hyphens: none;
  text-overflow: clip;

  pointer-events: none;
  user-select: none;
}

.deck-btn.no-image .label {
  color: var(--deck-text, #0b1220);
}

.deck-btn:hover {
  transform: translateY(-3px);
  border-color: rgba(255, 255, 255, 0.24);
  box-shadow:
    0 22px 56px rgba(0, 0, 0, 0.60),
    /* lift glow */
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 0 22px rgba(140, 114, 255, 0.16),
    /* rim highlight */
    0 1px 0 rgba(255, 255, 255, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    /* edge shading */
    inset 0 -16px 34px rgba(0, 0, 0, 0.24),
    inset 14px 0 26px rgba(0, 0, 0, 0.12),
    inset -14px 0 26px rgba(0, 0, 0, 0.10);
}

.deck-btn.dragging {
  opacity: 0.6;
  transform: scale(0.98);
}

.deck-btn.drop-target {
  box-shadow: 0 0 0 3px rgba(99, 208, 255, 0.4);
}

.deck-btn.running {
  border-color: rgba(248, 183, 74, 0.8);
  box-shadow:
    0 0 0 2px rgba(248, 183, 74, 0.2),
    inset 0 0 0 999px rgba(248, 183, 74, 0.06);
}

/* spider removed */
/* Small delete X (Edit mode) */
.deck-del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 9px;

  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 3;

  background: rgba(248, 94, 74, 0.18);
  border: 1px solid rgba(248, 94, 74, 0.55);
  color: rgba(248, 94, 74, 0.95);

  /* center the glyph properly */
  font-size: 18px;
  line-height: 1;
  font-weight: 900;
  padding: 0;

  cursor: pointer;
  opacity: 0.0;
  transform: translateY(-2px) scale(0.96);
  transition: opacity 0.12s ease, transform 0.12s ease, background 0.12s ease;
}

.deck-jump {
  position: absolute;
  top: 8px;
  right: 38px;
  width: 26px;
  height: 26px;
  border-radius: 9px;

  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 3;

  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(0, 0, 0, 0.55);
  color: rgba(240, 245, 255, 0.95);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);

  font-size: 16px;
  line-height: 1;
  font-weight: 900;
  padding: 0;

  cursor: pointer;
  opacity: 0.0;
  transform: translateY(-2px) scale(0.96);
  transition: opacity 0.12s ease, transform 0.12s ease, background 0.12s ease;
}

.mode-edit .deck-btn:hover .deck-del,
.mode-edit .deck-btn.selected .deck-del,
.mode-edit .deck-btn:hover .deck-jump,
.mode-edit .deck-btn.selected .deck-jump {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.deck-del:hover {
  background: rgba(248, 94, 74, 0.95);
  border-color: rgba(248, 94, 74, 0.95);
  color: #ffffff;
}

.deck-jump:hover {
  background: rgba(99, 208, 255, 0.95);
  border-color: rgba(99, 208, 255, 0.95);
  color: #0b0f17;
}

.deck-btn.selected {
  border-color: rgba(99, 208, 255, 0.8);
  box-shadow:
    0 0 0 2px rgba(99, 208, 255, 0.2),
    inset 0 0 0 999px rgba(99, 208, 255, 0.06);
}

/* Active program scene (only applies to buttons with a Switch Scene action) */
.deck-btn.active-scene {
  border-color: rgba(88, 255, 140, 0.95);
  box-shadow:
    0 0 0 2px rgba(88, 255, 140, 0.25),
    0 18px 50px rgba(0, 0, 0, 0.55);
}

/* Make the active SCENE button slightly larger in Live mode only */
.mode-live .deck-btn.active-scene {
  transform: scale(1.12);
  z-index: 2;
}

/* Active scene: border/glow only (no overlay tint) */

.deck-btn.active-scene .label {
  border-color: rgba(88, 255, 140, 0.35);
}

/* Buttons that affect sources in the active scene */
.deck-btn.scene-related {
  border-color: rgba(99, 208, 255, 0.28);
}

.deck-btn.scene-related.source-off {
  border-color: rgba(248, 94, 74, 0.8);
  box-shadow:
    0 0 0 2px rgba(248, 94, 74, 0.18),
    inset 0 0 0 999px rgba(248, 94, 74, 0.06);
}

.deck-btn.scene-related.source-on {
  border-color: rgba(99, 208, 255, 0.9);
  box-shadow:
    0 0 0 2px rgba(99, 208, 255, 0.18),
    inset 0 0 0 999px rgba(99, 208, 255, 0.06);
}

/* (removed) mute-specific borders; use active image + existing running/active scene cues */

/* old inline img style removed (images are now full-card backgrounds) */

.deck-btn .label {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 10px;
  z-index: 2;

  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;

  text-align: left;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.12);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.6);
}

.deck-btn .hotkey {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 46px; /* sits just above the label */
  z-index: 2;

  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.70);

  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.08);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.editor-body {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.editor-group {
  background: rgba(12, 14, 20, 0.6);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.group-title {
  font-weight: 600;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.subgroup-title {
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.75);
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}

.field-row.command-toggle {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 18, 28, 0.6);
}

.field-row.command-toggle:has(input:checked) {
  border-color: rgba(88, 255, 140, 0.65);
  background: rgba(88, 255, 140, 0.12);
  box-shadow: 0 0 0 2px rgba(88, 255, 140, 0.18);
}

.field-row.command-toggle:has(input:checked) .command-toggle-title {
  color: rgba(210, 255, 226, 0.98);
}

.field-row.command-toggle:has(input:checked) .command-toggle-sub {
  color: rgba(210, 255, 226, 0.75);
}

.field-row.command-toggle:has(input:checked) .slider {
  background: rgba(88, 255, 140, 0.35);
  border-color: rgba(88, 255, 140, 0.75);
}

.field-row.command-toggle:has(input:checked) .slider:before {
  background: rgba(210, 255, 226, 0.98);
}

.command-toggle-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.command-toggle-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.command-toggle-sub {
  font-size: 11px;
  color: var(--muted);
}

.field-row input,
.field-row select,
.field-row textarea {
  background: rgba(15, 18, 28, 0.85);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 10px;
}

.field-warning {
  margin-top: 6px;
  font-size: 12px;
  color: rgba(248, 94, 74, 0.95);
  font-weight: 600;
}

.select-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
}

.button-config-row {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 16px;
  align-items: start;
}

.editor-preview-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.selected-button-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 12px;
  background: rgba(10, 12, 18, 0.55);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.image-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

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

.image-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.image-preview {
  min-height: 78px;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
  padding: 10px;
  text-align: center;
  background: rgba(10, 12, 18, 0.6);
}

.image-preview.dragging {
  border-color: rgba(99, 208, 255, 0.6);
  background: rgba(99, 208, 255, 0.08);
  color: var(--accent-2);
}

.image-preview img {
  max-width: 100%;
  max-height: 120px;
  border-radius: 12px;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(8, 10, 16, 0.45);
}

.actions.flow {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
}

.action-card {
  min-width: 240px;
  max-width: 320px;
}

.action-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  min-height: 100%;
  align-self: stretch;
  color: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.03);
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}


.action-dropzone.active {
  background: rgba(99, 208, 255, 0.22);
  color: rgba(99, 208, 255, 0.95);
  border-color: rgba(99, 208, 255, 0.6);
}

.action-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 10px;
  background: rgba(10, 12, 18, 0.7);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-card.transition-card {
  max-width: 220px;
  padding: 8px;
  background: rgba(20, 24, 36, 0.6);
}

.action-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.action-header select,
.action-add select {
  width: 100%;
  min-height: 40px;
  font-size: 14px;
  padding: 10px 40px 10px 12px;
  border-radius: 12px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.10);
  color: var(--text);
}

.select-arrow,
.datalist-arrow {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23e8ecff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;
  padding-right: 40px;
}

.action-header select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%23e8ecff' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 18px 18px;
}

.action-header select {
  background: rgba(255, 255, 255, 0.10);
  color: var(--text);
}

.action-header select option,
.action-add select option {
  background: #0b0f17;
  color: #f5f7ff;
}

.action-controls {
  display: flex;
  gap: 6px;
  align-items: center;
}

.action-fields {
  display: grid;
  gap: 8px;
}

.inline-field {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.checkbox-list {
  display: grid;
  gap: 6px;
  max-height: 220px;
  overflow: auto;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.12);
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.action-add {
  display: flex;
  gap: 12px;
  align-items: stretch;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 12, 18, 0.55);
}

.action-palette {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
  width: 100%;
}

.action-palette.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.action-chip {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(18, 22, 34, 0.85);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 600;
  text-align: center;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.2s ease, background 0.2s ease;
}

.action-chip:hover {
  border-color: rgba(99, 208, 255, 0.6);
  background: rgba(25, 32, 50, 0.9);
  transform: translateY(-1px);
}

.action-chip.small {
  font-size: 12px;
  padding: 8px 10px;
  opacity: 0.8;
}

.actions-separator {
  height: 6px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  margin: 12px 0;
}

.action-add .btn {
  padding: 10px 16px;
  font-weight: 700;
}

.footer {
  color: var(--muted);
  font-size: 13px;
  display: flex;
  justify-content: space-between;
  padding-top: 8px;
}

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

@media (max-width: 900px) {
  .connect {
    width: 100%;
  }
  .field input {
    min-width: 180px;
  }
  .grid {
    grid-template-columns: repeat(var(--grid-columns, 2), minmax(140px, 1fr));
  }
}

@media (max-width: 600px) {
  .app {
    padding: 18px;
  }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .grid {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
  .select-row {
    grid-template-columns: 1fr;
  }
  .button-config-row {
    grid-template-columns: 1fr;
  }
  .image-grid {
    grid-template-columns: 1fr;
  }
  .image-row {
    grid-template-columns: 1fr;
  }
  .action-add {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  .deck-btn,
  .deck-btn:hover {
    transition: none;
  }
}
