/* Libro — J Developments app design guide v1. Tokens only. */

@font-face { font-family: 'Outfit'; font-weight: 300; font-display: swap; src: url('../fonts/outfit-latin-ext-300-normal.woff2') format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Outfit'; font-weight: 300; font-display: swap; src: url('../fonts/outfit-latin-300-normal.woff2') format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'Outfit'; font-weight: 400; font-display: swap; src: url('../fonts/outfit-latin-ext-400-normal.woff2') format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'Outfit'; font-weight: 400; font-display: swap; src: url('../fonts/outfit-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }
@font-face { font-family: 'DM Sans'; font-weight: 400; font-display: swap; src: url('../fonts/dm-sans-latin-ext-400-normal.woff2') format('woff2'); unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF; }
@font-face { font-family: 'DM Sans'; font-weight: 400; font-display: swap; src: url('../fonts/dm-sans-latin-400-normal.woff2') format('woff2'); unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD; }

:root {
    --ground: #F2F4F1; --surface: #FFFFFF;
    --text: #14202B; --text-soft: #4B5A66;
    --primary: #1F4E79; --on-primary: #F2F4F1;
    --line: #A9C4D6; --tint: #E3ECF2;
    --good: #1E7A4C; --caution: #8A5300; --danger: #B3261E;
    --credit-j: #1F4E79; --credit-text: #4B5A66;
    --r-sm: 8px; --r-md: 12px; --r-lg: 16px;
    --side: 16px;
    --font-head: 'Outfit', 'Helvetica Neue', Arial, sans-serif;
    --font-body: 'DM Sans', 'Helvetica Neue', Arial, sans-serif;
    color-scheme: light;
}
:root[data-theme="dark"] {
    --ground: #0F1B26; --surface: #172733;
    --text: #F2F4F1; --text-soft: #A9C4D6;
    --primary: #8DB8DA; --on-primary: #0F1B26;
    --line: #2A3D4D; --tint: #1D3345;
    --good: #6CCB98; --caution: #F0B45A; --danger: #F28B82;
    --credit-j: #F2F4F1; --credit-text: #F2F4F1;
    color-scheme: dark;
}
@media (min-width: 720px) { :root { --side: 24px; } }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
    background: var(--ground); color: var(--text);
    font: 400 16px/1.4 var(--font-body);
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: none;
}
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { text-wrap: balance; }
p, li, .wrap { text-wrap: pretty; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.t-title { font: 300 28px/1.1 var(--font-head); }
.t-head { font: 400 18px/1.1 var(--font-head); }
.t-small { font-size: 14px; }
.t-cap { font-size: 12px; }
.soft { color: var(--text-soft); }
.num { font-variant-numeric: tabular-nums; }

/* Loading: a thin primary line at the top of the content */
.loading { position: fixed; inset: 0 0 auto 0; height: 4px; z-index: 50; overflow: hidden; background: var(--tint); }
.loading::after { content: ''; position: absolute; inset: 0 60% 0 0; background: var(--primary); animation: slide 1.4s linear infinite; }
.loading[data-fraction]::after { animation: none; inset: 0 auto 0 0; width: var(--fraction, 0%); }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(260%); } }
@media (prefers-reduced-motion: reduce) { .loading::after { animation: none; inset: 0; opacity: .5; } }

/* Screen */
.screen { max-width: 720px; margin: 0 auto; padding: 0 var(--side) 48px; min-height: 100%; }
.topbar { display: flex; align-items: center; gap: 8px; min-height: 48px; padding: 16px 0 16px; padding-top: calc(16px + env(safe-area-inset-top)); }
.topbar h1 { flex: 1; min-width: 0; }
.topbar .back { margin-left: -12px; }
.iconbtn { width: 48px; height: 48px; flex: none; display: grid; place-items: center; border: 0; background: none; border-radius: 50%; color: var(--primary); padding: 0; }
.iconbtn:active { background: var(--tint); }
.topbar .iconbtn:last-child { margin-right: -12px; }
.icon { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; display: block; }

/* Buttons */
.btn { display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; min-height: 48px; padding: 0 16px; border-radius: var(--r-md); border: 1px solid transparent; font: 400 16px/1.1 var(--font-body); text-decoration: none; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-secondary { background: transparent; border-color: var(--primary); color: var(--primary); }
.btn-text { background: transparent; color: var(--primary); }
.btn-danger { background: var(--danger); color: var(--surface); }
:root[data-theme="dark"] .btn-danger { color: var(--ground); }
.btn-text.danger { color: var(--danger); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.inline { width: auto; }
@media (min-width: 720px) { .btn { width: auto; min-width: 160px; } .stack .btn { align-self: flex-start; } }

.stack { display: flex; flex-direction: column; gap: 12px; }
.row-gap { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Cards and rows */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 16px; }
.card > .t-head { margin-bottom: 12px; }
.card.flush { padding: 0; overflow: hidden; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 8px 16px; position: relative; width: 100%; text-align: left; background: none; border: 0; color: inherit; text-decoration: none; }
.row + .row::before, li + li > .row::before { content: ''; position: absolute; top: 0; left: 16px; right: 0; height: 1px; background: var(--line); }
button.row:active, a.row:active { background: var(--tint); }
.row .grow { flex: 1; min-width: 0; }
.row .value { color: var(--text-soft); flex: none; max-width: 60%; text-align: right; overflow-wrap: anywhere; }
.clip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clip2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

/* Input */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; color: var(--text-soft); }
.input { width: 100%; height: 48px; padding: 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); outline: none; }
textarea.input { height: auto; min-height: 96px; padding: 12px; resize: vertical; line-height: 1.4; }
.input:focus { border-color: var(--primary); }
.input::placeholder { color: var(--text-soft); }
.search { position: relative; }
.search .icon { position: absolute; left: 12px; top: 12px; color: var(--text-soft); pointer-events: none; }
.search .input { padding-left: 48px; }

/* Chips */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; margin: 0 calc(-1 * var(--side)); padding: 0 var(--side); scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 12px; border-radius: var(--r-sm); border: 0; background: var(--tint); color: var(--text); font-size: 14px; position: relative; white-space: nowrap; }
.chip::after { content: ''; position: absolute; inset: -8px 0; } /* 48px touch target */
.chip[aria-pressed="true"] { background: var(--primary); color: var(--on-primary); }

/* Switch */
.switch { appearance: none; -webkit-appearance: none; flex: none; width: 48px; height: 24px; margin: 12px 0; border-radius: 12px; background: var(--line); position: relative; cursor: pointer; }
.switch::after { content: ''; position: absolute; top: 4px; left: 4px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); transition: transform .15s; }
.switch:checked { background: var(--primary); }
.switch:checked::after { transform: translateX(24px); }

/* Status banner */
.banner { display: flex; gap: 12px; align-items: flex-start; padding: 12px 16px; background: var(--surface); border: 1px solid var(--caution); border-radius: var(--r-md); }
.banner .icon { color: var(--caution); flex: none; }
.banner.danger { border-color: var(--danger); } .banner.danger .icon { color: var(--danger); }
.banner.good { border-color: var(--good); } .banner.good .icon { color: var(--good); }
.banner .grow { flex: 1; min-width: 0; }
.banner .btn-text { width: auto; min-width: 0; min-height: 48px; margin: -12px -16px -12px 0; flex: none; }

/* Library */
.library-tools { display: flex; flex-direction: column; gap: 12px; margin-bottom: 24px; }
.group-title { margin: 24px 0 12px; color: var(--text-soft); }
.cover { flex: none; width: 48px; height: 72px; border-radius: var(--r-sm); background: var(--tint); border: 1px solid var(--line); object-fit: cover; display: grid; place-items: center; color: var(--text-soft); overflow: hidden; }
.cover.big { width: 120px; height: 180px; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover .icon { color: var(--line); }
.tag { display: inline-flex; align-items: center; gap: 4px; }
.tag .icon { width: 16px; height: 16px; }
.meter { height: 4px; border-radius: 4px; background: var(--tint); overflow: hidden; margin-top: 8px; max-width: 160px; }
.meter > i { display: block; height: 100%; background: var(--primary); }

.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 16px; padding: 48px 16px; }
.empty svg { width: 120px; height: 120px; fill: none; stroke: var(--line); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.empty p { max-width: 320px; color: var(--text-soft); }

/* Book details */
.book-head { display: flex; gap: 16px; margin-bottom: 24px; }
.book-head .grow { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.section { margin-top: 24px; }
.section > .t-cap { display: block; margin-bottom: 8px; color: var(--text-soft); }
.desc { color: var(--text-soft); white-space: pre-line; }

/* Welcome */
.welcome { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; gap: 24px; padding-top: 48px; }
.welcome .mark { width: 96px; height: 96px; fill: none; stroke: var(--primary); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; }
.welcome h1 { font: 300 56px/1.1 var(--font-head); }
.welcome .lead { max-width: 440px; }

/* Credit */
.credit { display: flex; align-items: center; justify-content: center; gap: 4px; margin-top: 48px; font-size: 12px; color: var(--credit-text); }
.credit svg { width: 16px; height: 16px; fill: none; stroke: var(--credit-j); stroke-width: 13; stroke-linecap: round; stroke-linejoin: round; }

/* Sheets, dialogs, snackbar */
.scrim { position: fixed; inset: 0; z-index: 30; background: color-mix(in srgb, var(--text) 40%, transparent); display: flex; align-items: flex-end; justify-content: center; }
:root[data-theme="dark"] .scrim { background: color-mix(in srgb, var(--ground) 70%, transparent); }
.scrim.center { align-items: center; padding: 24px; }
.sheet { width: 100%; max-width: 560px; max-height: 86dvh; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0; border-bottom: 0; padding: 24px; padding-bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 16px; }
.dialog { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; display: flex; flex-direction: column; gap: 16px; }
@media (min-width: 720px) { .scrim { align-items: center; padding: 24px; } .sheet { border-radius: var(--r-lg); border-bottom: 1px solid var(--line); } }
.actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.actions .btn { width: auto; min-width: 96px; }
.snack { position: fixed; z-index: 60; left: 16px; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 400px; padding: 12px 16px; border-radius: var(--r-md); background: var(--text); color: var(--ground); font-size: 14px; }

/* Reader */
.reader { position: fixed; inset: 0; background: var(--ground); display: flex; flex-direction: column; }
.reader foliate-view { flex: 1; min-height: 0; display: block; }
.reader-bar { position: absolute; left: 0; right: 0; z-index: 10; background: var(--surface); display: flex; align-items: center; gap: 8px; padding: 0 4px; }
.reader-bar.top { top: 0; border-bottom: 1px solid var(--line); padding-top: env(safe-area-inset-top); min-height: 56px; }
.reader-bar.top .t-head { flex: 1; min-width: 0; }
.reader-bar.bottom { bottom: 0; border-top: 1px solid var(--line); padding: 8px 16px calc(8px + env(safe-area-inset-bottom)); flex-direction: column; align-items: stretch; gap: 4px; }
.reader-bar .meta { display: flex; justify-content: space-between; gap: 16px; font-size: 12px; color: var(--text-soft); }
.reader-foot { position: absolute; left: 0; right: 0; bottom: env(safe-area-inset-bottom); height: 24px; display: flex; align-items: center; justify-content: center; font-size: 12px; color: var(--text-soft); pointer-events: none; }
.slider { -webkit-appearance: none; appearance: none; width: 100%; height: 48px; margin: 0; background: transparent; }
.slider::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: var(--line); }
.slider::-moz-range-track { height: 4px; border-radius: 4px; background: var(--line); }
.slider::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -10px; border-radius: 50%; background: var(--primary); border: 0; }
.slider::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: var(--primary); border: 0; }
.selbar { position: absolute; z-index: 12; left: 16px; right: 16px; bottom: calc(32px + env(safe-area-inset-bottom)); margin: 0 auto; max-width: 320px; display: flex; gap: 8px; padding: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
.selbar .btn { min-width: 0; flex: 1; }
.quote { border-left: 1px solid var(--line); padding-left: 12px; color: var(--text-soft); font-size: 14px; }
.stepper { display: flex; align-items: center; gap: 8px; }
.stepper .value { min-width: 48px; text-align: center; }
.stepper .iconbtn { border: 1px solid var(--primary); border-radius: var(--r-md); }
.toc { list-style: none; margin: 0; padding: 0; }
.toc .row { padding-right: 0; }
.setting { display: flex; flex-direction: column; gap: 8px; }
.setting > .t-cap { color: var(--text-soft); }
.note-item { display: flex; flex-direction: column; gap: 8px; align-items: stretch; padding: 12px 0; min-height: 56px; }
