/* 书架 (shelf.html): cream paper, walnut shelves; covers stand on the planks. */
.shelf-page{height:auto;min-height:100vh;overflow:visible;display:block;margin:0;
  --wood:#8a5a36;--wood-dark:#5e3b22;--wood-light:#b98a5c;--paper:#fffaf2;--ink:#3b2e25;--muted:#8d7d6f;--accent:#526b48;
  --cover-w:122px;--cover-h:183px;
  background:radial-gradient(circle at 12% 0,#f3e7d6 0,transparent 42%),linear-gradient(180deg,#f7f1e6,#efe6d8);color:var(--ink)}
.shelf-page .page-head{background:#faf5ec;border-bottom:1px solid #8a5a3622}
.shelf-page .page-head .matcha-logo{display:none}
.shelf-page .page-head a{color:var(--wood-dark)}
.shelf-main{max-width:1060px;margin:0 auto;padding:0 24px 60px}

.shelf-hero{margin:30px 0 22px;padding:40px 30px 32px;text-align:center;background:linear-gradient(160deg,#fffaf2,#f4e8d8);border:1px solid #8a5a3622;box-shadow:0 18px 40px #5e3b2214}
.shelf-kicker{font:600 11px "Cormorant Garamond",serif;letter-spacing:.28em;color:var(--wood)}
.shelf-hero h1{margin:10px 0 8px;font-size:clamp(34px,5vw,52px);font-weight:500;letter-spacing:.1em;color:var(--wood-dark)}
.shelf-hero p{margin:0 auto;max-width:460px;font-size:13px;line-height:1.9;color:var(--muted)}
.shelf-jump{display:flex;justify-content:center;flex-wrap:wrap;gap:10px;margin-top:18px}
.shelf-jump a{padding:8px 16px;border:1px solid #8a5a3633;border-radius:18px;background:#fffaf2;color:var(--wood-dark);font-size:13px;text-decoration:none}
.shelf-jump a:hover{background:#f3e5d2}
html{scroll-behavior:smooth}

.shelf-section{margin-top:22px;padding:26px 28px 30px;background:var(--paper);border:1px solid #8a5a361f;box-shadow:0 14px 34px #5e3b2212;scroll-margin-top:14px}
.shelf-head{display:flex;align-items:flex-end;justify-content:space-between;gap:16px;flex-wrap:wrap}
.shelf-head small{font:600 10px "Cormorant Garamond",serif;letter-spacing:.26em;color:var(--wood)}
.shelf-head h2{margin:6px 0 4px;font-size:28px;font-weight:500;color:var(--wood-dark)}
.shelf-count{margin:0;font-size:12px;color:var(--muted)}
.shelf-add{height:40px;padding:0 18px;border:0;background:var(--wood);color:#fffaf2;font:inherit;font-size:13px;letter-spacing:.05em;cursor:pointer;box-shadow:0 6px 14px #5e3b2230}
.shelf-add:hover{background:var(--wood-dark)}
.shelf-filters{display:flex;gap:6px;margin:16px 0 8px}
.shelf-filters button{height:28px;padding:0 13px;border:1px solid #8a5a3633;border-radius:14px;background:#fff;color:#7a5f4b;font:inherit;font-size:12px;cursor:pointer}
.shelf-filters button.active{background:var(--wood);border-color:var(--wood);color:#fffaf2}

/* the rack: rows of fixed height so every row stands on a plank */
.shelf-rack{--row:calc(var(--cover-h) + 76px);display:grid;grid-template-columns:repeat(auto-fill,minmax(var(--cover-w),1fr));grid-auto-rows:var(--row);column-gap:18px;padding:10px 14px 0;margin:0 -14px;
  background:repeating-linear-gradient(180deg,transparent 0 calc(var(--row) - 16px),var(--wood-light) calc(var(--row) - 16px) calc(var(--row) - 13px),var(--wood) calc(var(--row) - 13px) calc(var(--row) - 4px),var(--wood-dark) calc(var(--row) - 4px) var(--row))}
.shelf-item{position:relative;display:flex;flex-direction:column;align-items:center;justify-content:flex-end;gap:6px;width:100%;height:calc(var(--row) - 16px);padding:0 0 8px;border:0;background:none;font:inherit;color:inherit;cursor:pointer;text-align:center}
.shelf-cover{position:relative;display:block;width:var(--cover-w);height:var(--cover-h);overflow:hidden;background:#e9ddd0;box-shadow:2px 3px 0 #0000001a,0 8px 14px #3b2e2533;transition:transform .2s}
.shelf-cover img{display:block;width:100%;height:100%;object-fit:cover}
.shelf-item:hover .shelf-cover,.shelf-item:focus-visible .shelf-cover{transform:translateY(-6px) rotate(-1.5deg)}
.shelf-item:focus-visible{outline:none}
.shelf-item:focus-visible .shelf-cover{outline:3px solid var(--wood);outline-offset:3px}
.shelf-cover.drawn{display:flex;flex-direction:column;justify-content:space-between;padding:14px 12px;background:linear-gradient(160deg,hsl(var(--hue) 42% 46%),hsl(calc(var(--hue) + 30) 46% 30%));color:#fffaf2;text-align:left}
.shelf-cover.drawn::before{content:"";position:absolute;left:8px;top:0;bottom:0;width:2px;background:#ffffff33}
.shelf-cover.drawn i{font-style:normal;font-size:22px}
.shelf-cover.drawn b{font-size:15px;font-weight:600;line-height:1.35;overflow-wrap:anywhere;display:-webkit-box;-webkit-line-clamp:4;-webkit-box-orient:vertical;overflow:hidden}
.shelf-item.want .shelf-cover{filter:saturate(.55) brightness(1.04);opacity:.82}
.shelf-ribbon{position:absolute;top:8px;right:calc(50% - var(--cover-w) / 2 - 4px);padding:2px 8px;background:#526b48;color:#fff;font-size:11px;box-shadow:0 2px 5px #0003}
.shelf-label{display:flex;flex-direction:column;align-items:center;width:var(--cover-w);min-height:36px;margin-bottom:2px}
.shelf-label b{max-width:100%;font-size:13px;font-weight:600;color:var(--ink);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.shelf-label small{font-size:11px;color:#b9675f;letter-spacing:.04em}
.shelf-empty{grid-column:1/-1;align-self:center;margin:0;font-size:13px;color:var(--muted)}

/* add / edit dialog */
.shelf-dialog{width:min(620px,calc(100vw - 20px));max-height:calc(100vh - 24px);max-height:calc(100dvh - 24px);padding:0;border:0;background:#fffaf2;color:var(--ink);box-shadow:0 24px 70px #2a1d1459;overflow:auto}
.shelf-dialog::backdrop{background:#2a1d1466;backdrop-filter:blur(3px)}
.shelf-form{position:relative;padding:24px 26px 22px}
.shelf-dialog-close{position:absolute;top:8px;right:8px;width:38px;height:38px;border:0;background:none;color:var(--muted);font-size:24px;cursor:pointer}
.shelf-form>small{font:600 10px "Cormorant Garamond",serif;letter-spacing:.26em;color:var(--wood)}
.shelf-form h2{margin:4px 40px 16px 0;font-size:24px;font-weight:500;color:var(--wood-dark);overflow-wrap:anywhere}
.shelf-form-body{display:grid;grid-template-columns:auto 1fr;gap:22px}
.shelf-cover-field{display:flex;flex-direction:column;align-items:center;gap:8px;width:var(--cover-w)}
.shelf-cover-preview .shelf-cover{box-shadow:0 6px 14px #3b2e2533}
.shelf-cover-pick{position:relative;width:100%;padding:7px 0;border:1px dashed #8a5a3680;background:#fff;color:var(--wood-dark);font-size:12px;text-align:center;cursor:pointer}
.shelf-cover-pick:hover{background:#f6ecdf}
.shelf-cover-pick:focus-within{outline:2px solid var(--wood);outline-offset:1px}
.shelf-cover-pick input{position:absolute;width:1px;height:1px;opacity:0;pointer-events:none}
.shelf-link{padding:0;border:0;background:none;color:var(--muted);font:inherit;font-size:11px;text-decoration:underline;cursor:pointer}
.shelf-hint{margin:0;font-size:10px;line-height:1.5;color:#a8998b;text-align:center}
.shelf-fields{display:flex;flex-direction:column;gap:12px;min-width:0}
.shelf-fields label,.shelf-rating-field>span{display:flex;flex-direction:column;gap:6px;font-size:12px;color:#7a5f4b}
.shelf-fields label>span{display:inline;font-size:10px;color:#a8998b}
.shelf-fields input[type=text],.shelf-fields input[type=date],.shelf-fields textarea{width:100%;border:1px solid #8a5a3640;background:#fff;padding:9px 11px;font:inherit;font-size:14px;color:var(--ink);border-radius:0;outline:0}
.shelf-fields textarea{resize:vertical;line-height:1.7}
.shelf-fields input:focus,.shelf-fields textarea:focus{border-color:var(--wood);box-shadow:0 0 0 3px #8a5a361f}
.shelf-status{display:flex;gap:6px}
.shelf-status button{flex:1;height:34px;border:1px solid #8a5a3640;background:#fff;color:#7a5f4b;font:inherit;font-size:13px;cursor:pointer}
.shelf-status button.active{background:var(--wood);border-color:var(--wood);color:#fffaf2}
.shelf-rating-field{display:flex;flex-direction:column;gap:6px}
.shelf-hearts{display:flex;gap:2px}
.shelf-hearts button{border:0;background:none;padding:0 2px;font-size:24px;line-height:1;color:#e3d6c9;cursor:pointer;transition:transform .15s,color .15s}
.shelf-hearts button.on{color:#c9615a}
.shelf-hearts button:hover{transform:scale(1.15)}
[hidden]{display:none!important}
.shelf-status-text{min-height:18px;margin:12px 0 0;font-size:12px;color:var(--wood)}
.shelf-form-actions{display:flex;justify-content:flex-end;gap:10px;margin-top:10px}
.shelf-save{height:42px;padding:0 24px;border:0;background:var(--wood);color:#fffaf2;font:inherit;font-size:14px;letter-spacing:.06em;cursor:pointer}
.shelf-save:disabled{opacity:.6;cursor:wait}
.shelf-delete{margin-right:auto;height:42px;padding:0 16px;border:1px solid #a0504833;background:#fff;color:#a05048;font:inherit;font-size:13px;cursor:pointer}

@media(max-width:760px){
  .shelf-page{--cover-w:96px;--cover-h:144px}
  .shelf-main{padding:0 10px 40px}
  .shelf-hero{margin:12px 0 14px;padding:28px 16px 24px}
  .shelf-section{padding:20px 14px 24px}
  .shelf-rack{column-gap:10px;padding:8px 8px 0;margin:0 -8px}
  .shelf-head h2{font-size:23px}
  .shelf-form{padding:20px 16px 18px}
  .shelf-form-body{grid-template-columns:1fr}
  .shelf-cover-field{width:100%;flex-direction:row;flex-wrap:wrap;justify-content:center}
  .shelf-cover-pick{width:auto;padding:7px 14px}
  .shelf-hint{flex-basis:100%}
}
