/* ============ Base ============ */
/* Palette condivisa con HabitTracker ("Natural Neutral") e Journal ("cream-paper planner").
   Chiaro di default, scuro automatico con il tema di sistema. */
:root {
  color-scheme: light dark;
  --bg: #F5F0E8;             /* creamLight */
  --bg-end: #E8D9C3;         /* creamMid */
  --ink: #3D3733;
  --text: var(--ink);
  --muted: rgba(61, 55, 51, .55);
  --line: rgba(61, 55, 51, .08);
  --hair: rgba(61, 55, 51, .18);
  --card: rgba(255, 255, 255, .55);   /* cardTint su materiale */
  --card-solid: #FFFDF8;              /* paperRaised */
  --field: rgba(255, 253, 248, .85);
  --sheet: #F3EEE2;                   /* paper */
  --chrome: rgba(245, 240, 232, .78);
  --primary: #8FA080;                 /* salvia */
  --primary-dk: #7C8C6E;
  --on-primary: #FFFFFF;
  --accent: #8B7355;                  /* taupe del Journal */
  --muted-fill: #C9AE8C;
  --danger: #8B2E2E;
  --shadow: 0 8px 16px rgba(0, 0, 0, .10), 0 1px 2px rgba(0, 0, 0, .04);
  --backdrop: rgba(61, 55, 51, .35);
  --serif: ui-serif, "New York", "Iowan Old Style", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --row-h: 172px;
  --plank: 14px;
  --frame: 12px;
  --tabbar-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
  --gold: #e0be72;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #221E1A;
    --bg-end: #15120F;
    --ink: #F2ECE4;
    --muted: rgba(242, 236, 228, .55);
    --line: rgba(242, 236, 228, .07);
    --hair: rgba(242, 236, 228, .18);
    --card: rgba(44, 39, 33, .55);
    --card-solid: #27231E;
    --field: rgba(255, 255, 255, .05);
    --sheet: #1E1B17;
    --chrome: rgba(34, 30, 26, .80);
    --accent: #B79E7E;
    --muted-fill: #4A4139;
    --danger: #E2897E;
    --shadow: 0 8px 16px rgba(0, 0, 0, .16);
    --backdrop: rgba(0, 0, 0, .55);
  }
}

/* Legni */
body[data-wood="noce"]   { --wood: #6b4426; --wood-hi: #8d5c36; --wood-lo: #3d2413; --back: #2c1b10; --back2: #1e120a; }
body[data-wood="rovere"] { --wood: #b07f52; --wood-hi: #cfa073; --wood-lo: #7a5431; --back: #5a3e26; --back2: #432d1b; }
body[data-wood="ebano"]  { --wood: #34271f; --wood-hi: #4d3a2f; --wood-lo: #17100c; --back: #140e0b; --back2: #0c0806; }
body[data-wood="bianco"] { --wood: #e6dfd2; --wood-hi: #faf6ee; --wood-lo: #b6ac9b; --back: #cfc6b5; --back2: #b9ae9b; }
body[data-wood="salvia"] { --wood: #7d8f74; --wood-hi: #9aac90; --wood-lo: #4f5e49; --back: #3d4a39; --back2: #2c3729; }

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.45;
  min-height: 100vh;
  padding-top: var(--safe-t);
  padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 16px);
  background: linear-gradient(180deg, var(--bg), var(--bg-end)) fixed;
  -webkit-font-smoothing: antialiased;
}
body.noscroll { overflow: hidden; }
body.arranging { padding-bottom: calc(var(--tabbar-h) + var(--safe-b) + 290px); }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; text-rendering: optimizeLegibility; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
h1, h2, h3 { font-family: var(--serif); font-weight: 400; font-style: italic; letter-spacing: 0; margin: 0; }
/* etichette di sezione in stile Journal: piccole, maiuscole, inchiostro al 55% */
.label { font-size: 11px; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.subtle { color: var(--muted); font-size: 13px; margin: 0; }
[hidden] { display: none !important; }

#app { max-width: 1180px; margin: 0 auto; }
.view { display: none; padding: 0 16px; }
.view.active { display: block; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } }

/* ============ Topbar ============ */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 18px 0 14px;
}
.topbar h1 { font-size: 34px; line-height: 1.1; }
.topbar-actions { display: flex; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--card); border: 1px solid var(--line); color: var(--text);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
}
.icon-btn.on { background: var(--primary); color: var(--on-primary); border-color: transparent; }

.searchbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.searchbar input { flex: 1; }
input[type=search], input[type=text], input[type=number], input[type=date], input:not([type]), textarea, select {
  width: 100%;
  background: var(--field); border: 1px solid var(--hair); border-radius: 14px;
  padding: 11px 13px; font-size: 16px; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; line-height: 1.5; }
select { appearance: none; -webkit-appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%; background-size: 5px 5px; background-repeat: no-repeat; padding-right: 32px; }
input[type=date] { min-height: 44px; }

/* ============ Buttons ============ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 18px; border-radius: 999px; border: 1px solid var(--hair);
  background: var(--card-solid); font-weight: 600; font-size: 15px; text-decoration: none; color: var(--text);
}
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: transparent; box-shadow: 0 4px 10px rgba(143, 160, 128, .35); }
.btn:disabled { opacity: .45; }
.btn.danger { color: var(--danger); }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn-row > .btn { flex: 1; }

/* ============ Comodino (in lettura) ============ */
/* La stanza: comodino a sinistra, cesta a destra, appoggiati sul pavimento */
.room {
  position: relative;
  display: flex; align-items: flex-end; justify-content: space-between; gap: 12px;
  padding: 10px 6px 0; margin: 4px 0 26px;
}
.room::after { /* pavimento */
  content: ""; position: absolute; left: -16px; right: -16px; bottom: 26px; height: 1px;
  background: var(--hair);
}
.scene { position: relative; display: flex; flex-direction: column; align-items: center; background: none; border: 0; padding: 0; color: var(--text); }
.scene-label { margin-top: 10px; font-size: 11px; font-weight: 500; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); height: 16px; }

/* Comodino */
.nightstand-scene { flex: 0 1 auto; }
.ns-top-area { display: flex; align-items: flex-end; gap: 4px; padding: 0 4px; min-height: 40px; max-width: 172px; }
.hstack { display: flex; flex-direction: column; align-items: center; position: relative; }
.hbook {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  margin: 0; padding: 0 9px; border: 0; border-radius: 3px;
  transform: translateX(var(--shift));
  color: var(--t);
  background:
    linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.04) 30%, rgba(0,0,0,.06) 70%, rgba(0,0,0,.3)),
    var(--c);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.14), 0 1px 0 rgba(0,0,0,.18);
  cursor: pointer; text-align: left;
}
.hbook::before { content: ""; position: absolute; top: 3px; bottom: 3px; left: 4px; width: 2px; border-left: 1px solid rgba(224,190,114,.55); border-right: 1px solid rgba(224,190,114,.55); }
.hbook.s1::before, .hbook.s3::before { display: none; }
.hbook .h-title { font-family: var(--serif); font-size: 11px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; padding-left: 4px; }
.hbook .h-author { font-size: 7.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; opacity: .8; white-space: nowrap; flex: 0 0 auto; }
.htab { position: absolute; width: 10px; height: 5px; border-radius: 0 2px 2px 0; z-index: -1; }
.more-tag { position: absolute; top: -20px; right: -6px; font-size: 11px; font-weight: 600; color: var(--muted); }
.ns-empty {
  border: 1.5px dashed var(--hair); background: transparent; border-radius: 10px; color: var(--muted);
  font-size: 11.5px; padding: 8px 10px; margin-bottom: 4px; width: 120px; line-height: 1.25;
}

.lamp { position: relative; width: 46px; height: 96px; flex: 0 0 auto; }
.lamp-shade {
  position: absolute; top: 0; left: 1px; width: 44px; height: 36px; z-index: 2;
  background: linear-gradient(90deg, #E9DEC9, #F8F2E6 45%, #DCCFB6);
  clip-path: polygon(22% 0, 78% 0, 100% 100%, 0 100%);
  border-radius: 2px;
}
.lamp-stem { position: absolute; top: 34px; left: 21px; width: 4px; height: 50px; background: linear-gradient(90deg, #6E645C, #A3968A, #6E645C); border-radius: 2px; }
.lamp-base { position: absolute; bottom: 0; left: 9px; width: 28px; height: 10px; background: var(--primary); border-radius: 14px 14px 3px 3px; box-shadow: inset 0 -2px 0 rgba(0,0,0,.15); }
.lamp-glow {
  position: absolute; left: 50%; top: -10px; width: 220px; height: 170px; transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(255, 214, 140, .42), rgba(255, 214, 140, .12) 55%, rgba(255, 214, 140, 0));
  pointer-events: none; z-index: 0;
}
@media (prefers-color-scheme: dark) { .lamp-glow { background: radial-gradient(closest-side, rgba(255, 200, 110, .34), rgba(255, 200, 110, .1) 55%, rgba(255, 200, 110, 0)); } }

.ns-table { display: flex; flex-direction: column; align-items: center; position: relative; z-index: 1; }
.ns-top {
  width: 172px; height: 12px; border-radius: 4px 4px 2px 2px;
  background: linear-gradient(180deg, var(--wood-hi), var(--wood) 60%, var(--wood-lo));
  box-shadow: 0 3px 4px rgba(0,0,0,.25);
}
.ns-body {
  width: 156px; height: 98px; padding: 9px 10px; display: flex; flex-direction: column; gap: 7px;
  background: linear-gradient(90deg, var(--wood-lo), var(--wood) 12%, var(--wood) 88%, var(--wood-lo));
  box-shadow: inset 0 6px 6px -4px rgba(0,0,0,.35);
}
.ns-drawer {
  flex: 1; border-radius: 3px; display: grid; place-items: center;
  background: linear-gradient(180deg, var(--wood-hi), var(--wood));
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18), 0 1px 0 rgba(255,255,255,.12);
}
.ns-drawer i { width: 22px; height: 5px; border-radius: 3px; background: #C9AE8C; box-shadow: 0 1px 1px rgba(0,0,0,.35); }
.ns-legs { width: 140px; display: flex; justify-content: space-between; }
.ns-legs i { width: 9px; height: 16px; background: var(--wood-lo); border-radius: 0 0 3px 3px; }

/* Cesta della wishlist */
.basket-scene { flex: 0 0 auto; cursor: pointer; }
.basket { position: relative; width: 140px; height: 162px; }
.basket-books { position: absolute; left: 0; right: 0; bottom: 52px; height: 120px; }
.bbook {
  position: absolute; bottom: 0; display: block; border-radius: 2px 2px 0 0;
  transform: rotate(var(--r)); transform-origin: 50% 100%;
  background:
    linear-gradient(90deg, rgba(0,0,0,.3), rgba(255,255,255,.14) 20%, rgba(0,0,0,.05) 70%, rgba(0,0,0,.32)),
    var(--c);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.15);
}
.bbook.s0::before { content: ""; position: absolute; left: 1px; right: 1px; top: 8px; height: 4px; border-top: 1px solid var(--gold); border-bottom: 1px solid var(--gold); opacity: .7; }
.basket-front {
  position: absolute; left: 4px; right: 4px; bottom: 0; height: 84px; z-index: 2;
  border-radius: 6px 6px 26px 26px;
  background:
    repeating-linear-gradient(90deg, rgba(90, 60, 30, .22) 0 2px, transparent 2px 13px),
    repeating-linear-gradient(0deg, #CDAA74 0 7px, #B98F57 7px 9px, #D6B680 9px 16px, #B98F57 16px 18px);
  box-shadow: inset 0 -10px 14px rgba(70, 45, 20, .28), inset 0 2px 0 rgba(255,255,255,.2), 0 6px 10px rgba(0,0,0,.18);
}
.basket-rim {
  position: absolute; left: -4px; right: -4px; top: -6px; height: 12px; border-radius: 8px;
  background: repeating-linear-gradient(115deg, #C9A46C 0 6px, #A9804A 6px 8px);
  box-shadow: 0 2px 3px rgba(0,0,0,.25);
}
.basket-handle {
  position: absolute; left: 22px; right: 22px; top: 4px; height: 118px; z-index: 0;
  border: 7px solid #B98F57; border-bottom: 0; border-radius: 60px 60px 0 0;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.18);
}

.place-note { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; font-size: 14px; color: var(--muted); margin: 0 0 14px; }
.place-note b { color: var(--text); }
.wish-row { cursor: pointer; }
.wish-row .cover { width: 44px; height: 66px; border-radius: 2px 4px 4px 2px; box-shadow: 0 3px 8px rgba(0,0,0,.2); }
.wish-row .cover-fallback { margin: 2px; padding: 2px; }
.wish-row .cover-fallback b { font-size: 7px; }
.wish-row .cover-fallback small { display: none; }

@media (max-width: 360px) {
  .room { gap: 4px; }
  .basket { transform: scale(.86); transform-origin: bottom right; }
}
@media (min-width: 700px) {
  .room { justify-content: space-around; }
}

/* ============ Libreria ============ */
.bookcase {
  position: relative;
  margin: 0 auto;
  border: var(--frame) solid var(--wood);
  border-top-width: 18px;
  border-bottom-width: 0;
  border-radius: 6px 6px 0 0;
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.10) 0 1px, transparent 1px 7px, rgba(255,255,255,.025) 7px 8px, transparent 8px 15px),
    linear-gradient(180deg, var(--back), var(--back2));
  box-shadow:
    inset 0 0 40px rgba(0, 0, 0, .65),
    inset 0 18px 18px -12px rgba(0, 0, 0, .7),
    0 20px 40px rgba(0, 0, 0, .45);
  border-image: none;
}
.bookcase::before { /* cornice superiore */
  content: ""; position: absolute; left: calc(-1 * var(--frame) - 6px); right: calc(-1 * var(--frame) - 6px); top: -26px; height: 12px;
  background: linear-gradient(var(--wood-hi), var(--wood-lo)); border-radius: 4px 4px 2px 2px;
  box-shadow: 0 3px 6px rgba(0,0,0,.4);
}
.bookcase-foot {
  max-width: 100%; height: 22px; margin: 0 auto;
  background: linear-gradient(var(--wood-lo), var(--wood) 30%, var(--wood-lo));
  border-radius: 0 0 4px 4px; box-shadow: 0 10px 20px rgba(0,0,0,.5);
}

.shelf { position: relative; }
.shelf-head {
  display: flex; align-items: center; justify-content: center; gap: 6px; flex-wrap: wrap;
  padding: 12px 8px 0;
  position: relative; z-index: 1;
}
.plate {
  display: inline-block;
  /* etichetta di carta crema, corsivo serif come i titoli del Journal */
  font-family: var(--serif); font-style: italic; font-size: 15px; font-weight: 400; letter-spacing: 0;
  color: #3D3733;
  background: #F3EEE2;
  padding: 3px 14px 4px; border-radius: 4px;
  box-shadow: inset 0 0 0 1px rgba(61, 55, 51, .18), 0 2px 5px rgba(0,0,0,.45);
  position: relative;
  max-width: 70vw; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.plate small { font-family: var(--sans); font-style: normal; font-size: 11px; font-weight: 500; opacity: .55; margin-left: 6px; letter-spacing: 0; }
.shelf-tools { display: none; gap: 4px; }
.arranging .shelf-tools { display: inline-flex; }
.shelf-tools button {
  border: 0; background: rgba(0,0,0,.45); color: #f3e3c3; border-radius: 8px;
  height: 28px; min-width: 28px; padding: 0 7px; font-size: 13px;
}

.row {
  position: relative;
  height: var(--row-h);
  display: flex; align-items: flex-end;
  padding: 0 10px var(--plank);
  z-index: 0; /* contesto di impilamento: i segnalibri restano dietro al dorso */
}
.row::before { /* ombra sul fondo */
  content: ""; position: absolute; left: 0; right: 0; bottom: var(--plank); height: 26px;
  background: linear-gradient(transparent, rgba(0,0,0,.35)); pointer-events: none;
}
.row::after { /* ripiano */
  content: ""; position: absolute; left: calc(-1 * var(--frame)); right: calc(-1 * var(--frame)); bottom: 0; height: var(--plank);
  background:
    linear-gradient(90deg, rgba(0,0,0,.25), transparent 4%, transparent 96%, rgba(0,0,0,.25)),
    linear-gradient(180deg, var(--wood-hi) 0, var(--wood) 35%, var(--wood-lo) 100%);
  box-shadow: 0 6px 8px rgba(0, 0, 0, .5);
  z-index: 1; pointer-events: none;
}
.row.empty { justify-content: center; align-items: center; color: rgba(255,240,220,.35); font-style: italic; font-family: var(--serif); font-size: 14px; }

/* Oggetti sugli scaffali */
.item { position: relative; flex: 0 0 auto; transition: transform .18s ease, opacity .2s, filter .2s; }
.item.dim { opacity: .18; filter: grayscale(.8); }
.item.match { transform: translateY(-6px); }
.item.sel {
  transform: translateY(-12px);
  filter: drop-shadow(0 0 6px rgba(255, 210, 122, .9)) drop-shadow(0 12px 10px rgba(0,0,0,.6));
  z-index: 3;
}
.arranging .item:not(.sel) { cursor: grab; }
.arranging.has-sel .item:not(.sel):hover { transform: translateX(3px); }

/* Dorso */
.book {
  margin-right: 1px;
  color: var(--t);
  border-radius: 2px 2px 1px 1px;
  background:
    linear-gradient(90deg, rgba(0,0,0,.38), rgba(255,255,255,.14) 16%, rgba(255,255,255,.05) 38%, rgba(0,0,0,.06) 70%, rgba(0,0,0,.42)),
    var(--c);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.18), inset 0 2px 0 rgba(255,255,255,.08);
  display: flex; flex-direction: column; align-items: center;
  padding: 10px 0 8px;
  cursor: pointer;
}
.book .spine-title, .book .spine-author {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  /* niente puntini: il testo è dimensionato per starci intero (leggibile con lo zoom) */
  white-space: nowrap; overflow: hidden; text-overflow: clip;
  overflow-wrap: normal; word-break: keep-all;
  min-height: 0;
  max-width: 100%;
  line-height: 1.05;
}
.book .spine-title { font-family: var(--serif); font-weight: 600; flex: 1 1 auto; letter-spacing: .02em; text-align: center; }
.book .spine-author { font-size: 8.5px; text-transform: uppercase; letter-spacing: .08em; opacity: .82; margin-top: 6px; flex: 0 0 auto; max-height: 40%; font-weight: 600; }
.book.narrow .spine-author { display: none; }

/* varianti del dorso */
.book.s0::before, .book.s0::after {
  content: ""; position: absolute; left: 1px; right: 1px; height: 5px;
  border-top: 1px solid var(--gold); border-bottom: 1px solid var(--gold); opacity: .75;
}
.book.s0::before { top: 5px; } .book.s0::after { bottom: 5px; }
.book.s0 { padding: 15px 0 14px; }
.book.s1 .spine-title {
  flex: 0 1 auto; margin: auto 0;
  background: rgba(0,0,0,.28); padding: 8px 1px;
  outline: 1px solid rgba(224,190,114,.55); outline-offset: -2px;
}
.book.s2::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 20%; background: rgba(0,0,0,.28); border-bottom: 1px solid rgba(224,190,114,.5); }
.book.s2 .spine-title { margin-top: 24%; }
.book.s3 { box-shadow: inset 0 0 0 1px rgba(0,0,0,.2), inset 0 -16px 0 rgba(0,0,0,.18); }

/* segnalibri che spuntano */
.ribbon {
  position: absolute; width: 6px; border-radius: 1px 1px 0 0;
  clip-path: polygon(0 0, 50% 3px, 100% 0, 100% 100%, 0 100%);
  box-shadow: inset -1px 0 0 rgba(0,0,0,.25);
  z-index: -1;
}
.ribbon.paper { width: 9px; clip-path: none; border-radius: 1px; }

/* Decorazioni */
.deco {
  display: flex; align-items: flex-end; justify-content: center;
  line-height: 1; margin: 0 3px;
  filter: drop-shadow(0 5px 3px rgba(0, 0, 0, .55));
  user-select: none; -webkit-user-select: none;
  cursor: default;
}
.arranging .deco { cursor: grab; }
.deco .emo { display: block; transform: translateY(2px); }
.deco-bookend {
  width: 18px; height: 72px; margin: 0 2px;
  background: linear-gradient(90deg, #3a3a3a, #8a8a8a 40%, #4a4a4a);
  border-radius: 3px 3px 0 0; position: relative;
}
.deco-bookend::after { content: ""; position: absolute; bottom: 0; left: -6px; width: 30px; height: 5px; background: #2a2a2a; border-radius: 2px; }
.deco-stack { flex-direction: column; align-items: center; gap: 0; }
.deco-stack i { display: block; height: 13px; border-radius: 2px; box-shadow: inset 0 -2px 0 rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.12); }
.deco-stack .emo { margin-bottom: -2px; }
.deco-frame {
  width: 50px; height: 64px; margin: 0 4px; transform: rotate(-3deg); transform-origin: bottom;
  background: #f3ead8; border: 5px solid #8a5a2b; box-shadow: inset 0 0 0 3px #f3ead8, inset 0 0 0 4px #d7c7a8;
  display: grid; place-items: center; font-size: 26px;
}

.endslot {
  width: 36px; height: 110px; flex: 0 0 auto; margin-left: 4px;
  border: 2px dashed rgba(255, 220, 160, .45); border-radius: 6px;
  display: grid; place-items: center; color: rgba(255, 220, 160, .7); font-size: 20px;
}

.add-shelf { display: block; margin: 16px auto 22px; }

/* Benvenuto */
.welcome {
  background: var(--card); border: 1px solid var(--line); border-radius: 28px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); box-shadow: var(--shadow);
  padding: 20px; margin-bottom: 20px;
}
.welcome h2 { font-size: 24px; margin-bottom: 6px; }
.welcome p { color: var(--muted); margin: 0 0 14px; font-size: 14.5px; }

/* ============ Barra "sistema" ============ */
.arrange-bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tabbar-h) + var(--safe-b));
  z-index: 30;
  background: var(--chrome);
  backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-top: 1px solid var(--hair);
  padding: 10px 12px 10px;
  max-width: 100%;
}
.arrange-inner { max-width: 900px; margin: 0 auto; }
.arrange-hint { font-size: 13px; color: var(--muted); margin-bottom: 8px; display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.arrange-hint b { color: var(--text); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; border: 1px solid var(--hair); background: transparent; border-radius: 999px;
  padding: 6px 12px; font-size: 13px; color: var(--text);
}
.chip.on { background: var(--primary); color: var(--on-primary); border-color: transparent; font-weight: 600; }
.palette { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; scrollbar-width: none; }
.palette::-webkit-scrollbar { display: none; }
.pal-item {
  flex: 0 0 auto; width: 56px; height: 56px; border-radius: 16px; border: 1px solid var(--line);
  background: var(--card-solid); display: grid; place-items: center; font-size: 30px; padding: 0; position: relative;
}
.pal-item.on { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.pal-item .mini { transform: scale(.55); }
.arrange-actions { display: flex; gap: 8px; }
.arrange-actions .btn { flex: 1; }

/* ============ Tabbar ============ */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + var(--safe-b));
  padding-bottom: var(--safe-b);
  display: grid; grid-template-columns: 1fr 1fr auto 1fr 1fr; align-items: center;
  background: var(--chrome);
  backdrop-filter: blur(24px) saturate(1.4); -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-top: 1px solid var(--line);
}
.tabbar button {
  background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-size: 10.5px; padding: 6px 0;
}
.tabbar button.active { color: var(--ink); }
.tabbar .tab-add {
  width: 54px; height: 54px; border-radius: 50%; margin: 0 6px; transform: translateY(-10px);
  background: var(--primary); color: var(--on-primary); justify-content: center;
  box-shadow: 0 8px 16px rgba(0,0,0,.16), 0 0 0 4px var(--bg);
}
.tabbar .tab-add svg { width: 26px; height: 26px; stroke-width: 2.4; }

/* ============ Modali / sheet ============ */
.modal { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: var(--backdrop); animation: fadein .2s ease; }
.modal-panel {
  position: relative; width: 100%; max-width: 680px;
  max-height: calc(100% - var(--safe-t) - 16px);
  background: linear-gradient(180deg, var(--bg), var(--bg-end));
  border-radius: 28px 28px 0 0;
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  padding-bottom: calc(var(--safe-b) + 12px);
  box-shadow: 0 -10px 40px rgba(0,0,0,.2);
  animation: slideup .3s cubic-bezier(.2, .9, .3, 1);
}
.modal.tall .modal-panel { height: calc(100% - var(--safe-t) - 12px); }
.modal.closing .modal-panel { animation: slidedown .2s ease forwards; }
.modal.closing .modal-backdrop { animation: fadeout .2s ease forwards; }
@keyframes slideup { from { transform: translateY(100%); } }
@keyframes slidedown { to { transform: translateY(100%); } }
@keyframes fadein { from { opacity: 0; } }
@keyframes fadeout { to { opacity: 0; } }
@media (min-width: 760px) {
  .modal { align-items: center; }
  .modal-panel { border-radius: 28px; max-height: 88vh; }
  .modal.tall .modal-panel { height: 88vh; }
}

.sheet-head {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 14px; background: var(--chrome);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--line);
}
.sheet-head b { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 17px; }
.sheet-head .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--hair); }
.link-btn { background: none; border: 0; color: var(--accent); font-weight: 600; padding: 8px 6px; font-size: 16px; }
.pad { padding: 16px 20px; }
.pad h2 { font-size: 26px; margin-bottom: 10px; }

/* warmCard dell'HabitTracker: superficie smerigliata, bordo sottile, ombra morbida */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 24px;
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow);
  padding: 16px 18px; margin-bottom: 14px;
}
.card h3 { font-size: 20px; margin-bottom: 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card p { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.card p:last-child { margin-bottom: 0; }

/* Scheda libro */
.book-hero { display: flex; gap: 16px; align-items: flex-end; padding: 18px 16px 10px; }
.cover {
  position: relative; flex: 0 0 auto; width: 112px; height: 168px; border-radius: 3px 6px 6px 3px; overflow: hidden;
  box-shadow: 0 12px 24px rgba(0,0,0,.55), inset 3px 0 0 rgba(0,0,0,.25);
  background: var(--c, #444);
}
.cover img { position: relative; z-index: 1; width: 100%; height: 100%; object-fit: cover; display: block; }
.cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(0,0,0,.28), rgba(255,255,255,.08) 6%, transparent 12%); pointer-events: none; }
.cover-fallback {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
  padding: 12px 10px; color: var(--t, #f4ead2);
  border: 1px solid rgba(224,190,114,.5); margin: 6px; border-radius: 2px;
}
.cover-fallback b { font-family: var(--serif); font-size: 14px; line-height: 1.15; display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.cover-fallback small { margin-top: 8px; font-size: 9.5px; text-transform: uppercase; letter-spacing: .08em; opacity: .85; }
.cover-edit {
  position: absolute; right: 4px; bottom: 4px; z-index: 2; width: 28px; height: 28px; border-radius: 50%;
  background: rgba(0,0,0,.55); display: grid; place-items: center; font-size: 13px; cursor: pointer;
}
.hero-info { min-width: 0; flex: 1; }
.hero-info h2 { font-size: 22px; line-height: 1.15; margin-bottom: 4px; word-wrap: break-word; }
.hero-info .author { color: var(--accent); font-weight: 600; margin: 0 0 4px; font-size: 15px; }
.hero-info .meta { color: var(--muted); font-size: 12.5px; margin: 0; }
.hero-info .series { color: var(--muted); font-size: 12.5px; font-style: italic; margin: 0 0 4px; }

.book-body { padding: 4px 16px 20px; }

.stars { display: flex; gap: 4px; justify-content: center; margin: 6px 0 14px; }
.stars button { background: none; border: 0; padding: 2px; font-size: 36px; line-height: 1; color: rgba(255,255,255,.18); transition: transform .12s; }
.stars button { color: var(--hair); }
.stars button.on { color: var(--muted-fill); text-shadow: none; }
@media (prefers-color-scheme: dark) { .stars button.on { color: #C9AE8C; } }
.stars button:active { transform: scale(1.25); }
.stars.small button { font-size: 15px; padding: 0; }

.seg { display: flex; background: rgba(118, 118, 128, .12); border-radius: 12px; padding: 2px; margin-bottom: 14px; }
.seg button { flex: 1; background: none; border: 0; padding: 9px 4px; border-radius: 9px; font-size: 14px; color: var(--muted); font-weight: 600; }
.seg button { color: var(--text); font-weight: 500; }
.seg button.on { background: var(--card-solid); color: var(--text); font-weight: 600; box-shadow: 0 3px 8px rgba(0,0,0,.12), 0 1px 1px rgba(0,0,0,.04); }

.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.fields.one { grid-template-columns: 1fr; }
.field label, label.field { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; font-size: 11px; font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.field + .field { margin-top: 0; }
.form-stack > * + * { margin-top: 12px; }

.quote-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 10px; }
.quote-thumb, .quote-add {
  position: relative; aspect-ratio: 3 / 4; border-radius: 10px; overflow: hidden; border: 1px solid var(--line);
  background: var(--bg); padding: 0;
}
.quote-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.quote-thumb .rib { position: absolute; top: -2px; right: 10px; width: 12px; height: 30px; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); box-shadow: 0 2px 4px rgba(0,0,0,.4); }
.quote-thumb .pg { position: absolute; left: 6px; bottom: 6px; background: rgba(0,0,0,.6); border-radius: 6px; padding: 1px 6px; font-size: 11px; color: #fff; }
.quote-add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; color: var(--accent); font-size: 12.5px; font-weight: 600; border-style: dashed; border-color: var(--hair); background: transparent; cursor: pointer; text-align: center; padding: 6px; }
.quote-add .big { font-size: 26px; }

.guide-q { margin-bottom: 12px; }
.guide-q label { display: block; font-size: 14px; margin-bottom: 6px; font-family: var(--serif); color: var(--text); }
.guide-q textarea { min-height: 56px; font-size: 15px; }
details.guide > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
details.guide > summary::-webkit-details-marker { display: none; }
details.guide > summary::after { content: "›"; font-size: 24px; color: var(--muted); transform: rotate(90deg); transition: transform .2s; }
details.guide[open] > summary::after { transform: rotate(-90deg); }
details.guide[open] > summary { margin-bottom: 12px; }
.guide-progress { font-size: 12px; color: var(--muted); font-family: var(--sans); font-weight: 500; }
.moods { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { width: 32px; height: 32px; border-radius: 50%; border: 2px solid transparent; padding: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.3); }
.swatch.on { border-color: var(--text); }
.swatch.auto { background: conic-gradient(#7b2d26, #b08a3e, #2f4a3a, #1f3550, #5a3d5c, #7b2d26); }
.wood-swatch { width: 64px; height: 44px; border-radius: 10px; border: 2px solid transparent; padding: 0; position: relative; overflow: hidden; }
.wood-swatch.on { border-color: var(--accent); }
.wood-swatch span { position: absolute; left: 0; right: 0; bottom: 0; font-size: 10px; background: rgba(0,0,0,.5); color: #fff; padding: 1px 0; }

.tags { display: flex; flex-wrap: wrap; gap: 6px; }

/* Viewer foto */
.viewer { display: flex; flex-direction: column; min-height: 100%; }
.viewer-img { background: #000; display: grid; place-items: center; min-height: 46vh; max-height: 62vh; overflow: auto; }
.viewer-img img { max-width: 100%; max-height: 62vh; object-fit: contain; display: block; }
.viewer-img.zoom { place-items: start; }
.viewer-img.zoom img { max-width: none; max-height: none; width: 180%; }
.viewer-form { padding: 14px 16px; }
.viewer-book { font-family: var(--serif); font-size: 17px; margin-bottom: 12px; }

/* Lista segnalibri */
.bm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.bm-card { background: var(--card-solid); border: 1px solid var(--line); box-shadow: var(--shadow); border-radius: 20px; overflow: hidden; padding: 0; text-align: left; color: var(--text); position: relative; }
.bm-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: #000; }
.bm-card .bm-info { padding: 8px 10px 10px; }
.bm-card b { font-family: var(--serif); font-size: 14px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-card small { color: var(--muted); font-size: 12px; display: block; }
.bm-card .bm-note { font-size: 12.5px; color: var(--muted); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-style: italic; }
.bm-card .rib { position: absolute; top: -2px; right: 12px; width: 14px; height: 34px; clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 75%, 0 100%); box-shadow: 0 2px 4px rgba(0,0,0,.4); }
.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }
.empty-state .big { font-size: 54px; margin-bottom: 8px; }
.empty-state h3 { color: var(--text); margin-bottom: 6px; }

/* Ricerca / aggiunta libri */
.result { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.result img, .result .noimg { width: 44px; height: 66px; border-radius: 3px; object-fit: cover; flex: 0 0 auto; background: var(--card-solid); }
.result .r-info { flex: 1; min-width: 0; }
.result b { display: block; font-family: var(--serif); font-size: 15px; line-height: 1.2; }
.result small { color: var(--muted); font-size: 12.5px; }
.result .btn { flex: 0 0 auto; }

/* Import */
.callout { border-radius: 12px; padding: 12px 14px; font-size: 14px; margin: 0 0 14px; line-height: 1.45; }
.callout { border-radius: 18px; }
.callout.warn { background: rgba(201, 174, 140, .22); border: 1px solid rgba(139, 115, 85, .35); }
.callout.info { background: rgba(143, 160, 128, .16); border: 1px solid rgba(143, 160, 128, .4); }
.callout b { color: var(--text); }
.steps { padding-left: 0; list-style: none; counter-reset: s; margin: 0 0 16px; }
.steps li { counter-increment: s; position: relative; padding: 0 0 14px 42px; font-size: 14.5px; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: -2px; width: 28px; height: 28px; border-radius: 50%;
  background: var(--card-solid); border: 1px solid var(--accent); color: var(--accent); display: grid; place-items: center; font-weight: 700; font-size: 13px;
}
.steps li small { display: block; color: var(--muted); margin-top: 4px; font-size: 13px; }
.steps code, .card code { background: var(--bg); padding: 1px 6px; border-radius: 5px; font-size: 13px; }
.mock {
  margin-top: 8px; border-radius: 10px; border: 1px solid var(--line); background: #f4f1ea; color: #382110; padding: 10px; font-size: 12.5px; font-family: Georgia, serif;
}
.mock .mock-btn { display: inline-block; background: #f4f1ea; border: 1px solid #d6d0c4; border-radius: 3px; padding: 3px 10px; font-family: var(--sans); font-weight: 600; font-size: 12px; color: #333; }
.mock .mock-link { color: #00635d; text-decoration: underline; }
.radio-list label { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.radio-list label:last-child { border-bottom: 0; }
.radio-list input { margin-top: 3px; accent-color: var(--accent); width: 18px; height: 18px; flex: 0 0 auto; }
.radio-list small { display: block; color: var(--muted); font-size: 12.5px; }
.import-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.import-stats div { background: var(--card-solid); border: 1px solid var(--line); border-radius: 16px; padding: 10px; text-align: center; }
.import-stats b { display: block; font-size: 22px; font-family: var(--serif); }
.import-stats small { color: var(--muted); font-size: 12px; }

/* Action sheet */
.as { padding: 14px 12px 6px; display: flex; flex-direction: column; gap: 8px; }
.as h3 { text-align: center; font-size: 15px; color: var(--muted); font-family: var(--sans); font-weight: 600; margin: 4px 0 6px; }
.as button { padding: 14px; border-radius: 14px; border: 0; background: var(--card-solid); font-size: 16px; font-weight: 600; }
.as button.danger { color: var(--danger); }
.as button.cancel { background: transparent; color: var(--muted); }

/* Statistiche */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 14px; }
@media (min-width: 700px) { .stat-grid { grid-template-columns: repeat(4, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 24px; padding: 16px; box-shadow: var(--shadow); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.stat b { display: block; font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 32px; line-height: 1.1; color: var(--text); }
.stat small { color: var(--muted); font-size: 12.5px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 150px; padding-top: 18px; }
.bar { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; min-width: 0; }
.bar i { display: block; width: 100%; max-width: 38px; background: var(--primary); border-radius: 8px 8px 3px 3px; position: relative; min-height: 2px; }
.bar i span { position: absolute; top: -17px; left: 0; right: 0; text-align: center; font-size: 11px; color: var(--text); font-style: normal; }
.bar small { font-size: 10.5px; color: var(--muted); margin-top: 4px; }
.rank { list-style: none; padding: 0; margin: 0; }
.rank li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.rank li:last-child { border-bottom: 0; }
.rank li span:last-child { color: var(--muted); }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: 13px; margin: 5px 0; }
.dist-row .track { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.dist-row .track i { display: block; height: 100%; background: var(--primary); border-radius: 4px; }
.dist-row .track { background: var(--line) !important; }
.dist-row span:first-child { width: 58px; color: var(--accent); letter-spacing: -1px; }
.dist-row span:last-child { width: 28px; text-align: right; color: var(--muted); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-b) + 20px); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,.2); transition: all .25s ease; white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Schermi grandi */
@media (min-width: 900px) {
  :root { --row-h: 188px; }
  .topbar h1 { font-size: 34px; }
}

/* ============ Disposizione libera sugli scaffali ============ */
/* Libri sdraiati (in pila) */
.pile { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; margin: 0 2px; flex: 0 0 auto; }
.book.flat {
  flex-direction: row; align-items: center; justify-content: space-between; gap: 6px;
  padding: 0 10px; margin: 0; border-radius: 1px 2px 2px 1px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.04) 30%, rgba(0,0,0,.06) 70%, rgba(0,0,0,.34)),
    var(--c);
}
.pile > .book.flat:nth-child(3n+1) { margin-left: 5px; }
.pile > .book.flat:nth-child(3n+2) { margin-right: 4px; }
.book.flat .spine-title, .book.flat .spine-author { writing-mode: horizontal-tb; transform: none; max-width: none; max-height: 100%; }
.book.flat .spine-title { flex: 1 1 auto; text-align: left; min-width: 0; margin: 0; }
.book.flat .spine-author { margin: 0; max-height: none; }
.book.flat.s0 { padding: 0 16px; }
.book.flat.s0::before, .book.flat.s0::after {
  top: 1px; bottom: 1px; height: auto; width: 4px; right: auto;
  border-top: 0; border-bottom: 0; border-left: 1px solid var(--gold); border-right: 1px solid var(--gold);
}
.book.flat.s0::before { left: 5px; }
.book.flat.s0::after { left: auto; right: 5px; }
.book.flat.s1 .spine-title { padding: 1px 6px; margin: 0; }
.book.flat.s2::before { top: 0; bottom: 0; left: 0; right: auto; width: 16%; height: auto; border-bottom: 0; border-right: 1px solid rgba(224,190,114,.5); }
.book.flat.s2 .spine-title { margin: 0 0 0 16%; }
.book.flat.s3 { box-shadow: inset 0 0 0 1px rgba(0,0,0,.2), inset -16px 0 0 rgba(0,0,0,.18); }

/* Libri appoggiati in obliquo */
.item.lean { position: relative; flex: 0 0 auto; cursor: pointer; }
.item.lean .book { position: absolute; bottom: 0; margin: 0; }
.item.lean.lean-l .book { left: var(--off); transform-origin: 0 100%; transform: rotate(calc(-1 * var(--lean))); }
.item.lean.lean-r .book { left: 0; transform-origin: 100% 100%; transform: rotate(var(--lean)); }

/* Separatore: pannello di legno a tutta altezza */
.deco-divider {
  width: 10px; height: calc(var(--row-h) - var(--plank));
  background: linear-gradient(90deg, var(--wood-lo), var(--wood-hi) 35%, var(--wood) 70%, var(--wood-lo));
  border-radius: 1px;
  box-shadow: 3px 0 5px rgba(0,0,0,.3), -3px 0 5px rgba(0,0,0,.3);
}

/* Etichetta sul bordo della mensola */
.label-anchor { width: 8px; height: 24px; margin: 0; filter: none; z-index: 2; align-self: flex-end; }
.shelf-label {
  position: absolute; top: 100%; left: -2px; margin-top: 1px;
  height: 12px; padding: 0 6px; border-radius: 2px;
  font-family: var(--serif); font-style: italic; font-size: 9.5px; line-height: 12px; white-space: nowrap;
  color: #3D3733; background: #F3EEE2;
  box-shadow: inset 0 0 0 1px rgba(61,55,51,.22), 0 1px 2px rgba(0,0,0,.4);
}
.arranging .label-anchor::before {
  content: ""; position: absolute; left: 3px; bottom: 0; width: 2px; height: 22px; border-radius: 1px;
  background: rgba(255, 225, 170, .75);
}
.label-anchor.sel .shelf-label { outline: 2px solid #ffd27a; }

/* Palette e controlli di orientamento */
.pal-item { flex-direction: column; gap: 2px; width: 64px; height: 64px; }
.pal-name { font-size: 9px; color: var(--muted); line-height: 1; max-width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pal-label { font-family: var(--serif); font-style: italic; font-size: 12px; color: #3D3733; background: #F3EEE2; padding: 1px 6px; border-radius: 2px; box-shadow: inset 0 0 0 1px rgba(61,55,51,.25); }
.pal-divider { width: 7px; height: 34px; border-radius: 1px; background: linear-gradient(90deg, #7a5431, #cfa073 40%, #b07f52 70%, #7a5431); }
.orient { display: flex; gap: 6px; margin: 2px 0 8px; }
.orient-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 5px;
  padding: 8px 2px 7px; border-radius: 14px; border: 1px solid var(--hair); background: var(--card-solid);
  font-size: 11px; color: var(--text); min-height: 58px;
}
.orient-btn.on { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.orient-btn i { display: block; background: var(--ink); border-radius: 2px; }
.o-up { width: 8px; height: 24px; }
.o-flat { width: 24px; height: 8px; }
.o-lean-l { width: 8px; height: 24px; transform: rotate(-16deg); transform-origin: bottom left; }
.o-lean-r { width: 8px; height: 24px; transform: rotate(16deg); transform-origin: bottom right; }

/* ============ La stanza da lettura (2.5D) ============ */
:root {
  --wall: #EDE3D1; --wall-stripe: rgba(139, 115, 85, .07); --ceiling: #F6F0E6;
  --baseboard: #F8F3EA; --baseboard-sh: rgba(61, 55, 51, .18);
  --floor1: #BE9165; --floor2: #A97E54; --floor-dark: rgba(60, 35, 15, .35);
}
@media (prefers-color-scheme: dark) {
  :root {
    --wall: #2C2621; --wall-stripe: rgba(255, 240, 220, .03); --ceiling: #241F1B;
    --baseboard: #3A322B; --baseboard-sh: rgba(0, 0, 0, .4);
    --floor1: #5E4330; --floor2: #4E3726; --floor-dark: rgba(0, 0, 0, .45);
  }
}
#view-library .topbar, #view-library .searchbar { position: relative; z-index: 2; }
.stage-wrap { position: relative; margin: 0 -16px; }
body.in-library, body.in-library.arranging { padding-bottom: 0; }
.stage {
  height: 600px; overflow-x: auto; overflow-y: hidden;
  scroll-snap-type: x mandatory; scrollbar-width: none; overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
.stage::-webkit-scrollbar { display: none; }
.room3d {
  position: relative; display: flex; height: 100%; width: max-content; min-width: 100%;
  background:
    repeating-linear-gradient(90deg, var(--wall-stripe) 0 2px, transparent 2px 26px),
    var(--wall);
}
.room-layer { position: absolute; inset: 0; pointer-events: none; }
.floor { z-index: 0; }
.wall { position: relative; height: 100%; flex: 0 0 auto; z-index: 1; }
.wall-left { width: 390px; scroll-snap-align: start; }
.wall-right { width: 300px; scroll-snap-align: end; }
.wall-center {
  width: calc(100vw - 56px); max-width: 860px; scroll-snap-align: center;
  height: calc(100% - var(--floor-line, 58px));
  overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 44px 10px 0; scrollbar-width: none;
}
.wall-center::-webkit-scrollbar { display: none; }
.wall-center .bookcase-foot { margin-bottom: 0; }
@media (min-width: 1100px) {
  .stage { overflow-x: hidden; }
  .room3d { width: 100%; }
  .wall-center { width: auto; flex: 1 1 auto; max-width: none; }
  .wall-left { width: 400px; } .wall-right { width: 320px; }
}

/* pareti laterali: più scure verso l'angolo e verso chi guarda */
.wall-bg { position: absolute; inset: 0; pointer-events: none; }
.wall-left .wall-bg { background: linear-gradient(90deg, rgba(0,0,0,.05), rgba(0,0,0,.09) 80%, rgba(0,0,0,.2)); }
.wall-right .wall-bg { background: linear-gradient(270deg, rgba(0,0,0,.05), rgba(0,0,0,.09) 80%, rgba(0,0,0,.2)); }
.wall-left .baseboard, .wall-right .baseboard { display: none; }

/* soffitto, battiscopa e pavimento: poligoni calcolati in base alla larghezza delle pareti */
.ceiling { background: var(--ceiling); z-index: 0; box-shadow: none; }
.crown { background: linear-gradient(180deg, var(--baseboard), rgba(0,0,0,.06)); z-index: 0; }
.baseboards { background: var(--baseboard); z-index: 0; filter: drop-shadow(0 -1px 0 var(--baseboard-sh)); }
/* i disegni della stanza non usano lo stile delle icone (contorno) */
.armchair, .pet, .floor-plant, .rug { stroke: none; fill: currentColor; color: transparent; }
.floor {
  background:
    linear-gradient(180deg, var(--floor-dark), transparent 70%),
    repeating-conic-gradient(from 180deg at var(--vp, 50%) -900px, var(--floor1) 0deg 1.15deg, var(--floor2) 1.15deg 1.25deg);
}

/* pulsanti per "girarsi" a destra e sinistra (iPhone) */
.pan-btn {
  position: absolute; top: 46%; z-index: 6; width: 34px; height: 34px; border-radius: 50%;
  display: grid; place-items: center; font-size: 22px; line-height: 1; padding: 0 0 3px;
  background: var(--chrome); color: var(--text); border: 1px solid var(--line);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); box-shadow: var(--shadow);
}
.pan-left { left: 6px; } .pan-right { right: 6px; }

/* quadro e finestra seguono l'inclinazione delle pareti */
.wall-art {
  position: absolute; top: 15%; left: 190px; width: 120px; height: 86px;
  transform: perspective(600px) rotateY(24deg); transform-origin: right center;
  background: #F6F0E4; border: 6px solid #8A5A2B; box-shadow: 0 8px 14px rgba(0,0,0,.22), inset 0 0 0 3px #F6F0E4;
  overflow: hidden;
}
.wall-art span { position: absolute; inset: 9px; background:
  radial-gradient(circle at 70% 30%, #E8B969 0 10px, transparent 11px),
  linear-gradient(160deg, transparent 55%, #8FA080 56%),
  linear-gradient(200deg, transparent 50%, #6E8460 51%),
  #E9E0CD; }
.window {
  position: absolute; top: 12%; left: 46px; width: 156px; height: 178px;
  transform: perspective(600px) rotateY(-24deg); transform-origin: left center;
  border: 8px solid var(--baseboard); border-radius: 3px;
  box-shadow: 0 10px 22px rgba(0,0,0,.2), inset 0 0 0 2px rgba(0,0,0,.08);
}
.window-sky { position: absolute; inset: 0; overflow: hidden; }
.window-cross-v { position: absolute; left: 50%; top: 0; bottom: 0; width: 6px; margin-left: -3px; background: var(--baseboard); }
.window-cross-h { position: absolute; top: 45%; left: 0; right: 0; height: 6px; background: var(--baseboard); }
.curtain { position: absolute; top: -14px; bottom: -16px; width: 34px; z-index: 2;
  background: repeating-linear-gradient(90deg, #E9DCC4 0 6px, #D9C8AA 6px 9px, #EFE4CF 9px 14px);
  box-shadow: 0 6px 10px rgba(0,0,0,.15); }
.curtain.left { left: -22px; border-radius: 0 0 18px 4px; }
.curtain.right { right: -22px; border-radius: 0 0 4px 18px; }
.sill { position: absolute; left: -14px; right: -14px; bottom: -14px; height: 9px; background: var(--baseboard); border-radius: 2px; box-shadow: 0 4px 6px rgba(0,0,0,.18); }

/* mobili appoggiati sul pavimento */
.corner-furniture { position: absolute; left: 8px; right: 6px; bottom: 18px; display: flex; align-items: flex-end; z-index: 3; }
.corner-furniture.right { left: 26px; right: 10px; gap: 10px; }
.corner-furniture .nightstand-scene { z-index: 3; }
.chair-scene { position: relative; width: 200px; margin-left: 2px; z-index: 2; cursor: pointer; }
.armchair { width: 200px; height: auto; display: block; overflow: visible; }
.rug-wrap { position: absolute; left: 110px; right: -20px; bottom: -14px; height: 44px; z-index: 0; opacity: .95; }
.rug { width: 100%; height: 100%; display: block; }
.plant-wrap { width: 78px; margin-bottom: 26px; }
.floor-plant { width: 100%; height: auto; display: block; }
.corner-furniture .scene-label { position: absolute; bottom: -16px; white-space: nowrap; }
.corner-furniture .scene { padding-bottom: 0; }
.corner-furniture .nightstand-scene .scene-label, .corner-furniture .basket-scene .scene-label {
  position: static; margin-top: 4px; height: auto; padding: 2px 9px; border-radius: 999px;
  background: var(--chrome); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

/* animali che dormono */
.pet-wrap { position: absolute; display: block; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.pet-wrap.cat { left: 50px; top: 46px; width: 112px; z-index: 3; }
.pet-wrap.dog { left: 210px; bottom: -8px; width: 132px; z-index: 4; }
.pet { width: 100%; height: auto; display: block; overflow: visible; animation: breathe 3.4s ease-in-out infinite; transform-origin: 50% 90%; }
@keyframes breathe { 50% { transform: scale(1.025, 1.06); } }
.zzz { position: absolute; left: 14px; top: -8px; font-family: var(--serif); font-style: italic; color: var(--muted); pointer-events: none; }
.zzz i { position: absolute; font-size: 12px; opacity: 0; animation: zzz 3.6s ease-in infinite; }
.zzz i:nth-child(2) { animation-delay: 1.2s; font-size: 14px; }
.zzz i:nth-child(3) { animation-delay: 2.4s; font-size: 16px; }
@keyframes zzz { 0% { transform: translate(0, 0); opacity: 0; } 20% { opacity: .9; } 100% { transform: translate(-16px, -34px); opacity: 0; } }
.pet-wrap.petted .pet-head { animation: nuzzle .7s ease; transform-origin: 30% 70%; transform-box: fill-box; }
.pet-wrap.petted .dog-tail { animation: wag .25s ease-in-out 4; transform-origin: 0% 100%; transform-box: fill-box; }
@keyframes nuzzle { 30% { transform: rotate(-8deg); } 60% { transform: rotate(5deg); } }
@keyframes wag { 50% { transform: rotate(-25deg); } }
.heart { position: absolute; left: 40%; top: -6px; color: #D9776F; font-size: 18px; animation: heart 1.3s ease-out forwards; pointer-events: none; }
@keyframes heart { from { transform: translateY(0) scale(.6); opacity: 0; } 20% { opacity: 1; } to { transform: translateY(-40px) scale(1.2); opacity: 0; } }

.swatch.big { width: 40px; height: 40px; }
@media (prefers-reduced-motion: reduce) { .pet, .zzz i { animation: none; } }

/* ============ Decorazioni realistiche ============ */
.deco-svg { display: block; overflow: visible; stroke: none; fill: currentColor; color: transparent; }
.deco { filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .35)); position: relative; z-index: 2; }
.deco-art { display: block; line-height: 0; }
/* spazio libero: vuoto sullo scaffale, visibile solo mentre sistemi */
.item.space { height: 60px; align-self: flex-end; }
.space-box { display: none; }
.arranging .item.space .space-box {
  display: grid; place-items: center; height: 60px; border: 1.5px dashed rgba(255, 225, 170, .55); border-radius: 6px;
  color: rgba(255, 225, 170, .8); font-size: 13px;
}
.item.space.sel .space-box { border-color: #ffd27a; background: rgba(255, 210, 122, .12); }
.pal-art { display: grid; place-items: center; width: 52px; height: 42px; }
.pal-art .deco-svg { max-width: 48px; max-height: 40px; width: auto !important; height: auto !important; }
.pal-space { display: grid; place-items: center; height: 26px; border: 1.5px dashed var(--hair); border-radius: 5px; font-size: 11px; color: var(--muted); }
.pal-item { width: 76px; height: 70px; padding: 4px 2px; }
.pal-name { max-width: 72px; font-size: 8.5px; white-space: normal; line-height: 1.1; height: 19px; overflow: hidden; display: block; text-align: center; }

/* ============ Stanza a tutto schermo + zoom sulla libreria ============ */
body.in-library { padding-top: 0; }
body.in-library .stage-wrap { margin-top: 0; }
.room3d { padding-top: var(--safe-t); }
.wall-center {
  overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: flex-end;
  height: calc(100% - var(--floor-line, 58px) + 10px); padding: 40px 0 0;
}
.wall-center #welcome { width: min(92%, 420px); }
/* la libreria nella stanza: la stessa, rimpicciolita, appoggiata al pavimento */
.bookcase-preview { position: relative; cursor: zoom-in; flex: 0 0 auto; -webkit-tap-highlight-color: transparent; }
.bookcase-scaler { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
.bookcase-scaler .bookcase-foot { width: 100%; }
.bookcase-preview .bookcase { box-shadow: inset 0 0 40px rgba(0,0,0,.65), inset 0 18px 18px -12px rgba(0,0,0,.7); }
.bookcase-preview::after { /* ombra a terra */
  content: ""; position: absolute; left: 4%; right: 4%; bottom: -6px; height: 12px; border-radius: 50%;
  background: rgba(0,0,0,.28); filter: blur(4px); z-index: -1;
}
.preview-hint {
  position: absolute; left: 50%; bottom: 30px; transform: translateX(-50%); white-space: nowrap;
  font-size: 11.5px; font-weight: 600; color: var(--text); padding: 6px 12px; border-radius: 999px;
  background: var(--chrome); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  box-shadow: var(--shadow); pointer-events: none; transition: opacity .3s;
}
.bookcase-preview:hover .bookcase-scaler { filter: brightness(1.05); }

/* la vista con tutti i libri */
.shelf-view {
  position: fixed; left: 0; right: 0; top: 0; bottom: calc(var(--tabbar-h) + var(--safe-b));
  z-index: 35; display: flex; flex-direction: column;
}
.sv-backdrop {
  position: absolute; inset: 0; opacity: 0; transition: opacity .45s ease;
  background: repeating-linear-gradient(90deg, var(--wall-stripe) 0 2px, transparent 2px 26px), var(--wall);
}
.shelf-view.open .sv-backdrop { opacity: 1; }
.sv-bar, .shelf-view .searchbar { position: relative; z-index: 2; opacity: 0; transform: translateY(-8px); transition: opacity .35s ease .15s, transform .35s ease .15s; }
.shelf-view.open .sv-bar, .shelf-view.open .searchbar { opacity: 1; transform: none; }
.sv-bar { display: flex; align-items: center; gap: 10px; padding: calc(var(--safe-t) + 10px) 12px 8px; }
.sv-back {
  border: 1px solid var(--line); background: var(--chrome); color: var(--text); border-radius: 999px;
  padding: 9px 14px 9px 10px; font-weight: 600; font-size: 15px; box-shadow: var(--shadow);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.sv-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.sv-title b { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 21px; }
.sv-title small { font-size: 11.5px; color: var(--muted); }
.shelf-view .searchbar { padding: 0 12px 8px; margin: 0; }
.sv-scroll {
  position: relative; z-index: 1; flex: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 30px 12px 40px; scrollbar-width: thin;
}
.sv-content { margin: 0 auto; will-change: transform; }
.sv-content .bookcase-foot { width: 100%; }
body.shelf-open .stage { filter: blur(3px) brightness(.92); transition: filter .45s ease; }
.stage { transition: filter .45s ease; }
.arrange-bar { z-index: 38; }

/* trascinamento */
#bookcase, #bookcase-preview { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.item.dragging { opacity: .25; }
.drag-ghost {
  position: fixed !important; z-index: 90; margin: 0 !important; pointer-events: none;
  transform: rotate(-3deg) scale(1.08); transform-origin: 50% 80%;
  filter: drop-shadow(0 14px 14px rgba(0,0,0,.45)) !important; opacity: .96;
}
.drop-indicator {
  position: fixed; z-index: 89; width: 4px; margin-left: -2px; border-radius: 2px; display: none; pointer-events: none;
  background: #FFD27A; box-shadow: 0 0 10px 2px rgba(255, 210, 122, .8);
}
body.is-dragging, body.is-dragging * { cursor: grabbing !important; }

/* finestra: tocca per cambiare la vista */
.window { cursor: pointer; }

/* ============ Finestra: cielo, pioggia e neve ============ */
.window-sky { background: #9CC8EA; }
.sky-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; stroke: none; fill: none; }
.sky-svg .drift { animation: cloud-drift 46s ease-in-out infinite alternate; transform-box: fill-box; }
.sky-svg .drift.slow { animation-duration: 70s; }
@keyframes cloud-drift { to { translate: 9px 0; } }
.sky-svg .tw { animation: twinkle-star 4s ease-in-out infinite; }
@keyframes twinkle-star { 50% { opacity: .15; } }
.precip { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
/* pioggia: la goccia è inclinata nella stessa direzione in cui cade */
.rd { position: absolute; top: -26px; display: block; border-radius: 1px; animation: rainfall linear infinite;
  background: linear-gradient(rgba(220, 230, 240, 0), rgba(220, 230, 240, .75)); }
.rd.far { width: 1px; height: 8px; opacity: .45; }
.rd.near { width: 1.4px; height: 16px; opacity: .8; }
@keyframes rainfall { from { transform: translate(0, 0) rotate(6deg); } to { transform: translate(-22px, 210px) rotate(6deg); } }
/* goccioline sul vetro */
.bead { position: absolute; display: block; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255,255,255,.85) 0 18%, rgba(255,255,255,.18) 40%, rgba(120,135,150,.25) 100%);
  box-shadow: 0 .5px 1px rgba(0,0,0,.25); }
.rivulet { position: absolute; display: block; width: 2.6px; height: 3.2px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff 0 20%, rgba(255,255,255,.35) 60%, rgba(120,135,150,.3));
  animation: rivulet ease-in infinite; }
.rivulet::before { content: ""; position: absolute; left: .7px; bottom: 2px; width: 1.2px; height: 0; border-radius: 1px;
  background: linear-gradient(rgba(255,255,255,0), rgba(255,255,255,.35)); animation: inherit; animation-name: rivulet-trail; }
@keyframes rivulet {
  0%, 30% { transform: translateY(0); opacity: 0; }
  34% { opacity: .95; } 48% { transform: translateY(10px); } 56% { transform: translateY(12px); }
  80% { transform: translateY(46px); opacity: .9; } 100% { transform: translateY(90px); opacity: 0; } }
@keyframes rivulet-trail { 0%, 34% { height: 0; } 80% { height: 30px; } 100% { height: 46px; } }
/* neve: i fiocchi ondeggiano mentre scendono */
.sf { position: absolute; top: -8px; display: block; border-radius: 50%; background: #fff; animation: snowfall linear infinite; }
.sf.far { opacity: .7; }
.sf.near { opacity: .95; filter: blur(.3px); box-shadow: 0 0 2px rgba(255,255,255,.8); }
.sf.alt { animation-name: snowfall-alt; }
@keyframes snowfall { 0% { transform: translate(0, 0); } 25% { transform: translate(5px, 55px); } 50% { transform: translate(-3px, 110px); } 75% { transform: translate(4px, 165px); } 100% { transform: translate(0, 220px); } }
@keyframes snowfall-alt { 0% { transform: translate(0, 0); } 25% { transform: translate(-4px, 55px); } 50% { transform: translate(4px, 110px); } 75% { transform: translate(-5px, 165px); } 100% { transform: translate(1px, 220px); } }
.snow-ledge { position: absolute; left: 0; right: 0; bottom: 0; height: 5px; display: block;
  background: linear-gradient(#FFFFFF, #E4EAF0); border-radius: 3px 3px 0 0; box-shadow: 0 -1px 2px rgba(150,165,180,.35); }
/* riflesso del vetro */
.glass-gloss { position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(125deg, rgba(255,255,255,.16) 0 18%, transparent 30% 62%, rgba(255,255,255,.08) 70%, transparent 80%); }
@media (prefers-reduced-motion: reduce) { .rd, .sf, .rivulet, .sky-svg .drift, .sky-svg .tw { animation: none; } .rd, .sf { display: none; } }

/* La stanza occupa tutta la larghezza dello schermo (le altre schermate restano centrate a 1180px) */
body.in-library #app { max-width: none; }
#view-library { padding: 0; }
#view-library .stage-wrap { margin: 0; }
@media (min-width: 1100px) {
  .wall-left { width: clamp(400px, 27vw, 560px); }
  .wall-right { width: clamp(320px, 23vw, 480px); }
  .corner-furniture { left: clamp(8px, 3vw, 60px); }
  .corner-furniture.right { left: clamp(26px, 3vw, 70px); }
}

/* ============ Proporzioni reali della stanza ============
   I mobili sono disegnati a 2,4 px/cm; --rs li adatta all'altezza dello schermo
   (la stanza è alta ~2,85 m). */
.wall-left { width: calc(390px * var(--rs, 1)); }
.wall-right { width: calc(300px * var(--rs, 1)); }
@media (min-width: 1100px) {
  .wall-left { width: max(calc(390px * var(--rs, 1)), clamp(400px, 27vw, 560px)); }
  .wall-right { width: max(calc(300px * var(--rs, 1)), clamp(320px, 23vw, 480px)); }
}
.corner-furniture { transform: scale(var(--rs, 1)); transform-origin: 0 100%; right: auto; }
.corner-furniture.right { right: auto; }

/* comodino 50 × 58 cm, lampada 40 cm */
.ns-top-area { max-width: 128px; padding: 0 3px; gap: 3px; min-height: 0; }
.ns-top { width: 124px; height: 9px; }
.ns-body { width: 110px; height: 104px; padding: 8px; gap: 6px; }
.ns-legs { width: 96px; }
.ns-legs i { width: 7px; height: 22px; }
.ns-drawer i { width: 16px; height: 4px; }
.lamp { transform: scale(.92); transform-origin: 50% 100%; }

/* libri sdraiati sul comodino (~22 × 3 cm) */
.hstack { cursor: pointer; }
.hbook { padding: 0 4px; gap: 3px; border-radius: 1.5px; justify-content: flex-start; }
.hbook::before { left: 3px; top: 2px; bottom: 2px; width: 1.5px; border-width: .5px; }
.hbook .h-title { padding-left: 4px; letter-spacing: 0; line-height: 1; }
.htab { width: 6px; height: 3px; }
.more-tag { top: -16px; right: -2px; font-size: 10px; }
.ns-empty { width: 96px; font-size: 10.5px; padding: 6px 8px; }

/* cesta ~40 cm */
.basket-scene { margin-right: 6px; }
.basket { transform: scale(.72); transform-origin: 0 100%; margin: -46px -39px 0 0; }

/* pianta da terra ~85 cm */
.plant-wrap { width: 112px; margin-bottom: 0; }

/* finestra 85 × 100 cm con davanzale a ~90 cm da terra; quadro 50 × 35 cm */
.window {
  top: auto; width: 196px; height: 232px; left: calc(44px * var(--rs, 1));
  bottom: calc(var(--floor-line, 58px) + 214px * var(--rs, 1));
  transform: perspective(600px) rotateY(-24deg) scale(var(--rs, 1)); transform-origin: 0 100%;
}
.wall-art {
  top: auto; left: calc(196px * var(--rs, 1));
  bottom: calc(var(--floor-line, 58px) + 300px * var(--rs, 1));
  transform: perspective(600px) rotateY(24deg) scale(var(--rs, 1)); transform-origin: 100% 100%;
}

/* libreria nella stanza: niente targhette, ripiani non pieni */
.bookcase-preview .row { padding-left: 14px; }
/* poltrona ~90 cm di larghezza, schienale ~80 cm */
.chair-scene, .armchair { width: 224px; }
.pet-wrap.cat { left: 58px; top: 50px; width: 108px; }
.pet-wrap.dog { left: 236px; }
.rug-wrap { left: 130px; right: -40px; }

/* ============ Libri in vista nella stanza ============ */
.pick-bar {
  position: relative; z-index: 2; margin: 0 12px 6px; padding: 8px 8px 8px 14px; border-radius: 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--chrome); border: 1px solid var(--line); box-shadow: var(--shadow); font-size: 13px;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
}
.pick-bar #pick-count { color: var(--muted); }
#bookcase.picking .item:not([data-type="b"]) { opacity: .35; }
#bookcase.picking .item[data-type="b"] { cursor: pointer; }
#bookcase.picking .item[data-type="b"]:not(.in-room) { filter: saturate(.55) brightness(.85); }
#bookcase.picking .item.in-room { transform: translateY(-6px); }
#bookcase.picking .item.in-room::after {
  content: "✓"; position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%); z-index: 3;
  width: 14px; height: 14px; border-radius: 50%; display: grid; place-items: center;
  background: var(--primary); color: #fff; font-size: 9px; font-weight: 700; box-shadow: 0 1px 3px rgba(0,0,0,.4);
}
#bookcase.picking .book.flat.in-room::after { bottom: auto; top: 50%; left: auto; right: 4px; transform: translateY(-50%); }
/* interruttore nella scheda del libro */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer;
  background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 12px 14px; margin: 0 0 14px;
}
.toggle-row small { display: block; color: var(--muted); font-size: 12px; }
.toggle-row input { position: absolute; opacity: 0; pointer-events: none; }
.toggle-row .switch { flex: 0 0 auto; width: 46px; height: 28px; border-radius: 14px; background: var(--hair); position: relative; transition: background .2s; }
.toggle-row .switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.toggle-row input:checked + .switch { background: var(--primary); }
.toggle-row input:checked + .switch::after { transform: translateX(18px); }
.bookcase-preview .row.empty { font-size: 0; }

/* foglie d'autunno che cadono ondeggiando */
.lf { position: absolute; top: -10px; display: block; border-radius: 0 70% 0 70%; opacity: .95;
  box-shadow: inset -1px -1px 0 rgba(0,0,0,.18); animation: leaffall linear infinite; }
.lf.alt { animation-name: leaffall-alt; }
@keyframes leaffall { 0% { transform: translate(0, 0) rotate(0); } 25% { transform: translate(12px, 55px) rotate(110deg); }
  50% { transform: translate(-6px, 110px) rotate(200deg); } 75% { transform: translate(10px, 165px) rotate(290deg); } 100% { transform: translate(2px, 225px) rotate(380deg); } }
@keyframes leaffall-alt { 0% { transform: translate(0, 0) rotate(40deg); } 30% { transform: translate(-12px, 65px) rotate(-60deg); }
  60% { transform: translate(8px, 130px) rotate(-160deg); } 100% { transform: translate(-4px, 225px) rotate(-300deg); } }
@media (prefers-reduced-motion: reduce) { .lf { animation: none; display: none; } }

/* ============ Angolo lettura raccolto ============
   La parete centrale è larga quanto la libreria (la imposta renderPreview):
   poltrona e comodino stanno nell'angolo a sinistra, cesta e finestra in quello a destra. */
.wall-center { flex: 0 0 auto; max-width: none; padding-left: 0; padding-right: 0; }
.wall-left .corner-furniture { left: auto; right: 4px; transform-origin: 100% 100%; }
.corner-furniture.right { left: 4px; }
.wall-art { left: auto; right: calc(70px * var(--rs, 1)); transform-origin: 100% 100%; }
.window { left: calc(16px * var(--rs, 1)); }
@media (min-width: 1100px) {
  .room3d { width: 100%; }
  .wall-left { flex: 1 1 0; width: auto; min-width: calc(390px * var(--rs, 1)); }
  .wall-right { flex: 1 1 0; width: auto; min-width: calc(300px * var(--rs, 1)); }
  .wall-center { flex: 0 0 auto; }
  .wall-left .corner-furniture { left: auto; right: 4px; }
  .corner-furniture.right { left: 4px; }
}
/* cesta un po' più grande (~48 cm) */
.basket { transform: scale(.86); margin: -23px -20px 0 0; }

/* ============ Disposizione A: parete unica frontale ============
   Una sola parete continua (le tre sezioni restano solo per lo scorrimento su telefono). */
.wall-left .wall-bg, .wall-right .wall-bg { background: none; }
/* pavimento: assi che convergono al punto di fuga all'altezza degli occhi (--vp, --vpy) */
.floor {
  background:
    linear-gradient(180deg, var(--floor-dark), transparent 75%),
    repeating-conic-gradient(from 180deg at var(--vp, 50%) var(--vpy, 0px),
      var(--floor1) 0deg 4.2deg, var(--floor2) 4.2deg 4.45deg);
}
.baseboards { filter: drop-shadow(0 -1px 0 var(--baseboard-sh)); }
.crown { background: linear-gradient(180deg, var(--baseboard), rgba(0,0,0,.05)); }
/* finestra e quadro frontali, come gli altri mobili */
.window { transform: scale(var(--rs, 1)); transform-origin: 0 100%; box-shadow: 0 8px 18px rgba(0,0,0,.16), inset 0 0 0 2px rgba(0,0,0,.06); }
.wall-art { transform: scale(var(--rs, 1)); transform-origin: 100% 100%; }
/* la libreria si stacca dalla parete con un'ombra morbida */
.bookcase-preview .bookcase-scaler { filter: drop-shadow(0 0 14px rgba(40, 25, 10, .22)); }

/* ============ Disposizione configurabile ============ */
/* le sezioni laterali sono larghe quanto serve (--sec-w calcolata in sizeSections) */
.wall-left, .wall-right { width: var(--sec-w, calc(300px * var(--rs, 1))); }
@media (min-width: 1100px) {
  .wall-left, .wall-right { width: auto; flex: 1 1 0; min-width: var(--sec-w, calc(300px * var(--rs, 1))); }
}
/* finestra e quadro: sempre vicino alla libreria, sul lato scelto */
.window.on-left { left: auto; right: calc(16px * var(--rs, 1)); transform-origin: 100% 100%; }
.window.on-right { left: calc(16px * var(--rs, 1)); right: auto; transform-origin: 0 100%; }
.wall-art.on-left { left: auto; right: calc(60px * var(--rs, 1)); transform-origin: 100% 100%; }
.wall-art.on-right { right: auto; left: calc(60px * var(--rs, 1)); transform-origin: 0 100%; }
.wall-art.on-left.second { right: calc(290px * var(--rs, 1)); }
.wall-art.on-right.second { left: calc(290px * var(--rs, 1)); }
/* tappeto e animale seguono la poltrona */
.chair-scene .rug-wrap { position: absolute; left: -24px; right: -34px; bottom: -16px; height: 44px; z-index: -1; }
.chair-scene .pet-wrap.dog { left: 112px; bottom: -22px; z-index: 4; }
.stray-pet { position: relative; width: 150px; height: 70px; flex: 0 0 auto; }
.stray-pet .pet-wrap { left: 6px; top: auto; bottom: -6px; }
.corner-furniture { gap: 6px; }

/* configuratore */
.schematic-box { border-radius: 14px; overflow: hidden; border: 1px solid var(--line); box-shadow: var(--shadow); }
.layout-schematic { width: 100% !important; height: auto !important; display: block; stroke: none; fill: none; }
.preset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.preset { padding: 0 0 8px; border-radius: 14px; border: 1px solid var(--hair); background: var(--card-solid); overflow: hidden; font-size: 13px; font-weight: 600; color: var(--text); text-align: center; }
.preset span { display: block; margin-top: 6px; }
.preset.on { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.order-list { border: 1px solid var(--line); border-radius: 14px; background: var(--card); }
.order-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--line); font-size: 14.5px; }
.order-row:last-child { border-bottom: 0; }
.order-row.off .order-name { color: var(--muted); text-decoration: line-through; }
.order-ctrl { display: flex; align-items: center; gap: 6px; }
.icon-btn.small { width: 32px; height: 32px; font-size: 20px; line-height: 1; padding-bottom: 3px; box-shadow: none; }
.icon-btn.small:disabled { opacity: .3; }
.order-fixed { font-size: 11px; color: var(--muted); width: 42px; text-align: center; }
.mini-switch { position: relative; width: 42px; height: 26px; flex: 0 0 auto; cursor: pointer; }
.mini-switch input { position: absolute; opacity: 0; }
.mini-switch i { position: absolute; inset: 0; border-radius: 13px; background: var(--hair); transition: background .2s; }
.mini-switch i::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.3); transition: transform .2s; }
.mini-switch input:checked + i { background: var(--primary); }
.mini-switch input:checked + i::after { transform: translateX(16px); }

/* ============ Oggetti posizionati in centimetri (piano della parete) ============
   --k = pixel per cm, --rs = scala dei disegni (k / 2,4), --is = grandezza scelta per l'oggetto */
.placed { position: absolute; z-index: 3; }
.placed.on-floor { bottom: 18px; }
.placed.on-wall { z-index: 1; }
.placed.side-left { transform-origin: 100% 100%; }
.placed.side-right { transform-origin: 0 100%; }
.placed:not(.rug-placed) { transform: scale(calc(var(--rs, 1) * var(--is, 1))); }
.placed .window, .placed .wall-art { position: relative; left: auto; right: auto; top: auto; bottom: auto; transform: none; }
.rug-placed { bottom: 6px; height: calc(16 * var(--k, 2.4) * 1px); z-index: 2; }
.rug-placed .rug { width: 100%; height: 100%; display: block; }
.placed .chair-scene { margin: 0; }
.placed.stray-pet { width: 150px; height: 70px; }
/* il cagnolino dorme davanti alla poltrona, senza coprire l'etichetta del comodino */
.chair-scene .pet-wrap.dog { left: 18px; bottom: -24px; }

/* ============ Mobili appoggiati al muro ============
   Poltrona, comodino, cesta e pianta poggiano sulla stessa linea della libreria (la base della parete);
   davanti resta solo un piccolo strato di pavimento con il tappeto. */
.placed.on-floor { bottom: calc(var(--floor-line, 58px) - 10px); filter: drop-shadow(0 0 9px rgba(40, 25, 10, .2)); }
.rug-placed { bottom: 2px; height: calc(var(--floor-line, 58px) - 2px); z-index: 4; }
.chair-scene .pet-wrap.dog { bottom: -6px; }
.placed .scene-label { position: absolute; left: 50%; transform: translateX(-50%); bottom: -24px; margin: 0; z-index: 5; }
.rug-placed { z-index: 2; }

/* ============ Oggetti interattivi: più chiari ============ */
/* 1. reazione al passaggio del mouse e alla pressione */
.hot { cursor: pointer; transition: transform .25s ease, filter .25s ease; -webkit-tap-highlight-color: transparent; }
.hot:active { transform: scale(.97); }
@media (hover: hover) {
  .hot:hover { transform: translateY(-2px); filter: drop-shadow(0 0 3px rgba(255, 214, 140, .85)) drop-shadow(0 0 14px rgba(255, 200, 120, .45)); }
  .bookcase-preview.hot:hover { transform: none; }
  .bookcase-preview.hot:hover .bookcase-scaler { filter: drop-shadow(0 0 4px rgba(255, 214, 140, .8)) drop-shadow(0 0 18px rgba(255, 200, 120, .4)); }
}
.pet-wrap.hot, .pet-wrap { cursor: pointer; }

/* 2. cartellini di carta uguali per tutti (dimensione costante anche se l'oggetto è scalato) */
.tag, .preview-hint {
  position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; pointer-events: none; z-index: 6;
  font-family: var(--serif); font-style: italic; font-weight: 400; color: #3D3733; background: #F3EEE2;
  border-radius: .4em; padding: .2em .75em .25em; line-height: 1.25;
  box-shadow: inset 0 0 0 1px rgba(61, 55, 51, .18), 0 2px 6px rgba(0, 0, 0, .28);
  backdrop-filter: none; -webkit-backdrop-filter: none;
}
.tag i, .preview-hint i { font-style: normal; margin-right: .35em; }
.placed .tag { font-size: calc(13px / (var(--rs, 1) * var(--is, 1))); bottom: calc(-30px / (var(--rs, 1) * var(--is, 1))); }
.placed .tag-window { bottom: calc(-34px / (var(--rs, 1) * var(--is, 1))); }
.preview-hint { font-size: 13px; bottom: 18px; }
.ns-empty { border: 0; background: none; font-size: 9px; color: var(--muted); width: auto; padding: 0 0 4px; font-style: italic; }
body.no-tags .tag, body.no-tags .preview-hint { display: none; }
@keyframes tag-pop { from { opacity: 0; transform: translate(-50%, 4px); } }

@media (prefers-reduced-motion: reduce) { .hot, .hot:hover { transition: none; } }

/* ============ Interattività sobria ============ */
/* niente movimenti: solo un alone caldo e fermo al passaggio del mouse */
.hot, .hot:active { transform: none !important; }
@media (hover: hover) {
  .hot:hover { transform: none; filter: drop-shadow(0 0 10px rgba(255, 210, 140, .38)); }
  .bookcase-preview.hot:hover .bookcase-scaler { filter: drop-shadow(0 0 14px rgba(255, 210, 140, .35)) drop-shadow(0 0 14px rgba(40, 25, 10, .22)); }
}
/* etichette minimal: maiuscoletto spaziato, senza sfondo, numero più chiaro */
.tag, .preview-hint {
  background: none; box-shadow: none; padding: 0; border-radius: 0;
  font-family: var(--sans); font-style: normal; font-weight: 500;
  letter-spacing: .16em; text-transform: uppercase; line-height: 1;
  color: rgba(61, 55, 51, .78);
  text-shadow: 0 0 6px rgba(245, 240, 232, .9), 0 0 2px rgba(245, 240, 232, .9);
}
.tag b, .preview-hint b { font-weight: 400; opacity: .55; margin-left: .7em; letter-spacing: .08em; }
.placed .tag { font-size: calc(9.5px / (var(--rs, 1) * var(--is, 1))); bottom: calc(-22px / (var(--rs, 1) * var(--is, 1))); }
.placed .tag-window { bottom: calc(-26px / (var(--rs, 1) * var(--is, 1))); }
.preview-hint { font-size: 9.5px; bottom: 14px; color: rgba(243, 234, 216, .82); text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }
@media (prefers-color-scheme: dark) {
  .tag { color: rgba(242, 236, 228, .78); text-shadow: 0 0 6px rgba(20, 16, 12, .9), 0 0 2px rgba(20, 16, 12, .9); }
}

/* ============ Oggetti personalizzabili ============ */
/* niente etichette */
.tag, .preview-hint { display: none !important; }
/* quadro: il quadretto scelto in SVG */
.wall-art { background: none; border: 0; box-shadow: 0 8px 14px rgba(0,0,0,.22); overflow: visible; }
.wall-art span { display: none; }
.art-svg { width: 100% !important; height: 100% !important; display: block; stroke: none; fill: none; }
/* tende, paralume e vimini prendono i colori scelti */
.window .curtain { background: repeating-linear-gradient(90deg, var(--cu1, #E9DCC4) 0 6px, var(--cu2, #D9C8AA) 6px 9px, var(--cu3, #EFE4CF) 9px 14px); }
.window.no-curtains .curtain { display: none; }
.lamp-shade { background: var(--shade, linear-gradient(90deg, #E9DEC9, #F8F2E6 45%, #DCCFB6)); }
.basket-front {
  background:
    repeating-linear-gradient(90deg, rgba(90, 60, 30, .22) 0 2px, transparent 2px 13px),
    repeating-linear-gradient(0deg, var(--bk-a, #CDAA74) 0 7px, var(--bk-b, #B98F57) 7px 9px, var(--bk-c, #D6B680) 9px 16px, var(--bk-b, #B98F57) 16px 18px);
}
.basket-rim { background: repeating-linear-gradient(115deg, var(--bk-r1, #C9A46C) 0 6px, var(--bk-r2, #A9804A) 6px 8px); }
.basket-handle { border-color: var(--bk-b, #B98F57); }
/* tappeto e pianta toccabili */
.rug-hot { width: 100%; height: 100%; position: relative; }
.rug-hot .rug { width: 100%; height: 100%; display: block; }
.plant-wrap { position: relative; }
.chair-scene { display: block; }

/* schede di personalizzazione */
.cfg-preview {
  height: 170px; border-radius: 16px; margin-bottom: 6px; position: relative; overflow: hidden;
  background: linear-gradient(180deg, var(--wall, #EDE3D1) 0 78%, var(--floor2, #A97E54) 78%);
  display: grid; place-items: end center; padding-bottom: 14%;
}
.cfg-preview .cfg-stage { transform: scale(.62); transform-origin: 50% 100%; pointer-events: none; --rs: 1; --is: 1; }
.cfg-preview.cfg-window, .cfg-preview.cfg-frame { place-items: center; padding: 0; background: var(--wall, #EDE3D1); }
.cfg-preview.cfg-window .cfg-stage { transform: scale(.55); transform-origin: 50% 50%; }
.cfg-preview.cfg-window .window { position: relative; left: auto; right: auto; bottom: auto; transform: none; }
.cfg-preview.cfg-frame .cfg-stage { transform: scale(1.2); transform-origin: 50% 50%; }
.cfg-preview.cfg-frame .wall-art { position: relative; left: auto; right: auto; bottom: auto; top: auto; transform: none; }
.cfg-preview.cfg-rug { place-items: end center; padding-bottom: 6%; }
.cfg-preview.cfg-rug .cfg-stage { width: 300px; height: 60px; transform: none; }
.cfg-pet { width: 150px; height: 90px; position: relative; }
.cfg-pet .pet-wrap { position: relative; left: auto; top: auto; bottom: auto; width: 140px; }
.cfg-label { margin: 16px 0 8px; }
.thumb-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.thumb-grid.wide { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.obj-thumb { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px 6px; border-radius: 14px;
  border: 1px solid var(--hair); background: var(--card-solid); color: var(--text); font-size: 12px; }
.obj-thumb.on { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.obj-thumb small { font-size: 11.5px; }
.thumb-art { height: 62px; width: 100%; display: grid; place-items: center; }
.thumb-art svg { max-width: 100%; max-height: 62px; width: auto !important; height: auto !important; }
.thumb-grid.wide .thumb-art { height: 40px; }
.thumb-grid.wide .thumb-art svg { width: 100% !important; height: 40px !important; max-height: 40px; }
.chips.wrap { flex-wrap: wrap; }
.obj-row { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--text); text-align: left; cursor: pointer; }
.small-link { font-size: 13.5px; padding: 0 2px 10px; display: block; }
/* anteprima nelle schede: l'oggetto appoggiato sul pavimento del riquadro, senza tagli */
.cfg-preview { display: block; padding: 0; }
.cfg-preview .cfg-stage { position: absolute; left: 50%; bottom: 10%; transform: translateX(-50%) scale(.62); transform-origin: 50% 100%; }
.cfg-preview.cfg-window .cfg-stage, .cfg-preview.cfg-frame .cfg-stage { bottom: auto; top: 50%; transform-origin: 50% 50%; }
.cfg-preview.cfg-window .cfg-stage { transform: translate(-50%, -50%) scale(.55); }
.cfg-preview.cfg-frame .cfg-stage { transform: translate(-50%, -50%) scale(1.2); }
.cfg-preview.cfg-rug .cfg-stage { bottom: 6%; transform: translateX(-50%); }
.cfg-preview.cfg-pet .cfg-stage { transform: translateX(-50%) scale(1); }

/* ============ Evidenziazione lungo tutto il bordo ============
   un filo luminoso che segue la sagoma dell'oggetto + un alone leggero; niente movimenti */
@media (hover: hover) {
  .hot:hover { filter: drop-shadow(0 0 1.5px rgba(255, 222, 160, 1)) drop-shadow(0 0 1.5px rgba(255, 214, 140, .9)) drop-shadow(0 0 12px rgba(255, 200, 120, .45)); }
  .bookcase-preview.hot:hover { filter: none; }
  .bookcase-preview.hot:hover .bookcase-scaler { filter: drop-shadow(0 0 2px rgba(255, 222, 160, 1)) drop-shadow(0 0 2px rgba(255, 214, 140, .9)) drop-shadow(0 0 16px rgba(255, 200, 120, .45)); }
  /* passando sull'animale si illumina solo lui, non la poltrona su cui dorme */
  .chair-scene.hot:has(.pet-wrap:hover) { filter: none; }
}
/* l'animale è accanto alla poltrona (non dentro): stesse posizioni di prima */
.chair-group { position: relative; width: 224px; }
.chair-group .pet-wrap.dog { left: 18px; bottom: -6px; top: auto; }

/* ============ Comodino: la luce della lampada non va evidenziata ============
   L'alone della lampada è un riquadro trasparente: se il filtro (ombra o evidenziazione) si applica a tutto
   il comodino, anche il riquadro prende un bordo dritto. Il filtro va solo sulle parti solide. */
.placed.p-nightstand { filter: none; }
.p-nightstand .ns-table, .p-nightstand .lamp-shade, .p-nightstand .lamp-stem, .p-nightstand .lamp-base, .p-nightstand .hstack {
  filter: drop-shadow(0 0 9px rgba(40, 25, 10, .2));
}
@media (hover: hover) {
  .nightstand-scene.hot:hover { filter: none; }
  .nightstand-scene.hot:hover :is(.ns-table, .lamp-shade, .lamp-stem, .lamp-base, .hstack) {
    filter: drop-shadow(0 0 1.5px rgba(255, 222, 160, 1)) drop-shadow(0 0 1.5px rgba(255, 214, 140, .9)) drop-shadow(0 0 12px rgba(255, 200, 120, .45));
  }
}
.cfg-preview .nightstand-scene :is(.ns-table, .lamp-shade, .lamp-stem, .lamp-base, .hstack) { filter: none; }

/* Libreria nella stanza: bordo luminoso tutto intorno (la parete centrale non lo taglia più) */
.wall-center { overflow: visible; }
@media (hover: hover) {
  .bookcase-preview.hot:hover .bookcase-scaler {
    filter: drop-shadow(0 0 calc(1.5px / var(--ps, 1)) rgba(255, 222, 160, 1))
            drop-shadow(0 0 calc(1.5px / var(--ps, 1)) rgba(255, 214, 140, .9))
            drop-shadow(0 0 calc(12px / var(--ps, 1)) rgba(255, 200, 120, .45));
  }
}

/* ============ Animale e quadro: il bordo va sul disegno, non sul contenitore ============
   Quadro: l'ombra rettangolare sul muro prenderebbe anche lei l'alone (luce "tranciata").
   Animale: il disegno respira (animazione) e il filtro sul contenitore non sempre viene ridisegnato. */
@media (hover: hover) {
  .pet-wrap.hot:hover { filter: none; }
  /* l'animale (color miele) dorme sul tappeto crema: il filo crema non si vedrebbe, serve un filo più ambrato */
  .pet-wrap.hot:hover .pet {
    filter: drop-shadow(0 0 .8px rgba(140, 80, 20, .95)) drop-shadow(0 0 1.5px rgba(255, 200, 110, 1)) drop-shadow(0 0 1.5px rgba(255, 185, 90, .9)) drop-shadow(0 0 10px rgba(255, 185, 90, .6));
  }
}

/* Il respiro anima un gruppo dentro il disegno, non il disegno intero: in Safari un elemento con
   un'animazione di movimento perde il filtro, e il bordo luminoso dell'animale non si vedeva. */
.pet { animation: none; }
.pet .breath { animation: breathe 3.4s ease-in-out infinite; transform-origin: 50% 90%; transform-box: fill-box; }
@media (prefers-reduced-motion: reduce) { .pet .breath { animation: none; } }

/* il cane dorme SUL tappeto, davanti alla poltrona (non sospeso all'altezza dei piedini) */
.chair-group .pet-wrap.dog { bottom: -20px; }
/* respira gonfiandosi verso l'alto: la pancia resta appoggiata a terra */
.pet .breath { transform-origin: 50% 100%; }

/* Quadro: la luce va sul contenitore (come per gli altri oggetti: sull'SVG Safari la rimpicciolisce);
   l'ombra sul muro sta sul livello sopra, così non prende la luce e non si vede un riquadro tagliato */
.wall-art { box-shadow: none; }
.placed.p-frame { filter: none; }
/* niente filtro dentro un filtro (in Safari la luce sfarfalla): l'ombra è un livello a parte, dietro il quadro */
.placed.p-frame::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; box-shadow: 0 8px 14px rgba(0, 0, 0, .22); }
/* Safari taglia l'alone poco oltre il riquadro dell'elemento: 24px di margine trasparente tutto intorno
   (stessa misura e posizione del quadro); il margine non risponde al mouse, solo il quadro sì */
.placed .wall-art { box-sizing: content-box; padding: 24px; margin: -24px; pointer-events: none; }
.placed .wall-art .art-svg { pointer-events: auto; }

/* Segnalibri: pulsante per caricare le foto direttamente da qui */
.bm-add { cursor: pointer; white-space: nowrap; }
.pick-list .wish-row { cursor: pointer; }

/* Segnalibri scritti: la frase su un foglietto di carta, al posto della foto */
.viewer-text { padding: 14px 16px 0; }
.viewer-text textarea { width: 100%; min-height: 34vh; resize: vertical; font: italic 19px/1.45 var(--serif); padding: 16px 18px;
  background: #FBF7EF; color: #3D3733; border: 1px solid rgba(139, 115, 85, .25); border-radius: 14px; box-shadow: inset 0 1px 3px rgba(0,0,0,.06); }
.bm-card.is-text .bm-quote { margin: 0; aspect-ratio: 4 / 3; padding: 16px 16px 0; background: #FBF7EF; color: #3D3733;
  font: italic 15px/1.4 var(--serif); overflow: hidden; }
/* la frase si interrompe con i puntini su una riga intera (niente righe tagliate a metà) */
.bm-card.is-text .bm-quote span { display: -webkit-box; -webkit-line-clamp: 5; -webkit-box-orient: vertical; overflow: hidden; }
.bm-card.is-text .bm-quote span::before { content: "“"; font-size: 30px; line-height: 0; vertical-align: -.35em; margin-right: 2px; color: #8B7355; }
.quote-thumb.is-text { background: #FBF7EF; }
.quote-thumb .qt-text { position: absolute; inset: 8px 8px 22px; color: #3D3733; font: italic 11.5px/1.3 var(--serif); text-align: left;
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 6; -webkit-box-orient: vertical; }
button.quote-add { font: inherit; font-size: 12.5px; font-weight: 600; }

/* colore del segnalibro a scelta libera: il pallino arcobaleno apre il selettore di sistema */
.swatch.rc-custom { position: relative; display: inline-block; cursor: pointer; overflow: hidden;
  background: conic-gradient(#e0574f, #e8b04a, #8fa080, #4f86c6, #9a6cc4, #e0574f); }
.swatch.rc-custom input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }

/* Palette dei dorsi in "La tua libreria": ogni opzione è una filetta di dorsi */
.palette-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.palette-opt { display: flex; flex-direction: column; gap: 6px; padding: 8px 8px 7px; border-radius: 12px; border: 2px solid var(--line);
  background: var(--card-solid); color: var(--text); text-align: left; cursor: pointer; }
.palette-opt.on { border-color: var(--accent); }
.pal-spines { display: flex; align-items: flex-end; gap: 2px; height: 38px; padding: 0 2px 2px; border-bottom: 3px solid #8A5A2B; }
.pal-spines i { flex: 1; border-radius: 1.5px 1.5px 0 0; box-shadow: inset 0 0 0 .5px rgba(0,0,0,.18); }
.pal-title { font-size: 12.5px; font-weight: 600; }

/* ============ Stagioni ============ */
.season-chips { margin-top: -2px; }
.chip.small { padding: 5px 10px; font-size: 12.5px; }
/* nella stanza: festone appeso sopra la libreria e un oggetto sul pavimento accanto */
.season-room { position: absolute; pointer-events: none; z-index: 2; }
.season-garland { left: 0; top: calc(-1.6 * var(--k, 2) * 1px); line-height: 0; }
.season-floor { bottom: 0; right: calc(100% + 3 * var(--k, 2) * 1px); line-height: 0; filter: drop-shadow(0 0 6px rgba(40, 25, 10, .2)); }
.season-floor .deco-svg { width: 100% !important; height: auto !important; }
.season-wreath { position: absolute; left: 50%; top: -6px; transform: translateX(-50%); pointer-events: none; z-index: 4; line-height: 0; }
.cfg-preview .season-wreath { display: none; }

/* ============ Meteo alla finestra ============ */
/* vento: gli alberi si piegano e tornano, foglie/petali attraversano di traverso */
.sky-svg .sway { animation: tree-sway 2.8s ease-in-out infinite alternate; transform-box: fill-box; transform-origin: 50% 100%; }
.sky-svg .sway.far { animation-duration: 3.4s; }
.wx-storm .sky-svg .sway { animation-duration: 1.6s; }
@keyframes tree-sway { from { transform: skewX(2deg); } to { transform: skewX(-6deg); } }
.wx-wind .sky-svg .drift, .wx-storm .sky-svg .drift { animation-duration: 9s; }
.lf.wind { position: absolute; left: -10px; display: block; border-radius: 60% 0; animation: leaf-gust linear infinite; }
.lf.wind.alt { animation-name: leaf-gust-alt; }
@keyframes leaf-gust { 0% { transform: translate(0, 0) rotate(0); } 50% { transform: translate(110px, 18px) rotate(220deg); } 100% { transform: translate(240px, 6px) rotate(460deg); } }
@keyframes leaf-gust-alt { 0% { transform: translate(0, 0) rotate(40deg); } 50% { transform: translate(120px, -10px) rotate(-180deg); } 100% { transform: translate(240px, 14px) rotate(-420deg); } }
/* temporale: ogni tanto un lampo */
.flash { position: absolute; inset: 0; display: block; background: #F4F7FF; opacity: 0; animation: lightning 7s linear infinite; }
@keyframes lightning { 0%, 88%, 92%, 100% { opacity: 0; } 89% { opacity: .55; } 90% { opacity: .1; } 91% { opacity: .4; } }
@media (prefers-reduced-motion: reduce) { .sky-svg .sway, .lf.wind, .flash { animation: none; } .lf.wind, .flash { display: none; } }

.wx-real input[type=search] { width: 100%; }
.wx-results .wx-city { width: 100%; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left; color: var(--text); font-size: 14px; padding: 10px 2px; cursor: pointer; }

/* ============ Zoom dentro la libreria ============ */
.sv-scroll { overflow: auto; touch-action: pan-x pan-y; }
.sv-zoom { position: absolute; right: 14px; bottom: 14px; z-index: 3; display: flex; align-items: center;
  border: 1px solid var(--line); background: var(--chrome); border-radius: 999px; box-shadow: var(--shadow);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); opacity: 0; transition: opacity .3s ease .2s; }
.shelf-view.open .sv-zoom { opacity: 1; }
.sv-zoom button { border: 0; background: none; color: var(--text); font-size: 19px; line-height: 1; padding: 8px 13px; cursor: pointer; }
.sv-zoom .sv-zoom-val { font-size: 12.5px; font-weight: 600; min-width: 48px; padding: 8px 2px; color: var(--muted); }
.sv-zoom.zoomed .sv-zoom-val { color: var(--accent); }
body.arranging .sv-zoom { bottom: calc(var(--arrange-h, 230px) + 10px); }

/* ============ Vista a lista della libreria ============ */
.book-list { max-width: 820px; margin: 0 auto; background: var(--card-solid); border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow); padding: 14px 14px 6px; }
.bl-tools { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.bl-field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 180px; }
.bl-field span { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.bl-tags { margin-top: 12px; }
.bl-count { margin: 10px 2px 4px; font-size: 12.5px; }
.bl-row { display: flex; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); align-items: flex-start; }
.bl-cover { border: 0; background: none; padding: 0; flex: 0 0 auto; cursor: pointer; }
.bl-cover .cover { width: 44px; height: 66px; border-radius: 2px 4px 4px 2px; box-shadow: 0 3px 8px rgba(0,0,0,.2); }
.bl-cover .cover-fallback { margin: 2px; padding: 2px; } .bl-cover .cover-fallback b { font-size: 7px; } .bl-cover .cover-fallback small { display: none; }
.bl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.bl-title { border: 0; background: none; padding: 0; text-align: left; color: var(--text); cursor: pointer; }
.bl-title b { display: block; font-family: var(--serif); font-size: 16px; line-height: 1.2; }
.bl-title small { color: var(--muted); font-size: 12.5px; }
.bl-meta { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.bl-stars { color: var(--gold); letter-spacing: 1px; font-size: 13px; } .bl-stars .off { color: var(--hair); }
.bl-move { width: auto; max-width: 220px; padding: 5px 28px 5px 10px; font-size: 13px; }
.bl-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-chip { display: inline-flex; align-items: center; gap: 4px; }
.tag-chip button { border: 0; background: none; color: var(--muted); font-size: 14px; line-height: 1; padding: 0 0 0 2px; cursor: pointer; }
.add-tag { border-style: dashed; color: var(--accent); }
.tag-new { display: flex; gap: 8px; } .tag-new input { flex: 1; }

/* la lista sta sopra la libreria, che resta visibile (un po' sfocata) sullo sfondo */
.bl-layer { position: absolute; inset: 0; z-index: 1; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  padding: 70px 12px 24px; }
.shelf-view.listing .sv-scroll { filter: blur(2px) brightness(.85); transition: filter .3s ease; pointer-events: none; }
.bl-layer .book-list { background: color-mix(in srgb, var(--card-solid) 84%, transparent);
  backdrop-filter: blur(16px) saturate(1.1); -webkit-backdrop-filter: blur(16px) saturate(1.1); }
/* selezione multipla */
.book-list.selecting .bl-row { cursor: pointer; }
.bl-check { flex: 0 0 auto; width: 22px; height: 22px; margin-top: 22px; border-radius: 50%; border: 2px solid var(--hair);
  display: grid; place-items: center; font-size: 13px; font-weight: 700; color: #fff; }
.bl-row.picked .bl-check { background: var(--sage, #8FA080); border-color: var(--sage, #8FA080); }
.bl-row.picked { background: color-mix(in srgb, var(--accent) 8%, transparent); border-radius: 12px; }
.bl-bulk { position: sticky; bottom: 8px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px -6px 6px;
  padding: 10px 12px; border-radius: 16px; background: var(--chrome); border: 1px solid var(--line); box-shadow: var(--shadow);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.bl-bulk b { font-size: 13.5px; margin-right: auto; }
.bl-bulk select { width: auto; padding: 6px 28px 6px 10px; font-size: 13px; }
.chip.partial { border-style: dashed; }
.chip small { opacity: .6; font-size: 10.5px; }
