/* ===== Tokens ===== */
:root {
  --bg: #F7F4EC;
  --navy: #1B2F4F;
  --navy-deep: #13223B;
  --gold: #A8782C;
  --gold-soft: #D5BA7E;
  --beige: #EFE4CE;
  --line: #E8E1D0;
  --muted: #6B7280;
  --chap-read: #E6ECF2;
  --danger: #B3261E;
  --shadow: 0 1px 2px rgba(60, 64, 67, .06), 0 6px 18px rgba(60, 64, 67, .08);
  --shadow-sm: 0 1px 2px rgba(60, 64, 67, .07), 0 3px 8px rgba(60, 64, 67, .06);
  --ease: cubic-bezier(.22, .8, .3, 1);
  --serif: 'Lora', Georgia, 'Times New Roman', serif;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --nav-h: 66px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--navy);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, p { margin: 0; }
.serif { font-family: var(--serif); font-weight: 500; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.ic { width: 1.25em; height: 1.25em; flex: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }

.boot { height: 100dvh; }

/* ===== Layout ===== */
.shell {
  max-width: 560px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 20px) 20px calc(var(--nav-h) + env(safe-area-inset-bottom) + 32px);
}
.shell.enter { animation: viewIn .45s var(--ease) both; }
@keyframes viewIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; }
.gold { color: var(--gold); }

.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.sec-title { font-family: var(--serif); font-weight: 500; font-size: clamp(22px, 6vw, 26px); color: var(--navy); }
.sec-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 28px 0 14px; }
.sec-head .sec-title { margin: 0; }

/* ===== Capa do livro (CSS puro) ===== */
.cover {
  --w: 88px;
  width: var(--w);
  aspect-ratio: 5 / 7;
  background: linear-gradient(160deg, #0B1B3D, #06122C);
  border-radius: 3px 6px 6px 3px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, .35), inset 2px 0 0 rgba(255, 255, 255, .06);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--gold-soft);
  font-family: var(--serif);
  text-align: center;
  line-height: 1.12;
  flex: none;
  position: relative;
}
.cover::before, .cover::after {
  content: ''; position: absolute; left: 22%; right: 22%; height: 1px; background: var(--gold-soft); opacity: .8;
}
.cover::before { top: 20%; }
.cover::after { bottom: 20%; }
.cover span { font-size: calc(var(--w) * .1); font-weight: 400; }
.cover b { font-size: calc(var(--w) * .135); font-weight: 500; letter-spacing: .02em; }
.cover.sm { --w: 70px; box-shadow: var(--shadow-sm); }

/* ===== Botões ===== */
.btn {
  width: 100%; min-height: 54px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  font-weight: 600; font-size: 15.5px;
  transition: transform .18s var(--ease), box-shadow .2s, filter .2s, background .2s;
}
.btn:active { transform: scale(.98); }
.btn-gold { background: var(--gold-soft); color: var(--navy); box-shadow: 0 4px 14px rgba(0, 0, 0, .18); }
.btn-gold:hover { filter: brightness(1.04); }
.btn-navy { background: var(--navy); color: #fff; box-shadow: var(--shadow-sm); }
.btn-ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.btn-danger { background: #fff; color: var(--danger); border: 1px solid #efc9c6; }
.btn[disabled] { opacity: .6; pointer-events: none; }

/* ===== Início: herói ===== */
.hero {
  background: linear-gradient(165deg, #203559 0%, var(--navy) 55%, var(--navy-deep) 100%);
  color: #fff;
  border-radius: 28px;
  padding: 16px 16px 16px;
  box-shadow: 0 14px 30px rgba(27, 47, 79, .28), 0 2px 6px rgba(27, 47, 79, .2);
}
.hero-top { display: flex; gap: 16px; align-items: center; padding: 0 2px; }
.hero .cover { --w: clamp(78px, 24vw, 100px); }
.hero-info { min-width: 0; }
.hero .eyebrow { display: flex; align-items: center; gap: 7px; font-size: 10px; margin-bottom: 8px; }
.dot { width: 5px; height: 5px; border-radius: 50%; background: var(--gold-soft); display: inline-block; flex: none; }
.hero .eyebrow { color: var(--gold-soft); }
.hero-title { font-family: var(--serif); font-weight: 400; font-size: clamp(30px, 9vw, 38px); line-height: 1.1; }
.hero-chap { font-size: clamp(16px, 4.6vw, 18px); margin-top: 8px; }
.hero-sub { font-size: 12px; color: rgba(255, 255, 255, .6); margin-top: 8px; }
.hero-prog { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 2px 8px; font-size: 12.5px; color: rgba(255, 255, 255, .75); }
.hero-prog b { color: var(--gold-soft); font-weight: 600; }
.hero .btn { margin-top: 20px; }
.hero-done { text-align: center; padding: 14px 6px 8px; }
.hero-done h1 { font-family: var(--serif); font-weight: 400; font-size: 28px; margin: 10px 0 8px; }
.hero-done p { color: rgba(255, 255, 255, .75); font-size: 14px; }

/* ===== Barras de progresso ===== */
.bar { height: 6px; border-radius: 99px; background: #E6E1D5; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; border-radius: 99px; background: var(--gold); transition: width 1s var(--ease); }
.bar-dark { background: rgba(255, 255, 255, .2); }
.bar-dark > i { background: var(--gold-soft); }

.overall { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 24px 4px 0; }
.overall b { font-size: 14px; font-weight: 600; display: block; }
.overall .pct { font-family: var(--serif); font-size: 34px; color: var(--gold); line-height: 1; }
.overall + .bar { margin: 12px 4px 0; }

/* ===== Próximas leituras ===== */
.next-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.next-card {
  text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 12px 14px; box-shadow: var(--shadow-sm); min-height: 116px;
  display: flex; flex-direction: column; gap: 4px; color: var(--navy);
  transition: transform .2s var(--ease), box-shadow .2s;
}
.next-card:active { transform: scale(.97); }
.next-card:hover { box-shadow: var(--shadow); }
.next-card .nc-top { display: flex; justify-content: space-between; align-items: center; font-size: 12px; color: var(--muted); }
.next-card .nc-top .ic { width: 14px; height: 14px; }
.next-card b { font-family: var(--serif); font-weight: 500; font-size: 34px; line-height: 1.15; margin-top: 4px; }
.next-card em { font-style: normal; font-size: 11px; color: var(--muted); margin-top: auto; }
.next-card.first { background: var(--beige); border-color: #D9C79F; }
.next-card.first .nc-top { color: #7a5c28; }
.next-card.first .nc-top .ic { color: var(--gold); }
.next-card.first em { color: var(--gold); font-weight: 600; }

/* ===== Biblioteca ===== */
.lib-sub { margin: -8px 0 16px; font-size: 13px; color: var(--muted); }
.lib-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.tile {
  --h: 62px;
  position: relative; display: block; height: var(--h);
  border-radius: 14px; border: 1px solid var(--line); background: #fff;
  box-shadow: var(--shadow-sm); overflow: hidden;
  font-family: var(--serif); font-weight: 600; font-size: clamp(11.5px, 3.3vw, 14px); line-height: 1.1;
  color: var(--navy);
  transition: transform .2s var(--ease), box-shadow .2s, background .5s;
}
.tile:hover { box-shadow: var(--shadow); }
.tile:active { transform: scale(.95); }
.tile.started { background: var(--beige); border-color: #DDCDA6; }
.tile .lbl { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 0 3px; }
.tile .fill {
  position: absolute; left: 0; right: 0; bottom: 0; height: 0;
  background: var(--navy); overflow: hidden; transition: height 1s var(--ease);
}
.tile .fill .lbl { inset: auto 0 0 0; height: calc(var(--h) - 2px); color: #fff; }
.quote { text-align: center; font-family: var(--serif); font-style: italic; font-size: 13.5px; color: var(--muted); margin: 28px 0 0; }

/* ===== Barra inferior ===== */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: rgba(255, 255, 255, .94); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-inner { max-width: 560px; margin: 0 auto; height: var(--nav-h); display: grid; grid-template-columns: repeat(3, 1fr); }
.nav a { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 11px; color: var(--muted); transition: color .25s; }
.nav a .ic { width: 24px; height: 24px; transition: transform .25s var(--ease); }
.nav a.active { color: var(--gold); font-weight: 600; }
.nav a.active .ic { transform: translateY(-1px) scale(1.06); }

/* ===== Jornada (livro) ===== */
.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; }
.back { display: inline-flex; align-items: center; gap: 10px; font-size: 14.5px; padding: 6px 0; }
.back .ic { width: 20px; height: 20px; }
.topbar .eyebrow { font-size: 13px; letter-spacing: .1em; }
.book-head { display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: start; }
.book-head h1 { font-family: var(--serif); font-weight: 400; font-size: clamp(32px, 10vw, 42px); line-height: 1.1; margin: 4px 0 8px; }
.book-head .eyebrow { font-size: 10.5px; margin-top: 2px; }
.btn-mark {
  display: inline-flex; align-items: center; gap: 8px; height: 40px; padding: 0 16px; border-radius: 12px;
  background: var(--navy); color: #fff; font-weight: 600; font-size: 14px; box-shadow: var(--shadow-sm);
  transition: transform .18s var(--ease), background .3s, color .3s;
}
.btn-mark:active { transform: scale(.96); }
.btn-mark .ic { width: 18px; height: 18px; }
.btn-mark.done { background: #fff; color: var(--gold); border: 1px solid #D9C79F; }

.progress-card { margin-top: 24px; padding: 16px 18px 18px; border-radius: 20px; }
.pc-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.pc-row b { font-size: 13.5px; font-weight: 600; display: block; }
.pc-row .pct { font-family: var(--serif); font-size: 36px; color: var(--gold); line-height: 1; }

.chap-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.chap {
  height: 56px; border-radius: 12px; border: 1px solid var(--line); background: #fff; color: var(--muted);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 16px; font-weight: 500;
  transition: background .35s, color .35s, border-color .35s, transform .2s var(--ease);
}
.chap .ic { width: 12px; height: 12px; stroke-width: 2.4; }
.chap.read { background: var(--chap-read); border-color: transparent; color: var(--navy); box-shadow: none; }
.chap.current { background: var(--navy); border-color: var(--navy); color: #fff; box-shadow: 0 6px 14px rgba(27, 47, 79, .3); }
.chap .ul { width: 14px; height: 2px; border-radius: 2px; background: var(--gold-soft); }
.chap:active { transform: scale(.93); }
.chap.pop { animation: pop .35s var(--ease); }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(.86); } 100% { transform: scale(1); } }

/* ===== Perfil ===== */
.page-title { font-family: var(--serif); font-weight: 400; font-size: clamp(36px, 11vw, 46px); line-height: 1.1; }
.page-sub { color: var(--muted); font-size: 14px; margin: 6px 0 20px; }
.profile-card { padding: 18px 18px 14px; }
.pf-top { display: flex; align-items: center; gap: 16px; }
.avatar {
  width: 64px; height: 64px; border-radius: 50%; background: var(--beige); border: 1px solid #D9C79F;
  display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 24px; flex: none;
}
.pf-top h2 { font-family: var(--serif); font-weight: 500; font-size: 24px; line-height: 1.15; overflow-wrap: anywhere; }
.pf-top p { font-size: 13px; color: var(--muted); margin-top: 6px; overflow-wrap: anywhere; }
.pf-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; font-size: 11px; color: var(--muted); }
.link-gold { display: inline-flex; align-items: center; gap: 7px; color: var(--gold); font-weight: 600; font-size: 13.5px; padding: 4px 0; }
.link-gold .ic { width: 16px; height: 16px; }

.journey-card { padding: 16px 18px 14px; }
.journey-card .pc-row { margin-bottom: 10px; }
.journey-card .pct { font-size: 38px; }
.jc-foot { display: flex; justify-content: space-between; align-items: center; border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; font-size: 13.5px; }
.jc-foot span { display: inline-flex; align-items: center; gap: 10px; }
.jc-foot .ic { color: var(--gold); }
.jc-foot em { font-style: normal; color: var(--muted); font-size: 13px; text-align: right; }

.prefs { padding: 4px 18px; }
.pref {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; padding: 15px 0;
  border-bottom: 1px solid var(--line);
}
.pref:last-child { border-bottom: 0; }
.pref > .ic:first-child { color: var(--gold); width: 22px; height: 22px; }
.pref .pt { flex: 1; min-width: 0; }
.pref .pt b { display: block; font-size: 14.5px; font-weight: 600; }
.pref .pt small { display: block; color: var(--muted); font-size: 12.5px; margin-top: 3px; }
.pref > .chev { color: var(--muted); width: 18px; height: 18px; }
.soon { font-size: 10px; font-weight: 600; letter-spacing: .04em; color: var(--gold); background: var(--beige); border-radius: 99px; padding: 2px 8px; margin-left: 6px; vertical-align: 1px; text-transform: uppercase; }

.switch { position: relative; width: 50px; height: 30px; border-radius: 99px; background: #D6D2C6; flex: none; transition: background .3s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform .3s var(--ease); }
.switch.on { background: var(--gold); }
.switch.on::after { transform: translateX(20px); }

.extra-actions { display: grid; gap: 10px; margin-top: 24px; }
.extra-actions .btn { min-height: 48px; font-size: 14.5px; }
.link-danger { display: block; margin: 18px auto 0; color: var(--muted); font-size: 12.5px; text-decoration: underline; text-underline-offset: 3px; }

/* ===== Sheet (painel inferior) ===== */
.backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(19, 34, 59, 0); display: flex; align-items: flex-end; justify-content: center;
  transition: background .3s; pointer-events: none;
}
.backdrop.open { background: rgba(19, 34, 59, .45); pointer-events: auto; }
.sheet {
  width: 100%; max-width: 560px; background: var(--bg); border-radius: 26px 26px 0 0;
  padding: 10px 22px calc(env(safe-area-inset-bottom) + 24px);
  transform: translateY(100%); transition: transform .4s var(--ease);
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .18);
}
.backdrop.open .sheet { transform: none; }
.grab { width: 40px; height: 4px; border-radius: 4px; background: #D6D0C0; margin: 0 auto 18px; }
.sheet .eyebrow { margin-bottom: 6px; }
.sheet h3 { font-family: var(--serif); font-weight: 500; font-size: 26px; margin-bottom: 6px; }
.sheet .desc { color: var(--muted); font-size: 14px; margin-bottom: 18px; }
.sheet .stack { display: grid; gap: 10px; margin-top: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 6px 0 4px; }
.chip { min-width: 64px; height: 48px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-weight: 600; box-shadow: var(--shadow-sm); transition: all .2s; }
.chip.on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ===== Formulários ===== */
.field { display: block; margin-bottom: 12px; }
.field span { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; color: var(--navy); }
.input {
  width: 100%; height: 52px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line); background: #fff; font-size: 16px;
  transition: border-color .2s, box-shadow .2s;
}
.input:focus { outline: 0; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(168, 120, 44, .18); }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; margin: 2px 0 10px; }

/* ===== Toast ===== */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px); z-index: 80;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--navy); color: #fff; font-size: 13.5px; padding: 11px 18px; border-radius: 99px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25); max-width: calc(100vw - 40px); text-align: center;
  transition: opacity .3s, transform .35s var(--ease);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ===== Login ===== */
.login {
  min-height: 100dvh; position: relative; overflow: hidden; color: #fff;
  background: linear-gradient(180deg, #00A5CB 0%, #0086AE 14%, #006A92 40%, #005F86 100%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: calc(env(safe-area-inset-top) + 28px) 20px calc(env(safe-area-inset-bottom) + 28px);
}
.login::before, .login::after { content: ''; position: absolute; pointer-events: none; background: rgba(255, 255, 255, .05); }
.login::before { inset: -10% -20% auto -20%; height: 42%; clip-path: polygon(0 40%, 100% 0, 100% 70%, 0 100%); }
.login::after { inset: 0 -30% auto 10%; height: 38%; clip-path: polygon(0 100%, 100% 0, 100% 100%); background: rgba(255, 255, 255, .04); }
.login > * { position: relative; z-index: 1; }
.login-logo { width: min(44vw, 168px); height: auto; display: block; margin-bottom: 8px; animation: viewIn .7s var(--ease) both; }
.logo-fallback {
  width: min(40vw, 150px); aspect-ratio: 3 / 4; border: 2px solid #fff; border-radius: 999px 999px 4px 4px;
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 14px;
  font-family: var(--serif); font-size: 17px; line-height: 1.2; margin-bottom: 8px;
}
.login-tag { font-size: 13.5px; color: rgba(255, 255, 255, .85); margin: 6px 0 22px; text-align: center; }
.auth-card {
  width: 100%; max-width: 400px; background: #fff; color: var(--navy); border-radius: 24px; padding: 20px;
  box-shadow: 0 24px 60px rgba(0, 35, 55, .4); animation: viewIn .6s .1s var(--ease) both;
}
.seg { display: grid; grid-template-columns: 1fr 1fr; background: #F1EDE2; border-radius: 12px; padding: 4px; margin-bottom: 18px; position: relative; }
.seg button { height: 40px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--muted); position: relative; z-index: 1; transition: color .25s; }
.seg button.on { color: var(--navy); }
.seg .thumb { position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); background: #fff; border-radius: 9px; box-shadow: var(--shadow-sm); transition: transform .35s var(--ease); }
.seg.reg .thumb { transform: translateX(100%); }
.login-foot { font-size: 12px; color: rgba(255, 255, 255, .75); text-align: center; margin-top: 18px; max-width: 340px; }

.spin { width: 18px; height: 18px; border-radius: 50%; border: 2.5px solid rgba(27, 47, 79, .25); border-top-color: var(--navy); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Telas maiores ===== */
@media (min-width: 560px) {
  body { font-size: 16px; }
  .shell { padding-left: 28px; padding-right: 28px; padding-top: calc(env(safe-area-inset-top) + 36px); }
  .chap-grid { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); }
  .tile { --h: 66px; }
  .sheet { border-radius: 26px; margin-bottom: 24px; }
}

@media (max-width: 340px) {
  .shell { padding-left: 14px; padding-right: 14px; }
  .lib-grid, .chap-grid, .next-grid { gap: 7px; }
  .next-card b { font-size: 28px; }
  .book-head { grid-template-columns: auto 1fr; }
  .book-head .btn-mark { grid-column: 1 / -1; justify-self: start; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
