/* MOBILE-SHELL-2026-10-23: vỏ điện thoại kiểu ClickUp — chỉ ≤768px, desktop không đổi */
.ms-tabbar, .ms-fab { display: none; }

@media (max-width: 768px) {
  :root.ms-on { --ms-bar: calc(58px + env(safe-area-inset-bottom, 0px)); }

  /* ---- thanh tab đáy ---- */
  .ms-on .ms-tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 900;
    height: var(--ms-bar); padding: 0 4px env(safe-area-inset-bottom, 0px);
    background: color-mix(in oklch, var(--surface-1, #0b0d10) 88%, transparent);
    backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4);
    border-top: 1px solid var(--border-subtle);
  }
  .ms-tab {
    position: relative; flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    background: none; border: 0; padding: 0; color: var(--fg-muted, #8a93a0); font-size: 0.68rem; font-weight: 600; letter-spacing: 0.01em; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  .ms-tab[hidden] { display: none; }
  .ms-tab svg { width: 22px; height: 22px; }
  .ms-tab span { white-space: nowrap; }
  .ms-tab.is-active { color: var(--brand-primary); }
  .ms-tab.is-active::before {
    content: ""; position: absolute; top: 0; left: 30%; right: 30%; height: 3px; border-radius: 0 0 3px 3px; background: var(--brand-primary);
  }
  .ms-badge {
    position: absolute; top: 5px; left: calc(50% + 4px); min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
    background: var(--brand-danger, #ef4444); color: #fff; font: 700 0.62rem/17px system-ui, sans-serif; font-style: normal; text-align: center;
  }
  .ms-badge[hidden] { display: none; }

  /* ---- nút tạo nổi ---- */
  .ms-on .ms-fab {
    display: grid; place-items: center; position: fixed; right: 16px; bottom: calc(var(--ms-bar) + 16px); z-index: 901;
    width: 56px; height: 56px; border-radius: 18px; border: 0; cursor: pointer; color: #fff;
    background: var(--brand-primary); box-shadow: 0 10px 28px -8px color-mix(in oklch, var(--brand-primary) 70%, transparent), 0 2px 6px rgb(0 0 0 / 0.35);
  }
  .ms-on .ms-fab[hidden] { display: none; }
  .ms-fab svg { width: 26px; height: 26px; }
  .ms-fab:active { transform: scale(0.94); }

  /* đang mở modal (chi tiết dự án, annotator, đăng nhập…) → ẩn thanh tab + FAB */
  .ms-on body:has(.modal.is-open) .ms-tabbar,
  .ms-on body:has(.modal.is-open) .ms-fab,
  .ms-on body:has(#view-tasks .tv3-drawer-wrap.open) .ms-fab,
  .ms-on body:has(#topbar-bell-dd:not([hidden])) .ms-fab,
  .ms-on body:has(#mob-sidebar.is-open) .ms-fab { display: none; }

  /* ---- topbar gọn: menu nằm ở tab "Thêm", tạo mới ở FAB ---- */
  .ms-on .workspace { padding-bottom: calc(var(--ms-bar) + 24px); }
  .ms-on #mob-sidebar-toggle { display: none; }
  .ms-on #view-tasks > .tv3 .tv3-head-act [data-act="new"],
  .ms-on #view-tasks > .tv3 .tv3-head-act [data-act="new-project"] { display: none; }
  .ms-on #view-tasks > .tv3 .tv3-head-act:not(:has(> :not([data-act="new"]):not([data-act="new-project"]))) { display: none; }
  .ms-on #view-tasks > .tv3 .tv3-head { gap: var(--s-2); padding-bottom: var(--s-2); }
  .ms-on #view-tasks .tv3-head h2 { font-size: 1.35rem; }
  .ms-on #view-tasks .tv3-burger { min-width: 40px; min-height: 40px; }

  /* thông báo: dropdown → sheet đáy */
  .ms-on #topbar-bell-dd {
    position: fixed; left: 8px; right: 8px; top: auto; bottom: calc(var(--ms-bar) + 8px); width: auto; max-height: 70vh; overflow: auto; z-index: 905;
    border-radius: 18px;
  }

  /* ---- Công việc: bộ lọc thành hàng chip cuộn ngang ---- */
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-tabs { overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-tabs::-webkit-scrollbar { display: none; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-tools {
    display: flex; flex-wrap: nowrap; gap: 8px; overflow-x: auto; scrollbar-width: none; padding: 2px 0 var(--s-2); margin: 0;
  }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-tools::-webkit-scrollbar { display: none; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-tools > label {
    flex: none; display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 12px; border-radius: 17px; white-space: nowrap;
    border: 1px solid var(--border-subtle); background: var(--surface-glass-2); font-size: 0.8rem; color: var(--fg-secondary);
  }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-tools select {
    height: 30px; min-height: 0; border: 0; background: none; color: var(--fg-primary); font-weight: 600; font-size: 0.8rem; padding: 0 2px; max-width: 9.5rem;
  }

  /* ---- dòng việc kiểu ClickUp: [○ tên ………… avatar ▶] / [trạng thái · hạn · ưu tiên] ---- */
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-table-wrap { padding: 0; overflow: visible; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row {
    grid-template-columns: auto auto auto minmax(0, 1fr) auto auto; grid-template-rows: auto auto;
    align-items: center; gap: 3px 10px; padding: 10px 12px; min-height: 0;
  }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row td { display: block; line-height: 1.25; min-height: 0; height: auto; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row :is(.c-n, .c-rem) { display: none; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row .c-title { grid-column: 1 / 5; grid-row: 1; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row .c-title .tv3-title-cell { display: flex; align-items: center; gap: 10px; min-width: 0; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row .c-title .tv3-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row .tv3-row-proj { display: block; margin: 1px 0 0 30px; font-size: 0.72rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row .c-st { grid-column: 1; grid-row: 2; padding-left: 30px !important; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row .c-due { grid-column: 2; grid-row: 2; font-size: 0.75rem; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row .c-pr { grid-column: 3; grid-row: 2; font-size: 0.75rem; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row .c-due:has(.tv3-muted), .ms-on :is(#view-tasks, #tv3-embed) .tv3-row .c-pr:has(.tv3-muted) { display: none; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row .c-who { grid-column: 5; grid-row: 1 / 3; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row .c-act { grid-column: 6; grid-row: 1 / 3; width: auto; padding: 0; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row .c-act:empty { display: none; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row .tv3-pill { font-size: 0.66rem; padding: 1px 7px; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row .tv3-done { width: 20px; height: 20px; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-row.sub { padding-left: 28px; }
  .ms-on :is(#view-tasks, #tv3-embed) .tv3-group-h td { padding: 12px 12px 6px; }

  /* ---- chi tiết dự án: header + tab dính, 1 dòng tiêu đề, tab cuộn ngang ---- */
  .ms-on #project-detail-modal .detail-sheet { border-radius: 0; height: 100dvh; max-height: none; }
  .ms-on #project-detail-modal .detail-head {
    position: sticky; top: 0; z-index: 5; align-items: center; gap: 10px; padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top, 0px));
  }
  .ms-on #project-detail-modal .detail-title { font-size: 1.12rem; line-height: 1.25; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .ms-on #project-detail-modal .detail-head-main { min-width: 0; }
  .ms-on #project-detail-modal .detail-head-sub { overflow-x: auto; scrollbar-width: none; flex-wrap: nowrap; white-space: nowrap; }
  .ms-on #project-detail-modal .detail-tabs {
    position: sticky; top: 0; z-index: 4; display: flex; flex-wrap: nowrap; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: 8px 12px;
  }
  .ms-on #project-detail-modal .detail-tabs::-webkit-scrollbar { display: none; }
  .ms-on #project-detail-modal .detail-tab { flex: none; min-height: 36px; padding: 0 12px; border-radius: 18px; white-space: nowrap; }

  /* file ảnh: lưới 3 cột vuông */
  .ms-on #project-detail-modal .io-file-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
  .ms-on #project-detail-modal .io-file-card { min-width: 0; margin: 0; border-radius: 8px; overflow: hidden; }
  .ms-on #project-detail-modal .io-file-thumb { aspect-ratio: 1; width: 100%; height: auto; }
  .ms-on #project-detail-modal .io-file-thumb img { width: 100%; height: 100%; object-fit: cover; }
}
