/* 弹窗内的临时选区保持可聚焦，兼容手机浏览器的复制实现。 */
.clipboard-helper { position: fixed; left: 0; top: 0; width: 1px; height: 1px; opacity: 0; padding: 0; pointer-events: none; }
#copy-dialog { width: min(480px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--line); border-radius: 12px; color: var(--ink); }
#copy-dialog::backdrop { background: #16302b55; }
#copy-dialog p { font-size: 13px; color: var(--muted); }
#copy-fallback-value, #generated-url { user-select: text; -webkit-user-select: text; }
body:has(dialog[open]) { overflow: hidden; }
.mobile-account { display: none; }
.upload-management-table table { table-layout: fixed; min-width: 0; }
.upload-management-table td { vertical-align: top; overflow-wrap: anywhere; }
.upload-management-table th:first-child { width: 30%; }
.upload-guide { margin: 0; }
.upload-guide > summary { min-height: 44px; display: flex; align-items: center; color: var(--green); }
.upload-guide .stack { gap: 12px; padding: 8px 0; }
.upload-guide textarea { font-family: Consolas, monospace; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.upload-guide p, .upload-guide li { overflow-wrap: anywhere; }
.product-name { display: flex; align-items: center; gap: 4px; }
.product-name strong { min-width: 0; overflow-wrap: anywhere; }
.product-name > a { min-width: 0; display: inline-flex; align-items: center; min-height: 44px; }
@media (min-width: 801px) {
    .upload-management-table table { table-layout: auto; }
    .product-management-table th:first-child, .product-management-table td:first-child,
    .download-products-table th:first-child, .download-products-table td:first-child,
    .upload-management-table th:first-child, .upload-management-table td:first-child { min-width: 300px; }
    .product-name strong,
    .download-products-table td:first-child > strong,
    .upload-management-table td:first-child > strong { white-space: nowrap; }
    .product-name > a { flex-shrink: 0; }
}
.card.material-sections { padding: 0; overflow: hidden; }
.material-section { min-width: 0; }
.material-section + .material-section { border-top: 1px solid var(--line); }
.material-section .section-heading { gap: 12px; margin: 0; padding: 0 16px; min-height: 44px; background: #fbfcfc; }
.material-section .section-heading h2 { font-size: 14px; overflow-wrap: anywhere; min-width: 0; }
.material-section .section-heading > a { flex-shrink: 0; max-width: 50%; display: inline-flex; align-items: center; min-height: 44px; }
.material-empty { margin-left: 8px; font-size: 12px; font-weight: 400; }
.material-files { list-style: none; padding: 0; margin: 0; }
.material-files li { display: flex; align-items: start; gap: 16px; padding: 8px 16px; border-top: 1px solid var(--line); }
.material-files li > div:first-child { min-width: 0; flex: 1; overflow-wrap: anywhere; }
.material-files strong { font-size: 13px; font-weight: 500; }
.material-files details { margin-top: 2px; }
.material-files p { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.material-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 11px; color: var(--muted); justify-content: flex-end; }
.material-add { display: inline-flex; align-items: center; min-height: 44px; margin-top: 8px; }
.sort-handle { flex-shrink: 0; width: 32px; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--muted); cursor: grab; touch-action: none; user-select: none; font-size: 22px; }
.sort-handle:active { cursor: grabbing; }
.product-management-table tr.sorting { background: #eaf5f1; outline: 1px solid var(--green); }

@media (max-width: 800px) {
    .material-files li { flex-direction: column; gap: 4px; }
    .material-meta { justify-content: flex-start; }
    /* 保证表单和长文本不会撑宽页面，16px 输入字体避免 iPhone 聚焦时自动放大。 */
    main, .workspace, .card, .stack, .form-grid, label, .activity > div { min-width: 0; }
    input:not([type=radio]):not([type=checkbox]), select, textarea { min-width: 0; max-width: 100%; font-size: 16px; }
    p, h1, h2, td, .notice, .account { overflow-wrap: anywhere; }
    .button, .text-button, .row-actions > a, .pagination a { min-height: 44px; }
    .text-button, .row-actions > a, .pagination a { display: inline-flex; align-items: center; }
    /* 手机顶部只占两行：品牌和账号一行，导航一行；窄屏可横滑导航。 */
    .sidebar { padding: 4px 12px 0; border-right: 0; border-bottom: 1px solid var(--line); }
    .sidebar-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
    .sidebar .brand { gap: 8px; font-size: 14px; min-height: 44px; }
    .sidebar .brand-mark { width: 28px; height: 28px; border-radius: 8px; font-size: 19px; }
    .sidebar .brand small { display: none; }
    .mobile-account { display: flex; align-items: center; gap: 10px; min-width: 0; font-size: 12px; color: var(--muted); }
    .mobile-account > span { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .mobile-account .text-button { padding: 0 4px; white-space: nowrap; }
    .sidebar nav { display: flex; flex-wrap: nowrap; overflow-x: auto; gap: 2px; margin-top: 0; scrollbar-width: none; }
    .sidebar nav::-webkit-scrollbar { display: none; }
    .sidebar nav a { flex: 1 0 auto; justify-content: center; min-height: 44px; padding: 8px 10px; border-radius: 6px; }
    .topbar { display: none; }
    .workspace > main { padding-top: 16px; }
    .topbar > span { min-width: 0; }
    .account { gap: 12px; }
    .compact-heading { flex-wrap: wrap; }
    .compact-heading > a { min-height: 44px; display: inline-flex; align-items: center; }
    .compact-filter { gap: 8px; }
    .compact-filter input { flex: 1; width: 0; max-width: none; }
    .compact-filter .muted { flex-basis: 100%; }
    .activity-meta { max-width: 105px; }
    .activity > div:not(.activity-meta) { flex: 1; }
    .activity p { max-width: none; }
    .public-header { padding: 20px; }
    footer { padding: 20px 18px; }
    #toast { max-width: calc(100vw - 32px); width: max-content; padding: 12px 18px; text-align: center; }

    /* 产品表保留名称、文件和右侧复制按钮，无需横向滚动即可完成授权。 */
    .download-products-table table, .product-management-table table { min-width: 0; table-layout: fixed; }
    .download-products-table th:nth-child(2), .download-products-table td:nth-child(2),
    .download-products-table th:nth-child(4), .download-products-table td:nth-child(4),
    .product-management-table th:nth-child(2), .product-management-table td:nth-child(2),
    .product-management-table th:nth-child(3), .product-management-table td:nth-child(3) { display: none; }
    .download-products-table th, .download-products-table td,
    .product-management-table th, .product-management-table td { padding: 8px; font-size: 12px; }
    .download-products-table .copy-column { position: static; width: 102px; box-shadow: none; }
    .download-products-table .compact-button { min-height: 44px; padding: 7px 10px; }
    .download-products-table .single-line { max-width: 100%; }
    .product-management-table th:first-child { width: 34%; }
    .product-management-table th:nth-child(4) { width: 24%; }
    .product-management-table .badge { margin: 0; }
    .product-management-table .row-actions { min-width: 0; gap: 0 12px; }
    .product-management-table .row-actions a, .product-management-table .row-actions button { font-size: 12px; }

    /* 记录类长表在手机上改成带字段名的条目，完整保留授权和日志信息。 */
    .responsive-records table, .responsive-records tbody { display: block; min-width: 0; }
    .responsive-records thead { display: none; }
    .responsive-records tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; padding: 16px; border-bottom: 1px solid var(--line); }
    .responsive-records tr:last-child { border-bottom: 0; }
    .responsive-records td { display: block; border: 0; padding: 0; min-width: 0; font-size: 13px; }
    .responsive-records td::before { content: attr(data-label); display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; }
    .responsive-records td:last-child { grid-column: 1 / -1; }
    .responsive-records td time, .responsive-records .single-line { white-space: normal; }
    .responsive-records .row-actions { gap: 20px; }

    /* 弹窗可在软键盘弹出后滚动，关闭和确认按钮保持适合触摸的大小。 */
    #grant-dialog, #copy-dialog { padding: 18px; max-height: 90vh; max-height: 90dvh; overflow-y: auto; overscroll-behavior: contain; }
    #grant-dialog .mode-options { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    #grant-dialog .mode-option { min-width: 0; padding: 12px 8px; gap: 7px; }
    #grant-dialog .mode-option small { font-size: 11px; }
    #grant-dialog .stack { gap: 14px; }
    .form-actions > .button { flex: 1; }
}

/* 公共文件的关联选择和操作在窄屏内换行，保持触摸入口可用。 */
.shared-link-form { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.shared-link-form select { flex: 1; width: auto; min-width: 0; max-width: 100%; }
.shared-product-options { display: grid; gap: 4px; }
.shared-product-options label { display: flex; align-items: center; gap: 8px; min-height: 44px; overflow-wrap: anywhere; }
.shared-product-options input[type=checkbox] { flex-shrink: 0; }
.folder-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 10px 0; }
.folder-toolbar input:not([type=hidden]), .folder-toolbar select { flex: 1; min-width: 0; width: auto; max-width: 360px; }
.folder-breadcrumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; overflow-wrap: anywhere; }
.folder-breadcrumbs a { min-height: 44px; display: inline-flex; align-items: center; }
.folder-links { margin-bottom: 12px; }
.drive-files li:first-child { border-top: 0; }
.customer-files li { display: grid; grid-template-columns: minmax(0, 1fr) 80px 64px; align-items: center; gap: 12px; min-height: 46px; padding: 6px 16px; }
.customer-file-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.customer-file-name > span { min-width: 0; overflow-wrap: anywhere; }
.customer-file-icon { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
.customer-file-icon.folder { color: #b18625; }
.customer-file-size { text-align: right; font-size: 11px; white-space: nowrap; }
.customer-files .download-file-form { margin: 0; }
.customer-files .download-file-form .button { width: 100%; min-height: 32px; padding: 5px 10px; }
.customer-files details { margin-left: 26px; }
@media (max-width: 800px) {
    .customer-files li { grid-template-columns: minmax(0, 1fr) 64px 58px; gap: 8px; padding: 6px 10px; }
    .customer-files .download-file-form .button { min-height: 40px; }
}
.material-meta a, .material-meta .text-button { display: inline-flex; align-items: center; min-height: 32px; }
@media (max-width: 800px) {
    .shared-link-form label { flex-basis: 100%; }
    .material-meta a, .material-meta .text-button { min-height: 44px; }
}
/* 操作记录采用紧凑表格，手机横向滚动保留各列。 */
.log-table td{padding:6px 14px;vertical-align:top;line-height:1.5}
.log-table .log-detail{overflow-wrap:anywhere;min-width:220px}
.compact-heading .button.danger{color:#b54d48}
@media(max-width:800px){.log-table table{min-width:620px}.log-table td{padding:6px 10px}}
.log-table table{min-width:980px}
.log-table td:nth-child(4){min-width:130px;max-width:180px;overflow-wrap:anywhere}
.log-table td:nth-child(5),.log-table td:nth-child(6){min-width:120px;overflow-wrap:anywhere}
