:root {
  --ink: #1b1f1b;
  --muted: #5c6259;
  --line: #ded9cb;
  --bg: #f5f4ef;
  --surface: #ffffff;
  --accent: #1e7a56;
  --accent-strong: #124f38;
  --danger: #a5340e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
}

a { color: var(--accent-strong); }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: var(--accent-strong);
  border-bottom: none;
}
.topbar .brand { font-weight: 700; font-size: 17px; text-decoration: none; color: #fff; }
.topbar nav { display: flex; align-items: center; gap: 18px; }
.topbar nav a { text-decoration: none; font-size: 14px; color: rgba(255, 255, 255, 0.82); }
.topbar nav a:hover { color: #fff; }
.topbar .muted { color: rgba(255, 255, 255, 0.7); }
.topbar button.small { background: rgba(255, 255, 255, 0.14); }
.topbar button.small:hover { background: rgba(255, 255, 255, 0.24); }

.nav-toggle-input { display: none; }
.nav-toggle-btn { display: none; font-size: 22px; line-height: 1; cursor: pointer; color: #fff; padding: 4px 6px; }

@media (max-width: 760px) {
  .nav-toggle-btn { display: block; }
  .topbar { flex-wrap: wrap; }
  .topbar nav {
    flex-basis: 100%; flex-direction: column; align-items: flex-start; gap: 10px;
    max-height: 0; overflow: hidden; margin-top: 0;
  }
  .nav-toggle-input:checked ~ nav {
    max-height: 320px; margin-top: 14px; padding-top: 14px; border-top: 1px solid rgba(255, 255, 255, 0.25);
  }
}

.page { max-width: 1100px; margin: 0 auto; padding: 28px 24px 64px; }
.narrow { max-width: 640px; }

h1 { font-size: 24px; margin: 0 0 6px; }
h2 { font-size: 17px; margin: 24px 0 10px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.layout-with-sidebar { display: grid; grid-template-columns: 240px 1fr; gap: 28px; align-items: start; }
@media (max-width: 760px) { .layout-with-sidebar { grid-template-columns: 1fr; } }

.sidebar { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; position: sticky; top: 16px; }
.sidebar h2 { margin-top: 0; }
.sidebar fieldset { border: none; border-top: 1px solid var(--line); padding: 10px 0 4px; margin: 0; }
.sidebar legend { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); padding: 0; }
.checkbox-row { display: flex; align-items: center; gap: 7px; font-size: 13.5px; padding: 3px 0; }
.form-block label.checkbox-row { flex-direction: row; align-items: center; font-weight: 400; }
.sidebar button { width: 100%; margin-top: 12px; }
.button-like.ghost { display: block; text-align: center; margin-top: 8px; font-size: 13px; text-decoration: none; color: var(--muted); }

.content-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 16px; }
.card { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; text-decoration: none; color: var(--ink); transition: box-shadow 0.15s, transform 0.15s; }
.card:hover { box-shadow: 0 8px 20px -10px rgba(0,0,0,0.25); transform: translateY(-2px); }
.thumb { aspect-ratio: 1; background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 0 0 / 14px 14px; display: flex; align-items: center; justify-content: center; }
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.thumb-placeholder { color: var(--muted); font-size: 12.5px; }
.card-body { padding: 10px 12px 12px; }
.card-name { font-weight: 650; margin-bottom: 6px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 5px; }
.chip { font-size: 11px; background: #dceee3; color: var(--accent-strong); border-radius: 4px; padding: 2px 7px; }

.empty-state { color: var(--muted); padding: 32px 0; }

.form-block { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.form-block label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; font-weight: 600; }
.form-block input[type="text"] { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.form-block fieldset { border: none; border-top: 1px solid var(--line); padding: 12px 0 4px; margin: 0; }
.form-block legend { font-weight: 650; font-size: 13.5px; padding: 0; }
.form-block select { padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; min-width: 220px; }

button { cursor: pointer; background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: 9px 16px; font-size: 14px; font-weight: 600; }
button:hover { background: var(--accent-strong); }
button.danger { background: var(--danger); }
button.danger:hover { background: #7a2708; }
button.small { padding: 4px 10px; font-size: 12.5px; }

.inline-form { display: flex; gap: 8px; align-items: center; }
.back-link { display: inline-block; margin-bottom: 14px; font-size: 13.5px; }

.image-slots { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin: 18px 0; }
@media (max-width: 560px) { .image-slots { grid-template-columns: 1fr; } }
.image-slot { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px; }
.slot-preview { width: 100%; aspect-ratio: 4/3; object-fit: contain; background: repeating-conic-gradient(#eee 0% 25%, #fff 0% 50%) 0 0 / 14px 14px; border-radius: 6px; margin-bottom: 10px; }
.slot-empty { display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 12.5px; }

.option-group { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; margin-bottom: 14px; }
.option-group legend { font-weight: 700; padding: 0; }
.value-list { list-style: none; margin: 10px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.value-list li { display: flex; align-items: center; justify-content: space-between; padding: 5px 0; border-top: 1px solid var(--line); }
.value-list li:first-child { border-top: none; }

.error-banner { background: #f3e4d3; border: 1px solid var(--danger); color: var(--danger); border-radius: 8px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 14px; }

.autosave-status { font-size: 12px; color: var(--muted); min-height: 1.4em; }
.autosave-status[data-tone="busy"] { color: var(--muted); }
.autosave-status[data-tone="ok"] { color: var(--accent-strong); }
.autosave-status[data-tone="error"] { color: var(--danger); }

/* ==================== Cổng thành viên (member portal wizard) ==================== */

.panel-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.card-pad { padding: 18px; }

.wizard-shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 28px; align-items: start; }
@media (max-width: 780px) { .wizard-shell { grid-template-columns: 1fr; } }

.wz-rail { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; position: sticky; top: 16px; display: flex; flex-direction: column; gap: 18px; }
.wz-eyebrow { display: block; font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-strong); font-weight: 700; margin-bottom: 4px; }
.wz-rail-head h1 { font-size: 1.05rem; margin: 0; }
.wz-rail-head p { margin: 6px 0 0; }

.wz-tabs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.wz-tab a { display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--ink); font-weight: 600; font-size: 0.88rem; }
.wz-tab a:hover { background: var(--bg); }
.wz-tab[data-active="true"] a { background: #dceee3; color: var(--accent-strong); }

.wz-rail-foot { background: #f6eada; border: 1px solid #caa15c; border-radius: 8px; padding: 10px 12px; font-size: 0.76rem; }
.wz-rail-foot b { color: #8a5a1e; }

.wz-stage-bar { margin-bottom: 18px; }
.wz-panel h2 { font-family: Georgia, "Noto Serif", serif; font-size: 1.4rem; margin: 0 0 8px; }
.wz-panel .lead { color: var(--muted); max-width: 62ch; margin: 0 0 22px; }

.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; padding: 3px 9px; border-radius: 999px; width: fit-content; }
.pill-ready { background: #dceee3; color: var(--accent-strong); }
.pill-pending { background: #f6eada; color: #8a5a1e; }

.tabular { font-variant-numeric: tabular-nums; }

.btn { cursor: pointer; background: var(--accent); color: #fff; border: none; border-radius: 6px; padding: 9px 16px; font-size: 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: var(--accent-strong); }

.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; }

.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; flex-wrap: wrap; }
.subnav a { text-decoration: none; color: var(--muted); font-size: 0.85rem; font-weight: 600; padding: 9px 4px; margin-bottom: -1px; border-bottom: 2px solid transparent; }
.subnav a:hover { color: var(--ink); }
.subnav a.active { color: var(--accent-strong); border-bottom-color: var(--accent); }

.global-scope-note { background: #f6eada; border: 1px solid #caa15c; border-radius: 8px; padding: 9px 12px; font-size: 0.78rem; color: #8a5a1e; margin: 0 0 18px; }

.script-list { display: flex; flex-direction: column; gap: 10px; }
.script-item { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 14px; }
.script-item-head { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.script-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.script-item-title { font-weight: 650; font-size: 0.92rem; }
.item-meta { display: flex; gap: 8px; align-items: center; }
.dur-chip { font-size: 0.74rem; color: var(--muted); }
.script-item-actions { flex: none; display: flex; align-items: center; gap: 4px; }
.inline-form { display: inline-flex; }
.icon-btn { background: none; border: 1px solid transparent; color: var(--muted); cursor: pointer; padding: 5px 8px; border-radius: 6px; font-size: 0.85rem; }
.icon-btn:hover { background: var(--bg); border-color: var(--line); }
.icon-btn.danger-icon:hover { background: #f3e4d3; color: var(--danger); border-color: var(--danger); }

.switch { position: relative; width: 34px; height: 20px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 100%; height: 100%; margin: 0; position: absolute; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background 0.15s; }
.switch .thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3); transition: transform 0.15s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked ~ .thumb { transform: translateX(14px); }

.script-item-edit { border-top: 1px solid var(--line); margin-top: 4px; }
.script-item-edit summary { cursor: pointer; font-size: 0.82rem; font-weight: 600; color: var(--accent-strong); padding: 8px 0; }
.script-item-edit .form-block { border: none; padding: 4px 0 14px; }

.config-grid { display: flex; flex-direction: column; gap: 18px; }
.config-card h3 { font-size: 1rem; margin: 0 0 4px; }
.config-card .hint { color: var(--muted); font-size: 0.82rem; margin: 0 0 14px; }

.avatar-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar-circle { width: 56px; height: 56px; border-radius: 50%; flex: none; background: #dceee3; display: grid; place-items: center; border: 2px solid var(--accent); overflow: hidden; }
.avatar-circle img { width: 100%; height: 100%; object-fit: cover; }
.avatar-name { font-weight: 700; }
.avatar-tag { color: var(--muted); font-size: 0.82rem; }

.avatar-pick-list { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
.avatar-pick-row { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; }
.avatar-pick-row:hover { background: var(--bg); }
.avatar-pick-row input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; }

.voice-row { display: flex; align-items: center; gap: 14px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; margin-bottom: 8px; }
.voice-row.picked { border-color: var(--accent); background: #f2f9f5; }
.voice-row input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; flex: none; }
.voice-info { flex: 1; }
.voice-info .name { font-weight: 700; font-size: 0.9rem; }
.voice-info .desc { color: var(--muted); font-size: 0.78rem; }
.voice-note { color: var(--muted); font-size: 0.78rem; margin-top: 6px; }

.segmented { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.segmented-input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label { display: inline-block; border: none; background: transparent; padding: 8px 18px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; color: var(--muted); cursor: pointer; }
.segmented-input:checked + label { background: var(--accent); color: #fff; }
.segmented-input:focus-visible + label { outline: 2px solid var(--accent-strong); outline-offset: 2px; }
.style-hint { margin-top: 12px; color: var(--muted); font-size: 0.82rem; }

.demo-card { display: grid; grid-template-columns: 180px 1fr; gap: 24px; padding: 22px; }
@media (max-width: 640px) { .demo-card { grid-template-columns: 1fr; } }
.demo-avatar-box { aspect-ratio: 1; border-radius: 16px; background: #eef4f0; border: 1px solid var(--line); display: grid; place-items: center; position: relative; }
.demo-body { display: flex; flex-direction: column; justify-content: center; gap: 14px; }
.caption-box { font-size: 0.88rem; font-style: italic; background: var(--bg); border-radius: 8px; padding: 12px 14px; }
.demo-tags { display: flex; gap: 8px; flex-wrap: wrap; }

.summary-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 700px) { .summary-grid { grid-template-columns: 1fr; } }
.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.checklist li { display: flex; gap: 10px; align-items: flex-start; font-size: 0.88rem; }
.checklist li .tick { flex: none; width: 20px; height: 20px; border-radius: 50%; background: #dceee3; color: var(--accent-strong); display: grid; place-items: center; font-size: 0.7rem; font-weight: 700; }
.checklist .lbl { display: block; color: var(--muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; font-weight: 700; margin-bottom: 2px; }

.download-card { display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.file-chip { display: flex; align-items: center; gap: 12px; }
.file-icon { width: 38px; height: 38px; border-radius: 8px; background: var(--bg); display: grid; place-items: center; font-size: 1.05rem; flex: none; }
.file-name { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: 0.85rem; }
.file-meta { color: var(--muted); font-size: 0.76rem; }
.btn-lg { padding: 13px 22px; font-size: 0.95rem; }

.instructions { margin-top: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; }
.instructions summary { cursor: pointer; font-weight: 700; font-size: 0.88rem; color: var(--accent-strong); padding: 4px 0; }
.instructions ol { margin: 12px 0 0; padding-left: 20px; color: var(--muted); font-size: 0.86rem; display: flex; flex-direction: column; gap: 8px; }
.instructions ol code { font-family: Consolas, "SFMono-Regular", Menlo, monospace; background: var(--bg); padding: 1px 6px; border-radius: 4px; color: var(--ink); }

.handoff { display: flex; align-items: stretch; gap: 10px; margin: 22px 0 26px; flex-wrap: wrap; }
.handoff-node { flex: 1; min-width: 160px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; text-align: center; }
.handoff-node .emoji { font-size: 1.3rem; }
.handoff-node .label { font-weight: 700; font-size: 0.86rem; margin-top: 6px; }
.handoff-node .sub { color: var(--muted); font-size: 0.74rem; margin-top: 2px; }
.handoff-arrow { color: var(--muted); font-size: 1.2rem; flex: none; align-self: center; }

.actionbar { display: flex; justify-content: space-between; align-items: center; margin-top: 30px; padding-top: 20px; border-top: 1px solid var(--line); }
.actionbar .right { display: flex; gap: 10px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--ink); }

/* ==================== Biên tập (bảng đoạn kịch bản, kiểu app) ==================== */

.data-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.data-table th { text-align: left; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--line); }
.data-table td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--bg); }
.data-table td.actions-cell { white-space: nowrap; text-align: right; }
.status-dot { display: inline-flex; align-items: center; gap: 5px; font-size: 0.78rem; color: var(--muted); }
.status-dot::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.status-dot[data-on="true"] { color: var(--accent-strong); }
.status-dot[data-on="true"]::before { background: var(--accent); }

/* ==================== Canvas vị trí/kích thước nhân viên ảo (modal Biên tập) ==================== */

.canvas-editor-section { border-top: 1px solid var(--line); margin-top: 14px; padding-top: 14px; }
.canvas-editor-section h4 { margin: 0 0 8px; font-size: 0.9rem; }
.canvas-stage { position: relative; background: #1b1b1b; border-radius: 8px; overflow: hidden; margin: 8px 0; background-image: linear-gradient(rgba(255,255,255,0.06) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.06) 1px, transparent 1px); background-size: 10% 10%; }
.canvas-box { position: absolute; border: 2px solid var(--accent); background: rgba(30, 122, 86, 0.28); cursor: move; min-width: 20px; min-height: 20px; }
.canvas-resize-handle { position: absolute; right: -6px; bottom: -6px; width: 14px; height: 14px; background: var(--accent); border: 2px solid #fff; border-radius: 3px; cursor: nwse-resize; }
.canvas-editor-section .field-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.canvas-editor-section .field-row label { display: flex; flex-direction: column; gap: 3px; font-size: 0.78rem; color: var(--muted); }
.canvas-editor-section .field-row select,
.canvas-editor-section .field-row input[type="number"] { padding: 6px 8px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; }

dialog.modal { border: none; border-radius: 12px; padding: 0; max-width: 480px; width: calc(100% - 32px); box-shadow: 0 20px 50px -20px rgba(0,0,0,0.35); }
dialog.modal::backdrop { background: rgba(20, 24, 20, 0.45); }
dialog.modal .modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-bottom: 1px solid var(--line); }
dialog.modal .modal-head h3 { margin: 0; font-size: 1rem; }
dialog.modal .modal-close { background: none; border: none; color: var(--muted); font-size: 18px; cursor: pointer; padding: 2px 6px; }
dialog.modal .modal-body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
dialog.modal .modal-body label { display: flex; flex-direction: column; gap: 5px; font-size: 13.5px; font-weight: 600; }
dialog.modal .modal-body input[type="text"], dialog.modal .modal-body input[type="number"], dialog.modal .modal-body select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
