/* Reference basket and material picker: mockups 14 and 15. */
body.tray #workspaceDock[data-anchor] {
  inset: auto 14px calc(15px + env(safe-area-inset-bottom));
  width: auto; max-width: none; padding: 0; transform: none; z-index: 43;
  border: 1px solid var(--line); border-radius: 18px;
  background: var(--bg2); box-shadow: 0 8px 28px rgb(30 35 45 / .08);
}
body #workspaceDock[data-anchor] #tray {
  width: 100%; max-width: none; max-height: calc(100dvh - var(--hdr) - 36px);
  border-radius: 18px; background: var(--bg2);
}
#tray .tray-heading {
  position: relative; display: flex; flex: none; align-items: center; gap: 16px;
  min-height: 67px; padding: 17px 18px 10px;
}
#tray .tray-heading::before {
  content: ""; position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  width: 50px; height: 6px; border-radius: 8px; background: var(--line2);
}
#tray .dock-title { flex: 1; gap: 9px; font-size: 22px; line-height: 30px; font-weight: 650; }
#tray svg { flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#tray .tray-basket-icon { width: 28px; height: 28px; color: var(--ac); }
#tray #trayTitle { position: static; width: auto; height: auto; clip-path: none; overflow: visible; }
#tray #trayN { min-width: 0; height: auto; margin-left: -6px; padding: 0; border: 0; border-radius: 0; background: none; color: inherit; font: inherit; }
#tray #trayMin { justify-content: center; flex: none; width: 36px; min-height: 36px; padding: 6px; color: var(--tx2); border-radius: 8px; }
#tray #trayMin svg { width: 24px; height: 24px; }
#tray #trayMin:hover { background: var(--sf); }
#tray .tray-b { flex: 0 1 auto; gap: 12px; padding: 0 16px 18px; }
#tray .dock-materials { container-type: normal; }
#tray .dock-block { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 28px; padding-bottom: 14px; }
#tray .tray-selection { display: flex; align-items: center; gap: 16px; min-width: 0; max-width: 100%; }
#tray .tray-items { gap: 16px; min-width: 0; max-width: min(52vw, 880px); padding: 0; }
#tray .tray-items > div { width: 112px; height: 108px; }
#tray .tray-items img { width: 100%; height: 100%; border: 0; border-radius: 12px; }
#tray .tray-items em { display: none; }
#tray .tray-items [data-k] { top: 8px; right: 8px; width: 25px; height: 25px; opacity: 1; border: 0; background: rgb(55 58 65 / .45); color: #fff; font-size: 19px; }
#tray .tray-items [data-k]:hover { background: var(--ac); }
#tray .tray-pair { left: 7px; top: 8px; }
#tray #trayAdd { display: grid; place-items: center; flex: none; width: 110px; height: 108px; padding: 0; border: 2px dashed var(--line2); border-radius: 12px; background: var(--sf); color: var(--tx2); }
#tray #trayAdd svg { width: 32px; height: 32px; }
#tray #trayAdd:hover { border-color: var(--ac); color: var(--ac); }
#tray .tg-add { flex-wrap: nowrap; gap: 22px; margin: 0; }
#tray .tg-add > button, #tray #tgMore > summary {
  gap: 10px; width: 134px; min-height: 67px; padding: 12px 16px;
  border: 1.5px solid var(--line2); border-radius: 22px; background: transparent;
  color: var(--tx); font-size: 21px; font-weight: 550; white-space: nowrap;
}
#tray .tg-add > button:first-child { color: var(--ac); border-color: var(--ac); background: color-mix(in srgb, var(--ac) 3%, var(--bg2)); }
#tray .tg-add > button:hover, #tray #tgMore > summary:hover { border-color: var(--ac); color: var(--ac); background: var(--acs); }
#tray #tgAddRow svg { display: block; width: 26px; height: 26px; }
#tray #tgMore { position: relative; flex: none; width: auto; }
#tray #tgMore summary svg { fill: currentColor; }
#tray #tgMore > div { position: absolute; z-index: 3; bottom: calc(100% + 8px); right: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 240px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); box-shadow: var(--sh3); }
#tray #tgMore > div button { min-height: 38px; padding: 8px; font-size: 14px; }
#tray #tgMore[open] > div { position: static; margin-top: 8px; width: 240px; max-width: calc(100vw - 56px); }
#tray .tg-add:has(#tgMore[open]) { align-items: flex-start; }
#tray #tgMore[open] { max-width: 100%; }
#tray #trayClear { grid-column: 1 / -1; color: var(--ac); }
#tray #tgEmpty { color: var(--mu); font-size: 14px; }
#tray .dock-combo, #tray .quick-workflow { margin: 0; padding: 0; border: 0; border-radius: 14px; background: var(--sf); }
#tray :is(.dock-combo, .quick-workflow) > summary {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 51px;
  padding: 12px 18px; list-style: none; cursor: pointer; color: var(--tx); font-size: 18px;
}
#tray :is(.dock-combo, .quick-workflow) > summary::-webkit-details-marker { display: none; }
#tray :is(.dock-combo, .quick-workflow) > summary svg { width: 20px; height: 20px; }
#tray :is(.dock-combo, .quick-workflow) > summary b { font-weight: 600; }
#tray .tray-collapsed { margin-left: -7px; color: var(--tx2); font-size: 16px; }
#tray :is(.dock-combo, .quick-workflow) > summary::after { content: ""; flex: none; width: 8px; height: 8px; margin-left: auto; border: solid var(--mu); border-width: 0 1.7px 1.7px 0; transform: translateY(-2px) rotate(45deg); }
#tray :is(.dock-combo, .quick-workflow)[open] > summary::after { transform: translateY(2px) rotate(225deg); }
#tray :is(.dock-combo, .quick-workflow)[open] .tray-collapsed { display: none; }
#tray :is(.dock-combo, .quick-workflow) > :not(summary) { margin-left: 18px; margin-right: 18px; }
#tray .dock-combo .tray-act { flex-wrap: wrap; padding-bottom: 16px; }
#tray .quick-workflow .dock-actions { padding: 0 0 16px; border: 0; }
#tray .quick-help { font-size: 13px; }
#tray .basket-next { gap: 10px; min-height: 78px; padding: 15px 28px 15px 32px; background: var(--bg2); }
#tray .basket-next > svg { width: 22px; height: 22px; color: var(--tx2); }
#tray .basket-next p { flex: 1; min-width: 0; font-size: 17px; line-height: 1.5; overflow-wrap: anywhere; }
#tray #tgStudio { display: flex; align-items: center; justify-content: center; gap: 16px; min-width: 148px; min-height: 47px; padding: 10px 24px; border-radius: 12px; background: var(--ac); color: #fff; font-size: 18px; box-shadow: none; }
#tray #tgStudio::after { content: "→"; font-size: 24px; line-height: 1; font-weight: 400; }

/* The picker has its own scrolling grid; the heading and selected strip stay visible. */
#pk { padding: 32px 24px; background: rgb(26 28 33 / .36); backdrop-filter: blur(3px); }
#pk .pk-box { width: min(1052px, 100%); height: 737px; max-height: calc(100dvh - 64px); margin-top: 32px; border-radius: 13px; background: var(--bg2); }
#pk .pk-h { display: flex; flex: none; gap: 23px; min-height: 98px; padding: 28px 28px 26px 36px; border: 0; }
#pk #pkT { flex: 1; min-width: 0; font-size: 25px; line-height: 1.35; overflow-wrap: anywhere; }
#pk .pk-search { display: flex; align-items: center; gap: 10px; flex: 0 1 542px; min-width: 0; height: 42px; padding: 0 13px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); color: var(--mu); }
#pk .pk-search:focus-within { border-color: var(--ac); box-shadow: 0 0 0 2px var(--acs); }
#pk .pk-search svg { flex: none; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
#pk #pkQ { flex: 1; width: 100%; min-width: 0; height: 100%; padding: 0; border: 0; border-radius: 0; outline: 0; background: transparent; box-shadow: none; font-size: 16px; }
#pk #pkQ::placeholder { color: var(--mu); }
#pk .pk-search kbd { flex: none; padding: 0; border: 0; background: none; color: var(--mu); font-size: 13px; box-shadow: none; }
#pk :is(#pkDone, #pkDoneBottom) { flex: none; min-width: 109px; min-height: 42px; padding: 9px 18px; border-radius: 13px; background: var(--ac); color: #fff; font-size: 17px; white-space: nowrap; box-shadow: none; }
#pk #pkX { flex: none; width: 32px; min-height: 40px; padding: 0; font-size: 20px; color: var(--mu); }
#pk .pk-bar { flex: none; gap: 9px; margin: 0 36px 28px; overflow: visible; }
#pk .pk-cats { gap: 8px; flex: 0 1 auto; padding: 0; }
#pk .pk-cats .chip, #pk #pkFavOnly, #pkMore > summary { min-height: 38px; padding: 7px 14px; border: 1px solid transparent; border-radius: 12px; background: var(--sf); color: var(--mu); font-size: 16px; line-height: 22px; white-space: nowrap; }
#pk .pk-cats .chip.on, #pk #pkFavOnly.on { border-color: var(--ac); background: transparent; color: var(--ac); }
#pk .pk-cats i { display: none; }
#pk #pkPoseTypes { margin: 0 36px 12px; }
#pkMore { position: relative; flex: none; }
#pkMore > summary { display: flex; align-items: center; gap: 7px; list-style: none; cursor: pointer; }
#pkMore > summary::-webkit-details-marker { display: none; }
#pkMore > summary svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; }
#pkMore[open] > summary { border-color: var(--line2); color: var(--tx); }
#pk .pk-more-panel { position: absolute; z-index: 2; top: calc(100% + 8px); right: 0; width: min(400px, calc(100vw - 64px)); max-height: 45dvh; overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--bg2); box-shadow: var(--sh3); }
#pk .pk-types, #pkSourceCats { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; }
#pkSourceCats { margin-top: 10px; }
#pk .pk-types button { min-height: 36px; border-radius: 8px; }
#pk .pk-types button.on { background: var(--acs); color: var(--ac); }
#pk #pkG { flex: 1; min-height: 0; align-content: start; grid-template-columns: repeat(6, minmax(0, 1fr)); grid-auto-rows: max-content; gap: 14px; padding: 0 36px 14px; overscroll-behavior: contain; scrollbar-width: thin; }
#pk #pkG button { display: block; min-width: 0; align-self: start; padding: 0; border: 1.5px solid transparent; border-radius: 13px; background: var(--sf); overflow: hidden; }
#pk #pkG img { display: block; width: 100%; height: auto; aspect-ratio: 1.02; border-radius: 11px; background: transparent; box-shadow: none; object-fit: cover; }
#pk #pkG button:is(.pose,.depth,.costume,.anime,.dyn) img { object-fit: contain; }
#pk #pkG button > span { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
#pk #pkG button.on { border-color: color-mix(in srgb, var(--ac) 20%, var(--bg2)); background: var(--acs); }
#pk #pkG button.on img { mix-blend-mode: multiply; }
[data-theme=dark] #pk #pkG button.on img { mix-blend-mode: normal; }
#pk #pkG button.on::after { top: 5px; right: 5px; width: 25px; height: 25px; box-shadow: 0 0 0 2px var(--bg2); }
#pk #pkG button:hover { border-color: var(--ac); }
#pk #pkG > .fine { grid-column: 1 / -1; margin: 40px 0; text-align: center; }
#pk .pk-footer { display: flex; flex: none; align-items: center; gap: 26px; min-height: 85px; padding: 14px 36px; border-top: 1px solid var(--line); }
#pkSelectedCount { flex: none; margin: 0; font-size: 17px; color: var(--tx2); }
#pkSelectedCount b { color: var(--ac); font-weight: 500; }
#pkSelected { display: flex; flex: 1; gap: 14px; min-width: 0; padding: 3px 6px 3px 0; overflow-x: auto; scrollbar-width: thin; }
#pkSelected > button { position: relative; display: block; flex: none; width: 52px; height: 52px; padding: 0; border-radius: 8px; background: var(--sf); }
#pkSelected img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; }
#pkSelected [data-type=pose], #pkSelected [data-type=depth] { object-fit: contain; }
#pkSelected > button::after { content: "×"; position: absolute; right: -4px; top: -4px; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: var(--sf2); color: var(--tx2); font: 17px/1 var(--sans); }
#pk #pkDoneBottom { min-width: 134px; }
#pk :is(button, summary):focus-visible, #tray :is(button, summary):focus-visible { outline: 2px solid var(--ac); outline-offset: 3px; }

@media (max-width: 1100px) {
  #tray .tg-add { gap: 10px; }
  #tray .tg-add > button, #tray #tgMore > summary { width: 112px; min-height: 56px; padding: 10px 12px; font-size: 18px; border-radius: 16px; }
  #pk .pk-h { gap: 14px; }
  #pk #pkT { font-size: 21px; }
  #pk .pk-search { flex-basis: 45%; }
  #pk #pkG { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  #pk .pk-cats .chip, #pkMore > summary { padding-inline: 10px; font-size: 14px; }
}
@media (max-width: 767px) {
  body.tray #workspaceDock[data-anchor] { inset: auto 8px calc(8px + env(safe-area-inset-bottom)); border-radius: 16px; }
  body #workspaceDock[data-anchor] #tray { max-height: calc(100dvh - var(--hdr) - 24px); border-radius: 16px; }
  #tray .tray-heading { min-height: 56px; padding: 14px 12px 5px; }
  #tray .tray-heading::before { top: 7px; width: 38px; height: 4px; }
  #tray .dock-title { gap: 6px; font-size: 18px; }
  #tray .tray-basket-icon { width: 24px; height: 24px; }
  #tray .tray-b { padding: 4px 12px 12px; gap: 10px; }
  #tray .dock-block { gap: 12px; padding-bottom: 12px; }
  #tray .tray-selection { width: 100%; gap: 10px; }
  #tray .tray-items { max-width: none; gap: 10px; }
  #tray .tray-items > div, #tray #trayAdd { width: 76px; height: 76px; }
  #tray .tray-items [data-k] { top: 4px; right: 4px; width: 22px; height: 22px; }
  #tray .tg-add { width: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 7px; }
  #tray .tg-add > button, #tray #tgMore > summary { width: 100%; min-height: 44px; padding: 8px 6px; gap: 5px; border-radius: 12px; font-size: 14px; }
  #tray #tgAddRow svg { width: 19px; height: 19px; }
  #tray #tgMore[open] { grid-column: 1 / -1; width: 100%; }
  #tray #tgMore[open] > div { width: 100%; max-width: none; grid-template-columns: repeat(3, minmax(0, 1fr)); }
  #tray :is(.dock-combo, .quick-workflow) > summary { min-height: 45px; padding: 10px 12px; gap: 7px; font-size: 15px; }
  #tray .tray-collapsed { font-size: 13px; }
  #tray .basket-next { min-height: 70px; padding: 10px 12px; gap: 7px; }
  #tray .basket-next > svg { width: 18px; height: 18px; }
  #tray .basket-next p { font-size: 12px; }
  #tray #tgStudio { min-width: 98px; min-height: 42px; padding: 8px 12px; gap: 8px; font-size: 15px; }
  #pk { padding: 16px 12px; place-items: center; }
  #pk .pk-box { height: 737px; max-height: calc(100dvh - 32px); margin-top: 0; border-radius: 16px; }
  #pk .pk-h { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 14px 10px; min-height: 0; padding: 20px 18px; }
  #pk #pkT { font-size: 19px; }
  #pk .pk-search kbd { display: none; }
  #pk .pk-search { grid-column: 1 / -1; grid-row: 2; width: 100%; }
  #pk #pkDone { grid-row: 1; grid-column: 2; min-width: 85px; font-size: 14px; }
  #pk #pkX { grid-row: 1; grid-column: 3; width: 28px; }
  #pk .pk-bar { gap: 8px; margin: 0 18px 18px; }
  #pk .pk-cats { flex: 1; }
  #pk .pk-cats .chip, #pk #pkFavOnly, #pkMore > summary { min-height: 36px; padding: 6px 10px; font-size: 14px; }
  #pk #pkPoseTypes { margin: 0 18px 12px; }
  #pk #pkG { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; padding: 0 18px 16px; }
  #pk .pk-footer { min-height: 78px; gap: 12px; padding: 12px 18px; }
  #pkSelectedCount { font-size: 13px; }
  #pkSelected { gap: 10px; }
  #pkSelected > button { width: 42px; height: 42px; }
  #pk #pkDoneBottom { min-width: 90px; padding: 9px 12px; font-size: 14px; }
  html:not([lang=zh-CN]) #tray .tg-add > button, html:not([lang=zh-CN]) #tray #tgMore > summary { flex-direction: column; font-size: 11px; white-space: normal; overflow-wrap: anywhere; }
  html:not([lang=zh-CN]) #tray :is(.dock-combo, .quick-workflow) > summary { flex-wrap: wrap; }
  html:not([lang=zh-CN]) #tray .tray-collapsed { font-size: 11px; }
}
@media (max-height: 600px) and (min-width: 768px) {
  #pk { padding-block: 16px; }
  #pk .pk-box { max-height: calc(100dvh - 32px); margin-top: 0; }
  #pk .pk-h { min-height: 0; padding-block: 14px; }
  #pk .pk-bar { margin-bottom: 14px; }
}
