/* Savor mockup: presenter shell + mechanics shared by every direction.
   Direction stylesheets set the --sv-* tokens and style their own markup. */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: #e9e7e3;
  color: #1f1e1c;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

/* ================= Presenter (not part of the product) ================= */
.pz { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.pz-bar {
  flex: none; display: flex; align-items: center; gap: 18px;
  padding: 10px 18px; background: #fbfaf8; border-bottom: 1px solid #dcd8d1;
  font-size: 12px; letter-spacing: .01em; z-index: 10;
}
.pz-brand { display: flex; flex-direction: column; line-height: 1.2; min-width: 150px; }
.pz-brand b { font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.pz-brand span { color: #8a857c; }
.pz-group { display: flex; align-items: center; gap: 2px; padding: 3px; background: #efece7; border-radius: 9px; }
.pz-group button { padding: 7px 11px; border-radius: 7px; color: #5d5952; white-space: nowrap; transition: background .2s, color .2s; }
.pz-group button:hover { color: #1f1e1c; }
.pz-group button.is-active { background: #fff; color: #1f1e1c; box-shadow: 0 1px 2px rgba(0,0,0,.08), 0 0 0 1px rgba(0,0,0,.04); }
.pz-variants button { display: flex; flex-direction: column; align-items: flex-start; padding: 6px 12px; line-height: 1.25; }
.pz-variants button small { font-size: 10.5px; color: #9a958c; }
.pz-variants button.is-active small { color: #7d786f; }
.pz-label { font-size: 10px; text-transform: uppercase; letter-spacing: .12em; color: #9a958c; margin-right: 6px; }
.pz-spacer { flex: 1; }
.pz-reset { padding: 7px 10px; color: #7d786f; border-radius: 7px; }
.pz-reset:hover { background: #efece7; color: #1f1e1c; }
.pz-select { display: none; }

.pz-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; overflow: hidden; }
.pz-device { position: relative; flex: none; transform-origin: center center; }
.pz-device[data-device="phone"] { width: 390px; height: 844px; padding: 12px; border-radius: 58px; background: #1c1b1a; box-shadow: 0 0 0 1px #3a3836, 0 40px 80px -20px rgba(40,30,20,.45), 0 12px 24px -12px rgba(40,30,20,.3); }
.pz-device[data-device="phone"]::after { content: ''; position: absolute; top: 22px; left: 50%; width: 112px; height: 32px; margin-left: -56px; border-radius: 20px; background: #000; z-index: 60; pointer-events: none; }
.pz-device[data-device="phone"] .pz-screen { border-radius: 46px; }
.pz-device[data-device="tablet"] { width: 1180px; height: 820px; padding: 18px; border-radius: 40px; background: #1c1b1a; box-shadow: 0 0 0 1px #3a3836, 0 40px 80px -20px rgba(40,30,20,.45); }
.pz-device[data-device="tablet"] .pz-screen { border-radius: 24px; }
.pz-device[data-device="desktop"] { width: 100%; height: 100%; transform: none !important; }
.pz-screen { position: relative; width: 100%; height: 100%; overflow: hidden; isolation: isolate; }
.pz-device[data-device="phone"] { --safe-top: 44px; }

.pz-note {
  position: absolute; left: 22px; bottom: 20px; max-width: 290px; z-index: 5;
  font-size: 12px; line-height: 1.55; color: #5d5952;
  background: rgba(251,250,248,.92); border: 1px solid #dcd8d1; border-radius: 12px; padding: 14px 16px;
  backdrop-filter: blur(6px);
}
.pz-note b { display: block; font-size: 13px; color: #1f1e1c; margin-bottom: 4px; }
.pz-note ul { margin: 8px 0 0; padding-left: 16px; }
.pz-note li { margin: 2px 0; }
.pz-note-x { position: absolute; top: 8px; right: 10px; color: #9a958c; font-size: 16px; line-height: 1; }
.pz-hide-note .pz-note { display: none; }
.pz-device[data-device="desktop"] ~ .pz-note,
.pz-device[data-device="tablet"] ~ .pz-note { display: none; }

@media (max-width: 1440px) {
  .pz-variants button small { display: none; }
}
@media (max-width: 1280px) {
  .pz-brand { display: none; }
  .pz-bar { gap: 12px; }
}
@media (max-width: 1100px) {
  .pz-note { display: none; }
}
@media (max-width: 860px) {
  .pz-bar { gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
  .pz-screens, .pz-devices { display: none; }
  .pz-select { display: block; flex: 1; min-width: 0; font: inherit; padding: 8px; border-radius: 8px; border: 1px solid #dcd8d1; background: #fff; }
  .pz-variants { flex: none; }
  .pz-variants button { padding: 6px 9px; }
}

/* ================= App base ================= */
.app {
  position: absolute; inset: 0; overflow: hidden;
  container: app / inline-size;
  background: var(--sv-bg); color: var(--sv-ink);
  font-family: var(--sv-font-body);
  --safe-top: 0px;
}
.pz-device[data-device="phone"] .app { --safe-top: 44px; }
.sv-screen { position: absolute; inset: 0; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; }
.sv-enter { animation: sv-enter .55s cubic-bezier(.2,.7,.2,1) backwards; }
@keyframes sv-enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.sv-ico { width: 20px; height: 20px; stroke-width: var(--sv-stroke, 1.5); flex: none; }

/* ================= Reader (page turning between Folios) ================= */
.sv-book { position: relative; perspective: 2600px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.sv-page { position: absolute; top: 0; bottom: 0; overflow: hidden; background: var(--sv-paper); }
.sv-page--left { left: 0; width: 50%; }
.sv-page--right { left: 50%; width: 50%; }
.sv-page--single { left: 0; width: 100%; }
.sv-page-inner { position: absolute; inset: 0; overflow: hidden; }
.sv-book .sv-page--info .sv-page-inner { overflow-y: auto; scrollbar-width: none; }
.sv-book .sv-page--info .sv-page-inner::-webkit-scrollbar { display: none; }
.sv-book .sv-page[data-folio] { cursor: pointer; }
.sv-shade { position: absolute; inset: 0; pointer-events: none; opacity: 0; z-index: 3; }
.sv-leaf { position: absolute; top: 0; bottom: 0; z-index: 6; transform-style: preserve-3d; will-change: transform; }
.sv-leaf--right { left: 50%; width: 50%; }
.sv-leaf--left { left: 0; width: 50%; }
.sv-leaf--full { left: 0; width: 100%; }
.sv-leaf > .sv-page { left: 0; width: 100%; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
.sv-leaf > .sv-page--back { transform: rotateY(180deg); }
.sv-leaf--right .sv-page--front .sv-shade,
.sv-leaf--full .sv-page--front .sv-shade { background: linear-gradient(to left, rgba(20,14,8,.42), rgba(20,14,8,.12) 45%, rgba(255,255,255,.08) 85%, rgba(20,14,8,.18)); }
.sv-leaf--right .sv-page--back .sv-shade,
.sv-leaf--full .sv-page--back .sv-shade { background: linear-gradient(to right, rgba(20,14,8,.4), rgba(20,14,8,.1) 50%, rgba(255,255,255,.1)); }
.sv-leaf--left .sv-page--front .sv-shade { background: linear-gradient(to right, rgba(20,14,8,.42), rgba(20,14,8,.12) 45%, rgba(255,255,255,.08) 85%, rgba(20,14,8,.18)); }
.sv-leaf--left .sv-page--back .sv-shade { background: linear-gradient(to left, rgba(20,14,8,.4), rgba(20,14,8,.1) 50%, rgba(255,255,255,.1)); }
.sv-leaf .sv-page { box-shadow: 0 0 24px rgba(20,14,8,.18); }
.sv-cast { position: absolute; inset: 0; pointer-events: none; z-index: 4; opacity: 0; }
.sv-cast--left { background: linear-gradient(to right, rgba(20,14,8,.45), rgba(20,14,8,.12) 22%, transparent 55%); }
.sv-cast--right { background: linear-gradient(to left, rgba(20,14,8,.45), rgba(20,14,8,.12) 22%, transparent 55%); }
.sv-page--single .sv-cast--left { background: linear-gradient(to right, rgba(20,14,8,.35), transparent 70%); }
.sv-edge { position: absolute; top: 0; bottom: 0; width: 13%; z-index: 5; cursor: pointer; }
.sv-edge--prev { left: 0; }
.sv-edge--next { right: 0; }
.sv-edge:disabled { display: none; }
[data-layout="spread"] .sv-edge { width: 7%; }
.sv-edge::after { content: ''; position: absolute; top: 0; bottom: 0; width: 100%; opacity: 0; transition: opacity .3s; }
.sv-edge--next::after { right: 0; background: linear-gradient(to left, rgba(20,14,8,.16), transparent); }
.sv-edge--prev::after { left: 0; background: linear-gradient(to right, rgba(20,14,8,.16), transparent); }
.sv-edge:hover::after { opacity: 1; }
.is-turning .sv-edge { pointer-events: none; }

/* ================= Pivot stage (two sides of one Folio) ================= */
.sv-pivot { position: relative; perspective: 2400px; transform-style: preserve-3d; touch-action: pan-y; }
.sv-face-wrap { position: absolute; inset: 0; overflow: hidden; backface-visibility: hidden; -webkit-backface-visibility: hidden; will-change: transform; }
.sv-face-wrap--info { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.sv-pivot.is-scrubbing, .sv-pivot.is-scrubbing * { cursor: grabbing !important; user-select: none; }

/* editing affordances shared by all directions */
[contenteditable="true"] { outline: none; border-radius: 2px; transition: background .2s, box-shadow .2s; cursor: text; }
[contenteditable="true"]:hover { background: color-mix(in srgb, var(--sv-accent) 6%, transparent); }
[contenteditable="true"]:focus { background: color-mix(in srgb, var(--sv-accent) 9%, transparent); box-shadow: 0 0 0 1px color-mix(in srgb, var(--sv-accent) 35%, transparent); }
[contenteditable="true"]:empty::before { content: attr(data-placeholder); color: var(--sv-muted); opacity: .7; }
[data-method] { white-space: pre-wrap; }
.sv-share.is-selected { color: var(--sv-danger) !important; }
.sv-share.is-selected .sv-ico { stroke-width: 2; }
[data-action="dictate"].is-listening { color: var(--sv-danger) !important; animation: sv-listen 1s ease-in-out infinite; }
@keyframes sv-listen { 50% { transform: scale(1.12); opacity: .7; } }

/* ================= Shelf reordering ================= */
[data-sortable] [data-sort-id] { touch-action: pan-x pan-y; }
[data-sort-id].is-dragging { z-index: 30; position: relative; cursor: grabbing; transition: none !important; filter: drop-shadow(0 18px 18px rgba(30,20,10,.3)); }
.is-sorting { cursor: grabbing; }

/* ================= Overlays, sheets, toasts ================= */
.sv-overlay {
  position: absolute; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center;
  background: var(--sv-overlay, rgba(30,24,18,.4)); opacity: 0; transition: opacity .3s;
}
.sv-overlay.is-open { opacity: 1; }
.sv-sheet {
  position: relative; width: 100%; max-width: 520px; max-height: 92%; overflow: auto;
  background: var(--sv-paper); color: var(--sv-ink);
  border-radius: var(--sv-radius) var(--sv-radius) 0 0;
  padding: 26px 24px 28px; box-shadow: var(--sv-shadow, 0 -10px 40px rgba(20,14,8,.18));
  transform: translateY(40px); transition: transform .4s cubic-bezier(.2,.8,.2,1);
}
.sv-overlay.is-open .sv-sheet { transform: none; }
@container app (min-width: 768px) {
  .sv-overlay { align-items: center; }
  .sv-sheet { border-radius: var(--sv-radius); transform: translateY(16px) scale(.98); }
}
.sv-sheet-kicker { margin: 0 0 14px; font: 500 11px/1.4 var(--sv-font-label); letter-spacing: .14em; text-transform: uppercase; color: var(--sv-muted); }
.sv-sheet-title { margin: 0 0 10px; font: 400 28px/1.15 var(--sv-font-display); }
.sv-sheet-body { margin: 0 0 22px; font-size: 14px; line-height: 1.6; color: var(--sv-muted); }
.sv-sheet-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.sv-sheet-x { position: absolute; top: 14px; right: 14px; z-index: 2; width: 36px; height: 36px; display: grid; place-items: center; border-radius: 50%; color: var(--sv-ink); background: color-mix(in srgb, var(--sv-paper) 85%, transparent); }
.sv-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; font: 500 14px var(--sv-font-label); letter-spacing: .02em; border-radius: var(--sv-btn-radius, 999px); transition: background .2s, color .2s, opacity .2s; }
.sv-btn:disabled { opacity: .4; cursor: not-allowed; }
.sv-btn--solid { background: var(--sv-ink); color: var(--sv-paper); }
.sv-btn--accent { background: var(--sv-accent); color: var(--sv-accent-ink, #fff); }
.sv-btn--ghost { color: var(--sv-ink); box-shadow: inset 0 0 0 1px var(--sv-line); }
.sv-btn--danger { background: var(--sv-danger); color: #fff; }
.sv-btn--block { width: 100%; margin-top: 10px; }
.sv-choice { display: flex; gap: 16px; align-items: flex-start; width: 100%; text-align: left; padding: 18px 4px; border-top: 1px solid var(--sv-line); }
.sv-choice:last-of-type { border-bottom: 1px solid var(--sv-line); margin-bottom: 12px; }
.sv-choice-icon { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: var(--sv-bg); color: var(--sv-accent); flex: none; }
.sv-choice-title { display: block; font: 400 22px/1.2 var(--sv-font-display); margin-bottom: 4px; }
.sv-choice-sub { display: block; font-size: 13px; line-height: 1.5; color: var(--sv-muted); }
.sv-choice:hover .sv-choice-title { color: var(--sv-accent); }
.sv-field { display: block; margin-bottom: 8px; }
.sv-field-label { display: block; margin: 0 0 8px; font: 500 11px var(--sv-font-label); letter-spacing: .12em; text-transform: uppercase; color: var(--sv-muted); }
.sv-field-label em { font-style: normal; text-transform: none; letter-spacing: 0; opacity: .7; }
.sv-input { width: 100%; padding: 12px 0; font: 400 26px var(--sv-font-display); color: var(--sv-ink); background: transparent; border: 0; border-bottom: 1px solid var(--sv-line); outline: none; }
.sv-input:focus { border-color: var(--sv-ink); }
.sv-input::placeholder { color: var(--sv-muted); opacity: .6; font-style: italic; }
.sv-field-hint { margin: 6px 0 16px; font-size: 12px; line-height: 1.5; color: var(--sv-muted); }
.sv-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.sv-chip { padding: 7px 13px; font-size: 13px; border-radius: 999px; box-shadow: inset 0 0 0 1px var(--sv-line); color: var(--sv-ink); }
.sv-chip:hover { box-shadow: inset 0 0 0 1px var(--sv-ink); }
.sv-swatches { display: flex; gap: 12px; flex-wrap: wrap; }
.sv-swatch { width: 34px; height: 34px; border-radius: 50%; background: var(--c); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); transition: transform .2s, box-shadow .2s; }
.sv-swatch.is-active { box-shadow: 0 0 0 2px var(--sv-paper), 0 0 0 4px var(--sv-ink); transform: scale(1.05); }

.sv-overlay--lightbox .sv-sheet { max-width: 720px; padding: 0 0 22px; }
.sv-lightbox { margin: 0; }
.sv-lightbox img { width: 100%; max-height: 62vh; object-fit: cover; }
.sv-lightbox-doc { height: 280px; display: grid; place-items: center; gap: 8px; color: var(--sv-muted); background: var(--sv-bg); }
.sv-lightbox figcaption { display: flex; justify-content: space-between; gap: 12px; padding: 16px 24px 0; font-size: 13px; }
.sv-lightbox figcaption span { color: var(--sv-muted); }
.sv-ocr { margin: 16px 24px 0; padding: 16px 18px; background: var(--sv-bg); border-left: 2px solid var(--sv-accent); font-size: 14px; line-height: 1.6; }
.sv-ocr .sv-sheet-kicker { margin-bottom: 6px; font-size: 10px; }
.sv-ocr p:last-child { margin: 0; }

.sv-toasts { position: absolute; left: 0; right: 0; bottom: calc(26px + env(safe-area-inset-bottom)); z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.sv-toast {
  max-width: 440px; padding: 11px 18px; font: 500 13px/1.45 var(--sv-font-label); text-align: center;
  color: var(--sv-toast-ink, var(--sv-paper)); background: var(--sv-toast-bg, var(--sv-ink));
  border-radius: var(--sv-toast-radius, 999px); box-shadow: 0 10px 30px rgba(20,14,8,.25);
  opacity: 0; transform: translateY(10px); transition: opacity .35s, transform .35s;
}
.sv-toast.is-in { opacity: 1; transform: none; }
.sv-flash { position: absolute; inset: 0; z-index: 80; background: #fff; pointer-events: none; animation: sv-flash .5s ease-out forwards; }
@keyframes sv-flash { from { opacity: 1; } to { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .sv-enter { animation: none; }
}
