/* AutoColor bản điện thoại. Màn hình rộng (máy tính bảng ngang, máy tính) giữ nguyên bố cục gốc. */
.m-tabs { display: none; }
.m-pill { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 25;
  display: flex; align-items: center; gap: 8px; padding: 11px 18px; border-radius: 999px; border: 0;
  background: var(--accent); color: var(--accentInk); font-weight: 650; font-size: 14px; box-shadow: 0 8px 28px #000c; }
.m-pill svg { width: 18px; height: 18px; }
.m-only { display: none; }
#btnOutDir, #btnOpenLuts { display: none; }
.m-sheet .m-sheet-body { max-height: min(60vh, 520px); overflow-y: auto; margin-bottom: 12px; }
.m-sheet .m-sheet-body p { margin: 0 0 10px; }
.m-exp-list { display: grid; grid-template-columns: 1fr; gap: 6px; }
.m-exp { display: flex; align-items: center; gap: 10px; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.m-exp img, .m-exp-f { width: 52px; height: 52px; object-fit: cover; border-radius: 6px; flex: none; background: #000; }
.m-exp-f { display: grid; place-items: center; color: var(--accent2); font-size: 12px; }
.m-exp span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.m-exp small { display: block; color: var(--muted); font-size: 11.5px; }
.m-prog { height: 8px; border-radius: 8px; background: var(--bg); overflow: hidden; margin: 6px 0 8px; border: 1px solid var(--line); }
.m-prog i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }
.m-steps { margin: 0 0 10px; padding-left: 20px; line-height: 1.7; color: #d6d3cd; }

@media (max-width: 900px) {
  html, body { height: 100%; height: 100dvh; font-size: 14px; -webkit-text-size-adjust: 100%; }
  body { display: flex; flex-direction: column; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
  .m-only { display: inline-block; }

  /* Thanh trên cùng: tên app + một hàng nút cuộn ngang */
  .top { height: auto; flex: none; flex-direction: column; align-items: stretch; gap: 6px; padding: calc(6px + env(safe-area-inset-top)) 10px 8px; }
  .brand { font-size: 15px; gap: 8px; }
  .brand small { display: inline; }
  .app-icon { width: 24px; height: 24px; }
  .actions { gap: 6px; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; margin: 0 -10px; padding: 0 10px; }
  .actions::-webkit-scrollbar { display: none; }
  .actions .btn { flex: none; padding: 8px 12px; font-size: 13.5px; }
  #btnOpen { order: -5; } #btnExport { order: -4; } #btnCompare { order: -3; } #btnExportOpt { order: -2; }
  #btnExportOpt span { display: none; }
  .save-state { order: 20; align-self: center; }
  #btnBatch { order: 2; } #btnProjOpen { order: 3; } #btnProjSave { order: 4; } #btnSaveLut { order: 5; } #btnOffline { order: 6; }

  /* Bố cục: khung xem ở trên, phần chỉnh ở dưới, chuyển bằng thanh tab */
  .layout { display: flex; flex-direction: column; flex: 1; min-height: 0; height: auto; }
  .center { flex: none; height: 44%; min-height: 200px; }
  html[data-mtab="view"] .center { flex: 1; height: auto; }
  html[data-mtab="imgs"] .center { flex: 1; height: auto; }
  .center { order: 0; }
  .lib, .panel { order: 1; flex: 1; min-height: 0; border: 0; border-top: 1px solid var(--line); }
  html:not([data-mtab="lib"]) .lib { display: none; }
  html:not([data-mtab="edit"]) .panel { display: none; }
  .viewer { touch-action: none; }
  #cv { touch-action: none; }
  .empty { padding: 0 18px; }
  .empty h2 { font-size: 17px; }
  .empty p { font-size: 13px; line-height: 1.5; }
  .zoom-badge { font-size: 11px; }

  /* Dải ảnh: hàng ảnh nhỏ luôn hiện; thanh công cụ chỉ hiện ở tab Ảnh */
  html:not([data-mtab="imgs"]) .strip-bar { display: none; }
  .strip-hint { display: none; }
  .strip-bar { flex-wrap: wrap; white-space: normal; row-gap: 10px; column-gap: 16px; padding: 10px 12px; }
  .strip-bar .link { font-size: 14px; padding: 4px 0; }
  .strip-bar .sep { display: none; }
  .strip-list { padding: 4px 10px 6px; gap: 6px; }
  .asset { width: 66px; }
  .asset img, .asset .ph { height: 50px; }
  .asset .nm { display: none; }
  .asset .chk { bottom: 4px; }
  html[data-mtab="imgs"] .strip { flex: none; max-height: 52%; display: flex; flex-direction: column; }
  html[data-mtab="imgs"] .strip-list { flex-wrap: wrap; overflow-y: auto; overflow-x: hidden; }
  html[data-mtab="imgs"] .asset { width: calc((100% - 18px) / 4); }
  html[data-mtab="imgs"] .asset img, html[data-mtab="imgs"] .asset .ph { height: auto; aspect-ratio: 1; }
  html[data-mtab="imgs"] .asset .x { display: block; width: 22px; height: 22px; line-height: 22px; }
  html.m-multi .asset .x { display: none; }

  /* Bảng chỉnh */
  .hist-box { padding: 6px 12px 4px; }
  .hist-box canvas { height: 64px !important; }
  .panel-scroll { padding: 8px 12px 16px; -webkit-overflow-scrolling: touch; }
  .panel-foot { padding: 8px 12px; }
  .panel-foot .btn { padding: 9px 8px; }
  .card h3 { font-size: 14.5px; }
  .fix-keys, .base-ctl > p.muted.small:first-of-type { display: none; }
  .btn { padding: 9px 14px; }
  .link { font-size: 13.5px; }
  .sl { margin: 14px 0; }
  .sl-top { font-size: 13.5px; }
  .sl-top input.v { width: 54px; font-size: 13.5px; }
  .sl input[type=range] { height: 30px; }
  .sl input[type=range]::-webkit-slider-runnable-track { height: 4px; }
  .sl input[type=range]::-webkit-slider-thumb { width: 24px; height: 24px; margin-top: -10px; }
  .chk { font-size: 13.5px; padding: 4px 0; }
  .skin-preset { padding: 9px 8px; font-size: 14px; }
  .fix-tools button { padding: 9px 8px; }
  .rt-tools button { padding: 10px 4px; font-size: 13px; }

  /* Thư viện preset */
  .lib-head { padding: 10px 12px; }
  .lib-head input { padding: 10px 12px; font-size: 16px; } /* 16px: iPhone không tự phóng to khi gõ */
  .lib-list { -webkit-overflow-scrolling: touch; }
  .grp-h { padding: 10px 6px; font-size: 14px; }

  /* Hộp thoại, thông báo */
  .modal { padding: 16px; max-height: calc(100dvh - 40px); overflow-y: auto; }
  .modal-input { font-size: 16px; }
  .modal-btns .btn { padding: 10px 14px; }
  .toast { bottom: calc(128px + env(safe-area-inset-bottom)); max-width: calc(100vw - 24px); font-size: 13.5px; }
  .grid { grid-template-columns: 1fr 1fr 1fr; gap: 5px; }
  .m-pill { bottom: calc(72px + env(safe-area-inset-bottom)); }

  /* Thanh tab dưới */
  .m-tabs { display: flex; flex: none; border-top: 1px solid var(--line); background: var(--bg2); padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); }
  .m-tabs button { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px; background: none; border: 0; color: var(--muted); padding: 6px 0 4px; font-size: 11.5px; }
  .m-tabs button svg { width: 23px; height: 23px; }
  .m-tabs button.on { color: var(--accent2); }
}
@media (max-width: 900px) and (orientation: landscape) and (max-height: 520px) {
  .center { height: 58%; }
  .top { padding-top: 4px; }
  .brand { display: none; }
}
