/* ── builder layout ──────────────────────────────────────────────────── */
.builder { padding: 36px 0 64px; }
.builder-head { display: flex; gap: 20px; align-items: end; justify-content: space-between; flex-wrap: wrap; margin-bottom: 26px; }
.builder-title { font-size: clamp(30px, 4.4vw, 44px); margin: 8px 0 10px; }
.builder-sub { max-width: 640px; margin: 0; }
.head-actions { gap: 8px; }

.panes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 22px; align-items: start; }
.pane-side { display: grid; gap: 22px; position: sticky; top: 88px; }
.pane-edit { display: grid; gap: 12px; }

.tabs { display: none; }
@media (max-width: 980px) {
  .panes { grid-template-columns: 1fr; }
  .pane-side { position: static; }
  .tabs {
    display: flex; position: sticky; top: 76px; z-index: 20; gap: 4px; padding: 4px; margin-bottom: 18px;
    background: rgba(19, 19, 22, 0.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border); border-radius: 999px;
  }
  .tabs button { flex: 1; height: 38px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-weight: 550; cursor: pointer; transition: background 0.15s var(--ease), color 0.15s var(--ease); }
  .tabs button[aria-selected="true"] { background: var(--surface-3); color: var(--text); }
  [data-pane] { display: none !important; }
  [data-pane].active { display: grid !important; }
  .pane-preview.active, .pane-code.active { display: block !important; }
}

/* ── editor controls ─────────────────────────────────────────────────── */
.segmented { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.segmented button { height: 42px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-weight: 600; cursor: pointer; transition: background 0.15s var(--ease), color 0.15s var(--ease); }
.segmented button[aria-checked="true"] { background: var(--surface-3); color: var(--text); }
.mode-hint { margin: 0 2px; font-size: 14px; }

.vars { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 13px; }
.vars button { height: 30px; padding: 0 11px; border-radius: 999px; border: 1px dashed var(--border-strong); background: transparent; color: var(--soft); cursor: pointer; font-size: 13px; transition: border-color 0.15s var(--ease), color 0.15s var(--ease); }
.vars button:hover { border-color: var(--accent); color: var(--text); }

.group { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.group > summary { list-style: none; cursor: pointer; padding: 16px 20px; font-weight: 600; display: flex; gap: 8px; align-items: center; }
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after { content: "›"; margin-left: auto; color: var(--faint); transition: transform 0.2s var(--ease); font-size: 18px; }
.group[open] > summary::after { transform: rotate(90deg); }
.group > :not(summary) { margin-inline: 20px; }
.group > :last-child { margin-bottom: 20px; }
.group em { font-style: normal; font-weight: 500; font-size: 13px; }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field > span { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 10px; }
.field.narrow { max-width: 220px; }
input[type="text"], input:not([type]), textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--border); border-radius: 10px;
  padding: 11px 13px; color: var(--text); font-size: 15px; line-height: 1.45;
  transition: border-color 0.15s var(--ease), background 0.15s var(--ease);
}
textarea { resize: vertical; min-height: 46px; }
input:focus, textarea:focus { outline: none; border-color: rgba(180, 160, 255, 0.55); background: #0e0e11; }
input::placeholder, textarea::placeholder { color: var(--faint); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.count { color: var(--faint); font-variant-numeric: tabular-nums; }
.count.over { color: var(--bad); }

.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type="color"] { width: 46px; height: 44px; padding: 3px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg); cursor: pointer; flex: none; }
.color-row input[type="text"] { max-width: 140px; font-family: var(--mono); text-transform: uppercase; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.swatches button { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; transition: transform 0.15s var(--ease), border-color 0.15s var(--ease); }
.swatches button:hover { transform: scale(1.1); }
.swatches button[aria-pressed="true"] { border-color: var(--text); }

.check { display: flex; gap: 10px; align-items: center; margin: 4px 0 12px; cursor: pointer; color: var(--soft); font-size: 15px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.check.small { margin: 0; font-size: 13px; color: var(--muted); }

.item { border: 1px solid var(--border); border-radius: 12px; padding: 12px 12px 2px; margin-bottom: 10px; background: var(--bg); }
.item-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; color: var(--muted); font-size: 13px; }
.item-head .grow { flex: 1; }
.icon-btn { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; border: 0; background: transparent; color: var(--muted); cursor: pointer; transition: background 0.15s var(--ease), color 0.15s var(--ease); }
.icon-btn:hover { background: var(--surface-3); color: var(--text); }
.icon-btn.danger:hover { color: var(--bad); }
.add { margin-top: 2px; }

body:not(.mode-cv2) .cv2-only { display: none !important; }
body.mode-cv2 .embed-only { display: none !important; }

/* ── preview chrome ──────────────────────────────────────────────────── */
.pane-preview, .pane-code { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.preview-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.preview-bar .check { margin-left: auto; }
.mini-seg { display: inline-flex; padding: 3px; border-radius: 999px; background: var(--bg); border: 1px solid var(--border); }
.mini-seg button { height: 28px; padding: 0 12px; border: 0; border-radius: 999px; background: transparent; color: var(--muted); font-size: 13px; cursor: pointer; transition: background 0.15s var(--ease), color 0.15s var(--ease); }
.mini-seg button[aria-pressed="true"] { background: var(--surface-3); color: var(--text); }
.dc-frame { border-radius: 12px; overflow: hidden; border: 1px solid var(--border); transition: max-width 0.25s var(--ease); max-width: 100%; margin-inline: auto; }
.dc-frame.mobile { max-width: 390px; }
.limits { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 12px; font-size: 12.5px; color: var(--faint); font-variant-numeric: tabular-nums; }
.limits .over { color: var(--bad); }

.code-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.code {
  margin: 0; padding: 14px; background: var(--bg); border: 1px solid var(--border); border-radius: 12px;
  font: 13px/1.6 var(--mono); color: var(--soft); white-space: pre-wrap; word-break: break-word; max-height: 320px; overflow: auto;
}
.code .t { color: var(--accent); }
.code .s { color: var(--faint); }
.code-tip { font-size: 13px; margin: 10px 2px 0; }
.warnings { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.warnings li { font-size: 13px; color: var(--warn); background: rgba(245, 201, 122, 0.07); border: 1px solid rgba(245, 201, 122, 0.2); padding: 8px 12px; border-radius: 10px; }

.menu-wrap { position: relative; }
.menu { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; padding: 6px; z-index: 30;
        background: var(--surface-2); border: 1px solid var(--border-strong); border-radius: 14px; box-shadow: var(--shadow); }
.menu button { display: block; width: 100%; text-align: left; border: 0; background: transparent; padding: 10px 12px; border-radius: 10px; cursor: pointer; color: var(--soft); }
.menu button:hover { background: var(--surface-3); color: var(--text); }
.menu small { display: block; color: var(--faint); font-size: 12.5px; }

.dialog { border: 1px solid var(--border-strong); border-radius: 18px; background: var(--surface); color: var(--text); padding: 0; width: min(560px, 100% - 32px); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(3px); }
.dialog-body { padding: 22px; display: grid; gap: 12px; }
.dialog-body h3 { margin: 0; }
.dialog-body p { margin: 0; font-size: 14px; }
.dialog-body code { font-family: var(--mono); font-size: 13px; }
.dialog-body textarea { font-family: var(--mono); font-size: 13px; }
.dialog-actions { justify-content: flex-end; }

/* ══════════════════════════════════════════════════════════════════════
   Discord look-alike (dark / onyx). Sizes and colours follow the client.
   ══════════════════════════════════════════════════════════════════════ */
.dc {
  --dc-bg: #323339; --dc-embed: #2b2d31; --dc-text: #dbdee1; --dc-head: #f2f3f5; --dc-muted: #949ba4;
  --dc-link: #00a8fc; --dc-code: #2b2d31; --dc-code-border: #1e1f22; --dc-quote: #4e5058; --dc-btn: #4e5058;
  --dc-btn-hover: #6d6f78; --dc-mention: rgba(88, 101, 242, 0.3); --dc-mention-text: #c9cdfb; --dc-sep: #3f4147;
  background: var(--dc-bg); color: var(--dc-text);
  font: 400 16px/1.375 "gg sans", "Noto Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
  padding: 18px 16px 20px 0; min-height: 160px; overflow-wrap: anywhere;
}
.dc[data-theme="onyx"] { --dc-bg: #070709; --dc-embed: #111114; --dc-code: #121215; --dc-code-border: #1d1d22; --dc-sep: #2a2a30; }
.dc-msg { display: grid; grid-template-columns: 72px minmax(0, 1fr); }
.dc-avatar { width: 40px; height: 40px; border-radius: 50%; margin: 2px 0 0 16px; }
.dc-head { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; flex-wrap: wrap; }
.dc-name { color: var(--dc-head); font-weight: 500; font-size: 16px; }
.dc-tag { display: inline-flex; align-items: center; gap: 3px; height: 15px; padding: 0 4px; border-radius: 3px; background: #5865f2; color: #fff; font-size: 10px; font-weight: 600; text-transform: uppercase; line-height: 15px; }
.dc-tag svg { width: 10px; height: 10px; }
.dc-time { color: var(--dc-muted); font-size: 12px; margin-left: 2px; }
.dc-body { min-width: 0; }
.dc-text { white-space: normal; }
.dc-text p { margin: 0; }
.dc-text h1, .dc-text h2, .dc-text h3 { color: var(--dc-head); margin: 8px 0 4px; line-height: 1.375; letter-spacing: 0; }
.dc-text h1 { font-size: 24px; font-weight: 700; }
.dc-text h2 { font-size: 20px; font-weight: 700; }
.dc-text h3 { font-size: 16px; font-weight: 700; }
.dc-text > :first-child { margin-top: 0; }
.dc-sub { color: var(--dc-muted); font-size: 13px; line-height: 1.11rem; display: block; }
.dc-text ul, .dc-text ol { margin: 4px 0; padding-left: 24px; }
.dc-text li { margin: 0; }
.dc-quote { display: flex; gap: 0; margin: 2px 0; }
.dc-quote::before { content: ""; width: 4px; border-radius: 4px; background: var(--dc-quote); flex: none; }
.dc-quote > div { padding: 0 8px 0 12px; min-width: 0; }
.dc a { color: var(--dc-link); }
.dc a:hover { text-decoration: underline; }
.dc code.inline { font-family: "gg mono", Consolas, "Andale Mono WT", Monaco, monospace; font-size: 85%; background: var(--dc-code); border: 1px solid var(--dc-code-border); border-radius: 4px; padding: 0 3px; }
.dc pre { margin: 6px 0; padding: 7px 9px; background: var(--dc-code); border: 1px solid var(--dc-code-border); border-radius: 4px; font: 14px/1.125rem "gg mono", Consolas, Monaco, monospace; white-space: pre-wrap; color: #b5bac1; }
.dc .mention { background: var(--dc-mention); color: var(--dc-mention-text); border-radius: 3px; padding: 0 2px; font-weight: 500; }
.dc .ts { background: rgba(78, 80, 88, 0.35); border-radius: 3px; padding: 0 2px; }
.dc .spoiler { background: #1e1f22; color: transparent; border-radius: 3px; cursor: pointer; transition: background 0.1s; }
.dc .spoiler.on { background: rgba(78, 80, 88, 0.3); color: inherit; }
.dc .emoji { width: 1.375em; height: 1.375em; vertical-align: bottom; object-fit: contain; display: inline-block; }
.dc .emoji.big { width: 3rem; height: 3rem; }
.dc .var { background: rgba(180, 160, 255, 0.15); color: #d9cfff; border-radius: 3px; padding: 0 3px; font-size: 92%; font-family: "gg mono", Consolas, monospace; }

/* classic embed */
.dc-embed {
  display: grid; grid-template-columns: auto; grid-template-rows: auto; max-width: 516px; margin-top: 2px;
  background: var(--dc-embed); border-radius: 4px; border-left: 4px solid var(--dc-color, #1e1f22);
  padding: 8px 16px 16px 12px; font-size: 14px; line-height: 1.375;
}
.dc-embed.has-thumb { grid-template-columns: minmax(0, 1fr) auto; }
.dc-embed > * { grid-column: 1 / 2; min-width: 0; }
.dc-e-author { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--dc-head); font-size: 14px; font-weight: 600; }
.dc-e-author img { width: 24px; height: 24px; border-radius: 50%; object-fit: cover; }
.dc-e-title { margin-top: 8px; color: var(--dc-head); font-size: 16px; font-weight: 600; }
.dc-e-title a { color: var(--dc-link); }
.dc-e-desc { margin-top: 8px; font-size: 14px; }
.dc-e-desc .dc-text h1 { font-size: 20px; } .dc-e-desc .dc-text h2 { font-size: 18px; }
.dc-e-fields { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.dc-e-field { grid-column: span 12; font-size: 14px; }
.dc-e-field.inline { grid-column: span 4; }
.dc-e-fname { color: var(--dc-head); font-weight: 600; margin-bottom: 2px; }
.dc-e-thumb { grid-column: 2 / 3 !important; grid-row: 1 / 8; margin: 8px 0 0 16px; justify-self: end; }
.dc-e-thumb img { max-width: 80px; max-height: 80px; border-radius: 4px; object-fit: contain; }
.dc-e-image { margin-top: 16px; grid-column: 1 / -1 !important; }
.dc-e-image img { max-width: 100%; max-height: 300px; border-radius: 4px; object-fit: contain; }
.dc-e-footer { display: flex; align-items: center; gap: 8px; margin-top: 8px; color: var(--dc-muted); font-size: 12px; font-weight: 500; grid-column: 1 / -1 !important; }
.dc-e-footer img { width: 20px; height: 20px; border-radius: 50%; }

/* Components V2 */
.dc-cv2 { margin-top: 2px; max-width: 600px; }
.dc-cv2 > .dc-text { margin-bottom: 8px; }
.dc-container {
  position: relative; background: var(--dc-embed); border: 1px solid rgba(255, 255, 255, 0.04);
  border-radius: 8px; padding: 16px; display: grid; gap: 8px; overflow: hidden;
}
.dc-container.accent { border-left: 4px solid var(--dc-color); }
.dc-container.spoiler-box { cursor: pointer; }
.dc-container.spoiler-box > * { filter: blur(44px); opacity: 0.6; transition: filter 0.2s, opacity 0.2s; }
.dc-container.spoiler-box::after { content: "SPOILER"; position: absolute; inset: 0; margin: auto; width: max-content; height: max-content; padding: 6px 12px; background: rgba(0, 0, 0, 0.6); color: #fff; font-weight: 700; font-size: 14px; letter-spacing: 0.05em; border-radius: 20px; }
.dc-container.spoiler-box.on > * { filter: none; opacity: 1; }
.dc-container.spoiler-box.on::after { display: none; }
.dc-section { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: start; }
.dc-section .thumb img { width: 85px; height: 85px; border-radius: 8px; object-fit: cover; }
.dc-sep { height: 1px; background: var(--dc-sep); margin: 4px 0; }
.dc-gallery img { width: 100%; max-height: 350px; object-fit: cover; border-radius: 8px; }
.dc-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.dc a.dc-btn, .dc-btn { color: #fff; }
.dc-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 14px; border-radius: 8px; background: var(--dc-btn); color: #fff; font-size: 14px; font-weight: 500; transition: background 0.15s; max-width: 100%; }
.dc-btn:hover { background: var(--dc-btn-hover); text-decoration: none !important; }
.dc-btn span.l { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dc-btn svg { width: 14px; height: 14px; flex: none; opacity: 0.9; }
.dc-btn .emoji { width: 18px; height: 18px; }
.dc img.broken { background: #1e1f22; min-width: 40px; min-height: 40px; }
.dc-empty { color: var(--dc-muted); font-style: italic; font-size: 14px; }
