/* Bố cục từng màn. Ưu tiên điện thoại 360px, mở rộng cho máy tính. */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  font: 400 16px/1.5 var(--font); color: var(--text);
  background: linear-gradient(160deg, var(--bg-1), var(--bg-2) 55%, var(--bg-3));
  background-attachment: fixed;
  overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
button { font-family: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ===== Nền gradient chuyển động chậm ===== */
.bg { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.blob { position: absolute; border-radius: 50%; filter: blur(70px); will-change: transform; }
.blob.a { width: 60vmax; height: 60vmax; left: -15vmax; top: -15vmax; background: var(--blob-a); animation: drift-a 26s ease-in-out infinite alternate; }
.blob.b { width: 50vmax; height: 50vmax; right: -12vmax; top: 20vh; background: var(--blob-b); animation: drift-b 32s ease-in-out infinite alternate; }
.blob.c { width: 55vmax; height: 55vmax; left: 10vmax; bottom: -22vmax; background: var(--blob-c); animation: drift-c 38s ease-in-out infinite alternate; }
@keyframes drift-a { to { transform: translate(18vmax, 12vmax) scale(1.1); } }
@keyframes drift-b { to { transform: translate(-16vmax, 10vmax) scale(.9); } }
@keyframes drift-c { to { transform: translate(14vmax, -14vmax) scale(1.15); } }
@media (prefers-reduced-motion: reduce) {
  .blob { animation: none; }
  * { transition-duration: .01ms !important; }
}

/* ===== Khung chung ===== */
#view { max-width: 1180px; margin: 0 auto; padding: 16px 16px calc(var(--tab-h) + 44px); }
.screen { animation: enter .28s ease both; }
@keyframes enter { from { opacity: 0; transform: translateY(8px); } }

.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.topbar h1 { font-size: 22px; font-weight: 800; letter-spacing: -.01em; flex: 1; min-width: 0; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 36px; height: 36px; border-radius: 10px; }

/* ===== Thanh tab nổi (điện thoại: dưới; máy tính: trên) ===== */
#tabs {
  position: fixed; z-index: 20; left: 50%; bottom: max(14px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 4px;
  height: var(--tab-h); padding: 8px 10px; width: min(380px, calc(100vw - 28px));
  border-radius: 999px;
}
#tabs a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: 100%; border-radius: 999px; text-decoration: none;
  font: 600 11.5px var(--font); color: var(--text-soft);
  transition: background .15s, color .15s;
}
#tabs a[aria-current="page"] { color: var(--text); background: color-mix(in srgb, var(--accent-2) 34%, transparent); }
#tabs a.tab-add {
  flex: 0 0 64px; height: 64px; margin-top: -22px; color: var(--accent-text);
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  border: 2px solid rgba(255, 255, 255, .7);
  box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 55%, transparent);
}
#tabs a.tab-add[aria-current="page"] { color: var(--accent-text); background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
#tabs a.tab-add span { display: none; }
.tab-add svg { width: 28px; height: 28px; }

/* ===== Màn Tìm ===== */
.searchbox { position: relative; padding: 6px; border-radius: 999px; margin-bottom: 14px; }
.searchbox .field {
  min-height: 56px; padding-left: 54px; padding-right: 20px; font-size: 17px;
  border-radius: 999px; border-color: transparent; background: transparent;
}
.searchbox .field:focus { box-shadow: none; }
.searchbox:focus-within { box-shadow: var(--shadow), 0 0 0 3px color-mix(in srgb, var(--accent) 45%, transparent); }
.searchbox > svg { position: absolute; left: 24px; top: 50%; transform: translateY(-50%); color: var(--accent); z-index: 1; width: 24px; height: 24px; }
.kbd-hint { position: absolute; right: 22px; top: 50%; transform: translateY(-50%); display: none; font: 600 12px var(--font); color: var(--text-faint); border: 1px solid var(--field-border); border-radius: 6px; padding: 1px 8px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 12px; margin: 0 -16px 4px; padding-inline: 16px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.result-meta { color: var(--text-soft); font-size: 14px; margin: 0 4px 12px; }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 479px) {
  .card-body { padding: 10px 11px 12px; }
  .card-title { font-size: 14px; }
  .card-line { font-size: 12px; }
  .badge { top: 7px; left: 7px; font-size: 11px; padding: 2px 8px; }
}
.card {
  display: flex; flex-direction: column; overflow: hidden; padding: 0; text-align: left; color: inherit;
  cursor: pointer; border-radius: var(--r-md); transition: transform .18s ease, box-shadow .18s ease;
  text-decoration: none;
}
.card:hover { transform: translateY(-3px); }
.card:active { transform: scale(.985); }
.thumb { aspect-ratio: 4 / 3; width: 100%; background: var(--glass); display: block; object-fit: cover; }
.thumb-text {
  aspect-ratio: 4 / 3; padding: 16px; overflow: hidden; font-size: 14px; line-height: 1.5; color: var(--text-soft);
  background: color-mix(in srgb, var(--accent-2) 14%, var(--glass-strong));
  display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; white-space: pre-line;
}
.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; position: relative; }
.card-title { font-size: 15.5px; font-weight: 700; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.card-line { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-soft); min-width: 0; }
.card-line span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-line svg { flex: none; opacity: .8; }
.badge { position: absolute; top: 10px; left: 10px; z-index: 1; padding: 3px 10px; font: 700 12px var(--font); color: #fff; border-radius: 999px; background: rgba(20, 24, 40, .55); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.thumb-wrap { position: relative; }
.empty { text-align: center; padding: 44px 24px; color: var(--text-soft); }
.empty h2 { color: var(--text); font-size: 18px; margin: 8px 0 4px; }

/* ===== Màn Thêm ===== */
.panel { padding: 18px; display: flex; flex-direction: column; gap: 16px; }
.dropzone {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 26px 16px; border: 2px dashed color-mix(in srgb, var(--accent) 55%, transparent); border-radius: var(--r-md);
  background: color-mix(in srgb, var(--accent-2) 10%, transparent); color: var(--text-soft);
  transition: background .15s, border-color .15s;
}
.dropzone.over { background: color-mix(in srgb, var(--accent-2) 28%, transparent); border-style: solid; }
.dropzone svg { color: var(--accent); }
.dz-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.preview { width: 100%; max-height: 300px; object-fit: contain; border-radius: var(--r-sm); background: var(--glass); }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.label { display: block; font: 700 13px var(--font); color: var(--text-soft); margin-bottom: 6px; letter-spacing: .01em; }
.hint { font-size: 12.5px; color: var(--text-faint); margin-top: 4px; }
.tag-input { display: flex; flex-wrap: wrap; gap: 6px; padding: 7px 8px; min-height: 46px; align-items: center; cursor: text; }
.tag-input input { flex: 1; min-width: 110px; border: 0; background: none; font: 400 16px var(--font); color: var(--text); padding: 4px 4px; }
.tag-input input:focus { outline: none; }
.tag-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.actions .btn { flex: 1; min-width: 130px; }

/* ===== Màn Chi tiết ===== */
.detail { display: grid; gap: 16px; }
.detail-img { padding: 8px; }
.detail-img button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: var(--r-md); overflow: hidden; }
.detail-img img { width: 100%; display: block; border-radius: var(--r-md); }
.detail-text { padding: 20px; white-space: pre-wrap; line-height: 1.6; }
.info { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.info h2 { font-size: 20px; line-height: 1.3; }
.kv { display: grid; gap: 4px; }
.kv dt { font: 700 12.5px var(--font); color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; }
.kv dd { margin: 0; display: flex; flex-wrap: wrap; gap: 6px; color: var(--text); }
.kv-list { display: grid; gap: 14px; margin: 0; }
.ocr { padding: 12px 14px; border-radius: var(--r-sm); background: var(--field); border: 1px solid var(--field-border); font-size: 14px; color: var(--text-soft); }

.lightbox { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(8, 10, 20, .8); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); animation: enter .2s ease both; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.lightbox .btn { position: absolute; top: 14px; right: 14px; color: #fff; background: rgba(255, 255, 255, .18); }

.modal-back { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; padding: 16px; background: rgba(8, 10, 20, .45); animation: enter .2s ease both; }
.modal { width: min(420px, 100%); padding: 22px; display: flex; flex-direction: column; gap: 14px; margin-bottom: 8px; }
.modal h2 { font-size: 18px; }

/* ===== Màn Cài đặt ===== */
.settings { display: grid; gap: 14px; }
.setting { padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.setting-head { display: flex; align-items: center; gap: 12px; }
.setting-head .ico { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; color: var(--accent-text); background: linear-gradient(135deg, var(--accent-2), var(--accent)); flex: none; }
.setting-head h2 { font-size: 16.5px; }
.setting-head p { font-size: 13px; color: var(--text-soft); }
.status-pill { margin-left: auto; font: 700 12px var(--font); padding: 3px 10px; border-radius: 999px; background: var(--field); color: var(--text-faint); border: 1px solid var(--field-border); white-space: nowrap; }
.soon { font-size: 13.5px; color: var(--text-soft); }

/* ===== Thông báo ===== */
/* Điện thoại: thông báo nằm ngay TRÊN thanh menu dưới, gọn, không che nút quay lại / tiêu đề ở trên. */
#toast-box { position: fixed; z-index: 60; left: 50%; bottom: calc(max(14px, env(safe-area-inset-bottom)) + var(--tab-h) + 30px); transform: translateX(-50%); width: max-content; max-width: calc(100vw - 48px); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 8px; padding: 9px 16px; border-radius: 999px; font-weight: 600; font-size: 14px; animation: enter .25s ease both; }
.toast-ok svg { color: var(--ok); }
.toast-error svg { color: var(--danger); }

/* ===== Máy tính ===== */
@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .form-grid.two { grid-template-columns: 1fr 1fr; }
  .form-grid .span2 { grid-column: 1 / -1; }
}
@media (min-width: 900px) {
  #view { padding: 96px 28px 60px; }
  #tabs { bottom: auto; top: 16px; width: 440px; height: 56px; padding: 6px 8px; }
  #tabs a { flex-direction: row; gap: 8px; font-size: 14px; }
  /* Máy tính: menu nằm trên cùng → thông báo xuống góc dưới để không che menu */
  #toast-box { top: auto; bottom: 24px; }
  #tabs a.tab-add { flex: 1; height: 100%; margin-top: 0; border-width: 1px; box-shadow: none; }
  #tabs a.tab-add span { display: inline; }
  #tabs a.tab-add svg { width: 20px; height: 20px; }
  .grid { grid-template-columns: repeat(3, 1fr); gap: 18px; }
  .kbd-hint { display: block; }
  .detail { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; }
  .modal-back { align-items: center; }
  .settings { grid-template-columns: 1fr 1fr; }
  .form-layout { display: grid; grid-template-columns: 1fr 1.25fr; gap: 18px; align-items: start; }
}
@media (min-width: 1200px) {
  .grid { grid-template-columns: repeat(4, 1fr); }
}

/* ===== Bổ sung v0.2.0 ===== */
mark { background: color-mix(in srgb, var(--accent-2) 55%, transparent); color: inherit; border-radius: 4px; padding: 0 2px; }
.chips + .chips { padding-top: 0; }
.chip-label { align-self: center; font: 700 12px var(--font); color: var(--text-faint); text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.empty-fish { font-size: 48px; line-height: 1; }
.empty .btn { text-decoration: none; }
.ti-wrap { position: relative; }
.suggest { position: absolute; z-index: 15; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 6px; list-style: none; border-radius: var(--r-sm); max-height: 240px; overflow-y: auto; }
.suggest[hidden] { display: none; }
.suggest li { padding: 10px 12px; border-radius: 10px; cursor: pointer; font-size: 15px; }
.suggest li:hover, .suggest li.on { background: color-mix(in srgb, var(--accent-2) 30%, transparent); }
.pic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; }
.pic { position: relative; aspect-ratio: 1; border-radius: var(--r-sm); overflow: hidden; background: var(--glass); }
.pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pic-x { position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; display: grid; place-items: center; border: 0; border-radius: 50%; color: #fff; background: rgba(20, 24, 40, .65); cursor: pointer; }
.trash-list { display: grid; gap: 12px; }
.trash-row { display: flex; align-items: center; gap: 14px; padding: 12px; }
.trash-thumb { width: 72px; height: 72px; flex: none; object-fit: cover; border-radius: 12px; background: var(--glass); aspect-ratio: auto; padding: 6px; font-size: 11px; overflow: hidden; }
.trash-info { flex: 1; min-width: 0; }

/* Xem ảnh phóng to */
.lightbox { padding: 0; }
.lb-stage { position: absolute; inset: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; touch-action: none; user-select: none; -webkit-user-select: none; }
.lb-stage img { max-width: 100%; max-height: 100%; transform-origin: center; will-change: transform; -webkit-user-drag: none; }
.lightbox .btn.lb-close { top: max(14px, env(safe-area-inset-top)); right: 14px; z-index: 2; }
.lb-bar { position: absolute; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 6px; padding: 6px; border-radius: 999px; z-index: 2; }
.lightbox .lb-bar .btn { position: static; color: var(--text); background: transparent; box-shadow: none; }
.lb-sym { font: 700 22px/1 var(--font); }
.lb-fit { font-size: 14px; }
.chips[hidden] { display: none; }

/* ===== GĐ3: Gemini / gợi ý của máy ===== */
.ai-badge { display: inline-block; margin-left: 8px; padding: 1px 8px; border-radius: 999px; font: 700 11.5px var(--font); color: var(--accent); background: color-mix(in srgb, var(--accent) 14%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); vertical-align: 1px; }
.ai-box { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin: 12px 0; }
.ai-box[hidden], .ai-box [hidden] { display: none; }
.switch-row { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-soft); cursor: pointer; }
.switch-row input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.field.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }
.doctype { display: flex; flex-direction: column; gap: 8px; }
.doctype [hidden] { display: none; }
.ok-text { color: var(--ok); font-weight: 600; }
.err-text { color: var(--danger); font-weight: 600; }
.setting a { color: var(--accent); }

/* Chấm trạng thái đồng bộ Google Drive (góc trên phải) */
.sync-dot { position: fixed; z-index: 55; top: max(6px, env(safe-area-inset-top)); right: 6px; width: 36px; height: 36px; display: grid; place-items: center; border: 0; background: transparent; cursor: pointer; padding: 0; }
.sync-dot-core { width: 12px; height: 12px; border-radius: 50%; background: #9aa0a6; box-shadow: 0 0 0 3px color-mix(in srgb, #9aa0a6 25%, transparent); transition: background .2s; }
.sync-dot[data-state="idle"] .sync-dot-core { background: var(--ok); box-shadow: 0 0 0 3px color-mix(in srgb, var(--ok) 25%, transparent); }
.sync-dot[data-state="syncing"] .sync-dot-core { background: #3b82f6; box-shadow: 0 0 0 3px color-mix(in srgb, #3b82f6 25%, transparent); animation: sync-pulse 1s ease-in-out infinite; }
.sync-dot[data-state="offline"] .sync-dot-core, .sync-dot[data-state="auth"] .sync-dot-core { background: #f5a524; box-shadow: 0 0 0 3px color-mix(in srgb, #f5a524 30%, transparent); }
.sync-dot[data-state="error"] .sync-dot-core { background: var(--danger); box-shadow: 0 0 0 3px color-mix(in srgb, var(--danger) 25%, transparent); }
@keyframes sync-pulse { 50% { transform: scale(1.5); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .sync-dot[data-state="syncing"] .sync-dot-core { animation: none; } }

/* ===== v0.6.0: Chọn nhiều + Hồ sơ trình bày ===== */
.topbar .sel-toggle { margin-left: auto; margin-right: 40px; min-height: 40px; padding: 0 14px; font-size: 14px; }
.topbar .sel-toggle[aria-pressed="true"] { color: var(--accent-text); background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.card { -webkit-touch-callout: none; -webkit-user-drag: none; }
.grid.selecting { margin-bottom: 150px; }
.grid.selecting .card { user-select: none; -webkit-user-select: none; }
.sel-mark { display: none; position: absolute; top: 8px; right: 8px; z-index: 2; width: 28px; height: 28px; border-radius: 50%; place-items: center; color: transparent; background: rgba(255, 255, 255, .85); border: 2px solid var(--accent); }
.grid.selecting .sel-mark { display: grid; }
.card.selected { outline: 3px solid var(--accent); outline-offset: -3px; }
.card.selected .sel-mark { color: var(--accent-text); background: var(--accent); }
.selbar { position: fixed; z-index: 25; left: 50%; transform: translateX(-50%); bottom: calc(max(14px, env(safe-area-inset-bottom)) + var(--tab-h) + 26px); width: min(560px, calc(100vw - 28px)); padding: 10px 14px 12px; display: flex; flex-direction: column; gap: 8px; border-radius: var(--r-md); }
.selbar-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; font-size: 15px; }
.selbar-links { display: flex; gap: 2px; flex-wrap: wrap; justify-content: flex-end; }
.sel-link { min-height: 34px; padding: 0 10px; font-size: 13px; color: var(--accent); }
.sel-make:disabled { opacity: .5; cursor: not-allowed; }

.dos-controls .panel { margin-bottom: 18px; }
.dos-list { display: grid; gap: 8px; }
.dos-row { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border-radius: var(--r-sm); }
.dos-num { flex: none; width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; font: 700 13px var(--font); color: var(--accent-text); background: linear-gradient(135deg, var(--accent-2), var(--accent)); }
.dos-row-info { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 14.5px; }
.dos-row-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dos-row-info span { font-size: 12.5px; color: var(--text-soft); }
.dos-row-btns { flex: none; display: flex; }
.dos-row-btns .btn { width: 38px; min-height: 38px; }
.dos-row-btns .btn:disabled { opacity: .3; cursor: default; }
.dos-progress { display: grid; gap: 6px; font-size: 14px; color: var(--text-soft); }
.dos-progress progress { width: 100%; height: 10px; accent-color: var(--accent); }

/* Trang hồ sơ: giấy trắng chữ đen (cả khi máy đang ở chế độ tối) */
.dos-preview { display: grid; gap: 18px; justify-items: center; }
.dos-page { width: min(100%, 210mm); background: #fff; color: #111; padding: 14mm; border-radius: 6px; box-shadow: 0 6px 26px rgba(0, 0, 0, .22); font: 400 11pt/1.45 var(--font); }
.dos-title { font: 800 24pt/1.2 var(--font); margin: 4mm 0 3mm; overflow-wrap: anywhere; }
.dos-sub { color: #444; margin-bottom: 8mm; }
.dos-h2 { font: 700 14pt/1.3 var(--font); margin: 0 0 3mm; overflow-wrap: anywhere; }
.dos-notebox { border-left: 4px solid #e8730c; background: #fff6ea; padding: 4mm 5mm; margin-bottom: 8mm; }
.dos-notebox p { white-space: pre-wrap; overflow-wrap: anywhere; }
.dos-toc { list-style: none; margin: 0; padding: 0; display: grid; gap: 2mm; }
.dos-toc li { display: flex; gap: 3mm; }
.dos-toc-n { flex: none; width: 8mm; text-align: right; font-weight: 700; }
.dos-toc small { display: block; color: #555; font-size: 9.5pt; }
.dos-meta { display: grid; grid-template-columns: 34mm 1fr; gap: 1.5mm 4mm; margin: 0 0 4mm; font-size: 10.5pt; }
.dos-meta dt { font-weight: 700; color: #444; }
.dos-meta dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.dos-img { display: block; max-width: 100%; max-height: 165mm; width: auto; height: auto; margin: 3mm auto; object-fit: contain; break-inside: avoid; border: 1px solid #ddd; }
.dos-warn { font-size: 10pt; color: #a15a00; margin: 2mm 0; }
.dos-text { white-space: pre-wrap; overflow-wrap: anywhere; border: 1px solid #ddd; padding: 4mm; margin: 3mm 0; }
.dos-ocr { margin-top: 4mm; font-size: 9.5pt; color: #333; white-space: pre-wrap; overflow-wrap: anywhere; }
.dos-ocr strong { display: block; margin-bottom: 1mm; }
@media (max-width: 639px) {
  .dos-page { padding: 16px; font-size: 10.5pt; }
  .dos-meta { grid-template-columns: 1fr; gap: 0; }
  .dos-meta dd { margin-bottom: 6px; }
  .dos-title { font-size: 20pt; }
}
@media (min-width: 900px) {
  .selbar { bottom: 24px; }
}

/* ===== In / lưu PDF: khổ A4, chỉ in phần hồ sơ ===== */
@page { size: A4; margin: 14mm 14mm 16mm; @bottom-center { content: counter(page); font: 9pt sans-serif; color: #666; } }
@media print {
  html, body { background: #fff !important; overflow: visible !important; height: auto !important; min-height: 0 !important; }
  .bg, #tabs, #toast-box, .sync-dot, .no-print { display: none !important; }
  #view { max-width: none !important; margin: 0 !important; padding: 0 !important; }
  .screen { animation: none !important; transform: none !important; }
  .dos-preview { display: block; }
  .dos-page { width: auto; padding: 0; margin: 0; border-radius: 0; box-shadow: none; font-size: 11pt; }
  .dos-item { break-before: page; page-break-before: always; }
  .dos-meta, .dos-h2 { break-after: avoid; }
  .dos-meta { grid-template-columns: 34mm 1fr; }
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
