/* Savor · Atelier, aligned with the client's Figma prototype.
   Blush paper, clothbound spines lying flat on a shelf, an open Book beneath,
   Cormorant Garamond for everything editorial, Inter for small labels. */
.app {
  --bg: #FBF0E8; --paper: #FFFDF8; --ink: #292722; --muted: #6E685E; --line: #E7D9CC;
  --accent: #A85F48; --olive: #59634B; --gilt: #B08D57; --danger: #B3261E;
  --f-display: 'Cormorant Garamond', Georgia, serif; --f-body: 'Inter', system-ui, sans-serif; --f-label: 'Inter', system-ui, sans-serif;
  --ease: cubic-bezier(.2, .7, .2, 1);
}

/* ================= Screen frame ================= */
.lib { position: absolute; inset: 0; display: flex; flex-direction: column; }
.top { flex: none; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: calc(var(--safe-top) + 6px) 14px 4px; }
.mark { margin: 0; font: 500 21px/1 var(--f-display); letter-spacing: .24em; text-transform: uppercase; padding-left: .24em; }
.top-search, .top-btn { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--ink); }
.top-search { box-shadow: inset 0 0 0 1px var(--line); background: rgba(255, 253, 248, .6); }
.top-r { display: flex; align-items: center; justify-content: flex-end; gap: 4px; }
.sync { display: flex; align-items: center; gap: 2px; padding: 0 6px; color: var(--muted); font: 600 10px var(--f-label); }
.sync .ico { width: 18px; height: 18px; }
.sync.is-off { color: var(--danger); }
.lib-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.lib.is-archive .lib-body { overflow-y: auto; }

/* ================= Shelf: Books lying flat ================= */
.shelf { flex: none; padding: 2px 16px 0; }
.shelf-scroll { display: flex; flex-direction: column; align-items: center; gap: 2px; max-height: 148px; overflow-y: auto; padding: 8px 0 1px; scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 12px); mask-image: linear-gradient(to bottom, transparent 0, #000 12px); }
.shelf-scroll::-webkit-scrollbar { display: none; }
.lib.is-archive .shelf-scroll { max-height: none; -webkit-mask-image: none; mask-image: none; }
.spine-row { width: 100%; display: flex; justify-content: center; align-items: center; gap: 10px; }
.spine {
  position: relative; width: var(--w); height: var(--h); max-width: 420px; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 0 14px 0 16px; border-radius: 2px 3px 3px 2px; color: #F8EFE2; text-align: left;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, .16), rgba(255, 255, 255, 0) 30%, rgba(0, 0, 0, 0) 70%, rgba(0, 0, 0, .22)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .025) 0 1px, transparent 1px 3px),
    var(--tone);
  box-shadow: 0 1px 0 rgba(0, 0, 0, .18), 0 2px 4px -1px rgba(41, 39, 34, .35), inset 0 0 0 1px rgba(0, 0, 0, .08);
  transition: transform .45s var(--ease), box-shadow .3s;
}
.spine::before { content: ''; position: absolute; left: 0; top: 2px; bottom: 2px; width: 4px; background: linear-gradient(90deg, rgba(0, 0, 0, .25), transparent); border-radius: 2px 0 0 2px; }
.spine-t { min-width: 0; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: var(--f-display); font-size: 19px; line-height: 1; }
.spine--caps .spine-t { font-size: 14px; font-weight: 500; letter-spacing: .2em; text-transform: uppercase; }
.spine--italic .spine-t { font-style: italic; font-size: 20px; }
.spine-imprint { flex: none; font: 600 7px/1 var(--f-label); letter-spacing: .22em; opacity: .7; }
.spine-check { position: absolute; right: -30px; top: 50%; width: 22px; height: 22px; margin-top: -11px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; opacity: 0; transform: scale(.5); transition: opacity .25s, transform .3s var(--ease); }
.spine-check .ico { width: 14px; height: 14px; stroke-width: 2.4; }
.spine:hover { transform: translateX(-6px); }
.spine.is-open { transform: translateX(-16px); box-shadow: 0 1px 0 rgba(0, 0, 0, .18), 6px 4px 10px -4px rgba(41, 39, 34, .45); }
.spine.is-open::after { content: ''; position: absolute; right: 22%; top: 100%; width: 6px; height: 12px; background: var(--accent); clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 72%, 0 100%); }
.spine.is-empty { transform: translateX(-10px); animation: nudge 2.6s var(--ease) infinite; }
@keyframes nudge { 0%, 100% { transform: translateX(-6px); } 50% { transform: translateX(-14px); } }
.spine.is-suggested .spine-t { font-style: italic; opacity: .72; letter-spacing: .02em; text-transform: none; font-size: 18px; }
.spine.is-fresh { animation: drop .8s var(--ease) both; }
@keyframes drop { from { transform: translateY(-30px); opacity: 0; } }
.spine-row.is-dragging { position: relative; z-index: 5; filter: drop-shadow(0 12px 12px rgba(41, 39, 34, .3)); }
.shelf-scroll.is-sorting { cursor: grabbing; }
.shelf-empty { margin: 18px 0 8px; font: italic 17px/1.4 var(--f-display); color: var(--muted); text-align: center; }
/* placing a new Folio: Books move forward to receive it */
.lib.is-placing .spine { transform: translateX(-12px); box-shadow: 0 0 0 2px rgba(176, 141, 87, .55), 0 2px 6px rgba(41, 39, 34, .3); animation: none; }
.lib.is-placing .spine-row { padding-right: 30px; }
.spine-row.is-over .spine { transform: translateX(-20px) scale(1.03); box-shadow: 0 0 0 3px var(--gilt), 0 6px 12px rgba(41, 39, 34, .35); }
.spine.is-dropped .spine-check { opacity: 1; transform: none; }

.ledge { position: relative; display: flex; justify-content: space-between; align-items: center; height: 40px; padding-top: 12px; }
.ledge::before { content: ''; position: absolute; left: -6px; right: -6px; top: 0; height: 10px; border-radius: 2px;
  background: linear-gradient(180deg, #C9A27A 0, #B08A63 40%, #8E6A47 100%); box-shadow: 0 6px 10px -4px rgba(70, 45, 20, .45); }
.ledge-btn { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 4px; font: 500 10.5px var(--f-label); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.ledge-btn .ico { width: 15px; height: 15px; }
.ledge-btn:hover { color: var(--ink); }

/* ================= Open Book ================= */
.ob { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ob-head { flex: none; display: flex; align-items: center; gap: 6px; height: 44px; padding: 0 12px; }
.ob-title { flex: 1 1 auto; min-width: 0; display: inline-flex; align-items: center; gap: 4px; font: italic 400 19px/1.1 var(--f-display); white-space: nowrap; overflow: hidden; }
.ob-title > :not(.ico) { overflow: hidden; text-overflow: ellipsis; }
.ob-title .ico { width: 18px; height: 18px; color: var(--muted); }
.ob-title.is-suggested { color: var(--muted); }
.ob-count { flex: none; display: flex; align-items: center; font: 500 11px var(--f-label); color: var(--muted); letter-spacing: .04em; white-space: nowrap; }
.ob-count button { width: 24px; height: 32px; display: grid; place-items: center; color: var(--ink); }
.ob-count button .ico { width: 16px; height: 16px; }
.ob-acts { flex: none; display: flex; gap: 8px; margin-left: auto; }
.ob-acts button { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); background: rgba(255, 253, 248, .5); }
.ob-acts button .ico { width: 16px; height: 16px; }
.ob-acts button:disabled { opacity: .3; }
.ob-acts button:not(:disabled):hover { background: var(--paper); }

.ob-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; perspective: 2400px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.ob-spread { position: absolute; left: 0; transform-style: preserve-3d; will-change: transform; }
.ob-page { position: absolute; top: 0; bottom: 0; width: 50%; overflow: hidden; background: var(--paper); }
.ob-page--left { left: 0; border-radius: 3px 0 0 3px; box-shadow: -1px 1px 0 #EDE3D6, -2px 2px 0 #E4D8C9, -3px 3px 0 #EDE3D6, -10px 14px 24px -14px rgba(60, 40, 20, .5); }
.ob-page--right { left: 50%; border-radius: 0 3px 3px 0; box-shadow: 1px 1px 0 #EDE3D6, 2px 2px 0 #E4D8C9, 3px 3px 0 #EDE3D6, 10px 14px 24px -14px rgba(60, 40, 20, .5); }
.ob-page--left::after, .ob-page--right::after { content: ''; position: absolute; top: 0; bottom: 0; width: 26px; pointer-events: none; z-index: 2; }
.ob-page--left::after { right: 0; background: linear-gradient(to left, rgba(70, 48, 26, .16), transparent); }
.ob-page--right::after { left: 0; background: linear-gradient(to right, rgba(70, 48, 26, .2), transparent); }
.ob-page-in { position: absolute; inset: 0; overflow: hidden; container-type: inline-size; }
.ob-page-in[data-scroll] { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: none; }
.ob-page-in[data-scroll]::-webkit-scrollbar { display: none; }
.ob-page--right:not(.is-active-side) .ob-page-in { overflow: hidden; }
/* edit controls keep their space on both pages, but only show on the facing page */
.ob-page:not(.is-active-side) .ctl { visibility: hidden; pointer-events: none; }
.ob-shade { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; background: rgba(41, 39, 34, .5); transition: opacity .35s; }
.ob-stage:not(.is-both) .ob-spread > .ob-page:not(.is-facing) .ob-shade { opacity: .08; }
.ob-stage:not(.is-both) .ob-spread > .ob-page:not(.is-facing) { cursor: pointer; }
.ob-gutter { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; margin-left: -.5px; background: rgba(70, 48, 26, .25); z-index: 4; pointer-events: none; }

/* turning leaf */
.ob-leaf { position: absolute; top: 0; bottom: 0; width: 50%; z-index: 6; transform-style: preserve-3d; will-change: transform; }
.ob-leaf--right { left: 50%; }
.ob-leaf--left { left: 0; }
.ob-leaf > .ob-page { left: 0; width: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; box-shadow: 0 0 18px rgba(41, 39, 34, .14); }
.ob-leaf > .ob-page::after { display: none; }
.ob-leaf > .ob-page--back { transform: rotateY(180deg); }
.ob-leaf--right .ob-page--front .ob-shade { background: linear-gradient(to left, rgba(41, 30, 18, .42), rgba(41, 30, 18, .1) 45%, rgba(255, 255, 255, .06) 85%, rgba(41, 30, 18, .16)); }
.ob-leaf--right .ob-page--back .ob-shade { background: linear-gradient(to right, rgba(41, 30, 18, .38), rgba(41, 30, 18, .08) 50%, transparent); }
.ob-leaf--left .ob-page--front .ob-shade { background: linear-gradient(to right, rgba(41, 30, 18, .42), rgba(41, 30, 18, .1) 45%, rgba(255, 255, 255, .06) 85%, rgba(41, 30, 18, .16)); }
.ob-leaf--left .ob-page--back .ob-shade { background: linear-gradient(to left, rgba(41, 30, 18, .38), rgba(41, 30, 18, .08) 50%, transparent); }
.ob-cast { position: absolute; inset: 0; z-index: 5; pointer-events: none; opacity: 0; }
.ob-cast--left { background: linear-gradient(to right, rgba(41, 30, 18, .42), rgba(41, 30, 18, .1) 24%, transparent 55%); }
.ob-cast--right { background: linear-gradient(to left, rgba(41, 30, 18, .42), rgba(41, 30, 18, .1) 24%, transparent 55%); }

/* edges (iPad) and the Pivot spiral at the base of the spine */
.ob-edge { display: none; position: absolute; top: 0; bottom: 60px; width: 7%; z-index: 7; }
.ob-stage.is-both .ob-edge { display: block; }
.ob-edge:disabled { display: none !important; }
.ob-edge--prev { left: 0; } .ob-edge--next { right: 0; }
.ob-pivot { position: absolute; z-index: 8; width: 46px; height: 46px; margin-left: -23px; border-radius: 50%; touch-action: none; filter: drop-shadow(0 4px 6px rgba(70, 48, 26, .35)); }
.ob-stage.is-both .ob-pivot { display: none; }
.spiral { width: 100%; height: 100%; transform: rotate(calc(var(--p, 0) * -300deg)); }
.spiral-disc { fill: url(#none); fill: #D9C29A; stroke: #A98852; stroke-width: 1.2; }
.spiral-line { fill: none; stroke: #6D5530; stroke-width: 1.6; stroke-linecap: round; }
.ob-pivot:hover .spiral-disc { fill: #E3CFAA; }
.ob-pivot.is-cue { animation: cue 1.8s var(--ease) infinite; }
.ob-pivot.is-cue::after { content: ''; position: absolute; top: 50%; right: 100%; width: 54px; height: 2px; margin-right: 4px; background: var(--gilt); clip-path: polygon(0 50%, 8px 0, 8px 100%); }
@keyframes cue { 50% { transform: scale(1.12); } }
.ob-results { position: absolute; right: 8px; top: 8px; z-index: 7; padding: 4px 9px; border-radius: 999px; background: var(--ink); color: var(--paper); font: 600 10px var(--f-label); letter-spacing: .06em; }
.ob-stage.is-empty .ob-pivot { display: none; }

/* ================= Pages ================= */
.pg { position: relative; min-height: 100%; }
/* visual side */
.pg--visual { height: 100%; }
.pg-plate { position: absolute; inset: 12px 12px 30px; overflow: hidden; background: #E9DFD2; box-shadow: 0 0 0 1px rgba(41, 39, 34, .12); }
.pg-plate img { width: 100%; height: 100%; object-fit: cover; }
.pg-scrim { position: absolute; inset: 0; pointer-events: none; }
.ts-color-paper .pg-scrim { background: linear-gradient(to top, rgba(20, 14, 8, .62), rgba(20, 14, 8, 0) 48%); }
.ts-color-paper.ts-pos-top .pg-scrim { background: linear-gradient(to bottom, rgba(20, 14, 8, .6), rgba(20, 14, 8, 0) 46%); }
.ts-color-paper.ts-pos-center .pg-scrim { background: radial-gradient(ellipse at center, rgba(20, 14, 8, .5), rgba(20, 14, 8, 0) 70%); }
.ts-color-ink .pg-scrim, .ts-color-accent .pg-scrim { background: linear-gradient(to top, rgba(255, 253, 248, .86), rgba(255, 253, 248, 0) 50%); }
.ts-color-ink.ts-pos-top .pg-scrim, .ts-color-accent.ts-pos-top .pg-scrim { background: linear-gradient(to bottom, rgba(255, 253, 248, .86), rgba(255, 253, 248, 0) 48%); }
.ts-color-ink.ts-pos-center .pg-scrim, .ts-color-accent.ts-pos-center .pg-scrim { background: radial-gradient(ellipse at center, rgba(255, 253, 248, .8), rgba(255, 253, 248, 0) 70%); }
.pg-title { position: absolute; left: 7%; right: 7%; z-index: 2; }
.ts-pos-top .pg-title { top: 7%; padding-right: 40px; }
.ts-pos-center .pg-title { top: 50%; transform: translateY(-50%); text-align: center; }
.ts-pos-bottom .pg-title { bottom: 6%; }
.pg-title-t { margin: 0; font: 500 clamp(18px, 10.5cqw, 34px)/1.05 var(--f-display); text-wrap: balance; overflow-wrap: break-word; }
.pg-title-s { margin: 6px 0 0; font: italic 400 clamp(12px, 5cqw, 16px)/1.3 var(--f-display); }
.ts-font-italic .pg-title-t { font-style: italic; font-weight: 400; }
.ts-font-caps .pg-title-t { text-transform: uppercase; letter-spacing: .12em; font-size: clamp(14px, 7.2cqw, 24px); font-weight: 500; }
.ts-color-paper .pg-title { color: #FFFDF8; text-shadow: 0 1px 14px rgba(0, 0, 0, .35); }
.ts-color-ink .pg-title { color: var(--ink); }
.ts-color-accent .pg-title { color: var(--accent); }
.pg-title-t.is-auto { font-style: italic; opacity: .85; }
.pg--visual.is-card .pg-card { position: absolute; inset: 12px 12px 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 0 10%; text-align: center; box-shadow: inset 0 0 0 1px var(--line); }
.pg--visual.is-card .pg-title { position: static; transform: none; padding: 0; text-align: center; color: var(--ink); text-shadow: none; }
.pg--visual.is-card.ts-color-accent .pg-title { color: var(--accent); }
.pg-card-rule { width: 36px; height: 1px; background: var(--gilt); }
.pg-foot { position: absolute; left: 14px; right: 14px; bottom: 9px; display: flex; justify-content: space-between; font: 500 8.5px var(--f-label); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.pg-tools { position: absolute; top: 18px; right: 18px; z-index: 4; display: flex; gap: 6px; }
.pg-tools--info { position: static; justify-content: flex-end; margin: -8px -6px 8px; }
.pg-tool { width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; color: var(--ink); background: rgba(255, 253, 248, .9); box-shadow: 0 1px 4px rgba(41, 39, 34, .18); }
.pg-tool .ico { width: 16px; height: 16px; }
.pg-aa { font: 500 14px var(--f-display); }
.pg-tools--info .pg-tool { box-shadow: inset 0 0 0 1px var(--line); background: transparent; }

/* informational side (also the teaser on the right-hand page) */
.pg--info { padding: 22px 20px 34px; --ts: 1; }
.pg-ih h2 { margin: 0 0 6px; font: 500 calc(21px * var(--ts))/1.1 var(--f-display); }
.tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 0 0 4px; }
.tag { display: inline-flex; align-items: center; gap: 2px; padding: 2px 8px; border-radius: 999px; font: 500 10px var(--f-label); letter-spacing: .04em; color: var(--olive); background: rgba(89, 99, 75, .1); }
.tag button { display: grid; place-items: center; width: 14px; height: 14px; color: var(--olive); }
.tag button .ico { width: 10px; height: 10px; }
.tag--add { background: transparent; box-shadow: inset 0 0 0 1px rgba(89, 99, 75, .35); }
.sec { margin-top: 18px; }
.sec-h { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.sec-h h3 { margin: 0 auto 0 0; font: 600 calc(12.5px * var(--ts))/1 var(--f-display); letter-spacing: .16em; text-transform: uppercase; }
.sec-h h3::after { content: ''; display: block; width: 14px; height: 1px; margin-top: 7px; background: var(--ink); }
.sec-count { font: 500 10px var(--f-label); color: var(--muted); }
.sec-x, .sec-mic { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; color: var(--muted); }
.sec-x .ico, .sec-mic .ico { width: 15px; height: 15px; }
.sec-x:hover { color: var(--danger); background: rgba(179, 38, 30, .08); }
.ings { list-style: none; margin: 0; padding: 0; }
.ing { position: relative; display: grid; grid-template-columns: 3.4em 1fr; gap: 10px; padding: 4px 22px 4px 0; font: 400 calc(15px * var(--ts))/1.35 var(--f-display); border-bottom: 1px solid rgba(231, 217, 204, .7); }
.ing [data-f]:empty::before { content: none; }
.ing:focus-within [data-f]:empty::before { content: attr(data-placeholder); }
.ing-q { text-align: right; white-space: nowrap; }
.ing-note { color: var(--muted); font-style: italic; }
.ing-x { position: absolute; right: 0; top: 50%; width: 22px; height: 22px; margin-top: -11px; display: grid; place-items: center; color: var(--muted); opacity: 0; }
.ing-x .ico { width: 13px; height: 13px; }
.ing:hover .ing-x, .ing:focus-within .ing-x { opacity: 1; }
.method { font: 400 calc(15.5px * var(--ts))/1.55 var(--f-display); white-space: pre-wrap; }
.add { display: inline-block; margin-top: 8px; padding: 6px 0; font: 500 11px var(--f-label); letter-spacing: .08em; color: var(--accent); }
.add + .add { margin-left: 16px; }
.note { margin: 0 0 14px; padding-left: 12px; border-left: 2px solid var(--accent); }
.note-t { margin: 0; font: italic 400 calc(15.5px * var(--ts))/1.5 var(--f-display); }
.sec--notes.is-free .note-t { font-size: calc(17.5px * var(--ts)); }
.note-photo { width: 64%; margin-top: 8px; box-shadow: 0 0 0 4px #fff, 0 2px 8px rgba(41, 39, 34, .2); }
.note-meta { display: flex; justify-content: space-between; gap: 8px; margin-top: 6px; font: 500 10px var(--f-label); color: var(--muted); }
.note-tools { display: flex; gap: 10px; }
.note-tools button { color: var(--accent); font-weight: 600; }
.prov { margin: 22px 0 0; padding-top: 14px; border-top: 1px solid var(--line); text-align: center; }
.prov-from { margin: 0; font: italic 500 calc(15px * var(--ts)) var(--f-display); }
.prov-line { margin: 3px 0 0; font: 500 9.5px var(--f-label); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.prov-story { margin: 8px 0 0; font: 400 calc(14px * var(--ts))/1.5 var(--f-display); color: #4A453D; }
.arts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.art { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.art-thumb { aspect-ratio: 1; display: grid; place-items: center; overflow: hidden; background: #F1E9DD; box-shadow: 0 0 0 3px #fff, 0 1px 5px rgba(41, 39, 34, .2); color: var(--muted); }
.art-thumb img { width: 100%; height: 100%; object-fit: cover; }
.art-type { font: 500 9.5px var(--f-label); letter-spacing: .04em; color: var(--muted); }
.art--add .art-thumb { background: transparent; box-shadow: inset 0 0 0 1px dashed; border: 1px dashed var(--line); }
.art--add:disabled { opacity: .45; }
.pg-cue { margin: 20px 0 0; text-align: center; font: italic 13px var(--f-display); color: var(--muted); }
.pg--empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; padding: 0 12%; text-align: center; }
.pg--empty h2 { margin: 6px 0 8px; font: italic 400 24px/1.15 var(--f-display); }
.pg--empty p { margin: 0 0 18px; font: 400 15px/1.45 var(--f-display); color: var(--muted); }
.pg-empty-k { margin: 0 !important; font: 500 10px var(--f-label) !important; letter-spacing: .18em; text-transform: uppercase; }
.pg--blank { height: 100%; }

/* ================= Create Folio (inside the Book) ================= */
.pg--new { height: 100%; }
.new-frame { position: absolute; inset: 12px 12px 30px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid var(--accent); color: var(--accent); font: italic 16px var(--f-display); }
.new-frame .ico { width: 30px; height: 30px; stroke-width: 1.2; }
.new-frame p { margin: 0; }
.title-pill { position: absolute; top: 24px; left: 26px; right: 26px; z-index: 5; display: flex; align-items: center; gap: 6px; height: 40px; padding: 0 6px 0 16px; border-radius: 999px; background: rgba(255, 253, 248, .94); box-shadow: 0 4px 14px rgba(41, 39, 34, .22); }
.title-pill-in { flex: 1; min-width: 0; border: 0; background: transparent; outline: none; font: 500 18px var(--f-display); color: var(--ink); }
.title-pill-in::placeholder { color: var(--muted); }
.title-pill-mic { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; color: var(--ink); border-left: 1px solid var(--line); }
.title-pill-x { position: absolute; left: -10px; top: -10px; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 50%; background: var(--paper); box-shadow: 0 1px 4px rgba(41, 39, 34, .3); }
.title-pill-x .ico { width: 13px; height: 13px; }
.pg--ghost { height: 100%; padding: 26px 20px; opacity: .5; }
.pg--ghost p { margin: 16px 0 8px; font: 600 11px var(--f-display); letter-spacing: .16em; text-transform: uppercase; }
.pg--ghost i { display: block; height: 6px; margin: 7px 0; background: #EDE4D8; border-radius: 3px; }
.pg--ghost i:nth-of-type(3n) { width: 70%; }
.pg--compose { padding: 22px 18px 70px; }
.compose-t { margin: 0 0 6px; font: italic 400 18px/1.15 var(--f-display); color: var(--muted); }
.ask { width: 100%; display: flex; align-items: center; justify-content: space-between; margin-top: 14px; min-height: 46px; padding: 0 6px 0 16px; border-radius: 999px; background: #F3E9E4; box-shadow: inset 0 0 0 1px #E3D3CB; font: 600 13px var(--f-display); letter-spacing: .14em; text-transform: uppercase; color: #6A5A55; }
.ask-mic { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; box-shadow: inset 0 0 0 1px #D9C4BA; color: var(--accent); }
.cings { display: flex; flex-direction: column; gap: 4px; }
.cing { display: grid; grid-template-columns: 40px 46px 1fr 24px; gap: 4px; align-items: center; }
.cing input { min-width: 0; height: 30px; padding: 0 4px; border: 0; border-bottom: 1px solid var(--line); background: transparent; font: 400 14px var(--f-display); color: var(--ink); outline: none; }
.cing input:focus { border-color: var(--accent); }
.cing button { width: 24px; height: 24px; display: grid; place-items: center; color: var(--muted); }
.cing button .ico { width: 13px; height: 13px; }
.carea { width: 100%; min-height: 92px; padding: 4px 0; border: 0; resize: vertical; outline: none; background: repeating-linear-gradient(transparent 0 23px, var(--line) 23px 24px); font: 400 15px/24px var(--f-display); color: var(--ink); }
.save-pill { position: sticky; bottom: 12px; float: right; margin-top: 18px; padding: 8px 18px; border-radius: 999px; background: var(--paper); box-shadow: inset 0 0 0 1.5px #C9A79B, 0 2px 8px rgba(41, 39, 34, .15); font: 600 12px var(--f-display); letter-spacing: .16em; text-transform: uppercase; }
.save-pill:hover { box-shadow: inset 0 0 0 1.5px var(--accent), 0 2px 8px rgba(41, 39, 34, .15); color: var(--accent); }
.stamp { position: absolute; left: 50%; top: 42%; z-index: 6; padding: 6px 18px; border: 2.5px solid var(--accent); border-radius: 4px; color: var(--accent); background: rgba(255, 253, 248, .85); font: 600 22px var(--f-display); letter-spacing: .24em; text-transform: uppercase; transform: translate(-50%, -50%) rotate(-8deg); animation: stamp .55s cubic-bezier(.3, 1.6, .5, 1) both; }
@keyframes stamp { from { transform: translate(-50%, -50%) rotate(-8deg) scale(2.2); opacity: 0; } }

/* ================= Bottom bar ================= */
.bar { flex: none; display: flex; align-items: center; gap: 10px; min-height: 64px; padding: 6px 16px calc(10px + var(--safe-bottom)); }
.create { display: flex; align-items: center; gap: 8px; font: 500 17px var(--f-display); }
.create-dot { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 50%; background: var(--accent); color: #fff; box-shadow: 0 4px 10px -2px rgba(168, 95, 72, .55); }
.create:hover .create-dot { transform: scale(1.05); }
.bar-hint { flex: 1; min-width: 0; margin: 0; text-align: right; font: 400 11px/1.35 var(--f-label); color: var(--muted); }
.bar--create .bar-hint { text-align: center; }
.bar-x { width: 40px; height: 40px; flex: none; display: grid; place-items: center; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--line); }
.sources { flex: 1; display: flex; justify-content: center; gap: 14px; }
.sources button { display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 52px; font: 500 10.5px var(--f-label); color: var(--ink); }
.sources .ico { width: 26px; height: 26px; stroke-width: 1.2; }
.bar-link { flex: none; font: 500 11.5px var(--f-label); color: var(--muted); text-decoration: underline; text-underline-offset: 3px; }
.bar--place { justify-content: space-between; }
.drag-chip { display: flex; align-items: center; gap: 8px; height: 44px; padding: 0 12px 0 4px; border-radius: 10px; border: 1.5px dashed var(--gilt); background: var(--paper); font: 500 11px var(--f-label); cursor: grab; touch-action: none; }
.drag-chip img, .drag-chip i { width: 32px; height: 36px; object-fit: cover; background: #EDE3D6; box-shadow: 0 0 0 2px #fff, 0 1px 3px rgba(41, 39, 34, .25); }
.drag-ghost { position: fixed; z-index: 1000; pointer-events: none; transform: rotate(-4deg) scale(1.05); box-shadow: 0 12px 24px rgba(41, 39, 34, .3); }
.place-acts { display: flex; align-items: center; gap: 12px; }

/* ================= Archive ================= */
.archive { padding: 6px 16px 40px; }
.archive-h { display: flex; align-items: baseline; justify-content: space-between; margin: 4px 0 6px; }
.archive-h h2 { margin: 0; font: italic 400 26px var(--f-display); }
.archive-h p, .muted { margin: 0; font: 400 12px var(--f-label); color: var(--muted); }
.archive-k { margin: 20px 0 10px; font: 600 10.5px var(--f-label); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 18px 12px; }
.tile { display: flex; flex-direction: column; gap: 4px; text-align: left; }
.tile-img { aspect-ratio: 3 / 4; overflow: hidden; background: var(--paper); box-shadow: 0 0 0 5px var(--paper), 0 0 0 6px var(--line), 0 6px 12px -6px rgba(41, 39, 34, .35); margin: 6px; }
.tile-img img { width: 100%; height: 100%; object-fit: cover; }
.tile-img.is-card { display: grid; place-items: center; padding: 10px; text-align: center; font: italic 15px/1.15 var(--f-display); }
.tile-t { font: 500 14px/1.2 var(--f-display); }
.tile-s { font: 400 10px var(--f-label); color: var(--muted); }
.archived { display: flex; flex-direction: column; gap: 8px; }
.archived .spine { opacity: .75; cursor: default; }
.archived .spine:hover { transform: none; }

/* ================= Sheets ================= */
.kicker { margin: 0 0 12px; font: 600 10.5px var(--f-label); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.sheet-title { margin: 0 0 8px; font: 400 26px/1.15 var(--f-display); }
.sheet-body { margin: 0 0 6px; font: 400 14px/1.6 var(--f-label); color: var(--muted); }
.sheet-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.sheet-x { position: absolute; top: 12px; right: 12px; z-index: 2; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; background: rgba(255, 253, 248, .9); }
.hint { margin: 6px 0 14px; font: 400 12px/1.5 var(--f-label); color: var(--muted); }
.input { width: 100%; padding: 10px 0; border: 0; border-bottom: 1px solid var(--line); background: transparent; outline: none; font: 400 18px var(--f-display); color: var(--ink); }
.input--title { font-size: 26px; }
.input:focus { border-color: var(--ink); }
.input::placeholder { color: var(--muted); font-style: italic; opacity: .8; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 14px; scrollbar-width: none; }
.chip { flex: none; padding: 7px 13px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); font: italic 15px var(--f-display); }
.chip:hover { box-shadow: inset 0 0 0 1px var(--ink); }
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 34px; height: 22px; border-radius: 2px; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .1); }
.swatch.is-active { box-shadow: 0 0 0 2px var(--paper), 0 0 0 3.5px var(--ink); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 20px; border-radius: 999px; font: 500 14px var(--f-label); }
.btn .ico { width: 16px; height: 16px; }
.btn--small { min-height: 36px; padding: 0 14px; font-size: 13px; }
.btn--solid { background: var(--ink); color: var(--paper); }
.btn--accent { background: var(--accent); color: #fff; }
.btn--ghost { box-shadow: inset 0 0 0 1px var(--line); }
.btn--danger { background: var(--danger); color: #fff; }
.btn--block { width: 100%; margin-top: 10px; }
.btn:disabled { opacity: .4; }
.menu { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.menu button { padding: 15px 2px; text-align: left; font: 400 19px var(--f-display); border-bottom: 1px solid var(--line); }
.menu button:disabled { opacity: .4; }
.menu .is-danger { color: var(--danger); }
.rows { display: flex; flex-direction: column; border-top: 1px solid var(--line); max-height: 46vh; overflow-y: auto; }
.row { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 6px 2px; border-bottom: 1px solid var(--line); font: 400 17px var(--f-display); background: var(--paper); }
.row .ico { color: var(--muted); cursor: grab; }
.row small { margin-left: auto; font: 400 10.5px var(--f-label); color: var(--muted); }
.row.is-dragging { position: relative; z-index: 3; box-shadow: 0 8px 18px rgba(41, 39, 34, .2); }
.row--check input { width: 18px; height: 18px; accent-color: var(--accent); }
.row-tone { width: 26px; height: 14px; border-radius: 2px; background: var(--c); flex: none; }
.seg { display: flex; gap: 4px; padding: 3px; border-radius: 999px; background: #F2E8DE; }
.seg button { flex: 1; min-height: 36px; padding: 0 12px; border-radius: 999px; font: 500 13px var(--f-label); color: var(--muted); }
.seg button.is-active { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(41, 39, 34, .15); }
.tt-row { display: grid; grid-template-columns: 82px 1fr; align-items: center; gap: 10px; margin-bottom: 10px; }
.tt-row > span { font: 600 10px var(--f-label); letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* search */
.overlay--search { align-items: flex-start; }
.overlay--search .sheet { border-radius: 0 0 22px 22px; padding-top: calc(var(--safe-top) + 12px); transform: translateY(-40px); max-height: 80%; }
.search-bar { display: flex; align-items: center; gap: 8px; height: 46px; padding: 0 8px 0 14px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--line); background: #fff; }
.search-in { flex: 1; min-width: 0; border: 0; outline: none; background: transparent; font: 400 18px var(--f-display); color: var(--ink); }
.search-x { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 50%; background: #F2E8DE; }
.search-x .ico { width: 14px; height: 14px; }
.search-res { margin-top: 12px; }
.search-res h4 { display: flex; justify-content: space-between; margin: 14px 0 6px; font: 600 10.5px var(--f-label); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.res { width: 100%; display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 6px 2px; border-bottom: 1px solid var(--line); text-align: left; font: 400 17px var(--f-display); }
.res img, .res-card { width: 34px; height: 42px; object-fit: cover; flex: none; background: #F1E9DD; box-shadow: 0 0 0 2px #fff, 0 1px 3px rgba(41, 39, 34, .2); }
.res small { margin-left: auto; font: 400 10.5px var(--f-label); color: var(--muted); text-align: right; }
.search-none { margin: 18px 0 6px; font: italic 17px var(--f-display); color: var(--muted); text-align: center; }

/* Cooking View: high contrast, large type, one scrolling page */
.overlay--cooking { background: #fff; }
.overlay--cooking .sheet { max-width: none; max-height: none; height: 100%; border-radius: 0; padding: calc(var(--safe-top) + 6px) 0 0; background: #fff; color: #111; display: flex; flex-direction: column; }
.cook-bar { flex: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 14px 8px; border-bottom: 1px solid #ddd; }
.cook-btn { flex: none; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: #F1F1F1; }
.cook-awake { flex: 1; min-width: 0; text-align: center; font: 500 10px/1.3 var(--f-label); color: #555; }
.cook-size { flex: none; display: flex; gap: 4px; }
.cook-size button { min-width: 44px; height: 44px; padding: 0 9px; border-radius: 22px; background: #F1F1F1; font: 600 13px var(--f-label); }
.cook { flex: 1; overflow-y: auto; padding: 20px 22px 60px; --cs: 1.25; }
.cook h1 { margin: 0 0 18px; font: 600 calc(28px * var(--cs))/1.1 var(--f-display); }
.cook h2 { margin: 26px 0 10px; font: 700 calc(11px * var(--cs)) var(--f-label); letter-spacing: .14em; text-transform: uppercase; }
.cook ul { list-style: none; margin: 0; padding: 0; }
.cook li { padding: 8px 0; border-bottom: 1px solid #e6e6e6; font: 400 calc(16px * var(--cs))/1.4 var(--f-body); }
.cook li b { font-weight: 700; }
.cook p { margin: 0 0 16px; font: 400 calc(17px * var(--cs))/1.6 var(--f-body); }

/* artifact lightbox */
.overlay--lightbox .sheet { max-width: 640px; padding: 0 0 22px; }
.lightbox { margin: 0; }
.lightbox img { width: 100%; max-height: 60vh; object-fit: cover; }
.lightbox-doc { height: 260px; display: grid; place-items: center; color: var(--muted); background: var(--bg); }
.lightbox figcaption { display: flex; justify-content: space-between; gap: 12px; padding: 14px 22px 0; font: 400 13px var(--f-label); }
.lightbox figcaption span { color: var(--muted); }
.ocr { margin: 14px 22px 0; padding: 14px 16px; background: var(--bg); border-left: 2px solid var(--accent); font: 400 15px/1.55 var(--f-display); }
.ocr .kicker { margin-bottom: 6px; font-size: 9.5px; }
.ocr p:last-child { margin: 0; }

/* ================= iPad ================= */
/* Tablets are told apart by shape, so a scaled-down iPad preview still gets the iPad layout */
@container app (min-aspect-ratio: 3/5) {
  .shelf { padding: 6px 0 0; width: min(560px, 80%); margin: 0 auto; }
  .shelf-scroll { max-height: 176px; }
  .spine { height: calc(var(--h) + 6px); }
  .spine-t { font-size: 22px; } .spine--caps .spine-t { font-size: 16px; }
  .ob-head { max-width: 820px; width: 100%; margin: 0 auto; }
  .tiles { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
@container app (min-aspect-ratio: 5/4) {
  .lib-body { flex-direction: row; }
  .shelf { width: 340px; flex: none; display: flex; flex-direction: column; padding: 14px 10px 0 24px; margin: 0; }
  .shelf-scroll { max-height: none; flex: 1; justify-content: flex-end; padding-bottom: 2px; }
  .ledge { flex: none; margin-bottom: 18px; }
  .ob, .archive { flex: 1; min-width: 0; }
  .lib.is-archive .lib-body { overflow: hidden; }
  .lib.is-archive .archive { overflow-y: auto; padding: 14px 32px 40px; }
}

/* Short phones (iPhone SE class): a shorter shelf so the open Book keeps its size */
@container app (max-height: 760px) and (max-aspect-ratio: 3/5) {
  .top { padding-bottom: 0; }
  .shelf-scroll { max-height: 112px; padding-top: 4px; }
  .spine { height: calc(var(--h) * .82); }
  .spine-t { font-size: 17px; } .spine--caps .spine-t { font-size: 12.5px; }
  .ledge { height: 34px; padding-top: 10px; }
  .ob-head { height: 38px; }
  .bar { min-height: 54px; padding-top: 2px; }
  .create-dot { width: 36px; height: 36px; }
}

/* Reduce Motion: no animated movement */
.app.is-reduced *, .app.is-reduced *::before, .app.is-reduced *::after { animation: none !important; transition-duration: .01ms !important; }
