/* Thư viện Táo, bản 2. Tối làm gốc, nền xám trung tính tuyệt đối (không ám màu, để soi màu
   footage không lệch mắt). Xanh điện chỉ dành cho nút/điều khiển, không dùng cho nội dung. */
:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface-2: #1a1a1a;
  --ink: #f2f2f2;
  --muted: #8e8e8e;
  --line: #262626;
  --chip: #1c1c1c;
  --media-bg: #0e0e0e;
  --accent: #2f6bff;
  --accent-ink: #ffffff;
  --accent-soft: rgba(47, 107, 255, .16);
  --warn: #e0b341;
  --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 10px 30px rgba(0, 0, 0, .35);
  --stretch: 118%;
  --font-display: "Tao Archivo", "Archivo", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Tao Be Vietnam Pro", "Be Vietnam Pro", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "Tao JetBrains Mono", "JetBrains Mono", ui-monospace, Menlo, monospace;
  --card: 240px;
  --detail-w: min(520px, 42vw);
  color-scheme: dark;
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #efefef; --surface: #ffffff; --surface-2: #f6f6f6; --ink: #0d0d0d; --muted: #5e5e5e;
    --line: #d9d9d9; --chip: #e7e7e7; --accent: #1f5bff; --accent-soft: rgba(31, 91, 255, .12);
    --warn: #9a6a00; --shadow: 0 1px 2px rgba(10, 12, 17, .06), 0 10px 26px rgba(10, 12, 17, .08);
    color-scheme: light;
  }
}
:root[data-theme="dark"] { color-scheme: dark; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font-body); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent); color: var(--accent-ink); }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* Thanh trên */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px;
  padding: 12px 20px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand-mark {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  border: 1.5px solid var(--ink); font: 900 14px var(--font-display); font-stretch: var(--stretch);
}
.brand-name { font: 900 17px var(--font-display); font-stretch: var(--stretch); letter-spacing: .01em; }
.brand-name em { font-style: normal; font-weight: 500; color: var(--muted); }
.nav { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 999px; flex: none; }
.nav-item { padding: 6px 14px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 500; white-space: nowrap; }
.nav-item.is-active { background: var(--ink); color: var(--bg); }
.nav-item.is-soon { cursor: default; }
.nav-item small { font-size: 10px; font-family: var(--font-mono); opacity: .7; margin-left: 2px; }
.search {
  flex: 1; min-width: 160px; display: flex; align-items: center; gap: 8px; padding: 0 14px; height: 40px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 999px; color: var(--muted);
}
.search:focus-within { border-color: var(--accent); }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--ink); }
.mode { font: 11px var(--font-mono); color: var(--muted); white-space: nowrap; }

/* Thanh công cụ */
.toolbar { display: flex; align-items: center; gap: 8px; padding: 14px 20px 8px; flex-wrap: wrap; }
.btn {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 12px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 9px; font-weight: 500; white-space: nowrap;
}
.btn:hover { border-color: color-mix(in srgb, var(--ink) 30%, var(--line)); }
.btn[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.btn.select select { background: none; border: 0; outline: 0; padding-right: 2px; cursor: pointer; }
.btn.select option { background: var(--surface); }
.pill { font: 11px var(--font-mono); background: var(--accent); color: var(--accent-ink); border-radius: 999px; padding: 0 6px; }
.spacer { flex: 1; }
.count { font: 12px var(--font-mono); color: var(--muted); white-space: nowrap; }
.size { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--muted); }
.size input { width: 120px; accent-color: var(--accent); }

/* Gợi ý "Thử" + bộ lọc đang bật */
.try, .active-filters { display: flex; align-items: center; gap: 6px; padding: 4px 20px 8px; overflow-x: auto; scrollbar-width: none; }
.try-label { font: 900 11px var(--font-display); font-stretch: var(--stretch); color: var(--muted); letter-spacing: .08em; margin-right: 4px; flex: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px; border-radius: 999px;
  background: var(--chip); border: 1px solid transparent; font-size: 12.5px; white-space: nowrap;
}
button.chip:hover { border-color: var(--line); }
.chip.is-on { background: var(--accent); color: var(--accent-ink); }
.chip .x { opacity: .75; font-size: 14px; line-height: 1; }
.chip small { font: 10.5px var(--font-mono); opacity: .6; }
.link-btn { background: none; border: 0; color: var(--muted); text-decoration: underline; font-size: 12.5px; flex: none; }

/* Bố cục chính */
.layout { display: flex; align-items: flex-start; gap: 18px; padding: 8px 20px 40px; }
.filters {
  position: sticky; top: 76px; width: 230px; flex: none; max-height: calc(100vh - 92px); overflow-y: auto;
  padding-right: 6px; scrollbar-width: thin;
}
.filters[data-closed] { display: none; }
.fgroup { border-bottom: 1px solid var(--line); padding: 10px 0; }
.fgroup summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; font-weight: 600; font-size: 13px; }
.fgroup summary::-webkit-details-marker { display: none; }
.fgroup summary span { font: 11px var(--font-mono); color: var(--muted); font-weight: 400; }
.fgroup .chips { display: flex; flex-wrap: wrap; gap: 5px; padding-top: 9px; }
.results { flex: 1; min-width: 0; }

/* Lưới */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card), 1fr)); gap: 14px; }
.card {
  position: relative; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; overflow: hidden; cursor: pointer; text-align: left; padding: 0;
  transition: border-color .15s, transform .15s;
}
.card:hover { border-color: color-mix(in srgb, var(--ink) 35%, var(--line)); }
.card.is-selected { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.media { position: relative; aspect-ratio: 16 / 9; background: var(--media-bg); overflow: hidden; }
.media img { width: 100%; height: 100%; object-fit: contain; display: block; }
body.fill .media img { object-fit: cover; }
.badges { position: absolute; left: 8px; top: 8px; display: flex; gap: 4px; }
.badge { font: 600 10px var(--font-mono); letter-spacing: .04em; padding: 2px 6px; border-radius: 4px; background: rgba(0, 0, 0, .72); color: #fff; }
.badge.warn { color: #ffd66b; }
.frame-dots { position: absolute; left: 8px; right: 8px; bottom: 6px; display: flex; gap: 3px; opacity: 0; transition: opacity .15s; }
.card:hover .frame-dots { opacity: 1; }
.frame-dots i { flex: 1; height: 2px; border-radius: 2px; background: rgba(255, 255, 255, .35); }
.frame-dots i.on { background: #fff; }
.card-body { padding: 9px 11px 11px; display: flex; flex-direction: column; gap: 5px; }
.card-title { font-weight: 600; font-size: 13px; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-title span { color: var(--muted); font-weight: 400; font-family: var(--font-mono); font-size: 11.5px; }
.card-meta { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 11.5px; min-width: 0; }
.card-meta .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.palette { display: flex; height: 6px; border-radius: 3px; overflow: hidden; flex: none; width: 48px; }
.palette i { flex: 1; }
.empty { color: var(--muted); text-align: center; padding: 60px 0; }

/* Bảng chi tiết bên phải */
.detail {
  position: sticky; top: 76px; width: var(--detail-w); flex: none; max-height: calc(100vh - 92px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px; scrollbar-width: thin;
}
.detail-nav { display: flex; justify-content: flex-end; gap: 6px; margin-bottom: 10px; }
.icon-btn { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); }
.icon-btn:hover { border-color: var(--accent); }
.viewer { position: relative; background: var(--media-bg); border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; }
.viewer img { width: 100%; height: 100%; object-fit: contain; display: block; }
.viewer-cap { font: 11px var(--font-mono); color: var(--muted); margin: 6px 0 8px; }
.notice { font-size: 12.5px; color: var(--warn); border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent); background: color-mix(in srgb, var(--warn) 8%, transparent); border-radius: 8px; padding: 8px 10px; margin-bottom: 12px; }
.strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 5px; margin-bottom: 14px; }
.strip button { padding: 0; border: 1px solid transparent; border-radius: 6px; overflow: hidden; background: var(--media-bg); aspect-ratio: 16 / 9; }
.strip button.on { border-color: var(--accent); }
.strip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.d-title { font: 800 20px/1.2 var(--font-display); font-stretch: 108%; margin: 0 0 4px; }
.d-sub { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.d-sub a { color: var(--ink); }
.d-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); text-decoration: none; }
.btn-primary:hover { border-color: var(--accent); filter: brightness(1.1); }
.btn-link { text-decoration: none; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-bottom: 14px; }
.stat { background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; }
.stat b { display: block; font: 600 15px var(--font-mono); }
.stat span { font-size: 11px; color: var(--muted); }
.d-sec { margin: 0 0 14px; }
.d-sec h3 { font: 900 11px var(--font-display); font-stretch: var(--stretch); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 0 0 6px; }
.d-sec p { margin: 0; }
.tag-rows { display: grid; gap: 7px; }
.tag-row { display: grid; grid-template-columns: 112px 1fr; gap: 8px; align-items: start; }
.tag-row > span { font-size: 12px; color: var(--muted); padding-top: 4px; }
.tag-row .chips { display: flex; flex-wrap: wrap; gap: 5px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { display: flex; align-items: center; gap: 6px; font: 11px var(--font-mono); color: var(--muted); }
.swatch i { width: 22px; height: 22px; border-radius: 5px; border: 1px solid var(--line); }
details.transcript summary { cursor: pointer; color: var(--muted); font-size: 12.5px; }
details.transcript p { white-space: pre-wrap; font-size: 12.5px; color: var(--muted); margin-top: 6px; }

/* Màn hình hẹp */
@media (max-width: 1100px) {
  .mode { display: none; }
  .filters { display: none; }
}
@media (max-width: 820px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 16px; }
  .nav { order: 3; }
  .search { order: 2; flex-basis: 100%; }
  .toolbar, .try, .active-filters { padding-left: 16px; padding-right: 16px; }
  .layout { padding: 8px 16px 40px; }
  .size input { width: 80px; }
  .detail { position: fixed; inset: auto 0 0 0; top: 12vh; width: auto; max-height: none; border-radius: 16px 16px 0 0; z-index: 30; box-shadow: var(--shadow); }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .tag-row { grid-template-columns: 1fr; gap: 4px; }
}

/* ===================== Giai đoạn 1 ===================== */
.page[hidden] { display: none !important; }
.topbar .spacer { flex: 1; }
.nav-item { display: inline-flex; align-items: center; gap: 5px; }
.nav-item .pill { margin-left: 2px; }
.nav-item svg { width: 14px; height: 14px; }
.btn.static { cursor: default; color: var(--muted); }
.btn:disabled { opacity: .5; cursor: default; }

/* Chọn chế độ xem */
.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); }
.seg-btn { height: 26px; padding: 0 12px; border: 0; border-radius: 6px; background: none; font-weight: 500; color: var(--muted); }
.seg-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }

/* Thẻ shot: clip chạy khi rê chuột */
.media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--media-bg); }
body.fill .media video { object-fit: cover; }
.badge.dead { color: #ff8a8a; }
.badge.len { left: auto; }
.badges-r { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 4px; }
.more { display: flex; justify-content: center; padding: 18px 0; color: var(--muted); font-size: 12.5px; }

/* Trình phát + cắt In/Out */
.viewer video { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.viewer .vbtns { position: absolute; right: 8px; top: 8px; display: flex; gap: 6px; }
.viewer .vbtns .icon-btn { background: rgba(0, 0, 0, .6); border-color: rgba(255, 255, 255, .15); color: #fff; }
.trim { position: relative; height: 40px; margin: 10px 0 6px; border-radius: 8px; background: var(--surface-2); border: 1px solid var(--line); touch-action: none; user-select: none; cursor: pointer; }
.trim-sel { position: absolute; top: 0; bottom: 0; background: var(--accent-soft); border-top: 2px solid var(--accent); border-bottom: 2px solid var(--accent); }
.trim-h { position: absolute; top: -2px; bottom: -2px; width: 12px; margin-left: -6px; border-radius: 4px; background: var(--accent); cursor: ew-resize; }
.trim-h::after { content: ""; position: absolute; left: 5px; top: 12px; bottom: 12px; width: 2px; background: rgba(255, 255, 255, .8); border-radius: 1px; }
.trim-play { position: absolute; top: 4px; bottom: 4px; width: 2px; margin-left: -1px; background: var(--ink); pointer-events: none; }
.trim-info { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font: 12px var(--font-mono); color: var(--muted); }
.trim-info b { color: var(--ink); font-weight: 500; }
.trim-info .spacer { flex: 1; }
.trim-info .btn { height: 28px; padding: 0 9px; font-family: var(--font-body); }
.hint { font-size: 11.5px; color: var(--muted); margin: 6px 0 10px; }
kbd { font: 10.5px var(--font-mono); padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; background: var(--surface-2); color: var(--ink); }
.export-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.strip button { position: relative; }
.strip button span { position: absolute; left: 3px; bottom: 2px; font: 9.5px var(--font-mono); color: #fff; text-shadow: 0 0 3px #000; }

/* ============ Import ============ */
.imp-box { margin: 18px 20px 0; padding: 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.imp-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.imp-row textarea {
  flex: 1; min-width: 260px; min-height: 44px; max-height: 220px; resize: vertical; padding: 11px 16px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 22px; color: var(--ink); font: inherit; line-height: 1.45;
}
.imp-row textarea:focus { outline: 0; border-color: var(--accent); }
.imp-row > .btn { height: 44px; padding: 0 16px; border-radius: 22px; }
.imp-sub { margin-top: 10px; }
.imp-sub .btn { border-radius: 999px; }
.drop-hint { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border: 1px dashed var(--line); border-radius: 999px; color: var(--muted); font-size: 12.5px; }
.imp-limits { font-size: 12px; color: var(--muted); }
.imp-msg { margin: 10px 2px 0; font-size: 13px; }
.imp-msg.err { color: #ff8a8a; }
.imp-layout { display: grid; grid-template-columns: 380px 1fr; gap: 18px; padding: 18px 20px 40px; align-items: start; }
.queue-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.queue-head h2 { margin: 0; font: 900 12px var(--font-display); font-stretch: var(--stretch); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 2px; padding: 3px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); margin-bottom: 10px; }
.tab { height: 30px; border: 0; border-radius: 7px; background: none; color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.tab span { font: 10.5px var(--font-mono); opacity: .8; }
.tab[aria-selected="true"] { background: var(--surface-2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); }
.q-list { display: grid; gap: 8px; max-height: calc(100vh - 290px); overflow-y: auto; scrollbar-width: thin; padding-right: 2px; }
.q-item { display: grid; grid-template-columns: 96px 1fr; gap: 11px; padding: 9px; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; }
.q-thumb { aspect-ratio: 16 / 10; border-radius: 6px; overflow: hidden; background: var(--media-bg); display: grid; place-items: center; color: var(--muted); }
.q-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.q-body { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.q-title { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-meta { font: 11px var(--font-mono); color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.q-foot { display: flex; align-items: center; gap: 6px; margin-top: 3px; flex-wrap: wrap; }
.status { font-size: 11.5px; padding: 2px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status.ok { background: rgba(60, 190, 110, .14); color: #59d38c; }
.status.run { background: var(--accent-soft); color: var(--ink); }
.status.err { background: rgba(255, 90, 90, .12); color: #ff8a8a; }
.q-foot .spacer { flex: 1; }
.q-foot .btn { height: 26px; padding: 0 9px; font-size: 12px; border-radius: 999px; }
.q-err { font-size: 11.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.q-empty { color: var(--muted); font-size: 13px; padding: 18px 4px; }
.spin { width: 10px; height: 10px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: spin .8s linear infinite; vertical-align: -1px; margin-right: 4px; }
@keyframes spin { to { transform: rotate(360deg); } }
.imp-main { display: grid; gap: 14px; }
.imp-hero { min-height: 300px; display: grid; place-content: center; justify-items: center; text-align: center; gap: 10px; padding: 40px 24px; border: 1.5px dashed var(--line); border-radius: 16px; }
.imp-icon { width: 60px; height: 60px; border-radius: 16px; display: grid; place-items: center; background: var(--surface); border: 1px solid var(--line); color: var(--accent); }
.imp-icon svg { width: 26px; height: 26px; }
.imp-hero h1 { margin: 6px 0 0; font: 900 26px/1.15 var(--font-display); font-stretch: var(--stretch); }
.imp-hero p { margin: 0; max-width: 560px; color: var(--muted); }
.legacy-box { display: flex; gap: 16px; align-items: center; justify-content: space-between; padding: 14px 16px; border: 1px solid var(--line); background: var(--surface); border-radius: 14px; }
.legacy-box p { margin: 3px 0 0; color: var(--muted); font-size: 12.5px; }
.drop { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: color-mix(in srgb, var(--bg) 70%, transparent); backdrop-filter: blur(4px); }
.drop > div { display: flex; align-items: center; gap: 10px; padding: 26px 40px; border: 2px dashed var(--accent); border-radius: 20px; font: 800 20px var(--font-display); background: var(--surface); }
.drop svg { width: 24px; height: 24px; color: var(--accent); }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60; background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 10px; font-size: 13px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }

@media (max-width: 1000px) { .imp-layout { grid-template-columns: 1fr; } .q-list { max-height: none; } }
@media (max-width: 820px) {
  .imp-box { margin: 12px 16px 0; }
  .imp-layout { padding: 14px 16px 40px; }
  .legacy-box { flex-direction: column; align-items: stretch; }
}
body[data-route="import"] [data-show="library"], body[data-route="library"] [data-show="import"],
body[data-route="collections"] [data-show="library"], body[data-route="trash"] [data-show="library"] { display: none !important; }
body[data-route="collections"] [data-show="import"], body[data-route="trash"] [data-show="import"] { display: block !important; }

.notice.pending { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.notice.pending .btn { flex: none; height: 28px; padding: 0 10px; font-size: 12px; }
#analysis-box { margin-top: 12px; }
#analysis-sub { font-family: var(--font-mono); font-size: 11.5px; }

/* ============ Bộ sưu tập ============ */
:root { --ccard: 240px; }
.col-head, .col-top { padding: 20px 20px 6px; }
.col-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.page-title { font: 900 26px var(--font-display); font-stretch: var(--stretch); margin: 0; display: flex; align-items: baseline; gap: 10px; }
.search.small { flex: 0 1 260px; height: 34px; border-radius: 9px; }
.col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; padding: 14px 20px 40px; align-items: start; }
.col-card { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; text-decoration: none; text-align: left; padding: 0; }
.col-card:hover { border-color: color-mix(in srgb, var(--ink) 35%, var(--line)); }
.col-cover { display: grid; grid-template-columns: 2fr 1fr; grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 2px; aspect-ratio: 16 / 9; background: var(--line); }
.col-cover > div { position: relative; background: var(--media-bg); overflow: hidden; }
.col-cover .cv-a { grid-row: span 2; }
.col-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.col-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 2px; }
.col-body b { font: 800 15px var(--font-display); font-stretch: 108%; }
.col-body span { font: 11.5px var(--font-mono); color: var(--muted); }
.col-body p { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.col-new { align-items: center; justify-content: center; gap: 12px; aspect-ratio: 16 / 11; border-style: dashed; color: var(--muted); background: none; }

.back { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); text-decoration: none; font-size: 13px; }
.back:hover { color: var(--ink); }
.c-name { display: block; width: 100%; margin: 6px 0 2px; background: none; border: 1px solid transparent; border-radius: 8px; padding: 2px 6px; margin-left: -7px;
  font: 900 28px var(--font-display); font-stretch: var(--stretch); color: var(--ink); }
.c-brief { display: block; width: 100%; resize: none; background: none; border: 1px solid transparent; border-radius: 8px; padding: 4px 6px; margin-left: -7px;
  color: var(--muted); font: 14px/1.5 var(--font-body); overflow: hidden; }
.c-name:hover, .c-brief:hover { border-color: var(--line); }
.c-name:focus, .c-brief:focus { outline: 0; border-color: var(--accent); color: var(--ink); }
.c-meta { font: 11.5px var(--font-mono); color: var(--muted); margin-top: 6px; }
.c-layout { display: flex; gap: 20px; align-items: flex-start; padding: 12px 20px 40px; }
.c-side { position: sticky; top: 76px; width: 210px; flex: none; display: flex; flex-direction: column; gap: 2px; }
.c-side h4 { font: 900 11px var(--font-display); font-stretch: var(--stretch); letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 14px 0 4px; }
.c-nav { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 7px 10px; border-radius: 8px; border: 1px solid transparent; background: none; text-align: left; font-weight: 500; }
.c-nav span { font: 11px var(--font-mono); color: var(--muted); }
.c-nav:hover { background: var(--surface); }
.c-nav.is-on { border-color: var(--accent); background: var(--accent-soft); }
.c-nav.drop-on { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }
.c-nav-row { display: flex; align-items: center; gap: 2px; }
.c-nav-row .c-nav { flex: 1; min-width: 0; }
.icon-btn.mini { width: 26px; height: 26px; flex: none; }
.icon-btn.mini svg { width: 14px; height: 14px; }
.c-side .link-btn { text-align: left; padding: 6px 10px; }
.link-btn.danger, .danger { color: #ff6b6b; }
.c-help { font-size: 12px; color: var(--muted); margin: 6px 0; }
.c-side .c-help { padding: 10px; margin-top: 12px; }
.c-main { flex: 1; min-width: 0; }
.c-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.c-toolbar > b { font: 800 15px var(--font-display); font-stretch: 108%; }
.c-grid { grid-template-columns: repeat(auto-fill, minmax(var(--ccard), 1fr)); }
.citem { cursor: pointer; }
.citem.dragging { opacity: .4; }
.citem.drop-before { box-shadow: -4px 0 0 0 var(--accent); }
.citem.drop-after { box-shadow: 4px 0 0 0 var(--accent); }
.citem .media video, .sug .media video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--media-bg); }
body.fill .citem .media video { object-fit: cover; }
.badge.trim { display: inline-flex; align-items: center; gap: 4px; }
.badge.trim svg { width: 11px; height: 11px; }
.cmenu { position: absolute; right: 8px; top: 8px; opacity: 0; background: rgba(0, 0, 0, .7); border-color: transparent; color: #fff; }
.citem:hover .cmenu, .cmenu:focus-visible { opacity: 1; }
.cnote { font-size: 12.5px; padding: 5px 7px; border: 1px dashed transparent; border-radius: 6px; margin: 0 -7px; cursor: text; white-space: pre-wrap; }
.cnote.empty { color: var(--muted); border-color: var(--line); text-align: center; }
.cnote:hover { border-color: var(--line); }
.cnote textarea { width: 100%; resize: vertical; background: var(--surface-2); border: 1px solid var(--accent); border-radius: 6px; padding: 5px 7px; color: var(--ink); font: 12.5px/1.45 var(--font-body); outline: 0; }
.c-suggest { margin-top: 32px; padding-top: 18px; border-top: 1px solid var(--line); }
.c-suggest h3, .sim-head h3 { font: 900 12px var(--font-display); font-stretch: var(--stretch); letter-spacing: .08em; text-transform: uppercase; margin: 0; }
.sug-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 10px; }
.sug { display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.sug-media { position: relative; overflow: hidden; padding: 0; border: 0; aspect-ratio: 16 / 9; background: var(--media-bg); display: block; width: 100%; }
.sug-media img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.sug-body { padding: 6px 8px; display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.sug-body b { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sug-body span { font: 10.5px var(--font-mono); color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sug-add { margin: 0 8px 8px; height: 28px; justify-content: center; }
.sim-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.seg.small .seg-btn { height: 24px; padding: 0 9px; font-size: 12px; }
.sim-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.sim-grid .sug-body { padding: 4px 6px; }

/* Menu nổi */
.pop { position: fixed; z-index: 70; min-width: 220px; max-width: 320px; max-height: 70vh; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px; }
.pop-menu { display: flex; flex-direction: column; }
.pop-menu button { display: flex; align-items: center; gap: 8px; width: 100%; padding: 7px 10px; border: 0; border-radius: 7px; background: none; text-align: left; }
.pop-menu button:hover { background: var(--surface-2); }
.pop-menu button small { margin-left: auto; font: 10.5px var(--font-mono); color: var(--muted); padding-left: 10px; white-space: nowrap; }
.pop-sep { font: 10.5px var(--font-mono); color: var(--muted); padding: 6px 10px 3px; border-top: 1px solid var(--line); margin-top: 4px; }
.pop-menu .pop-sep:first-child { border-top: 0; margin-top: 0; }

/* Hộp thoại đoạn cắt */
.modal { position: fixed; inset: 0; z-index: 65; display: grid; place-items: center; background: rgba(0, 0, 0, .6); padding: 16px; }
.modal-box { width: min(760px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; box-shadow: var(--shadow); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal .viewer video { width: 100%; height: 100%; object-fit: contain; display: block; }

/* Trình chiếu */
.present { position: fixed; inset: 0; z-index: 80; background: #000; display: flex; flex-direction: column; color: #f2f2f2; }
.pr-stage { flex: 1; min-height: 0; display: grid; place-items: center; }
.pr-stage video, .pr-stage img { max-width: 100%; max-height: 100%; width: 100%; height: 100%; object-fit: contain; }
.pr-info { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; padding: 16px 24px 22px; background: linear-gradient(transparent, rgba(0, 0, 0, .9)); }
.pr-info h2 { font: 800 22px var(--font-display); font-stretch: 108%; margin: 2px 0 4px; }
.pr-info p { margin: 0; color: #bdbdbd; max-width: 70ch; white-space: pre-wrap; }
.pr-group { font: 900 11px var(--font-display); font-stretch: var(--stretch); letter-spacing: .1em; text-transform: uppercase; color: #8e8e8e; }
.pr-ctl { display: flex; align-items: center; gap: 8px; flex: none; }
.present .icon-btn { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .15); color: #fff; }
.present .count { color: #8e8e8e; margin-right: 6px; }

@media (max-width: 820px) {
  .c-layout { flex-direction: column; }
  .c-side { position: static; width: 100%; }
  .sim-grid { grid-template-columns: repeat(2, 1fr); }
}
.mode.warn { color: var(--warn); }

/* ============ Xoá video / thùng rác ============ */
.btn-danger { color: #ff6b6b; }
.btn-danger:hover { border-color: #ff6b6b; }
.toast { display: flex; align-items: center; gap: 10px; }
.toast-btn { background: none; border: 0; color: var(--accent); font-weight: 700; padding: 0 2px; text-decoration: underline; }
body.selecting #grid .card { outline: 1px dashed var(--line); }
body.selecting #grid .card .media::after { content: ""; position: absolute; right: 8px; top: 8px; width: 20px; height: 20px; border-radius: 6px;
  border: 2px solid rgba(255, 255, 255, .85); background: rgba(0, 0, 0, .35); }
#grid .card.is-picked { border-color: #ff6b6b; box-shadow: 0 0 0 1px #ff6b6b; }
#grid .card.is-picked .media::after { background: #ff6b6b; border-color: #ff6b6b;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='m6 12 4 4 8-8' fill='none' stroke='white' stroke-width='3'/%3E%3C/svg%3E"); background-size: 16px; background-position: center; background-repeat: no-repeat; }
.selbar { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 40; display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 8px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.tr-help { padding: 0 20px; color: var(--muted); font-size: 13px; max-width: 900px; margin: 4px 0 14px; }
.tr-help code { font: 12px var(--font-mono); }
.tr-list { display: flex; flex-direction: column; gap: 8px; padding: 0 20px 40px; max-width: 1100px; }
.tr-item { display: flex; align-items: center; gap: 12px; padding: 8px 12px 8px 8px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.tr-item input { width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.tr-item img { width: 120px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 6px; background: var(--media-bg); flex: none; }
.tr-body { flex: 1; min-width: 0; }
.tr-body b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tr-body span { font: 11.5px var(--font-mono); color: var(--muted); }
.tr-item .btn { height: 30px; flex: none; }
@media (max-width: 820px) { .tr-item img { width: 80px; } }

/* ============ Khung xem ghim + dải shot ngang (máy tính và điện thoại) ============ */
.d-stick { position: sticky; top: -14px; z-index: 6; margin: -14px -14px 12px; padding: 14px 14px 10px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.d-stick .detail-nav { margin-bottom: 8px; }
.d-stick .viewer { max-height: 38vh; }
.d-stick .viewer-cap { margin: 5px 0 4px; }
.d-stick .trim { margin: 6px 0 4px; }
.d-stick .strip { display: flex; grid-template-columns: none; gap: 5px; overflow-x: auto; margin: 8px -14px 0; padding: 2px 14px 4px;
  scroll-snap-type: x proximity; scrollbar-width: thin; overscroll-behavior-x: contain; }
.d-stick .strip button { flex: 0 0 92px; scroll-snap-align: center; }
.d-stick .strip button.on { box-shadow: 0 0 0 2px var(--accent); }
@media (max-width: 820px) {
  .d-stick .viewer { max-height: 30vh; }
  .d-stick .strip button { flex-basis: 78px; }
  .d-stick .trim-info { gap: 8px; font-size: 11px; flex-wrap: nowrap; }
  .d-stick .trim-info .btn { height: 28px; padding: 0 7px; }
  .d-stick .detail-nav { margin-bottom: 4px; }
  .d-stick .detail-nav .icon-btn { width: 28px; height: 28px; }
}
