:root {
    --bg: #f4f5fa; --panel: #fff; --ink: #1b1d29; --muted: #646879; --line: #e7e8f0;
    --pri: #5b4bd1; --pri-d: #4536b5; --ai: #5b4bd1; --ai-bg: #eeebff; --soft: #f4f5fa;
    --ok: #16a34a; --warn: #d97706; --bad: #dc2626; --radius: 22px;
    --t-violet: #e7e4ff; --t-orange: #ffe6cc; --t-green: #d6f2e6; --t-blue: #dcebff; --t-pink: #fbe0ec; --t-yellow: #fff1c2;
    font-family: "Be Vietnam Pro", system-ui, sans-serif; color: var(--ink); background: var(--bg);
  }
  body.dark {
    --bg: #13141b; --panel: #1d1f29; --ink: #f2f2f7; --muted: #a5a8ba; --line: #2e3142;
    --pri: #8b7cf6; --pri-d: #a99cff; --ai: #b4a9ff; --ai-bg: #2a2740; --soft: #262836;
    --t-violet: #2f2b52; --t-orange: #44321f; --t-green: #1f3d33; --t-blue: #1f3048; --t-pink: #45263a; --t-yellow: #423b1f;
    --ok: #8bd2a6; --warn: #f0c968; --bad: #ffa5a0;
    color-scheme: dark;
  }
  * { box-sizing: border-box; }
  body { margin: 0; min-height: 100vh; font-size: 16px; line-height: 1.5; background: var(--bg); color: var(--ink); }
  a { color: var(--pri-d); }
  h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; }
  .muted { color: var(--muted); }
  .small { font-size: 14px; }
  .mono, code { font-family: ui-monospace, Menlo, monospace; }
  hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
  
  
  .page { max-width: 1120px; margin: 0 auto; padding: 28px 24px 80px; }
  .page.narrow { max-width: 820px; }
  .page.wide { max-width: 1500px; }
  .empty { text-align: center; color: var(--muted); padding: 48px 20px; background: var(--panel); border: 2px dashed var(--line); border-radius: var(--radius); }
  .empty .btn { margin-top: 14px; }
  
  /* tiện ích bố cục */
  .row { display: flex; align-items: center; gap: 12px; margin-top: 16px; }
  .row.end { justify-content: flex-end; }
  .row.between { justify-content: space-between; }
  .row.gap { gap: 14px; }
  .row.wrap { flex-wrap: wrap; }
  .row.gap-s, .gap-s { gap: 8px; }
  .row.gap-s { margin-top: 0; }
  .col { display: flex; flex-direction: column; }
  .col.gap { gap: 16px; }
  .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
  .grid3 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
  .card { background: var(--panel); border: 0; border-radius: var(--radius); padding: 22px; box-shadow: 0 1px 2px rgba(27, 29, 41, .04); }
  
  /* nút bấm */
  .btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; transition: transform .08s, background .15s, box-shadow .15s; }
  .btn:hover { background: var(--soft); box-shadow: 0 2px 8px rgba(0, 0, 0, .06); }
  .btn:active { transform: translateY(1px); }
  .btn:disabled { opacity: .5; pointer-events: none; }
  .btn.primary { background: var(--pri); color: #fff; border-color: var(--pri); }
  .btn.primary:hover { background: var(--pri-d); }
  .btn.ai { background: var(--ai-bg); color: var(--ai); border-color: transparent; }
  .btn.ai:hover { filter: brightness(.97); }
  .btn.ghost { background: transparent; border-color: transparent; color: var(--muted); }
  .btn.big { padding: 14px 28px; font-size: 18px; border-radius: 14px; }
  .btn.small { padding: 7px 12px; font-size: 14px; }
  .btn.tiny { padding: 4px 10px; font-size: 13px; border-radius: 8px; margin-top: 4px; }
  .icon-btn { border: 0; background: none; cursor: pointer; font-size: 15px; padding: 6px 8px; border-radius: 8px; color: var(--muted); text-decoration: none; }
  .icon-btn:hover { background: var(--bg); color: var(--ink); }
  .chips { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 14px; margin: 8px 0 4px; }
  .chip { border: 1px solid var(--line); background: var(--panel); border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 14px; cursor: pointer; color: var(--ink); }
  .chip:hover { border-color: var(--pri); color: var(--pri-d); }
  .pills { display: inline-flex; background: var(--bg); padding: 4px; border-radius: 12px; gap: 4px; }
  .pills button { border: 0; background: none; padding: 8px 16px; border-radius: 9px; font: inherit; font-weight: 600; cursor: pointer; color: var(--muted); }
  .pills button.on { background: var(--panel); color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .1); }
  
  /* biểu mẫu */
  .field { display: flex; flex-direction: column; gap: 6px; margin: 14px 0; }
  .field > span { font-weight: 600; font-size: 15px; }
  .req { color: var(--pri); }
  input, select, textarea { font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px; width: 100%; }
  input:focus, select:focus, textarea:focus { outline: 3px solid rgba(91, 75, 209, .2); border-color: var(--pri); }
  input.big { font-size: 20px; padding: 14px 16px; }
  input[type=range] { padding: 0; accent-color: var(--pri); }
  input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--pri); }
  textarea { resize: vertical; }
  .check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; cursor: pointer; }
  .check input { margin-top: 4px; }
  .form { padding: 28px; }
  .row-edit { display: flex; gap: 8px; align-items: center; margin-bottom: 6px; }
  .row-edit.two > input:first-child { flex: 1; }
  .row-edit.two > input:nth-child(2) { flex: 1.4; }
  .opt-k { width: 22px; text-align: center; color: var(--muted); }
  .w-s { max-width: 80px; }
  .mh-hint-demo { background: #fff3b0; color: #5b4500; border: 1px dashed #d4a20b; border-radius: 6px; padding: 0 4px; font-style: italic; }
  
  /* trang chủ */
  .hero { text-align: center; padding: 30px 0 10px; }
  .hero h1 { font-size: clamp(30px, 4.4vw, 48px); font-weight: 800; letter-spacing: -.02em; }
  .hero p { max-width: 720px; margin: 0 auto; color: var(--muted); font-size: 18px; }
  .hl { color: var(--pri); }
  .sec { margin-top: 40px; font-size: 22px; }
  .projects { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 12px; }
  .proj { display: flex; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 6px 6px 6px 14px; }
  
  /* trình hướng dẫn tạo bài */
  .title { font-size: 32px; margin-top: 10px; }
  .assist { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .assist button { text-align: left; display: flex; flex-direction: column; gap: 4px; padding: 14px 16px; border: 2px solid var(--line); border-radius: 14px; background: var(--panel); font: inherit; cursor: pointer; color: var(--ink); }
  .assist button small { color: var(--muted); font-size: 13.5px; }
  .assist button.on { border-color: var(--pri); background: var(--ai-bg); }
  
  /* thanh các bước */
  .stepper { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
  .st { display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; border-radius: 999px; color: var(--muted); text-decoration: none; font-weight: 600; font-size: 14.5px; }
  a.st:hover { background: var(--panel); }
  .st-n { width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: var(--line); color: var(--muted); font-size: 13px; }
  .st.on { color: var(--ink); background: var(--panel); box-shadow: 0 1px 4px rgba(0, 0, 0, .08); }
  .st.on .st-n { background: var(--pri); color: #fff; }
  .st.done .st-n { background: var(--ok); color: #fff; }
  .st-sep { width: 24px; height: 2px; background: var(--line); }
  
  /* trình soạn thảo */
  .ed-top { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 14px; }
  .ed-name { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 280px; }
  #p-title { font-size: 22px; font-weight: 700; border-color: transparent; background: transparent; max-width: 640px; }
  #p-title:hover, #p-title:focus { background: var(--panel); border-color: var(--line); }
  .ed-grid { display: grid; grid-template-columns: 270px minmax(0, 1fr) 420px; gap: 16px; align-items: start; }
  .scenes { padding: 12px; position: sticky; top: 20px; max-height: calc(100vh - 40px); overflow: auto; }
  .scenes-h { font-weight: 700; padding: 4px 6px 8px; }
  #scene-list { list-style: none; margin: 0 0 10px; padding: 0; }
  .scene-li { display: flex; align-items: center; gap: 8px; padding: 8px; border-radius: 10px; cursor: pointer; font-size: 14.5px; position: relative; }
  .scene-li:hover { background: var(--bg); }
  .scene-li.on { background: var(--ai-bg); outline: 2px solid var(--pri); }
  .sl-t { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sl-hint { font-size: 12px; color: #8a6300; }
  .sl-act { display: none; }
  .scene-li:hover .sl-act, .scene-li.on .sl-act { display: flex; }
  .sl-act button { border: 0; background: none; cursor: pointer; padding: 2px 4px; color: var(--muted); border-radius: 6px; }
  .sl-act button:hover { background: var(--panel); color: var(--ink); }
  .scene-form { padding: 22px 26px; }
  .form-h { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
  .form-h h2 { margin: 0; }
  .layout-pick { display: flex; align-items: center; gap: 8px; font-weight: 600; }
  .layout-pick select { width: auto; }
  .grid-icon { display: grid; grid-template-columns: 1fr 110px; gap: 12px; }
  .f-icon input { text-align: center; font-size: 20px; }
  .latex-help { margin-top: -8px; }
  .scene-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 20px; }
  .ai-box h3, .hint-box b { font-size: 16px; }
  .ai-box input { font-size: 14px; }
  .hint-box { background: #fffbea; border-color: #f2df9c; }
  .img-pick { display: flex; gap: 12px; align-items: center; }
  .img-pick img, .img-none { width: 200px; height: 112px; object-fit: cover; border-radius: 10px; border: 1px solid var(--line); }
  .img-none { display: grid; place-items: center; color: var(--muted); background: var(--bg); font-size: 14px; }
  
  /* xem trước */
  .pv { background: #11131a; border-radius: 14px; overflow: hidden; }
  .pv-stage { width: 100%; aspect-ratio: 16 / 9; }
  .pv-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: #1b1e27; color: #cfd3dc; font-size: 13px; }
  .pv-play { border: 0; background: var(--pri); color: #fff; width: 34px; height: 34px; border-radius: 50%; cursor: pointer; font-size: 14px; }
  .pv-seek { flex: 1; }
  .pv.big .pv-stage { aspect-ratio: 16 / 9; }
  .design-grid { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 20px; align-items: start; }
  .scene-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0; }
  .themes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .theme-b { text-align: left; border: 2px solid transparent; border-radius: 12px; padding: 10px 12px; cursor: pointer; background: var(--bg); color: var(--ink); font: inherit; display: flex; flex-direction: column; gap: 2px; }
  .theme-b b { font-size: 15px; }
  .theme-b small { font-size: 12px; color: var(--muted); opacity: .85; }
  .theme-b .sw { display: flex; gap: 4px; }
  .theme-b .sw i { width: 18px; height: 18px; border-radius: 50%; display: block; }
  .theme-b.on { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 1px; }
  
  /* trợ lý luyện tập */
  .score-row { display: flex; gap: 14px; align-items: center; margin: 14px 0; }
  .score { flex: none; width: 86px; height: 86px; border-radius: 50%; display: grid; place-content: center; text-align: center; background: conic-gradient(var(--c) calc(var(--p) * 1%), #eee 0); position: relative; }
  .score::before { content: ""; position: absolute; inset: 8px; border-radius: 50%; background: #fff; }
  .score span, .score small { position: relative; }
  .score span { font-size: 26px; font-weight: 800; line-height: 1; }
  .score small { color: var(--muted); }
  .crit-i { margin: 10px 0; }
  .crit-h { display: flex; justify-content: space-between; font-size: 14.5px; font-weight: 600; }
  .crit-bar { height: 8px; background: #eee; border-radius: 6px; overflow: hidden; margin: 4px 0; }
  .crit-bar i { display: block; height: 100%; background: linear-gradient(90deg, #f59e0b, #16a34a); border-radius: 6px; }
  .coach h4 { margin-top: 18px; }
  .coach ul { padding-left: 20px; margin: 0; }
  .coach li { margin: 6px 0; font-size: 14.5px; }
  .q { background: var(--bg); border-radius: 10px; padding: 8px 12px; margin: 6px 0; font-size: 14.5px; }
  .q summary { cursor: pointer; font-weight: 600; }
  .q div { margin-top: 6px; }
  .warn-box { background: #fffbea; border: 1px solid #f2df9c; border-radius: 12px; padding: 10px 14px; margin: 10px 0; }
  
  /* xuất bản */
  .exports { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; margin-top: 8px; }
  .ex { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
  .ex p { flex: 1; margin: 0 0 10px; font-size: 14.5px; }
  
  /* hộp thoại, màn chờ, thông báo */
  .modal-back { position: fixed; inset: 0; background: rgba(15, 18, 28, .45); display: grid; place-items: center; z-index: 50; padding: 20px; }
  .modal { background: var(--panel); border-radius: 20px; padding: 26px; width: min(520px, 100%); max-height: 90vh; overflow: auto; position: relative; box-shadow: 0 30px 80px rgba(0, 0, 0, .25); }
  .modal-wide { width: min(820px, 100%); }
  .modal-x { position: absolute; right: 14px; top: 12px; border: 0; background: none; font-size: 18px; cursor: pointer; color: var(--muted); }
  .layout-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
  .layout-grid button { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; border: 1px solid var(--line); border-radius: 14px; background: var(--panel); color: var(--ink); cursor: pointer; font: inherit; font-size: 14px; }
  .layout-grid button span { font-size: 30px; }
  .layout-grid button:hover { border-color: var(--pri); background: var(--ai-bg); }
  .busy { position: fixed; inset: 0; z-index: 60; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(4px); display: grid; place-items: center; }
  .busy-card { background: var(--panel); border-radius: 20px; padding: 32px 40px; text-align: center; box-shadow: 0 20px 60px rgba(0, 0, 0, .12); min-width: 340px; }
  .busy-msg { font-size: 19px; font-weight: 700; margin-top: 14px; }
  .busy-sub { color: var(--muted); font-size: 14px; margin-top: 6px; }
  .spinner { width: 48px; height: 48px; margin: 0 auto; border-radius: 50%; border: 5px solid var(--ai-bg); border-top-color: var(--pri); animation: spin 0.9s linear infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  #toasts { position: fixed; right: 20px; bottom: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
  .toast { background: #1d2230; color: #fff; padding: 12px 18px; border-radius: 12px; max-width: 420px; box-shadow: 0 10px 30px rgba(0, 0, 0, .2); transition: opacity .4s, transform .4s; }
  .toast-error { background: #b91c1c; }
  .toast-ok { background: #15803d; }
  .toast.out { opacity: 0; transform: translateY(10px); }
  
  @media (max-width: 1200px) {
    .ed-grid { grid-template-columns: 240px minmax(0, 1fr); }
    .scene-side { grid-column: 1 / -1; position: static; }
    .design-grid { grid-template-columns: 1fr; }
    .exports { grid-template-columns: 1fr 1fr; }
  }
  @media (max-width: 760px) {
    .grid2, .assist, .exports, .ed-grid { grid-template-columns: 1fr; }
    .scenes { position: static; max-height: none; }
    .layout-grid { grid-template-columns: repeat(2, 1fr); }
  }
  [hidden] { display: none !important; }
  #save-st { white-space: nowrap; }
  #sources .row-edit.two > input:first-child { flex: 2; }
  #sources .row-edit.two > input:nth-child(2) { flex: 1; color: var(--muted); font-size: 13px; }
  .task-card { max-width: 760px; }
  .task-frames { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0 6px; }
  .task-frames:empty { display: none; }
  .task-frames img { width: 100%; border-radius: 8px; border: 1px solid var(--line); background: #000; }
  .review-list { margin: 10px 0 0; padding-left: 20px; font-size: 14.5px; }
  .t-edit { display: grid; grid-template-columns: repeat(var(--cols), 1fr); gap: 6px; }
  .t-edit .t-head { font-weight: 700; background: var(--ai-bg); }
  
  
  /* Khung ứng dụng: thanh bên kiểu dashboard + nội dung */
  body { display: grid; grid-template-columns: 252px minmax(0, 1fr); align-items: start; }
  .side { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 28px; padding: 22px 16px; background: var(--panel); border-right: 1px solid var(--line); overflow-y: auto; z-index: 20; }
  .logo { display: flex; align-items: center; gap: 11px; padding: 4px 10px; color: var(--ink); text-decoration: none; font-size: 24px; font-weight: 800; letter-spacing: -.02em; white-space: nowrap; }
  .logo-text span { color: var(--pri); }
  .side-nav { display: flex; flex-direction: column; gap: 4px; }
  .side-h { padding: 0 14px 8px; font-size: 11.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: var(--muted); }
  .side-nav a, .side-btn { display: flex; align-items: center; gap: 13px; min-height: 46px; padding: 0 14px; border: 0; border-radius: 14px; background: none; color: var(--muted); font: inherit; font-size: 15px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; text-align: left; }
  .side-nav a:hover, .side-btn:hover { color: var(--ink); background: var(--soft); }
  .side-nav a.on { color: #fff; background: var(--pri); box-shadow: 0 8px 18px rgba(91, 75, 209, .28); }
  .side-nav svg, .side-btn svg { width: 20px; height: 20px; flex: none; }
  .side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; }
  .side-promo { display: flex; flex-direction: column; gap: 8px; padding: 20px; border-radius: 20px; color: #fff; background: #1b1d29; }
  .side-promo b { font-size: 15px; }
  .side-promo span { font-size: 13px; line-height: 1.5; color: #c9cbd6; }
  .side-promo a { margin-top: 6px; display: flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 12px; background: #fff; color: #1b1d29; font-weight: 700; font-size: 14px; text-decoration: none; }
  body.dark .side-promo { background: var(--soft); }
  #app { min-width: 0; }
  /* trình soạn thảo cần chỗ: thanh bên chỉ còn biểu tượng */
  body[data-view="p"] { grid-template-columns: 84px minmax(0, 1fr); }
  body[data-view="p"] .side { padding-inline: 14px; align-items: center; }
  body[data-view="p"] .side-label, body[data-view="p"] .side-h, body[data-view="p"] .side-promo { display: none; }
  body[data-view="p"] .logo { padding: 4px 0; font-size: 16px; }
  body[data-view="p"] .side-nav a, body[data-view="p"] .side-btn { width: 52px; justify-content: center; padding: 0; }
  
  /* Bảng điều khiển trang chủ */
  .dash { max-width: 1440px; display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 24px; align-items: start; padding: 28px clamp(16px, 3vw, 36px) 64px; }
  .dash-main, .dash-aside { min-width: 0; display: flex; flex-direction: column; gap: 24px; }
  .dash-aside { position: sticky; top: 28px; }
  .dash-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; }
  .dash-head h1 { margin: 0; font-size: 28px; font-weight: 800; letter-spacing: -.02em; }
  .dash-head p { margin: 4px 0 0; color: var(--muted); }
  .dash-search { position: relative; display: flex; align-items: center; }
  .dash-search svg { position: absolute; left: 16px; width: 18px; height: 18px; color: var(--muted); pointer-events: none; }
  .dash-search input { width: 280px; max-width: 70vw; height: 48px; padding: 0 16px 0 46px; border: 0; border-radius: 14px; background: var(--panel); }
  .dash-hero { position: relative; overflow: hidden; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 24px; padding: 36px 40px; border-radius: 28px; color: #fff; background: var(--pri); }
  .dash-hero-copy { position: relative; flex: 1 1 340px; max-width: 520px; display: flex; flex-direction: column; gap: 12px; }
  .dash-hero small { font-size: 12.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #e6e2ff; }
  .dash-hero h2 { margin: 0; font-size: clamp(24px, 2.6vw, 32px); font-weight: 800; line-height: 1.22; letter-spacing: -.02em; }
  .dash-hero-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 8px; }
  .dash-hero-actions a, .dash-hero-actions button { display: inline-flex; align-items: center; gap: 8px; min-height: 48px; padding: 0 22px; border-radius: 14px; font: inherit; font-size: 14.5px; font-weight: 700; text-decoration: none; cursor: pointer; }
  .dash-hero-actions svg { width: 18px; height: 18px; }
  .hero-pri { border: 0; background: #fff; color: #1b1d29; }
  .hero-pri:hover { background: #f1efff; }
  .hero-sec { border: 1.5px solid rgba(255, 255, 255, .8); background: none; color: #fff; }
  .hero-sec:hover { background: rgba(255, 255, 255, .12); }
  .dash-hero-art { display: flex; align-items: flex-end; gap: 14px; }
  .dash-hero-art i { display: block; width: 84px; border-radius: 20px; }
  .dash-hero-art i:nth-child(1) { height: 116px; background: rgba(255, 255, 255, .16); }
  .dash-hero-art i:nth-child(2) { height: 168px; background: #ffb86b; }
  .dash-hero-art i:nth-child(3) { height: 138px; background: rgba(255, 255, 255, .3); }
  .dash-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
  .stat { display: flex; align-items: center; gap: 16px; padding: 20px; border-radius: 20px; background: var(--panel); }
  .stat-ic { width: 52px; height: 52px; flex: none; display: grid; place-items: center; border-radius: 16px; background: var(--tint); color: var(--ink); }
  .stat-ic svg { width: 22px; height: 22px; }
  .stat b { display: block; font-size: 24px; font-weight: 800; line-height: 1.2; }
  .stat span { font-size: 13px; color: var(--muted); }
  .dash-sec-h { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
  .dash-sec-h h2 { margin: 0; font-size: 20px; font-weight: 700; }
  .dash-link { color: var(--pri); font-size: 14px; font-weight: 700; text-decoration: none; cursor: pointer; }
  .dash-link:hover { text-decoration: underline; }
  .courses { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
  .course { position: relative; display: flex; flex-direction: column; gap: 14px; padding: 14px; border-radius: 24px; background: var(--panel); transition: transform .15s, box-shadow .15s; }
  .course:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(27, 29, 41, .08); }
  .course-link { display: flex; flex-direction: column; gap: 14px; color: var(--ink); text-decoration: none; }
  .course-thumb { height: 128px; display: grid; place-items: center; border-radius: 18px; background: var(--tint); }
  .course-thumb svg { width: 46px; height: 46px; }
  .course-body { display: flex; flex-direction: column; gap: 5px; padding: 0 6px 6px; }
  .course-body b { font-size: 16px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .course-meta { font-size: 13px; color: var(--muted); }
  .course .del { position: absolute; top: 20px; right: 20px; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 12px; background: var(--panel); font-size: 20px; opacity: 0; transition: opacity .15s; }
  .course:hover .del, .course .del:focus-visible { opacity: 1; }
  .dash-empty { display: flex; flex-direction: column; gap: 4px; padding: 28px; border: 2px dashed var(--line); border-radius: 22px; color: var(--muted); }
  .dash-empty b { color: var(--ink); }
  .panel { padding: 24px; border-radius: 24px; background: var(--panel); }
  .panel h2 { margin: 0 0 16px; font-size: 18px; font-weight: 700; }
  .cal-h { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
  .cal-h h2 { margin: 0; }
  .cal-h div { display: flex; gap: 6px; }
  .cal-h button { width: 40px; height: 40px; display: grid; place-items: center; border: 0; border-radius: 12px; background: var(--soft); color: var(--ink); cursor: pointer; }
  .cal-h button svg { width: 16px; height: 16px; }
  .cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; text-align: center; }
  .cal span { height: 36px; display: grid; place-items: center; border-radius: 10px; font-size: 13px; font-weight: 600; }
  .cal .wd { height: 28px; font-size: 12px; color: var(--muted); }
  .cal .has { background: var(--t-orange); }
  .cal .today { background: var(--pri); color: #fff; }
  .steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; counter-reset: s; }
  .steps li { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: 18px; background: var(--tint); counter-increment: s; }
  .steps li::before { content: counter(s); width: 32px; height: 32px; flex: none; display: grid; place-items: center; border-radius: 10px; background: var(--panel); font-weight: 800; font-size: 14px; }
  .steps b { display: block; font-size: 14px; }
  .steps span { font-size: 12.5px; color: var(--muted); }
  .tint-violet { --tint: var(--t-violet); }
  .tint-orange { --tint: var(--t-orange); }
  .tint-green { --tint: var(--t-green); }
  .tint-blue { --tint: var(--t-blue); }
  .tint-pink { --tint: var(--t-pink); }
  @media (max-width: 1200px) {
    .dash { grid-template-columns: 1fr; }
    .dash-aside { position: static; display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
  }
  @media (max-width: 860px) {
    body, body[data-view="p"] { display: block; }
    .side { position: sticky; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
    .side .side-label, .side-h, .side-promo { display: none; }
    .logo { padding: 0 8px 0 0; font-size: 18px; }
    .side-nav, .side-foot { flex-direction: row; margin-top: 0; }
    .side-nav a, .side-btn { width: 46px; justify-content: center; padding: 0; }
    .dash-stats { grid-template-columns: 1fr; }
    .dash-hero { padding: 28px 24px; }
    .dash-hero-art { display: none; }
    .dash-search, .dash-search input { width: 100%; max-width: none; }
    .course .del { opacity: 1; }
  }
  @media (prefers-reduced-motion: reduce) { .course { transition: none; } }
  
  /* Biểu mẫu: một chiều cao điều khiển, mũi tên select tùy biến, thanh trượt màu nhấn */
  input:not([type=checkbox]):not([type=radio]):not([type=range]):not([type=file]), select { min-height: 46px; padding: 10px 14px; border-radius: 12px; background: var(--soft); border-color: transparent; }
  textarea { padding: 12px 14px; border-radius: 14px; background: var(--soft); border-color: transparent; line-height: 1.55; }
  input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: var(--line); }
  input:focus, select:focus, textarea:focus { background: var(--panel); outline: 3px solid color-mix(in srgb, var(--pri) 22%, transparent); border-color: var(--pri); }
  select { appearance: none; -webkit-appearance: none; padding-right: 42px; cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23646879' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; background-size: 18px; }
  input.big { min-height: 56px; font-size: 19px; }
  .field > span { font-size: 14.5px; }
  input[type=range] { -webkit-appearance: none; appearance: none; height: 46px; background: transparent; border: 0; cursor: pointer; }
  input[type=range]::-webkit-slider-runnable-track { height: 8px; border-radius: 99px; background: linear-gradient(var(--pri), var(--pri)) 0 / var(--fill, 50%) 100% no-repeat, var(--line); }
  input[type=range]::-moz-range-track { height: 8px; border-radius: 99px; background: var(--line); }
  input[type=range]::-moz-range-progress { height: 8px; border-radius: 99px; background: var(--pri); }
  input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -7px; border-radius: 50%; background: var(--panel); border: 3px solid var(--pri); box-shadow: 0 2px 6px rgba(27, 29, 41, .2); }
  input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--panel); border: 3px solid var(--pri); }
  input[type=checkbox] { width: 20px; height: 20px; flex: none; }
  .check { align-items: center; min-height: 46px; margin: 0; padding: 0 14px; border-radius: 12px; background: var(--soft); }
  .check input { margin-top: 0; }
  .chip { border-color: transparent; background: var(--soft); padding: 7px 13px; }
  .chip:hover { border-color: var(--pri); color: var(--pri); background: var(--ai-bg); }
  .pills { background: var(--soft); }
  .btn { min-height: 44px; border-radius: 12px; }
  .btn.small { min-height: 38px; }
  .btn.big { min-height: 54px; }
  .btn.primary { box-shadow: 0 8px 18px color-mix(in srgb, var(--pri) 28%, transparent); }
  .btn.primary:hover { box-shadow: 0 10px 22px color-mix(in srgb, var(--pri) 34%, transparent); }
  .btn:not(.primary):not(.ai):not(.ghost) { background: var(--soft); border-color: transparent; }
  .btn:not(.primary):not(.ai):not(.ghost):hover { background: var(--line); box-shadow: none; }
  .btn svg, .i svg { width: 18px; height: 18px; flex: none; }
  .card h3 { display: flex; align-items: center; gap: 10px; font-size: 17px; }
  .ic-chip { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 14px; background: var(--tint, var(--t-violet)); color: var(--ink); }
  .ic-chip svg { width: 22px; height: 22px; }
  .card h3 .ic-chip { width: 34px; height: 34px; border-radius: 10px; }
  .card h3 .ic-chip svg { width: 18px; height: 18px; }
  .warn-box, .hint-box { border-radius: 16px; }
  body.dark .warn-box, body.dark .hint-box { background: var(--t-yellow); border-color: transparent; color: var(--ink); }
  
  /* Đầu trình soạn thảo: thanh dự án + các bước */
  .page.wide { padding: 24px clamp(16px, 2.4vw, 32px) 64px; }
  .ed-top { margin-bottom: 20px; padding: 14px 16px; border-radius: 22px; background: var(--panel); }
  .ed-name { gap: 12px; }
  #p-title { min-height: 44px; font-size: 20px; font-weight: 800; letter-spacing: -.01em; background: transparent; }
  #save-st { padding: 6px 12px; border-radius: 99px; background: var(--t-green); color: var(--ink); font-size: 12.5px; font-weight: 600; }
  .stepper { margin: 0; padding: 4px; gap: 4px; border-radius: 16px; background: var(--soft); }
  .st { min-height: 40px; padding: 6px 14px 6px 6px; border-radius: 12px; }
  .st.on { background: var(--pri); color: #fff; box-shadow: none; }
  .st.on .st-n { background: #fff; color: var(--pri); }
  a.st:hover { background: var(--panel); }
  .st-sep { display: none; }
  .scenes, .scene-form { border-radius: 22px; }
  .scenes-h { font-size: 16px; }
  .scene-li { min-height: 44px; border-radius: 12px; }
  .scene-li.on { outline: 0; background: var(--ai-bg); color: var(--ink); box-shadow: inset 3px 0 0 var(--pri); }
  .form-h h2 { font-size: 22px; }
  .pv { border-radius: 20px; }
  .pv-play { width: 38px; height: 38px; }
  .theme-b { border-radius: 14px; }
  .layout-grid button span { font-size: 26px; }
  
  /* Xuất bản */
  .exports { gap: 16px; }
  .ex { gap: 6px; padding: 22px; }
  .ex h3 { margin: 12px 0 2px; font-size: 16px; }
  .ex p { font-size: 14px; }
  .ex .btn { width: 100%; }
  @media (max-width: 600px) { .ed-top { padding: 12px; } .stepper { width: 100%; overflow-x: auto; flex-wrap: nowrap; } .st { white-space: nowrap; } }
  .doc-box { display: flex; flex-direction: column; gap: 10px; }
  .wiz-head { display: flex; align-items: center; gap: 16px; margin: 18px 0 20px; }
  .wiz-head .ic-chip { width: 56px; height: 56px; border-radius: 18px; }
  .wiz-head .ic-chip svg { width: 26px; height: 26px; }
  .wiz-head .title { margin: 0; font-size: 28px; }
  .wiz-head p { margin: 4px 0 0; }
  .page.narrow .card.form { border-radius: 24px; }
  .assist button { border-color: transparent; background: var(--soft); border-radius: 16px; }
  .look-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px 14px; }
  .look-grid .field { margin: 0; }
  .look-grid .field > span { font-size: 12px; }
  