.mobile-directory,
.mobile-sides,
.mobile-picker-text,
.upload-label.camera-label,
[hidden] {
  display: none !important;
}

.phone-entry {
  display: grid;
  gap: 8px;
  justify-items: center;
  padding: 10px;
  border-radius: 9px;
  background: #f6f9f6;
  border: 1px solid var(--line);
}

.phone-entry img {
  width: 205px;
  max-width: 100%;
  height: auto;
}

.image-stage.pixel {
  touch-action: pan-x pan-y pinch-zoom;
  overscroll-behavior: contain;
}

.upload-label .file-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

@media (max-width: 760px), (pointer: coarse) and (max-width: 1000px) and (max-height: 600px) {
  .shell {
    padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
    padding-bottom: calc(74px + env(safe-area-inset-bottom));
  }

  .top-inner {
    min-height: 52px;
    padding: max(7px, env(safe-area-inset-top)) 12px 7px;
    flex-wrap: nowrap;
    gap: 8px;
  }

  .top-inner nav {
    position: fixed;
    inset: auto 0 0;
    width: 100%;
    height: calc(54px + env(safe-area-inset-bottom));
    padding: 0 max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, .97);
    z-index: 25;
  }

  .nav-link {
    flex: 1;
    font-size: 14.5px;
    padding: 0 6px;
  }

  .nav-link.active::after {
    top: 0;
    bottom: auto;
    left: 26%;
    right: 26%;
    border-radius: 0 0 3px 3px;
  }

  .brand { gap: 7px; min-width: 0; }
  .brand strong { font-size: 13px; }
  .brand small { font-size: 9.5px; letter-spacing: 0; }
  .steel-mark { width: 31px; height: 32px; }
  .identity { gap: 6px; font-size: 12px; flex-shrink: 0; }
  .identity-name { max-width: 68px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .identity .avatar { display: none; }
  .identity button { font-size: 12px; min-height: 38px; }
  .phone-btn { padding: 4px 8px; }
  .phone-btn .ui-icon { display: none; }

  /* 手机顶部紧凑化，为现场拍图腾出首屏 */
  .page-intro {
    align-items: center;
    padding: 8px 0 7px;
    gap: 8px;
  }
  .page-intro h1 { font-size: 19px; }
  .page-intro p { margin-top: 1px; font-size: 11px; }
  .progress-mini {
    min-width: 118px;
    max-width: 146px;
    padding: 5px 8px;
    gap: 3px;
    font-size: 10.5px;
  }
  .progress-mini > span { font-size: 9.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .work-grid { display: block; }

  /* 手机端目录与搜索条 */
  .rail {
    position: static;
    margin-bottom: 10px;
    border-color: #bccbc0;
  }

  .mobile-directory {
    display: flex !important;
    width: 100%;
    min-height: 52px;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--panel);
    border: 0;
    padding: 8px 12px;
    text-align: left;
    color: var(--deep);
  }

  .mobile-dir-left {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    flex: 1;
  }

  .dir-search-ico {
    width: 18px;
    height: 18px;
    color: var(--green);
  }

  .mobile-dir-text {
    display: grid;
    min-width: 0;
    gap: 1px;
  }

  .mobile-dir-text strong {
    font-size: 14px;
    line-height: 1.25;
  }

  .mobile-filter-summary {
    font-size: 11.5px;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-filter-summary.has-filter {
    color: var(--green);
    font-weight: 600;
  }

  .mobile-dir-right {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
  }

  .rail.mobile-open .dir-chevron {
    transform: rotate(180deg);
  }

  .rail:not(.mobile-open) .rail-head,
  .rail:not(.mobile-open) .entry-list {
    display: none;
  }

  .rail.mobile-open .rail-head {
    border-top: 1px solid var(--line);
    padding: 11px 12px;
    gap: 9px;
  }

  .rail-head > .row { display: none; }
  .rail .entry-list { max-height: min(46dvh, 360px); }

  .entry-choice {
    min-height: 54px;
    padding: 10px 12px;
  }

  .quick-terms {
    gap: 6px;
  }

  .quick-chip {
    min-height: 32px;
    padding: 4px 10px;
    font-size: 12.5px;
  }

  input:not([type=checkbox]):not([type=file]), select {
    min-height: 44px;
    font-size: 16px;
  }

  .segmented button {
    min-height: 40px;
    font-size: 13.5px;
  }

  /* 条目头部与快捷翻页（手机合并单行，现场核对移至图位卡下方让首屏直达拍照按钮） */
  .entry-heading {
    padding-bottom: 7px;
  }

  .entry-head-top {
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
  }

  .eyeline {
    gap: 5px;
    font-size: 11px;
    min-width: 0;
  }

  .eyeline .muted {
    display: none;
  }

  .entry-heading h2 {
    font-size: 19px;
    margin-top: 5px;
  }

  .compare-open-btn, .pager-text {
    display: none;
  }

  .entry-toolbar {
    width: auto;
    flex-shrink: 0;
  }

  .entry-pager {
    width: auto;
    padding: 1px 2px;
    gap: 1px;
  }

  .pager-btn {
    min-height: 30px !important;
    min-width: 30px;
    padding: 2px 5px !important;
  }

  .pager-pos {
    font-size: 11px;
    padding: 0 3px;
  }

  .focus-line {
    font-size: 12.5px !important;
    margin-top: 3px !important;
  }

  .entry-work-stack {
    gap: 8px;
  }

  .entry-work-stack > .mobile-sides {
    order: 1;
    margin-bottom: 0;
  }

  .entry-work-stack > .compare {
    order: 2;
  }

  .entry-work-stack > .field-note {
    order: 3;
    padding: 9px 11px;
    font-size: 12.5px;
    flex-direction: column;
    gap: 3px;
  }

  /* 手机并排左错/右对强区分切卡 */
  .mobile-sides {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 10px;
  }

  .mobile-side {
    display: flex;
    gap: 8px;
    align-items: center;
    min-width: 0;
    min-height: 56px;
    padding: 6px 8px;
    color: var(--muted);
    border: 1.5px solid var(--line);
    background: var(--panel);
    border-radius: 10px;
    text-align: left;
    position: relative;
  }

  .mobile-side-thumb {
    position: relative;
    width: 48px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 6px;
    overflow: hidden;
    background: #edf0ea;
    border: 1px solid rgba(18, 38, 40, .1);
  }

  .mobile-side-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
  }

  .thumb-mark {
    position: absolute;
    left: 2px;
    top: 2px;
    width: 15px;
    height: 15px;
    border-radius: 4px;
    display: grid;
    place-items: center;
    font-size: 11px;
    font-weight: 800;
    color: #ffffff;
    line-height: 1;
  }

  .thumb-mark.left { background: var(--wrong); }
  .thumb-mark.right { background: var(--right); }

  .mobile-side-copy {
    display: grid;
    min-width: 0;
    gap: 2px;
  }

  .mobile-side-copy strong {
    font-size: 13px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mobile-side-sub {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
  }

  .side-pill {
    font-size: 10px;
    font-weight: 650;
    padding: 1px 5px;
    border-radius: 4px;
    background: #ebefeb;
    color: #465853;
    white-space: nowrap;
  }

  .side-pill.busy { background: var(--busy-bg); color: var(--busy-ink); }
  .side-pill.bad { background: var(--wrong-bg); color: var(--wrong-ink); }
  .side-pill.warn, .side-pill.sand { background: var(--warn-bg); color: var(--warn-ink); }
  .side-pill.ok, .side-pill.mine { background: var(--right-bg); color: var(--right-ink); }

  .side-role-mini {
    font-size: 10px;
    color: var(--muted);
  }

  .mobile-side.left[aria-pressed=true] {
    border: 2px solid var(--wrong);
    background: var(--wrong-bg);
    color: var(--wrong-ink);
  }

  .mobile-side.right[aria-pressed=true] {
    border: 2px solid var(--right);
    background: var(--right-bg);
    color: var(--right-ink);
  }

  .compare { display: block; }
  .compare[data-mobile-side=left] > .right,
  .compare[data-mobile-side=right] > .left {
    display: none;
  }

  .figure {
    height: clamp(136px, 18.5dvh, 185px);
    padding: 6px;
  }

  .card-head {
    padding: 7px 11px;
  }

  .card-content {
    padding: 8px 11px 10px;
    gap: 6px;
  }

  .caption {
    font-size: 13.5px;
    line-height: 1.55;
  }

  .upload-guard {
    font-size: 11px;
    padding: 5px 8px;
    gap: 2px 6px;
  }

  .review-state:not(:empty) {
    padding: 10px;
    gap: 9px;
  }

  .review-thumb {
    width: 56px;
    height: 46px;
  }

  .upload-guard {
    font-size: 11.5px;
    padding: 7px 9px;
  }

  /* 手机底部大按钮：拍照 + 相册清晰并排，不挤历史按钮 */
  .card-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  .upload-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .desktop-picker-text { display: none; }
  .mobile-picker-text,
  .upload-label.camera-label {
    display: inline-flex !important;
  }

  .upload-pair .upload-label {
    min-height: 46px;
    padding: 8px 10px;
    font-size: 14px;
    width: 100%;
  }

  .camera-label {
    background: var(--deep) !important;
    color: #ffffff !important;
    border-color: var(--deep) !important;
  }

  .slot-card.left .camera-label {
    background: var(--wrong) !important;
    border-color: var(--wrong) !important;
  }

  .slot-card.right .camera-label {
    background: var(--right) !important;
    border-color: var(--right) !important;
  }

  .history-trigger {
    min-height: 40px;
    justify-content: center;
    border-top: 1px dashed var(--line);
    padding-top: 8px;
    width: 100%;
  }

  .source-fields summary { padding-block: 5px; }
  .source-grid { grid-template-columns: 1fr; }

  /* 登录页手机优化 */
  .sign-page {
    grid-template-columns: 1fr;
    align-content: start;
  }

  .sign-cover {
    min-height: 140px;
    padding: 18px 16px;
    gap: 12px;
  }

  .sign-cover .cover-title h2 {
    font-size: 22px;
    margin-top: 4px;
  }

  .cover-title h2 br, .cover-title span, .cover-bottom {
    display: none;
  }

  .cover-pills {
    margin-top: 10px;
    gap: 6px;
  }

  .cover-pill {
    font-size: 11px;
    padding: 4px 9px;
  }

  .sign-side {
    padding: 16px 14px 28px;
    align-items: start;
  }

  .sign-form {
    padding: 20px 16px;
  }

  /* 弹窗与全屏核图器 */
  .dialog {
    max-height: calc(100dvh - 14px);
    width: min(96vw, 620px);
  }

  .dialog-copy { padding: 14px; }
  .dialog-head { padding: 8px 12px; }
  .dialog-head .btn { min-height: 38px; }

  .viewer[open] {
    max-height: 100dvh;
    width: 100vw;
  }

  .viewer .dialog-head {
    padding: max(6px, env(safe-area-inset-top)) 10px 6px;
    min-height: 44px;
  }

  .viewer-side-tabs {
    display: none;
  }

  .viewer-tools {
    padding: 6px max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
    gap: 5px;
    font-size: 11px;
  }

  .viewer-tools .actions {
    width: 100%;
    gap: 4px;
    justify-content: flex-start;
    margin: 0;
    flex-wrap: wrap;
  }

  .viewer-tools .btn {
    flex: 1;
    min-height: 38px;
    padding: 4px 5px;
    font-size: 12px;
  }

  /* 历史弹窗手机端适配 */
  .history-list {
    padding: 12px;
  }

  .history-compare {
    grid-template-columns: 1fr;
    padding: 8px;
  }

  .hc-figure {
    height: 140px;
  }

  .history-tabs {
    width: 100%;
    overflow-x: auto;
  }

  .history-row {
    grid-template-columns: 74px 1fr;
    gap: 10px;
    padding: 9px;
  }

  .thumb-btn img {
    height: 54px;
  }

  /* 进度页与管理表格手机卡片化 */
  .progress-hero {
    grid-template-columns: 1fr;
    gap: 16px;
    padding: 18px 16px;
  }

  .total-cells {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .total-cells > div {
    padding-left: 10px;
  }

  .total-cells b {
    font-size: 24px;
  }

  .progress-controls {
    width: 100%;
    flex-wrap: wrap;
  }

  .progress-controls input:not([type=checkbox]):not([type=file]) {
    width: 100%;
    max-width: none;
    flex: 1 1 100%;
  }

  .progress-sort {
    width: 100%;
  }

  .management {
    padding: 14px 12px;
  }

  .admin-kpis {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .kpi-card {
    padding: 10px 11px;
  }

  .kpi-card b {
    font-size: 22px;
  }

  .admin-tabs {
    width: 100%;
  }

  .admin-tabs button {
    padding: 7px 6px;
    font-size: 13px;
  }

  .grant-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grant-list label, .check { min-height: 38px; }
  .grant-list input, .check input { width: 17px; height: 17px; }
  .form-cols { grid-template-columns: 1fr; }
  .form-end .btn { min-height: 44px; }
  .section-head .btn { min-height: 42px; padding-inline: 11px; }

  .table-filters { gap: 6px; }
  .table-filters input { flex: 1 1 100%; max-width: none; }
  .table-filters select { flex: 1 1 calc(50% - 4px); min-width: 0; }

  .management .table-scroll { overflow: visible; }
  .management table, .management tbody { display: block; width: 100%; }
  .management thead {
    position: absolute;
    clip-path: inset(50%);
    width: 1px;
    height: 1px;
    overflow: hidden;
  }
  .management tr {
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 10px 0;
    gap: 6px 8px;
    border-bottom: 1px solid var(--line);
  }
  .management td {
    border: 0;
    padding: 2px 0;
    font-size: 13px;
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .management td .text-btn { min-height: 36px; }

  /* 协作进度 4 列映射 */
  .people-progress td:first-child { grid-column: 1/-1; }
  .people-progress td:nth-child(2)::before { content: "已完成 "; color: var(--muted); font-weight: 400; }
  .people-progress td:nth-child(3)::before { content: "剩余 "; color: var(--muted); font-weight: 400; }
  .people-progress td:nth-child(4) { grid-column: 1/-1; }
  .person-bar progress { width: min(74%, 250px); }

  /* 人员管理 6 列映射：人员/账号/工序/负荷/状态/管理 */
  .member-table td:first-child { grid-column: 1/-1; }
  .member-table td:nth-child(2)::before { content: "账号 "; color: var(--muted); }
  .member-table td:nth-child(3) { grid-column: 1/-1; }
  .member-table td:nth-child(3)::before { content: "授权工序 "; color: var(--muted); display: block; margin-bottom: 3px; font-size: 11.5px; }
  .member-table td:nth-child(4) { grid-column: 1/-1; }
  .member-table td:nth-child(6) { justify-self: end; }

  /* 图位任务 6 列映射：隐藏桌面批量勾选列，保持紧凑两列卡片 */
  .task-table .col-check { display: none; }
  .task-table td:nth-child(2) { grid-column: 1/-1; }
  .task-table td:nth-child(5)::before { content: "责任人 "; color: var(--muted); display: block; font-size: 11.5px; margin-bottom: 2px; }
  .task-table td:nth-child(5) { grid-column: 1/-1; }
  .task-table td:nth-child(6) { grid-column: 1/-1; justify-self: end; }
  .owner-text-mobile { display: none; }
  .inline-assign { max-width: none; width: 100%; min-height: 40px !important; }

  #notice {
    bottom: calc(64px + env(safe-area-inset-bottom));
    width: min(92vw, 420px);
    text-align: center;
  }
}

/* 横屏窄高手机（如 844x390）下全屏核图器极简压缩，保证图片最大化无遮挡 */
@media (max-height: 460px) and (pointer: coarse) {
  .viewer .dialog-head {
    min-height: 36px;
    padding: 4px 10px;
  }
  .viewer .dialog-head h2 {
    font-size: 13px;
  }
  .viewer .dialog-head .btn {
    min-height: 30px;
    padding: 2px 9px;
  }
  .viewer-tools {
    padding: 4px 10px;
    min-height: 38px;
    flex-wrap: nowrap;
  }
  .viewer-meta {
    display: none;
  }
  .viewer-tools .btn {
    min-height: 32px;
    font-size: 11.5px;
  }
}

@media (pointer: coarse) and (min-width: 761px) and (min-height: 601px) {
  .upload-label.camera-label {
    display: inline-flex !important;
  }
}
