:root {
    --ink: #16181d;
    --ink-2: #4a4f59;
    --line: #e3e5ea;
    --soft: #f4f5f7;
    --panel: #ffffff;
    --stage: #eceef2;
    --accent: #e8364f;
    --accent-ink: #ffffff;
    --fill: #d9dce3;
    --radius: 10px;
    color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    height: 100%;
    background: var(--stage);
    color: var(--ink);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

button, input, select { font: inherit; color: inherit; }

/* ---------- top bar ---------- */

.top {
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0 16px;
    background: var(--panel);
    border-bottom: 1px solid var(--line);
    position: relative;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--ink);
    font-weight: 700;
    font-size: 17px;
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 13px;
    letter-spacing: .5px;
}

.top-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn {
    height: 36px;
    padding: 0 14px;
    border: 1px solid var(--line);
    background: var(--panel);
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
}

.btn:hover:not(:disabled) { background: var(--soft); }
.btn:disabled { opacity: .4; cursor: default; }
.btn.icon { width: 36px; padding: 0; font-size: 18px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.primary:hover { background: #d42a43; }

/* ---------- layout ---------- */

.layout {
    display: flex;
    height: calc(100% - 60px);
}

.stage {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    overflow: hidden;
}

.canvas-wrap {
    position: relative;
    line-height: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

.stage-info {
    margin-top: 12px;
    color: var(--ink-2);
    font-size: 13px;
    min-height: 18px;
}

.empty {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    line-height: 1.45;
}

.empty[hidden] { display: none; }

.empty-card {
    background: rgba(255, 255, 255, .94);
    border-radius: 14px;
    padding: 26px 30px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .18);
    max-width: 340px;
}

.empty-title { font-size: 20px; font-weight: 700; margin-bottom: 8px; }
.empty-line { color: var(--ink-2); margin-bottom: 4px; }
.empty-card .btn { margin-top: 12px; }
.empty-note { margin-top: 12px; font-size: 13px; color: var(--ink-2); }

kbd {
    display: inline-block;
    padding: 1px 7px;
    border: 1px solid var(--line);
    border-bottom-width: 2px;
    border-radius: 5px;
    background: var(--soft);
    font: 13px/1.5 ui-monospace, Consolas, monospace;
}

/* ---------- side panel ---------- */

.panel {
    width: 360px;
    flex-shrink: 0;
    background: var(--panel);
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.tabs {
    display: flex;
    gap: 4px;
    padding: 10px;
    border-bottom: 1px solid var(--line);
}

.tab {
    flex: 1;
    height: 36px;
    border: 0;
    border-radius: 8px;
    background: none;
    cursor: pointer;
    color: var(--ink-2);
    font-weight: 500;
}

.tab:hover { background: var(--soft); }
.tab.active { background: var(--soft); color: var(--ink); font-weight: 600; }

.tab-body {
    flex: 1;
    overflow-y: auto;
    padding: 6px 16px 40px;
}

.group {
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.group:last-child { border-bottom: 0; }

h3 {
    margin: 0 0 10px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .6px;
    color: var(--ink-2);
}

details > summary { list-style: none; cursor: pointer; }
details > summary::-webkit-details-marker { display: none; }
details > summary h3 { margin: 0; display: inline-flex; gap: 8px; align-items: center; }
details > summary h3::after { content: "+"; font-size: 15px; }
details[open] > summary h3::after { content: "\2212"; }
details[open] > summary { margin-bottom: 10px; }

.head-row { display: flex; justify-content: space-between; align-items: center; }

.row + .row { margin-top: 8px; }

/* Slider: a bar that fills, with the label and value painted on it. A native
   range input sits on top at zero opacity so dragging and keys still work. */
.slider {
    position: relative;
    height: 36px;
    border-radius: 8px;
    background: var(--soft);
    overflow: hidden;
    user-select: none;
}

.slider .fill {
    position: absolute;
    inset: 0 auto 0 0;
    background: var(--fill);
    pointer-events: none;
}

.slider .label,
.slider .val {
    position: absolute;
    top: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    pointer-events: none;
    font-size: 14px;
}

.slider .label { left: 12px; color: var(--ink); }
.slider .val { right: 12px; font-variant-numeric: tabular-nums; color: var(--ink-2); }

.slider input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    opacity: 0;
    cursor: ew-resize;
}

.slider:focus-within { outline: 2px solid #f6b3bd; outline-offset: 1px; }

.color-row {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 36px;
    padding: 0 6px 0 12px;
    border-radius: 8px;
    background: var(--soft);
    cursor: pointer;
    font-size: 14px;
}

input[type=color] {
    width: 44px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: none;
    cursor: pointer;
}

/* ---------- position ---------- */

.pos-layout { display: flex; gap: 12px; align-items: center; }
.pos-sliders { flex: 1; }

.pos-grid {
    display: grid;
    grid-template-columns: repeat(3, 22px);
    gap: 5px;
}

.pos-cell {
    width: 22px;
    height: 22px;
    border: 0;
    border-radius: 5px;
    background: var(--fill);
    cursor: pointer;
    padding: 0;
}

.pos-cell:hover { background: #b9bec8; }
.pos-cell.active { background: var(--accent); }

/* ---------- swatches ---------- */

.swatches {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.swatch {
    aspect-ratio: 1;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    padding: 0;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
}

.swatch:hover { transform: scale(1.06); }
.swatch.active { border-color: var(--ink); box-shadow: 0 0 0 2px #fff inset; }

.custom-bg { display: flex; gap: 8px; }

.swatch-btn {
    flex: 1;
    height: 44px;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 12px;
    border: 2px solid transparent;
    border-radius: 8px;
    background: var(--soft);
    cursor: pointer;
    font-size: 14px;
    position: relative;
}

.swatch-btn input[type=color] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.swatch-btn.active { border-color: var(--ink); }

.dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15);
    flex-shrink: 0;
}

.dot.checker {
    background:
        conic-gradient(#cfd3da 25%, #fff 0 50%, #cfd3da 0 75%, #fff 0) 0 0 / 10px 10px;
}

/* ---------- export tab ---------- */

.field {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
    font-size: 14px;
}

.field select, .field input {
    height: 36px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 10px;
    background: var(--panel);
    min-width: 170px;
}

.export-size { color: var(--ink-2); font-size: 13px; }
.note { margin: 0 0 10px; color: var(--ink-2); font-size: 14px; }

/* ---------- toast ---------- */

.toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 20px);
    background: var(--ink);
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    opacity: 0;
    transition: opacity .2s, transform .2s;
    pointer-events: none;
    z-index: 50;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- narrow screens ---------- */

@media (max-width: 860px) {
    html, body { height: auto; }
    .layout { flex-direction: column; height: auto; }
    .stage { min-height: 56vh; padding: 16px; }
    .panel { width: 100%; border-left: 0; border-top: 1px solid var(--line); }
    .tab-body { overflow: visible; }
    .top { height: auto; flex-wrap: wrap; padding: 10px 16px; }
    .top-actions { flex-wrap: wrap; }
}

/* ---------- code mode ---------- */

.seg {
    display: flex;
    background: var(--soft);
    border-radius: 10px;
    padding: 4px;
    gap: 4px;
}

.seg button {
    flex: 1;
    height: 34px;
    border: 0;
    border-radius: 7px;
    background: none;
    cursor: pointer;
    color: var(--ink-2);
    font-weight: 500;
}

.seg button.active {
    background: var(--panel);
    color: var(--ink);
    font-weight: 600;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    font-size: 14px;
    cursor: pointer;
}

.check-row input { width: 18px; height: 18px; accent-color: var(--accent); }

/* ================================================================
 * Video Player additions
 * ================================================================ */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.btn.small { height: 32px; padding: 0 12px; font-size: 14px; }
.gap-top { margin-top: 10px; }

/* ---------- preview ---------- */

.preview-wrap {
    position: relative;
    width: 640px;
    height: 360px;
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(16, 20, 30, .18);
}

#preview {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
    background: transparent;
}

.empty { border-radius: 12px; background: #1b1d23; }

/* ---------- text inputs ---------- */

.text-input {
    display: block;
    width: 100%;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    font-size: 14px;
}

.text-input[hidden] { display: none; }
.text-input:focus, .field input:focus, .code-box:focus { outline: 2px solid #f6b3bd; outline-offset: 1px; }
.text-input[readonly] { background: var(--soft); color: var(--ink-2); }

.link-status { margin: 8px 0 8px; font-size: 13px; min-height: 19px; color: var(--ink-2); }
.link-status.ok { color: #0f7a4a; font-weight: 600; }
.link-status.bad { color: #c22a3f; font-weight: 600; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }

.chips span {
    padding: 2px 8px;
    border-radius: 6px;
    background: var(--soft);
    border: 1px solid var(--line);
    color: var(--ink-2);
    font: 12px/1.6 ui-monospace, Consolas, monospace;
}

.seg + .row { margin-top: 10px; }
.seg button { font-size: 14px; }

/* ---------- theme picker ---------- */

.theme-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.theme-item {
    border: 2px solid transparent;
    background: var(--soft);
    border-radius: 8px;
    padding: 6px 6px 7px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 13px;
    color: var(--ink-2);
    line-height: 1.2;
}

.theme-item:hover { border-color: var(--line); }
.theme-item.active { border-color: var(--accent); color: var(--ink); font-weight: 600; }

/* A tiny drawing of each theme's control bar. --a is the accent color. */
.thumb {
    position: relative;
    height: 52px;
    border-radius: 5px;
    overflow: hidden;
    background: linear-gradient(135deg, #3a4150, #1c1f26);
}

.thumb i { position: absolute; display: block; }
.thumb .bar { left: 0; right: 0; bottom: 0; height: 15px; }
.thumb .trk { left: 6px; right: 6px; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, .35); }
.thumb .prg { left: 6px; width: 40%; height: 2px; border-radius: 2px; background: var(--a); }
.thumb .play { width: 14px; height: 14px; left: 50%; top: 40%; margin: -7px 0 0 -7px; border-radius: 50%; background: var(--a); }

.t-studio .bar { background: linear-gradient(transparent, rgba(0, 0, 0, .7)); }
.t-studio .trk, .t-studio .prg { bottom: 9px; }

.t-pill .bar { left: 5px; right: 5px; bottom: 5px; height: 10px; border-radius: 6px; background: rgba(255, 255, 255, .22); }
.t-pill .trk, .t-pill .prg { bottom: 9px; left: 14px; }
.t-pill .trk { right: 10px; }
.t-pill .play { background: rgba(255, 255, 255, .25); box-shadow: inset 0 0 0 1.5px #fff; }

.t-minimal .trk, .t-minimal .prg { bottom: 3px; height: 1.5px; left: 0; }
.t-minimal .trk { right: 0; }
.t-minimal .play { background: none; box-shadow: inset 0 0 0 1.5px #fff; }

.t-bold .bar { background: var(--a); height: 13px; }
.t-bold .trk, .t-bold .prg { bottom: 13px; left: 0; height: 2px; border-radius: 0; }
.t-bold .trk { right: 0; background: rgba(0, 0, 0, .3); }
.t-bold .prg { background: #fff; }
.t-bold .play { border-radius: 4px; width: 18px; margin-left: -9px; }

.t-light .bar { left: 4px; right: 4px; bottom: 4px; height: 12px; border-radius: 4px; background: #fff; }
.t-light .trk, .t-light .prg { bottom: 12px; left: 9px; }
.t-light .trk { right: 9px; background: #d9dce3; }
.t-light .play { background: #fff; }

/* ---------- watermark corner picker ---------- */

.pos-grid.two { grid-template-columns: repeat(2, 26px); }
.pos-grid.two .pos-cell { width: 26px; height: 26px; }

/* ---------- embed code ---------- */

.code-box {
    display: block;
    width: 100%;
    min-height: 150px;
    resize: vertical;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fbfbfc;
    font: 12px/1.5 ui-monospace, "Cascadia Mono", Consolas, monospace;
    word-break: break-all;
    margin-bottom: 10px;
}

.field input { min-width: 170px; }
