:root {
  color-scheme: dark;
  --bg: #0b0b0d;
  --surface: rgba(5, 5, 6, 0.72);
  --surface-strong: #111113;
  --surface-soft: #0d0d0f;
  --border: rgba(255, 255, 255, 0.075);
  --border-strong: rgba(255, 255, 255, 0.13);
  --text: #f3f3f5;
  --muted: #929299;
  --violet: #a970ff;
  --violet-strong: #9147ff;
  --green: #5fdb9d;
  --red: #ff6b7a;
  --shadow: none;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 1180px;
  background: var(--bg);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family: Poppins, ui-sans-serif, system-ui, sans-serif;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

button,
input,
select {
  font: inherit;
}

button,
a,
input,
select {
  outline: none;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible {
  box-shadow: 0 0 0 3px rgba(169, 112, 255, 0.26);
}

.app-shell {
  width: min(1840px, calc(100vw - 36px));
  margin: 0 auto;
  padding-bottom: 50px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px;
  background: rgba(11, 11, 13, 0.97);
  border-bottom: 1px solid var(--border);
}

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

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  color: white;
  background: #9147ff;
  box-shadow: none;
  font-weight: 950;
  letter-spacing: -0.05em;
}

.brand h1,
.brand p,
.section-header h2,
.editor-section h3,
.eyebrow {
  margin: 0;
}

.brand h1 {
  font-size: 20px;
  letter-spacing: -0.02em;
}

.brand p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.status-area,
.header-actions,
.media-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 13px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-weight: 750;
}

.pill::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: none;
}

.pill.neutral {
  color: var(--muted);
}

.pill.online {
  color: var(--green);
  background: rgba(95, 219, 157, 0.07);
}

.pill.warning {
  color: #ffcc66;
  background: rgba(255, 204, 102, 0.07);
}

.workspace {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.panel-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.sidebar {
  position: sticky;
  top: 88px;
  max-height: calc(100vh - 106px);
  overflow: auto;
  padding: 14px;
}

.sidebar-heading,
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sidebar-heading {
  padding: 7px 8px 12px;
  font-weight: 850;
}

.icon-button,
.round-button {
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-soft);
  cursor: pointer;
}

.icon-button {
  width: 30px;
  height: 30px;
  border-radius: 4px;
  font-size: 22px;
  line-height: 1;
}

.alert-list {
  display: grid;
  gap: 7px;
}

.alert-tab {
  width: 100%;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text);
  background: transparent;
  text-align: left;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.alert-tab:hover {
  background: rgba(255, 255, 255, 0.04);
}

.alert-tab.active {
  border-color: rgba(169, 112, 255, 0.5);
  background: rgba(145, 71, 255, 0.13);
}

.alert-tab-icon {
  width: 38px;
  height: 38px;
  border-radius: 4px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--tab-color) 18%, #11141f);
  color: var(--tab-color);
  font-weight: 900;
}

.alert-tab-copy {
  min-width: 0;
}

.alert-tab-copy strong,
.alert-tab-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.alert-tab-copy strong {
  font-size: 14px;
}

.alert-tab-copy small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.alert-tab-status {
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: #4a4f60;
}

.alert-tab-status.enabled {
  background: var(--green);
  box-shadow: none;
}

.sidebar-section {
  margin-top: 18px;
  padding: 16px 8px 3px;
  border-top: 1px solid var(--border);
}

.eyebrow {
  color: #aeb5ca;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.url-field {
  display: block;
  margin-top: 10px;
}

.url-field span {
  display: block;
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 11px;
}

.url-field input {
  width: 100%;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: #c8ccda;
  background: #0e1018;
  font-size: 11px;
}

.history {
  max-height: 220px;
  margin-top: 10px;
  overflow: auto;
}

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

.history-item {
  padding: 9px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.055);
}

.history-item strong,
.history-item span {
  display: block;
}

.history-item strong {
  font-size: 12px;
}

.history-item span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.main-column {
  min-width: 0;
}

.preview-card {
  padding: 20px;
}

.section-header {
  margin-bottom: 16px;
}

.section-header.compact {
  margin-bottom: 13px;
}

.section-header h2 {
  margin-top: 4px;
  font-size: 23px;
  letter-spacing: -0.035em;
}

.preview-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 17px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 48%, #272b3b, #12151f 70%);
  background-size: 40px 40px, 40px 40px, auto;
  cursor: crosshair;
  user-select: none;
  touch-action: none;
}

.safe-zone {
  position: absolute;
  inset: 5%;
  border: 1px dashed rgba(255, 255, 255, 0.10);
  border-radius: 12px;
  pointer-events: none;
}

.stage-label {
  position: absolute;
  right: 12px;
  bottom: 10px;
  padding: 6px 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  color: #9aa1b4;
  background: rgba(8, 10, 16, 0.72);
  font-size: 10px;
  pointer-events: none;
}

.preview-shell {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center;
  cursor: grab;
  touch-action: none;
}

.preview-shell:active {
  cursor: grabbing;
}

.preview-alert-card {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transform-origin: center;
  border-style: solid;
  border-width: 1px;
  backdrop-filter: blur(18px);
}

.preview-alert-card.with-shadow {
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.42), 0 0 46px color-mix(in srgb, var(--accent) 30%, transparent);
}

.preview-alert-card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -2;
  background: radial-gradient(circle at 50% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 58%);
}

.preview-alert-card.layout-top { flex-direction: column; }
.preview-alert-card.layout-left { flex-direction: row; }
.preview-alert-card.layout-right { flex-direction: row-reverse; }
.preview-alert-card.layout-hidden,
.preview-alert-card.layout-background { flex-direction: column; }

.preview-image {
  display: block;
  flex: 0 0 auto;
  object-fit: contain;
  filter: drop-shadow(0 16px 24px rgba(0, 0, 0, 0.32));
}

.layout-hidden .preview-image,
.layout-background .preview-image {
  display: none;
}

.preview-background {
  position: absolute;
  inset: 0;
  z-index: -3;
  background-position: center;
  background-size: cover;
  opacity: 0.28;
}

.preview-copy {
  min-width: 0;
}

.preview-title,
.preview-message {
  margin: 0;
  text-wrap: balance;
  overflow-wrap: anywhere;
  text-shadow: 0 3px 16px rgba(0, 0, 0, 0.45);
}

.preview-title {
  font-weight: 900;
  line-height: 1.02;
  letter-spacing: -0.035em;
}

.preview-message {
  margin-top: 10px;
  font-weight: 650;
  line-height: 1.25;
}

.preview-accent {
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: 0;
  height: 4px;
  border-radius: 999px 999px 0 0;
  background: var(--accent);
  box-shadow: 0 0 24px var(--accent);
}

.editor-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.editor-section {
  min-width: 0;
  padding: 19px;
}

.editor-section.wide {
  grid-column: 1 / -1;
}

.editor-section h3 {
  margin-top: 5px;
  margin-bottom: 15px;
  font-size: 17px;
  letter-spacing: -0.02em;
}

.field-grid {
  display: grid;
  gap: 13px;
}

.field-grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.compact-grid {
  margin-top: 14px;
}

.field {
  display: block;
  min-width: 0;
}

.field > span,
.color-field > span {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 18px;
  margin-bottom: 7px;
  color: #c3c7d6;
  font-size: 12px;
  font-weight: 700;
}

output {
  color: var(--muted);
  font-weight: 600;
}

.field input[type="text"],
.field select {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: #0e111a;
}

.field input[type="text"]:focus,
.field select:focus {
  border-color: rgba(169, 112, 255, 0.58);
}

.field input[type="range"] {
  width: 100%;
  accent-color: var(--violet);
}

.variable-help {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 13px;
  color: var(--muted);
  font-size: 12px;
}

.variable-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.variable-chip {
  padding: 4px 7px;
  border: 1px solid rgba(169, 112, 255, 0.23);
  border-radius: 7px;
  color: #cbb1ff;
  background: rgba(169, 112, 255, 0.08);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  cursor: pointer;
}

.button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 11px;
  color: white;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition: 150ms ease;
}

.button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: linear-gradient(135deg, #ad75ff, #9147ff);
  box-shadow: 0 10px 26px rgba(145, 71, 255, 0.26);
}

.button.secondary,
.button.ghost {
  border-color: var(--border-strong);
  background: #171a25;
}

.button.ghost {
  background: rgba(255, 255, 255, 0.035);
}

.button.danger-ghost {
  border-color: rgba(255, 107, 122, 0.22);
  color: #ff8994;
  background: rgba(255, 107, 122, 0.06);
}

.button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.file-button input {
  display: none;
}

.media-preview {
  height: 150px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
  background: #0d1018;
}

.media-preview img {
  max-width: 88%;
  max-height: 125px;
  object-fit: contain;
}

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

.media-actions {
  margin-top: 11px;
}

.sound-box {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #0d1018;
}

.sound-box span {
  min-width: 0;
  overflow: hidden;
  color: #c8ccda;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.round-button {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 13px;
}

.color-field input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #0e111a;
  cursor: pointer;
}

.switch-row {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #d1d4de;
  font-size: 12px;
  font-weight: 750;
  cursor: pointer;
}

.switch-row input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.switch {
  position: relative;
  width: 40px;
  height: 23px;
  border-radius: 999px;
  background: #363a49;
  transition: 160ms ease;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 17px;
  height: 17px;
  border-radius: 50%;
  background: white;
  transition: 160ms ease;
}

.switch-row input:checked + .switch {
  background: var(--violet-strong);
}

.switch-row input:checked + .switch::after {
  transform: translateX(17px);
}

.bottom-switch {
  align-self: end;
  min-height: 40px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 50;
  max-width: 420px;
  padding: 13px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  color: white;
  background: #1b1f2b;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: 180ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast.error {
  border-color: rgba(255, 107, 122, 0.45);
}

@media (max-width: 1450px) {
  .editor-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

[hidden] {
  display: none !important;
}

.mode-tabs {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.035);
}

.mode-tab {
  min-width: 108px;
  height: 36px;
  padding: 0 15px;
  border: 0;
  border-radius: 9px;
  color: var(--muted);
  background: transparent;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.mode-tab.active {
  color: white;
  background: linear-gradient(135deg, rgba(173, 117, 255, .95), rgba(145, 71, 255, .95));
  box-shadow: 0 8px 20px rgba(145, 71, 255, .22);
}

.sidebar-copy {
  margin: 2px 8px 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.sidebar-buttons {
  display: grid;
  gap: 9px;
  padding: 0 8px 4px;
}

.switch-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.chat-preview-stage {
  cursor: default;
}

.chat-preview-box {
  position: absolute;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  transform-origin: top left;
}

.chat-preview-box:active {
  cursor: grabbing;
}

.chat-preview-message {
  flex: 0 0 auto;
  border: 1px solid transparent;
  border-left-style: solid;
  line-height: 1.38;
  overflow-wrap: anywhere;
}

.chat-preview-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 4px;
  line-height: 1.1;
}

.chat-preview-badges {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.chat-preview-badges img {
  display: block;
  width: 20px;
  height: 20px;
  object-fit: contain;
  filter: none;
}

/* Flat, low-cost visual system. */
.preview-alert-card,
.chat-preview-message {
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.preview-alert-card.with-shadow { box-shadow: 0 8px 24px rgba(0, 0, 0, .28); }
.preview-image { filter: none; }

.preview-stage, .safe-zone, .stage-label, .field input[type="text"],
.field select, .variable-chip, .button, .media-preview, .sound-box,
.color-field input[type="color"], .toast, .mode-tabs, .mode-tab,
.url-field input, .round-button { border-radius: 4px; }

.mode-tabs { background: rgba(0, 0, 0, .35); }
.mode-tab { transition: background-color 120ms ease, color 120ms ease; }
.mode-tab:hover { color: var(--text); background: rgba(255, 255, 255, .05); }
.mode-tab.active {
  color: #fff;
  background: rgba(145, 71, 255, .18);
  box-shadow: inset 0 -2px 0 var(--violet);
}

.button {
  font-weight: 600;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.button:hover { transform: none; border-color: rgba(255,255,255,.2); background-color: rgba(255,255,255,.08); }
.button:active, .mode-tab:active, .alert-tab:active, .icon-button:active, .round-button:active { transform: scale(.98); }
.button.primary { background: #9147ff; box-shadow: none; }
.button.primary:hover { background: #a970ff; }
.button.secondary, .button.ghost { background: rgba(255,255,255,.045); }

.switch { border-radius: 4px; transition: background-color 120ms ease; }
.switch::after { border-radius: 2px; transition: transform 120ms cubic-bezier(.23,1,.32,1); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}

.chat-preview-text {
  font-weight: 550;
  text-shadow: 0 2px 3px rgba(0, 0, 0, .65);
}

@media (max-width: 1350px) {
  .topbar {
    flex-wrap: wrap;
    gap: 10px;
  }

  .mode-tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }
}
