:root {
  --bg: #0b0b0d;
  --panel: #141416;
  --panel-2: #1a1a1d;
  --panel-3: #222226;
  --border: #2a2a30;
  --border-soft: #1f1f24;
  --text: #f4f4f7;
  --muted: #9a9aa6;
  --accent: #c026d3;
  --accent-2: #7c3aed;
  --accent-bright: #f472b6;
  --accent-dim: rgba(192, 38, 211, 0.16);
  --glow: rgba(168, 85, 247, 0.45);
  --grad: linear-gradient(135deg, #7c3aed 0%, #c026d3 48%, #ec4899 100%);
  --grad-soft: linear-gradient(135deg, rgba(124, 58, 237, 0.35), rgba(236, 72, 153, 0.22));
  --live: #34d399;
  --warn: #fbbf24;
  --danger: #ef4444;
  --radius: 14px;
  --sidebar: 15.5rem;
  --font: "Outfit", "Segoe UI", sans-serif;
  --font-brand: "Syne", "Outfit", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(1200px 600px at 15% -10%, rgba(124, 58, 237, 0.18), transparent 55%),
    radial-gradient(900px 500px at 90% 0%, rgba(236, 72, 153, 0.12), transparent 50%),
    var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-bright); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ------------------------------------------------------------------ shell */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar);
  flex: 0 0 var(--sidebar);
  background: linear-gradient(180deg, #121214 0%, #0c0c0e 100%);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  box-shadow: 8px 0 40px rgba(0, 0, 0, 0.35);
  padding: 16px 12px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 20px;
}

.brand-logo {
  flex: 0 0 40px;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: 20px;
  color: #fff;
  background: var(--grad);
  box-shadow: 0 0 24px var(--glow), 0 8px 18px rgba(124, 58, 237, 0.35);
}

.brand-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

.brand-mark {
  font-family: var(--font-brand);
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.04em;
  line-height: 1;
  color: #fff;
  text-shadow: 0 0 22px rgba(192, 38, 211, 0.55);
}

.brand-sub {
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 600;
  line-height: 1.3;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1 1 auto;
  min-height: 0;
}

.nav .nav-bottom {
  margin-top: auto;
}

.nav button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border: 0;
  border-radius: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.nav button:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); }

.nav button.active {
  background: var(--grad);
  color: #fff;
  box-shadow: 0 8px 22px rgba(124, 58, 237, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.06) inset;
}

.nav .icon { width: 18px; text-align: center; font-size: 15px; }

.nav a.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  box-sizing: border-box;
}
.nav a.nav-link:hover { background: rgba(255, 255, 255, 0.04); color: var(--text); text-decoration: none; }

/* --------------------------------------- sidebar subcategories (nav groups) */
.nav-group { margin-top: 10px; }
.nav .nav-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 12px;
  background: transparent;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
  text-align: left;
}
.nav .nav-group-head:hover { background: var(--panel-2); color: var(--text); }
.nav .nav-group-head .caret { font-size: 9px; width: 10px; transition: transform 0.15s ease; opacity: 0.7; }
.nav-group.collapsed .nav-group-head .caret { transform: rotate(-90deg); }
.nav-group-items { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; }
.nav-group.collapsed .nav-group-items { display: none; }

.setup-strip {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), transparent 40%),
    var(--panel);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 18px 50px rgba(0, 0, 0, 0.35);
}
.setup-strip::after {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  bottom: -2px;
  height: 2px;
  background: linear-gradient(90deg, transparent, #a855f7 20%, #ec4899 50%, #a855f7 80%, transparent);
  box-shadow: 0 0 18px 2px rgba(168, 85, 247, 0.75), 0 0 40px rgba(236, 72, 153, 0.45);
  pointer-events: none;
}
.setup-strip h2 { margin-bottom: 12px; }
.setup-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.setup-steps > div {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.setup-steps .n {
  flex: 0 0 28px;
  height: 28px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: var(--grad);
  border: 0;
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  box-shadow: 0 0 16px rgba(168, 85, 247, 0.45);
}
.setup-steps .meta { color: var(--muted); font-size: 12.5px; margin-top: 2px; }
@media (max-width: 900px) {
  .setup-steps { grid-template-columns: 1fr; }
}

.sidebar-foot {
  margin-top: 12px;
  flex: 0 0 auto;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--grad-soft);
  border: 1px solid rgba(168, 85, 247, 0.28);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
  font-size: 12px;
  color: #f5d0fe;
  line-height: 1.5;
}

/* ------------------------------------------------------------------- main */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(11, 11, 13, 0.78);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 1px 0 rgba(168, 85, 247, 0.08);
}

.channel-form { display: flex; gap: 8px; flex: 1; max-width: 460px; }
.channel-form input.channel-locked {
  cursor: default;
  color: var(--text);
  opacity: 0.95;
  pointer-events: none;
  user-select: none;
  border-style: dashed;
}

input, select, textarea {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 9px 12px;
  font-family: inherit;
  font-size: 14px;
  width: 100%;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: rgba(168, 85, 247, 0.65);
  box-shadow: 0 0 0 3px var(--accent-dim), 0 0 18px rgba(168, 85, 247, 0.2);
}
textarea { resize: vertical; min-height: 74px; line-height: 1.5; }
input[type="range"] { padding: 0; height: 26px; accent-color: var(--accent); }
input[type="checkbox"] { width: auto; }

button {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  padding: 9px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
}

button:hover { border-color: rgba(168, 85, 247, 0.55); }
button:active { transform: translateY(1px); }

.btn-primary {
  background: var(--grad);
  border-color: transparent;
  color: #fff;
  box-shadow: 0 8px 24px rgba(124, 58, 237, 0.4), 0 0 20px rgba(236, 72, 153, 0.22);
}
.btn-primary:hover { border-color: transparent; filter: brightness(1.06); }

a.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #fff;
}
a.btn-primary:hover { text-decoration: none; color: #fff; }

.btn-ghost { background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 12.5px; }
.btn-danger { color: #ffb4b4; border-color: rgba(239, 68, 68, 0.4); }
.btn-warn { background: rgba(251, 191, 36, 0.16); border-color: rgba(251, 191, 36, 0.55); color: #ffe6a6; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(26, 26, 29, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.dot.live { background: var(--live); box-shadow: 0 0 10px var(--live); animation: pulse 1.6s infinite; }
.dot.err { background: var(--danger); }
.dot.warn { background: var(--warn); }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.content { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.panel-view { display: none; flex-direction: column; gap: 14px; }
.panel-view.active { display: flex; }

.card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent 28%),
    var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.26);
}

.card h2 {
  margin: 0 0 2px;
  font-size: 16px;
  letter-spacing: -0.01em;
  font-weight: 700;
}

.card h3 {
  margin: 12px 0 8px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}
.card > h3:first-child { margin-top: 0; }
.card p.hint { margin: 0 0 10px; color: var(--muted); font-size: 12.5px; line-height: 1.45; }

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }

.stat {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 40%),
    var(--panel-2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 14px 16px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.22);
}

.stat.featured {
  background: var(--grad);
  border-color: transparent;
  box-shadow: 0 12px 32px rgba(124, 58, 237, 0.45), 0 0 28px rgba(236, 72, 153, 0.25);
}
.stat.featured .label,
.stat.featured .value { color: #fff; }

.stat .label { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.12em; color: var(--muted); font-weight: 700; }
.stat .value { font-size: 26px; font-weight: 800; margin-top: 6px; letter-spacing: -0.02em; }
.stat .value.accent { color: var(--accent-bright); }

.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 8px; }
.field > label { font-size: 12px; font-weight: 700; color: var(--muted); letter-spacing: 0.04em; }
.field .row { display: flex; align-items: center; gap: 10px; }
.inline { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.inline input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); }

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13.5px;
}
.switch-row:last-child { border-bottom: 0; }
.switch-row .meta,
.switch-row .small { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.switch-row input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); flex: 0 0 auto; }

/* Compact chip-style toggle rows (wrap a group in .toggle-wrap) */
.toggle-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 10px;
}
.toggle-wrap .switch-row {
  display: inline-flex;
  width: auto;
  max-width: 100%;
  padding: 7px 11px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  background: var(--panel-2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  gap: 8px;
  margin: 0;
}
.toggle-wrap .switch-row:has(input:checked) {
  background: var(--accent-dim);
  border-color: rgba(168, 85, 247, 0.5);
  color: #f5d0fe;
}
.toggle-wrap .switch-row .meta,
.toggle-wrap .switch-row .small { display: none; }

.page { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.page-head h2 { margin: 0 0 2px; }
.page-head .hint { margin: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.page-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
.page-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  align-items: start;
}
.page-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.page-card-head h2,
.page-card-head h3 { margin: 0; }
.page-card-head h3 {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.compact-nums {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
}
.compact-nums .field { margin-bottom: 0; }

@media (max-width: 980px) {
  .page-grid,
  .page-grid-3 { grid-template-columns: 1fr; }
}

.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.copy-row { display: flex; gap: 8px; align-items: center; }
.copy-row input { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--border); }
td { padding: 9px 10px; border-bottom: 1px solid var(--border-soft); vertical-align: top; }

.event-feed { max-height: 460px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.event-row {
  display: flex;
  gap: 10px;
  align-items: baseline;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--border-soft);
  font-size: 13.5px;
}
.event-row .type {
  font-size: 10.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 7px;
  border-radius: 6px;
  white-space: nowrap;
}
.type.chat { background: rgba(255, 255, 255, 0.08); color: #cfcfd6; }
.type.gift { background: rgba(192, 38, 211, 0.22); color: #f0abfc; }
.type.follow { background: rgba(61, 220, 151, 0.18); color: #7ff0bd; }
.type.sub { background: rgba(251, 191, 36, 0.18); color: #ffd97a; }
.type.like, .type.system { background: rgba(120, 120, 140, 0.18); color: #c3c3d0; }
.event-row .who { font-weight: 700; }
.event-row .when { margin-left: auto; color: var(--muted); font-size: 11.5px; white-space: nowrap; }

.rule {
  border: 1px solid var(--border-soft);
  border-radius: 14px;
  padding: 14px;
  background: var(--panel-2);
  margin-bottom: 12px;
}
.rule-head { display: flex; align-items: center; gap: 10px; }
.rule-head input[type="text"] { font-weight: 700; }
.rule-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.rule-action {
  display: grid;
  grid-template-columns: 110px 1fr auto;
  gap: 8px;
  align-items: center;
}

.badge-list { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  font-size: 12.5px;
  cursor: pointer;
  user-select: none;
}
.chip.on { border-color: rgba(168, 85, 247, 0.55); background: var(--accent-dim); color: #f5d0fe; }

.alert-log {
  margin-top: 12px;
  padding: 10px;
  border-radius: 10px;
  background: #0d0d0f;
  border: 1px dashed var(--border);
  font-family: ui-monospace, monospace;
  font-size: 12px;
  color: var(--muted);
  max-height: 160px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.callout {
  border-left: 3px solid #c026d3;
  background: var(--accent-dim);
  padding: 12px 14px;
  border-radius: 0 12px 12px 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: #fce7f3;
}

.callout.warn { border-color: var(--warn); background: rgba(251, 191, 36, 0.12); color: #ffefc6; }

.small { font-size: 12.5px; color: var(--muted); }
.tag-new {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.1em;
  background: var(--accent);
  color: #fff;
  border-radius: 5px;
  padding: 2px 5px;
  margin-left: 6px;
  vertical-align: middle;
}

.leaderboard { display: flex; flex-direction: column; gap: 6px; }
.leaderboard .lb-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--panel-2);
  font-size: 13.5px;
}
.leaderboard .rank { width: 22px; font-weight: 800; color: var(--accent-bright); }
.leaderboard .score { margin-left: auto; color: var(--muted); font-size: 12.5px; }

/* ------------------------------------------------------------------ music */
.music-now { display: flex; gap: 16px; align-items: stretch; }
.music-art-box {
  position: relative;
  flex: 0 0 132px;
  height: 132px;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(34, 211, 238, 0.45);
  background: var(--panel-2);
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.18);
}
.music-art-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
.music-art-glow { position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 22px rgba(34, 211, 238, 0.25); }
.music-now-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; justify-content: center; }
.music-badge {
  align-self: flex-start;
  font-size: 10.5px; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase;
  padding: 3px 9px; border-radius: 999px;
  background: var(--panel-3); border: 1px solid var(--border); color: var(--muted);
}
.music-badge.on { background: rgba(34, 211, 238, 0.14); border-color: rgba(34, 211, 238, 0.55); color: #9beefc; }
.music-now-title { font-size: 19px; font-weight: 800; letter-spacing: -0.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.music-now-artist { color: #22d3ee; font-size: 13.5px; font-weight: 600; }
.music-bar { height: 7px; border-radius: 999px; background: var(--panel-3); overflow: hidden; border: 1px solid var(--border-soft); }
.music-bar > div {
  height: 100%; width: 0; border-radius: 999px;
  background: linear-gradient(90deg, #0891b2, #22d3ee);
  box-shadow: 0 0 10px rgba(34, 211, 238, 0.8);
  transition: width 0.6s linear;
}
.music-now-times { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.music-controls { display: flex; align-items: center; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.music-vol { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.music-vol input { width: 130px; }
.music-host-on { color: #3ddc97; font-weight: 700; }
.music-embed { margin-top: 14px; border-radius: 14px; overflow: hidden; border: 1px solid var(--border-soft); background: #000; min-height: 100px; }
.music-embed iframe { display: block; width: 100%; border: 0; }
.music-preview-wrap {
  border-radius: 12px; overflow: hidden; border: 1px solid var(--border);
  /* checkerboard proves the overlay really is transparent in the preview */
  background: repeating-conic-gradient(#141416 0% 25%, #101012 0% 50%) 50% / 18px 18px;
}
.music-preview-wrap iframe { display: block; width: 100%; height: 210px; border: 0; }

.fn-builder {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  gap: 14px;
  align-items: start;
  margin-top: 8px;
}
.fn-preview-host {
  min-height: 280px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: repeating-conic-gradient(#1a1a1e 0% 25%, #121214 0% 50%) 50% / 18px 18px;
}
.fn-preview-host iframe {
  display: block;
  width: 100%;
  height: 300px;
  border: 0;
  background: transparent;
}
.fn-editor .field { margin-bottom: 8px; }
@media (max-width: 1100px) {
  .fn-builder { grid-template-columns: 1fr; }
}

.builder-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 14px;
  align-items: start;
}
.builder-canvas-host {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: repeating-conic-gradient(#1a1a1e 0% 25%, #121214 0% 50%) 50% / 20px 20px;
}
.builder-canvas-host iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: transparent;
}
.builder-side .builder-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 8px 0;
}
.layer-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.layer-group {
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}
.layer-group-title {
  margin: 0 0 10px;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 700;
}
.layer-list { display: flex; flex-direction: column; gap: 6px; }
.layer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid transparent;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.layer-row:hover { border-color: rgba(168, 85, 247, 0.35); background: rgba(168, 85, 247, 0.08); }
.layer-row span { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.layer-row strong { font-size: 13.5px; }
.layer-row .small { color: var(--muted); line-height: 1.35; }
.layer-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}
@media (max-width: 900px) {
  .layer-groups { grid-template-columns: 1fr; }
}

.alert-preview-wrap {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  min-height: 320px;
  background:
    radial-gradient(600px 220px at 50% 20%, rgba(168, 85, 247, 0.18), transparent 60%),
    repeating-conic-gradient(#1a1a1e 0% 25%, #121214 0% 50%) 50% / 18px 18px;
}
.alert-preview-wrap iframe {
  display: block;
  width: 100%;
  height: 320px;
  border: 0;
  background: transparent;
}
.alert-logo-row {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  flex-wrap: wrap;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
}
.alert-logo-thumb-wrap {
  width: 72px;
  height: 72px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex: 0 0 auto;
  overflow: hidden;
}
.alert-logo-thumb {
  width: 56px;
  height: 56px;
  object-fit: contain;
}
.alert-logo-controls { flex: 1 1 220px; min-width: 0; }
.alert-logo-controls .field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(255, 255, 255, 0.72);
}
.chip-file {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
}

/* -------------------------------------------------------------------- TTS */
.tts-page { display: flex; flex-direction: column; gap: 14px; }
.tts-head { padding: 14px 16px; }
.tts-head h2 { margin: 0 0 2px; }
.tts-head .hint { margin: 0; }
.tts-head-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}
.tts-toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.tts-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.tts-toggle:has(input:checked) {
  background: var(--grad-soft);
  border-color: rgba(168, 85, 247, 0.45);
  box-shadow: 0 0 16px rgba(124, 58, 237, 0.2);
}
.tts-toggle input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }

.tts-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}
.tts-card { padding: 14px 16px; }
.tts-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.tts-card-head h3 {
  margin: 0;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}
.tts-tight { margin-bottom: 8px; }
.tts-tight > label { margin-bottom: 0; }
.tts-voice-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(0, 1.3fr);
  gap: 8px;
  margin-bottom: 12px;
}
.tts-voice-row input,
.tts-voice-row select { margin: 0; }
.tts-sliders { display: flex; flex-direction: column; gap: 8px; }
.tts-slider {
  display: grid;
  grid-template-columns: 88px 1fr;
  gap: 10px;
  align-items: center;
  font-size: 12.5px;
  color: var(--muted);
  font-weight: 600;
}
.tts-slider b { color: var(--text); font-weight: 700; margin-left: 4px; }
.tts-slider input[type="range"] { width: 100%; margin: 0; }
.tts-slider-muted { opacity: 0.55; }
.tts-limits {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.tts-limits .field { margin-bottom: 0; }
.tts-filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}
.tts-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: var(--panel-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}
.tts-chip:has(input:checked) {
  background: var(--accent-dim);
  border-color: rgba(168, 85, 247, 0.5);
  color: #f5d0fe;
}
.tts-chip input { width: 14px; height: 14px; accent-color: var(--accent); margin: 0; }
.tts-block-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.tts-block-grid textarea {
  min-height: 88px;
  font-size: 13px;
  line-height: 1.4;
}

@media (max-width: 980px) {
  .tts-grid { grid-template-columns: 1fr; }
  .tts-block-grid { grid-template-columns: 1fr; }
  .tts-voice-row { grid-template-columns: 1fr; }
}

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

@media (max-width: 640px) {
  .music-now { flex-direction: column; }
  .music-art-box { flex: none; width: 100%; height: 190px; }
  .copy-row { flex-wrap: wrap; }
}

@media (max-width: 860px) {
  .sidebar { width: 4.5rem; flex: 0 0 4.5rem; }
  .brand-text, .nav button span.label, .sidebar-foot { display: none; }
  .brand-logo { flex: 0 0 36px; width: 36px; height: 36px; font-size: 17px; }
  .nav button { justify-content: center; }
  /* icon-only rail: group headers vanish and items stay reachable */
  .nav .nav-group-head { display: none !important; }
  .nav-group.collapsed .nav-group-items { display: flex; }
  .nav-group { margin-top: 6px; }
}
