@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Literata:opsz,wght@7..72,500;7..72,600;7..72,700&display=swap');

:root {
  --paper: #f4ebdd;
  --paper-deep: #eadfce;
  --paper-light: #fbf7f0;
  --ink: #24332d;
  --ink-muted: #69746d;
  --sage: #607466;
  --sage-dark: #3d5749;
  --sage-soft: #dce5db;
  --coral: #c96e52;
  --amber: #d8a352;
  --line: rgba(71, 83, 72, 0.16);
  --shadow: 0 24px 60px rgba(76, 66, 47, 0.11);
  --display: 'Literata', Georgia, serif;
  --sans: 'DM Sans', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { min-width: 320px; scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); font-family: var(--sans); }
button, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 3px solid rgba(201, 110, 82, 0.42); outline-offset: 3px; }
[hidden] { display: none !important; }

.page-noise { position: fixed; inset: 0; pointer-events: none; opacity: .035; z-index: 0; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.7'/%3E%3C/svg%3E"); }
.app-shell { position: relative; z-index: 1; width: min(1240px, calc(100% - 48px)); margin: 0 auto; }
.topbar { display: flex; align-items: center; justify-content: space-between; height: 90px; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; color: var(--paper-light); background: var(--sage); border-radius: 10px 10px 10px 3px; transform: rotate(-3deg); box-shadow: 4px 4px 0 var(--paper-deep); }
.brand-mark svg { width: 18px; height: 18px; transform: rotate(3deg); stroke-width: 1.8; }
.brand-wordmark { letter-spacing: -.08em; font-size: 24px; line-height: 1; font-weight: 700; }
.brand-wordmark span { color: var(--coral); }
.topbar-meta { display: flex; align-items: center; gap: 18px; color: var(--ink-muted); font-size: 12px; }
.privacy-note { display: inline-flex; align-items: center; gap: 6px; }
.privacy-note svg { width: 14px; color: var(--sage); }
.status-pill { display: inline-flex; align-items: center; gap: 7px; color: var(--sage-dark); background: rgba(220, 229, 219, .7); padding: 8px 11px; border-radius: 999px; font-weight: 600; }
.status-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--sage); box-shadow: 0 0 0 3px rgba(96, 116, 102, .14); }
.settings-button { display: grid; place-items: center; width: 35px; height: 35px; border: 1px solid var(--line); border-radius: 50%; color: var(--sage-dark); background: rgba(251, 247, 240, .35); }
.settings-button:hover { color: var(--coral); border-color: rgba(201, 110, 82, .35); background: var(--paper-light); }
.settings-button svg { width: 16px; height: 16px; }

.hero-section { display: flex; align-items: flex-end; justify-content: space-between; padding: 86px 5.7% 74px; }
.hero-copy { max-width: 680px; }
.eyebrow, .section-kicker { color: var(--coral); font-size: 11px; font-weight: 700; letter-spacing: .15em; text-transform: uppercase; }
.eyebrow { display: flex; align-items: center; gap: 10px; margin: 0 0 24px; }
.eyebrow-line { display: block; width: 28px; height: 2px; background: var(--coral); }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 20px; font-family: var(--display); font-size: clamp(48px, 7vw, 83px); font-weight: 600; letter-spacing: -.065em; line-height: .98; }
h1 em { color: var(--sage); font-weight: 500; font-style: italic; }
.hero-description { max-width: 460px; margin-bottom: 0; color: var(--ink-muted); font-size: 16px; line-height: 1.7; }
.hero-stamp { position: relative; display: grid; place-items: center; width: 130px; height: 130px; margin: 0 6% 8px 30px; color: var(--sage-dark); font-family: var(--display); font-size: 11px; letter-spacing: .04em; line-height: 1.35; text-align: center; text-transform: lowercase; transform: rotate(8deg); }
.stamp-ring { position: absolute; inset: 0; border: 1px dashed var(--sage); border-radius: 50%; opacity: .7; }
.stamp-ring::after { position: absolute; inset: 8px; border: 1px solid rgba(96, 116, 102, .3); border-radius: 50%; content: ''; }

.workspace { display: grid; grid-template-columns: minmax(275px, .72fr) minmax(520px, 1.5fr); gap: 34px; align-items: start; padding: 0 5.7% 70px; }
.section-kicker { display: flex; align-items: center; gap: 9px; margin: 0 0 16px; color: var(--ink-muted); letter-spacing: .13em; }
.section-kicker span { color: var(--coral); font-family: var(--display); font-size: 14px; font-weight: 600; letter-spacing: 0; }
.drop-card { display: flex; min-height: 330px; flex-direction: column; align-items: center; justify-content: center; padding: 28px; border: 1.5px dashed rgba(96, 116, 102, .42); border-radius: 17px; background: rgba(251, 247, 240, .36); text-align: center; transition: background .2s ease, border-color .2s ease, transform .2s ease; }
.drop-card:hover, .drop-card.is-dragging { border-color: var(--sage); background: rgba(220, 229, 219, .55); transform: translateY(-2px); }
.upload-icon { display: grid; place-items: center; width: 52px; height: 52px; margin-bottom: 20px; color: var(--sage-dark); background: var(--sage-soft); border-radius: 50%; }
.upload-icon svg { width: 24px; height: 24px; stroke-width: 1.7; }
.drop-title { margin-bottom: 8px; font-family: var(--display); font-size: 22px; font-weight: 600; letter-spacing: -.035em; }
.drop-caption { margin-bottom: 21px; color: var(--ink-muted); font-size: 13px; line-height: 1.6; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 9px; font-weight: 700; transition: transform .2s ease, box-shadow .2s ease, background .2s ease; }
.button svg { width: 16px; height: 16px; }
.button-primary { padding: 12px 17px; color: var(--paper-light); background: var(--sage); box-shadow: 0 5px 0 var(--sage-dark); }
.button-primary:hover { background: var(--sage-dark); transform: translateY(-2px); box-shadow: 0 7px 0 #2e4438; }
.button-primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #2e4438; }
.drop-footnote { display: inline-flex; align-items: center; gap: 5px; margin: 24px 0 0; color: #8c918a; font-size: 10px; }
.drop-footnote svg { width: 12px; height: 12px; }
.how-it-works { padding: 32px 5px 0; }
.mini-step { display: flex; align-items: flex-start; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.mini-step:last-child { border-bottom: 0; }
.step-icon { display: grid; flex: 0 0 auto; place-items: center; width: 30px; height: 30px; color: var(--sage); background: rgba(220, 229, 219, .7); border-radius: 8px; }
.step-icon svg { width: 15px; height: 15px; }
.mini-step strong, .mini-step small { display: block; }
.mini-step strong { margin-bottom: 3px; font-size: 12px; }
.mini-step small { color: var(--ink-muted); font-size: 11px; line-height: 1.4; }

.reader-kicker { color: var(--coral); }
.reader-card { min-height: 634px; overflow: hidden; border: 1px solid rgba(111, 91, 66, .12); border-radius: 18px; background: var(--paper-light); box-shadow: var(--shadow); }
.reader-empty { display: grid; min-height: 634px; place-items: center; align-content: center; padding: 40px; text-align: center; }
.empty-illustration { display: grid; place-items: center; width: 83px; height: 83px; margin-bottom: 22px; color: var(--sage); background: var(--sage-soft); border-radius: 50% 50% 47% 53%; transform: rotate(-5deg); }
.empty-illustration svg { width: 36px; height: 36px; stroke-width: 1.25; transform: rotate(5deg); }
.empty-title { margin-bottom: 10px; font-family: var(--display); font-size: 24px; font-weight: 600; letter-spacing: -.04em; line-height: 1.15; }
.empty-caption { margin: 0; color: var(--ink-muted); font-size: 13px; }
.reader-loaded { padding: 31px 34px 25px; }
.book-heading { display: flex; align-items: center; gap: 13px; padding-bottom: 24px; border-bottom: 1px solid var(--line); }
.book-cover { display: grid; flex: 0 0 auto; place-items: center; width: 47px; height: 58px; color: var(--paper-light); background: var(--sage); border-radius: 4px 8px 8px 4px; box-shadow: 4px 4px 0 var(--paper-deep); }
.book-cover svg { width: 22px; height: 22px; stroke-width: 1.5; }
.book-info { min-width: 0; }
.book-label { margin-bottom: 4px; color: var(--coral); font-size: 10px; font-weight: 700; letter-spacing: .13em; text-transform: uppercase; }
.book-info h2 { overflow: hidden; margin-bottom: 3px; font-family: var(--display); font-size: clamp(19px, 2.5vw, 26px); font-weight: 600; letter-spacing: -.045em; text-overflow: ellipsis; white-space: nowrap; }
.book-meta { margin: 0; color: var(--ink-muted); font-size: 11px; }
.icon-button { display: grid; flex: 0 0 auto; place-items: center; width: 32px; height: 32px; margin-left: auto; border: 0; border-radius: 50%; color: var(--ink-muted); background: transparent; }
.icon-button:hover { color: var(--coral); background: rgba(201, 110, 82, .1); }
.icon-button svg { width: 17px; height: 17px; }
.reading-status { display: flex; align-items: center; gap: 8px; min-height: 48px; color: var(--sage-dark); font-size: 12px; font-weight: 600; }
.reading-status .status-dot { width: 6px; height: 6px; box-shadow: none; }
.reading-status.is-reading .status-dot { background: var(--coral); box-shadow: 0 0 0 3px rgba(201, 110, 82, .15); }
.progress-block { margin-bottom: 18px; }
.progress-labels { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--ink-muted); font-size: 10px; font-weight: 600; }
.progress-track { height: 5px; overflow: hidden; border-radius: 99px; background: var(--paper-deep); }
.progress-fill { width: 0; height: 100%; border-radius: inherit; background: var(--coral); transition: width .25s ease; }
.warning-banner { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 16px; padding: 12px 13px; border: 1px solid rgba(201, 110, 82, .22); border-radius: 9px; color: #83513e; background: #fbede4; font-size: 11px; line-height: 1.4; }
.warning-banner svg { flex: 0 0 auto; width: 16px; margin-top: 1px; }
.warning-banner strong, .warning-banner span { display: block; }
.warning-banner strong { margin-bottom: 2px; font-size: 11px; }
.text-preview { height: 190px; overflow: auto; padding: 19px 20px; border: 1px solid var(--line); border-radius: 10px; color: #46534b; background: rgba(244, 235, 221, .48); font-family: var(--display); font-size: 15px; line-height: 1.8; scrollbar-color: var(--sage-soft) transparent; }
.text-preview:empty::before { color: var(--ink-muted); content: 'O texto do teu livro vai aparecer aqui.'; font-family: var(--sans); font-size: 12px; }
.text-preview .chunk { border-radius: 4px; transition: color .25s ease, background .25s ease; }
.text-preview .chunk.is-active { color: var(--sage-dark); background: rgba(216, 163, 82, .23); box-shadow: 0 0 0 2px rgba(216, 163, 82, .11); }
.reader-controls { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.control-row { display: flex; align-items: center; }
.main-controls { justify-content: center; gap: 13px; }
.transport-button, .play-button { display: inline-flex; align-items: center; justify-content: center; border: 0; }
.transport-button { width: 38px; height: 38px; border-radius: 50%; color: var(--sage); background: transparent; }
.transport-button:hover { color: var(--sage-dark); background: var(--sage-soft); }
.transport-button svg { width: 19px; height: 19px; }
.play-button { min-width: 126px; gap: 8px; padding: 12px 19px; border-radius: 999px; color: var(--paper-light); background: var(--coral); box-shadow: 0 5px 0 #a7523c; font-size: 13px; font-weight: 700; }
.play-button:hover { background: #b65c43; transform: translateY(-1px); }
.play-button:disabled { cursor: wait; opacity: .82; transform: none; }
.play-button svg { width: 17px; height: 17px; fill: currentColor; }
.settings-row { gap: 24px; margin-top: 20px; }
.select-control { display: flex; flex: 1; min-width: 0; align-items: center; justify-content: space-between; gap: 10px; color: var(--ink-muted); font-size: 10px; font-weight: 700; }
.select-control > span { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
.select-control svg { width: 13px; height: 13px; color: var(--sage); }
.select-control select { min-width: 0; max-width: 205px; padding: 7px 22px 7px 8px; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); background-color: transparent; font-size: 11px; }
.reader-note { display: flex; align-items: center; gap: 6px; margin: 13px 4px 0; color: var(--ink-muted); font-size: 10px; line-height: 1.5; }
.reader-note svg { flex: 0 0 auto; width: 13px; color: var(--sage); }
.footer { display: flex; justify-content: space-between; padding: 19px 5.7% 31px; border-top: 1px solid var(--line); color: #8a918b; font-size: 10px; letter-spacing: .02em; }
.footer span:first-child { color: var(--sage-dark); font-weight: 700; }

.settings-overlay { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; padding: 24px; background: rgba(36, 51, 45, .32); backdrop-filter: blur(5px); }
.settings-panel { width: min(100%, 470px); padding: 28px; border: 1px solid rgba(111, 91, 66, .15); border-radius: 18px; background: var(--paper-light); box-shadow: 0 24px 80px rgba(36, 51, 45, .2); }
.settings-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; padding-bottom: 18px; border-bottom: 1px solid var(--line); }
.settings-eyebrow { margin-bottom: 6px; color: var(--coral); font-size: 10px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.settings-header h2 { margin: 0; font-family: var(--display); font-size: 25px; letter-spacing: -.045em; }
.settings-intro { margin: 19px 0 20px; color: var(--ink-muted); font-size: 13px; line-height: 1.55; }
.settings-field { display: block; color: var(--ink); font-size: 12px; font-weight: 700; }
.settings-field > span { display: block; margin-bottom: 8px; }
.settings-field small { color: var(--ink-muted); font-weight: 400; }
.key-input-wrap { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 8px; background: #fffdf9; }
.key-input-wrap:focus-within { border-color: var(--sage); box-shadow: 0 0 0 3px rgba(96, 116, 102, .12); }
.key-input-wrap input { min-width: 0; flex: 1; padding: 12px; border: 0; outline: 0; color: var(--ink); background: transparent; font: 12px var(--sans); }
.key-toggle { display: grid; place-items: center; width: 38px; height: 36px; border: 0; color: var(--ink-muted); background: transparent; }
.key-toggle svg { width: 16px; height: 16px; }
.settings-security { display: flex; align-items: flex-start; gap: 7px; margin: 12px 0 7px; color: var(--ink-muted); font-size: 10px; line-height: 1.45; }
.settings-security svg { flex: 0 0 auto; width: 13px; color: var(--sage); }
.settings-status { min-height: 16px; margin: 0; color: var(--sage-dark); font-size: 11px; }
.settings-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.button-secondary { padding: 10px 13px; color: var(--sage-dark); border: 1px solid var(--line); background: transparent; }
.button-secondary:hover { background: var(--sage-soft); }

.is-loading .upload-icon { animation: breathe 1.2s ease-in-out infinite; }
.is-loading .drop-title::after { content: '…'; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }

@media (max-width: 900px) {
  .hero-section { padding-top: 62px; }
  .workspace { grid-template-columns: 1fr; }
  .upload-column { display: grid; grid-template-columns: 1fr 1fr; gap: 25px; align-items: start; }
  .upload-column > .section-kicker { grid-column: 1 / -1; margin-bottom: -10px; }
  .how-it-works { padding: 0; }
  .reader-card, .reader-empty { min-height: 560px; }
}
@media (max-width: 620px) {
  .app-shell { width: min(100% - 28px, 1240px); }
  .topbar { height: 74px; }
  .topbar-meta { gap: 8px; }
  .privacy-note { display: none; }
  .status-pill { padding: 7px 9px; font-size: 10px; }
  .settings-button { width: 34px; height: 34px; }
  .hero-section { align-items: flex-start; padding: 42px 4px 38px; }
  .hero-stamp { display: none; }
  h1 { font-size: clamp(46px, 15vw, 72px); }
  .hero-description { font-size: 14px; }
  .workspace { gap: 34px; padding: 0 4px 44px; }
  .upload-column { display: block; }
  .drop-card { min-height: 275px; padding: 22px 18px; }
  .how-it-works { padding-top: 34px; }
  .reader-card { min-height: auto; }
  .reader-loaded { padding: 20px 15px 17px; }
  .reader-empty { min-height: 390px; padding: 25px 18px; }
  .book-heading { padding-bottom: 20px; }
  .book-cover { width: 42px; height: 52px; }
  .book-info h2 { font-size: 18px; }
  .reading-status { min-height: 40px; }
  .text-preview { height: 180px; padding: 15px 14px; font-size: 14px; }
  .main-controls { gap: 8px; }
  .transport-button { width: 42px; height: 42px; }
  .play-button { flex: 1; max-width: 210px; }
  .settings-row { display: grid; gap: 13px; }
  .select-control select { max-width: none; flex: 1; }
  .footer { display: grid; gap: 8px; padding-left: 4px; padding-right: 4px; }
  .settings-overlay { align-items: flex-end; padding: 0; }
  .settings-panel { width: 100%; padding: 24px 20px 28px; border-radius: 20px 20px 0 0; }
  .settings-actions { display: grid; grid-template-columns: 1fr 1.35fr; }
  .settings-actions .button { width: 100%; }
}

@media (max-width: 380px) {
  .brand-wordmark { font-size: 21px; }
  .status-pill { max-width: 82px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .hero-description { font-size: 13px; }
  .reader-note { align-items: flex-start; }
}
