/* NetRegis Website Builder — editor UI */

:root {
    --e-blue: #1d6ae5;
    --e-blue-d: #1550b8;
    --e-blue-l: #e8f0fd;
    --e-ink: #0f172a;
    --e-text: #1e293b;
    --e-dim: #475569;
    --e-muted: #94a3b8;
    --e-line: #e2e8f0;
    --e-line-2: #cbd5e1;
    --e-soft: #f8fafc;
    --e-soft-2: #f1f5f9;
    --e-stage: #e7ebf1;
    --e-danger: #dc2626;
    --e-ok: #059669;
    --e-r: 10px;
    --e-top: 58px;
    --e-rail: 76px;
    --e-panel: 372px;
    --e-font: 'Noto Sans Thai', 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    overflow: hidden;
    font-family: var(--e-font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--e-text);
    background: var(--e-stage);
    -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--e-blue); outline-offset: 2px; }

.sbe { display: grid; grid-template-rows: var(--e-top) minmax(0, 1fr); height: 100vh; height: 100dvh; }

/* ---------- Buttons ---------- */
.sbe-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    height: 38px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: 9px;
    background: var(--e-soft-2);
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.sbe-btn:hover { background: #e2e8f0; }
.sbe-btn--primary { background: var(--e-blue); color: #fff; box-shadow: 0 6px 16px -8px rgba(29, 106, 229, .8); }
.sbe-btn--primary:hover { background: var(--e-blue-d); }
.sbe-btn--ghost { background: transparent; border-color: var(--e-line); }
.sbe-btn--ghost:hover { background: var(--e-soft); border-color: var(--e-line-2); }
.sbe-btn--danger { background: #fef2f2; color: var(--e-danger); }
.sbe-btn--danger:hover { background: #fee2e2; }
.sbe-btn--sm { height: 32px; padding: 0 12px; font-size: 13px; }
.sbe-btn--block { width: 100%; }
.sbe-btn--dashed { width: 100%; height: 44px; border: 1.5px dashed var(--e-line-2); background: transparent; color: var(--e-blue); }
.sbe-btn--dashed:hover { border-color: var(--e-blue); background: var(--e-blue-l); }
.sbe-btn:disabled { opacity: .45; cursor: not-allowed; }

.sbe-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--e-dim);
    font-size: 16px;
    transition: background .15s, color .15s;
}
.sbe-icon-btn:hover:not(:disabled) { background: var(--e-soft-2); color: var(--e-ink); }
.sbe-icon-btn:disabled { opacity: .35; cursor: default; }
.sbe-icon-btn--sm { width: 30px; height: 30px; font-size: 14px; }
.sbe-icon-btn.is-danger:hover { background: #fef2f2; color: var(--e-danger); }

/* ---------- Top bar ---------- */
.sbe-top {
    position: relative;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 14px 0 12px;
    background: #fff;
    border-bottom: 1px solid var(--e-line);
}
.sbe-brand { display: flex; align-items: center; gap: 9px; flex-shrink: 0; text-decoration: none; padding-right: 14px; border-right: 1px solid var(--e-line); height: 34px; }
.sbe-brand img { border-radius: 7px; }
.sbe-brand span { font-family: 'DM Sans', var(--e-font); font-weight: 700; font-size: 15px; color: var(--e-ink); letter-spacing: -.01em; }
.sbe-doc { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.sbe-doc strong { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.sbe-status { color: var(--e-muted); font-size: 12px; display: flex; align-items: center; gap: 5px; white-space: nowrap; }
.sbe-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: var(--e-muted); }
.sbe-status.is-ok::before { background: var(--e-ok); }
.sbe-status.is-busy::before { background: #f59e0b; animation: sbePulse 1s ease-in-out infinite; }
.sbe-status.is-error { color: var(--e-danger); }
.sbe-status.is-error::before { background: var(--e-danger); }
@keyframes sbePulse { 50% { opacity: .3; } }

.sbe-center { display: flex; align-items: center; gap: 10px; margin: 0 auto; }
.sbe-pagesel { position: relative; display: flex; align-items: center; gap: 8px; height: 38px; padding: 0 32px 0 12px; border: 1px solid var(--e-line); border-radius: 9px; background: #fff; color: var(--e-dim); }
.sbe-pagesel:hover { border-color: var(--e-line-2); }
.sbe-pagesel select { appearance: none; border: 0; background: transparent; font-weight: 600; color: var(--e-ink); max-width: 180px; cursor: pointer; outline: none; padding: 0; }
.sbe-pagesel-caret { position: absolute; right: 11px; font-size: 11px; pointer-events: none; }
.sbe-seg { display: inline-flex; padding: 3px; border-radius: 10px; background: var(--e-soft-2); gap: 2px; }
.sbe-seg button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 36px;
    height: 32px;
    padding: 0 10px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: var(--e-dim);
    font-size: 13px;
    font-weight: 600;
    transition: background .15s, color .15s, box-shadow .15s;
}
.sbe-seg button:hover { color: var(--e-ink); }
.sbe-seg button.is-active { background: #fff; color: var(--e-blue); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }
.sbe-devices button { font-size: 16px; }
.sbe-actions { position: relative; display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.sbe-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    z-index: 50;
    min-width: 230px;
    padding: 6px;
    border: 1px solid var(--e-line);
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 18px 40px -12px rgba(15, 23, 42, .25);
}
.sbe-menu button, .sbe-menu a { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px; background: none; text-align: left; text-decoration: none; font-size: 14px; }
.sbe-menu button:hover, .sbe-menu a:hover { background: var(--e-soft-2); }
.sbe-menu i { color: var(--e-dim); width: 18px; }

/* ---------- Body: rail / panel / stage ---------- */
.sbe-body { display: grid; grid-template-columns: var(--e-rail) var(--e-panel) minmax(0, 1fr); min-height: 0; }
.sbe-rail { display: flex; flex-direction: column; gap: 4px; padding: 10px 8px; background: #fff; border-right: 1px solid var(--e-line); }
.sbe-rail button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 10px 2px 8px;
    border: 0;
    border-radius: 10px;
    background: none;
    color: var(--e-dim);
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.25;
    text-align: center;
    transition: background .15s, color .15s;
}
.sbe-rail button i { font-size: 20px; }
.sbe-rail button:hover { background: var(--e-soft-2); color: var(--e-ink); }
.sbe-rail button.is-active { background: var(--e-blue-l); color: var(--e-blue); }

.sbe-panel { position: relative; min-height: 0; background: #fff; border-right: 1px solid var(--e-line); }
.sbe-panel-scroll { height: 100%; overflow-y: auto; overscroll-behavior: contain; padding: 18px 18px 40px; scrollbar-width: thin; }

.sbe-stage { position: relative; min-width: 0; min-height: 0; padding: 16px; display: flex; flex-direction: column; background-color: var(--e-stage); background-image: radial-gradient(#d3d9e2 1px, transparent 1px); background-size: 18px 18px; }
.sbe-canvas {
    position: relative;
    flex: 1;
    width: 100%;
    min-height: 0;
    margin: 0 auto;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 20px 50px -20px rgba(15, 23, 42, .35);
    transition: width .3s ease, border-radius .3s ease;
}
.sbe-canvas[data-device="tablet"] { width: min(834px, 100%); }
.sbe-canvas[data-device="mobile"] { width: 410px; max-width: 100%; max-height: 860px; border-radius: 34px; border: 10px solid #0f172a; box-shadow: 0 30px 60px -24px rgba(15, 23, 42, .55); }
.sbe-stage:has(.sbe-canvas[data-device="mobile"]) { justify-content: center; }
/* The back buffer stays "visible" to the browser (opacity, not visibility) so it is fully painted before the swap */
.sbe-frame { position: absolute; inset: 0; z-index: 0; width: 100%; height: 100%; border: 0; background: #fff; opacity: 0; pointer-events: none; }
.sbe-frame.is-active { z-index: 1; opacity: 1; pointer-events: auto; }
.sbe-loading { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; background: #fff; color: var(--e-dim); font-weight: 500; }
.sbe-spinner { width: 34px; height: 34px; border: 3px solid var(--e-line); border-top-color: var(--e-blue); border-radius: 50%; animation: sbeSpin .8s linear infinite; }
@keyframes sbeSpin { to { transform: rotate(360deg); } }
.sbe-preview-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 12px; padding: 8px 8px 8px 16px; border-radius: 12px; background: #0f172a; color: #e2e8f0; font-size: 13.5px; }

/* Preview mode: no panel */
.sbe.is-preview .sbe-body { grid-template-columns: 0 0 minmax(0, 1fr); }
.sbe.is-preview .sbe-rail, .sbe.is-preview .sbe-panel { display: none; }

/* ---------- Panel content ---------- */
.sbe-ph { display: flex; align-items: center; gap: 10px; margin: -2px 0 16px; }
.sbe-ph h2 { flex: 1; min-width: 0; margin: 0; font-size: 17px; font-weight: 700; color: var(--e-ink); line-height: 1.3; }
.sbe-ph h2 small { display: block; font-size: 12px; font-weight: 500; color: var(--e-muted); }
.sbe-ph .sbe-icon-btn { margin-left: -6px; }
.sbe-ph-tools { display: flex; gap: 2px; }
.sbe-hint { margin: -6px 0 16px; color: var(--e-dim); font-size: 13px; }
.sbe-hint i { color: var(--e-blue); }
.sbe-note { margin: 8px 0 0; padding: 10px 12px; border-radius: 9px; background: var(--e-soft); color: var(--e-dim); font-size: 12.5px; }
.sbe-note i { color: var(--e-blue); }

.sbe-group { padding: 16px 0; border-top: 1px solid var(--e-line); }
.sbe-group:first-of-type { border-top: 0; padding-top: 4px; }
.sbe-group-title { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--e-muted); }
.sbe-group-title i { font-size: 14px; }
.sbe-collapse > summary { list-style: none; cursor: pointer; }
.sbe-collapse > summary::-webkit-details-marker { display: none; }
.sbe-collapse > summary .sbe-group-title { margin: 0; }
.sbe-collapse > summary .sbe-group-title::after { content: '\F282'; font-family: 'bootstrap-icons'; margin-left: auto; transition: transform .2s; }
.sbe-collapse[open] > summary .sbe-group-title { margin-bottom: 12px; }
.sbe-collapse[open] > summary .sbe-group-title::after { transform: rotate(180deg); }

.sbe-field { margin-bottom: 14px; }
.sbe-field:last-child { margin-bottom: 0; }
.sbe-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 6px; font-size: 13px; font-weight: 600; color: var(--e-text); }
.sbe-label small { font-weight: 500; color: var(--e-muted); font-size: 12px; }
.sbe-help { margin: 5px 0 0; font-size: 12px; color: var(--e-muted); }
.sbe-input, .sbe-textarea, .sbe-select {
    display: block;
    width: 100%;
    padding: 9px 11px;
    border: 1px solid var(--e-line-2);
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    transition: border-color .15s, box-shadow .15s;
}
.sbe-input:hover, .sbe-textarea:hover, .sbe-select:hover { border-color: #94a3b8; }
.sbe-input:focus, .sbe-textarea:focus, .sbe-select:focus { outline: none; border-color: var(--e-blue); box-shadow: 0 0 0 3px rgba(29, 106, 229, .15); }
.sbe-input.is-invalid { border-color: var(--e-danger); box-shadow: 0 0 0 3px rgba(220, 38, 38, .12); }
/* A setting opened from the page: flash it so it is easy to spot */
.sbe-input.is-flash, .sbe-textarea.is-flash { animation: sbeFlash 1.6s ease; }
@keyframes sbeFlash { 0%, 60% { border-color: var(--e-blue); box-shadow: 0 0 0 4px rgba(29, 106, 229, .3); } }
.sbe-textarea { resize: vertical; min-height: 64px; line-height: 1.55; }
.sbe-select { appearance: none; padding-right: 32px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16'%3E%3Cpath fill='%2364748b' d='M1.6 4.6a.8.8 0 0 1 1.1 0L8 9.9l5.3-5.3a.8.8 0 1 1 1.1 1.1l-5.8 5.9a.8.8 0 0 1-1.2 0L1.6 5.7a.8.8 0 0 1 0-1.1z'/%3E%3C/svg%3E") no-repeat right 11px center; cursor: pointer; }
.sbe-input + .sbe-input, .sbe-select + .sbe-input { margin-top: 8px; }
.sbe-row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.sbe-row2 .sbe-field { margin-bottom: 0; }
.sbe-field .sbe-seg { display: flex; width: 100%; }
.sbe-field .sbe-seg button { flex: 1; }

/* switch */
.sbe-toggle { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; cursor: pointer; font-size: 13.5px; font-weight: 500; }
.sbe-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.sbe-toggle-ui { position: relative; flex-shrink: 0; width: 40px; height: 23px; border-radius: 999px; background: var(--e-line-2); transition: background .2s; }
.sbe-toggle-ui::after { content: ''; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .2s; }
.sbe-toggle input:checked + .sbe-toggle-ui { background: var(--e-blue); }
.sbe-toggle input:checked + .sbe-toggle-ui::after { transform: translateX(17px); }
.sbe-toggle input:focus-visible + .sbe-toggle-ui { outline: 2px solid var(--e-blue); outline-offset: 2px; }

/* range */
.sbe-range { display: flex; align-items: center; gap: 12px; }
.sbe-range input[type="range"] { flex: 1; accent-color: var(--e-blue); }
.sbe-range output { min-width: 44px; padding: 4px 6px; border-radius: 6px; background: var(--e-soft-2); text-align: center; font-size: 12.5px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Section list ---------- */
.sbe-list { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.sbe-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 8px 8px 6px;
    border: 1px solid var(--e-line);
    border-radius: var(--e-r);
    background: #fff;
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s, background .15s;
    user-select: none;
}
.sbe-row:hover { border-color: #a8c3f3; box-shadow: 0 4px 14px -8px rgba(29, 106, 229, .45); }
.sbe-row.is-active { border-color: var(--e-blue); background: var(--e-blue-l); }
.sbe-row.is-hidden .sbe-row-main { opacity: .45; }
.sbe-row.is-fixed { background: var(--e-soft); border-style: dashed; }
.sbe-row.is-dragging { opacity: .4; }
.sbe-row.is-drop-before::before, .sbe-row.is-drop-after::after { content: ''; position: absolute; left: 6px; right: 6px; height: 3px; border-radius: 3px; background: var(--e-blue); }
.sbe-row.is-drop-before::before { top: -5px; }
.sbe-row.is-drop-after::after { bottom: -5px; }
.sbe-grip { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 30px; color: var(--e-muted); cursor: grab; touch-action: none; font-size: 15px; }
.sbe-grip:active { cursor: grabbing; }
.sbe-row-icon { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; flex-shrink: 0; border-radius: 9px; background: var(--e-soft-2); color: var(--e-dim); font-size: 17px; }
.sbe-row.is-active .sbe-row-icon { background: #fff; color: var(--e-blue); }
.sbe-row-main { flex: 1; min-width: 0; line-height: 1.3; }
.sbe-row-main strong { display: block; font-size: 13.5px; font-weight: 600; }
.sbe-row-main small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--e-muted); font-size: 12px; }
.sbe-row-tools { display: flex; gap: 0; opacity: .0; transition: opacity .15s; }
.sbe-row:hover .sbe-row-tools, .sbe-row.is-active .sbe-row-tools, .sbe-row-tools:focus-within { opacity: 1; }
.sbe-row.is-hidden .sbe-row-tools { opacity: 1; }
.sbe-add-gap { display: block; margin: 12px 0 0; }

/* ---------- Layout pickers ---------- */
.sbe-variants { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.sbe-variant {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 8px 8px 7px;
    border: 1.5px solid var(--e-line);
    border-radius: 10px;
    background: #fff;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--e-dim);
    text-align: center;
    transition: border-color .15s, box-shadow .15s, color .15s;
}
.sbe-variant:hover { border-color: #a8c3f3; color: var(--e-ink); }
.sbe-variant.is-active { border-color: var(--e-blue); color: var(--e-blue); box-shadow: 0 0 0 3px rgba(29, 106, 229, .14); }
.sbe-variant svg { display: block; width: 100%; height: auto; border-radius: 6px; background: var(--e-soft-2); }
.sbe-variant.is-active svg { background: #eef4fe; }
.sk-h { fill: #334155; }
.sk-t { fill: #cbd5e1; }
.sk-i { fill: #9fc0f5; }
.sk-b { fill: #1d6ae5; }
.sk-c { fill: #fff; stroke: #cbd5e1; stroke-width: .8; }
.sk-p { fill: #1d6ae5; }
.sk-l { fill: #fff; opacity: .9; }
.sk-d { fill: #1e293b; }
.sk-m { fill: #fde68a; }

.sbe-swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.sbe-swatch {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px 6px 6px;
    border: 1.5px solid var(--e-line);
    border-radius: 999px;
    background: #fff;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--e-dim);
}
.sbe-swatch span { width: 20px; height: 20px; border-radius: 50%; border: 1px solid rgba(15, 23, 42, .12); }
.sbe-swatch:hover { border-color: #a8c3f3; }
.sbe-swatch.is-active { border-color: var(--e-blue); color: var(--e-blue); }

/* ---------- Items (repeatable lists) ---------- */
.sbe-items { display: grid; gap: 8px; }
.sbe-item { border: 1px solid var(--e-line); border-radius: var(--e-r); background: #fff; overflow: hidden; }
.sbe-item.is-open { border-color: var(--e-line-2); box-shadow: 0 6px 18px -12px rgba(15, 23, 42, .35); }
.sbe-item-head { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 10px; cursor: pointer; user-select: none; }
.sbe-item-head:hover { background: var(--e-soft); }
.sbe-item-thumb { width: 34px; height: 34px; flex-shrink: 0; border-radius: 7px; background: var(--e-soft-2) center / cover no-repeat; display: inline-flex; align-items: center; justify-content: center; color: var(--e-muted); font-size: 15px; }
.sbe-item-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; font-weight: 600; }
.sbe-item-title small { color: var(--e-muted); font-weight: 500; }
.sbe-item-tools { display: flex; }
.sbe-item-body { padding: 12px 12px 14px; border-top: 1px solid var(--e-line); background: var(--e-soft); }
.sbe-item-body .sbe-input, .sbe-item-body .sbe-textarea, .sbe-item-body .sbe-select { background-color: #fff; }

/* ---------- Image field ---------- */
.sbe-image { display: flex; gap: 10px; align-items: stretch; }
.sbe-image-thumb {
    position: relative;
    width: 108px;
    height: 76px;
    flex-shrink: 0;
    border: 1px solid var(--e-line);
    border-radius: 9px;
    overflow: hidden;
    background: repeating-conic-gradient(#f1f5f9 0% 25%, #fff 0% 50%) 50% / 14px 14px;
    cursor: pointer;
}
.sbe-image-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sbe-image-thumb.is-logo img { object-fit: contain; padding: 6px; }
.sbe-image-thumb.is-empty { display: flex; align-items: center; justify-content: center; color: var(--e-muted); font-size: 22px; }
.sbe-image-thumb:hover { border-color: var(--e-blue); }
.sbe-image-actions { display: flex; flex-direction: column; justify-content: center; gap: 6px; min-width: 0; }
.sbe-image-actions .sbe-btn { justify-content: flex-start; }

/* ---------- Link field ---------- */
.sbe-link-custom { margin-top: 8px; }

/* ---------- Icon picker ---------- */
.sbe-icon-pick { display: flex; align-items: center; gap: 10px; width: 100%; padding: 6px 10px 6px 6px; border: 1px solid var(--e-line-2); border-radius: 8px; background: #fff; text-align: left; }
.sbe-icon-pick:hover { border-color: #94a3b8; }
.sbe-icon-pick > i:first-child { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 7px; background: var(--e-blue-l); color: var(--e-blue); font-size: 16px; }
.sbe-icon-pick span { flex: 1; color: var(--e-dim); font-size: 13px; }
.sbe-icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; }
.sbe-icon-grid button { aspect-ratio: 1; border: 1px solid var(--e-line); border-radius: 9px; background: #fff; font-size: 19px; color: var(--e-text); }
.sbe-icon-grid button:hover { border-color: var(--e-blue); color: var(--e-blue); background: var(--e-blue-l); }
.sbe-icon-grid button.is-active { border-color: var(--e-blue); background: var(--e-blue); color: #fff; }

/* ---------- Theme ---------- */
.sbe-palettes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.sbe-palette { padding: 0; border: 1.5px solid var(--e-line); border-radius: 12px; overflow: hidden; background: #fff; text-align: left; transition: border-color .15s, box-shadow .15s, transform .15s; }
.sbe-palette:hover { border-color: #a8c3f3; transform: translateY(-1px); }
.sbe-palette.is-active { border-color: var(--e-blue); box-shadow: 0 0 0 3px rgba(29, 106, 229, .16); }
.sbe-palette-demo { position: relative; display: flex; flex-direction: column; gap: 5px; height: 66px; padding: 11px 12px; }
.sbe-palette-demo b { display: block; width: 62%; height: 7px; border-radius: 4px; }
.sbe-palette-demo i { display: block; width: 84%; height: 4px; border-radius: 3px; opacity: .55; }
.sbe-palette-demo em { position: absolute; left: 12px; bottom: 10px; width: 38px; height: 12px; border-radius: 999px; }
.sbe-palette-demo s { position: absolute; right: 12px; bottom: 10px; width: 12px; height: 12px; border-radius: 50%; }
.sbe-palette-name { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 7px 10px; border-top: 1px solid var(--e-line); font-size: 12.5px; font-weight: 600; color: var(--e-text); }
.sbe-palette-name small { color: var(--e-muted); font-weight: 500; font-size: 11px; }
.sbe-colors { display: grid; gap: 10px; }
.sbe-color { display: flex; align-items: center; gap: 10px; }
.sbe-color input[type="color"] { width: 42px; height: 36px; padding: 2px; border: 1px solid var(--e-line-2); border-radius: 8px; background: #fff; cursor: pointer; flex-shrink: 0; }
.sbe-color .sbe-input { flex: 1; font-family: 'DM Sans', monospace; text-transform: lowercase; }
.sbe-color-label { width: 74px; flex-shrink: 0; font-weight: 600; font-size: 13px; }
.sbe-fonts { display: grid; gap: 6px; }
.sbe-font { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border: 1.5px solid var(--e-line); border-radius: 10px; background: #fff; text-align: left; }
.sbe-font:hover { border-color: #a8c3f3; }
.sbe-font.is-active { border-color: var(--e-blue); background: var(--e-blue-l); }
.sbe-font strong { font-size: 18px; font-weight: 600; line-height: 1.2; color: var(--e-ink); }
.sbe-font small { color: var(--e-muted); font-size: 11.5px; white-space: nowrap; }
.sbe-shapes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.sbe-shape { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 12px 6px 9px; border: 1.5px solid var(--e-line); border-radius: 10px; background: #fff; font-size: 12.5px; font-weight: 600; color: var(--e-dim); }
.sbe-shape:hover { border-color: #a8c3f3; }
.sbe-shape.is-active { border-color: var(--e-blue); color: var(--e-blue); background: var(--e-blue-l); }
.sbe-shape-demo { width: 54px; height: 30px; border: 2px solid currentColor; }
.sbe-shape-btn { padding: 4px 12px; background: currentColor; }
.sbe-shape-btn::before { content: 'ปุ่ม'; color: #fff; font-size: 11px; }

/* ---------- Logo box ---------- */
.sbe-logo-box { display: flex; align-items: center; justify-content: center; min-height: 96px; margin-bottom: 10px; padding: 14px; border: 1px solid var(--e-line); border-radius: 12px; cursor: pointer; transition: border-color .15s; }
.sbe-logo-box:hover { border-color: var(--e-blue); }
.sbe-logo-box img { max-width: 100%; max-height: 72px; object-fit: contain; }
.sbe-logo-box span { font-size: 21px; font-weight: 700; }

/* ---------- Pages ---------- */
.sbe-page-badge { display: inline-block; padding: 1px 7px; border-radius: 999px; background: var(--e-soft-2); color: var(--e-dim); font-size: 11px; font-weight: 600; margin-left: 6px; vertical-align: 1px; }

/* ---------- Modal ---------- */
.sbe-modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 20px; background: rgba(15, 23, 42, .5); backdrop-filter: blur(3px); animation: sbeFade .15s ease; }
@keyframes sbeFade { from { opacity: 0; } }
.sbe-modal-box { display: flex; flex-direction: column; width: min(760px, 100%); max-height: min(86vh, 860px); border-radius: 16px; background: #fff; box-shadow: 0 40px 80px -30px rgba(15, 23, 42, .5); animation: sbeRise .2s ease; }
.sbe-modal-box.is-small { width: min(460px, 100%); }
@keyframes sbeRise { from { transform: translateY(12px); opacity: 0; } }
.sbe-modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 16px 12px 22px; border-bottom: 1px solid var(--e-line); }
.sbe-modal-head h2 { margin: 0; font-size: 17px; font-weight: 700; }
.sbe-modal-body { overflow-y: auto; padding: 18px 22px 22px; }
.sbe-modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.sbe-modal-foot--start { justify-content: flex-start; padding-top: 14px; border-top: 1px solid var(--e-line); }

.sbe-types { display: grid; grid-template-columns: repeat(auto-fill, minmax(196px, 1fr)); gap: 10px; }
.sbe-type { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border: 1.5px solid var(--e-line); border-radius: 12px; background: #fff; text-align: left; transition: border-color .15s, box-shadow .15s, transform .15s; }
.sbe-type:hover { border-color: var(--e-blue); box-shadow: 0 10px 24px -14px rgba(29, 106, 229, .6); transform: translateY(-1px); }
.sbe-type > i { display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex-shrink: 0; border-radius: 10px; background: var(--e-blue-l); color: var(--e-blue); font-size: 19px; }
.sbe-type strong { display: block; font-size: 14px; margin-bottom: 2px; }
.sbe-type small { display: block; color: var(--e-dim); font-size: 12.5px; line-height: 1.45; }

.sbe-tabs { display: flex; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--e-line); }
.sbe-tabs button { padding: 8px 12px 10px; border: 0; border-bottom: 2px solid transparent; background: none; font-weight: 600; color: var(--e-dim); margin-bottom: -1px; }
.sbe-tabs button.is-active { color: var(--e-blue); border-bottom-color: var(--e-blue); }
.sbe-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; min-height: 190px; padding: 24px; border: 2px dashed var(--e-line-2); border-radius: 14px; background: var(--e-soft); text-align: center; color: var(--e-dim); cursor: pointer; transition: border-color .15s, background .15s; }
.sbe-drop i { font-size: 34px; color: var(--e-blue); }
.sbe-drop strong { color: var(--e-ink); font-size: 15px; }
.sbe-drop:hover, .sbe-drop.is-over { border-color: var(--e-blue); background: var(--e-blue-l); }
.sbe-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.sbe-gallery button { position: relative; aspect-ratio: 4 / 3; padding: 0; border: 2px solid transparent; border-radius: 10px; overflow: hidden; background: var(--e-soft-2); }
.sbe-gallery button img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .2s; }
.sbe-gallery button:hover { border-color: var(--e-blue); }
.sbe-gallery button:hover img { transform: scale(1.05); }
.sbe-gallery button.is-active { border-color: var(--e-blue); }
.sbe-gallery button.is-active::after { content: '\F26A'; font-family: 'bootstrap-icons'; position: absolute; top: 6px; right: 6px; display: flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 50%; background: var(--e-blue); color: #fff; font-size: 13px; }
.sbe-empty { padding: 26px; text-align: center; color: var(--e-muted); }

.sbe-help-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 14px; }
.sbe-help-list li { display: flex; gap: 12px; }
.sbe-help-list i { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; flex-shrink: 0; border-radius: 9px; background: var(--e-blue-l); color: var(--e-blue); font-size: 16px; }
.sbe-help-list strong { display: block; }
.sbe-help-list span { color: var(--e-dim); font-size: 13.5px; }

/* ---------- Toast ---------- */
.sbe-toast { position: fixed; left: 50%; bottom: 24px; z-index: 120; display: flex; align-items: center; gap: 14px; width: max-content; max-width: calc(100vw - 32px); padding: 11px 12px 11px 16px; border-radius: 12px; background: #0f172a; color: #f8fafc; font-size: 13.5px; box-shadow: 0 20px 40px -14px rgba(15, 23, 42, .6); transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.sbe-toast.is-on { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }
.sbe-toast span { flex: 1 1 auto; min-width: 0; }
.sbe-toast button { padding: 5px 10px; border: 0; border-radius: 7px; background: rgba(255, 255, 255, .14); color: #fff; font-weight: 600; font-size: 13px; white-space: nowrap; }
.sbe-toast button:hover { background: rgba(255, 255, 255, .24); }

/* ---------- Mobile switch (phones) ---------- */
.sbe-switch { display: none; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    :root { --e-panel: 336px; --e-rail: 68px; }
    .sbe-brand span { display: none; }
    .sbe-actions .sbe-btn--ghost span { display: none; }
    .sbe-actions .sbe-btn--ghost { width: 38px; padding: 0; }
}
@media (max-width: 900px) {
    :root { --e-top: 54px; }
    .sbe-top { gap: 8px; padding: 0 8px; }
    .sbe-brand { padding-right: 8px; }
    .sbe-doc strong { max-width: 120px; }
    .sbe-center { margin: 0 0 0 auto; }
    .sbe-devices, #sbePreview, #sbeRedo { display: none; }
    .sbe-pagesel { height: 36px; padding: 0 26px 0 10px; }
    .sbe-pagesel select { max-width: 92px; }
    .sbe-pagesel > i:first-child { display: none; }
    .sbe-pagesel-caret { right: 9px; }
    #sbeOrder span { display: none; }
    #sbeOrder { width: 38px; padding: 0; }
    .sbe-body { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) 62px; }
    .sbe-rail { grid-row: 2; flex-direction: row; justify-content: space-around; gap: 0; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--e-line); }
    .sbe-rail button { flex: 1; padding: 6px 2px; font-size: 11px; }
    .sbe-rail button i { font-size: 19px; }
    .sbe-panel, .sbe-stage { grid-row: 1; grid-column: 1; }
    .sbe-panel { border-right: 0; }
    .sbe-panel-scroll { padding: 16px 16px 90px; }
    .sbe-stage { padding: 0; background: #fff; }
    .sbe-canvas, .sbe-canvas[data-device] { width: 100%; max-height: none; border: 0; border-radius: 0; box-shadow: none; }
    .sbe[data-view="panel"] .sbe-stage { visibility: hidden; pointer-events: none; }
    .sbe[data-view="stage"] .sbe-panel { display: none; }
    .sbe-switch {
        position: fixed;
        left: 50%;
        bottom: calc(76px + env(safe-area-inset-bottom));
        z-index: 40;
        transform: translateX(-50%);
        display: inline-flex;
        align-items: center;
        gap: 8px;
        height: 46px;
        padding: 0 18px;
        border: 0;
        border-radius: 999px;
        background: #0f172a;
        color: #fff;
        font-weight: 600;
        box-shadow: 0 14px 30px -10px rgba(15, 23, 42, .6);
    }
    .sbe.is-preview .sbe-body { grid-template-rows: minmax(0, 1fr) 0; }
    .sbe.is-preview .sbe-switch { display: none; }
    .sbe-preview-bar { position: fixed; left: 10px; right: 10px; bottom: 10px; margin: 0; }
    .sbe-modal { padding: 0; align-items: flex-end; }
    .sbe-modal-box { width: 100%; max-height: 92vh; border-radius: 18px 18px 0 0; }
    .sbe-modal-body { padding: 16px 16px calc(22px + env(safe-area-inset-bottom)); }
    .sbe-types { grid-template-columns: minmax(0, 1fr); }
    .sbe-toast { bottom: calc(134px + env(safe-area-inset-bottom)); }
    .sbe-row-tools { opacity: 1; }
}
@media (max-width: 420px) {
    .sbe-doc { display: none; }
}
