/* ===================================================================== tokens */
:root {
  --bg: #f3f4f8; --surface: #ffffff; --surface-2: #f1f3f7; --surface-3: #e8ebf1; --border: #e1e4ec;
  --text: #171a21; --muted: #6b7280; --accent: #5145e5; --accent-2: #7c3aed; --accent-soft: #eef0ff;
  --ok: #15803d; --ok-soft: #dcfce7; --warn: #b45309; --warn-soft: #fef3c7;
  --bad: #b91c1c; --bad-soft: #fee2e2; --run: #0369a1; --run-soft: #e0f2fe;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 10px 30px -12px rgba(16, 24, 40, .28);
  --radius: 14px;
  /* posting status colors (library cards) */
  --st-pending: #f59e0b; --st-posted: #16a34a; --st-not_posted: #3b82f6; --st-skipped: #9ca3af; --st-error: #dc2626;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1015; --surface: #171a21; --surface-2: #1e222b; --surface-3: #262b36; --border: #2a2f3a;
    --text: #e8eaf0; --muted: #9aa1ad; --accent: #8b85ff; --accent-2: #a78bfa; --accent-soft: #23214a;
    --ok: #4ade80; --ok-soft: #13301f; --warn: #fbbf24; --warn-soft: #362a10;
    --bad: #f87171; --bad-soft: #3a1717; --run: #38bdf8; --run-soft: #10283a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4); --shadow-lg: 0 14px 34px -14px rgba(0, 0, 0, .7);
  }
}

/* ===================================================================== base */
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
h1 { margin: 2px 0; font-size: 21px; letter-spacing: -.01em; }
h2 { margin: 0 0 12px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); } .small { font-size: 12px; } .hidden { display: none !important; }
.eyebrow { font-size: 11px; letter-spacing: .14em; color: var(--accent); font-weight: 700; }
code { background: var(--surface-2); padding: 0 4px; border-radius: 4px; font-size: 12px; }

button { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); padding: 7px 14px; transition: background .15s, border-color .15s, box-shadow .15s; }
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: #fff; font-weight: 600;
  box-shadow: 0 4px 14px -6px var(--accent); }
button.primary:hover:not(:disabled) { filter: brightness(1.06); }
button.danger { color: var(--bad); }
button.danger:hover:not(:disabled) { border-color: var(--bad); background: var(--bad-soft); }
button.ghost { background: transparent; }
button.link { border: 0; background: none; padding: 2px 4px; color: var(--accent); font-size: 12px; box-shadow: none; }
button.link:hover { text-decoration: underline; }
input, select, textarea { font: inherit; font-size: 13px; color: var(--text); background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 9px; padding: 7px 10px; width: 100%; transition: border-color .15s, box-shadow .15s; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); background: var(--surface); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
textarea { resize: vertical; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.pill { padding: 4px 11px; border-radius: 99px; background: var(--surface-2); font-size: 12px; font-weight: 600; }
.pill.running { background: var(--run-soft); color: var(--run); }
.tag { font-size: 11px; padding: 2px 8px; border-radius: 99px; font-weight: 600; white-space: nowrap; }
.tag.ok { background: var(--ok-soft); color: var(--ok); }
.tag.bad { background: var(--bad-soft); color: var(--bad); }
.tag.warn { background: var(--warn-soft); color: var(--warn); }
.tag.run { background: var(--run-soft); color: var(--run); }
.tag.idle { background: var(--surface-2); color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }
.toast { position: fixed; bottom: 18px; right: 18px; background: var(--text); color: var(--bg); padding: 11px 16px;
  border-radius: 11px; max-width: 420px; z-index: 30; font-size: 13px; box-shadow: var(--shadow-lg); }

/* ===================================================================== top bar */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 14px 20px; flex-wrap: wrap;
  padding: 14px 24px 12px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 10; }
.topbar p { margin: 0; font-size: 12px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.topbar-right { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; margin-left: auto; }
.view-tabs { display: inline-flex; gap: 4px; margin-top: 10px; padding: 4px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 12px; }
.view-tab { padding: 6px 16px; border-radius: 9px; font-weight: 600; font-size: 13px; border: 0; background: transparent; color: var(--muted); }
.view-tab:hover:not(:disabled) { color: var(--text); }
.view-tab.active { background: var(--surface); color: var(--accent); box-shadow: var(--shadow); }
.badge { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 99px; font-size: 11px; line-height: 18px;
  text-align: center; background: var(--st-pending); color: #fff; margin-left: 6px; }
.user-menu { display: flex; gap: 4px; align-items: center; font-size: 12px; padding: 4px 6px 4px 10px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 99px; }
.pwd-dialog { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text);
  padding: 20px; width: min(380px, calc(100vw - 32px)); box-shadow: var(--shadow-lg); }
.pwd-dialog::backdrop { background: rgba(10, 12, 20, .5); backdrop-filter: blur(2px); }

/* ===================================================================== production view */
.layout { display: grid; grid-template-columns: 380px 1fr; gap: 18px; padding: 18px 24px; align-items: start; }
@media (max-width: 980px) { .layout { grid-template-columns: 1fr; padding: 14px 16px; } }
.side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: calc(var(--topbar-h, 112px) + 12px); max-height: calc(100vh - var(--topbar-h, 112px) - 24px);
  overflow: auto; padding-right: 2px; }
@media (max-width: 980px) { .side { position: static; max-height: none; } }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; font-size: 12px; font-weight: 700; }
.seg { display: flex; gap: 14px; margin: 6px 0 10px; }
.row, .row-between { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.row-between { justify-content: space-between; }
.form { display: flex; flex-direction: column; gap: 10px; }
.form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; }
.form label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 10px;
  max-height: 360px; overflow: auto; padding: 2px; }
.product { position: relative; border: 2px solid transparent; border-radius: 12px; overflow: hidden;
  cursor: pointer; background: var(--surface-2); box-shadow: var(--shadow); transition: transform .12s, border-color .12s; }
.product:hover { transform: translateY(-1px); }
.product.selected { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.product img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.product .pname { font-size: 11px; padding: 5px 7px; word-break: break-word; line-height: 1.3; }
.product input { position: absolute; top: 7px; left: 7px; }
.account-list { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.account { display: flex; justify-content: space-between; align-items: center; font-size: 12px; padding: 7px 10px;
  border-radius: 9px; background: var(--surface-2); }
.assign { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 2px; }
.advanced { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 4px; }
.advanced summary { cursor: pointer; font-size: 13px; margin: 8px 0; color: var(--accent); font-weight: 600; }

.board { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.workers { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.worker { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
  font-size: 12px; box-shadow: var(--shadow); }
.worker strong { font-size: 13px; }
.summary { display: flex; gap: 10px; flex-wrap: wrap; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 16px;
  min-width: 110px; box-shadow: var(--shadow); font-size: 12px; color: var(--muted); }
.stat b { font-size: 22px; display: block; color: var(--text); line-height: 1.2; }
.products { display: flex; flex-direction: column; gap: 14px; }
.pcard { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.phead { display: flex; justify-content: space-between; gap: 8px; align-items: center; flex-wrap: wrap; }
.phead h3 { margin: 0; font-size: 15px; }
.pmsg { font-size: 12px; color: var(--muted); margin: 4px 0 8px; }
.variant { border-top: 1px dashed var(--border); padding: 12px 0 6px; }
.vhead { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.vtitle { font-weight: 600; font-size: 13px; }
.steps { display: flex; gap: 4px; margin: 8px 0; flex-wrap: wrap; }
.stp { font-size: 11px; padding: 3px 10px; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.stp.done { background: var(--ok-soft); color: var(--ok); }
.stp.active { background: var(--run-soft); color: var(--run); font-weight: 600; }
.stp.fail { background: var(--bad-soft); color: var(--bad); }
.vmsg { font-size: 12px; }
.verror { font-size: 12px; color: var(--bad); white-space: pre-wrap; margin: 4px 0; }
.bar { height: 6px; background: var(--surface-2); border-radius: 9px; overflow: hidden; margin: 8px 0; }
.bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }
.thumbs { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0; }
.thumbs a img { width: 64px; aspect-ratio: 9 / 16; height: auto; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: block; }
.thumbs .ph { width: 64px; aspect-ratio: 9 / 16; border-radius: 8px; border: 1px dashed var(--border);
  display: grid; place-items: center; color: var(--muted); font-size: 10px; }
/* Videos are vertical 9:16 from the start (no square placeholder before playing). */
video { aspect-ratio: 9 / 16; width: 220px; max-width: 100%; height: auto; border-radius: 10px; background: #000;
  display: block; margin: 8px 0; object-fit: contain; }
details.log summary { font-size: 12px; color: var(--muted); cursor: pointer; }
details.log pre { font-size: 11px; white-space: pre-wrap; background: var(--surface-2); padding: 9px; border-radius: 9px;
  max-height: 220px; overflow: auto; margin: 4px 0; }

/* ===================================================================== video library */
.library { padding: 18px 24px; display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 700px) { .library { padding: 14px 12px; } }
.lib-toolbar { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.lib-toolbar label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); font-weight: 500; min-width: 150px; }
.lib-toolbar label.grow { flex: 1; min-width: 220px; }
.lib-day { display: flex; flex-direction: column; gap: 12px; margin-bottom: 10px; }
.lib-day-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 4px 2px 6px;
  border-bottom: 2px solid var(--border); position: sticky; top: var(--topbar-h, 112px); background: var(--bg); z-index: 2; }
.lib-day-head h2 { margin: 0; font-size: 17px; }
.lib-day-head span { font-size: 12px; color: var(--muted); }
.lib-product { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px 14px; box-shadow: var(--shadow); }
.lib-product-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.lib-product-head h3 { margin: 0; font-size: 14px; }
.lib-product-head .count { font-size: 12px; color: var(--muted); }
.lib-row { display: flex; flex-wrap: wrap; gap: 14px; }

.lib-card { width: 232px; background: var(--surface); border: 1px solid var(--border); border-top: 4px solid var(--st-color, var(--border));
  border-radius: 14px; display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s; }
.lib-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.lib-card.s-pending { --st-color: var(--st-pending); }
.lib-card.s-posted { --st-color: var(--st-posted); }
.lib-card.s-not_posted { --st-color: var(--st-not_posted); }
.lib-card.s-skipped { --st-color: var(--st-skipped); }
.lib-card.s-error { --st-color: var(--st-error); box-shadow: 0 0 0 1px var(--st-error), var(--shadow); }
.lib-card { border-color: color-mix(in srgb, var(--st-color, var(--border)) 45%, var(--border)); }
.lib-thumb { position: relative; aspect-ratio: 9 / 16; background: #0b0d12; }
.lib-thumb video { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border-radius: 0; aspect-ratio: auto; object-fit: cover; }
.lib-thumb .nofile { position: absolute; inset: 0; display: grid; place-items: center; color: #9aa1ad; font-size: 12px; text-align: center; padding: 12px; }
.lib-status { position: absolute; top: 8px; left: 8px; z-index: 1; font-size: 11px; font-weight: 700; color: #fff;
  background: var(--st-color); padding: 2px 9px; border-radius: 99px; box-shadow: 0 2px 6px rgba(0, 0, 0, .3); pointer-events: none; }
.lib-dl { position: absolute; top: 8px; right: 8px; z-index: 1; font-size: 11px; color: #fff; background: rgba(0, 0, 0, .55);
  padding: 2px 8px; border-radius: 99px; pointer-events: none; }
.lib-body { padding: 10px 12px 4px; display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.lib-title { font-size: 13px; font-weight: 600; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-meta { font-size: 11px; color: var(--muted); }
.lib-caption { font-size: 12px; white-space: pre-wrap; color: var(--text); background: var(--surface-2); border-radius: 9px; padding: 7px 9px;
  display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; cursor: pointer; }
.lib-caption.open { -webkit-line-clamp: unset; display: block; }
.lib-caption.none { color: var(--muted); font-style: italic; cursor: default; }
.lib-tags { font-size: 11px; color: var(--accent); word-break: break-word; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-foot { padding: 8px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.lib-foot select { font-weight: 600; border-color: color-mix(in srgb, var(--st-color) 55%, var(--border)); }
.lib-btns { display: grid; grid-template-columns: 1fr auto auto; gap: 6px; }
.lib-btns button { padding: 6px 8px; font-size: 12px; }
.st-error { color: var(--st-error); } .st-pending { color: var(--st-pending); } .st-posted { color: var(--st-posted); } .st-not_posted { color: var(--st-not_posted); } .st-skipped { color: var(--st-skipped); }
.stat.st { border-top: 3px solid var(--st-color); }
.stat.s-pending { --st-color: var(--st-pending); } .stat.s-posted { --st-color: var(--st-posted); }
.stat.s-not_posted { --st-color: var(--st-not_posted); } .stat.s-skipped { --st-color: var(--st-skipped); }
.stat.s-error { --st-color: var(--st-error); }
@media (max-width: 560px) { .lib-card { width: calc(50% - 7px); } .lib-btns { grid-template-columns: 1fr 1fr; } }

/* ===================================================================== login page */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 22%, transparent), transparent),
              radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--accent-2) 20%, transparent), transparent), var(--bg); }
.login-box { width: 100%; max-width: 400px; padding: 30px 28px 26px; border-radius: 20px; box-shadow: var(--shadow-lg); }
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-logo { width: 44px; height: 44px; border-radius: 13px; display: grid; place-items: center; font-size: 22px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 8px 20px -8px var(--accent); }
.login-box h1 { margin: 0; font-size: 22px; }
.login-box .form { gap: 14px; margin-top: 6px; }
.login-box input { padding: 10px 12px; font-size: 14px; }
.login-box button.primary { margin-top: 4px; padding: 11px; font-size: 14px; }
.login-foot { margin-top: 16px; text-align: center; font-size: 11px; color: var(--muted); }

/* ===================================================================== error reason on cards */
.lib-error { font-size: 12px; color: var(--bad); background: var(--bad-soft); border: 1px solid color-mix(in srgb, var(--st-error) 35%, transparent);
  border-radius: 9px; padding: 7px 9px; white-space: pre-wrap; cursor: pointer; }
.lib-error b { display: block; font-size: 11px; margin-bottom: 2px; }

/* ===================================================================== dialogs */
.modal { border: 1px solid var(--border); border-radius: 18px; background: var(--surface); color: var(--text);
  padding: 0; width: min(460px, calc(100vw - 24px)); max-height: calc(100vh - 40px); box-shadow: var(--shadow-lg); }
.modal.wide { width: min(820px, calc(100vw - 24px)); }
.modal::backdrop { background: rgba(10, 12, 20, .55); backdrop-filter: blur(3px); }
.modal-body { display: flex; flex-direction: column; gap: 12px; padding: 20px 22px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 4px; }
.modal-foot .muted { margin-right: auto; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
.field.inline { flex-direction: row; align-items: center; gap: 8px; }
.field.inline select { width: auto; }
button.danger-solid { background: var(--st-error); border-color: var(--st-error); color: #fff; font-weight: 600; }
button.danger-solid:hover:not(:disabled) { filter: brightness(1.08); border-color: var(--st-error); }
button.link.strong { font-weight: 700; }
.link-like { color: var(--accent); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 5px 11px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); }
.chip:hover:not(:disabled) { border-color: var(--st-error); color: var(--st-error); }
.chip.on { background: var(--bad-soft); border-color: var(--st-error); color: var(--st-error); font-weight: 600; }
.log-view { background: var(--surface-2); border-radius: 12px; padding: 14px; font-size: 12px; line-height: 1.55; white-space: pre-wrap;
  max-height: 60vh; overflow: auto; margin: 0; font-family: Consolas, "Cascadia Mono", monospace; }

/* ===================================================================== product photos */
.dropzone { border: 2px dashed var(--border); border-radius: 14px; padding: 18px; text-align: center; cursor: pointer;
  background: var(--surface-2); transition: border-color .15s, background .15s; display: flex; flex-direction: column; gap: 4px; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 10px; }
.photo-grid:empty { display: none; }
.photo { position: relative; border-radius: 12px; overflow: hidden; background: var(--surface-2); border: 2px solid transparent; box-shadow: var(--shadow); }
.photo.main { border-color: var(--st-pending); }
.photo img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.photo .photo-name { font-size: 11px; padding: 4px 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.photo .photo-tag { position: absolute; top: 6px; left: 6px; font-size: 10px; font-weight: 700; color: #fff; background: var(--st-pending);
  padding: 1px 7px; border-radius: 99px; }
.photo .photo-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; }
.photo .photo-actions button { padding: 2px 7px; font-size: 12px; border-radius: 8px; background: rgba(255, 255, 255, .92); color: #111; border: 0; }
.photo.pending img { opacity: .8; }
.product-edit { position: absolute; top: 6px; right: 6px; padding: 1px 8px; font-size: 12px; border-radius: 8px;
  background: rgba(255, 255, 255, .92); color: #111; border: 0; box-shadow: var(--shadow); }

/* product picker header: count on the left, actions wrap neatly on the right */
#manualBox > .row-between { align-items: flex-start; }
#selCount { white-space: nowrap; padding-top: 2px; }
#manualBox > .row-between > span { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 2px 6px; }

/* ---- production: task list (history, click a task to open / close it) */
.board-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.board-head h2 { margin: 0; font-size: 16px; }
.board-head .link { margin-left: auto; }
.task-list { display: flex; flex-direction: column; gap: 12px; }
.task { background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.task.running { border-left-color: var(--run); }
.task.open { box-shadow: var(--shadow-lg, var(--shadow)); }
.task-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; cursor: pointer; user-select: none; }
.task-head:hover { background: var(--surface-2); }
.task-head:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.task-head .caret { font-size: 20px; line-height: 1; color: var(--accent); width: 18px; flex: none; text-align: center; }
.task-main { flex: 1; min-width: 0; }
.task-title { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 14px; }
.task-meta { margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar.thin { height: 4px; margin: 7px 0 0; max-width: 420px; }
.task-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; flex: none; }
.small-btn { padding: 5px 10px; font-size: 12px; }
a.button-like { display: inline-flex; align-items: center; border: 1px solid var(--border); border-radius: 10px;
  color: var(--text); text-decoration: none; }
a.button-like:hover { border-color: var(--accent); text-decoration: none; }
.task-body { border-top: 1px solid var(--border); padding: 14px 16px; display: flex; flex-direction: column; gap: 14px;
  background: color-mix(in srgb, var(--bg) 55%, var(--surface)); }
.task-top { display: flex; flex-direction: column; gap: 10px; }
#taskMore { align-self: center; }
@media (max-width: 720px) {
  .task-head { flex-wrap: wrap; padding: 10px 12px; }
  .task-actions { width: 100%; justify-content: flex-start; padding-left: 26px; }
  .task-meta { white-space: normal; }
}

/* ---- user menu: inline on desktop, a 👤 dropdown on phones */
.user-toggle { border: 0; background: none; padding: 0 4px 0 0; box-shadow: none; color: var(--muted); font-size: 12px; cursor: default; }
.user-toggle b { color: var(--text); }
.user-links { display: flex; gap: 4px; align-items: center; }

/* ---- phones: one compact sticky row (tabs + 👤), main action as a floating button */
@media (max-width: 720px) {
  /* no backdrop-filter here: it would pin the fixed "Tạo task" button to the header */
  .topbar { flex-wrap: nowrap; align-items: center; gap: 8px; padding: 8px 12px; backdrop-filter: none; background: var(--surface); }
  .topbar .eyebrow, .topbar h1, .topbar > div > p { display: none; }
  .topbar > div:first-child { min-width: 0; }
  .view-tabs { margin-top: 0; }
  .view-tab { padding: 7px 11px; white-space: nowrap; }
  .hide-sm { display: none; }
  .topbar-right { flex-direction: row; align-items: center; gap: 8px; margin-left: auto; }
  .user-menu { position: relative; padding: 0; background: none; border: 0; }
  .user-toggle { cursor: pointer; display: inline-flex; align-items: center; gap: 4px; padding: 7px 10px; font-size: 13px;
    border: 1px solid var(--border); border-radius: 99px; background: var(--surface-2); max-width: 130px; }
  .user-toggle b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .user-links { display: none; position: absolute; right: 0; top: calc(100% + 8px); z-index: 20; min-width: 170px;
    flex-direction: column; align-items: stretch; gap: 2px; padding: 6px; background: var(--surface);
    border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg, var(--shadow)); }
  .user-menu.open .user-links { display: flex; }
  .user-links .link { font-size: 14px; padding: 10px 12px; text-align: left; border-radius: 8px; }
  .user-links .link:hover { background: var(--surface-2); text-decoration: none; }
  /* "Tạo task & chạy" floats bottom-right so it stays reachable without a tall header */
  .top-actions { position: fixed; right: 14px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 15; }
  .top-actions .pill { display: none; }
  .top-actions .primary { padding: 13px 20px; border-radius: 99px; font-size: 15px; box-shadow: 0 10px 28px -8px var(--accent); }
  .layout { padding-bottom: 90px; }
  .toast { left: 12px; right: 12px; bottom: 80px; max-width: none; }
  .lib-day-head h2 { font-size: 15px; }
}
@media (max-width: 720px) {
  .lib-toolbar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; padding: 12px; }
  .lib-toolbar label, .lib-toolbar label.grow { min-width: 0; }
  .lib-toolbar > label:nth-child(3), .lib-toolbar label.grow { grid-column: 1 / -1; }
  .lib-toolbar select, .lib-toolbar input { width: 100%; }
  .summary { gap: 8px; }
  .stat { padding: 8px 12px; min-width: 0; flex: 1 1 calc(33% - 8px); }
  .stat b { font-size: 18px; }
}

/* ---- poster + ▶ (the video loads only when played) */
.player { position: relative; display: block; overflow: hidden; background: #0b0d12; cursor: pointer; }
.player img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.player video { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; border-radius: 0; aspect-ratio: auto; object-fit: contain; background: #000; }
.player .play-btn { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 54px; height: 54px;
  border-radius: 50%; display: grid; place-items: center; padding-left: 4px; font-size: 22px; color: #fff;
  background: rgba(15, 17, 26, .55); border: 2px solid rgba(255, 255, 255, .85); backdrop-filter: blur(4px);
  transition: transform .15s, background .15s; pointer-events: none; }
.player:hover .play-btn, .player:focus-visible .play-btn { transform: translate(-50%, -50%) scale(1.08); background: rgba(81, 69, 229, .8); }
.player.playing { cursor: default; }
.lib-thumb .player { position: absolute; inset: 0; }
.task-player { aspect-ratio: 9 / 16; width: 220px; max-width: 100%; border-radius: 10px; margin: 8px 0 4px; }
