.pins-app {
  --surface:#faf9f6; --panel:#fffefa; --ink:#1c2b40; --muted:#66707a; --rule:#dad9d2;
  --wash:#eeede8; --navy:#192e48; --radius:14px; --shadow:0 12px 32px #20263419;
  --ease:cubic-bezier(.22,.76,.18,1); min-height:0; background:var(--surface);
}
#pinRoom { height:100%; min-height:0; overflow:auto; color:var(--ink); padding-top:clamp(14px,3vh,30px); }
#pinRoom button,.album-dialog button { font-family:inherit; color:inherit; }
#pinRoom button:disabled { cursor:default; opacity:.42; }
#pinRoom button:focus-visible { outline:2px solid #7793bc; outline-offset:2px; }
.room-head { margin:0 0 12px; }
.room-head #pinCount { color:var(--muted); font-size:12px; }
.profile-back { border:0; background:transparent; color:var(--ink); }
.collection-title { margin-bottom:24px; }
.collection-title p { font-size:10px; color:#796b51; margin:0 0 6px; }
.collection-title h1 { font-size:clamp(25px,2.5vw,36px); letter-spacing:.04em; }
.collection-layout { display:grid; grid-template-columns:minmax(0,1fr) clamp(132px,17%,212px); gap:clamp(18px,3vw,46px); align-items:start; }
@media(min-width:821px){
  .collection-layout { grid-template-columns:minmax(160px,24%) minmax(0,1fr);align-items:start;gap:clamp(24px,3vw,48px); }
  .collection-layout .display-case {grid-column:2;grid-row:1;min-width:0;}
  #pinRoom .collection-layout .collection-entry {grid-row:1;grid-column:1;position:sticky;top:12px;padding:clamp(36px,5vh,58px) 8px 22px;}
  .collection-entry #entryArt {width:80%;max-width:210px;}
  .small-collection .collection-layout {grid-template-columns:minmax(180px,29%) minmax(0,1fr);}
  .small-collection .pin-wall {grid-template-columns:repeat(auto-fit,minmax(min(155px,100%),1fr));padding-block:clamp(22px,4vh,44px);gap:clamp(14px,2vw,32px);}
  .small-collection .badge-mount {width:100%;max-width:clamp(155px,16vw,218px);}
  .small-collection .collection-entry #entryArt {max-width:248px;}
  .small-collection .badge-button strong {margin-top:8px;font-size:15px;}
  .jacket-view.panel-open .studio-body {width:min(100%,calc(var(--studio-height)*1.12 + 250px));align-self:center;}
}
.display-case { padding:0; border:0; box-shadow:none; background:transparent; }
.display-case header { border-bottom:1px solid var(--rule); margin:0; padding:0 0 10px; }
.display-case h2 { font-size:17px; }
.display-case progress,.display-case progress::-webkit-progress-bar { background:#deded8; border-radius:6px; }
.display-case progress::-webkit-progress-value { background:#817355; border-radius:6px; }
.gallery-tools,.gallery-actions,.segments,.studio-foot,.album-state,.tool-dock,#steps { display:flex;align-items:center; }
.gallery-tools { position:relative; justify-content:space-between; gap:6px; margin:10px 0 12px; }
.gallery-actions { gap:2px; }
.segments { padding:3px; background:var(--wash); border-radius:24px; white-space:nowrap; }
#pinRoom .segments button { min-height:36px; padding:3px 14px; font-size:13px; border-radius:20px; }
.segments button,.gallery-actions button,.album-topbar button,.tool-dock button,.studio-foot button,.studio-pane button { border:0; background:transparent; }
.segments button[aria-pressed=true] { background:#fff; box-shadow:0 1px 4px #161e2b16; font-weight:600; }
.gallery-actions button,.album-topbar button[data-icon],.studio-foot button[data-icon],#closeTool { width:44px; display:grid; place-items:center; }
#pinRoom button svg:not(.cover-art) { width:19px; height:19px; }
.gallery-tools input,.studio-pane input:not([type=range]),.popover select,.studio-pane select,.album-dialog select,.album-dialog input[type=search] {
  font:inherit; font-size:13px; box-sizing:border-box; min-height:40px; min-width:0; max-width:100%; padding:7px 10px;
  border:0; border-radius:8px; background:var(--wash,#eeede8); color:var(--ink);
}
.gallery-tools input { width:145px; }
.popover,.studio-pane { background:var(--panel); border-radius:var(--radius); box-shadow:var(--shadow); }
.popover { position:absolute; z-index:8; top:100%; right:0; min-width:168px; padding:14px; }
.popover label,.studio-pane label { display:grid; gap:6px; color:var(--muted); font-size:12px; }
.popover label+label { margin-top:9px; }
#pinRoom select,.album-dialog select { appearance:none; padding-right:26px; background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='m1 1 5 5 5-5' fill='none' stroke='%2356616c'/%3E%3C/svg%3E"); background-position:right 9px center; background-repeat:no-repeat; }
.pin-wall { grid-template-columns:repeat(6,minmax(0,1fr)); min-height:0; gap:22px 8px; padding:20px 4px; border:0; border-radius:5px; box-shadow:none; background:#f3f0e9; }
#pinRoom .badge-button { gap:3px; background:transparent; border:0; padding:0; }
.badge-mount { width:min(100%,122px); margin-bottom:5px; background:none; }
.badge-button img { width:100%; aspect-ratio:1; object-fit:contain; filter:drop-shadow(0 4px 3px #46372040); }
.badge-button strong { font-size:13px; }
.badge-button .catalog-number { font-size:9px; }
#pinRoom .collection-entry { display:grid; width:100%; grid-template-columns:1fr; justify-items:center; gap:16px; padding:12px 0 10px; border:0; color:var(--ink); box-shadow:none; background:transparent; }
#entryArt { display:block; width:70%; max-width:135px; aspect-ratio:4/5; transform:rotate(-5deg); border-radius:2px 5px 5px 2px; overflow:hidden; box-shadow:2px 2px #d8d0bd,3px 3px #b4a68b,4px 9px 12px #292c3526; transition:transform .3s var(--ease); }
.collection-entry:hover #entryArt { transform:rotate(-2deg) translateY(-2px); }
.cover-art { width:100%; height:100%; display:block; pointer-events:none; }
.entry-label { margin:0; gap:8px; font-size:13px; }
#wallPager { display:flex; justify-content:center; align-items:center; gap:14px; font-size:12px; }
#wallPager button { background:transparent; border:0; }
#pinRoom.studio-active { max-width:none; padding:8px clamp(7px,2vw,25px); overflow:hidden; }
.book-view { height:var(--studio-height,80vh); min-height:0; display:flex; flex-direction:column; gap:5px; }
.album-topbar { flex:none; display:flex; align-items:center; gap:6px; min-height:44px; justify-content:space-between; }
.album-state { gap:2px; }
#pinRoom .primary { border-radius:24px; background:var(--navy);color:white;padding:0 20px; font-weight:600; font-size:13px; }
#steps button { color:var(--muted); border-radius:18px; padding:4px 12px; font-size:13px; }
#steps button[aria-current=step] { color:var(--ink); background:var(--wash); }
#saveState { font-size:0; display:inline-grid; place-items:center; width:22px; }
.book-view:not(.is-editing) #saveState:not(.is-error) {display:none;}
#saveState:not(:empty)::before { content:'✓'; color:#586f65; font:14px system-ui; }
#saveState.is-saving::before { content:'◷'; color:#776949; }
#saveState.is-error::before { content:'!'; font-weight:bold; color:#a14242; }
.studio-body { min-height:0; min-width:0; position:relative; flex:1; display:flex; }
.studio-body .book-stage { flex:1; min-width:0; min-height:0; padding:0; }
.studio-body .memory-book { width:var(--fitted-width,75%); max-width:none; max-height:none; height:auto; }
.memory-book::before { padding-top:var(--book-ratio,62.5%); }
.book-stage.is-front-closed .memory-book { transform:scale(var(--closed-scale,1)) translateX(-25%); }
.book-stage.is-back-closed .memory-book { transform:scale(var(--closed-scale,1)) translateX(25%); }
.book-leaf { left:50%;width:50%;height:100%;top:0; box-sizing:border-box; transform-origin:left center; filter:none; }
.book-leaf.is-turning { filter:none; }
.leaf-face { border-radius:2px 7px 7px 2px; box-shadow:none; }
.leaf-back { border-radius:7px 2px 2px 7px; }
.leaf-face[data-page] { inset:2px 2px 2px 0; box-shadow:inset 8px 0 14px -10px #0009, 0 2px 1px #b6ac96; }
.page-mark {color:var(--page-ink,#eed399);}
.leaf-back[data-page] { inset:2px 0 2px 2px; }
.binding-leaf .leaf-face[data-page] { border:2px solid var(--binding-color); }
.cover-face { display:block; border:0; background:var(--binding-color); box-shadow:1px 2px 0 #cfc8b9,0 6px 12px #1c243a22; }
.cover-face::after,#entryArt::after { content:''; display:block; position:absolute; pointer-events:none; inset:0 auto 0 0; width:5%; border:0; border-radius:0; background:linear-gradient(90deg,#0002,transparent 40%,#0002 67%,#fff2 85%,transparent); }
.cover-back::after { left:auto; right:0; transform:scaleX(-1); }
.cover-text-target,.cover-photo-target { position:absolute; z-index:1; }
#pinRoom .cover-text-target { left:9%;width:82%;height:18%;background:transparent;border:0; }
#pinRoom .cover-photo-target { top:24%;left:50%;transform:translateX(-50%);width:44px;border:0;border-radius:50%;color:#766346;background:#fffdf3e0;display:grid;place-items:center; }
#pinRoom .cover-photo-target.has-photo { top:9%; }
#pinRoom .cover-photo-target.has-photo:not(:focus-visible) {opacity:0;pointer-events:none;}
.cover-art image { touch-action:none; }
.pins-app.canvas-focus { grid-template-columns:minmax(0,1fr);grid-template-rows:minmax(0,1fr); }
.pins-app.canvas-focus > .rail { display:none; }
.pins-app.canvas-focus #pinRoom { grid-column:1;grid-row:1; }
/* 新版 GlobalHeader（.gh-top）在手机端是 grid 的第一行。
   canvas-focus 若仍把 main 钉在 row 1，.gh-top 会被自动排到 row 2，
   编辑徽章册时整条导航就沉到屏幕底部。这里显式把头部留在第一行。 */
.pins-app.gh-app.canvas-focus {
  grid-template-columns:minmax(0,1fr);
  grid-template-rows:auto minmax(0,1fr);
}
.pins-app.gh-app.canvas-focus > .gh-top { grid-column:1;grid-row:1; }
.pins-app.gh-app.canvas-focus #pinRoom { grid-column:1;grid-row:2; }
.pin-wall { background:transparent; gap:24px 12px; }
.badge-mount { position:relative; }
#pinRoom .badge-mount svg { position:absolute;bottom:1px;right:0;width:16px;height:16px; padding:2px;border-radius:50%;background:var(--surface);color:var(--muted); }
.gallery-actions .applied,.gallery-actions button[aria-expanded=true] { background:var(--wash);border-radius:50%;color:var(--navy); }
#detailImage {display:block;max-width:65%;height:200px;object-fit:contain;margin:12px auto;}
#badgeDetail {max-width:350px;color:#263449;}
#badgeDetail p {margin:9px 0;font-size:14px;}
#detailNumber {letter-spacing:.1em;color:#7d725e;}
#detailAlbum {border:0;border-radius:20px;padding:0 14px;margin-top:8px;}
#selection {position:absolute;z-index:90;border:1px solid #fff9;box-shadow:0 0 0 1px #27314335;pointer-events:none;box-sizing:border-box;}
.album-item.is-selected {outline:0;}
#pinRoom #selection button {width:44px;height:44px;min-height:44px;position:absolute;pointer-events:auto;touch-action:none;display:grid;place-items:center;border:0;padding:0;background:transparent;color:white;}
#pinRoom #selection button svg {width:19px;height:19px;padding:3px;border-radius:50%;background:#293441e6;box-shadow:0 0 0 1px #fffc;}
#deleteSelected {top:min(0px,calc(50% - 18px));left:min(0px,calc(50% - 18px));transform:translate(-50%,-50%);}
#transformSelected {bottom:min(0px,calc(50% - 18px));right:min(0px,calc(50% - 18px));transform:translate(50%,50%);cursor:nwse-resize;}
#itemMenu {z-index:110;right:auto;bottom:auto;min-width:100px;padding:5px;max-height:100%;overflow:auto;}
#itemMenu button {display:block;width:100%;text-align:left;background:transparent;border:0;border-radius:8px;padding:3px 12px;}
#itemMenu button:hover {background:var(--wash);}
.align-guide {position:absolute;z-index:9999;background:#caddf6;pointer-events:none;opacity:.8;}
.guide-x {width:1px;top:0;bottom:0;} .guide-y {height:1px;left:0;right:0;}
.inline-title {position:absolute;left:6%;width:88%;transform:translateY(-78%);text-align:center;z-index:20;background:var(--cover-color);border:0;border-bottom:1px solid currentColor;border-radius:0;outline:0;}
#pageThumbs {display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:6px;margin:6px 0;}
#pageThumbs .cover-art {height:auto;}
#pageThumbs button {font-size:11px;padding:2px;}
.page-mini {position:relative;display:block;padding-top:125%;border-radius:3px;overflow:hidden;pointer-events:none;}
#pageThumbs button[aria-pressed=true] .page-mini {outline:2px solid #78879a;outline-offset:1px;}
#pageNumber {font-variant-numeric:tabular-nums;font-size:13px;min-width:52px;}
#pinRoom #pageNumber:disabled {opacity:1;}
.studio-pane {animation:pane-in .18s var(--ease);}
@keyframes pane-in {from {opacity:0;transform:translateY(4px);} to {opacity:1;transform:none;}}

.tool-dock { align-self:center; flex:none; max-width:100%; gap:3px; padding:3px 6px; border-radius:18px; background:#eeede7; }
#pinRoom .tool-dock button { display:grid; justify-items:center; align-content:center; gap:4px; min-width:48px; border-radius:12px; padding:4px 8px; font-size:11px; line-height:1.2; }
.tool-dock button[aria-pressed=true] { background:#fff; box-shadow:0 1px 4px #26314115; }
.studio-foot { flex:none; justify-content:center; gap:4px; font-size:12px; color:var(--muted); }
.studio-foot output { min-width:52px; text-align:center; }
.studio-foot input { width:70px;accent-color:var(--navy); }
.studio-pane { flex:none; width:clamp(205px,21vw,265px); box-sizing:border-box; padding:8px 14px 14px; margin:8px 4px 8px 8px; min-height:0; align-self:center; max-height:calc(100% - 16px); overflow-y:auto;overscroll-behavior:contain; }
.studio-pane header { display:flex;align-items:center;justify-content:space-between;position:sticky;top:-8px;background:var(--panel);z-index:2; }
.studio-pane h3 { margin:0; font-size:15px; }
.studio-pane .setting,.studio-pane #targetField { margin-bottom:12px; }
.visual-choices { display:flex;flex-wrap:wrap;gap:3px; }
.studio-pane .visual-choices button { font-size:12px; padding:5px 7px; border-radius:8px; }
.visual-choices button[aria-pressed=true] { background:var(--wash); box-shadow:inset 0 0 0 1px #a5a8a9; }
.visual-choices button.swatch { position:relative; width:36px; padding:0; }
.swatch::before { content:''; display:block; width:25px; height:25px; margin:auto; border-radius:50%; background:var(--sample); box-shadow:inset 0 0 0 1px #0001; }
#pinRoom #coverFrameStyle svg { width:27px;height:27px;fill:#aa9780; }
.material-sample { display:block;width:40px;height:25px;border-radius:4px;margin:0 auto 4px;background:#2e425d; }
.material-sample.cloth { background:repeating-linear-gradient(90deg,#ffffff20 0 1px,transparent 1px 3px),repeating-linear-gradient(#526073 0 1px,#273b55 1px 3px); }
.material-sample.leather { background:radial-gradient(ellipse at 2px 2px,#607187 8%,transparent 32%) 0 0/4px 3px,#30435b; }
.material-sample.velvet { background:linear-gradient(130deg,#28374c,#68778c77,#23334b),url('/web/v3/assets/pins/texture-velvet.jpg') center/90px; }
.material-sample.satin { background:linear-gradient(145deg,#21334c,#76879b,#2b3b52); }
#templates,#ornaments,#trayItems { display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:5px; }
#templates button,#ornaments button,#trayItems button { min-width:0; font-size:11px; padding:4px; border-radius:6px; }
#templates .cover-art { height:auto; margin-bottom:6px; box-shadow:1px 2px 3px #0002; }
#ornaments img,#trayItems img { display:block; width:100%;height:50px;object-fit:contain; }
/* 素材图防保存：托盘图片不响应指针（原生右键/长按菜单落在按钮上），
   内置素材关闭 iOS 长按呼出与文字选择；右键拦截在 pins.js 的 contextmenu 里 */
#ornaments img,#trayItems img { pointer-events:none; }
.asset-art { -webkit-touch-callout:none; user-select:none; }
.studio-pane input { width:100%; accent-color:var(--navy); }
.panel-actions { display:grid;grid-template-columns:1fr 1fr; }
.studio-pane button:hover,.gallery-actions button:hover { background-color:var(--wash); }
.sheet-grip,.book-view:not(.is-editing) .edit-only { display:none; }
@media(max-width:1370px){.pin-wall{grid-template-columns:repeat(5,minmax(0,1fr))}}
@media(max-width:1050px){.pin-wall{grid-template-columns:repeat(4,minmax(0,1fr))}}
@media(max-width:820px){
  /* 编辑态交给 flex 撑满内容区：不再依赖 JS 用 viewport 坐标算高度，
     否则徽章墙滚动后进入编辑，顶部导航会被顶出屏幕、底部页码栏掉到屏幕外。 */
  #pinRoom.studio-active {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 8px 8px calc(14px + env(safe-area-inset-bottom, 0px));
  }
  #pinRoom.studio-active > .book-view {
    flex: 1 1 auto;
    height: auto;
    min-height: 0;
  }
  .pin-wall{grid-template-columns:repeat(3,minmax(0,1fr))}
  .studio-body { flex-direction:column; }
  .studio-pane { width:min(100%,540px); max-height:48%; height:var(--sheet-h,34%); margin:0; align-self:center; border-radius:16px 16px 8px 8px; padding:0 14px 10px; }
  #pinRoom .segments button {min-height:44px;}
  #pinRoom .sheet-grip { display:block; min-height:20px;width:100%;touch-action:none;cursor:ns-resize; }
  .sheet-grip::before { content:''; display:block; width:28px;height:3px;border-radius:3px;background:#b9b7b1;margin:auto; }
  .studio-pane header { top:0; }
  #ornaments,#trayItems { grid-template-columns:repeat(auto-fill,minmax(56px,1fr)); }
  #templates { max-width:260px; }
}
/* iOS Safari 的底部地址栏浮在页面上，单靠 safe-area 仍会盖住页码栏。 */
@supports (-webkit-touch-callout: none) {
  @media (max-width: 820px) and (display-mode: browser) {
    .pins-app.canvas-focus #pinRoom.studio-active {
      padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
    }
  }
}
@media(max-width:599px){
  .collection-layout { display:flex;flex-direction:column;gap:12px; }
  #pinRoom .collection-entry { order:-1;width:auto;grid-template-columns:84px auto;gap:15px;padding:0 0 5px;text-align:left; }
  #entryArt {width:78px;}
  .display-case {width:100%;}
  .collection-title {margin-bottom:14px;}
  .gallery-tools { flex-wrap:wrap; }
  .pins-app.canvas-focus #pinRoom { padding-bottom:calc(14px + env(safe-area-inset-bottom,0px)); }
  .gallery-actions { margin-left:auto; }
  .gallery-actions input {width:116px;}
  #steps button {padding:2px 5px;font-size:12px;}
  #pinRoom .album-topbar button[data-icon] {width:34px;}
  .album-state {gap:0;}
  #pinRoom .primary {padding:0 12px;}
  .album-topbar {gap:0;}
  .tool-dock {gap:0;}
  #pinRoom .tool-dock button {min-width:43px;padding-inline:5px;}
}
@media(max-width:470px){.pin-wall{grid-template-columns:repeat(2,minmax(0,1fr))}}
@media(prefers-reduced-motion:reduce){#entryArt,.book-leaf,.memory-book { transition:none!important; }}

/* 拖拽落位：按坐标命中的书页高亮 + 触屏拖拽浮层 */
.leaf-face.is-drop-target {
  outline: 2px solid rgba(185, 154, 94, .85);
  outline-offset: -2px;
  box-shadow: inset 0 0 0 999px rgba(201, 168, 106, .08), inset 8px 0 14px -10px #0009;
}
.pin-drag-ghost {
  position: fixed;
  z-index: 700;
  width: 68px;
  height: 68px;
  margin: -34px 0 0 -34px;
  object-fit: contain;
  pointer-events: none;
  opacity: .92;
  transform: rotate(-4deg);
  filter: drop-shadow(0 10px 16px rgba(20, 26, 38, .35));
}
