:root {
  font-family: "DM Sans", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #202938;
  background: #f5f6f8;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  --line: #e7eaf0;
  --muted: #7b8493;
  --blue: #386fce;
  --blue-dark: #2f61b5;
}

* { box-sizing: border-box; }
body { min-width: 320px; min-height: 100vh; margin: 0; }
button, input { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible, .canvas-scroll:focus-visible { outline: 3px solid #9bbbf2; outline-offset: 2px; }
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar { height: 72px; padding: 0 34px; display: flex; justify-content: space-between; align-items: center; background: #fff; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; gap: 11px; align-items: center; color: #243044; font: 700 17px/1 "Manrope", sans-serif; text-decoration: none; letter-spacing: -.5px; }
.brand strong { color: var(--blue); }
.brand-mark { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: #fff; background: #3973d6; box-shadow: 0 4px 10px #3973d633; }
.brand-mark svg { width: 21px; height: 21px; }
.topbar-actions { display: flex; align-items: center; gap: 24px; }
.privacy-note { display: inline-flex; align-items: center; gap: 8px; color: #697486; font-size: 12px; }
.privacy-dot { width: 7px; height: 7px; border-radius: 50%; background: #43ad7a; box-shadow: 0 0 0 3px #eaf7f0; }
.button { min-height: 39px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; padding: 0 15px; border: 1px solid transparent; border-radius: 8px; cursor: pointer; font-size: 13px; font-weight: 650; transition: background .15s ease, transform .15s ease, border-color .15s ease; }
.button svg { width: 17px; height: 17px; }
.button:hover { transform: translateY(-1px); }
.button-primary { background: var(--blue); color: #fff; box-shadow: 0 3px 7px #386fce26; }
.button-primary:hover { background: var(--blue-dark); }
.button-quiet { color: #4f5a6a; background: #fff; border-color: #e2e6ed; text-decoration: none; }
.button-quiet:hover { background: #f8f9fb; border-color: #cfd6e1; }
.reader-layout { flex: 1; width: min(1220px, calc(100% - 48px)); margin: 29px auto 36px; display: flex; }
.reader-card { width: 100%; min-height: min(790px, calc(100vh - 137px)); display: flex; flex-direction: column; overflow: hidden; background: #fff; border: 1px solid #e6e9ef; border-radius: 12px; box-shadow: 0 7px 24px #2532470a; }
.document-bar { min-height: 64px; display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 0 20px; border-bottom: 1px solid var(--line); }
.document-info { min-width: 0; display: flex; align-items: center; gap: 12px; }
.document-icon { width: 35px; height: 35px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 8px; background: #f0f4fb; color: #5874a5; }
.document-icon svg { width: 20px; height: 20px; }
.document-copy { min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.document-name { max-width: min(60vw, 620px); overflow: hidden; color: #364153; font-size: 13px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.document-meta { color: #929aa8; font-size: 11px; }
.download-link svg { width: 16px; height: 16px; }
.toolbar { min-height: 51px; display: flex; justify-content: center; align-items: center; gap: 17px; background: #fff; border-bottom: 1px solid var(--line); }
.toolbar-group { display: flex; align-items: center; gap: 7px; }
.icon-button { width: 29px; height: 29px; display: inline-grid; place-items: center; padding: 0; border: 0; border-radius: 6px; background: transparent; color: #596578; cursor: pointer; }
.icon-button:hover:not(:disabled) { background: #f0f3f8; color: #27364a; }
.icon-button:disabled, .text-button:disabled { color: #bec5cf; cursor: default; }
.icon-button svg { width: 18px; height: 18px; }
.page-counter { display: inline-flex; align-items: center; gap: 7px; color: #8a93a1; font-size: 12px; }
.page-counter input { width: 42px; height: 27px; padding: 0 5px; border: 1px solid #e2e6ed; border-radius: 5px; color: #465164; background: #fff; text-align: center; font-size: 12px; }
.page-counter input::-webkit-inner-spin-button { appearance: none; }
.zoom-value { min-width: 41px; color: #697486; font-size: 11px; text-align: center; }
.text-button { padding: 5px 8px; border: 0; border-radius: 5px; background: transparent; color: #586477; cursor: pointer; font-size: 11px; }
.text-button:hover:not(:disabled) { background: #f0f3f8; }
.toolbar-divider { height: 21px; width: 1px; background: #e9ecf1; }
.speech-panel { min-height: 61px; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 8px 18px; border-bottom: 1px solid var(--line); background: #fbfcfe; }
.speech-description { min-width: 175px; display: flex; align-items: center; gap: 10px; }
.speech-icon { width: 32px; height: 32px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 9px; background: #edf3ff; color: #4978cc; }
.speech-icon svg { width: 19px; height: 19px; }
.speech-copy { display: flex; flex-direction: column; gap: 3px; }
.speech-copy strong { color: #3b4657; font-size: 12px; font-weight: 700; }
.speech-copy > span { color: #929aa8; font-size: 10px; }
.speech-controls { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.voice-label { margin-right: -3px; color: #778191; font-size: 11px; }
.speech-controls select { max-width: 190px; height: 35px; padding: 0 25px 0 10px; border: 1px solid #e0e5ec; border-radius: 7px; background: #fff; color: #596477; font-size: 11px; }
.speech-controls .button { min-height: 35px; padding: 0 12px; white-space: nowrap; font-size: 11px; }
.speech-controls .button svg { width: 15px; height: 15px; }
.speech-action { color: #596477; }
.viewer-stage { position: relative; flex: 1; min-height: 510px; display: flex; align-items: center; justify-content: center; overflow: hidden; background: #f4f6f9; }
.empty-state { max-width: 440px; display: flex; flex-direction: column; align-items: center; padding: 36px 24px 46px; text-align: center; }
.empty-illustration { width: 88px; height: 88px; margin-bottom: 15px; }
.empty-illustration svg { width: 100%; height: 100%; }
.empty-state h1 { margin: 0 0 8px; color: #263347; font: 750 21px/1.3 "Manrope", sans-serif; letter-spacing: -.6px; }
.empty-state p { margin: 0 0 22px; color: #7b8594; font-size: 13px; line-height: 1.6; }
.empty-open { min-height: 42px; padding: 0 17px; }
.empty-open svg { width: 18px; height: 18px; }
.file-hint { margin-top: 13px; color: #9aa2ae; font-size: 10px; }
.canvas-scroll { width: 100%; height: 100%; min-height: 510px; overflow: auto; padding: 30px; }
.canvas-wrap { width: fit-content; min-width: min-content; margin: 0 auto; background: white; box-shadow: 0 3px 16px #202c3c21; }
#pdf-canvas { display: block; }
.drop-overlay { position: absolute; z-index: 4; inset: 12px; display: none; place-items: center; border: 2px dashed #6b95dc; border-radius: 12px; background: #edf4ffed; color: #315fae; font-size: 16px; font-weight: 700; pointer-events: none; }
.viewer-stage.is-dragging .drop-overlay { display: grid; }
.loading-state, .error-state { position: absolute; z-index: 2; display: flex; align-items: center; justify-content: center; gap: 11px; padding: 16px 20px; border: 1px solid #e4e8ef; border-radius: 9px; background: #fff; color: #586477; box-shadow: 0 5px 18px #24324812; font-size: 13px; }
.error-state { max-width: min(480px, calc(100% - 36px)); color: #a83939; line-height: 1.55; text-align: center; }
.spinner { width: 17px; height: 17px; border: 2px solid #dce6f6; border-top-color: #4778d1; border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.reader-footer { min-height: 38px; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 0 17px; border-top: 1px solid var(--line); color: #969eaa; font-size: 10px; }
.footer-shortcut { color: #a3aab5; }
.is-hidden { display: none !important; }

@media (max-width: 700px) {
  .topbar { height: 62px; padding: 0 16px; }
  .topbar-actions { gap: 10px; }
  .privacy-note { display: none; }
  .reader-layout { width: calc(100% - 20px); margin: 12px auto 18px; }
  .reader-card { min-height: calc(100vh - 92px); border-radius: 9px; }
  .document-bar { min-height: 58px; padding: 0 12px; }
  .document-icon { width: 31px; height: 31px; }
  .document-name { max-width: 49vw; font-size: 12px; }
  .document-meta { font-size: 10px; }
  .download-link { width: 36px; min-width: 36px; padding: 0; font-size: 0; }
  .download-link svg { width: 17px; height: 17px; }
  .toolbar { min-height: 48px; gap: 9px; }
  .toolbar-group { gap: 3px; }
  .icon-button { width: 27px; height: 27px; }
  .toolbar-divider { height: 18px; }
  .text-button { padding: 4px 5px; font-size: 10px; }
  .zoom-value { min-width: 35px; font-size: 10px; }
  .page-counter { gap: 4px; font-size: 10px; }
  .page-counter input { width: 35px; height: 25px; font-size: 11px; }
  .view-controls { display: none; }
  .speech-panel { align-items: flex-start; flex-direction: column; gap: 10px; padding: 10px 12px; }
  .speech-description { min-width: 0; }
  .speech-controls { width: 100%; justify-content: flex-start; flex-wrap: wrap; gap: 6px; }
  .speech-controls select { flex: 1 1 135px; max-width: none; }
  .speech-controls .button { padding: 0 9px; }
  .speech-controls .speech-start { margin-left: auto; }
  .voice-label { display: none; }
  .viewer-stage, .canvas-scroll { min-height: 430px; }
  .canvas-scroll { padding: 16px 10px; }
  .reader-footer { padding: 0 10px; font-size: 9px; }
  .footer-shortcut { display: none; }
}

@media (max-width: 380px) {
  .brand { gap: 7px; font-size: 15px; }
  .brand-mark { width: 30px; height: 30px; }
  .topbar .button { padding: 0 10px; }
  .toolbar { gap: 5px; }
  .desktop-divider { display: none; }
}

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