/* Ruang Baca — mengikuti design guideline
   Warna: Canvas Light #F5F5F7, Deep Black #111111, Periwinkle #6B7FD7,
          Bright Yellow #FFE66D, Electric Blue #2563EB, abu watermark #96969B
   Huruf: sans-serif geometris (Inter / Helvetica Neue / Arial), judul tebal & rapat,
          italic untuk punchline / keterangan bawah. */
@font-face { font-family: 'Inter'; src: url('/fonts/inter-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-latin-400-italic.woff2') format('woff2'); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-latin-600-normal.woff2') format('woff2'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Inter'; src: url('/fonts/inter-latin-800-normal.woff2') format('woff2'); font-weight: 800; font-display: swap; }

:root {
  --paper: #F5F5F7;
  --card: #FFFFFF;
  --ink: #111111;
  --muted: #5F5F66;
  --soft: #96969B;
  --line: #E3E3E8;
  --blue: #2563EB;
  --peri: #6B7FD7;
  --yellow: #FFE66D;
  --dark: #111111;
  --ok: #1F7A4D;
  --warn: #8A6A00;
  --danger: #C62828;
  --radius: 14px;
  --sans: 'Inter', 'Helvetica Neue', Arial, system-ui, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--paper); color: var(--ink); font-family: var(--sans); font-size: 16px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
body { min-height: 100vh; min-height: 100dvh; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--blue); }
h1, h2, h3 { font-family: var(--sans); font-weight: 800; letter-spacing: -0.025em; line-height: 1.1; margin: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.hidden { display: none !important; }
em, .italic { font-style: italic; }
.star { display: inline-block; flex: none; }

/* highlight box */
.hl { display: inline; padding: 0 .18em; -webkit-box-decoration-break: clone; box-decoration-break: clone; font-style: normal; }
.hl-yellow { background: var(--yellow); color: var(--ink); }
.hl-peri { background: var(--peri); color: #fff; }
.hl-blue { background: var(--blue); color: #fff; }

/* boot */
.boot { min-height: 100dvh; display: grid; place-items: center; }
.mark { width: 40px; height: 40px; border-radius: 10px; background: var(--blue); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 15px; letter-spacing: -0.02em; flex: none; position: relative; }
.mark::after { content: ''; position: absolute; top: 6px; right: 6px; width: 6px; height: 6px; border-radius: 50%; background: var(--yellow); }
.boot .mark { animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .35; } }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1.5px solid transparent; border-radius: 10px; padding: 10px 18px; font-weight: 700; font-size: 0.9375rem; cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, opacity .15s, transform .1s; white-space: nowrap; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1d4fcc; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover:not(:disabled) { background: #1d4fcc; }
.btn-gold, .btn-yellow { background: var(--yellow); color: var(--ink); border-color: var(--ink); }
.btn-gold:hover:not(:disabled), .btn-yellow:hover:not(:disabled) { background: #ffdf3f; }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink); }
.btn-ghost:hover:not(:disabled) { border-color: var(--ink); }
.btn-text { background: none; border: none; padding: 6px 4px; color: var(--muted); cursor: pointer; font-size: .875rem; font-weight: 500; }
.btn-text:hover { color: var(--ink); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 13px; font-size: .8125rem; }

/* inputs */
.field { display: block; margin: 0 0 14px; }
.field span { display: block; font-size: .8125rem; font-weight: 600; color: var(--ink); margin-bottom: 6px; }
.input { width: 100%; padding: 13px 15px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; outline: none; font-size: 1rem; }
.input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.code-box { position: relative; height: 64px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; cursor: text; }
.code-box:focus-within { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.code-slots { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: clamp(10px, 4vw, 18px); pointer-events: none; }
.code-box .code-slot { display: block; margin: 0; width: 1.1em; text-align: center; font-size: 1.7rem; font-weight: 700; line-height: 1; color: #B9B9C0; font-variant-numeric: tabular-nums; transition: color .12s, transform .12s; }
.code-box .code-slot.filled { color: var(--ink); }
.code-box .code-slot.next { color: var(--blue); transform: scale(1.25); }
.code-input { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; outline: 0; background: transparent; color: transparent; caret-color: transparent; font-size: 16px; text-align: center; letter-spacing: 1em; -webkit-text-fill-color: transparent; }
.code-input::selection { background: transparent; color: transparent; }
.input.code { font-size: 1.6rem; font-weight: 700; letter-spacing: .5em; text-align: center; font-variant-numeric: tabular-nums; padding-left: calc(15px + .5em); }

/* login */
.login { min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) { .login { grid-template-columns: 1.05fr 1fr; } }
.login-art { display: none; background: var(--blue); color: #fff; padding: 52px 56px; position: relative; overflow: hidden; }
@media (min-width: 900px) { .login-art { display: flex; flex-direction: column; justify-content: center; padding-bottom: 180px; } }
.login-art .wm { font-size: .8125rem; font-weight: 600; color: rgba(255,255,255,.7); letter-spacing: .02em; }
.login-art .quote { font-size: clamp(2rem, 3.2vw, 3rem); font-weight: 800; line-height: 1.08; letter-spacing: -0.03em; max-width: 13ch; position: relative; z-index: 1; }
.login-art .quote em { font-style: normal; background: var(--yellow); color: var(--ink); padding: 0 .15em; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.login-art .punch { font-style: italic; color: rgba(255,255,255,.85); margin-top: 18px; font-size: 1.05rem; position: relative; z-index: 1; }
.login-art .stack { position: absolute; right: -30px; bottom: 120px; display: flex; gap: 14px; transform: rotate(-8deg); }
.login-art .stack i { display: block; width: 112px; height: 158px; border-radius: 4px 8px 8px 4px; box-shadow: 0 18px 40px rgba(0,0,0,.28); border: 2px solid var(--ink); }
.login-art .stack i:nth-child(1) { background: #fff; }
.login-art .stack i:nth-child(2) { background: var(--yellow); transform: translateY(-26px); }
.login-art .stack i:nth-child(3) { background: var(--peri); transform: translateY(10px); }
.login-art .s1 { position: absolute; top: 120px; right: 70px; }
.login-art .s2 { position: absolute; top: 96px; left: 60px; }
.login-art .s3 { position: absolute; bottom: 92px; left: 56px; opacity: .9; }
.login-art footer { font-size: .8125rem; color: rgba(255,255,255,.8); font-style: italic; position: absolute; left: 56px; bottom: 48px; z-index: 1; }
.login-main { display: grid; place-items: center; padding: calc(32px + var(--safe-top)) 22px calc(32px + var(--safe-bottom)); }
.login-card { width: 100%; max-width: 380px; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand .name { font-weight: 800; font-size: 1.0625rem; line-height: 1.05; letter-spacing: -0.02em; }
.brand .name small { display: block; font-weight: 500; font-size: .625rem; letter-spacing: .01em; color: var(--soft); margin-top: 2px; }
.login-card h1 { font-size: 2rem; margin: 34px 0 10px; }
.login-card p.lead { color: var(--muted); margin: 0 0 26px; }
.note { border-radius: 10px; padding: 12px 14px; font-size: .875rem; margin: 0 0 16px; }
.note-warn { background: #FFF6C9; color: #4A3D00; border: 1.5px solid var(--yellow); }
.note-err { background: #FDECEC; color: var(--danger); border: 1.5px solid #F6C7C7; }
.note-ok { background: #E7F5EE; color: var(--ok); border: 1.5px solid #BFE3D0; }
.device-pick { list-style: none; padding: 0; margin: 10px 0 0; display: grid; gap: 8px; }
.device-pick li { display: flex; align-items: center; justify-content: space-between; gap: 10px; background: #fff; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px; }

/* shell */
.top { position: sticky; top: 0; z-index: 10; background: rgba(245,245,247,.9); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); padding-top: var(--safe-top); }
.top-in { max-width: 1120px; margin: 0 auto; padding: 12px 22px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--ink); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: .875rem; border: none; cursor: pointer; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 28px 22px calc(60px + var(--safe-bottom)); }
.offline-bar { background: var(--yellow); color: var(--ink); font-size: .8125rem; font-weight: 600; text-align: center; padding: 8px 16px; }
.hello { margin: 6px 0 30px; }
.hello .eyebrow { display: inline-block; font-size: .75rem; letter-spacing: .06em; text-transform: uppercase; font-weight: 700; background: var(--peri); color: #fff; padding: 4px 10px; border-radius: 4px; }
.hello h1 { font-size: clamp(2rem, 4.4vw, 2.9rem); margin-top: 12px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.hello .punch { font-style: italic; color: var(--muted); margin-top: 8px; }
.section-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 34px 0 16px; padding-bottom: 10px; border-bottom: 2px solid var(--ink); }
.section-h h2 { font-size: 1.3rem; }
.section-h .small { font-style: italic; }

/* books */
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr)); gap: 18px; }
.book { display: grid; grid-template-columns: 112px 1fr; gap: 18px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(17,17,17,.04), 0 6px 18px -10px rgba(17,17,17,.18); }
.cover { position: relative; aspect-ratio: 1 / 1.414; border-radius: 3px 6px 6px 3px; overflow: hidden; background: #ddd; box-shadow: 0 10px 22px -10px rgba(17,17,17,.45); cursor: pointer; border: none; padding: 0; width: 100%; }
.cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover::after { content: ''; position: absolute; inset: 0 auto 0 0; width: 6px; background: linear-gradient(90deg, rgba(0,0,0,.18), rgba(255,255,255,.08), transparent); }
.cover .gen { position: absolute; inset: 0; padding: 12px 10px; display: flex; flex-direction: column; justify-content: space-between; color: #fff; font-weight: 800; font-size: .85rem; line-height: 1.1; text-align: left; }
.cover .gen small { font-size: .55rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--yellow); }
.book-info { display: flex; flex-direction: column; min-width: 0; }
.book-info h3 { font-size: 1.15rem; }
.book-info .sub { color: var(--muted); font-size: .875rem; margin-top: 5px; font-style: italic; line-height: 1.35; }
.book-info .meta { font-size: .75rem; color: var(--muted); margin-top: 9px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.price-wrap { display: inline-flex; align-items: center; gap: 6px; }
.price-old { color: var(--soft); font-size: .92em; }
.price-label { font-size: .75rem; color: var(--muted); font-style: italic; margin-top: 4px; }
.price { background: var(--yellow); color: var(--ink); font-weight: 700; padding: 1px 6px; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 4px; font-size: .72rem; font-weight: 600; }
.pill-ok { background: #E7F5EE; color: var(--ok); }
.pill-warn { background: #FFF6C9; color: var(--warn); }
.book-actions { margin-top: auto; padding-top: 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.progress { height: 5px; border-radius: 4px; background: var(--line); overflow: hidden; margin-top: 10px; }
.progress i { display: block; height: 100%; background: var(--blue); width: 0; transition: width .2s; }
.locked .cover img, .locked .cover .gen { filter: grayscale(.9) brightness(.9); }
.lock { position: absolute; inset: 0; display: grid; place-items: center; }
.lock span { width: 38px; height: 38px; border-radius: 50%; background: rgba(17,17,17,.85); display: grid; place-items: center; }
.empty { background: var(--card); border: 1.5px dashed var(--line); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); font-style: italic; }
.tip { margin-top: 28px; font-size: .8125rem; color: var(--muted); background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--blue); border-radius: 10px; padding: 14px 16px; }
.tip b { color: var(--ink); }

/* account */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; position: relative; }
.card h2 { font-size: 1.15rem; margin-bottom: 12px; padding-left: 12px; border-left: 4px solid var(--blue); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.row:first-of-type { border-top: none; }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(17,17,17,.55); display: grid; place-items: center; padding: 20px; z-index: 50; animation: fade .15s; }
.modal { background: var(--card); border-radius: 16px; padding: 24px; max-width: 400px; width: 100%; box-shadow: 0 30px 60px rgba(0,0,0,.3); border: 2px solid var(--ink); }
.modal h2 { font-size: 1.35rem; margin-bottom: 8px; }
.modal .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

/* toast */
#toast { position: fixed; left: 50%; bottom: calc(24px + var(--safe-bottom)); transform: translate(-50%, 20px); background: var(--ink); color: #fff; padding: 11px 18px; border-radius: 10px; font-size: .875rem; font-weight: 500; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 100; max-width: calc(100vw - 40px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* reader */
.reader { position: fixed; inset: 0; background: #1C1C20; display: flex; flex-direction: column; z-index: 20; }
.reader, .reader * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.r-top { flex: none; display: flex; align-items: center; gap: 10px; padding: calc(8px + var(--safe-top)) 12px 8px; background: var(--ink); color: #fff; border-bottom: 1px solid #2a2a2e; }
.r-top .t { flex: 1; min-width: 0; }
.r-top .t b { display: block; font-weight: 700; font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.r-top .t small { color: var(--soft); font-size: .75rem; font-style: italic; }
.icon-btn { width: 38px; height: 38px; border-radius: 10px; border: none; background: transparent; color: #fff; display: grid; place-items: center; cursor: pointer; flex: none; }
.icon-btn:hover { background: #26262b; }
.icon-btn:disabled { opacity: .35; }
.r-scroll { flex: 1; overflow: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.r-pages { --zoom: 1; width: calc(min(94vw, 820px) * var(--zoom)); margin: 0 auto; padding: 18px 0 calc(40px + var(--safe-bottom)); display: flex; flex-direction: column; gap: 14px; }
.r-page { position: relative; width: 100%; aspect-ratio: var(--ar, 0.707); background: #fff; box-shadow: 0 8px 30px rgba(0,0,0,.35); border-radius: 2px; overflow: hidden; }
.r-page canvas { width: 100%; height: 100%; display: block; pointer-events: none; }
.r-page .num { position: absolute; inset: 0; display: grid; place-items: center; color: var(--soft); font-size: .8125rem; }
.r-page.done .num { display: none; }
.r-page.err .num { color: var(--danger); padding: 20px; text-align: center; }
.r-foot { position: absolute; left: 50%; bottom: calc(14px + var(--safe-bottom)); transform: translateX(-50%); background: var(--yellow); color: var(--ink); font-weight: 700; font-size: .78rem; padding: 5px 12px; border-radius: 6px; font-variant-numeric: tabular-nums; pointer-events: none; }

@media print {
  body * { display: none !important; }
  body::after { content: 'Buku ini hanya bisa dibaca di Ruang Baca dan tidak bisa dicetak.'; display: block; padding: 40px; font: 16px sans-serif; }
}
