:root {
  --ink: #27231f;
  --muted: #82786c;
  --bg: #f4f0e8;
  --surface: #fffdf9;
  --surface-2: #eee7dc;
  --line: rgba(59, 49, 39, .13);
  --gold: #b38a4b;
  --gold-dark: #7d5c2e;
  --champagne: #e3c995;
  --paper: #fffefa;
  --shadow: 0 28px 70px rgba(70, 55, 37, .17);
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; }
body { color: var(--ink); background: var(--bg); font-family: 'Segoe UI', Arial, sans-serif; -webkit-font-smoothing: antialiased; user-select: none; }
button, input, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.noise { position: fixed; inset: 0; opacity: .025; pointer-events: none; z-index: 30; background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.8'/%3E%3C/svg%3E"); }
#app, .view { width: 100%; height: 100%; }
.view { display: none; }
.view.active { display: flex; flex-direction: column; }

#library-view { overflow-y: auto; background-color: var(--bg); background-image: linear-gradient(rgba(244,240,232,.76), rgba(244,240,232,.88)), var(--advertising-background, none), radial-gradient(circle at 88% 1%, rgba(220,192,145,.24), transparent 27%), radial-gradient(circle at 5% 100%, rgba(202,181,148,.16), transparent 31%); background-position: center, center, center, center; background-size: cover, cover, auto, auto; background-repeat: no-repeat; scrollbar-color: #c7b599 transparent; }
.topbar, .reader-toolbar { min-height: 88px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 0 clamp(24px, 3.6vw, 68px); border-bottom: 1px solid var(--line); background: rgba(255, 253, 249, .88); backdrop-filter: blur(14px); }
.brand { display: flex; align-items: center; min-width: 0; }
.brand img { width: 180px; height: 58px; object-fit: contain; object-position: left center; }
.header-identity { text-align: center; line-height: 1.2; }
.site-address { display: block; margin-bottom: 7px; color: var(--gold-dark); font-family: Georgia, serif; font-size: 12px; letter-spacing: .08em; }
.user-line { display: flex; align-items: center; justify-content: center; gap: 10px; color: #6e655c; font-size: 11px; }
.user-line strong { color: var(--ink); font-weight: 600; }
.user-line i { width: 3px; height: 3px; border-radius: 50%; background: var(--gold); }
.top-actions, .reader-actions { justify-self: end; display: flex; align-items: center; gap: 9px; }

.button, .icon-button, .back-button, .page-arrow, .zoom-controls button, .modal-close { border: 0; cursor: pointer; transition: transform .2s ease, background .2s ease, color .2s ease, opacity .2s ease, box-shadow .2s ease; }
.button:hover, .icon-button:hover, .back-button:hover { transform: translateY(-2px); }
.button { height: 43px; padding: 0 17px; border-radius: 7px; font-size: 12px; font-weight: 700; }
.button:disabled { opacity: .42; cursor: not-allowed; transform: none; }
.button-primary { color: #fff; background: linear-gradient(135deg, #9a713a, #c69b59); box-shadow: 0 10px 22px rgba(147, 105, 49, .18); }
.button-primary:hover { box-shadow: 0 13px 27px rgba(147, 105, 49, .26); }
.button-secondary { color: #493d30; background: #eee5d7; border: 1px solid #ded0bc; }
.button-ghost { color: #62584e; background: transparent; border: 1px solid #d8cec0; }
.button-danger { color: #fff; background: #9b4f46; }
.button-danger:hover { background: #823c35; }
.plus { font-size: 19px; font-weight: 400; vertical-align: -1px; margin-right: 5px; }
.gear-icon { margin-right: 5px; font-size: 16px; vertical-align: -1px; }
.note-icon { margin-right: 5px; font-size: 16px; vertical-align: -1px; }
.icon-button { width: 42px; height: 42px; border-radius: 50%; background: #eee8de; color: #62584e; font-size: 18px; }
.icon-button:hover { background: #dfd4c3; }
.profile-button { color: var(--gold-dark); font-size: 21px; }
.close-button:hover { background: #8b4841; color: white; }

.library-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 30px; padding: clamp(38px, 5vh, 65px) clamp(28px, 6vw, 108px) 34px; }
.section-kicker { margin: 0 0 9px; color: var(--gold-dark); font-size: 10px; letter-spacing: .24em; font-weight: 800; }
.summary { margin: 0; color: var(--muted); font-size: 13px; }
.search-box { width: min(360px, 32vw); height: 45px; display: flex; gap: 13px; align-items: center; padding: 0 15px; border: 1px solid #d8cec0; border-radius: 9px; background: rgba(255, 253, 249, .75); box-shadow: 0 8px 24px rgba(83, 66, 45, .05); }
.magnifier { position: relative; width: 16px; height: 16px; flex: none; border: 1.8px solid #8b7c69; border-radius: 50%; }
.magnifier::after { content: ''; position: absolute; width: 7px; height: 1.8px; right: -5px; bottom: -3px; background: #8b7c69; transform: rotate(45deg); border-radius: 2px; }
.search-box input { width: 100%; color: var(--ink); background: transparent; border: 0; outline: 0; font-size: 13px; }
.search-box input::placeholder { color: #a29789; }

.book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: clamp(29px, 3.2vw, 55px); padding: 6px clamp(28px, 6vw, 108px) 70px; }
.book-card { min-width: 0; cursor: pointer; outline: none; animation: enter .5s both; }
.cover-wrap { position: relative; width: 100%; max-width: 235px; aspect-ratio: .72; margin-bottom: 17px; perspective: 900px; }
.cover { position: absolute; inset: 0; overflow: hidden; background: #e9e2d8; border-radius: 3px 8px 8px 3px; box-shadow: 12px 17px 31px rgba(72,57,40,.2), inset 7px 0 12px rgba(0,0,0,.08); transform-origin: left center; transition: transform .35s ease, box-shadow .35s ease; }
.book-card:hover .cover, .book-card:focus .cover { transform: rotateY(-7deg) translateY(-6px); box-shadow: 20px 25px 45px rgba(67,51,34,.24); }
.cover::after { content: ''; position: absolute; inset: 0; box-shadow: inset 5px 0 rgba(255,255,255,.2), inset -1px 0 rgba(0,0,0,.14); pointer-events: none; }
.cover canvas, .cover img { width: 100%; height: 100%; object-fit: cover; background: white; display: block; }
.cover-placeholder { width: 100%; height: 100%; display: grid; place-items: center; background: linear-gradient(145deg, #f5efe5, #ddd0bd); color: var(--gold-dark); font-size: 27px; font-family: Georgia, serif; }
.book-index { color: #a29077; font-size: 9px; letter-spacing: .15em; margin-bottom: 7px; }
.book-card h3 { margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; font-weight: 650; }
.book-meta { margin-top: 7px; color: var(--muted); font-size: 11px; }

.empty-state { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding-bottom: 75px; }
.empty-illustration { width: 128px; height: 164px; display: grid; place-items: center; margin-bottom: 28px; border: 1px solid #d6c9b7; background: linear-gradient(145deg,#fffdfa,#e8dfd2); box-shadow: 15px 20px 43px rgba(70,53,34,.14); transform: rotate(-3deg); }
.empty-illustration span { color: var(--gold-dark); letter-spacing: .18em; }
.empty-state h2 { margin: 0; font-size: 27px; }
.empty-state > p:not(.section-kicker) { color: var(--muted); margin: 12px 0 24px; }

.reader-view { background: #ded7cc; }
.reader-toolbar { min-height: 72px; position: relative; z-index: 4; grid-template-columns: 1fr auto 1fr; background: rgba(255,253,249,.94); }
.back-button { justify-self: start; background: transparent; color: #685e54; padding: 12px 0; font-size: 12px; font-weight: 700; }
.back-button span { font-size: 18px; margin-right: 8px; vertical-align: -1px; }
.reader-title { text-align: center; max-width: 40vw; }
.reader-title strong { display: block; white-space: nowrap; text-overflow: ellipsis; overflow: hidden; font-size: 13px; }
.reader-title span { display: block; color: var(--muted); margin-top: 4px; font-size: 10px; }
.zoom-controls { display: flex; height: 36px; align-items: stretch; border: 1px solid #d8cec0; border-radius: 7px; overflow: hidden; background: #fff; }
.zoom-controls button { min-width: 34px; padding: 0 9px; background: transparent; color: #645b52; font-size: 15px; border-right: 1px solid #e3dbd0; }
.zoom-controls button:last-child { border-right: 0; }
.zoom-controls button:hover { background: #eee6da; }
#zoom-label { min-width: 56px; color: var(--gold-dark); font-size: 10px; font-weight: 700; }
.page-jump { display: flex; height: 36px; align-items: stretch; border: 1px solid #d8cec0; border-radius: 7px; overflow: hidden; background: #fff; }
.page-jump button { min-width: 31px; padding: 0 7px; border: 0; border-right: 1px solid #e3dbd0; color: #665a4d; background: transparent; cursor: pointer; font-size: 11px; font-weight: 700; }
.page-jump button:last-child { border-right: 0; }
.page-jump button:hover { background: #eee6da; }
.page-jump input { width: 48px; padding: 0 4px; color: var(--gold-dark); background: #fff; border: 0; border-right: 1px solid #e3dbd0; outline: none; text-align: center; font-size: 11px; font-weight: 700; -moz-appearance: textfield; }
.page-jump input::-webkit-inner-spin-button { display: none; }

.reader-stage { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; padding: 27px 100px 17px; overflow: auto; touch-action: none; overscroll-behavior: contain; background-color: #ded6ca; background-image: linear-gradient(rgba(222,214,202,.55), rgba(211,202,189,.68)), var(--advertising-background, none), radial-gradient(ellipse at center, #f4efe7 0, #ded6ca 66%, #d3cabd 100%); background-position: center; background-size: cover, cover, auto; background-repeat: no-repeat; }
.reader-stage.zoomed { align-items: flex-start; justify-content: flex-start; cursor: grab; }
.reader-stage.touch-dragging { cursor: grabbing; }
.open-book { position: relative; flex: none; height: 100%; max-height: 780px; aspect-ratio: 1.42; display: flex; filter: drop-shadow(0 27px 30px rgba(74,58,40,.24)); transition: height .2s ease, max-height .2s ease; }
.open-book.single-page { width: 100%; height: auto; max-height: none; aspect-ratio: .72; }
.open-book.single-page .page-left, .open-book.single-page .spine { display: none; }
.open-book.single-page .page-right { width: 100%; border-radius: 8px; box-shadow: none; }
.paper { position: relative; width: 50%; height: 100%; overflow: hidden; background: var(--paper); display: flex; align-items: center; justify-content: center; }
.paper canvas { max-width: 100%; max-height: 100%; display: block; }
.paper .native-page { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; display: block; }
.page-left { border-radius: 8px 1px 1px 8px; box-shadow: inset -18px 0 26px -26px #000; transform-origin: right center; }
.page-right { border-radius: 1px 8px 8px 1px; box-shadow: inset 18px 0 26px -26px #000; transform-origin: left center; }
.paper.blank canvas { display: none; }
.paper.blank .native-page { display: none; }
.paper.blank::before { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, #f1ede5, #fffdf8); }
.page-number { position: absolute; z-index: 2; bottom: 8px; color: #8d8982; font: 10px Georgia, serif; }
.page-left .page-number { left: 18px; }
.page-right .page-number { right: 18px; }
.spine { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; z-index: 3; transform: translateX(-50%); background: rgba(35,28,20,.16); box-shadow: 0 0 15px 4px rgba(35,28,20,.09); }
.turn-forward .page-right { animation: turnForward .35s ease; }
.turn-back .page-left { animation: turnBack .35s ease; }
.reader-loading { position: absolute; inset: 0; z-index: 6; display: flex; flex-direction: column; align-items: center; justify-content: center; color: #665b4f; background: var(--paper); }
.reader-loading span { width: 34px; height: 34px; border: 3px solid #ddd3c5; border-top-color: var(--gold); border-radius: 50%; animation: spin .8s linear infinite; }
.reader-loading p { font-size: 12px; margin-top: 14px; }
.page-arrow { position: fixed; top: 50%; z-index: 4; width: 56px; height: 56px; transform: translateY(-50%); border: 1px solid rgba(90,72,52,.18); border-radius: 50%; color: #6b5d4c; background: rgba(255,253,249,.78); font: 34px Georgia, serif; box-shadow: 0 10px 28px rgba(73,56,37,.08); }
.page-arrow:hover { background: var(--gold); color: white; transform: translateY(-50%) scale(1.06); }
.page-arrow:disabled { opacity: .25; cursor: default; }
.page-arrow:disabled:hover { background: rgba(255,253,249,.78); color: #6b5d4c; transform: translateY(-50%); }
.page-arrow.prev { left: clamp(22px, 4vw, 70px); }
.page-arrow.next { right: clamp(22px, 4vw, 70px); }
.reader-footer { min-height: 53px; display: flex; align-items: center; gap: 14px; padding: 0 clamp(28px, 5vw, 84px); border-top: 1px solid var(--line); color: #81776c; background: #f9f6f1; font-size: 9px; letter-spacing: .12em; }
.progress-track { width: 180px; height: 2px; background: #ded4c6; }
#progress-bar { height: 100%; width: 0; background: var(--gold); transition: width .3s ease; }
.reader-site { margin-left: auto; color: #a48d6d; font-family: Georgia, serif; letter-spacing: .08em; }
.keyboard-hint { margin-left: auto; letter-spacing: .03em; }
kbd { display: inline-grid; place-items: center; min-width: 22px; height: 20px; margin: 0 2px; border: 1px solid #d2c6b5; border-radius: 3px; color: #72675b; font-family: inherit; }

.modal-overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 30px; background: rgba(51,43,35,.38); backdrop-filter: blur(12px); }
.modal-card { width: min(560px, 94vw); max-height: 92vh; overflow-y: auto; padding: 34px; color: var(--ink); background: #fffdf9; border: 1px solid rgba(255,255,255,.7); border-radius: 16px; box-shadow: 0 35px 90px rgba(55,42,28,.28); animation: modalEnter .28s ease both; }
.modal-brand { display: flex; justify-content: center; margin: -5px 0 22px; }
.modal-brand img { width: 230px; height: 74px; object-fit: contain; }
.modal-card h2 { margin: 0; font: 600 32px Georgia, serif; letter-spacing: -.02em; }
.modal-copy { margin: 10px 0 25px; color: var(--muted); font-size: 13px; line-height: 1.55; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.form-grid .wide { grid-column: 1 / -1; }
.password-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
.modal-card label { display: block; }
.modal-card label > span { display: block; margin-bottom: 7px; color: #62584e; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.modal-card input, .modal-card textarea { width: 100%; color: var(--ink); background: #f7f3ed; border: 1px solid #ded4c7; border-radius: 7px; outline: none; transition: border .2s, box-shadow .2s, background .2s; }
.modal-card input { height: 45px; padding: 0 13px; }
.modal-card textarea { min-height: 220px; resize: vertical; padding: 13px; line-height: 1.55; user-select: text; }
.modal-card input:focus, .modal-card textarea:focus { border-color: #bc9254; background: #fff; box-shadow: 0 0 0 3px rgba(188,146,84,.12); }
.form-error { min-height: 18px; margin: 10px 0 0; color: #a7463d; font-size: 11px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.notes-card { width: min(760px, 94vw); }
.notes-heading { display: flex; align-items: flex-start; justify-content: space-between; }
.modal-close { width: 38px; height: 38px; border-radius: 50%; color: #6a6055; background: #eee7dd; font-size: 22px; }
.modal-close:hover { background: #dfd3c3; }
.order-identity { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 16px; }
.note-field { display: block; }
.note-field-heading { display: flex; align-items: center; justify-content: space-between; min-height: 31px; margin-bottom: 7px; }
.note-field-heading > span { color: #62584e; font-size: 10px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.voice-order-button { display: inline-flex; align-items: center; gap: 5px; min-height: 34px; padding: 0 11px; color: #76552a; background: #f1e7d7; border: 1px solid #dac5a4; border-radius: 17px; font-size: 12px; font-weight: 800; cursor: pointer; }
.android .voice-order-button { display: inline-flex; }
.voice-order-button.listening { color: #fff; background: #9b4038; border-color: #9b4038; animation: microphonePulse 1s ease-in-out infinite; }
.split-actions { align-items: center; justify-content: space-between; }
.split-actions > div { display: flex; gap: 9px; }
.floating-notes { position: fixed; right: 28px; bottom: 28px; z-index: 45; width: min(460px, calc(100vw - 32px)); filter: drop-shadow(0 24px 38px rgba(57,43,29,.25)); }
.floating-notes .notes-card { width: 100%; max-height: calc(100vh - 32px); padding: 22px; border-radius: 19px; box-shadow: none; overflow-y: auto; }
.floating-notes .notes-card h2 { font-size: 25px; }
.floating-notes .modal-copy { margin: 7px 0 17px; font-size: 12px; }
.floating-notes .notes-heading { margin: -4px -3px 0; padding: 4px 3px 10px; cursor: grab; touch-action: none; }
.floating-notes.dragging .notes-heading { cursor: grabbing; }
.drag-label { display: flex; align-items: center; gap: 10px; }
.drag-dots { color: #aa8a5c; font-size: 20px; line-height: 1; }
.floating-notes .order-identity { gap: 10px; margin-bottom: 12px; }
.floating-notes .modal-card input { height: 40px; }
.floating-notes .modal-card textarea { min-height: 150px; max-height: 260px; }
.floating-notes .form-error { margin-top: 7px; }
.autosave-status { margin: 2px 0 0; color: #927b5c; font-size: 10px; line-height: 1.4; }
.autosave-status.saved { color: #52735e; }
.floating-notes .modal-actions { margin-top: 11px; }
.floating-notes .modal-actions .button { height: 38px; padding: 0 12px; font-size: 10px; }
.android .floating-notes { width: min(330px, calc(100vw - 70px)); right: 12px; bottom: 12px; filter: drop-shadow(0 14px 24px rgba(57,43,29,.22)); }
.android .floating-notes .notes-card { max-height: min(430px, calc(100vh - 105px)); padding: 13px; border-radius: 14px; background: rgba(255,253,249,.97); backdrop-filter: blur(8px); }
.android .floating-notes .notes-card h2 { font-size: 18px; }
.android .floating-notes .section-kicker { margin-bottom: 3px; font-size: 8px; }
.android .floating-notes .modal-copy { display: none; }
.android .floating-notes .notes-heading { padding: 2px 1px 7px; }
.android .floating-notes .drag-label { gap: 6px; }
.android .floating-notes .drag-dots { font-size: 16px; }
.android .floating-notes .modal-close { width: 29px; height: 29px; font-size: 18px; }
.android .floating-notes .order-identity { gap: 6px; margin-bottom: 7px; }
.android .floating-notes .modal-card label > span, .android .floating-notes .note-field-heading > span { margin-bottom: 4px; font-size: 8px; }
.android .floating-notes .modal-card input { height: 32px; padding: 0 8px; font-size: 11px; }
.android .floating-notes .note-field-heading { min-height: 25px; margin-bottom: 3px; }
.android .floating-notes .voice-order-button { min-height: 25px; padding: 0 8px; font-size: 9px; }
.android .floating-notes .modal-card textarea { min-height: 76px; max-height: 112px; padding: 8px; resize: none; font-size: 11px; line-height: 1.35; }
.android .floating-notes .form-error { min-height: 12px; margin-top: 3px; font-size: 9px; }
.android .floating-notes .autosave-status { font-size: 8px; line-height: 1.25; }
.android .floating-notes .modal-actions { display: grid; grid-template-columns: auto 1fr; gap: 5px; margin-top: 6px; }
.android .floating-notes .split-actions > div { justify-content: flex-end; gap: 4px; }
.android .floating-notes .modal-actions .button { height: 30px; padding: 0 7px; font-size: 8px; }
.assistive-order-button { position: fixed; right: 22px; top: 52%; z-index: 38; width: 66px; height: 66px; display: grid; place-items: center; padding: 0; color: #fff; background: linear-gradient(145deg, #d1aa69, #8b612e); border: 3px solid rgba(255,255,255,.9); border-radius: 50%; outline: none; box-shadow: 0 10px 28px rgba(63,43,21,.34), inset 0 1px 4px rgba(255,255,255,.4); cursor: grab; touch-action: none; user-select: none; transition: transform .18s ease, opacity .18s ease, box-shadow .18s ease; }
.assistive-order-button:hover, .assistive-order-button:focus-visible { transform: scale(1.07); box-shadow: 0 13px 34px rgba(63,43,21,.42), 0 0 0 5px rgba(198,155,89,.2); }
.assistive-order-button.dragging { cursor: grabbing; transform: scale(1.05); transition: none; }
.assistive-order-button.is-hidden { opacity: 0; pointer-events: none; transform: scale(.75); }
.assistive-order-icon { position: relative; width: 27px; height: 29px; display: block; }
.assistive-order-icon::before { content: ''; position: absolute; left: 8px; top: 1px; width: 10px; height: 10px; border: 2px solid currentColor; border-radius: 50%; }
.assistive-order-icon::after { content: ''; position: absolute; left: 3px; bottom: 1px; width: 19px; height: 11px; border: 2px solid currentColor; border-bottom: 0; border-radius: 12px 12px 2px 2px; }
.assistive-order-icon i { position: absolute; right: -3px; bottom: 0; z-index: 1; width: 13px; height: 13px; background: #fff; border-radius: 50%; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.assistive-order-icon b { position: absolute; right: 0; bottom: -1px; z-index: 2; color: #8b612e; font: 800 13px/13px Arial, sans-serif; }
.assistive-order-label { position: absolute; top: calc(100% + 5px); left: 50%; transform: translateX(-50%); padding: 3px 7px; color: #564329; background: rgba(255,253,249,.94); border: 1px solid rgba(139,97,46,.18); border-radius: 9px; box-shadow: 0 4px 12px rgba(63,43,21,.12); font-size: 9px; font-weight: 800; letter-spacing: .03em; white-space: nowrap; pointer-events: none; }
.assistive-mic-button { position: fixed; right: 77px; top: calc(52% + 14px); z-index: 39; width: 38px; height: 38px; display: none; place-items: center; padding: 0; color: #76552a; background: rgba(255,253,249,.97); border: 2px solid #c69b59; border-radius: 50%; box-shadow: 0 7px 18px rgba(63,43,21,.25); cursor: pointer; touch-action: manipulation; transition: transform .18s ease, opacity .18s ease, background .18s ease; }
.android .assistive-mic-button { display: grid; }
.assistive-mic-button:hover, .assistive-mic-button:focus-visible { transform: scale(1.08); background: #fff; }
.assistive-mic-button.listening { color: #fff; background: #9b4038; border-color: #fff; animation: microphonePulse 1s ease-in-out infinite; }
.assistive-mic-button.is-hidden { opacity: 0; pointer-events: none; transform: scale(.65); }
.auth-card { position: relative; width: min(430px, 94vw); }
.modal-close-corner { position: absolute; top: 18px; right: 18px; }
.config-card { width: min(720px, 95vw); }
.config-section { display: flex; align-items: center; justify-content: space-between; gap: 22px; padding: 18px 0; border-top: 1px solid #e4dbcf; }
.config-section > div:first-child { min-width: 180px; }
.config-section strong { display: block; margin-bottom: 5px; font-size: 13px; }
.config-section span { display: block; color: var(--muted); font-size: 11px; line-height: 1.45; }
.config-delete-section { align-items: flex-start; }
.delete-controls { width: min(330px, 52%); display: flex; flex-direction: column; align-items: stretch; gap: 9px; }
.delete-controls select { width: 100%; height: 42px; padding: 0 11px; color: var(--ink); background: #f7f3ed; border: 1px solid #ded4c7; border-radius: 7px; outline: none; }
.config-background-section { display: flex; align-items: flex-start; }
.android .config-background-section { display: flex; }
.config-drive-section { display: flex; align-items: flex-start; }
.config-section .drive-status { display: block; margin-top: 7px; color: #9b4f46; font-size: 12px; line-height: 1.4; }
.config-section .drive-status.linked { color: #52735e; }
.api-config-controls { width: min(360px, 56%); display: flex; flex-direction: column; gap: 8px; }
.api-config-controls input { width: 100%; height: 42px; padding: 0 11px; color: var(--ink); background: #f7f3ed; border: 1px solid #ded4c7; border-radius: 7px; outline: none; font-size: 14px; }
.api-config-controls input:focus { border-color: #bc9255; box-shadow: 0 0 0 3px rgba(188,146,85,.12); }
.background-controls { width: min(330px, 52%); display: flex; flex-direction: column; align-items: stretch; gap: 9px; }
.background-controls > div { display: flex; flex-wrap: wrap; gap: 8px; }
.background-preview { width: 100%; height: 112px; object-fit: cover; border: 1px solid #d8cec0; border-radius: 9px; background: #eee7dc; }
.toast { position: fixed; left: 50%; bottom: 27px; z-index: 60; transform: translate(-50%, 20px); padding: 12px 18px; color: white; background: #4d4338; border: 1px solid #6d5c49; border-radius: 7px; font-size: 12px; opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes enter { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes modalEnter { from { opacity: 0; transform: translateY(12px) scale(.985); } to { opacity: 1; transform: none; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes microphonePulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(155,64,56,.35); } 50% { box-shadow: 0 0 0 8px rgba(155,64,56,0); } }
@keyframes turnForward { 0% { transform: rotateY(0); filter: brightness(1); } 50% { transform: rotateY(-8deg); filter: brightness(.88); } 100% { transform: rotateY(0); filter: brightness(1); } }
@keyframes turnBack { 0% { transform: rotateY(0); filter: brightness(1); } 50% { transform: rotateY(8deg); filter: brightness(.88); } 100% { transform: rotateY(0); filter: brightness(1); } }

@media (max-width: 1160px) {
  .button-secondary { width: 43px; padding: 0; font-size: 0; }
  .button-secondary .note-icon { margin: 0; font-size: 17px; }
  .header-identity { display: none; }
  .topbar { grid-template-columns: 1fr auto; }
}
@media (max-width: 880px) {
  .library-heading { align-items: flex-start; flex-direction: column; }
  .search-box { width: 100%; }
  .reader-stage { padding-left: 82px; padding-right: 82px; }
  .keyboard-hint, .reader-site { display: none; }
  .modal-card { padding: 27px; }
  .floating-notes { right: 12px; bottom: 12px; width: calc(100vw - 24px); }
  .floating-notes .notes-card { max-height: calc(100vh - 24px); padding: 19px; }
}

@media (max-width: 700px) {
  .topbar { min-height: 72px; display: flex; padding: 0 12px; }
  .brand { flex: 1; }
  .brand img { width: 118px; height: 48px; }
  .top-actions { gap: 5px; }
  #config-button { width: 40px; padding: 0; font-size: 0; }
  #config-button .gear-icon { margin: 0; font-size: 18px; }
  #fullscreen-button, #close-button, #reader-fullscreen-button, #reader-close-button { display: none; }
  .library-heading { padding: 27px 18px 25px; }
  .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 25px 18px; padding: 5px 18px 50px; }
  .reader-toolbar { min-height: 94px; display: flex; padding: 0 10px; }
  .reader-title { display: none; }
  .reader-actions { margin-left: auto; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
  .reader-stage { padding: 18px 54px 14px; }
  .page-arrow { width: 42px; height: 42px; font-size: 27px; }
  .page-arrow.prev { left: 6px; }
  .page-arrow.next { right: 6px; }
  .reader-footer { min-height: 45px; padding: 0 15px; }
  .progress-track { width: 110px; }
  .password-fields { grid-template-columns: 1fr; }
  .config-section { align-items: stretch; flex-direction: column; gap: 11px; }
  .delete-controls, .background-controls, .api-config-controls { width: 100%; }
  .android .topbar { min-height: 72px; display: flex; padding: 0 12px; }
  .android .brand { flex: 1; }
  .android .brand img { width: 118px; height: 48px; }
  .android .top-actions { gap: 5px; }
  .android #config-button { width: 40px; padding: 0; font-size: 0; }
  .android #config-button .gear-icon { margin: 0; font-size: 18px; }
  .android #notes-button, .android #reader-notes-button { display: none; }
  .android #fullscreen-button, .android #close-button, .android #reader-fullscreen-button, .android #reader-close-button { display: none; }
  .android .icon-button, .android .button-secondary { width: 40px; height: 40px; }
  .android .library-heading { padding: 27px 18px 25px; }
  .android .book-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 25px 18px; padding: 5px 18px 50px; }
  .android .reader-toolbar { min-height: 94px; display: flex; padding: 0 10px; }
  .android .reader-title { display: none; }
  .android .reader-actions { width: 235px; margin-left: auto; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
  .android .reader-stage { padding: 18px 54px 14px; }
  .android .page-arrow { width: 42px; height: 42px; font-size: 27px; }
  .android .page-arrow.prev { left: 6px; }
  .android .page-arrow.next { right: 6px; }
  .android .reader-footer { min-height: 45px; padding: 0 15px; }
  .android .progress-track { width: 110px; }
  .android .floating-notes { width: min(310px, calc(100vw - 64px)); right: 10px; bottom: 10px; }
  .android .floating-notes .notes-card { max-height: min(405px, calc(100vh - 96px)); }
  .android .assistive-order-button { width: 60px; height: 60px; right: 12px; }
  .android .password-fields { grid-template-columns: 1fr; }
  .android .config-section { align-items: stretch; flex-direction: column; gap: 11px; }
  .android .delete-controls { width: 100%; }
}
