*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1e1e1e;
  --accent: #ea5c2a;
  --text: #fbf9fe;
  --surface: #2a2a2a;
  --surface2: #303030;
  --surface3: #393939;
  --border: #3d3d3d;
  --border-bright: #635849;
  --muted: #8a7e72;
  --muted-bright: #b0a496;
  --green: #3ecf4a;
  --radius: 10px;
  --t: 0.18s ease;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ─── HEADER ─────────────────────────────────────────────────── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border-bright);
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  height: 48px;
  z-index: 50;
}

header h1 { font-size: 1.05rem; font-weight: 700; color: var(--text); }
header h1 span { color: var(--accent); }

/* ─── LAYOUT ──────────────────────────────────────────────────── */
.layout {
  display: grid;
  grid-template-columns: 38% 62%;
  flex: 1;
  min-height: 0;
}

.panel {
  padding: 20px 22px;
  overflow-y: auto;
  height: 100%;
}

.panel-left { border-right: 1px solid var(--border-bright); }
.panel-right {
  background: var(--bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 14px 16px 0;
}

.panel-title {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted-bright);
  margin-bottom: 10px;
}

/* ─── PALETTE + BUILDER ROW ───────────────────────────────────── */
.palette-builder-row {
  display: grid;
  grid-template-columns: 162px 1fr;
  gap: 12px;
  flex: 1;
  min-height: 0;
  padding-bottom: 12px;
}

.palette-col {
  overflow-y: auto;
  min-height: 0;
}

.palette-col .panel-title {
  position: sticky; top: 0;
  background: var(--bg);
  padding-top: 2px;
  z-index: 1;
}

.builder-col {
  overflow-y: auto;
  min-height: 0;
  padding-right: 2px;
}

/* ─── TOOLTIP ─────────────────────────────────────────────────── */
.tip-wrap { position: relative; display: inline-flex; align-items: center; }

.tip-icon {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--surface3);
  border: 1px solid var(--border-bright);
  color: var(--muted-bright);
  font-size: 11px; font-weight: 700;
  cursor: default;
  display: inline-flex; align-items: center; justify-content: center;
  user-select: none; flex-shrink: 0;
  transition: background var(--t), color var(--t);
}
.tip-icon:hover { background: var(--accent); color: #fff; }

.tip-text {
  display: none;
  position: fixed;
  background: #131110;
  color: #fbf9fe;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 12px 15px;
  font-size: 13px; line-height: 1.65;
  width: 280px; z-index: 999999;
  pointer-events: none;
  box-shadow: 0 16px 48px rgba(0,0,0,.95);
}
.tip-wrap:hover .tip-text { display: block; }

/* ─── TOGGLE ──────────────────────────────────────────────────── */
.ts { position: relative; width: 38px; height: 22px; flex-shrink: 0; cursor: pointer; }
.ts input { opacity: 0; width: 0; height: 0; position: absolute; }

.ts .track {
  position: absolute; inset: 0;
  background: var(--surface3);
  border-radius: 999px;
  border: 1px solid var(--border-bright);
  transition: background var(--t), border-color var(--t);
}

.ts .thumb {
  position: absolute; top: 3px; left: 3px;
  width: 14px; height: 14px;
  background: var(--muted-bright);
  border-radius: 50%;
  transition: left var(--t), background var(--t);
  pointer-events: none;
}

.ts input:checked ~ .track { background: rgba(234,92,42,.3); border-color: var(--accent); }
.ts input:checked ~ .thumb { left: 19px; background: var(--accent); }

.toggle-row { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.toggle-label { font-weight: 600; font-size: .9rem; color: var(--text); }

/* ─── OPTION BLOCK ────────────────────────────────────────────── */
.option-block {
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 8px;
  transition: border-color var(--t);
}
.option-block.active { border-color: rgba(234,92,42,.6); }
.option-block:last-child { margin-bottom: 0; }
.option-header { display: flex; align-items: center; gap: 10px; }

.option-sub {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--border-bright);
  display: flex; flex-direction: column; gap: 10px;
  animation: sd .2s ease;
}

@keyframes sd {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── INPUTS ──────────────────────────────────────────────────── */
.input-row { display: flex; align-items: center; gap: 8px; }

.input-field {
  background: var(--surface2);
  border: 1px solid var(--border-bright);
  border-radius: 7px; color: var(--text);
  font-size: 13px; padding: 7px 11px;
  outline: none; transition: border-color var(--t);
  width: 100%; font-family: inherit;
}
.input-field::placeholder { color: var(--muted); font-size: 12px; }
.input-field:focus { border-color: var(--accent); }

.input-field.lang {
  max-width: 64px; text-align: center;
  font-weight: 700; letter-spacing: .05em;
}

.wiki-link {
  color: var(--accent); font-size: 12px;
  text-decoration: none; white-space: nowrap; flex-shrink: 0;
}
.wiki-link:hover { text-decoration: underline; }

.md-guide {
  background: var(--surface2);
  border: 1px solid var(--border-bright);
  border-radius: 7px; padding: 9px 13px;
  font-size: 11.5px; line-height: 2;
  color: var(--muted-bright);
  font-family: 'Cascadia Code', 'Fira Code', monospace;
}
.md-guide b { color: var(--text); }

/* ─── PREMIUM ─────────────────────────────────────────────────── */
.premium-section {
  border: 1px solid var(--border-bright);
  border-radius: var(--radius); overflow: hidden;
}

.premium-header {
  background: var(--surface);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
}

.premium-badge {
  background: linear-gradient(135deg, #f7b731, #ea5c2a);
  color: #fff; font-size: 10px; font-weight: 800;
  padding: 3px 9px; border-radius: 999px;
  letter-spacing: .07em; text-transform: uppercase; flex-shrink: 0;
}

.premium-body {
  padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
  background: rgba(234,92,42,.04);
}

.premium-warn {
  background: rgba(234,92,42,.1);
  border: 1px solid rgba(234,92,42,.35);
  border-radius: 7px; padding: 10px 12px;
  font-size: 12px; color: #e8a87c;
  display: flex; gap: 8px; align-items: flex-start;
}

/* ─── GENERATE AREA ───────────────────────────────────────────── */
.generate-area {
  padding: 12px 20px;
  border-top: 1px solid var(--border-bright);
  background: var(--surface);
  display: flex; flex-direction: column; gap: 9px;
  flex-shrink: 0;
}

.generate-area-title {
  font-size: .65rem; font-weight: 700;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted-bright);
}

.generate-row { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.btn-generate {
  background: var(--accent); color: #fff;
  border: none; border-radius: 8px;
  padding: 9px 20px; font-size: 13.5px; font-weight: 700;
  cursor: pointer; transition: opacity var(--t), transform var(--t);
  letter-spacing: .03em; flex-shrink: 0;
}
.btn-generate:hover { opacity: .88; transform: translateY(-1px); }
.btn-generate:active { transform: translateY(0); }

.security-warn {
  display: none; align-items: center; gap: 8px;
  background: rgba(234,92,42,.1); border: 1px solid rgba(234,92,42,.4);
  border-radius: 8px; padding: 8px 13px;
  font-size: 12px; color: #e8a87c;
}
.security-warn.show { display: flex; animation: sd .25s ease; }

.config-output {
  background: var(--surface2);
  border: 1px solid var(--border-bright);
  border-radius: var(--radius); padding: 11px 14px;
  font-family: 'Cascadia Code', 'Fira Code', monospace;
  font-size: 12px; color: #8dd9a0;
  word-break: break-all; letter-spacing: .03em;
  min-height: 40px; cursor: pointer;
  transition: border-color var(--t);
}
.config-output:hover { border-color: var(--accent); }

.copied-toast {
  color: var(--green); font-size: 13px; font-weight: 600;
  opacity: 0; transition: opacity .3s; white-space: nowrap;
}
.copied-toast.show { opacity: 1; }

/* ─── FORMAT SELECTOR ─────────────────────────────────────────── */
.format-selector {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 8px; margin-bottom: 10px;
}

.format-option { cursor: pointer; }
.format-option input { display: none; }

.format-card {
  background: var(--surface2);
  border: 2px solid var(--border-bright);
  border-radius: 8px; padding: 9px 13px;
  display: flex; align-items: center; gap: 10px;
  transition: all var(--t); cursor: pointer;
}

.format-option input:checked ~ .format-card {
  border-color: var(--accent);
  background: rgba(234,92,42,.1);
}
.format-card:hover { border-color: rgba(234,92,42,.6); }

.format-icon { font-size: 18px; flex-shrink: 0; }
.format-name { font-weight: 700; font-size: 13px; color: var(--text); }
.format-desc { font-size: 10.5px; color: var(--muted-bright); }

/* ─── FORMAT ALERT ────────────────────────────────────────────── */
.format-alert {
  background: rgba(234,92,42,.1);
  border: 1px solid rgba(234,92,42,.35);
  border-radius: 7px; padding: 7px 11px;
  font-size: 11.5px; color: #e8a87c;
  margin-bottom: 10px;
}

/* ─── COLOR SECTION ───────────────────────────────────────────── */
.color-section { margin-bottom: 10px; }

/* ─── CELLS PALETTE ───────────────────────────────────────────── */
.cells-palette {
  display: flex; flex-direction: column; gap: 7px;
  margin-bottom: 0;
}

.cell-group {
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: 8px; padding: 8px 9px;
}

.cell-group-title {
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted-bright); margin-bottom: 6px;
}

.cell {
  background: var(--surface2);
  border: 1px solid var(--border-bright);
  border-radius: 6px; padding: 5px 9px;
  font-size: 11.5px; margin-bottom: 4px;
  cursor: grab; transition: all var(--t);
  user-select: none; color: var(--text);
}
.cell:last-child { margin-bottom: 0; }
.cell:hover { border-color: var(--accent); background: rgba(234,92,42,.15); color: #fff; }
.cell:active { cursor: grabbing; }
.cell.dragging { opacity: 0.4; }

/* ─── BUILDER SECTIONS ────────────────────────────────────────── */
.builder-section { margin-top: 0; }
.builder-section .panel-title { margin-bottom: 8px; }

.build-group {
  display: grid; grid-template-columns: 95px 1fr;
  gap: 9px; align-items: start;
  margin-bottom: 9px;
}

.build-label {
  font-size: 11px; font-weight: 600;
  color: var(--text); padding-top: 7px;
}

.build-label-sub {
  font-size: 10.5px; font-weight: 600;
  color: var(--muted-bright); padding-top: 7px;
}

.build-group.stacked { grid-template-columns: 1fr; }
.build-group.stacked .build-label { padding-top: 0; margin-bottom: 5px; }

/* ─── DROP ZONES ──────────────────────────────────────────────── */
.drop-zone {
  min-height: 34px;
  background: var(--surface2);
  border: 2px dashed var(--border-bright);
  border-radius: 7px; padding: 7px;
  display: flex; flex-wrap: wrap; gap: 5px;
  align-items: center; transition: all var(--t);
  position: relative;
}

.drop-zone:empty::before {
  content: 'Drop here';
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%,-50%);
  color: var(--muted); font-size: 10px;
  pointer-events: none; font-style: italic;
}

.drop-zone-large { min-height: 52px; }
.drop-zone-inline { flex: 1; min-height: 30px; }
.drop-zone.drag-over { border-color: var(--accent); background: rgba(234,92,42,.1); }
.drop-zone.has-content { border-style: solid; border-color: var(--border-bright); }

/* ─── DROPPED CELLS ───────────────────────────────────────────── */
.dropped-cell {
  background: var(--surface3);
  border: 1px solid var(--border-bright);
  border-radius: 5px; padding: 4px 8px;
  font-size: 11px; display: inline-flex;
  align-items: center; gap: 5px;
  cursor: pointer; transition: all var(--t); color: var(--text);
}
.dropped-cell:hover { border-color: var(--accent); }

.dropped-cell .remove-cell {
  color: var(--muted-bright); font-size: 12px; font-weight: 700;
  cursor: pointer; transition: color var(--t);
}
.dropped-cell .remove-cell:hover { color: #ff6b6b; }
.dropped-cell.linked { background: rgba(234,92,42,.15); border-color: var(--accent); }
.dropped-cell .link-icon { font-size: 10px; color: var(--accent); }

/* ─── FIELDS ──────────────────────────────────────────────────── */
.field-row {
  display: grid; grid-template-columns: 1fr 1fr auto;
  gap: 8px; align-items: start;
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: 8px; padding: 9px;
  margin-bottom: 7px;
}
.field-col { display: flex; flex-direction: column; }

.inline-toggle {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; cursor: pointer;
  padding-top: 18px; user-select: none;
  color: var(--muted-bright);
}
.inline-toggle input { cursor: pointer; }

/* ─── ADD MODULE BUTTON ───────────────────────────────────────── */
.btn-add-module {
  background: var(--surface);
  border: 1px dashed var(--border-bright);
  border-radius: 8px; color: var(--accent);
  font-size: 12.5px; font-weight: 600;
  padding: 9px; width: 100%;
  cursor: pointer; transition: all var(--t); margin-top: 7px;
}
.btn-add-module:hover { border-color: var(--accent); background: rgba(234,92,42,.07); }

/* ─── MODULE BLOCKS ───────────────────────────────────────────── */
.module-block {
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: 8px; padding: 11px;
  margin-bottom: 9px; position: relative;
}
.module-options { margin-top: 8px; }
.inline-options { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }

.module-separator {
  border-top: 1px solid var(--border-bright);
  margin: 10px 0; padding-top: 8px;
  display: flex; align-items: center; gap: 8px;
  font-size: 11px; color: var(--muted-bright);
}
.module-separator label { display: flex; align-items: center; gap: 4px; cursor: pointer; }

.remove-module {
  position: absolute; top: 8px; right: 8px;
  background: var(--surface2);
  border: 1px solid var(--border-bright);
  border-radius: 4px; padding: 3px 7px;
  font-size: 11px; color: var(--muted-bright);
  cursor: pointer; transition: all var(--t);
}
.remove-module:hover { border-color: #ff6b6b; color: #ff6b6b; }

/* ─── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 900px) {
  body { height: auto; overflow: auto; }
  .layout { grid-template-columns: 1fr; height: auto; }
  .panel { height: auto; overflow-y: visible; }
  .panel-right { overflow: visible; height: auto; }
  .panel-left { border-right: none; border-bottom: 1px solid var(--border-bright); }
  .panel { padding: 16px 14px; }
  .generate-area { padding: 12px 14px; }
  .build-group { grid-template-columns: 1fr; }
  .build-label, .build-label-sub { padding-top: 0; margin-bottom: 4px; }
  .palette-builder-row { grid-template-columns: 1fr; height: auto; }
  .palette-col, .builder-col { overflow-y: visible; height: auto; }
}

@media (max-width: 500px) {
  header { padding: 0 14px; }
  header h1 { font-size: .95rem; }
}

/* ─── COLOR + PREVIEW ROW ─────────────────────────────────────── */
.color-preview-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.color-section { margin-bottom: 0; flex: 1; }

.btn-preview {
  background: var(--surface2);
  border: 1px solid var(--border-bright);
  border-radius: 8px;
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  padding: 7px 14px;
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
  flex-shrink: 0;
}
.btn-preview:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(234,92,42,.08);
}

/* ─── CELL TOOLTIP ────────────────────────────────────────────── */
.cell-wrap {
  position: relative;
}
.cell-wrap .cell-desc {
  display: none;
  position: fixed;
  background: #131110;
  color: #fbf9fe;
  border: 1px solid var(--border-bright);
  border-radius: var(--radius);
  padding: 9px 13px;
  font-size: 12px;
  line-height: 1.6;
  width: 240px;
  z-index: 999999;
  pointer-events: none;
  box-shadow: 0 12px 40px rgba(0,0,0,.9);
}
.cell-wrap:hover .cell-desc { display: block; }

/* ─── PREVIEW MODAL ───────────────────────────────────────────── */
.preview-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.preview-overlay.open { display: flex; animation: sd .2s ease; }

.preview-modal {
  background: var(--surface);
  border: 1px solid var(--border-bright);
  border-radius: 14px;
  width: min(680px, 95vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(0,0,0,.8);
}

.preview-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-bright);
  flex-shrink: 0;
}

.preview-modal-title {
  font-weight: 700;
  font-size: 14px;
}

.preview-modal-sub {
  font-size: 11px;
  color: var(--muted-bright);
  flex: 1;
}

.preview-close {
  background: none;
  border: none;
  color: var(--muted-bright);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  transition: color var(--t), background var(--t);
  line-height: 1;
}
.preview-close:hover { color: #ff6b6b; background: rgba(255,107,107,.1); }

.preview-discord-bg {
  background: #313338;
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
}

/* Bot message row */
.preview-bot-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 8px;
}

.preview-bot-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  object-fit: cover;
}

.preview-bot-name {
  font-weight: 600;
  font-size: 14px;
  color: #fff;
}

.preview-bot-tag {
  background: #5865f2;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 3px;
  margin-left: 5px;
  vertical-align: middle;
  letter-spacing: .04em;
}

.preview-bot-time {
  color: #72767d;
  font-size: 11px;
  margin-left: 8px;
}

/* Discord embed */
.preview-embed {
  background: #2b2d31;
  border-left: 4px solid var(--accent);
  border-radius: 0 4px 4px 0;
  padding: 10px 14px 12px;
  max-width: 520px;
  margin-left: 52px;
  font-family: 'gg sans', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

.preview-embed-author {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 6px;
}

.preview-embed-author-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
}

.preview-embed-author-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
}

.preview-embed-title {
  color: #00aff4;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
  cursor: pointer;
}

.preview-embed-desc {
  color: #dbdee1;
  font-size: 13.5px;
  line-height: 1.6;
  margin-bottom: 8px;
  white-space: pre-wrap;
}

.preview-embed-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.preview-embed-field {
  flex: 1 1 auto;
  min-width: 120px;
}
.preview-embed-field.block { flex: 1 1 100%; }

.preview-embed-field-name {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 2px;
}
.preview-embed-field-value {
  font-size: 12.5px;
  color: #dbdee1;
}

.preview-embed-image {
  width: 100%;
  max-width: 400px;
  border-radius: 4px;
  margin-top: 8px;
  object-fit: cover;
  display: block;
}

.preview-embed-thumbnail {
  float: right;
  width: 72px; height: 72px;
  border-radius: 4px;
  object-fit: cover;
  margin-left: 12px;
}

.preview-embed-footer {
  font-size: 11.5px;
  color: #72767d;
  margin-top: 8px;
  clear: both;
}

.preview-embed-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: 52px;
  margin-top: 6px;
}

.preview-btn-link {
  background: #4e5058;
  color: #fff;
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: default;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Empty preview */
.preview-empty {
  color: #72767d;
  font-size: 13px;
  text-align: center;
  padding: 40px 20px;
  font-style: italic;
}

/* ─── FIELD CUSTOM TEXT INPUT ─────────────────────────────────── */
.field-custom-input {
  margin-top: 5px;
  font-size: 11.5px;
  padding: 5px 9px;
  color: var(--muted-bright);
  border-color: var(--border);
  background: var(--bg);
}
.field-custom-input:focus {
  border-color: var(--accent);
  color: var(--text);
}