/* App runtime layer on top of the approved design system (design.css).
   Turns fixed 390×844 artboards into real, responsive, scrollable screens. */

html, body { height: 100%; }
body.app-body {
  margin: 0; background: #0b0606; color: var(--ivory); font-family: var(--f-ui);
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent;
  background:
    radial-gradient(60% 40% at 20% 0%, rgba(116, 32, 43, 0.28), transparent 70%),
    radial-gradient(50% 40% at 90% 30%, rgba(86, 21, 32, 0.24), transparent 70%),
    #0b0606;
}
#root { min-height: 100%; }

.app-screen.screen {
  width: 100%; max-width: 480px; height: 100vh; height: 100dvh; margin: 0 auto;
  border-radius: 0; border: 0; box-shadow: none;
}
@media (min-width: 560px) {
  .app-screen.screen { border-left: 1px solid rgba(199,154,75,.16); border-right: 1px solid rgba(199,154,75,.16); box-shadow: 0 0 80px rgba(0,0,0,.6); }
}
.app-screen.screen.full { max-width: none; border: 0; }
.app-screen.screen.console { max-width: 1180px; }

.app-screen .content { min-height: 0; }
.app-screen .scroll { overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; padding-bottom: 24px; }
.app-screen .scroll.flush { padding-bottom: 0; }
.fill-scroll { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; }
.fill-scroll > .grow-col { flex: 1; display: flex; flex-direction: column; min-height: min-content; }
.spacer { flex: 1; }

.view-enter { animation: viewIn var(--t-base) var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
a { color: inherit; }
a.link, button.link { cursor: pointer; background: none; border: 0; font: inherit; padding: 0; }
.btn:active { transform: translateY(1px) scale(.99); }
.btn[disabled], .btn.is-busy { opacity: .55; pointer-events: none; }
.icon-btn:active { background: rgba(199,154,75,.1); }
.tabbar a { cursor: pointer; }
.tabbar { padding-bottom: env(safe-area-inset-bottom); height: calc(78px + env(safe-area-inset-bottom)); }
.list-row.tap { cursor: pointer; width: 100%; text-align: left; font: inherit; color: inherit; background: none; border-left: 0; border-right: 0; border-top: 0; }
.list-row.tap:active { background: rgba(199,154,75,.06); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Real inputs inside the approved .field shell */
.field { cursor: text; }
.field:focus-within { border-color: var(--gold-400); box-shadow: 0 0 0 3px rgba(214,176,106,.18); color: var(--ivory); }
.field.error:focus-within { border-color: #c4636b; box-shadow: 0 0 0 3px rgba(196, 99, 107, .16); }
.field input { flex: 1; min-width: 0; height: 100%; background: none; border: 0; outline: none; color: var(--ivory); font: inherit; }
.field input::placeholder { color: var(--text-3); letter-spacing: normal; }
.field input.code { font-size: 20px; }
.field input.code::placeholder { font-family: var(--f-display); letter-spacing: .16em; color: rgba(214,176,106,.35); }
.field input[type=password] { letter-spacing: .2em; }
.field .eye { width: 36px; height: 36px; margin-right: -8px; display: grid; place-items: center; color: var(--text-3); }
.textarea-parch { width: 100%; background: transparent; border: 0; outline: none; resize: none; color: var(--sepia-900); font-family: var(--f-editorial); font-size: 20px; line-height: 1.55; }
.textarea-parch::placeholder { color: rgba(77,51,33,.5); font-style: italic; }
.input-plain { width: 100%; background: transparent; border: 0; outline: none; color: var(--sepia-900); font-family: var(--f-editorial); font-size: 24px; font-weight: 600; }
.input-plain::placeholder { color: rgba(77,51,33,.45); }
.check-box { cursor: pointer; }
.toggle { cursor: pointer; transition: background var(--t-fast) var(--ease); }
.toggle::after { transition: left var(--t-fast) var(--ease); }

/* Toasts & sheets */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: 110px; display: flex; justify-content: center; z-index: 200; pointer-events: none; }
.toast-wrap .toast { pointer-events: auto; animation: viewIn var(--t-base) var(--ease) both; max-width: calc(100vw - 40px); }
.toast .toast-act { color: var(--gold-300); font-weight: 600; margin-left: 6px; }
.sheet-layer { position: absolute; inset: 0; z-index: 60; }
.sheet-layer .scrim-full { z-index: 0; background: rgba(8,4,4,.55); animation: fade var(--t-base) var(--ease) both; }
.sheet-layer .sheet { animation: sheetUp var(--t-base) var(--ease) both; max-height: 88%; overflow-y: auto; padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.loading { flex: 1; display: grid; place-items: center; }
.loading svg { animation: flicker 1.6s ease-in-out infinite; }
.empty { text-align: center; padding: 40px 20px; }
.empty .emblem { margin-bottom: 16px; }

/* Home book is a real button */
button.book-btn { background: none; border: 0; padding: 0; cursor: pointer; }

/* Swipe-to-remove rows */
.swipe-row { position: relative; overflow: hidden; }
.swipe-row .swipe-bg { position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end; padding-right: 18px; color: #eaa9ae; font-size: 12px; letter-spacing: .1em; text-transform: uppercase; background: rgba(90,20,28,.35); }
.swipe-row .swipe-fg { position: relative; background: var(--ink-900); transition: transform var(--t-fast) var(--ease); }

/* ---------------- Reader ---------------- */
.rd { position: absolute; inset: 0; display: flex; flex-direction: column; background: #0d0706; }
.rd.theme-dark { background: #120c0a; }
.rd-top, .rd-bottom { transition: opacity var(--t-base) var(--ease), transform var(--t-base) var(--ease); position: relative; z-index: 4; }
.rd.chrome-off .rd-top { opacity: 0; transform: translateY(-8px); pointer-events: none; }
.rd.chrome-off .rd-bottom { opacity: 0; transform: translateY(8px); pointer-events: none; }
.rd-stage { flex: 1; min-height: 0; display: flex; justify-content: center; position: relative; padding: 4px 12px 0; }
.rd-spread { display: flex; width: 100%; max-width: 980px; height: 100%; gap: 0; }
.rd-spread.two { box-shadow: 0 30px 70px rgba(0,0,0,.7), 0 0 80px rgba(214,150,70,.14); border-radius: 4px; overflow: hidden; }
.rd-page { flex: 1; min-width: 0; border-radius: 6px; padding: 30px 28px 22px; overflow-y: auto; overflow-x: hidden; position: relative; scrollbar-width: none; }
.rd-page::-webkit-scrollbar { display: none; }
.rd-spread.two .rd-page { border-radius: 0; }
.rd-spread.two .rd-page:first-child { box-shadow: inset -40px 0 50px -30px rgba(90,50,20,.5), inset 0 0 50px rgba(122,76,30,.3); }
.rd-spread.two .rd-page:last-child { box-shadow: inset 40px 0 50px -30px rgba(90,50,20,.5), inset 0 0 50px rgba(122,76,30,.3); }
.rd-gutter { width: 2px; background: linear-gradient(90deg, rgba(60,30,10,.5), rgba(255,240,210,.3)); flex: none; }
.rd-page.dark { background: #15100d; color: #e6d8c1; box-shadow: inset 0 0 60px rgba(0,0,0,.5); }
.rd-page.dark::before { display: none; }
.rd-text { font-size: calc(17px * var(--zoom, 1)); }
.rd-spread.two.narrow .rd-text { font-size: calc(12.5px * var(--zoom, 1)); }
.rd-spread.two.narrow .rd-page { padding: 20px 14px 36px; }
.rd-p { font-family: var(--f-reading); font-size: 1em; line-height: 1.62; color: var(--sepia-900); text-align: justify; hyphens: auto; -webkit-hyphens: auto; margin-top: .5em; text-indent: 1.4em; user-select: text; -webkit-user-select: text; }
.rd-p.first { text-indent: 0; margin-top: .85em; }
.rd-p.first::first-letter { font-family: var(--f-display); font-size: 2.5em; float: left; line-height: .9; margin: .1em .18em 0 0; color: var(--crimson-500); }
.dark .rd-p { color: #e6d8c1; }
.dark .rd-p.first::first-letter { color: var(--gold-400); }
.rd-label { text-align: center; font-family: var(--f-display); font-size: 11px; letter-spacing: .3em; color: var(--sepia-500); text-transform: uppercase; }
.rd-title { text-align: center; font-family: var(--f-display); font-size: 1.42em; line-height: 1.15; color: var(--sepia-900); margin-top: 8px; }
.dark .rd-title { color: var(--gold-300); }
.dark .rd-label { color: var(--gold-600); }
.rd-img { height: 180px; margin: 12px auto 8px; width: min(230px, 100%); background-position: center; background-size: cover; mix-blend-mode: multiply; border-radius: 4px; mask-image: radial-gradient(closest-side,#000 55%,transparent 100%); -webkit-mask-image: radial-gradient(closest-side,#000 55%,transparent 100%); }
.dark .rd-img { mix-blend-mode: normal; opacity: .75; }
.rd-quote { text-align: center; font-family: var(--f-editorial); font-style: italic; font-size: 1em; color: var(--sepia-700); line-height: 1.4; }
.dark .rd-quote { color: var(--text-2); }
.rd-num { margin-top: 18px; text-align: center; font-family: var(--f-reading); font-size: 13px; color: var(--sepia-500); font-variant-numeric: lining-nums; pointer-events: none; }
.rd-ribbon { position: absolute; top: 0; right: 22px; width: 22px; height: 34px; color: var(--crimson-500); fill: var(--crimson-500); stroke: none; z-index: 2; }
.rd-edge { position: absolute; top: 0; bottom: 0; width: 18%; z-index: 3; }
.rd-edge.l { left: 0; } .rd-edge.r { right: 0; }
.rd-cont { flex: 1; min-height: 0; overflow-y: auto; padding: 10px 30px 60px; position: relative; }
.rd-cont .rd-page { overflow: visible; margin: 0 auto 18px; max-width: 680px; min-height: 0; }
.rd-cont.dark-flow .rd-page { background: transparent; box-shadow: none; padding: 10px 0 30px; border-bottom: 1px solid var(--gold-line-soft); border-radius: 0; }
.rd-rail { position: absolute; right: 6px; top: 70px; bottom: 150px; width: 2px; background: rgba(199,154,75,.15); border-radius: 2px; z-index: 5; pointer-events: none; }
.rd-rail i { position: absolute; left: 0; right: 0; background: var(--gold-500); border-radius: 2px; }
/* Original PDF pages, shown as-is (2:3 page, fitted to the stage, scaled by zoom) */
.rd-page.pdf { padding: 0; background: transparent; box-shadow: none; container-type: size; overflow: auto; border-radius: 0; }
.rd-page.pdf::before { display: none; }
.rd-pdf-frame { position: relative; aspect-ratio: 2 / 3; width: calc(min(100cqw, 100cqh * 2 / 3) * var(--zoom, 1)); margin: 0 auto; border-radius: 3px; overflow: hidden;
  background: linear-gradient(180deg, #e9d9b8, #d9c39a); box-shadow: 0 18px 50px rgba(0,0,0,.6), 0 0 60px rgba(214,150,70,.10); }
.rd-pdf { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.rd-pdf-frame .rd-ribbon { right: 9%; }
.rd-page.pdf.theme-sepia .rd-pdf { filter: sepia(.32) saturate(1.08) brightness(.96); }
.rd-page.pdf.theme-dark .rd-pdf { filter: brightness(.7) contrast(1.06); }
.rd-page.pdf.theme-dark .rd-pdf-frame { background: #2a211b; }
.rd-spread.pdf { box-shadow: none; border-radius: 0; overflow: visible; max-width: none; }
.rd-spread.two.pdf .rd-page { box-shadow: none; }
.rd-spread.two.pdf .rd-gutter { display: none; }
.rd-spread.two.pdf .rd-page:first-child .rd-pdf-frame { margin-right: 0; border-radius: 3px 0 0 3px; box-shadow: -14px 18px 50px rgba(0,0,0,.55), inset -18px 0 24px -16px rgba(60,30,10,.55); }
.rd-spread.two.pdf .rd-page:last-child .rd-pdf-frame { margin-left: 0; border-radius: 0 3px 3px 0; box-shadow: 14px 18px 50px rgba(0,0,0,.55); }
.rd-spread.two.pdf .rd-page:last-child .rd-pdf-frame::after { content: ''; position: absolute; inset: 0 auto 0 0; width: 22px; background: linear-gradient(90deg, rgba(60,30,10,.35), transparent); pointer-events: none; }
.rd-cont .rd-page.pdf, .rd-cont.dark-flow .rd-page.pdf { container-type: normal; max-width: none; margin: 0 auto 16px; padding: 0; border: 0; overflow: visible; }
.rd-cont .rd-pdf-frame { width: calc(min(100%, 680px) * var(--zoom, 1)); }
mark.hl { color: inherit; padding: 1px 0; border-radius: 2px; }
mark.hl.gold { background: rgba(199,154,75,.3); box-shadow: 0 2px 0 var(--gold-500); }
mark.hl.crimson { background: rgba(155,38,50,.22); box-shadow: 0 2px 0 var(--crimson-500); }
mark.hl.parchment { background: rgba(200,169,115,.35); box-shadow: 0 2px 0 var(--parch-400); }
mark.hl.has-note { cursor: pointer; }
.sel-bar { position: absolute; z-index: 30; display: flex; align-items: center; gap: 4px; padding: 6px; border-radius: 14px; background: #231312; border: 1px solid var(--gold-line); box-shadow: var(--shadow-card); animation: viewIn var(--t-fast) var(--ease) both; }
.sel-bar .dot { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; }
.sel-bar .dot i { width: 22px; height: 22px; border-radius: 50%; display: block; }
.sel-bar .sep { width: 1px; height: 26px; background: var(--gold-line); margin: 0 4px; }
input[type=range].scrub { -webkit-appearance: none; appearance: none; flex: 1; height: 24px; background: transparent; cursor: pointer; }
input[type=range].scrub::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, var(--gold-400) 0 var(--fill, 0%), rgba(199,154,75,.25) var(--fill, 0%) 100%); }
input[type=range].scrub::-moz-range-track { height: 4px; border-radius: 4px; background: rgba(199,154,75,.25); }
input[type=range].scrub::-moz-range-progress { height: 4px; border-radius: 4px; background: var(--gold-400); }
input[type=range].scrub::-webkit-slider-thumb { -webkit-appearance: none; width: 20px; height: 20px; margin-top: -8px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f7e2b0, #c79a4b); box-shadow: 0 0 0 4px rgba(199,154,75,.18), 0 2px 6px rgba(0,0,0,.5); border: 0; }
input[type=range].scrub::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #f7e2b0, #c79a4b); border: 0; }
.opt-card { height: 78px; display: grid; place-items: center; align-content: center; gap: 4px; }
.opt-card.on { border-color: var(--gold-400) !important; background: rgba(199,154,75,.14) !important; }
.swatch { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; border: 1px solid var(--gold-line); margin: 0 auto; }
.swatch.on { border: 2px solid var(--gold-400); box-shadow: 0 0 0 3px rgba(214,176,106,.25); }

/* ---------------- Journey ---------------- */
button.day-dot { background: none; cursor: pointer; }
button.day-dot.done { background: linear-gradient(180deg, #e6c887, #a67b35); }
button.day-dot[disabled] { cursor: default; }
.wheel { height: 212px; overflow-y: auto; scroll-snap-type: y mandatory; scrollbar-width: none; text-align: center; font-family: var(--f-editorial); font-variant-numeric: lining-nums; position: relative; }
.wheel::-webkit-scrollbar { display: none; }
.wheel .pad-cell { height: 80px; }
.wheel button { display: block; width: 100%; height: 52px; scroll-snap-align: center; font-size: 20px; color: var(--text-3); opacity: .6; transition: all var(--t-fast) var(--ease); font-family: var(--f-editorial); }
.wheel button.on { font-size: 30px; color: var(--gold-200); opacity: 1; }
.step-row { width: 100%; text-align: left; display: flex; gap: 14px; align-items: center; padding: 12px 0; border-bottom: 1px solid rgba(77,51,33,.2); color: inherit; font: inherit; background: none; }
.step-row .t { font-family: var(--f-display); font-size: 13px; letter-spacing: .12em; text-transform: uppercase; }
.step-row .s { font-size: 12.5px; color: var(--sepia-500); }
.step-body { font-family: var(--f-reading); font-size: 16.5px; line-height: 1.55; margin: 4px 0 14px 48px; }
.ph-box { border: 1px dashed rgba(122,90,60,.55); border-radius: 12px; padding: 12px 14px; background: rgba(122,90,60,.06); }
.parch-check { width: 22px; height: 22px; border-radius: 6px; flex: none; border: 1px solid var(--sepia-500); display: grid; place-items: center; color: #2b0f0a; cursor: pointer; background: none; }
.parch-check.on { background: linear-gradient(180deg, #e6c887, #a67b35); border: 0; }
.parch-area { width: 100%; min-height: 110px; background: rgba(255,250,235,.35); border: 1px solid rgba(122,90,60,.3); border-radius: 10px; padding: 10px 12px; color: var(--sepia-900); font-family: var(--f-editorial); font-size: 18px; line-height: 1.45; resize: vertical; outline: none; }
.parch-area:focus { border-color: var(--sepia-500); }

/* ---------------- Console ---------------- */
.console-grid { display: flex; flex: 1; min-height: 0; }
.console-grid > .side { width: 330px; padding: 22px 28px; border-right: 1px solid var(--gold-line-soft); overflow-y: auto; }
.console-grid > .main { flex: 1; padding: 22px 28px; overflow: auto; min-width: 0; }
@media (max-width: 820px) {
  .console-grid { flex-direction: column; overflow-y: auto; }
  .console-grid > .side { width: auto; border-right: 0; border-bottom: 1px solid var(--gold-line-soft); overflow: visible; }
  .console-grid > .main { overflow: visible; padding: 22px 20px; }
  .console-grid > .side { padding: 22px 20px; }
  .console-head { flex-wrap: wrap; gap: 12px; }
  .console-head .field { width: 100% !important; }
}
table.map td .btn-text { padding: 0 8px; }
