/* MyDrive — giao diện kiểu Google Drive */
* { box-sizing: border-box; }
html, body {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f8fafd;
  color: #1f1f1f;
  font-size: 14px;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
.hidden { display: none !important; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #cfd6de; border-radius: 6px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #aab4c0; border: 2px solid transparent; background-clip: content-box; }

/* ---- Nút icon chung ---- */
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; color: #444746; flex: none;
}
.icon-btn:hover { background: #e4e9f1; }
.icon-btn.big { width: 40px; height: 40px; }
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn.big svg { width: 22px; height: 22px; }

/* ---- Thanh trên cùng ---- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  height: 64px; padding: 0 14px; background: #f8fafd;
}
.brand { display: flex; align-items: center; gap: 8px; font-size: 20px; color: #5e5e5e; user-select: none; margin-right: 6px; }
.brand-ic { font-size: 24px; }
.search {
  flex: 1; max-width: 720px; display: flex; align-items: center; gap: 10px;
  background: #e9eef6; border-radius: 24px; height: 48px; padding: 0 10px 0 16px;
}
.search:focus-within { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.15), 0 0 0 1px #d3e3fd; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 15px; color: #1f1f1f; }
.search svg { width: 20px; height: 20px; color: #444746; flex: none; }
.top-right { display: flex; gap: 2px; margin-left: auto; }
#viewToggle button {
  width: 40px; height: 40px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: #444746;
}
#viewToggle button:hover { background: #e4e9f1; }
#viewToggle button.active { background: #c2e7ff; color: #001d35; }
#viewToggle svg { width: 20px; height: 20px; }

/* ---- Khung chính ---- */
.shell { display: flex; align-items: flex-start; }
.sidebar {
  width: 256px; flex: none; padding: 6px 12px 20px;
  position: sticky; top: 64px; align-self: flex-start;
  max-height: calc(100vh - 64px); overflow: auto;
}
body.sb-hidden .sidebar { display: none; }
.new-wrap { position: relative; padding: 4px 0 4px 4px; }
.btn-new {
  display: inline-flex; align-items: center; gap: 12px;
  background: #c2e7ff; color: #001d35; font-weight: 600; font-size: 14px;
  height: 52px; padding: 0 22px 0 16px; border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0,0,0,.14);
}
.btn-new:hover { background: #b3ddfe; box-shadow: 0 2px 6px rgba(0,0,0,.2); }
.btn-new svg { width: 22px; height: 22px; }
.nav { display: flex; flex-direction: column; margin-top: 12px; }
.nav button {
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px; height: 38px; border-radius: 0 19px 19px 0;
  font-size: 13.5px; color: #1f1f1f; text-align: left; margin-right: 10px;
}
.nav button:hover { background: #e4e9f1; }
.nav button.active { background: #d3e3fd; font-weight: 600; color: #041e49; }
.nav-ic { font-size: 16px; width: 20px; text-align: center; }
.nav .g-dot { margin-left: auto; }
.storage { margin-top: 20px; padding: 0 16px; font-size: 12.5px; color: #5e5e5e; }
.usage-bar { height: 4px; background: #dde1e7; border-radius: 2px; overflow: hidden; margin-bottom: 8px; }
.usage-bar i { display: block; height: 100%; width: 0; background: #0b57d0; border-radius: 2px; transition: width .3s; }
.usage-bar.g { margin-top: 10px; }
.usage-bar.g i { background: #34a853; }

.main {
  flex: 1; min-width: 0; background: #fff;
  border-radius: 16px; margin: 0 12px 12px 4px;
  min-height: calc(100vh - 76px);
}
body.sb-hidden .main { margin-left: 12px; }

/* ---- Thanh công cụ ---- */
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 20px 8px; flex-wrap: wrap; }
.crumbs { display: flex; align-items: center; gap: 2px; flex-wrap: wrap; font-size: 14px; min-height: 36px; }
.crumb { padding: 6px 10px; border-radius: 8px; color: #444746; }
.crumb:hover { background: #f0f4f9; }
.crumb.current { color: #1f1f1f; font-weight: 600; cursor: default; }
.crumb.current:hover { background: none; }
.crumb-sep { color: #9aa0a6; }
.crumb-q { padding: 6px 2px; font-weight: 600; }
.toolbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.group-toggle { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #444746; user-select: none; cursor: pointer; }
.group-toggle input { accent-color: #0b57d0; width: 16px; height: 16px; cursor: pointer; }
.group-toggle.disabled { opacity: .45; }
.btn-ghost {
  height: 36px; padding: 0 14px; border-radius: 18px; border: 1px solid #dadce0;
  font-size: 13.5px; display: inline-flex; align-items: center; gap: 8px; color: #444746; background: #fff;
}
.btn-ghost:hover { background: #f0f4f9; }
.btn-ghost svg { width: 16px; height: 16px; }
.btn-primary { height: 38px; padding: 0 20px; border-radius: 19px; background: #0b57d0; color: #fff; font-weight: 600; font-size: 14px; }
.btn-primary:hover { background: #0842a8; }
.btn-primary.danger { background: #d93025; }
.btn-primary.danger:hover { background: #b3261e; }

/* ---- Menu thả xuống ---- */
.menu {
  position: absolute; background: #fff; border-radius: 10px; z-index: 60; min-width: 210px;
  box-shadow: 0 2px 10px rgba(0,0,0,.22), 0 0 0 1px rgba(0,0,0,.04);
  padding: 6px 0;
}
.menu.float { position: fixed; }
.mi { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 16px; font-size: 13.5px; text-align: left; white-space: nowrap; }
.mi:hover { background: #f0f4f9; }
.mi.danger { color: #d93025; }
.mi .check { width: 18px; display: inline-flex; }
.mi .check svg { width: 16px; height: 16px; }
.mi-ic { width: 20px; text-align: center; }
.menu-sep { border-top: 1px solid #eceef1; margin: 6px 0; }
#newMenu { left: 0; top: calc(100% + 4px); }
#sortMenu { right: 0; top: calc(100% + 4px); }

/* ---- Tiêu đề cột (kiểu danh sách) ---- */
.list-head, .row {
  display: grid; grid-template-columns: 56px minmax(0,1fr) 150px 110px 48px;
  align-items: center; column-gap: 8px;
}
.list-head {
  position: sticky; top: 64px; z-index: 10; background: #fff;
  padding: 6px 20px; font-size: 12.5px; color: #444746; border-bottom: 1px solid #e8eaed;
}
.list-head .sortable { cursor: pointer; user-select: none; display: flex; align-items: center; gap: 4px; }
.list-head .sortable:hover { color: #1f1f1f; }
.list-head .arrow { color: #0b57d0; }

/* ---- Hàng (kiểu danh sách) ---- */
.row { padding: 0 20px; height: 44px; font-size: 13.5px; border-bottom: 1px solid #f2f4f7; }
.row:hover { background: #f0f4f9; }
.cell-ic { display: flex; align-items: center; }
.f-ic { width: 28px; height: 28px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 15px; flex: none; }
.cell-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell-when { color: #5e5e5e; font-size: 12.5px; }
.cell-size { color: #5e5e5e; font-size: 12.5px; text-align: right; }
.row .more, .card .more { opacity: 0; }
.row:hover .more, .row .more.open, .card:hover .more, .card .more.open { opacity: 1; }

/* ---- Thẻ (kiểu lưới / thư viện) ---- */
.section { padding: 4px 0 10px; }
.section-head {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 26px 4px; font-size: 13.5px; font-weight: 600; color: #1f1f1f;
  cursor: pointer; user-select: none;
}
.section-head .chev {
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center; color: #444746; flex: none;
}
.section-head .chev svg { width: 16px; height: 16px; transition: transform .15s; }
.section-head .chev.closed svg { transform: rotate(-90deg); }
.section-count { color: #80868b; font-weight: 400; font-size: 12.5px; }
.cards { display: grid; gap: 12px; padding: 8px 20px 6px; }
.cards.grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.cards.gallery { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.card {
  border: 1px solid #dde3ea; border-radius: 12px; overflow: hidden; background: #fff;
  display: flex; flex-direction: column; transition: box-shadow .12s;
}
.card:hover { box-shadow: 0 1px 6px rgba(0,0,0,.2); }
.card .thumb { height: 150px; background: #f1f5f9; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.cards.gallery .card .thumb { height: 215px; }
.card .thumb img, .card .thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }
.big-ic { width: 78px; height: 78px; border-radius: 22px; display: flex; align-items: center; justify-content: center; font-size: 38px; flex: none; }
.card-bar { display: flex; align-items: center; gap: 6px; padding: 5px 5px 5px 12px; }
.card-name { flex: 1; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---- Trạng thái trống ---- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 90px 20px; color: #5e5e5e; text-align: center; }
.empty .e-ic { font-size: 58px; }
.empty .e-title { font-size: 17px; color: #1f1f1f; font-weight: 600; }

/* ---- Lớp phủ kéo–thả ---- */
.drop-overlay {
  position: fixed; inset: 0; z-index: 80;
  background: rgba(248,250,253,.88); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center;
}
.drop-box {
  border: 2px dashed #0b57d0; color: #0b57d0; border-radius: 20px;
  padding: 48px 72px; text-align: center; font-size: 20px; font-weight: 600; background: rgba(255,255,255,.6);
}
.drop-ic { font-size: 46px; margin-bottom: 10px; }
.drop-sub { font-size: 13px; font-weight: 400; color: #5e5e5e; margin-top: 8px; }

/* ---- Thông báo (toast) ---- */
.toasts { position: fixed; left: 16px; bottom: 16px; z-index: 90; display: flex; flex-direction: column; gap: 10px; width: 340px; max-width: calc(100vw - 32px); }
.toast {
  background: #1f1f1f; color: #fff; border-radius: 10px; padding: 12px 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,.3); font-size: 13px;
}
.t-row { display: flex; gap: 10px; align-items: flex-start; }
.t-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-sub { color: #c7c7c7; margin-top: 2px; }
.t-bar { height: 3px; background: #3c3c3c; border-radius: 2px; margin-top: 7px; overflow: hidden; }
.t-bar i { display: block; height: 100%; width: 0; background: #8ab4f8; transition: width .15s; }
.toast.done .t-sub { color: #81c995; }
.toast.err .t-sub { color: #f28b82; }
.toast.info { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.toast.err.info span { color: #f28b82; }
.t-undo { color: #8ab4f8; font-weight: 600; flex: none; }

/* ---- Hộp xem trước ---- */
.modal { position: fixed; inset: 0; z-index: 70; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; padding: 24px; }
.pv-panel { background: #fff; border-radius: 14px; width: min(1000px, 96vw); max-height: 92vh; display: flex; flex-direction: column; overflow: hidden; }
.pv-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 18px; border-bottom: 1px solid #eceef1; }
.pv-titles { flex: 1; min-width: 0; }
.pv-name { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-meta { font-size: 12px; color: #5e5e5e; margin-top: 2px; }
.pv-actions { display: flex; align-items: center; gap: 2px; }
.pv-body { flex: 1; overflow: auto; display: flex; align-items: center; justify-content: center; background: #26272b; min-height: 300px; }
.pv-body img, .pv-body video { max-width: 100%; max-height: 82vh; min-height: 140px; object-fit: contain; display: block; border-radius: 4px; }
.pv-body iframe { width: 100%; height: 80vh; border: 0; background: #fff; }
.pv-text { margin: 0; padding: 20px; color: #e8eaed; font: 12.5px/1.6 Consolas, "Courier New", monospace; white-space: pre-wrap; word-break: break-word; align-self: stretch; }
.pv-fallback { color: #e8eaed; display: flex; flex-direction: column; gap: 14px; align-items: center; padding: 48px; text-align: center; }
.pv-fallback .big-ic { background: #3c3d41; }
.pv-fallback .btn-primary { background: #8ab4f8; color: #062e6f; }
.pv-loading { color: #9aa0a6; padding: 40px; }
.pv-audio-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; padding: 30px; }
.pv-audio-wrap .pv-audio-ic { font-size: 64px; }
.pv-audio-wrap audio { width: min(480px, 80vw); }

/* ---- Hộp thoại ---- */
.dlg-panel { background: #fff; border-radius: 14px; width: min(420px, 94vw); padding: 22px; }
.dlg-title { font-size: 16px; font-weight: 600; }
.dlg-msg { color: #5e5e5e; font-size: 13.5px; margin-top: 8px; }
.dlg-input-wrap { margin-top: 14px; }
.dlg-input-wrap input { width: 100%; height: 40px; border: 1px solid #dadce0; border-radius: 8px; padding: 0 12px; font: inherit; outline: 0; }
.dlg-input-wrap input:focus { border-color: #0b57d0; box-shadow: 0 0 0 1px #0b57d0; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

/* ---- Kéo–thả nội bộ (chuyển tệp vào thư mục) ---- */
.drag-target { outline: 2px dashed #0b57d0; outline-offset: -2px; background: #e8f0fe !important; }
.dragging { opacity: .45; }

/* ---- Thao tác & Vùng an toàn trên điện thoại (Safe Area & Touch) ---- */
.crumb-back-btn {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; line-height: 1; font-weight: 700;
  color: #0b57d0; background: #e8f0fe; margin-right: 4px; flex: none;
}
.crumb-back-btn:hover { background: #d3e3fd; }
.sheet-handle { display: none; }
.sheet-title { display: none; }
.menu-backdrop { position: fixed; inset: 0; background: rgba(32,33,36,.45); z-index: 70; backdrop-filter: blur(1.5px); }

/* ---- Thanh thao tác khi chọn (Selection Bar) ---- */
.selection-bar {
  position: fixed; top: 0; left: 0; right: 0;
  height: 56px; padding: 0 12px;
  background: #0b57d0; color: #fff; z-index: 40;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 10px rgba(0,0,0,.22);
}
.sel-bar-left, .sel-bar-right { display: flex; align-items: center; gap: 8px; }
.sel-count { font-size: 15px; font-weight: 600; margin-left: 4px; }
.selection-bar .icon-btn { color: #fff; }
.selection-bar .icon-btn:hover { background: rgba(255,255,255,.2); }
.selection-bar .danger-btn:hover { background: rgba(242,139,130,.3); color: #fce8e6; }

/* ---- Nút nổi Tạo mới (FAB) & Thanh điều hướng đáy (Bottom Nav) ---- */
.fab-new { display: none; }
.bottom-nav { display: none; }

/* ---- Màn hẹp / điện thoại ---- */
@media (max-width: 860px) {
  /* Hỗ trợ tai thỏ iPhone / camera dynamic island */
  .topbar {
    height: calc(56px + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
    gap: 6px;
  }
  .selection-bar {
    height: calc(56px + env(safe-area-inset-top, 0px));
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: max(8px, env(safe-area-inset-left, 0px));
    padding-right: max(8px, env(safe-area-inset-right, 0px));
  }
  .brand { font-size: 18px; margin-right: 2px; }
  .brand span:last-child { display: none; }
  .search { height: 42px; border-radius: 21px; padding: 0 10px 0 14px; }
  .list-head { top: calc(56px + env(safe-area-inset-top, 0px)); }

  /* Sidebar drawer: trượt từ trái, nền mờ khi mở */
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 75;
    width: min(300px, 86vw); height: 100%; max-height: none;
    background: #f8fafd;
    padding-top: max(14px, env(safe-area-inset-top, 0px));
    padding-bottom: max(24px, env(safe-area-inset-bottom, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: 12px;
    transform: translateX(-105%); visibility: hidden;
    transition: transform .22s ease, visibility .22s;
  }
  body:not(.sb-hidden) .sidebar {
    transform: none; visibility: visible;
    box-shadow: 0 6px 30px rgba(0,0,0,.28);
  }
  body.sb-hidden .sidebar { display: block; }
  .sb-backdrop { position: fixed; inset: 0; z-index: 74; background: rgba(32,33,36,.45); }
  body.sb-hidden .sb-backdrop { display: none; }

  /* Nội dung chính: để khoảng trống phía dưới cho Bottom Nav & FAB */
  .main {
    margin: 0 6px calc(66px + env(safe-area-inset-bottom, 0px));
    border-radius: 12px;
    min-height: calc(100vh - 130px);
  }
  body.sb-hidden .main { margin-left: 6px; }

  /* Thanh công cụ & Breadcrumb cuộn ngang */
  .toolbar { padding: 8px 10px 6px; gap: 8px; }
  .toolbar-right { gap: 8px; }
  .crumbs {
    overflow-x: auto; white-space: nowrap; flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
    max-width: 100%; padding-bottom: 2px;
  }
  .crumbs::-webkit-scrollbar { display: none; }
  .crumb { padding: 6px 8px; flex: none; font-size: 13.5px; }

  /* Danh sách tệp: tối ưu chạm & hiển thị nút 3 chấm rõ ràng */
  .list-head { padding: 6px 10px; }
  .list-head, .row { grid-template-columns: 44px minmax(0,1fr) 42px; }
  .col-when, .col-size { display: none; }
  .row {
    padding: 0 10px; height: 50px; min-height: 50px;
    -webkit-user-select: none; user-select: none;
  }
  .f-ic { width: 32px; height: 32px; font-size: 17px; }
  .cell-name { font-size: 14px; }
  .row .more, .card .more { opacity: 1 !important; }
  .row .more { width: 38px; height: 38px; }
  .card .more { width: 36px; height: 36px; }
  .group-toggle span { display: none; }

  /* Lưới thẻ & Gallery */
  .cards { padding: 8px 10px 6px; gap: 8px; }
  .cards.grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .cards.gallery { grid-template-columns: repeat(auto-fill, minmax(155px, 1fr)); }
  .card .thumb { height: 130px; }
  .cards.gallery .card .thumb { height: 165px; }
  .card-bar { padding: 4px 4px 4px 10px; }
  .section-head { padding: 10px 14px 4px; }
  .empty { padding: 50px 16px; }
  .drop-box { padding: 28px 18px; font-size: 16px; border-radius: 16px; }

  /* Toasts nằm phía trên Bottom Nav */
  .toasts {
    left: 12px; right: 12px;
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    width: auto; max-width: 460px; margin: 0 auto;
  }

  /* Nút nổi Tạo mới (FAB) */
  .fab-new {
    display: flex; align-items: center; justify-content: center;
    position: fixed; right: max(16px, env(safe-area-inset-right, 0px));
    bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    width: 56px; height: 56px; border-radius: 16px;
    background: #c2e7ff; color: #001d35;
    font-size: 32px; font-weight: 300; line-height: 1;
    box-shadow: 0 4px 14px rgba(0,0,0,.24), 0 1px 3px rgba(0,0,0,.12);
    z-index: 52; cursor: pointer; transition: transform .15s, background .15s;
    -webkit-tap-highlight-color: transparent;
  }
  .fab-new:active { transform: scale(.93); background: #b3ddfe; }

  /* Thanh điều hướng đáy màn hình (Bottom Nav) */
  .bottom-nav {
    display: flex; position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(56px + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
    background: #ffffff; border-top: 1px solid #e1e4e8;
    z-index: 55; justify-content: space-around; align-items: center;
    box-shadow: 0 -2px 10px rgba(0,0,0,.04); user-select: none;
  }
  .b-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 2px; flex: 1; height: 100%; color: #5e5e5e; font-size: 11px; font-weight: 500;
    position: relative; transition: color .12s, transform .12s;
    -webkit-tap-highlight-color: transparent;
  }
  .b-nav-ic { font-size: 20px; line-height: 1; }
  .b-nav-lbl { line-height: 1.1; }
  .b-nav-item.active { color: #0b57d0; font-weight: 600; }
  .b-nav-item.active .b-nav-ic { transform: scale(1.1); }
  .b-nav-item .g-dot {
    position: absolute; top: 6px; right: calc(50% - 15px);
    width: 7px; height: 7px;
  }
}

/* ---- Điện thoại nhỏ & Menu dạng Bottom Sheet ---- */
@media (max-width: 640px) {
  .modal { padding: 0; }
  .pv-panel {
    align-self: stretch; width: 100vw; height: 100vh; height: 100dvh;
    max-height: none; border-radius: 0;
  }
  .pv-head {
    padding-top: max(10px, env(safe-area-inset-top, 0px));
    padding-left: max(12px, env(safe-area-inset-left, 0px));
    padding-right: max(12px, env(safe-area-inset-right, 0px));
  }
  .pv-actions .icon-btn { width: 42px; height: 42px; }
  .pv-body { min-height: 0; padding-bottom: env(safe-area-inset-bottom, 0px); }
  .pv-body img, .pv-body video { max-height: calc(100dvh - 66px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }
  .pv-body iframe { height: calc(100dvh - 66px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px)); }

  .dlg-panel {
    width: min(420px, calc(100vw - 28px));
    max-width: none; border-radius: 18px; padding: 20px 18px; margin: auto;
  }
  .dlg-actions button { min-height: 42px; padding: 0 18px; }

  /* Menu chuyển thành Bottom Sheet trượt từ đáy màn hình */
  .sheet-handle {
    display: block; width: 36px; height: 4px;
    background: #cfd4dc; border-radius: 2px; margin: 2px auto 10px;
  }
  .sheet-title {
    display: block; font-size: 13.5px; font-weight: 600; color: #444746;
    padding: 0 16px 8px; border-bottom: 1px solid #edf0f4; margin-bottom: 4px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .menu.float, #newMenu, #sortMenu {
    position: fixed !important;
    left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important;
    width: 100% !important; max-width: 100% !important;
    border-radius: 20px 20px 0 0 !important;
    box-shadow: 0 -6px 28px rgba(0,0,0,.25) !important;
    padding: 8px 10px max(18px, env(safe-area-inset-bottom, 0px)) !important;
    animation: sheetUp .2s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 80vh; overflow-y: auto; z-index: 75 !important;
  }
  .mi {
    padding: 12px 18px; font-size: 15px; border-radius: 10px; min-height: 48px;
  }
  .mi-ic { font-size: 18px; width: 24px; }
}

@keyframes sheetUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* ---- Màn hình hẹp ≤ 480px ---- */
@media (max-width: 480px) {
  #viewToggle button { width: 32px; height: 32px; }
  #viewToggle button svg { width: 17px; height: 17px; }
  .btn-new { height: 46px; padding: 0 16px 0 12px; }
  .conv-row { flex-wrap: wrap; }
  .conv-drop { padding: 22px 12px; font-size: 14px; }
  .conv-fmt { flex-wrap: wrap; gap: 8px; }
  .conv-fmt select { flex: 1; }
  .topbar { gap: 4px; }
  .search { height: 38px; }
  .search input { font-size: 13.5px; }
}

/* ---- Vùng chọn kéo chuột & chọn nhiều mục ---- */
.marquee {
  position: fixed; z-index: 65; pointer-events: none;
  border: 1px solid rgba(11,87,208,.55); background: rgba(11,87,208,.10); border-radius: 2px;
}
.row.selected { background: #d3e3fd; }
.card.selected { border-color: #0b57d0; box-shadow: 0 0 0 1px #0b57d0 inset; background: #f4f8ff; }
.row.selected .more, .card.selected .more { opacity: 1; }

/* ---- Google Drive ---- */
.g-nav-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 0 14px; height: 38px; margin: 4px 10px 0 0;
  border-radius: 0 19px 19px 0; font-size: 13.5px; color: #1f1f1f; text-align: left; width: calc(100% - 10px);
}
.g-nav-btn:hover { background: #e4e9f1; }
.g-dot { width: 8px; height: 8px; border-radius: 50%; margin-left: auto; background: #9aa0a6; flex: none; }
.g-dot.on { background: #34a853; }
.google-body { margin-top: 12px; max-height: 62vh; overflow: auto; font-size: 13.5px; }
.g-hint { background: #e8f0fe; color: #041e49; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; }
.g-steps { margin: 0 0 12px; padding-left: 20px; line-height: 1.75; color: #444746; }
.g-steps a { color: #0b57d0; }
.g-steps code, .g-note code { background: #f1f3f4; padding: 1px 5px; border-radius: 4px; font-size: 12px; }
.g-input { width: 100%; height: 40px; border: 1px solid #dadce0; border-radius: 8px; padding: 0 12px; font: inherit; outline: 0; margin-top: 8px; }
.g-input:focus { border-color: #0b57d0; box-shadow: 0 0 0 1px #0b57d0; }
.g-note { color: #5e5e5e; font-size: 12.5px; margin-top: 12px; line-height: 1.6; }
.g-status { background: #e6f4ea; color: #137333; border-radius: 8px; padding: 10px 12px; font-weight: 600; }
.g-row { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid #f1f3f4; }
.g-row a { color: #0b57d0; text-decoration: none; }
.g-row a:hover { text-decoration: underline; }
.g-list-title { font-weight: 600; margin: 14px 0 4px; }
.g-progress { margin-top: 12px; }
.g-progress .t-bar { background: #e1e5ea; }
.g-progress .t-bar i { background: #34a853; }
.g-prog-text { color: #5e5e5e; font-size: 12.5px; margin-top: 6px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-err { color: #d93025; font-size: 12.5px; padding: 3px 0; }

/* ---- Nơi lưu & tệp trên Drive ---- */
.dest-wrap { position: relative; }
#destMenu { right: 0; top: calc(100% + 4px); }
.mi.disabled { opacity: .55; }
.cloud-badge { font-size: 11px; margin-left: 4px; }
.card .thumb { position: relative; }
.thumb .cloud-badge {
  position: absolute; top: 6px; right: 6px; margin: 0;
  background: rgba(255,255,255,.92); border-radius: 8px; padding: 1px 5px;
  box-shadow: 0 1px 3px rgba(0,0,0,.15);
}

/* ---- Trang Convert PDF ---- */
.conv-wrap { max-width: 1400px; margin: 16px auto; padding: 0 8px; }
.conv-drop { border: 2px dashed #c4c7c5; border-radius: 14px; padding: 36px 20px; text-align: center; color: #5e5e5e; cursor: pointer; transition: .15s; background: #fafbfc; }
.conv-drop:hover, .conv-drop.over { border-color: #0b57d0; background: #f4f8fe; }
.conv-fmt { display: flex; align-items: center; gap: 10px; margin: 16px 2px 10px; color: #3c4043; font-size: 13.5px; }
.conv-fmt select { height: 36px; border: 1px solid #dadce0; border-radius: 8px; padding: 0 8px; background: #fff; font: inherit; cursor: pointer; }
.conv-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid #e3e5ea; border-radius: 12px; margin-bottom: 8px; background: #fff; }
.conv-info { flex: 1; min-width: 0; }
.conv-name { font-weight: 500; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-name .cell-size { color: #80868b; font-weight: 400; margin-left: 6px; }
.conv-sub { font-size: 12px; color: #80868b; margin-top: 2px; }
.conv-bar { height: 5px; background: #e1e5ea; border-radius: 3px; overflow: hidden; margin-top: 8px; }
.conv-bar i { display: block; height: 100%; background: #0b57d0; width: 0; transition: width .2s; }
.conv-err { color: #d93025; font-size: 12px; margin-top: 2px; }
.conv-ok { color: #137333; font-size: 12px; margin-top: 2px; }
.conv-row button:disabled { opacity: .5; cursor: default; }
.conv-src { display: flex; align-items: center; gap: 10px; margin: 0 2px 12px; font-size: 13px; color: #3c4043; flex-wrap: wrap; }
.conv-src #convSrcText b { color: #137333; }
.conv-cfg { border: 1px solid #e3e5ea; border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; background: #fff; }

/* ---- Khung so sánh song song PDF ↔ kết quả convert ---- */
.conv-item { margin-bottom: 12px; }
.conv-item .conv-row { margin-bottom: 0; border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.conv-item .conv-split + .conv-row, .conv-item > .conv-row:only-child { border-radius: 12px; }
.conv-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 10px; border: 1px solid #e3e5ea; border-top: 0; border-radius: 0 0 12px 12px; background: #f8f9fa; }
.conv-pane { border: 1px solid #e3e5ea; border-radius: 10px; overflow: hidden; background: #fff; display: flex; flex-direction: column; min-width: 0; }
.conv-pane-title { display: flex; align-items: center; gap: 8px; padding: 7px 12px; font-size: 12.5px; font-weight: 600; color: #3c4043; background: #f1f3f4; border-bottom: 1px solid #e3e5ea; }
.conv-pane-title .t-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-pane-title .btn-ghost { height: 28px; padding: 0 10px; font-size: 12px; }
.conv-frame { width: 100%; height: max(640px, calc(100vh - 240px)); border: 0; background: #525659; }
.conv-pane-body { height: max(640px, calc(100vh - 240px)); overflow: auto; background: #fff; }
.conv-pane-body pre { margin: 0; padding: 14px; white-space: pre-wrap; word-break: break-word; font: 12.5px/1.55 Consolas, Menlo, monospace; }
.conv-pane-body .docx-wrapper { background: #e8eaed; padding: 12px; min-height: 100%; box-sizing: border-box; }
.conv-pane-body .docx-wrapper > section.docx { box-shadow: 0 1px 5px rgba(0,0,0,.18); margin-bottom: 14px; }
.conv-fallback { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; min-height: 320px; gap: 12px; color: #5e5e5e; text-align: center; padding: 20px; font-size: 13px; line-height: 1.6; }
@media (max-width: 900px) { .conv-split { grid-template-columns: 1fr; } .conv-frame, .conv-pane-body { height: 420px; } }
.conv-order { display: flex; flex-direction: column; gap: 2px; }
.conv-order .icon-btn { width: 26px; height: 22px; padding: 0; font-size: 12px; line-height: 1; }
.conv-pages { width: 170px; height: 34px; border: 1px solid #dadce0; border-radius: 8px; padding: 0 8px; font: inherit; font-size: 12px; color: #3c4043; }
.conv-pages:focus { border-color: #0b57d0; outline: 0; }
.conv-pages:disabled { opacity: .5; }
@media (max-width: 900px) { .conv-pages { width: 110px; } }
.conv-thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; padding: 12px; }
.conv-thumb { margin: 0; }
.conv-thumb img { width: 100%; height: 190px; object-fit: cover; border: 1px solid #e3e5ea; border-radius: 8px; background: #f1f3f4; display: block; }
.conv-thumb figcaption { font-size: 11.5px; color: #5e5e5e; margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
