:root {
  color-scheme: dark;
  --bg: #2f3238;
  --rail: #25272d;
  --panel: #30333a;
  --panel-dark: #1f2126;
  --panel-soft: #373a42;
  --input: #17191d;
  --line: #424650;
  --text: #f4f5f7;
  --muted: #a7adb8;
  --faint: #747b88;
  --accent: #5965f3;
  --accent-soft: #343962;
  --danger: #ef4444;
  --ok: #35a760;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 "Segoe UI", system-ui, sans-serif;
}
button, input, textarea, select { font: inherit; }
button {
  border: 0;
  background: var(--panel-dark);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 13px;
  cursor: pointer;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .45; cursor: not-allowed; filter: none; }
button.primary {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 8px 22px rgba(89, 101, 243, .22);
}
button.danger {
  background: transparent;
  color: var(--danger);
  padding: 6px 8px;
}
button.ghost {
  background: transparent;
  color: var(--muted);
}
button.wide { width: 100%; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--input);
  color: var(--text);
  border-radius: 8px;
  padding: 11px 12px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 96px; }
label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 600;
}
.hidden { display: none !important; }
.error { color: #ffb3b5; min-height: 20px; }

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: #111317;
}
.login-panel {
  width: min(390px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 26px;
  display: grid;
  gap: 16px;
  box-shadow: 0 26px 70px rgba(0, 0, 0, .4);
}
.login-panel h1 { margin: 0 0 4px; font-size: 24px; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 198px 1fr;
}
.sidebar {
  background: var(--rail);
  padding: 18px 12px;
  display: grid;
  align-content: start;
  gap: 14px;
  border-right: 1px solid #202227;
}
.brand {
  display: grid;
  grid-template-columns: 38px 1fr;
  align-items: center;
  gap: 10px;
  padding: 0 4px 10px;
}
.brand strong { display: block; font-size: 13px; }
.brand small { display: block; color: var(--muted); font-size: 11px; }
.bot-mark {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 12px;
}
.side-nav, .template-list { display: grid; gap: 8px; }
.nav-item, .template-item {
  text-align: left;
  min-height: 50px;
  display: grid;
  grid-template-columns: 24px 1fr;
  align-items: center;
  gap: 9px;
  background: transparent;
  color: var(--muted);
}
.nav-item span {
  width: 24px;
  height: 24px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: #1d2027;
  color: var(--accent);
}
.nav-item b, .template-item span { color: var(--text); font-size: 13px; }
.nav-item small, .template-item small {
  grid-column: 2;
  color: var(--faint);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-item.active, .template-item.active {
  background: var(--accent-soft);
  color: #fff;
}
.side-section-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  padding: 4px 8px 0;
}
.template-item {
  grid-template-columns: 1fr;
  gap: 2px;
  padding: 10px 12px;
  background: #202229;
}
.template-item small { grid-column: auto; }
.side-bottom { margin-top: 16px; }

.workspace {
  min-width: 0;
  display: grid;
  grid-template-rows: auto 1fr;
}
.topbar {
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  border-bottom: 1px solid #2a2d33;
  background: #292c32;
}
.topbar > div:first-child {
  min-width: 240px;
  flex: 1;
  display: grid;
  gap: 6px;
}
.title-input, .muted-input {
  border: 0;
  background: transparent;
  padding: 0;
  border-radius: 0;
}
.title-input { font-size: 20px; font-weight: 800; }
.muted-input { color: var(--muted); }
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.main-grid {
  min-height: 0;
  display: grid;
  grid-template-columns: 430px minmax(420px, 1fr);
  gap: 0;
}
.editor {
  min-height: 0;
  overflow: auto;
  padding: 16px 14px;
  display: grid;
  align-content: start;
  gap: 12px;
  border-right: 1px solid var(--line);
}
.output {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(260px, 1fr) minmax(280px, 42vh) auto;
  gap: 12px;
  padding: 16px;
}

.mode-card, .panel, .tab-panel {
  background: var(--panel);
  border-radius: 10px;
}
.mode-card {
  display: grid;
  gap: 12px;
  padding: 12px;
}
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}
.segmented button {
  background: var(--panel-dark);
  color: var(--muted);
  font-weight: 800;
}
.segmented button.active, .tabs button.active {
  background: var(--accent);
  color: #fff;
}
.builder-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.switch-card {
  min-height: 58px;
  display: grid;
  gap: 2px;
  justify-items: start;
  background: #282b33;
}
.switch-card.active {
  background: var(--accent-soft);
  color: #fff;
}
.switch-card span { font-weight: 800; }
.switch-card small { color: var(--muted); }

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.tabs button {
  background: var(--panel-dark);
  color: var(--muted);
  font-weight: 800;
}
.tab-panel {
  padding: 12px;
  display: grid;
  gap: 12px;
}
.check {
  display: flex;
  align-items: center;
  gap: 9px;
}
.check input { width: 16px; height: 16px; }
.inline-head, .card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 900;
}
.counter, .section-title span {
  display: inline-flex;
  align-items: center;
  min-height: 20px;
  padding: 0 7px;
  margin-left: 6px;
  border-radius: 7px;
  background: #202229;
  color: #b9c0cc;
  font-size: 11px;
}
.notice {
  border: 1px solid #514934;
  background: #332f24;
  color: #ffd28a;
  border-radius: 8px;
  padding: 10px 12px;
}
.section-title {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-weight: 800;
  text-transform: uppercase;
  font-size: 12px;
}
.component-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.component-toolbar button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--panel-dark);
  color: #c5cad3;
}
.chip-icon {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  display: inline-block;
}
.chip-icon.blue { background: #363f93; }
.chip-icon.violet { background: #4836a6; }
.chip-icon.amber { background: #735b20; }
.chip-icon.red { background: #622a2a; }
.chip-icon.green { background: #1f6d45; }
.chip-icon.cyan { background: #1c5f80; }
.stack { display: grid; gap: 10px; }
.builder-card {
  background: var(--panel-dark);
  border-radius: 10px;
  padding: 12px;
  display: grid;
  gap: 10px;
}
.builder-card strong {
  font-size: 14px;
  font-weight: 900;
  text-transform: capitalize;
}
.kind-container {
  background: #343740;
}
.kind-actionRow {
  background: #1c1e24;
}
.card-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.items-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-weight: 800;
  font-size: 12px;
}
.items-head button,
.small {
  padding: 7px 10px;
  font-size: 12px;
}
.nested-stack {
  display: grid;
  gap: 10px;
  padding-left: 10px;
  border-left: 2px solid #454a56;
}
.nested-group {
  display: grid;
  gap: 9px;
  padding: 10px;
  background: #17191d;
  border-radius: 8px;
}
.nested-title {
  color: var(--muted);
  font-weight: 900;
  font-size: 12px;
  text-transform: uppercase;
}
.media-source-editor {
  display: grid;
  gap: 10px;
}
.media-source-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.media-source-tabs button {
  background: #22252c;
  color: var(--muted);
  font-weight: 800;
}
.media-source-tabs button.active {
  background: var(--accent-soft);
  color: #fff;
  outline: 1px solid var(--accent);
}
.upload-zone {
  min-height: 130px;
  display: grid;
  place-items: center;
  gap: 4px;
  border: 1px dashed #5865f2;
  border-radius: 10px;
  background: #202229;
  color: #d7d9ff;
  cursor: pointer;
  text-align: center;
}
.upload-zone input {
  display: none;
}
.upload-zone span {
  font-weight: 900;
}
.upload-zone small {
  color: var(--muted);
}
.selected-upload {
  padding: 8px 10px;
  border-radius: 7px;
  background: #202229;
  color: var(--muted);
  overflow-wrap: anywhere;
  font-size: 12px;
}
.container-tools {
  display: grid;
  gap: 9px;
  padding: 10px;
  background: #2a2d35;
  border-radius: 8px;
}

.panel {
  min-width: 0;
  padding: 0;
  overflow: hidden;
}
.panel-title {
  min-height: 42px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
  border-bottom: 1px solid #2a2d33;
}
.discord-preview {
  min-height: 220px;
  height: calc(100% - 42px);
  background: #313338;
  padding: 16px 18px;
  overflow: auto;
}
.discord-message {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 12px;
  max-width: 780px;
}
.discord-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #5865f2;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
}
.discord-body {
  min-width: 0;
  display: grid;
  gap: 4px;
  align-content: start;
}
.discord-header {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 22px;
}
.discord-name {
  color: #f2f3f5;
  font-weight: 700;
}
.discord-bot {
  border-radius: 3px;
  background: #5865f2;
  color: #fff;
  padding: 1px 4px;
  font-size: 10px;
  font-weight: 800;
}
.discord-time {
  color: #949ba4;
  font-size: 12px;
}
.message-content {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: #dbdee1;
}
.embed-preview {
  max-width: 520px;
  border-left: 4px solid var(--accent);
  background: #2b2d31;
  border-radius: 4px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
}
.embed-title { font-weight: 800; }
.embed-desc { color: #dbdee1; white-space: pre-wrap; }
.discord-components {
  display: grid;
  gap: 8px;
  margin-top: 4px;
  max-width: 560px;
}
.discord-component {
  min-width: 0;
  color: #dbdee1;
  white-space: pre-wrap;
}
.text-display {
  font-size: 15px;
  line-height: 1.35;
}
.container-preview {
  display: grid;
  gap: 10px;
  background: #2b2d31;
  border: 1px solid #3f4147;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  padding: 12px 14px;
}
.container-preview > .action-row-preview,
.container-preview > .text-display,
.container-preview > .section-preview,
.container-preview > .media-gallery-preview,
.container-preview > .file-preview {
  margin: 0;
}
.action-row-preview {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}
.section-preview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}
.section-texts {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.thumbnail-preview {
  width: 72px;
  height: 72px;
  border-radius: 6px;
  background: #1e1f22;
  border: 1px solid #41444d;
  color: #949ba4;
  display: grid;
  place-items: center;
  font-size: 11px;
  text-align: center;
}
.separator-preview {
  min-height: 16px;
  display: grid;
  align-items: center;
}
.separator-preview.spacing-2 {
  min-height: 32px;
}
.separator-preview hr {
  width: 100%;
  border: 0;
  border-top: 1px solid #4e525b;
  margin: 0;
}
.media-gallery-preview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 6px;
}
.media-item-preview {
  min-height: 86px;
  border-radius: 6px;
  background: #1e1f22;
  border: 1px solid #41444d;
  color: #b5bac1;
  display: grid;
  place-items: center;
  padding: 8px;
  text-align: center;
  overflow-wrap: anywhere;
  overflow: hidden;
  position: relative;
}
.media-item-preview img {
  width: 100%;
  height: 100%;
  min-height: 110px;
  object-fit: cover;
  display: block;
}
.media-item-preview span {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  padding: 4px 6px;
  border-radius: 5px;
  background: rgba(0, 0, 0, .62);
  color: #fff;
  font-size: 12px;
}
.file-preview {
  display: inline-grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  max-width: 360px;
  padding: 10px;
  border: 1px solid #41444d;
  border-radius: 6px;
  background: #1e1f22;
  overflow-wrap: anywhere;
}
.file-icon {
  padding: 4px 6px;
  border-radius: 4px;
  background: #34373f;
  color: #b5bac1;
  font-size: 10px;
  font-weight: 900;
}
.component-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: 6px;
  min-height: 32px;
  min-width: 60px;
  max-width: 180px;
  padding: 2px 16px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.component-button.style-2 { background: #4e5058; color: #fff; }
.component-button.style-3 { background: #248046; }
.component-button.style-4 { background: #da373c; }
.component-button.style-5 { background: #4e5058; color: #d8dcff; }
.preview-label {
  display: inline-flex;
  padding: 7px 10px;
  border-radius: 5px;
  background: #1e2026;
  color: var(--muted);
  font-weight: 700;
}
.select-preview {
  min-height: 40px;
  width: min(320px, 100%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 6px;
  border: 1px solid #41444d;
  background: #1e1f22;
  color: #b5bac1;
  padding: 0 12px;
}
.select-preview::after {
  content: "⌄";
  color: #949ba4;
}
.json-panel textarea {
  height: calc(100% - 42px);
  min-height: 260px;
  border: 0;
  border-radius: 0;
  background: #17191d;
  font-family: Consolas, "Cascadia Mono", monospace;
  font-size: 13px;
}
.status {
  min-height: 22px;
  color: var(--muted);
}
.status.ok { color: #9be7b1; }
.status.error { color: #ffb3b5; }

@media (max-width: 1080px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid #202227;
  }
  .main-grid { grid-template-columns: 1fr; }
  .editor { border-right: 0; border-bottom: 1px solid var(--line); }
  .output { grid-template-rows: auto auto auto; }
}
@media (max-width: 680px) {
  .topbar { align-items: stretch; flex-direction: column; }
  .actions { justify-content: flex-start; }
  .tabs, .segmented, .builder-switch { grid-template-columns: 1fr; }
  .main-grid { min-width: 0; }
}

/* Reference visual adaptation */
:root {
  --color-bg: #232428;
  --color-bg-secondary: #1e1f22;
  --color-bg-tertiary: #15161a;
  --color-bg-hover: #2b2d31;
  --color-bg-active: #35373c;
  --color-input: #1a1b1f;
  --color-border: rgba(255, 255, 255, .08);
  --color-border-strong: rgba(255, 255, 255, .14);
  --color-text: #dbdee1;
  --color-header: #f2f3f5;
  --color-text-muted: #949ba4;
  --color-accent: #5865f2;
  --color-accent-hover: #6d78ff;
  --color-green: #3ba55c;
  --accent-rgb: 88, 101, 242;
  --bg: var(--color-bg-secondary);
  --rail: var(--color-bg-secondary);
  --panel: var(--color-bg);
  --panel-dark: var(--color-bg-tertiary);
  --panel-soft: var(--color-bg-hover);
  --input: var(--color-input);
  --line: var(--color-border);
  --text: var(--color-text);
  --muted: var(--color-text-muted);
  --accent: var(--color-accent);
  --accent-soft: rgba(88, 101, 242, .14);
}

body {
  height: 100vh;
  overflow: hidden;
  background: var(--color-bg-tertiary);
  font-family: "Noto Sans", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

button {
  border-radius: .5rem;
  transition: background .16s ease, border-color .16s ease, transform .16s ease, box-shadow .16s ease;
}

button:hover {
  filter: none;
}

input,
textarea,
select {
  border-radius: .5rem;
  padding: .625rem .875rem;
  font-size: 14px;
  background: var(--color-input);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  transition: border-color .2s, box-shadow .2s;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12);
}

label {
  gap: .5rem;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--color-text-muted);
}

.auth-screen {
  background: linear-gradient(135deg, #1e1f22 0%, #0a0a12 100%);
}

.login-panel {
  background: var(--color-bg);
  border: 1px solid var(--color-border-strong);
  border-radius: 16px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .45);
}

.login-panel button[type="submit"],
button.primary,
#sendButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-hover) 100%);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .16);
}

.login-panel button[type="submit"]:hover,
button.primary:hover,
#sendButton:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(var(--accent-rgb), .35);
}

#saveTemplateButton,
.ghost,
.segmented button,
.tabs button,
.items-head button,
.media-source-tabs button,
.component-toolbar button,
.container-tools button {
  background: var(--color-bg-hover);
  color: var(--color-text);
  border: 1px solid transparent;
}

#saveTemplateButton:hover,
.ghost:hover,
.segmented button:hover,
.tabs button:hover,
.items-head button:hover,
.media-source-tabs button:hover,
.component-toolbar button:hover,
.container-tools button:hover {
  background: var(--color-bg-active);
  transform: translateY(-1px);
}

button.danger,
#deleteTemplateButton {
  color: #f87171;
  background: rgba(239, 68, 68, .08);
  border: 1px solid rgba(239, 68, 68, .18);
}

.app {
  height: 100vh;
  min-height: 0;
  grid-template-columns: 244px minmax(0, 1fr);
  background: var(--color-bg-tertiary);
}

.sidebar {
  min-height: 0;
  background: var(--color-bg-secondary);
  border-right: 1px solid var(--color-border);
  padding: 14px 10px;
  gap: 12px;
  overflow: auto;
}

.brand {
  grid-template-columns: 34px 1fr;
  padding: 4px 8px 12px;
}

.bot-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--color-accent), var(--color-accent-hover));
  box-shadow: 0 8px 24px rgba(var(--accent-rgb), .22);
}

.brand strong {
  color: var(--color-header);
  font-size: 13px;
  line-height: 1.1;
}

.brand small {
  color: var(--color-text-muted);
  font-size: 11px;
}

.nav-item,
.template-item {
  border-radius: 10px;
  padding: 10px;
  background: transparent;
  border: 1px solid transparent;
}

.nav-item.active,
.template-item.active {
  background: rgba(var(--accent-rgb), .14);
  border-color: rgba(var(--accent-rgb), .22);
}

.nav-item:hover,
.template-item:hover {
  background: var(--color-bg-hover);
}

.template-item {
  min-height: 46px;
  background: rgba(255, 255, 255, .025);
}

.side-section-title {
  padding: 8px 8px 0;
  color: var(--color-text-muted);
  letter-spacing: .06em;
}

.workspace {
  min-height: 0;
}

.topbar {
  min-height: 58px;
  padding: 10px 14px;
  background: var(--color-bg-secondary);
  border-bottom: 1px solid var(--color-border);
}

.title-input {
  color: var(--color-header);
  font-size: 18px;
  font-weight: 800;
}

.muted-input {
  color: var(--color-text-muted);
  font-size: 13px;
}

.actions button {
  min-height: 36px;
  padding: .5rem .85rem;
  font-size: 12px;
}

.main-grid {
  height: calc(100vh - 58px);
  grid-template-columns: 430px minmax(0, 1fr);
  background: var(--color-bg);
}

.editor {
  padding: 12px;
  gap: 10px;
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  scrollbar-width: thin;
  scrollbar-color: var(--color-bg-hover) transparent;
}

.output {
  background: var(--color-bg);
  padding: 12px;
  gap: 10px;
}

.mode-card,
.tab-panel {
  margin-bottom: .75rem;
  border-radius: .75rem;
  padding: 1rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  transition: all .2s ease;
}

.mode-card:hover,
.tab-panel:hover {
  border-color: rgba(var(--accent-rgb), .28);
}

.segmented {
  gap: 6px;
}

.segmented button,
.tabs button {
  min-height: 38px;
  font-size: 12px;
  font-weight: 700;
  color: var(--color-text-muted);
}

.segmented button.active,
.tabs button.active,
.media-source-tabs button.active {
  background: linear-gradient(135deg, var(--color-accent) 0%, var(--color-accent-hover) 100%);
  color: #fff;
  border-color: transparent;
}

.tabs {
  gap: 6px;
}

.inline-head h2,
.section-title {
  margin-bottom: .75rem;
  color: var(--color-header);
  font-size: 14px;
  font-weight: 800;
  text-transform: none;
  letter-spacing: 0;
}

.counter,
.section-title span {
  background: rgba(var(--accent-rgb), .16);
  color: #c7ccff;
  border: 1px solid rgba(var(--accent-rgb), .18);
}

.component-toolbar,
.container-tools .component-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: .5rem;
}

.component-toolbar button,
.container-tools button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px 5px 5px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .01em;
  background: var(--color-bg-tertiary);
  color: var(--color-text-muted);
  border: 1px solid color-mix(in srgb, var(--color-border) 40%, transparent);
  white-space: nowrap;
  line-height: 1;
}

.component-toolbar button:hover,
.container-tools button:hover {
  background: color-mix(in srgb, var(--color-accent) 8%, var(--color-bg-tertiary));
  color: var(--color-text);
  border-color: rgba(var(--accent-rgb), .28);
  box-shadow: 0 1px 6px rgba(0, 0, 0, .14);
}

.chip-icon {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--btn-accent, var(--color-accent)) 16%, var(--color-bg-tertiary));
}

.chip-icon.blue { --btn-accent: #5865f2; background: color-mix(in srgb, #5865f2 22%, var(--color-bg-tertiary)); }
.chip-icon.violet { --btn-accent: #7c3aed; background: color-mix(in srgb, #7c3aed 22%, var(--color-bg-tertiary)); }
.chip-icon.amber { --btn-accent: #d97706; background: color-mix(in srgb, #d97706 22%, var(--color-bg-tertiary)); }
.chip-icon.red { --btn-accent: #ef4444; background: color-mix(in srgb, #ef4444 22%, var(--color-bg-tertiary)); }
.chip-icon.green { --btn-accent: #22c55e; background: color-mix(in srgb, #22c55e 22%, var(--color-bg-tertiary)); }
.chip-icon.cyan { --btn-accent: #0ea5e9; background: color-mix(in srgb, #0ea5e9 22%, var(--color-bg-tertiary)); }

.builder-card,
.nested-group,
.container-tools {
  margin-bottom: .5rem;
  border-radius: .5rem;
  padding: .75rem;
  background: var(--color-bg-tertiary);
  border: 1px solid transparent;
  transition: all .2s ease;
}

.builder-card:hover,
.nested-group:hover {
  border-color: rgba(var(--accent-rgb), .18);
}

.kind-container {
  background: color-mix(in srgb, var(--color-accent) 5%, var(--color-bg-tertiary));
  border-color: rgba(var(--accent-rgb), .12);
}

.kind-actionRow {
  background: var(--color-bg-tertiary);
}

.card-head strong {
  color: var(--color-header);
  font-size: 13px;
}

.card-controls {
  color: var(--color-text-muted);
}

.nested-stack {
  border-left: 2px solid var(--color-border);
}

.items-head,
.nested-title {
  color: var(--color-text-muted);
}

.upload-zone {
  background: var(--color-bg-tertiary);
  border-color: rgba(var(--accent-rgb), .45);
  color: #c7ccff;
}

.selected-upload {
  background: var(--color-bg-hover);
  color: var(--color-text-muted);
}

.notice {
  background: rgba(217, 119, 6, .1);
  border-color: rgba(217, 119, 6, .25);
  color: #fbbf24;
}

.panel {
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: .75rem;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .12);
}

.panel-title {
  min-height: 40px;
  padding: 0 14px;
  background: rgba(255, 255, 255, .015);
  color: var(--color-text-muted);
  border-bottom: 1px solid var(--color-border);
  font-size: 11px;
  letter-spacing: .06em;
}

.discord-preview {
  background: #313338;
}

.json-panel textarea {
  background: #111216;
  color: #d7dae0;
  font-family: "Fira Code", "JetBrains Mono", Consolas, monospace;
}

.status {
  padding: 0 2px;
  font-size: 12px;
}

@media (max-width: 1080px) {
  body {
    overflow: auto;
    height: auto;
  }

  .app {
    height: auto;
    min-height: 100vh;
  }

  .main-grid {
    height: auto;
  }
}
