/* ================================================================ tokens */
:root {
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #f3f4f6;
  --surface-3: #e9ebef;
  --border: #e6e8ec;
  --border-strong: #d2d6dc;
  --ink: #0f172a;
  --ink-2: #475569;
  --muted: #8a94a6;
  --accent: #2563eb;
  --accent-soft: #e8efff;
  --accent-ink: #ffffff;
  --primary: #0f172a;
  --primary-ink: #ffffff;
  --good: #16a34a; --good-ink: #15803d; --good-bg: #e8f6ed;
  --warn: #f59e0b; --warn-ink: #b45309; --warn-bg: #fdf3e1;
  --bad: #dc2626;  --bad-ink: #b91c1c;  --bad-bg: #fdecec;
  --info: #2563eb; --info-ink: #1d4ed8; --info-bg: #e8efff;
  --today: #eef4ff;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, .06);
  --shadow: 0 1px 3px rgba(15, 23, 42, .06), 0 6px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 20px 50px rgba(15, 23, 42, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar: 236px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0d12; --surface: #13161d; --surface-2: #1a1e27; --surface-3: #232836; --border: #232836; --border-strong: #313849;
    --ink: #eef1f6; --ink-2: #b4bccb; --muted: #7d879a; --accent: #5b8cff; --accent-soft: #1b2847; --primary: #eef1f6; --primary-ink: #0b0d12;
    --good-ink: #4ade80; --good-bg: #12291c; --warn-ink: #fbbf24; --warn-bg: #2c2210; --bad-ink: #f87171; --bad-bg: #331617; --info-ink: #93b4ff; --info-bg: #1b2847;
    --today: #16213a; --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 16px rgba(0,0,0,.3); --shadow-lg: 0 20px 50px rgba(0,0,0,.55);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0b0d12; --surface: #13161d; --surface-2: #1a1e27; --surface-3: #232836; --border: #232836; --border-strong: #313849;
  --ink: #eef1f6; --ink-2: #b4bccb; --muted: #7d879a; --accent: #5b8cff; --accent-soft: #1b2847; --primary: #eef1f6; --primary-ink: #0b0d12;
  --good-ink: #4ade80; --good-bg: #12291c; --warn-ink: #fbbf24; --warn-bg: #2c2210; --bad-ink: #f87171; --bad-bg: #331617; --info-ink: #93b4ff; --info-bg: #1b2847;
  --today: #16213a; --shadow: 0 1px 3px rgba(0,0,0,.4), 0 6px 16px rgba(0,0,0,.3); --shadow-lg: 0 20px 50px rgba(0,0,0,.55);
  color-scheme: dark;
}

/* ================================================================ base */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 14px/1.5 Inter, "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  -webkit-font-smoothing: antialiased; font-feature-settings: "cv11", "ss01";
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
svg.i { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
svg.i.sm { width: 14px; height: 14px; }
svg.i.lg { width: 20px; height: 20px; }
.muted { color: var(--muted); }
.ink2 { color: var(--ink-2); }
.small { font-size: 12px; }
.xs { font-size: 11px; }
.num { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; }
.col { display: flex; flex-direction: column; gap: 4px; }
.grow { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.hidden { display: none !important; }
kbd { font: 11px/1 ui-monospace, Consolas, monospace; padding: 3px 5px; border-radius: 5px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--ink-2); }
code { font: 12.5px ui-monospace, Consolas, monospace; background: var(--surface-2); padding: 1px 5px; border-radius: 5px; }
::selection { background: var(--accent-soft); }

/* ================================================================ shell */
.shell { display: grid; grid-template-columns: var(--sidebar) 1fr; min-height: 100vh; }
.sidebar {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px;
  padding: 14px 12px; background: var(--surface); border-right: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 14px; font-weight: 700; font-size: 15px; letter-spacing: -.01em; }
.brand-logo { width: 30px; height: 30px; border-radius: 9px; background: linear-gradient(135deg, #ff4d4d, #c81e1e); display: grid; place-items: center; box-shadow: 0 4px 10px rgba(220, 38, 38, .3); }
.brand-logo svg { width: 14px; height: 14px; fill: #fff; stroke: none; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--ink-2);
  cursor: pointer; border: 0; background: transparent; width: 100%; text-align: left; font-weight: 500; text-decoration: none !important;
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item.active { background: var(--surface-2); color: var(--ink); font-weight: 600; }
.nav-item.active svg { color: var(--accent); }
.nav-item .count { margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--bad-bg); color: var(--bad-ink); }
.nav-sep { height: 1px; background: var(--border); margin: 8px 4px; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 6px; }
.sync-box { padding: 10px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 12px; color: var(--ink-2); }
.sync-box b.num { font-weight: 600; color: var(--ink); }
#refreshBtn .cd { font-size: 11px; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--muted); padding: 1px 6px; border-radius: 999px; background: var(--surface-2); min-width: 34px; text-align: center; }
.sync-box .bar {height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 6px; }
.sync-box .bar > i { display: block; height: 100%; background: var(--accent); transition: width .3s; }

.main { min-width: 0; display: flex; flex-direction: column; }
.pagebar {
  position: sticky; top: 0; z-index: 15; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 14px 28px; background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid transparent;
}
.pagebar.scrolled { border-bottom-color: var(--border); }
.pagebar h1 { margin: 0; font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.pagebar .sub { color: var(--muted); font-size: 13px; }
.search-trigger {
  display: flex; align-items: center; gap: 8px; min-width: 240px; padding: 7px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface); color: var(--muted); cursor: pointer;
}
.search-trigger:hover { border-color: var(--border-strong); }
.search-trigger kbd { margin-left: auto; }
.page { padding: 8px 28px 96px; max-width: 1560px; width: 100%; }

/* ================================================================ controls */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap;
  padding: 7px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface);
  cursor: pointer; font-weight: 500; line-height: 1.2; transition: background .12s, border-color .12s, box-shadow .12s;
  box-shadow: var(--shadow-sm); text-decoration: none !important; color: var(--ink);
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .input:focus-visible, .nav-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn.primary:hover { filter: brightness(1.15); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.danger { color: var(--bad-ink); }
.btn.danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.icon { padding: 6px; }
.btn.sm { padding: 4px 8px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.input, .select, textarea.input {
  width: 100%; padding: 7px 10px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--ink); transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus, textarea.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea.input { resize: vertical; min-height: 72px; }
.input-icon { position: relative; }
.input-icon svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-icon .input { padding-left: 32px; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field > label, .field > .label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.field .hint { font-size: 11.5px; color: var(--muted); font-weight: 400; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--border); }
.seg button { border: 0; background: transparent; padding: 5px 10px; border-radius: 6px; cursor: pointer; color: var(--ink-2); font-weight: 500; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.seg button:hover { color: var(--ink); }
.seg button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); font-weight: 600; }
.seg .n { font-size: 11px; color: var(--muted); font-weight: 600; }

.wd-toggle { display: flex; gap: 4px; flex-wrap: wrap; }
.wd-toggle button { width: 38px; height: 32px; border-radius: 8px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 12px; color: var(--ink-2); }
.wd-toggle button.on { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; font-size: 13px; color: var(--ink-2); }
.switch input { appearance: none; width: 32px; height: 18px; border-radius: 999px; background: var(--surface-3); position: relative; cursor: pointer; transition: background .15s; margin: 0; flex: none; }
.switch input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(14px); }

.fchip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-size: 12.5px; color: var(--ink-2); white-space: nowrap; }
.fchip:hover { border-color: var(--ink-2); }
.fchip.on { background: var(--ink); border-color: var(--ink); color: var(--surface); }
.fchip.off { opacity: .45; }

/* ================================================================ display */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-h { display: flex; align-items: center; gap: 8px; padding: 14px 16px 10px; }
.card-h h3 { margin: 0; font-size: 14px; font-weight: 650; }
.card-h .sub { color: var(--muted); font-size: 12px; }
.card-b { padding: 4px 16px 16px; }
.card-b.flush { padding: 0 0 6px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi { padding: 14px 16px; }
.kpi .label { color: var(--ink-2); font-size: 12.5px; font-weight: 500; display: flex; align-items: center; gap: 6px; }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .foot { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi.alert .value { color: var(--bad-ink); }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; line-height: 1.5; }
.badge svg.i { width: 12px; height: 12px; vertical-align: -1px; }
.tone-good { background: var(--good-bg); color: var(--good-ink); }
.tone-warn { background: var(--warn-bg); color: var(--warn-ink); }
.tone-bad { background: var(--bad-bg); color: var(--bad-ink); }
.tone-info { background: var(--info-bg); color: var(--info-ink); }
.tone-neutral { background: var(--surface-2); color: var(--ink-2); }
.tag { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 6px; font-size: 11.5px; font-weight: 500; background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--border); white-space: nowrap; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex: none; background: var(--c, var(--muted)); }
.avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; flex: none; background: var(--surface-3); display: inline-grid; place-items: center; font-weight: 700; color: #fff; font-size: 13px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--c, transparent); }
.avatar.sm { width: 26px; height: 26px; font-size: 11px; box-shadow: 0 0 0 2px var(--surface), 0 0 0 3px var(--c, transparent); }
.avatar.lg { width: 52px; height: 52px; font-size: 18px; }
.delta-up { color: var(--good-ink); font-weight: 600; }
.delta-down { color: var(--bad-ink); font-weight: 600; }
.progress { height: 6px; border-radius: 6px; background: var(--surface-3); overflow: hidden; min-width: 60px; }
.progress > i { display: block; height: 100%; border-radius: 6px; background: var(--c, var(--accent)); }

.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty .ico { width: 54px; height: 54px; border-radius: 16px; background: var(--surface-2); display: grid; place-items: center; margin: 0 auto 12px; }
.empty .ico svg { width: 26px; height: 26px; color: var(--muted); }
.empty h3 { margin: 0 0 6px; color: var(--ink); }
.empty p { margin: 0 0 16px; }

/* list rows (dashboard) */
.lrow { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-top: 1px solid var(--border); }
.lrow:first-child { border-top: 0; }
.lrow.click { cursor: pointer; }
.lrow.click:hover { background: var(--surface-2); }
.lrow .title { font-weight: 600; }
.alert-ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; flex: none; }

.dash-grid { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.dash-col { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.agenda-day { padding: 8px 16px 4px; font-size: 12px; font-weight: 700; color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; display: flex; gap: 8px; align-items: center; }
.agenda-day.today { color: var(--accent); }
.vthumb { width: 96px; aspect-ratio: 16/9; border-radius: 8px; object-fit: cover; background: var(--surface-3); flex: none; }
.vthumb.sm { width: 72px; }
.vthumb.short { aspect-ratio: 9/16; width: 40px; }

/* ================================================================ toolbar & table */
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 900px; }
.tbl th.c-actions { width: 96px; }
.tbl th, .tbl td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border); }
.tbl thead th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface); position: sticky; top: 0; z-index: 1; white-space: nowrap; text-transform: none; }
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--ink); }
.tbl th.sorted { color: var(--ink); }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: color-mix(in srgb, var(--surface-2) 70%, transparent); }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr.archived { opacity: .55; }
.tbl tbody tr.dragging { opacity: .4; }
.tbl tbody tr.drop-above td { box-shadow: inset 0 2px 0 var(--accent); }
.tbl td.r, .tbl th.r { text-align: right; }
.tbl td.c-content { min-width: 140px; max-width: 200px; }
.tbl td.c-note { min-width: 160px; max-width: 260px; }
.tbl td.c-schedule, .tbl td.c-due, .tbl td.c-subs, .tbl td.c-bkt { white-space: nowrap; }
.tbl td.c-last { min-width: 230px; max-width: 290px; }
.tbl .last-vid .vthumb.sm { width: 64px; }
.tbl td.c-tags { min-width: 90px; }
.grip { cursor: grab; color: var(--muted); opacity: 0; padding: 2px; }
.tbl tr:hover .grip { opacity: 1; }
.ch-cell { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.ch-name { font-weight: 600; cursor: pointer; }
.ch-name:hover { color: var(--accent); }
.row-actions { display: flex; gap: 2px; justify-content: flex-end; opacity: .35; transition: opacity .12s; }
.tbl tr:hover .row-actions { opacity: 1; }
.cell-edit { display: block; min-height: 24px; padding: 2px 6px; margin: -2px -6px; border-radius: 6px; cursor: text; border: 1px solid transparent; }
.cell-edit:hover { background: var(--surface-2); border-color: var(--border); }
.cell-edit.empty::before { content: "—"; color: var(--muted); }
.cell-input { width: 100%; min-width: 90px; padding: 3px 6px; border-radius: 6px; border: 1px solid var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
select.cell-select {
  appearance: none; border: 0; cursor: pointer; padding: 2px 22px 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 6px center; background-size: 12px;
}
.last-vid { display: flex; gap: 10px; align-items: center; max-width: 290px; }
.last-vid .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink); font-weight: 500; line-height: 1.35; }

.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.ch-card { padding: 16px; display: flex; flex-direction: column; gap: 12px; cursor: pointer; transition: box-shadow .15s, transform .15s; }
.ch-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.ch-card .big { font-size: 22px; font-weight: 700; letter-spacing: -.02em; }

/* ================================================================ calendar */
.cal { overflow: hidden; }
.cal-head, .cal-body { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-head div { padding: 9px 10px; font-size: 12px; font-weight: 600; color: var(--muted); border-bottom: 1px solid var(--border); }
.cal-day { min-height: 124px; padding: 6px 6px 8px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); position: relative; cursor: pointer; transition: background .1s; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day:hover { background: color-mix(in srgb, var(--surface-2) 60%, transparent); }
.cal-day.other { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.cal-day.other .dn { color: var(--muted); }
.cal-day.today { background: var(--today); }
.cal-day.drop { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.cal-day .dn { display: flex; align-items: center; justify-content: space-between; font-size: 12px; font-weight: 600; margin-bottom: 4px; padding: 0 2px; }
.cal-day.today .dn > span:first-child { background: var(--accent); color: #fff; border-radius: 999px; min-width: 22px; text-align: center; padding: 1px 6px; }
.cal-day .plus { opacity: 0; color: var(--muted); display: inline-flex; }
.cal-day:hover .plus { opacity: 1; }
.chip {
  display: flex; align-items: center; gap: 5px; font-size: 11.5px; line-height: 1.3; padding: 3px 6px; margin-bottom: 3px; border-radius: 6px;
  background: color-mix(in srgb, var(--c) 13%, var(--surface)); color: var(--ink); cursor: pointer; overflow: hidden; white-space: nowrap;
  border-left: 3px solid var(--c);
}
.chip .t { overflow: hidden; text-overflow: ellipsis; }
.chip b { font-weight: 650; }
.chip svg.i { width: 11px; height: 11px; flex: none; color: var(--c); }
.chip.plan { background: var(--surface); border: 1px dashed color-mix(in srgb, var(--c) 70%, var(--border)); border-left: 3px solid var(--c); }
.chip.plan[draggable="true"] { cursor: grab; }
.chip.plan.done { opacity: .65; }
.chip.plan.done .t { text-decoration: line-through; }
.chip.due { background: transparent; color: var(--ink-2); border-left-style: dotted; }
.chip.due.overdue { color: var(--bad-ink); background: var(--bad-bg); }
.chip:hover { filter: brightness(.97); }
.chip .st { width: 6px; height: 6px; border-radius: 50%; flex: none; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-top: 12px; font-size: 12px; color: var(--ink-2); }
.legend > span { display: inline-flex; align-items: center; gap: 6px; }

.agenda-list .lrow { align-items: flex-start; }

/* ================================================================ timeline */
.tl-scroll { overflow-x: auto; }
table.tl { border-collapse: separate; border-spacing: 0; width: 100%; }
.tl th, .tl td { border-bottom: 1px solid var(--border); text-align: center; padding: 0; height: 46px; min-width: 24px; }
.tl thead th { font-size: 10.5px; color: var(--muted); font-weight: 500; height: 50px; line-height: 1.2; }
.tl thead th.mon { color: var(--ink-2); font-weight: 700; }
.tl .name { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; padding: 6px 14px; min-width: 230px; max-width: 250px; border-right: 1px solid var(--border); }
.tl .todaycol { background: var(--today); }
.tl .wkend { background: color-mix(in srgb, var(--surface-2) 55%, transparent); }
.tl td.cell { cursor: pointer; position: relative; }
.tl td.cell:hover { background: var(--surface-2); }
.mk { display: inline-block; width: 12px; height: 12px; border-radius: 50%; background: var(--c); vertical-align: middle; box-shadow: 0 0 0 2px var(--surface); }
.mk.short { width: 9px; height: 9px; border-radius: 2px; transform: rotate(45deg); }
.mk.plan { background: transparent; border: 2px solid var(--c); }
.mk.due { width: 8px; height: 8px; background: transparent; border: 2px dotted var(--c); }
.mk.overdue { background: var(--bad-bg); border: 2px solid var(--bad); width: 10px; height: 10px; }
.mk-n { position: absolute; top: 4px; right: 2px; font-size: 9px; font-weight: 700; color: var(--ink-2); }

/* ================================================================ overlays */
.overlay { position: fixed; inset: 0; z-index: 60; background: rgba(15, 23, 42, .38); display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 16px; overflow-y: auto; animation: fade .15s; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes slide { from { transform: translateX(30px); opacity: 0; } }
.modal { width: 100%; max-width: 560px; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); animation: pop .18s; }
.modal.wide { max-width: 760px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 16px 20px 6px; }
.modal-h h3 { margin: 0; font-size: 16px; font-weight: 700; flex: 1; letter-spacing: -.01em; }
.modal-b { padding: 12px 20px 18px; }
.modal-f { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 20px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--surface-2) 50%, var(--surface)); border-radius: 0 0 16px 16px; }

.drawer-ov { position: fixed; inset: 0; z-index: 50; background: rgba(15, 23, 42, .25); animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; z-index: 51; width: min(640px, 100vw); background: var(--surface); box-shadow: var(--shadow-lg); border-left: 1px solid var(--border); display: flex; flex-direction: column; animation: slide .2s; }
.drawer-h { padding: 18px 20px 0; border-bottom: 1px solid var(--border); }
.drawer-b { flex: 1; overflow-y: auto; padding: 18px 20px 30px; }
.utabs { display: flex; gap: 18px; margin-top: 14px; }
.utabs button { border: 0; background: none; padding: 8px 0 10px; cursor: pointer; color: var(--ink-2); font-weight: 500; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.utabs button.on { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.mini-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.mini-kpi { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.mini-kpi .l { font-size: 11.5px; color: var(--ink-2); }
.mini-kpi .v { font-size: 19px; font-weight: 700; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.mini-kpi .f { font-size: 11px; color: var(--muted); }
.sec-t { font-size: 13px; font-weight: 650; margin: 20px 0 10px; display: flex; align-items: center; gap: 8px; }
.callout { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: 10px; }
.callout svg.i { margin-top: 2px; }

.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { display: flex; align-items: center; gap: 12px; background: var(--primary); color: var(--primary-ink); padding: 10px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: 13px; animation: pop .18s; max-width: 90vw; }
.toast button { background: none; border: 0; color: inherit; font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; }

.popover { position: fixed; z-index: 70; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); padding: 6px; min-width: 200px; animation: pop .12s; max-height: 70vh; overflow-y: auto; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 10px; border-radius: 7px; border: 0; background: none; cursor: pointer; text-align: left; color: var(--ink); }
.menu-item:hover, .menu-item.sel { background: var(--surface-2); }
.menu-item.danger { color: var(--bad-ink); }
.menu-sep { height: 1px; background: var(--border); margin: 5px 2px; }

.palette { max-width: 600px; padding: 0; overflow: hidden; }
.palette input { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 16px 18px 16px 44px; font-size: 15px; box-shadow: none !important; }
.palette .input-icon svg { left: 16px; width: 18px; height: 18px; }
.palette-list { max-height: 50vh; overflow-y: auto; padding: 6px; }
.palette-group { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 10px 4px; }
.palette-foot { display: flex; gap: 14px; padding: 8px 14px; border-top: 1px solid var(--border); font-size: 11.5px; color: var(--muted); }

/* chart */
.chart { position: relative; }
.chart > svg { display: block; width: 100%; height: 190px; overflow: visible; }
.chart .gl { stroke: var(--border); stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 11px; }
.chart .ln { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .ar { fill: var(--accent); opacity: .08; }
.chart .cr { stroke: var(--border-strong); stroke-width: 1; }
.chart .hd { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.tip { position: absolute; pointer-events: none; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 8px; padding: 6px 10px; font-size: 12px; box-shadow: var(--shadow); white-space: nowrap; z-index: 5; }
.spark { display: block; overflow: visible; }
.spark path { fill: none; stroke: var(--accent); stroke-width: 1.75; stroke-linejoin: round; stroke-linecap: round; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 46px; }
.bars i { flex: 1; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 2px; opacity: .85; }
.bars i.zero { background: var(--surface-3); }

/* settings */
.settings-wrap { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.settings-nav { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 2px; }
.set-section { padding: 20px; }
.set-section h2 { margin: 0 0 4px; font-size: 16px; }
.set-section > p.desc { margin: 0 0 16px; color: var(--ink-2); font-size: 13px; }
.edit-list { display: flex; flex-direction: column; gap: 8px; }
.edit-row { display: flex; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.tone-pick { display: flex; gap: 4px; }
.tone-pick button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.tone-pick button.on { border-color: var(--ink); }
.codebox { position: relative; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 12px 44px 12px 14px; font: 12.5px/1.55 ui-monospace, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }
.codebox .btn { position: absolute; top: 8px; right: 8px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; }
.swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; box-shadow: inset 0 0 0 2px var(--surface); }
.swatch.on { border-color: var(--ink); }

.skeleton { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; }
@keyframes sk { to { background-position: -200% 0; } }

/* ================================================================ kho video */
.nav-item .count.info { background: var(--warn-bg); color: var(--warn-ink); }
.pill { display: inline-block; min-width: 18px; padding: 0 6px; border-radius: 999px; background: var(--warn-bg); color: var(--warn-ink); font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.tone-text-good { color: var(--good-ink); } .tone-text-warn { color: var(--warn-ink); } .tone-text-bad { color: var(--bad-ink); font-weight: 600; } .tone-text-neutral { color: var(--muted); }

.pipe-strip { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px; margin-bottom: 14px; }
.pipe { padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; cursor: pointer; border-top: 3px solid var(--c); }
.pipe:hover { box-shadow: var(--shadow); }
.pipe-n { display: flex; flex-wrap: wrap; gap: 2px 12px; font-size: 12px; color: var(--ink-2); }
.pipe-n span { white-space: nowrap; }
.pipe-n b { font-size: 15px; color: var(--ink); font-variant-numeric: tabular-nums; }

.kb { display: grid; grid-template-columns: repeat(5, minmax(220px, 1fr)); gap: 12px; align-items: start; overflow-x: auto; padding-bottom: 6px; }
.kb-col { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius); padding: 8px; min-height: 120px; transition: background .12s, border-color .12s; }
.kb-col.over, .dk-group.over { background: var(--accent-soft); border-color: var(--accent); }
.dk-group { border: 1px dashed transparent; border-radius: 10px; }
.kb-col > header { display: flex; align-items: center; gap: 7px; padding: 2px 4px 8px; font-size: 13px; }
.kb-list { display: flex; flex-direction: column; gap: 8px; }
.kb-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--c); border-radius: 10px; padding: 9px 10px; cursor: grab; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 5px; }
.kb-card:hover { border-color: var(--border-strong); border-left-color: var(--c); }
.kb-card.dragging { opacity: .45; }
.kb-ch { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--ink-2); font-weight: 600; }
.kb-title { font-weight: 600; font-size: 13.5px; line-height: 1.35; word-break: break-word; }
.kb-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 7px; font-size: 11.5px; color: var(--ink-2); }
.kb-meta .tag { font-size: 11px; padding: 0 6px; gap: 3px; }
.kb-when { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; font-variant-numeric: tabular-nums; }
.kb-when.today { color: var(--warn-ink); }
.kb-when.late { color: var(--bad-ink); }
.kb-when.wait { color: var(--warn-ink); font-weight: 500; }
.kb-ico { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 6px; border: 0; background: transparent; color: var(--ink-2); cursor: pointer; padding: 0; }
.kb-ico:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.kb-empty { color: var(--muted); font-size: 12px; text-align: center; padding: 14px 6px; border: 1px dashed var(--border-strong); border-radius: 10px; }
.prio { display: inline-flex; vertical-align: -2px; margin-right: 4px; }
.prio.p1 { color: var(--warn); } .prio.p2 { color: var(--bad); }

details.more { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: var(--surface-2); }
details.more > summary { cursor: pointer; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
details.more[open] { background: transparent; }

.sa-ch { padding: 12px 0; border-top: 1px solid var(--border); }
.sa-ch:first-child { border-top: 0; padding-top: 0; }
.prop-row { display: flex; align-items: center; gap: 12px; padding: 9px 10px; margin-top: 6px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--surface); }
.prop-row:hover { border-color: var(--border-strong); }
.prop-row input[type=checkbox] { width: 16px; height: 16px; flex: none; accent-color: var(--accent); }
.prop-date { display: flex; flex-direction: column; align-items: center; min-width: 64px; font-size: 11px; color: var(--muted); line-height: 1.3; text-align: center; }
.prop-date b { font-size: 12.5px; color: var(--ink); }
.mix-row .input[type=number] { text-align: center; }

/* thẻ số liệu bấm được */
a.kpi.click { color: inherit; text-decoration: none; transition: box-shadow .15s, transform .15s, border-color .15s; }
a.kpi.click:hover { box-shadow: var(--shadow); transform: translateY(-1px); border-color: var(--border-strong); }
/* hạn đăng gom 1 dòng/ngày */
.due-row { align-items: flex-start; gap: 10px; padding-top: 8px; padding-bottom: 8px; }
.due-lbl { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; padding-top: 4px; min-width: 70px; }
.due-chips { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; }
.due-chip { display: inline-flex; align-items: center; gap: 6px; padding: 3px 10px; border-radius: 999px; border: 1px dashed var(--border-strong); background: var(--surface); color: var(--ink-2); font-size: 12.5px; cursor: pointer; }
.due-chip:hover { border-style: solid; border-color: var(--accent); color: var(--ink); }
.due-chip.late { border-style: solid; border-color: color-mix(in srgb, var(--bad) 45%, transparent); background: var(--bad-bg); color: var(--bad-ink); }
.due-chip b { font-weight: 600; }
.chip.due-sum .dots { display: inline-flex; gap: 2px; }
.chip.due-sum .dots .dot { width: 7px; height: 7px; }
.lbl-short { display: none; }
.ai-card { border-left: 3px solid var(--accent); }
.ai-card .card-h h3 { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.ai-card .card-h { flex-wrap: nowrap; }
.ai-card .card-h .sub { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* màn laptop: bảng kênh bỏ ảnh thu nhỏ để giữ đủ cột "Hạn đăng tiếp" + thao tác trong khung */
@media (max-width: 1600px) {
  .tbl .last-vid .vthumb { display: none; }
  .tbl td.c-last { min-width: 170px; max-width: 220px; }
  .tbl td.c-content { min-width: 130px; max-width: 170px; }
  .tbl td.c-bkt .cell-select { max-width: 112px; }
  .tbl td.c-schedule { white-space: normal; max-width: 130px; }
  .tbl th, .tbl td { padding-left: 10px; padding-right: 10px; }
}
/* laptop nhỏ: ẩn cột Nhãn (vẫn lọc bằng ô "Nhãn" phía trên) để bảng vừa khung */
@media (max-width: 1400px) {
  .tbl .c-tags { display: none; }
  .tbl td.c-last { min-width: 150px; max-width: 180px; }
  .tbl th, .tbl td { padding-left: 8px; padding-right: 8px; }
}
.ai-text { font-size: 13.5px; line-height: 1.55; color: var(--ink); }
.ai-text p { margin: 0 0 8px; } .ai-text p:last-child { margin-bottom: 0; }
.ai-text ul { margin: 0 0 10px; padding-left: 18px; } .ai-text li { margin: 3px 0; }
.ai-text p > b:only-child { display: block; margin-top: 10px; font-size: 13px; color: var(--ink-2); text-transform: uppercase; letter-spacing: .02em; }
.ti-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.ti-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); }

/* ================================================================ trợ lý */
.chat-host { position: fixed; right: 20px; bottom: 20px; z-index: 45; }
.chat-fab { width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--primary); color: var(--primary-ink); box-shadow: var(--shadow-lg); cursor: pointer; display: grid; place-items: center; }
.chat-fab:hover { filter: brightness(1.15); }
.chat-panel { width: 400px; max-width: calc(100vw - 32px); height: min(620px, calc(100vh - 40px)); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: pop .18s; }
.chat-h { display: flex; align-items: center; gap: 8px; padding: 12px 12px 10px 16px; border-bottom: 1px solid var(--border); }
.chat-b { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.chat-hello { color: var(--ink-2); font-size: 13px; }
.chip-btn { text-align: left; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); border-radius: 10px; padding: 8px 10px; cursor: pointer; font-size: 13px; }
.chip-btn:hover { border-color: var(--accent); }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; word-break: break-word; }
.msg p { margin: 0 0 6px; } .msg p:last-child { margin-bottom: 0; }
.msg ul { margin: 2px 0 6px; padding-left: 18px; } .msg li { margin: 2px 0; }
.msg code { font-size: 12px; background: var(--surface-3); padding: 0 4px; border-radius: 4px; }
.msg.user { align-self: flex-end; background: var(--primary); color: var(--primary-ink); border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 4px; }
.msg .act { margin-top: 6px; font-size: 12px; color: var(--good-ink); display: flex; align-items: center; gap: 4px; }
.msg .act.bad { color: var(--bad-ink); }
.msg.typing { display: flex; gap: 4px; padding: 12px 14px; }
.msg.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.msg.typing span:nth-child(2) { animation-delay: .2s; } .msg.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.chat-f { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--border); }
.chat-f textarea { flex: 1; resize: none; min-height: 38px; max-height: 120px; }

/* ================================================================ responsive */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  /* thanh điều hướng dưới đáy */
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: auto; bottom: 0; left: 0; right: 0; height: auto; z-index: 40; flex-direction: row; gap: 0;
    padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--border);
    background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(12px);
  }
  .sidebar .brand, .sidebar .nav-sep, .sidebar .side-foot { display: none; }
  .sidebar > nav { flex-direction: row !important; flex: 4; gap: 0 !important; }
  .sidebar .nav-item {
    flex: 1; flex-direction: column; gap: 3px; font-size: 10.5px; padding: 7px 2px; min-height: 52px;
    align-items: center; justify-content: center; text-align: center; position: relative; line-height: 1.15; border-radius: 10px;
  }
  .sidebar .nav-item svg.i { width: 20px; height: 20px; }
  .sidebar .nav-item.active { background: transparent; color: var(--accent); }
  .sidebar .nav-item .count { position: absolute; top: 2px; left: calc(50% + 6px); margin: 0; padding: 0 5px; font-size: 10px; }
  .sidebar .nav-item .lbl { display: none; }
  .sidebar .nav-item .lbl-short { display: inline; white-space: nowrap; }

  .pagebar { padding: 10px 16px; gap: 6px; }
  .pagebar h1 { font-size: 19px; }
  .page { padding: 4px 16px calc(84px + env(safe-area-inset-bottom)); }
  .search-trigger { flex: none !important; min-width: 0; padding: 7px 9px; }
  .search-trigger span, .search-trigger kbd { display: none; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .mini-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .toasts { bottom: calc(76px + env(safe-area-inset-bottom)); width: calc(100% - 32px); }
  .chat-host { right: 14px; bottom: calc(72px + env(safe-area-inset-bottom)); }
  .chat-fab { width: 46px; height: 46px; }
  .toast { width: 100%; justify-content: space-between; }

  /* cài đặt */
  .settings-wrap { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .settings-nav { position: static; flex-direction: row; overflow-x: auto; gap: 6px; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
  .settings-nav::-webkit-scrollbar { display: none; }
  .settings-nav .nav-item { flex: none; width: auto; white-space: nowrap; border: 1px solid var(--border); background: var(--surface); border-radius: 999px; padding: 7px 12px; }
  .settings-nav .nav-item.active { background: var(--ink); color: var(--surface); border-color: var(--ink); }
  .settings-nav .nav-item.active svg { color: inherit; }
  .set-section { padding: 16px; }
  .edit-row { flex-wrap: wrap; }
  .edit-row .input { flex: 1 1 150px !important; min-width: 0 !important; width: auto !important; }
  .codebox { font-size: 11.5px; }
}
@media (max-width: 760px) {
  /* tránh iPhone tự phóng to khi chạm vào ô nhập */
  input, select, textarea, .input { font-size: 16px !important; }
  .switch input { font-size: inherit !important; }

  .toolbar { gap: 8px; }
  .toolbar > .input-icon { width: 100% !important; flex: 1 1 100%; }
  .toolbar > select.input { flex: 1; }
  .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .seg::-webkit-scrollbar { display: none; }
  .toolbar h2 { min-width: 0 !important; flex: 1; font-size: 16px !important; }

  /* hộp thoại dạng tấm trượt từ dưới lên */
  .overlay { align-items: flex-end; padding: 0; }
  .modal, .modal.wide { max-width: 100%; border-radius: 20px 20px 0 0; max-height: 94vh; display: flex; flex-direction: column; animation: sheet .22s ease-out; }
  .modal::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 4px; background: var(--border-strong); margin: 8px auto 0; flex: none; }
  .modal-b { overflow-y: auto; }
  .modal .seg[data-status] { display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .modal .seg[data-status] button { justify-content: flex-start; padding: 8px 10px; }
  .modal-f { border-radius: 0; padding-bottom: calc(12px + env(safe-area-inset-bottom)); flex-wrap: wrap; }
  .modal-f .btn { flex: 1; padding: 11px 12px; }
  .modal-f .btn.danger { flex: 0 0 auto; margin-right: auto; }
  .overlay:has(.palette) { align-items: flex-start; padding: 12px; }
  .palette { border-radius: 16px !important; }
  .palette::before { display: none !important; }

  /* ngăn chi tiết kênh */
  .drawer-h { padding: 14px 16px 0; }
  .drawer-b { padding: 14px 16px calc(24px + env(safe-area-inset-bottom)); }
  .drawer .avatar.lg { width: 44px; height: 44px; }
  .utabs { overflow-x: auto; scrollbar-width: none; gap: 16px; }
  .utabs::-webkit-scrollbar { display: none; }
  .utabs button { white-space: nowrap; }
  .callout { flex-wrap: wrap; }

  /* thẻ & danh sách */
  .cards-grid { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .ch-card { padding: 14px; gap: 10px; }
  .lrow { padding: 10px 14px; gap: 10px; }
  .card-h { flex-wrap: wrap; padding: 12px 14px 8px; }
  .kpi { padding: 12px 14px; }

  /* dòng thời gian */
  .tl .name { min-width: 118px; max-width: 128px; padding: 6px 8px; }
  .tl .name .avatar { display: none; }
  .tl .name .ch-name { font-size: 13px; }

  /* lịch dạng danh sách */
  .agenda-day { cursor: pointer; }

  /* kho video: các cột xếp dọc; điện thoại không kéo thả được → bấm thẻ để đổi trạng thái */
  .kb { grid-template-columns: minmax(0, 1fr); overflow: visible; }
  .kb-col { min-height: 0; }
  .pipe-strip { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 8px; margin: 0 -16px 12px; padding: 0 16px 4px; scrollbar-width: none; }
  .pipe-strip::-webkit-scrollbar { display: none; }
  .pipe-strip > .pipe { flex: 0 0 78%; scroll-snap-align: start; }
  .pipe-n { gap: 8px; flex-wrap: wrap; }
  .prop-row { flex-wrap: wrap; gap: 8px 10px; }
  .prop-row > .grow { flex: 1 1 calc(100% - 110px); }
  .prop-row input[type=time] { margin-left: 26px; }
  .chat-host:has(.chat-panel) { inset: 0; right: 0; bottom: 0; }
  .chat-panel { width: 100%; max-width: 100%; height: 100%; border-radius: 0; border: 0; }
  .chat-h { padding-top: calc(12px + env(safe-area-inset-top)); }
  .chat-f { padding-bottom: calc(10px + env(safe-area-inset-bottom)); }
}
@keyframes sheet { from { transform: translateY(40px); opacity: 0; } }
@media (max-width: 560px) {
  .hide-xs { display: none; }
  .kho-row { flex-wrap: wrap; row-gap: 6px; }
  .kho-row > .grow { flex: 1 1 calc(100% - 40px); }
  .kho-row > .badge { margin-left: 38px; }
  .lrow svg.spark { display: none; }
  .due-lbl { min-width: 0; }
  .due-row { flex-direction: column; gap: 6px; }
  .kpis { gap: 10px; }
  .kpi .value { font-size: 22px; }
  .kpi .label { font-size: 12px; }
  .pagebar .hide-sm { display: none; }
  .pagebar .btn { padding: 8px; }
}
/* màn hình cảm ứng: không có rê chuột → luôn hiện các nút ẩn */
@media (hover: none) {
  .btn.sm { min-height: 34px; }
  .btn.icon { min-width: 36px; min-height: 36px; justify-content: center; }
  .row-actions { opacity: 1; }
  .grip { display: none; }
  .cal-day .plus { opacity: 1; }
  .ch-card:hover { transform: none; }
}

/* ================================================================ hộp thư bình luận */
.cm-chans { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin-bottom: 12px; padding-bottom: 2px; }
.cm-chans::-webkit-scrollbar { display: none; }
.cm-chans .fchip b { font-weight: 650; font-variant-numeric: tabular-nums; }
.cm-activity { margin-bottom: 12px; }
.cm-bulk {
  position: sticky; top: 58px; z-index: 5; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; margin-bottom: 12px; border: 1px solid var(--border); border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(10px); box-shadow: var(--shadow-sm);
}
.cm-list { display: flex; flex-direction: column; gap: 10px; }
.cm { padding: 12px 14px; border-left: 3px solid var(--c); }
.cm.selected { box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-sm); border-color: var(--accent); border-left-color: var(--c); }
.cm-head { display: flex; align-items: center; gap: 8px; min-width: 0; margin-bottom: 8px; font-size: 12.5px; }
.cm-head .tag, .cm-head .badge { flex: none; }
.cm-chname { flex: 0 1 auto; max-width: 180px; }
.cm-video { flex: 0 1 auto; min-width: 0; color: var(--ink-2); }
.cm-sel { width: 16px; height: 16px; margin: 0; flex: none; cursor: pointer; accent-color: var(--accent); }
.cm-body { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 16px; }
.cm-left, .cm-right { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.cm-author { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 13px; }
.cm-author .avatar { box-shadow: none; }
.cm-text { white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; }
.cm-vi { white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface-2); border-radius: var(--radius-sm); padding: 8px 10px; color: var(--ink-2); font-size: 13px; }
.cm-vi .cm-lbl { display: block; margin-bottom: 2px; }
.cm-lbl { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: none; }
.cm-ta { min-height: 0 !important; resize: vertical; line-height: 1.5; }
.cm-out { border-color: var(--border-strong); }
.cm-mid { gap: 8px; }
.cm-hint .input { flex: 1; min-width: 0; padding-top: 5px; padding-bottom: 5px; font-size: 12.5px; }
.cm-actions { gap: 4px; flex-wrap: wrap; }
.cm-done { justify-content: flex-start; background: var(--surface-2); border-radius: var(--radius-sm); padding: 10px 12px; }
.yt-row .avatar { flex: none; }
.yt-guide { white-space: pre-wrap; }
.qbar { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.qbar i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }
.steps { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; color: var(--ink-2); }
@media (max-width: 900px) {
  .cm-bulk { top: 0; }
}
@media (max-width: 760px) {
  .cm-body { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .cm { padding: 12px; }
  .cm-head { flex-wrap: wrap; }
  .cm-video { flex-basis: 100%; order: 9; }
  .cm-bulk { position: static; }
  .cm-bulk .btn { flex: 1; }
}
