/* styles.css — VDO Scene & Prompt Studio (JULA'S HERB)
   ออกแบบเอง ไม่พึ่ง CDN เพื่อให้เปิดใช้แบบออฟไลน์ 100% */

:root {
  --bg: #fbf5f7;
  --surface: #ffffff;
  --surface-2: #fdf2f6;
  --ink: #2c2530;
  --muted: #8b8090;
  --brand: #e8537a;       /* watermelon pink */
  --brand-d: #c63c63;
  --green: #4caf72;
  --accent: #ff7a45;      /* orange (cart) */
  --line: #f0e3ea;
  --line-2: #e7dae3;
  --ok: #2e9e63;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 6px 24px rgba(120, 60, 90, .08);
  --shadow-lg: 0 12px 40px rgba(120, 60, 90, .16);
  --font: "Segoe UI", "Sarabun", "Noto Sans Thai", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.55;
}
h1, h2, h3, h4 { margin: 0; font-weight: 700; }
button { font-family: inherit; cursor: pointer; }
img { display: block; }

/* ---------- header ---------- */
.app-header {
  position: sticky; top: 0; z-index: 40;
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px;
  background: linear-gradient(100deg, var(--brand), #f47ea0 55%, var(--accent));
  color: #fff;
  box-shadow: var(--shadow);
}
.app-header .logo {
  width: 40px; height: 40px; border-radius: 12px;
  background: rgba(255,255,255,.22);
  display: grid; place-items: center; font-size: 22px;
}
.app-header .titles h1 { font-size: 17px; letter-spacing: .2px; }
.app-header .titles p { margin: 0; font-size: 12px; opacity: .9; }
.app-header .spacer { flex: 1; }
.app-header .hbtns { display: flex; gap: 8px; }
.hbtn {
  border: 1px solid rgba(255,255,255,.45); background: rgba(255,255,255,.16);
  color: #fff; padding: 8px 14px; border-radius: 10px; font-size: 13px; font-weight: 600;
  transition: background .15s;
}
.hbtn:hover { background: rgba(255,255,255,.30); }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 400px 1fr;
  gap: 18px;
  padding: 18px 22px 60px;
  align-items: start;
  max-width: 1500px; margin: 0 auto;
}
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.left-col { position: sticky; top: 78px; }
@media (max-width: 980px) { .left-col { position: static; } }
.panel-pad { padding: 16px 16px 18px; }

.step-title {
  display: flex; align-items: center; gap: 9px;
  font-size: 14px; font-weight: 700; color: var(--brand-d);
  margin-bottom: 12px;
}
.step-title .num {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--brand); color: #fff; font-size: 12px;
  display: grid; place-items: center; flex: none;
}
.hr { height: 1px; background: var(--line); margin: 16px 0; border: 0; }

/* ---------- product picker ---------- */
.search-row { display: flex; gap: 8px; margin-bottom: 10px; }
.input, .select, textarea.input {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); background: #fff; color: var(--ink);
  font-size: 14px; outline: none; transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, textarea.input:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px rgba(232,83,122,.12);
}
textarea.input { resize: vertical; min-height: 58px; }

.cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--line-2); background: #fff; color: var(--muted);
  padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600;
  transition: all .12s;
}
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.product-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
  max-height: 320px; overflow-y: auto; padding: 4px; margin: 0 -4px;
}
.product-tile {
  border: 2px solid var(--line); border-radius: 12px; background: var(--surface-2);
  padding: 6px; text-align: center; transition: all .12s; overflow: hidden;
}
.product-tile:hover { border-color: var(--brand); transform: translateY(-2px); }
.product-tile.active { border-color: var(--brand); background: #fff; box-shadow: var(--shadow); }
.product-tile .thumb {
  width: 100%; aspect-ratio: 1; object-fit: contain; background: #fff;
  border-radius: 8px; margin-bottom: 5px;
}
.product-tile .pname {
  font-size: 10.5px; line-height: 1.25; color: var(--ink);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-height: 26px;
}
.product-tile .badge-new {
  font-size: 9px; background: var(--green); color: #fff; border-radius: 5px;
  padding: 1px 5px; display: inline-block; margin-bottom: 3px;
}

.selected-card {
  display: flex; gap: 12px; align-items: center;
  border: 1px dashed var(--brand); background: var(--surface-2);
  border-radius: 12px; padding: 10px; margin-top: 12px;
}
.selected-card img { width: 54px; height: 54px; object-fit: contain; background:#fff; border-radius: 8px; flex: none; }
.selected-card .meta { font-size: 13px; }
.selected-card .meta b { color: var(--brand-d); }
.selected-card .meta span { color: var(--muted); font-size: 12px; }

/* ---------- form ---------- */
.field { margin-bottom: 12px; }
.field > label { display: block; font-size: 12.5px; font-weight: 600; color: var(--ink); margin-bottom: 5px; }
.field .hint { font-size: 11px; color: var(--muted); font-weight: 400; }
.seg { display: flex; gap: 6px; }
.seg button {
  flex: 1; border: 1px solid var(--line-2); background: #fff; color: var(--muted);
  padding: 8px 4px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; transition: all .12s;
}
.seg button.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.btn-generate {
  width: 100%; margin-top: 4px; padding: 13px; border: 0; border-radius: 12px;
  background: linear-gradient(100deg, var(--brand), var(--accent));
  color: #fff; font-size: 15px; font-weight: 700; letter-spacing: .3px;
  box-shadow: 0 6px 18px rgba(232,83,122,.35); transition: transform .1s, box-shadow .15s;
}
.btn-generate:hover { transform: translateY(-1px); box-shadow: 0 9px 24px rgba(232,83,122,.45); }
.btn-generate:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---------- output board ---------- */
.board-empty {
  text-align: center; color: var(--muted); padding: 80px 20px;
}
.board-empty .big { font-size: 54px; margin-bottom: 12px; }
.board-empty h3 { color: var(--ink); margin-bottom: 6px; }

.board-head {
  display: flex; align-items: center; flex-wrap: wrap; gap: 10px;
  padding: 14px 16px; border-bottom: 1px solid var(--line);
}
.board-head .tt { font-size: 16px; font-weight: 700; }
.board-head .tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tag {
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--brand-d); border: 1px solid var(--line-2);
}
.board-toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface-2);
  position: sticky; top: 68px; z-index: 10; border-radius: 0;
}
.btn {
  border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  padding: 7px 12px; border-radius: 9px; font-size: 13px; font-weight: 600; transition: all .12s;
}
.btn:hover { border-color: var(--brand); color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-d); color:#fff; }
.btn.ghost { background: transparent; }
.toolbar-spacer { flex: 1; }
.mode-toggle { display: flex; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; }
.mode-toggle button { border: 0; background: #fff; color: var(--muted); padding: 7px 12px; font-size: 12.5px; font-weight: 600; }
.mode-toggle button.active { background: var(--brand); color: #fff; }

.scenes { padding: 16px; display: flex; flex-direction: column; gap: 14px; }

.scene-card {
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: #fff;
  transition: box-shadow .15s;
}
.scene-card:hover { box-shadow: var(--shadow); }
.scene-card .sc-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.scene-card .sc-num {
  width: 26px; height: 26px; border-radius: 8px; background: var(--brand); color: #fff;
  font-size: 13px; font-weight: 700; display: grid; place-items: center; flex: none;
}
.scene-card .sc-beat { font-weight: 700; font-size: 13.5px; }
.scene-card .sc-dur { font-size: 11.5px; color: var(--muted); }
.scene-card .sc-head .right { margin-left: auto; display: flex; gap: 6px; }
.icon-btn {
  border: 1px solid var(--line-2); background: #fff; color: var(--muted);
  width: 30px; height: 28px; border-radius: 8px; font-size: 13px; display: grid; place-items: center;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }

.sc-body { display: grid; grid-template-columns: 92px 1fr; gap: 14px; padding: 14px; }
@media (max-width: 560px) { .sc-body { grid-template-columns: 1fr; } }
.sc-thumb { width: 92px; height: 92px; object-fit: contain; background: var(--surface-2); border-radius: 10px; border: 1px solid var(--line); }
.sc-info { min-width: 0; }
.kv { font-size: 12.5px; margin-bottom: 8px; color: var(--muted); }
.kv b { color: var(--ink); font-weight: 600; }
.script-line {
  background: var(--surface-2); border-radius: 10px; padding: 9px 11px; margin-bottom: 8px; font-size: 13.5px;
}
.script-line .lbl { font-size: 11px; color: var(--brand-d); font-weight: 700; display: block; margin-bottom: 2px; }
.script-line.vo { border-left: 3px solid var(--brand); }
.script-line.cap { border-left: 3px solid var(--green); }

.prompt-box { margin-top: 8px; position: relative; }
.prompt-box .pb-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.prompt-box .pb-head .lbl { font-size: 11px; font-weight: 700; color: var(--accent); }
.prompt-box pre {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-family: "Cascadia Code", Consolas, "SF Mono", monospace; font-size: 12px; line-height: 1.5;
  background: #2c2530; color: #f3e9ef; padding: 11px 12px; border-radius: 10px;
}
.copy-mini {
  border: 1px solid var(--line-2); background:#fff; color: var(--muted);
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 7px;
}
.copy-mini:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- toast ---------- */
.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 13px;
  box-shadow: var(--shadow-lg); animation: toastIn .2s ease;
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--brand-d); }
@keyframes toastIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------- modal ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(44,37,48,.5); z-index: 90;
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.overlay.show { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 460px;
  box-shadow: var(--shadow-lg); max-height: 86vh; overflow-y: auto;
}
.modal-head { display: flex; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--line); }
.modal-head h3 { font-size: 15px; }
.modal-head .x { margin-left: auto; border: 0; background: none; font-size: 20px; color: var(--muted); }
.modal-body { padding: 18px; }
.proj-item {
  display: flex; align-items: center; gap: 10px; padding: 10px; border: 1px solid var(--line);
  border-radius: 10px; margin-bottom: 8px;
}
.proj-item .pi-name { font-weight: 600; font-size: 13.5px; }
.proj-item .pi-meta { font-size: 11px; color: var(--muted); }
.proj-item .pi-actions { margin-left: auto; display: flex; gap: 6px; }
.note { font-size: 12px; color: var(--muted); background: var(--surface-2); border-radius: 10px; padding: 10px 12px; }
.switch-row { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }

/* ---------- collapsible groups (v2) ---------- */
.group { border: 1px solid var(--line); border-radius: 12px; margin-bottom: 10px; overflow: hidden; background: var(--surface); }
.group > summary {
  list-style: none; cursor: pointer; padding: 11px 13px; font-size: 13px; font-weight: 700; color: var(--brand-d);
  background: var(--surface-2); display: flex; align-items: center; gap: 6px; user-select: none;
}
.group > summary::-webkit-details-marker { display: none; }
.group > summary::after { content: '▾'; margin-left: auto; color: var(--muted); transition: transform .15s; }
.group[open] > summary::after { transform: rotate(180deg); }
.group-body { padding: 13px; }
.group-body .field:last-child { margin-bottom: 0; }

.check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--ink); cursor: pointer; margin-top: 4px; }
.check input { accent-color: var(--brand); }
.radio-row { display: flex; flex-wrap: wrap; gap: 10px; }
.radio { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--ink); cursor: pointer; }
.radio input { accent-color: var(--brand); }

.upload-btn {
  display: inline-block; border: 1px dashed var(--brand); color: var(--brand-d); background: var(--surface-2);
  padding: 9px 14px; border-radius: 10px; font-size: 13px; font-weight: 600; cursor: pointer; transition: all .12s;
}
.upload-btn:hover { background: #fff; border-style: solid; }
.face-preview { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.face-preview img { width: 56px; height: 56px; object-fit: cover; border-radius: 10px; border: 2px solid var(--brand); }

.queue-list { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.queue-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 9px; border: 1px solid var(--line-2);
  border-radius: 9px; background: var(--surface-2); font-size: 12.5px;
}
.queue-item img { width: 30px; height: 30px; object-fit: contain; background: #fff; border-radius: 6px; flex: none; }
.queue-item .qn { flex: 1; min-width: 0; }
.queue-item .qn b { display: block; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.queue-item .qn span { color: var(--muted); font-size: 11px; }
.queue-item .qx { border: 0; background: none; color: var(--brand-d); font-size: 16px; cursor: pointer; }

/* ---------- view toggle + batch tabs ---------- */
.view-toggle { display: flex; border: 1px solid var(--line-2); border-radius: 9px; overflow: hidden; }
.view-toggle button { border: 0; background: #fff; color: var(--muted); padding: 7px 11px; font-size: 12.5px; font-weight: 600; }
.view-toggle button.active { background: var(--green); color: #fff; }

.batch-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 16px 0; }
.batch-tab {
  border: 1px solid var(--line-2); background: #fff; color: var(--muted); padding: 6px 12px;
  border-radius: 999px; font-size: 12.5px; font-weight: 600; display: flex; align-items: center; gap: 6px;
}
.batch-tab img { width: 18px; height: 18px; object-fit: contain; border-radius: 4px; }
.batch-tab.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ---------- table view ---------- */
.sb-table-wrap { padding: 12px 16px 16px; overflow-x: auto; }
.sb-table { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.sb-table th, .sb-table td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.sb-table th { background: var(--surface-2); color: var(--brand-d); font-size: 12px; position: sticky; top: 0; }
.sb-table td.c-num { text-align: center; font-weight: 700; color: var(--brand); width: 34px; }
.sb-table td.c-dur { text-align: center; color: var(--muted); width: 44px; white-space: nowrap; }
.sb-table .row-vo { color: var(--ink); }
.sb-table .row-cap { color: var(--green); font-weight: 600; }
.sb-table .beat-tag { font-size: 10.5px; color: var(--muted); display: block; margin-top: 2px; }
.sb-table .t-prompt { width: 90px; text-align: center; }
.sb-table pre { white-space: pre-wrap; word-break: break-word; font-family: Consolas, monospace; font-size: 11.5px; line-height: 1.5; background: #2c2530; color: #f3e9ef; padding: 11px 12px; border-radius: 8px; margin: 0; }

/* ---------- script (teleprompter) view ---------- */
.script-view { padding: 16px; }
.script-block { margin-bottom: 18px; }
.script-block h4 { font-size: 13px; color: var(--brand-d); margin-bottom: 8px; }
.tele {
  background: #2c2530; color: #fdf2f6; border-radius: 12px; padding: 16px 18px; line-height: 1.9; font-size: 15px;
}
.tele .tline { display: flex; gap: 10px; margin-bottom: 6px; }
.tele .tline .tn { color: var(--brand); font-weight: 700; flex: none; }
.cap-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cap-chip { background: var(--surface-2); border: 1px solid var(--line-2); color: var(--green); border-radius: 8px; padding: 5px 10px; font-size: 12.5px; font-weight: 600; }
.script-prompts .prompt-box { margin-bottom: 12px; }

/* ---------- improved card body (v2) ---------- */
.sc-chips { display: flex; flex-wrap: wrap; gap: 5px; margin: 10px 0; }
.sc-chip { font-size: 11px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--muted); border-radius: 7px; padding: 3px 8px; }
.sc-thumbs { display: flex; flex-direction: column; gap: 6px; }
.sc-thumbs .face-ref { width: 92px; height: 64px; object-fit: cover; border-radius: 8px; border: 2px solid var(--brand); }
.sc-thumbs .ref-cap { font-size: 9px; color: var(--muted); text-align: center; }
details.prompt-fold { margin-top: 8px; }
details.prompt-fold > summary {
  list-style: none; cursor: pointer; font-size: 11.5px; font-weight: 700; color: var(--muted);
  display: flex; align-items: center; gap: 8px; padding: 7px 11px; user-select: none;
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 9px;
}
details.prompt-fold > summary:hover { color: var(--accent); border-color: var(--accent); }
details.prompt-fold[open] > summary { border-radius: 9px 9px 0 0; border-bottom: 0; }
details.prompt-fold > summary::-webkit-details-marker { display: none; }
details.prompt-fold > summary::before { content: '▸'; transition: transform .15s; }
details.prompt-fold[open] > summary::before { transform: rotate(90deg); }
details.prompt-fold > summary .copy-mini { margin-left: auto; }
details.prompt-fold[open] .prompt-box { margin-top: 0; }
details.prompt-fold[open] > *:not(summary):first-of-type { margin-top: 10px; }

/* ---------- persona (v3) ---------- */
.persona-modal-actions { display: flex; gap: 8px; margin-top: 6px; }
#personaHint { color: var(--brand-d); }
/* ---------- single Flow prompt view ---------- */
.single-view { padding: 16px; }
.single-view .lead { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.single-view .lead b { color: var(--brand-d); }
.single-view pre {
  white-space: pre-wrap; word-break: break-word; font-family: Consolas, monospace; font-size: 12.5px; line-height: 1.6;
  background: #2c2530; color: #f3e9ef; padding: 14px 15px; border-radius: 12px; margin: 0;
}
.single-view .ing { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 14px; }
.single-view .ing b { color: var(--brand-d); }
.single-view .out-block { margin-bottom: 16px; }
.single-view .out-head { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.single-view .out-title { font-size: 13.5px; font-weight: 800; color: var(--ink); }
.single-view .out-head .btn { margin-left: auto; }
.single-view .script-read {
  font-size: 16px; line-height: 1.85; color: var(--ink);
  background: var(--surface-2); border: 1px solid var(--line-2); border-left: 4px solid var(--brand);
  border-radius: 12px; padding: 14px 16px;
}

/* ================== v4: TOOLBAR LAYOUT ================== */
.toolbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap;
  padding: 10px 22px; background: var(--surface);
  border-bottom: 1px solid var(--line); box-shadow: var(--shadow);
}
.tb-product {
  display: flex; align-items: center; gap: 9px;
  border: 2px solid var(--brand); background: var(--surface-2);
  border-radius: 12px; padding: 7px 12px; min-width: 210px; max-width: 300px;
  font-weight: 700; color: var(--ink); transition: all .12s;
}
.tb-product:hover { background: #fff; box-shadow: var(--shadow); }
.tb-thumb { width: 34px; height: 34px; border-radius: 8px; background: #fff; display: grid; place-items: center; overflow: hidden; flex: none; font-size: 17px; }
.tb-thumb img { width: 100%; height: 100%; object-fit: contain; }
.tb-name { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-caret { color: var(--brand-d); margin-left: auto; }
.tb-field label { display: block; font-size: 10.5px; font-weight: 700; color: var(--muted); margin: 0 0 3px 2px; }
.tb-field .select { padding: 8px 10px; font-size: 13px; min-width: 140px; }
.tb-inline { display: flex; gap: 5px; align-items: center; }
.tb-field .seg button { padding: 8px 10px; }
.tb-generate { width: auto; margin: 0; padding: 11px 22px; font-size: 14px; flex: none; }
.tb-adv { padding: 11px 14px; }
.tb-hint { padding: 4px 24px 0; font-size: 12px; color: var(--brand-d); min-height: 0; }
.tb-hint:empty { display: none; }

.board-wrap { padding: 14px 22px 60px; max-width: 1500px; margin: 0 auto; }
@media (max-width: 760px) {
  .toolbar { gap: 8px; }
  .tb-product { min-width: 100%; max-width: none; }
}

/* product modal */
.modal-wide { max-width: 880px; }
.product-grid-modal { grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); max-height: 52vh; }

/* drawer (ตั้งค่าขั้นสูง) */
.drawer-overlay {
  position: fixed; inset: 0; background: rgba(44,37,48,.45); z-index: 80;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.drawer-overlay.show { opacity: 1; pointer-events: auto; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: 420px; max-width: 94vw; z-index: 85;
  background: var(--bg); box-shadow: -12px 0 40px rgba(120,60,90,.25);
  transform: translateX(105%); transition: transform .22s ease;
  display: flex; flex-direction: column;
}
.drawer.show { transform: translateX(0); }
.drawer-head {
  display: flex; align-items: center; padding: 14px 18px;
  background: linear-gradient(100deg, var(--brand), var(--accent)); color: #fff;
}
.drawer-head h3 { font-size: 15px; }
.drawer-head .x { margin-left: auto; border: 0; background: rgba(255,255,255,.2); color: #fff; width: 30px; height: 30px; border-radius: 8px; font-size: 18px; cursor: pointer; }
.drawer-body { padding: 14px; overflow-y: auto; flex: 1; }

/* ================== v4: GRID 9 ================== */
.g9 { padding: 16px; }
.g9-top { margin-bottom: 14px; }
.g9-tip { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; font-size: 12.5px; margin-bottom: 10px; }
.g9-tip b { color: var(--brand-d); }
.g9-vo { background: #2c2530; color: #fdf2f6; border-radius: 12px; padding: 12px 14px; font-size: 14px; line-height: 1.8; margin-bottom: 10px; }
.g9-vo .seg-tag { display: inline-block; background: var(--brand); color: #fff; font-size: 10.5px; font-weight: 700; border-radius: 6px; padding: 1px 7px; margin-right: 6px; }
.g9-vo .vo-line { margin-bottom: 4px; }
.g9-timeline { display: flex; gap: 4px; margin-bottom: 14px; }
.g9-timeline .tl {
  flex: 1; text-align: center; font-size: 11px; font-weight: 700; color: #fff;
  border-radius: 8px; padding: 5px 4px; line-height: 1.35;
}
.g9-timeline .tl small { display: block; font-weight: 600; opacity: .85; font-size: 9.5px; }
.tl-a { background: #e8537a; } .tl-b { background: #f0734f; } .tl-c { background: #4caf72; } .tl-d { background: #7c6bd6; }
.g9-vo .seg-tag.tl-a { background: #e8537a; } .g9-vo .seg-tag.tl-b { background: #f0734f; }
.g9-vo .seg-tag.tl-c { background: #4caf72; } .g9-vo .seg-tag.tl-d { background: #7c6bd6; }

.g9-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 700px) { .g9-grid { grid-template-columns: 1fr; } }
.g9-cell { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.g9-cell .gc-head {
  display: flex; align-items: center; gap: 6px; padding: 7px 9px;
  background: var(--surface-2); border-bottom: 1px solid var(--line); font-size: 11.5px;
}
.g9-cell .gc-num { width: 21px; height: 21px; border-radius: 6px; background: var(--brand); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; flex: none; }
.g9-cell .gc-role { font-weight: 700; }
.g9-cell .gc-time { color: var(--muted); margin-left: auto; }
.g9-cell .gc-mode { font-size: 10px; font-weight: 700; border-radius: 6px; padding: 1px 6px; }
.g9-cell .gc-mode.oncam { background: #fde3eb; color: var(--brand-d); }
.g9-cell .gc-mode.vo { background: #e3f3ea; color: #2e7d4f; }
.g9-cell .gc-img { position: relative; aspect-ratio: 3/4; background: var(--surface-2); }
.g9-cell .gc-img img { width: 100%; height: 100%; object-fit: cover; }
.g9-cell .gc-img img.ph { object-fit: contain; opacity: .55; padding: 14px; }
.g9-cell .gc-up {
  position: absolute; bottom: 6px; left: 6px; right: 6px;
  background: rgba(44,37,48,.78); color: #fff; border: 0; border-radius: 8px;
  font-size: 11px; font-weight: 600; padding: 6px; cursor: pointer;
}
.g9-cell .gc-up:hover { background: rgba(44,37,48,.95); }
.g9-cell .gc-body { padding: 8px 9px; font-size: 11.5px; display: flex; flex-direction: column; gap: 6px; }
.g9-cell .gc-desc { color: var(--ink); line-height: 1.45; }
.g9-cell .gc-cam { color: var(--muted); font-size: 10.5px; background: var(--surface-2); border-radius: 6px; padding: 3px 7px; }
.g9-cell .gc-btns { display: flex; gap: 5px; margin-top: auto; }
.g9-cell .gc-btns .copy-mini { flex: 1; padding: 5px 4px; }
