/* ==========================================================
   Chat's Bookshelf
   ========================================================== */

@font-face{
  font-family:'Fraunces';
  src:url('/fonts/fraunces.woff2') format('woff2');
  font-weight:100 900; font-style:normal; font-display:swap;
}
@font-face{
  font-family:'Nunito';
  src:url('/fonts/nunito.woff2') format('woff2');
  font-weight:200 1000; font-style:normal; font-display:swap;
}

:root{
  --paper:#FBF1E4;
  --paper-soft:#F5E9D8;
  --ink:#3A2C2E;
  --ink-soft:#6b5a56;
  --wood:#B0673D;
  --wood-dark:#8C4F2E;
  --wood-line:rgba(60,30,10,0.18);
  --rose:#E3A6A0;
  --sage:#8FA888;
  --butter:#EFC75E;
  --sky:#9DBEDD;
  --lilac:#C6A6D6;
  --card:#ffffff;
  --danger:#a15a4a;
  --back-panel:#E9D6BD;
  --back-panel-2:#E2CCB0;
  --shadow:0 10px 24px rgba(58,44,46,0.14);
  --shadow-lg:0 24px 60px rgba(58,44,46,0.28);
  --safe-top:env(safe-area-inset-top,0px);
  --safe-bottom:env(safe-area-inset-bottom,0px);
  --serif:'Fraunces',Georgia,'Times New Roman',serif;
  --sans:'Nunito',system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;
  --ease:cubic-bezier(.2,.8,.3,1);
}

*{ box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
[hidden]{ display:none !important; }

html{ -webkit-text-size-adjust:100%; text-size-adjust:100%; }
html,body{
  margin:0; padding:0; min-height:100%;
  background:var(--paper); color:var(--ink);
  font-family:var(--sans); -webkit-font-smoothing:antialiased;
}
body{ overflow-x:hidden; }
body.locked{ overflow:hidden; }

h1,h2,h3,.serif{ font-family:var(--serif); font-weight:600; margin:0; }

button{ font-family:inherit; cursor:pointer; border:none; background:none; color:inherit; touch-action:manipulation; padding:0; }
input,textarea,select{ font-family:inherit; font-size:16px; color:var(--ink); }

:focus-visible{ outline:2px solid var(--wood); outline-offset:2px; }
button:focus:not(:focus-visible){ outline:none; }

::-webkit-scrollbar{ width:8px; height:8px; }
::-webkit-scrollbar-thumb{ background:rgba(58,44,46,0.2); border-radius:8px; }

/* ==========================================================
   PASSWORD GATE
   ========================================================== */
#authGate{
  position:fixed; inset:0; z-index:1000;
  display:flex; align-items:center; justify-content:center;
  padding:24px; padding-top:calc(24px + var(--safe-top)); padding-bottom:calc(24px + var(--safe-bottom));
  background:
    radial-gradient(ellipse at 50% 0%, #fff6ea 0%, transparent 60%),
    var(--paper);
  animation:fadeIn .35s ease both;
}
.auth-card{ width:100%; max-width:320px; display:flex; flex-direction:column; align-items:center; }
.auth-mark{ width:64px; height:64px; margin-bottom:14px; filter:drop-shadow(0 6px 8px rgba(58,44,46,.14)); }
.auth-title{ font-size:clamp(28px,8vw,38px); letter-spacing:.3px; margin-bottom:30px; text-align:center; }
.auth-form{ width:100%; display:flex; flex-direction:column; gap:14px; }
.auth-form input{
  width:100%; padding:15px 18px; border-radius:14px; text-align:center; letter-spacing:.5px;
  border:2px solid rgba(58,44,46,.12); background:var(--card); outline:none;
  transition:border-color .15s ease, box-shadow .15s ease;
}
.auth-form input:focus{ border-color:var(--wood); box-shadow:0 0 0 4px rgba(176,103,61,.12); }
.auth-form input:disabled{ opacity:.55; }
.auth-form button{
  width:100%; padding:15px; border-radius:14px; background:var(--ink); color:var(--paper);
  font-weight:800; font-size:15px; transition:transform .1s ease, opacity .15s ease;
}
.auth-form button:active{ transform:scale(.97); }
.auth-form button:disabled{ opacity:.5; cursor:not-allowed; }
.auth-msg{ font-size:13px; text-align:center; min-height:20px; color:var(--danger); }
.auth-msg.info{ color:var(--ink-soft); }
.auth-form.shake{ animation:shake .35s ease; }
@keyframes shake{ 20%,60%{ transform:translateX(-6px) } 40%,80%{ transform:translateX(6px) } }
@keyframes fadeIn{ from{ opacity:0 } to{ opacity:1 } }

/* ==========================================================
   LAYOUT
   ========================================================== */
.wrap{
  max-width:1040px; margin:0 auto;
  padding:20px clamp(14px,3.2vw,28px) 80px;
  padding-top:calc(20px + var(--safe-top));
  padding-bottom:calc(80px + var(--safe-bottom));
  padding-left:max(clamp(14px,3.2vw,28px), env(safe-area-inset-left,0px));
  padding-right:max(clamp(14px,3.2vw,28px), env(safe-area-inset-right,0px));
}

header.top{
  display:flex; align-items:center; justify-content:space-between;
  gap:6px 14px; margin-bottom:18px; flex-wrap:wrap;
}
header.top h1{ font-size:clamp(23px,5.4vw,34px); letter-spacing:.2px; line-height:1.15; }
.top-meta{ display:flex; align-items:center; gap:12px; }
.count{ font-size:13px; color:var(--ink-soft); font-weight:600; font-variant-numeric:tabular-nums; }

.sync{
  display:inline-flex; align-items:center; gap:6px;
  font-size:11.5px; font-weight:700; color:var(--ink-soft);
  padding:4px 9px 4px 8px; border-radius:999px; background:rgba(58,44,46,.05);
  transition:background .2s ease, color .2s ease;
}
.sync i{ width:7px; height:7px; border-radius:50%; background:var(--sage); transition:background .2s ease; }
.sync[data-state="syncing"] i{ background:var(--butter); animation:pulse 1s ease-in-out infinite; }
.sync[data-state="offline"] i,
.sync[data-state="error"] i{ background:var(--rose); }
.sync[data-state="offline"], .sync[data-state="error"]{ color:var(--danger); background:rgba(227,166,160,.18); }
.sync[data-state="local"]{ display:none; }
@keyframes pulse{ 50%{ opacity:.35; transform:scale(.8) } }

/* ---------- search ---------- */
.search-row{ position:relative; margin-bottom:14px; z-index:40; }
.search-row input{
  width:100%; padding:14px 44px 14px 44px; border-radius:16px;
  border:2px solid rgba(58,44,46,.1); background:var(--card); outline:none;
  box-shadow:0 2px 0 rgba(58,44,46,.03);
  transition:border-color .15s ease, box-shadow .15s ease;
  -webkit-appearance:none; appearance:none;
}
.search-row input::-webkit-search-cancel-button{ -webkit-appearance:none; }
.search-row input:focus{ border-color:var(--wood); box-shadow:0 0 0 4px rgba(176,103,61,.12); }
.search-ico{ position:absolute; left:15px; top:50%; width:18px; height:18px; margin-top:-9px; color:var(--ink-soft); pointer-events:none; }

.results{
  position:absolute; top:calc(100% + 8px); left:0; right:0;
  background:var(--card); border-radius:16px; box-shadow:var(--shadow-lg);
  max-height:min(60vh,520px); max-height:min(60dvh,520px);
  overflow-y:auto; overscroll-behavior:contain; display:none;
  border:1px solid rgba(58,44,46,.06);
}
.results.open{ display:block; animation:popIn .16s var(--ease) both; }
@keyframes popIn{ from{ opacity:0; transform:translateY(-4px) } to{ opacity:1; transform:none } }

.result-item{
  display:flex; align-items:center; gap:12px; width:100%; text-align:left;
  padding:10px 14px; border-bottom:1px solid rgba(58,44,46,.06);
  transition:background .1s ease;
}
.result-item:last-child{ border-bottom:none; }
.result-item.active, .result-item:hover{ background:rgba(58,44,46,.04); }
.result-item.note{ color:var(--ink-soft); font-size:14px; padding:16px; cursor:default; }
.result-cover{
  width:38px; height:56px; object-fit:cover; border-radius:3px; flex:none;
  background:var(--paper-soft); box-shadow:0 2px 5px rgba(58,44,46,.18);
}
.result-text{ flex:1; min-width:0; }
.rt-title{ font-weight:800; font-size:14px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.rt-sub{ font-size:12.5px; color:var(--ink-soft); white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.add-btn{
  background:var(--sage); color:#fff; font-weight:800; font-size:13px;
  padding:8px 16px; border-radius:10px; flex:none;
  transition:transform .1s ease, background .15s ease;
}
.add-btn:active{ transform:scale(.94); }
.add-btn.added{ background:rgba(143,168,136,.22); color:#6b8a64; }

/* ---------- filters ---------- */
.filters{
  display:flex; gap:10px 14px; flex-wrap:wrap; align-items:center;
  margin-bottom:22px; position:relative; z-index:30;
}
.chips{ display:flex; gap:8px; flex-wrap:wrap; }
.filter-chip{
  display:inline-flex; align-items:center; gap:6px;
  padding:8px 14px; border-radius:999px; font-size:13px; font-weight:800;
  background:rgba(58,44,46,.06); color:var(--ink-soft);
  transition:background .15s ease, color .15s ease, transform .1s ease;
}
.filter-chip b{ font-weight:700; font-size:11.5px; opacity:.65; font-variant-numeric:tabular-nums; }
.filter-chip:active{ transform:scale(.96); }
.filter-chip:hover{ background:rgba(58,44,46,.1); }
.filter-chip.active{ background:var(--ink); color:var(--paper); }

.sort-wrap{ position:relative; margin-left:auto; }
.sort-trigger{
  display:flex; align-items:center; gap:5px; padding:8px 6px;
  font-size:13px; font-weight:700; color:var(--ink-soft);
  text-decoration:underline; text-underline-offset:3px;
}
.sort-trigger svg{ width:12px; height:12px; opacity:.7; transition:transform .15s ease; }
.sort-trigger[aria-expanded="true"] svg{ transform:rotate(180deg); }
.sort-menu{
  position:absolute; right:0; top:calc(100% + 6px); min-width:170px; padding:6px;
  background:var(--card); border-radius:14px; box-shadow:var(--shadow-lg);
  border:1px solid rgba(58,44,46,.06); display:none; z-index:100;
}
.sort-menu.open{ display:block; animation:popIn .14s var(--ease) both; }
.sort-option{
  display:block; width:100%; text-align:left; padding:10px 12px; border-radius:9px;
  font-size:13.5px; font-weight:700; transition:background .12s ease;
}
.sort-option:hover,.sort-option:focus-visible{ background:rgba(58,44,46,.06); }
.sort-option.active{ background:var(--ink); color:var(--paper); }

/* ==========================================================
   THE SHELF
   ========================================================== */
.case{
  --side:clamp(9px,2.4vw,20px);
  --rowpad:clamp(6px,1.6vw,14px);
  position:relative;
  padding:clamp(10px,2vw,16px) var(--side) 12px;
  border-radius:14px 14px 6px 6px;
  background:
    repeating-linear-gradient(90deg, rgba(60,30,10,.07) 0 1px, transparent 1px 23px),
    linear-gradient(90deg, #A9602F 0%, #C27C4A 8%, #B5703F 50%, #C27C4A 92%, #A9602F 100%);
  box-shadow:
    inset 0 2px 0 rgba(255,255,255,.22),
    inset 0 -3px 0 rgba(0,0,0,.18),
    0 26px 34px -22px rgba(58,44,46,.55),
    0 3px 0 rgba(60,30,10,.18);
  contain:layout style;
}

.shelf-row{ position:relative; }
.shelf-row + .shelf-row{ margin-top:0; }

.spines{
  position:relative;
  display:flex; align-items:flex-end; gap:2px;
  padding:clamp(16px,3vw,26px) var(--rowpad) 6px;
  min-height:var(--rowh,170px);
  background:
    linear-gradient(to top, #C9915F 0 7px, #B67A48 7px 8px, transparent 8px),
    repeating-linear-gradient(90deg, rgba(120,70,30,.045) 0 1px, transparent 1px 38px),
    linear-gradient(180deg, var(--back-panel-2) 0%, var(--back-panel) 55%, #EBDAC3 100%);
  box-shadow:
    inset 0 16px 18px -12px rgba(60,30,10,.38),
    inset 10px 0 14px -10px rgba(60,30,10,.32),
    inset -10px 0 14px -10px rgba(60,30,10,.32);
}

.plank{
  position:relative; z-index:2; height:15px;
  background:
    repeating-linear-gradient(90deg, var(--wood-line) 0 2px, transparent 2px 26px),
    linear-gradient(180deg, #C98655 0%, var(--wood) 35%, var(--wood-dark) 100%);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.28),
    0 6px 8px -3px rgba(58,44,46,.28);
  margin:0 calc(var(--side) * -.4);
  border-radius:2px;
}

/* ---------- one spine ---------- */
.spine{
  --c:#E3A6A0; --fg:#fff; --w:36px; --h:130px; --tilt:0deg;
  position:relative; flex:none; display:block;
  width:var(--w); height:var(--h);
  padding:0; margin:0 0 3px;
  color:var(--fg);
  border-radius:3px 3px 1px 1px;
  background-color:var(--c);
  background-image:
    linear-gradient(90deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,.06) 14%, rgba(0,0,0,0) 40%, rgba(0,0,0,.10) 78%, rgba(0,0,0,.26) 100%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='64' height='64'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 .55 0'/%3E%3C/filter%3E%3Crect width='64' height='64' filter='url(%23n)' opacity='.5'/%3E%3C/svg%3E");
  background-blend-mode:normal, multiply;
  box-shadow:
    inset 0 0 0 1px rgba(0,0,0,.07),
    inset 1px 0 0 rgba(255,255,255,.18),
    4px 0 6px -2px rgba(50,25,10,.30);
  transform-origin:50% 100%;
  transform:rotate(var(--tilt));
  transition:transform .22s var(--ease), box-shadow .22s ease;
  cursor:pointer; overflow:hidden;
  contain:layout paint;
  font-family:var(--serif);
  -webkit-user-select:none; user-select:none;
}
.spine::before, .spine::after{
  content:""; position:absolute; left:0; right:0; pointer-events:none;
  height:3px; background:rgba(255,255,255,.34);
  box-shadow:0 5px 0 rgba(255,255,255,.2);
  mix-blend-mode:soft-light;
}
.spine::before{ top:7%; }
.spine::after{ bottom:17%; }
.spine.dark::before, .spine.dark::after{ background:rgba(0,0,0,.28); box-shadow:0 5px 0 rgba(0,0,0,.18); mix-blend-mode:multiply; }

@media (hover:hover){
  .spine:hover{
    transform:translateY(-9px) rotate(var(--tilt));
    box-shadow:
      inset 0 0 0 1px rgba(0,0,0,.07), inset 1px 0 0 rgba(255,255,255,.18),
      6px 10px 14px -4px rgba(50,25,10,.38);
    z-index:3;
  }
}
.spine:active{ transform:translateY(-5px) rotate(var(--tilt)); }
.spine:focus-visible{ outline-offset:3px; transform:translateY(-9px) rotate(var(--tilt)); z-index:3; }

.spine.drop{ animation:drop .5s var(--ease) both; }
@keyframes drop{
  from{ opacity:0; transform:translateY(-34px) rotate(var(--tilt)); }
  to{ opacity:1; transform:rotate(var(--tilt)); }
}

.spine-text{
  position:absolute; left:2px; right:2px; top:14%; bottom:24%;
  display:flex; align-items:center; justify-content:center; gap:3px;
  pointer-events:none;
}
.spine-text span{
  writing-mode:vertical-rl; transform:rotate(180deg);
  max-height:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
  line-height:1.15;
}
.spine-text .st{ font-weight:650; font-size:var(--fs,11.5px); letter-spacing:.15px; }
.spine-text .sa{ font-family:var(--sans); font-weight:700; font-size:9px; opacity:.72; letter-spacing:.2px; }

.spine-status{
  position:absolute; left:50%; bottom:5px; transform:translateX(-50%);
  width:52%; height:4px; border-radius:3px; pointer-events:none;
  box-shadow:0 0 0 1px rgba(255,255,255,.5);
}
.spine-status.want{ background:var(--lilac); }
.spine-status.reading{ background:var(--sage); }
.spine-status.read{ background:var(--butter); }

/* ---------- empty ---------- */
.empty-shelf{
  position:absolute; inset:0; display:flex; flex-direction:column;
  align-items:center; justify-content:center; text-align:center; padding:20px;
  color:var(--ink-soft);
}
.empty-shelf .serif{ font-size:clamp(18px,3.6vw,22px); margin-bottom:8px; color:var(--ink); }
.empty-shelf p{ font-size:14px; margin:0; line-height:1.55; max-width:34ch; }

/* ==========================================================
   BOOK DETAIL (bottom sheet on phones, dialog on larger screens)
   ========================================================== */
.overlay{
  position:fixed; inset:0; background:rgba(58,44,46,.45);
  opacity:0; visibility:hidden; pointer-events:none;
  transition:opacity .25s ease, visibility 0s linear .25s; z-index:200;
}
.overlay.open{ opacity:1; visibility:visible; pointer-events:auto; transition:opacity .25s ease; }

.sheet{
  --sheet-accent:var(--sage);
  position:fixed; z-index:201; overflow-y:auto; overscroll-behavior:contain;
  -webkit-overflow-scrolling:touch;
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--sheet-accent) 20%, var(--paper)) 0%, var(--paper) 340px),
    var(--paper);
  box-shadow:0 -10px 40px rgba(0,0,0,.24);
  outline:none; visibility:hidden;

  /* phone: bottom sheet */
  left:0; right:0; bottom:0; margin:0 auto; width:100%; max-width:640px;
  max-height:92vh; max-height:92dvh;
  border-radius:24px 24px 0 0;
  padding-bottom:var(--safe-bottom);
  transform:translateY(105%);
  transition:transform .34s var(--ease), visibility 0s linear .34s;
}
.sheet.open{ transform:none; visibility:visible; transition:transform .34s var(--ease); }
.sheet.dragging{ transition:none; }

.sheet-handle{ display:flex; justify-content:center; padding:12px 0 4px; touch-action:none; cursor:grab; }
.sheet-handle span{ width:40px; height:5px; border-radius:5px; background:rgba(58,44,46,.22); }

.close-x{
  position:absolute; top:10px; right:10px; z-index:3;
  width:38px; height:38px; border-radius:50%;
  font-size:26px; line-height:1; color:var(--ink-soft);
  display:flex; align-items:center; justify-content:center;
  transition:background .15s ease;
}
.close-x:hover{ background:rgba(58,44,46,.08); }

.sheet-body{ display:flex; flex-direction:column; align-items:center; gap:14px; padding:6px 22px 30px; text-align:center; }
.sheet-cover-col{ flex:none; padding-top:6px; }
.sheet-info{ width:100%; min-width:0; }

/* ---------- 3D book ---------- */
.stage{
  --bw:132px; --bh:198px; --bd:24px;
  position:relative; width:var(--bw); height:var(--bh);
  margin:12px auto 18px; perspective:1100px;
}
.book3d{
  --accent:var(--sheet-accent);
  position:absolute; inset:0; transform-style:preserve-3d;
  transform:rotateX(-3deg) rotateY(-26deg);
  transition:transform .6s var(--ease);
}
.stage:hover .book3d, .stage.flat .book3d{ transform:rotateX(0deg) rotateY(-8deg); }
.face{ position:absolute; backface-visibility:hidden; -webkit-backface-visibility:hidden; }

.face.front{
  inset:0; border-radius:2px 5px 5px 2px; overflow:hidden; background:var(--accent);
  transform:translateZ(calc(var(--bd) / 2));
  box-shadow:inset 0 0 0 1px rgba(0,0,0,.08);
}
.face.front img{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; display:block; opacity:0; transition:opacity .35s ease; }
.face.front img.ready{ opacity:1; }
.gloss{
  position:absolute; inset:0; pointer-events:none;
  background:
    linear-gradient(90deg, rgba(0,0,0,.28) 0, rgba(255,255,255,.22) 2.2%, rgba(0,0,0,.12) 4.6%, rgba(255,255,255,0) 11%),
    linear-gradient(115deg, rgba(255,255,255,.22) 0%, rgba(255,255,255,0) 34%, rgba(0,0,0,.10) 100%);
}
.face.back{
  inset:0; background:color-mix(in srgb, var(--accent) 70%, #000);
  transform:rotateY(180deg) translateZ(calc(var(--bd) / 2));
  border-radius:2px 5px 5px 2px;
}
.face.side-l{
  top:0; bottom:0; width:var(--bd); left:calc(50% - var(--bd) / 2);
  transform:rotateY(-90deg) translateZ(calc(var(--bw) / 2));
  background:
    linear-gradient(90deg, rgba(0,0,0,.28), rgba(255,255,255,.12) 40%, rgba(0,0,0,.22)),
    var(--accent);
  border-radius:2px 0 0 2px;
}
.face.side-r{
  top:2px; bottom:2px; width:var(--bd); left:calc(50% - var(--bd) / 2);
  transform:rotateY(90deg) translateZ(calc(var(--bw) / 2));
  background:
    repeating-linear-gradient(180deg, rgba(0,0,0,.0) 0 2px, rgba(120,95,60,.18) 2px 3px),
    linear-gradient(90deg, #efe4d0, #fbf5ea 50%, #e8dcc4);
}
.face.side-t{
  left:2px; right:2px; height:var(--bd); top:calc(50% - var(--bd) / 2);
  transform:rotateX(90deg) translateZ(calc(var(--bh) / 2));
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,0) 0 2px, rgba(120,95,60,.18) 2px 3px),
    linear-gradient(180deg, #efe4d0, #fbf5ea);
}
.book-shadow{
  position:absolute; left:6%; right:-8%; bottom:-14px; height:22px; z-index:-1;
  background:radial-gradient(ellipse at center, rgba(40,20,10,.38) 0%, rgba(40,20,10,0) 70%);
  filter:blur(3px); transform:translateX(10px);
}

.cover-fallback{
  position:absolute; inset:0; display:none; flex-direction:column; align-items:center; justify-content:center;
  gap:10px; padding:20px 16px 20px 22px; text-align:center; color:var(--fb-fg,#fff);
  background:
    linear-gradient(160deg, rgba(255,255,255,.18), rgba(0,0,0,.14)),
    var(--accent);
}
.cover-fallback::before{
  content:""; position:absolute; inset:9px 9px 9px 14px; border:1.5px solid currentColor; opacity:.4; border-radius:3px;
}
.cover-fallback.show{ display:flex; }
.fb-title{ font-size:15px; line-height:1.2; display:-webkit-box; -webkit-line-clamp:5; -webkit-box-orient:vertical; overflow:hidden; position:relative; }
.fb-rule{ width:26px; height:2px; background:currentColor; opacity:.55; border-radius:2px; position:relative; }
.fb-author{ font-size:11px; font-weight:700; opacity:.85; letter-spacing:.3px; position:relative; }

/* ---------- info column ---------- */
.sheet-info h2{ font-size:clamp(20px,5vw,24px); margin-bottom:3px; line-height:1.25; overflow-wrap:anywhere; }
.sheet-info .author{ color:var(--ink-soft); font-size:14.5px; margin-bottom:2px; font-weight:600; }
.sheet-info .meta{ font-size:12.5px; color:var(--ink-soft); margin-bottom:18px; min-height:1em; }

.field-label{
  font-size:11px; font-weight:800; color:var(--ink-soft);
  margin-bottom:7px; display:block; text-transform:uppercase; letter-spacing:.5px;
}
.status-picker{ display:flex; gap:6px; margin-bottom:18px; flex-wrap:wrap; justify-content:center; }
.status-btn{
  padding:10px 14px; border-radius:11px; font-size:13px; font-weight:800;
  background:rgba(58,44,46,.06); color:var(--ink-soft);
  transition:background .15s ease, color .15s ease, transform .1s ease;
}
.status-btn:active{ transform:scale(.96); }
.status-btn.active{ background:var(--sheet-accent); color:var(--on-accent,#fff); box-shadow:0 3px 8px -2px color-mix(in srgb, var(--sheet-accent) 70%, transparent); }

.stars{ display:flex; gap:2px; margin-bottom:18px; font-size:28px; justify-content:center; }
.star{ color:rgba(58,44,46,.18); line-height:1; padding:4px 3px; transition:color .1s ease, transform .12s ease; }
.star:hover{ transform:scale(1.12); }
.star.filled{ color:var(--butter); text-shadow:0 1px 0 rgba(176,130,20,.35); }

textarea.note{
  display:block; width:100%; min-height:76px; max-height:240px;
  padding:12px 14px; border-radius:14px; margin-bottom:16px;
  border:2px solid rgba(58,44,46,.1); background:rgba(255,255,255,.7);
  resize:none; outline:none; line-height:1.5; overflow-y:auto; text-align:left;
  transition:border-color .15s ease, background .15s ease;
}
textarea.note:focus{ border-color:var(--sheet-accent); background:#fff; }

.remove-btn{
  font-size:13px; color:var(--danger); font-weight:800;
  text-decoration:underline; text-underline-offset:3px; padding:10px 6px;
}

/* ---------- toasts ---------- */
.toasts{
  position:fixed; left:0; right:0; z-index:400; pointer-events:none;
  bottom:calc(18px + var(--safe-bottom));
  display:flex; flex-direction:column; align-items:center; gap:8px; padding:0 14px;
}
.toast{
  pointer-events:auto; display:flex; align-items:center; gap:14px;
  max-width:min(440px,100%); padding:11px 14px 11px 16px; border-radius:14px;
  background:var(--ink); color:var(--paper); font-size:13.5px; font-weight:700;
  box-shadow:0 12px 30px rgba(58,44,46,.35);
  animation:toastIn .28s var(--ease) both;
}
.toast.out{ animation:toastOut .2s ease both; }
.toast span{ overflow:hidden; text-overflow:ellipsis; white-space:nowrap; min-width:0; }
.toast button{ color:var(--butter); font-weight:800; font-size:13.5px; padding:4px 2px; flex:none; }
@keyframes toastIn{ from{ opacity:0; transform:translateY(14px) scale(.97) } to{ opacity:1; transform:none } }
@keyframes toastOut{ to{ opacity:0; transform:translateY(8px) } }

/* ==========================================================
   RESPONSIVE
   ========================================================== */
@media (min-width:720px){
  .overlay{ background:rgba(58,44,46,.5); }

  .sheet{
    left:50%; right:auto; top:50%; bottom:auto; margin:0;
    width:min(780px,92vw); max-width:none; max-height:88vh; max-height:88dvh;
    border-radius:26px; padding-bottom:0;
    box-shadow:var(--shadow-lg);
    transform:translate(-50%,-46%) scale(.97); opacity:0;
    transition:transform .3s var(--ease), opacity .22s ease, visibility 0s linear .3s;
  }
  .sheet.open{ transform:translate(-50%,-50%); opacity:1; transition:transform .3s var(--ease), opacity .22s ease; }
  .sheet-handle{ display:none; }

  .sheet-body{ flex-direction:row; align-items:flex-start; gap:34px; padding:34px 34px 32px; text-align:left; }
  .sheet-cover-col{ padding-top:0; width:230px; }
  .stage{ --bw:172px; --bh:258px; margin:10px auto 22px; }
  .sheet-info{ padding-top:6px; padding-right:28px; }
  .status-picker, .stars{ justify-content:flex-start; }
  .stars{ margin-left:-3px; }
}

@media (min-width:1100px){
  .wrap{ max-width:1120px; }
}

@media (max-width:520px){
  .filter-chip{ padding:7px 12px; font-size:12.5px; }
  .chips{ gap:6px; }
  .sync span{ display:none; }
  .sync{ padding:6px; }
  .toast{ font-size:13px; }
}

@media (max-width:719px) and (max-height:560px) and (orientation:landscape){
  /* phone held sideways: put cover beside the details */
  .sheet{ max-width:none; max-height:100vh; max-height:100dvh; border-radius:0; }
  .sheet-body{ flex-direction:row; align-items:flex-start; text-align:left; gap:24px; padding:16px 28px 24px; }
  .stage{ --bw:104px; --bh:156px; margin:8px auto 12px; }
  .sheet-handle{ display:none; }
  .status-picker, .stars{ justify-content:flex-start; }
}

@media (prefers-reduced-motion:reduce){
  *,*::before,*::after{ animation-duration:.01ms !important; animation-iteration-count:1 !important; transition-duration:.01ms !important; }
}

.spine-text .sa:empty{ display:none; }
