/* 模型库视图独有的样式：筛选行、模型卡片封面、3D 视口与动作控制面板。其余沿用 library.css / viewer.css。 */
.model-filters { display: grid; gap: 4px; margin-bottom: 22px; }
.model-filter-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.model-filter-label { flex-shrink: 0; width: 34px; padding-left: 2px; font-size: 11px; color: var(--muted); }
.model-filter-row .filters { flex: 1; min-width: 0; padding-block: 2px; }

.model-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.model-cover { aspect-ratio: 1 / .84; background: radial-gradient(circle at 50% 38%, #fff, #e9eef5 72%); }
.model-cover img { position: relative; object-fit: contain; }
.model-cover.surface-cover img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: block; }
.model-cover:has(img:not([hidden])) .cover-fallback { color: transparent; }
.model-cover .cover-fallback { background: radial-gradient(circle at 50% 38%, #fff, #e9eef5 72%); color: #b3c0d4; }
.model-ref { display: block; margin: 4px 0 11px; font-size: 10px; color: var(--muted); overflow-wrap: anywhere; }
.model-card .card-bottom .card-open { color: var(--blue); }
#models-library .library-heading { flex-wrap: wrap; }
.library-heading .model-library-actions { gap: 10px; min-width: 0; margin-left: auto; }
.model-library-actions .search-box { flex: 1; min-width: 0; }
#model-import-open { flex-shrink: 0; min-height: 38px; }
@media(max-width:720px) {
  .library-heading .model-library-actions { width: 100%; }
  .model-library-actions .search-box { width: auto; }
  #model-import-open { min-height: 40px; }
}
.model-import { width: min(600px, calc(100vw - 32px)); max-height: calc(100dvh - 40px); background: #fff; border-radius: 20px; font-family: "Segoe UI", "Microsoft YaHei", sans-serif; font-weight: 400; }
.model-import::backdrop { background: #25344b88; backdrop-filter: blur(5px); }
.model-import-header { display: flex; align-items: center; gap: 16px; padding: 28px 30px 24px; }
.model-import-symbol { display: grid; place-items: center; width: 52px; height: 52px; flex-shrink: 0; border-radius: 13px; background: #eaf0ff; color: var(--blue); }
.model-import-symbol svg { width: 29px; height: 29px; }
.model-import-header h2 { margin: 0 0 5px; font-size: 22px; font-weight: 600; letter-spacing: -.5px; }
.model-import-header p { font-size: 13px; color: #69758a; line-height: 1.6; }
.model-import-header .icon-button { align-self: flex-start; margin-left: auto; flex-shrink: 0; border: 0; color: #77849a; }
.model-import form { margin: 0; }
.model-import-content { padding: 0 30px 26px; }
.model-dropzone { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 7px; width: 100%; min-height: 184px; padding: 22px; border: 1px dashed #9db5fa; border-radius: 12px; background: #f6f8ff; color: var(--ink); font: inherit; transition: background .15s, border-color .15s; }
.model-dropzone:hover, .model-dropzone.dragover { background: #edf2ff; border-color: var(--blue); }
.model-dropzone:focus-visible { outline: 3px solid #b5c7ff; outline-offset: 3px; }
.model-upload-icon { display: block; color: var(--blue); margin-bottom: 7px; }
.model-upload-icon svg { width: 34px; height: 34px; }
.model-dropzone strong { max-width: 100%; font-size: 17px; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
#model-file-action { font-size: 15px; color: #6c788c; }
#model-file-action b { color: var(--blue); font-weight: 600; }
.model-dropzone small { font-size: 12px; color: #69758a; margin-top: 7px; }
.model-name-label { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin: 23px 0 9px; }
.model-name-label label { font-size: 14px; font-weight: 600; }
.model-name-label span { font-size: 12px; color: #7b8698; }
.model-import input[type=text] { width: 100%; min-width: 0; height: 44px; padding: 10px 14px; border: 1px solid #d9e0ec; border-radius: 9px; color: var(--ink); background: #fff; font: inherit; font-size: 14px; }
.model-import input[type=text]:focus { outline: 3px solid #345fe81a; border-color: #94adf4; }
.model-classification { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 20px; }
.model-classification > div { min-width: 0; }
.model-classification label { display: block; margin-bottom: 9px; font-size: 14px; font-weight: 600; }
.model-select { position: relative; min-width: 0; }
.model-select-trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid #d9e0ec; border-radius: 9px; background: #fff; color: var(--ink); font: inherit; font-size: 14px; text-align: left; }
.model-select-trigger::after { content: ''; width: 7px; height: 7px; flex-shrink: 0; margin: -4px 2px 0; border-right: 1.5px solid #7b8698; border-bottom: 1.5px solid #7b8698; transform: rotate(45deg); }
.model-select-trigger:hover { border-color: #aebee0; background: #fafbff; }
.model-select-trigger:focus-visible, .model-select-trigger[aria-expanded=true] { outline: 3px solid #345fe81a; border-color: #94adf4; }
.model-select-trigger[aria-expanded=true]::after { transform: rotate(225deg); margin-top: 4px; border-color: var(--blue); }
.model-select-menu { position: absolute; z-index: 5; bottom: calc(100% + 8px); left: 0; width: 100%; max-height: min(248px, 40dvh); overflow-y: auto; overscroll-behavior: contain; padding: 5px; border: 1px solid #dce4f1; border-radius: 12px; background: #fff; box-shadow: 0 8px 28px #25344b24; scrollbar-width: thin; scrollbar-color: #c7d2e6 transparent; }
.model-select-option { display: flex; align-items: center; justify-content: space-between; gap: 6px; min-height: 36px; padding: 8px 10px; border-radius: 7px; color: var(--ink); font-size: 13px; line-height: 1.5; cursor: pointer; }
.model-select-option:hover, .model-select-option.active { background: #f1f4fa; }
.model-select-option[aria-selected=true] { background: #edf2ff; color: var(--blue); font-weight: 600; }
.model-select-option[aria-selected=true]::after { content: ''; width: 5px; height: 9px; flex-shrink: 0; margin-right: 3px; border-right: 1.5px solid currentColor; border-bottom: 1.5px solid currentColor; transform: rotate(45deg); }
#model-import-status { margin-top: 16px; padding: 10px 13px; border-radius: 8px; background: #edf2ff; color: #345fe8; font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
#model-import-status[data-state=error] { background: #fff2f1; color: #b43c32; }
.model-import-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 30px; border-top: 1px solid #e5eaf2; }
.model-import-footer > span { color: #7b8698; font-size: 11px; }
.model-import-footer > div { display: flex; gap: 10px; }
.model-import-footer button { min-height: 40px; padding: 9px 17px; font: inherit; font-size: 13px; font-weight: 500; gap: 9px; border-radius: 9px; }
.model-import-footer svg { width: 16px; height: 16px; }
.model-import button:disabled { opacity: .5; cursor: not-allowed; }
.model-import[aria-busy=true] button:disabled { cursor: wait; }
@media(max-width:600px) {
  .model-import { max-height: calc(100dvh - 24px); border-radius: 16px; }
  .model-import-header { padding: 22px 20px; gap: 12px; }
  .model-import-symbol { width: 42px; height: 42px; border-radius: 11px; }
  .model-import-symbol svg { width: 25px; height: 25px; }
  .model-import-header h2 { font-size: 20px; }
  .model-import-header p { font-size: 12px; }
  .model-import-content { padding: 0 20px 22px; }
  .model-dropzone { min-height: 172px; padding: 18px 12px; }
  .model-dropzone strong { font-size: 16px; }
  .model-dropzone small { font-size: 11px; }
  .model-import-footer { padding: 16px 20px; flex-wrap: wrap; }
  .model-import-footer > span { width: 100%; }
  .model-import-footer > div { width: 100%; }
  #model-import-submit { flex: 1; }
}
@media(prefers-reduced-motion:reduce) { .model-dropzone { transition: none; } }
.model-import > .lin-companion { display: none; }
@media(max-width:720px) { .model-detail:has([data-clip]) > .lin-companion { display: none; } }
.model-import-preview { position: fixed; left: -10000px; top: 0; width: 480px; height: 400px; }
#model-import-queue { margin-top: 20px; }
.model-queue-heading { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; font-size: 12px; }
.model-queue-heading > span { color: #69758a; }
.model-queue-list { max-height: 180px; overflow-y: auto; overscroll-behavior: contain; border: 1px solid #dce4f1; border-radius: 10px; scrollbar-width: thin; }
.model-queue-row { display: flex; border-bottom: 1px solid #edf0f6; }
.model-queue-row:last-child { border-bottom: 0; }
.model-queue-row button { border: 0; background: transparent; color: var(--ink); font: inherit; text-align: left; cursor: pointer; }
.model-queue-row [data-entry] { flex: 1; min-width: 0; padding: 10px 12px; }
.model-queue-row [data-entry] > span { display: block; font-size: 13px; overflow-wrap: anywhere; }
.model-queue-row small { display: block; margin-top: 4px; font-size: 11px; color: #69758a; overflow-wrap: anywhere; }
.model-queue-row [data-remove] { display: grid; place-items: center; flex-shrink: 0; width: 36px; color: #69758a; }
.model-queue-row svg { width: 14px; height: 14px; }
.model-queue-row button:hover { background: #f1f4fa; }
.model-queue-row [aria-pressed=true] { background: #edf2ff; color: var(--blue); }
.model-queue-row button:focus-visible { outline: 2px solid var(--blue); outline-offset: -2px; }
.model-queue-row[data-state=done] small { color: #208465; }
.model-queue-row[data-state=error] small { color: #b43c32; }
.model-import:has(#model-import-queue:not([hidden])) .model-dropzone { min-height: 110px; padding-block: 16px; gap: 6px; }
.model-import:has(#model-import-queue:not([hidden])) .model-upload-icon { display: none; }
.model-import:has(#model-import-queue:not([hidden])) .model-import-footer { position: sticky; bottom: 0; z-index: 6; background: #fff; }
.model-materials { margin-top: 20px; }
.model-materials > button { font: inherit; font-size: 13px; }
#model-material-preview { height: 220px; margin-top: 14px; overflow: hidden; border: 1px solid #e5eaf2; border-radius: 12px; }
.model-material-row { padding-top: 16px; }
.model-material-row h3 { margin: 0 0 10px; font-size: 13px; overflow-wrap: anywhere; }
.model-material-slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.model-material-slots label { display: block; margin-bottom: 7px; font-size: 12px; color: #69758a; }
.model-texture-select summary { cursor: pointer; list-style: none; font-size: 12px; overflow-wrap: anywhere; }
.model-texture-select summary::-webkit-details-marker { display: none; }
.model-texture-select .model-select-option { width: 100%; border: 0; background: transparent; text-align: left; font: inherit; font-size: 12px; overflow-wrap: anywhere; }
.model-texture-select .model-select-option:hover, .model-texture-select .model-select-option[aria-pressed=true] { background: #edf2ff; color: var(--blue); }
.model-materials[aria-busy=true] { pointer-events: none; opacity: .6; }
.model-import:has(#model-materials-body:not([hidden])) .model-import-footer { position: sticky; bottom: 0; z-index: 6; background: #fff; }
@media(max-width:600px) { .model-material-slots { grid-template-columns: 1fr; } }
#model-title, .model-detail .viewer-header > div:first-child { min-width: 0; overflow-wrap: anywhere; }
.model-detail .viewer-tools { flex-shrink: 0; }

/* ---------- 详情弹窗 ---------- */
.model-detail { width: min(1240px, 96vw); height: min(820px, 94dvh); max-width: 96vw; max-height: 94dvh; background: var(--panel); }
.model-detail .viewer-header h2 { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; font-size: 18px; }
.model-detail .viewer-header .eyebrow { color: var(--blue); }
#model-ref { font-size: 11px; font-weight: 400; color: var(--muted); }
#model-download { gap: 8px; }
#model-download svg { width: 14px; height: 14px; }
.model-detail [data-close] svg { width: 16px; height: 16px; }
.model-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 18px; padding: 18px; }

.model-stage { position: relative; min-height: 0; overflow: hidden; border-radius: 11px; background: #eef2f7; }
.model-stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.model-stage[data-tool=pan] canvas { cursor: move; }
.model-stage[data-tool=move] canvas { cursor: grab; }
.model-stage.dragging canvas { cursor: grabbing; }
.model-stage.static > :not(.model-note) { display: none; }
.model-stage[data-kind=hdri] [data-mode=pan],
.model-stage[data-kind=hdri] [data-mode=move],
.model-stage[data-kind=hdri] [data-act=grid],
.model-stage[data-kind=hdri] [data-act=wire],
.model-stage[data-kind=hdri] .model-tools hr,
.model-stage[data-kind=hdri] .model-axes { display: none; }
.model-stage:fullscreen { border-radius: 0; }

.model-tools { position: absolute; left: 12px; top: 12px; display: flex; flex-direction: column; gap: 2px; padding: 6px; background: #fffffff2; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 4px 16px #3443680d; }
.model-tools button, .model-views button { display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 7px; background: transparent; color: #4b5567; font-size: 11px; white-space: nowrap; }
.model-tools button:hover, .model-views button:hover { background: #f1f4f9; color: #3b527e; }
.model-tools button[aria-pressed=true], .model-views button.active { background: #e8eefc; color: var(--blue); }
.model-tools svg { width: 17px; height: 17px; }
.model-tools hr { width: 100%; margin: 4px 0; border: 0; border-top: 1px solid var(--line); }
.model-views { position: absolute; right: 12px; top: 12px; display: flex; gap: 2px; padding: 4px; background: #fffffff2; border: 1px solid var(--line); border-radius: 9px; }
.model-axes { position: absolute; right: 14px; bottom: 12px; width: 56px; height: 56px; pointer-events: none; overflow: visible; font: 600 9px Arial, sans-serif; }
.model-hint { position: absolute; left: 14px; bottom: 12px; right: 84px; font-size: 10px; color: #7b879a; pointer-events: none; }
.model-note { position: absolute; inset: 0; display: grid; place-items: center; padding: 30px; text-align: center; color: var(--muted); font-size: 12px; }
.model-textures { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; width: min(640px, 100%); }
.model-textures figure { margin: 0; }
.model-textures img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.model-textures figcaption { margin-top: 6px; font-size: 11px; }

/* 底部留白：Lin 会缩小后停在弹窗右下角（lin.js），避免挡住最后几项控件 */
.model-panel { display: flex; flex-direction: column; min-height: 0; overflow: auto; padding: 2px 4px 96px 0; }
.model-panel h3 { font-size: 15px; margin-bottom: 4px; }
.model-panel section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.model-panel section:last-of-type { border-bottom: 0; }
.model-panel h4 { display: flex; align-items: center; gap: 7px; margin: 0 0 10px; font-size: 11px; font-weight: 500; color: var(--muted); }
.model-count { font-size: 10px; padding: 1px 6px; border-radius: 4px; background: #f1f4f9; color: #647187; }
.model-empty-note { font-size: 12px; line-height: 1.9; color: var(--muted); margin-top: 10px; }
.model-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.model-chips .filter { background: #f5f7fa; }
.model-chips .filter.active { background: #e8eefc; }
.model-chips [data-clip] { max-width: 100%; white-space: normal; overflow-wrap: anywhere; text-align: left; }
.model-actions { display: grid; grid-template-columns: 1.4fr 1fr; gap: 9px; margin-top: 12px; }
.model-actions button { gap: 7px; }
.model-actions svg { width: 14px; height: 14px; }
.model-actions .primary-button svg { fill: currentColor; }
.model-actions .primary-button.playing { background: #2443b6; }

.model-panel input[type=range] { width: 100%; margin: 0; accent-color: var(--blue); }
.model-joint { display: grid; grid-template-columns: 74px minmax(0, 1fr) 58px; gap: 8px; align-items: center; margin-bottom: 7px; font-size: 11px; }
.model-joint label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-range { display: grid; grid-template-columns: 1fr 1fr; font-size: 9px; color: #a3acbb; }
.model-range input { grid-column: 1 / -1; }
.model-range span:last-child { text-align: right; }
.model-joint input[type=number] { width: 100%; padding: 5px 6px; border: 1px solid #e1e6ee; border-radius: 6px; background: #fff; color: var(--ink); font-size: 11px; text-align: right; }
.model-joint input[type=number]:focus { outline: none; border-color: #94adf4; box-shadow: 0 0 0 3px #345fe810; }
.model-param { display: grid; grid-template-columns: 74px minmax(0, 1fr) 58px; gap: 8px; align-items: center; margin-bottom: 9px; font-size: 11px; }
.model-param output { text-align: right; font-size: 11px; color: #4b5567; }
.model-switch { position: relative; display: flex; align-items: center; justify-content: space-between; padding: 6px 0; font-size: 11px; cursor: pointer; }
.model-switch input { position: absolute; opacity: 0; pointer-events: none; }
.model-switch i { position: relative; width: 32px; height: 18px; border-radius: 9px; background: #d5dce7; transition: background .2s; }
.model-switch i::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0002; transition: transform .2s; }
.model-switch input:checked + i { background: var(--blue); }
.model-switch input:checked + i::after { transform: translateX(14px); }
.model-switch input:focus-visible + i { outline: 3px solid #89a7ff; outline-offset: 2px; }
.model-paints { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 11px; }
.model-paints label { display: flex; align-items: center; gap: 7px; cursor: pointer; }
.model-paints input { width: 26px; height: 26px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; cursor: pointer; }
.model-meta { margin-top: auto; padding-top: 14px; font-size: 10px; color: #a3acbb; }

@media(min-width:1700px) { .model-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media(max-width:1200px) {
  .model-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .model-body { grid-template-columns: minmax(0, 1fr) 290px; gap: 14px; padding: 14px; }
}
@media(max-width:960px) {
  .model-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .model-detail { height: 94dvh; }
  .model-body { grid-template-columns: 1fr; grid-template-rows: minmax(320px, 58dvh) auto; overflow: auto; }
  .model-panel { overflow: visible; }
  .model-tools { flex-direction: row; flex-wrap: wrap; right: 12px; }
  .model-tools button { font-size: 0; gap: 0; padding: 7px; }
  .model-tools hr { width: auto; margin: 0 3px; border-top: 0; border-left: 1px solid var(--line); }
  .model-views { top: auto; bottom: 12px; right: 76px; }
  .model-hint { display: none; }
}
@media(max-width:720px) {
  .model-filter-row { align-items: flex-start; }
  .model-filter-label { padding-top: 9px; }
  .model-detail { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; border: 0; }
  .model-detail .viewer-header h2 { font-size: 14px; gap: 8px; }
  .model-body { padding: 10px; grid-template-rows: minmax(280px, 52dvh) auto; }
  .model-views { left: 12px; right: auto; }
}
@media(max-width:480px) { .model-grid { grid-template-columns: 1fr; } }
