/* Caption Studio — scoped to #cs-app so the WP theme isn't affected */
.cs-app {
  --bg: #0f1115; --card: #171a21; --line: #262b36; --text: #e8eaf0; --muted: #8b93a7;
  --brand: #7c3aed; --brand2: #a78bfa; --ok: #22c55e; --bad: #ef4444;
  width: 100vw !important; max-width: none !important; margin-left: calc(50% - 50vw) !important; margin-right: 0 !important; padding: 24px max(16px, calc((100vw - 1280px) / 2));
  background: var(--bg); color: var(--text); box-sizing: border-box; min-height: 80vh;
  font: 15px/1.45 "Poppins", "Mukta", system-ui, sans-serif; position: relative;
}
.cs-app *, .cs-app *::before, .cs-app *::after { box-sizing: border-box; }
.cs-app button, .cs-app input, .cs-app select, .cs-app textarea { font: inherit; color: inherit; }
.cs-app [hidden] { display: none !important; }
.cs-boot { color: var(--muted); padding: 40px; text-align: center; }

.cs-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; gap: 12px; flex-wrap: wrap; }
.cs-brand { font-weight: 800; font-size: 22px; }
.cs-brand span { display: block; font-weight: 500; font-size: 13px; color: var(--muted); }
.cs-usage { background: var(--card); border: 1px solid var(--line); padding: 6px 12px; border-radius: 999px; font-size: 13px; }
.cs-warn { background: #3b2a0a; border: 1px solid #a16207; color: #fde68a; padding: 10px 14px; border-radius: 10px; margin-bottom: 14px; }

.cs-card { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.cs-center { max-width: 520px; margin: 40px auto; text-align: center; }

.cs-drop { display: block; border: 2px dashed #3a4152; border-radius: 18px; padding: 56px 20px; text-align: center; cursor: pointer; background: var(--card); transition: .15s; }
.cs-drop:hover, .cs-drop.over { border-color: var(--brand2); background: #1c1830; }
.cs-drop-icon { font-size: 34px; opacity: .8; }
.cs-drop-title { font-size: 20px; font-weight: 700; margin-top: 6px; }
.cs-drop-sub { color: var(--muted); font-size: 13px; margin-top: 4px; }

.cs-row { display: flex; gap: 16px; margin-top: 16px; flex-wrap: wrap; }
.cs-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.cs-field select { min-width: 280px; }
.cs-file-proj input { font-size: 12px; }

.cs-app select, .cs-app input[type=number], .cs-app textarea {
  background: #0f1218; border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; outline: none;
}
.cs-app select:focus, .cs-app input:focus, .cs-app textarea:focus { border-color: var(--brand2); }

.cs-btn { background: #232836; border: 1px solid #323848; border-radius: 10px; padding: 9px 16px; cursor: pointer; font-weight: 600; text-decoration: none; display: inline-block; }
.cs-btn:hover:not(:disabled) { background: #2b3142; }
.cs-btn:disabled { opacity: .45; cursor: not-allowed; }
.cs-primary { background: var(--brand); border-color: var(--brand); color: #fff !important; }
.cs-primary:hover:not(:disabled) { background: #6d28d9; }
.cs-ghost { background: transparent; }
.cs-small { padding: 5px 10px; font-size: 13px; }

.cs-progress { display: flex; align-items: center; gap: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; margin: 14px 0; }
.cs-bar { flex: 1; height: 8px; background: #0f1218; border-radius: 99px; overflow: hidden; }
.cs-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brand), var(--brand2)); transition: width .2s; }
.cs-ptext { font-size: 13px; min-width: 240px; }

.cs-editor { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 20px; margin-top: 8px; }
@media (max-width: 960px) { .cs-editor { grid-template-columns: 1fr; } }
.cs-left { display: flex; flex-direction: column; align-items: center; min-width: 0; }
.cs-stage { position: relative; background: #000; border-radius: 12px; overflow: hidden; max-width: 100%; }
.cs-stage video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.cs-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
/* keep native controls clickable above the overlay */
.cs-stage video::-webkit-media-controls-panel { z-index: 2; }
.cs-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; justify-content: center; }

.cs-right { background: var(--card); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; display: flex; flex-direction: column; max-height: calc(68vh + 70px); }
.cs-tabs { display: flex; border-bottom: 1px solid var(--line); }
.cs-tabs button { flex: 1; background: none; border: 0; padding: 12px; cursor: pointer; color: var(--muted); font-weight: 600; }
.cs-tabs button.on { color: var(--text); box-shadow: inset 0 -2px 0 var(--brand2); }
.cs-pane { padding: 14px; overflow: auto; }

.cs-group { margin-bottom: 14px; }
.cs-label { font-size: 12px; color: var(--muted); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.cs-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cs-chip { background: #0f1218; border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; cursor: pointer; font-size: 13px; }
.cs-chip.on { border-color: var(--brand2); background: #241b3d; }
.cs-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.cs-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.cs-grid label b { color: var(--text); font-weight: 600; }
.cs-grid input[type=color] { width: 100%; height: 34px; border: 1px solid var(--line); border-radius: 8px; background: #0f1218; padding: 2px; }
.cs-grid input[type=range] { accent-color: var(--brand2); }
.cs-grid .cs-check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }

.cs-list { display: flex; flex-direction: column; gap: 8px; }
.cs-cue { border: 1px solid var(--line); border-radius: 10px; padding: 8px; background: #12151c; }
.cs-cue.on { border-color: var(--brand2); background: #1a1530; }
.cs-cue-top { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; font-size: 12px; color: var(--muted); }
.cs-cue-top .cs-t { width: 72px; padding: 3px 6px; font-size: 12px; }
.cs-seek { background: none; border: 0; color: var(--brand2); cursor: pointer; font-size: 12px; padding: 0 4px 0 0; min-width: 62px; text-align: left; }
.cs-x { background: none; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; padding: 1px 7px; color: var(--muted); }
.cs-x:hover { color: var(--text); }
.cs-x[data-act=add] { margin-left: auto; }
.cs-cue textarea { width: 100%; resize: vertical; font-family: "Mukta", "Poppins", sans-serif; font-size: 15px; }
.cs-muted { color: var(--muted); }

.cs-toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: #1f2633; border: 1px solid #334; color: #fff; padding: 11px 18px; border-radius: 12px; z-index: 99999; box-shadow: 0 10px 30px rgba(0,0,0,.4); max-width: 90vw; }
.cs-toast.bad { background: #3a1515; border-color: #7f1d1d; }

/* ===== v0.3 style panel ===== */
.cs-right { max-height: calc(68vh + 90px); }
.cs-pane { padding: 0; }
.cs-sec { padding: 16px; border-bottom: 1px solid var(--line); }
.cs-sec:last-child { border-bottom: 0; }
.cs-sec-h { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; font-weight: 700; letter-spacing: .02em; margin-bottom: 12px; color: var(--text); }
.cs-sec-h span { font-weight: 500; color: var(--muted); font-size: 12px; }
.cs-sub { font-size: 12px; color: var(--muted); margin: 12px 0 6px; }
.cs-sub:first-of-type { margin-top: 0; }

.cs-presets { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cs-preset { position: relative; background: #0c0e14; border: 1.5px solid var(--line); border-radius: 12px; padding: 0; cursor: pointer; overflow: hidden; text-align: left; transition: transform .12s, border-color .12s, box-shadow .12s; }
.cs-preset canvas { display: block; width: 100%; height: 78px; }
.cs-preset span { display: block; padding: 7px 10px; font-size: 12px; font-weight: 600; color: #c9cfdd; background: #12151d; border-top: 1px solid var(--line); }
.cs-preset:hover { transform: translateY(-2px); border-color: #3d4560; }
.cs-preset.on { border-color: var(--brand2); box-shadow: 0 0 0 3px rgba(167,139,250,.25); }
.cs-preset.on span { color: #fff; background: #221a3b; }
.cs-preset.on::after { content: "✓"; position: absolute; top: 6px; right: 6px; width: 20px; height: 20px; border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; display: grid; place-items: center; font-weight: 700; }

.cs-seg { display: flex; background: #0c0e14; border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 3px; margin-bottom: 10px; }
.cs-seg button { flex: 1; background: transparent; border: 0; border-radius: 7px; padding: 7px 4px; font-size: 12.5px; font-weight: 600; color: var(--muted); cursor: pointer; transition: background .12s, color .12s; white-space: nowrap; }
.cs-seg button:hover { color: var(--text); }
.cs-seg button.on { background: #2a2350; color: #fff; box-shadow: inset 0 0 0 1px rgba(167,139,250,.45); }
.cs-seg-script button { font-size: 14px; padding: 9px 4px; }

.cs-select { display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.cs-app .cs-select select { flex: 1; max-width: 210px; appearance: none; -webkit-appearance: none; padding: 9px 30px 9px 12px; border-radius: 10px; background: #0c0e14 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%239aa3b8' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 12px center; cursor: pointer; }

.cs-range { display: block; margin: 12px 0 4px; }
.cs-range-h { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.cs-range-h b { color: var(--text); font-weight: 600; background: #0c0e14; border: 1px solid var(--line); border-radius: 6px; padding: 0 7px; font-size: 12px; }
.cs-app input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 6px; border-radius: 99px; background: linear-gradient(90deg, var(--brand2) var(--p, 50%), #262b38 var(--p, 50%)); outline: none; cursor: pointer; }
.cs-app input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 4px solid var(--brand); box-shadow: 0 2px 8px rgba(0,0,0,.4); }
.cs-app input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 4px solid var(--brand); }

.cs-sws { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.cs-sw { display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); cursor: pointer; }
.cs-sw-dot { position: relative; width: 40px; height: 40px; border-radius: 12px; border: 2px solid #2d3344; box-shadow: inset 0 0 0 2px rgba(0,0,0,.35); transition: transform .12s; }
.cs-sw:hover .cs-sw-dot { transform: scale(1.06); }
.cs-sw-dot input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }

.cs-toggle { display: flex; align-items: center; gap: 10px; font-size: 13px; cursor: pointer; margin-top: 12px; }
.cs-toggle small { color: var(--muted); }
.cs-toggle input { display: none; }
.cs-toggle i { position: relative; width: 36px; height: 20px; border-radius: 99px; background: #2a2f3d; transition: background .15s; flex: none; }
.cs-toggle i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; }
.cs-toggle input:checked + i { background: var(--brand); }
.cs-toggle input:checked + i::after { transform: translateX(16px); }

/* in-app confirm */
.cs-modal { position: fixed; inset: 0; z-index: 100000; background: rgba(5,6,10,.6); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; animation: csFade .15s ease; }
.cs-modal.out { opacity: 0; transition: opacity .15s; }
.cs-modal-card { width: min(420px, 100%); background: #161a24; border: 1px solid #2a3042; border-radius: 18px; padding: 26px; box-shadow: 0 30px 80px -20px rgba(0,0,0,.8); animation: csPop .18s ease; }
.cs-modal-ic { width: 42px; height: 42px; border-radius: 12px; display: grid; place-items: center; background: rgba(250,204,21,.14); color: #facc15; font-weight: 800; font-size: 20px; margin-bottom: 14px; }
.cs-modal-card h3 { margin: 0 0 6px; font-size: 18px; }
.cs-modal-card p { margin: 0 0 22px; color: var(--muted); font-size: 14px; }
.cs-modal-btns { display: flex; justify-content: flex-end; gap: 10px; }
@keyframes csFade { from { opacity: 0; } }
@keyframes csPop { from { transform: scale(.94); opacity: 0; } }
a.cs-usage { color: var(--text) !important; text-decoration: none; transition: border-color .15s; }
a.cs-usage:hover { border-color: var(--brand2); }
