:root {
  color-scheme: light;
  --ink: #282c26;
  --muted: #85877e;
  --paper: #fffefa;
  --canvas: #f4f1e9;
  --line: #e8e5dc;
  --green: #64745a;
  --green-dark: #4f6047;
  --orange: #df845e;
  --serif: "Newsreader", Georgia, serif;
  --sans: "DM Sans", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  height: 76px;
  padding: 0 6.2%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(40, 44, 38, .08);
}
.brand { display: inline-flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: -.04em; font-size: 19px; }
.brand-mark { display: grid; place-items: center; width: 31px; height: 31px; border-radius: 50% 50% 45% 50%; background: var(--green); color: white; font: 600 19px var(--serif); letter-spacing: -.08em; }
.topbar-actions { display: flex; align-items: center; gap: 24px; }
.topbar-note { display: flex; gap: 9px; align-items: center; color: var(--muted); font-size: 12px; }
.upload-top-button { min-height: 35px; padding: 0 12px; display: inline-flex; align-items: center; gap: 7px; border: 1px solid #dcd9cf; border-radius: 4px; background: #fbfaf6; color: var(--green-dark); font-size: 12px; font-weight: 600; cursor: pointer; }
.upload-top-button:hover { background: #e8e9e0; }
.upload-top-button > span { font-size: 16px; line-height: 1; }
.privacy-dot { width: 7px; height: 7px; border-radius: 100%; background: #8a9b74; display: inline-block; flex: 0 0 auto; }

main { flex: 1; }
.welcome { width: min(1060px, 88%); margin: 76px auto 0; display: grid; grid-template-columns: 1.1fr .9fr; align-items: center; position: relative; }
.welcome-copy { padding: 0 0 65px 5px; }
.eyebrow { color: var(--green); font-size: 10px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; }
h1 { margin: 23px 0 17px; font: 500 clamp(45px, 5.8vw, 72px)/.99 var(--serif); letter-spacing: -.045em; }
h1 em { color: var(--green); font-weight: 400; }
.welcome-copy > p { max-width: 405px; color: #77796f; font: 16px/1.7 var(--sans); margin: 0 0 29px; }
.upload-button { min-height: 49px; padding: 0 20px; display: inline-flex; justify-content: center; align-items: center; gap: 10px; border-radius: 5px; background: var(--green); color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .2s, transform .2s; }
.upload-button:hover { background: var(--green-dark); transform: translateY(-1px); }
.upload-button > span { font-size: 20px; font-weight: 400; }
.upload-button > #upload-label-text { font-size: 13px; font-weight: 600; }
.upload-button.is-loading { opacity: .7; cursor: wait; pointer-events: none; }
.upload-button.is-loading:hover { background: var(--green); transform: none; }
.upload-hint { display: block; color: #96978f; font-size: 11px; margin-top: 12px; }

.book-art { height: 335px; position: relative; display: grid; place-items: center; }
.art-sun { position: absolute; width: 228px; height: 228px; border-radius: 50%; background: #e9e1d0; top: 18px; left: 50%; transform: translateX(-47%); }
.art-book { width: 202px; height: 264px; background: #c87859; position: relative; transform: rotate(5deg); box-shadow: 13px 16px 0 #e4b28e, 19px 22px 24px #a99d8666; border-radius: 2px 8px 8px 2px; padding: 39px 28px; color: #fff5e8; }
.art-book-spine { position: absolute; left: 13px; top: 0; bottom: 0; width: 2px; background: #a95f44; }
.art-book > span { font: 500 23px/.98 var(--serif); letter-spacing: .025em; position: absolute; top: 79px; left: 31px; }
.art-book > b { position: absolute; right: 30px; bottom: 25px; font-size: 29px; font-weight: 400; }
.art-lines { display: flex; gap: 5px; }
.art-lines i { display: block; width: 15px; height: 2px; background: #efcdb5; }
.art-caption { position: absolute; right: 4%; bottom: 11px; color: #8e8e81; font-size: 8px; font-weight: 700; line-height: 1.8; letter-spacing: .15em; transform: rotate(5deg); }
.feature-row { grid-column: 1 / -1; border-top: 1px solid #e1ded5; display: flex; justify-content: space-between; padding: 22px 5px 0; margin-top: 15px; color: #6f7168; font-size: 11px; }
.feature-row > div { display: flex; align-items: center; gap: 11px; }
.feature-icon { color: var(--orange); font: 500 12px var(--serif); }

.site-footer { padding: 21px 6.2%; text-align: center; color: #999a91; font-size: 10px; letter-spacing: .02em; }
.site-footer span { color: var(--orange); margin-left: 4px; }

.reader { min-height: calc(100vh - 116px); display: grid; grid-template-columns: 260px 1fr; }
.sidebar { min-height: 100%; padding: 35px 24px 24px 30px; background: #eeece4; border-right: 1px solid #e5e2d9; display: flex; flex-direction: column; }
.sidebar-heading { display: flex; align-items: center; justify-content: space-between; }
.icon-button { background: none; border: 1px solid #dcdbd2; border-radius: 50%; width: 31px; height: 31px; cursor: pointer; color: #666b60; }
.icon-button:hover, .round-button:hover { background: #e8e7de; }
.book-title { margin: 23px 0 6px; font: 500 25px/1.1 var(--serif); overflow-wrap: anywhere; }
.book-meta { font-size: 11px; color: var(--muted); margin: 0; }
.sidebar-rule { height: 1px; background: #dedbd1; margin: 25px 0 22px; }
.contents-label { color: #9a9b91; font-size: 9px; font-weight: 700; letter-spacing: .13em; display: flex; justify-content: space-between; }
.chapter-list { margin: 14px -9px 0; overflow: auto; max-height: min(55vh, 520px); }
.chapter-item { display: block; text-align: left; width: 100%; padding: 11px 10px; border: 0; border-radius: 4px; background: none; color: #64675f; cursor: pointer; font-size: 12px; line-height: 1.4; }
.chapter-item:hover { background: #e8e6dd; }
.chapter-item.active { background: #e2e4d9; color: #4e6046; font-weight: 600; }
.chapter-item small { display: block; color: #a0a197; font-size: 10px; margin-top: 3px; font-weight: 400; }
.sidebar-bottom { margin-top: auto; padding-top: 26px; display: flex; align-items: flex-start; gap: 9px; color: #99998e; font-size: 10px; line-height: 1.6; }
.sidebar-bottom .privacy-dot { margin-top: 4px; }

.reading-area { min-width: 0; min-height: calc(100vh - 116px); display: flex; flex-direction: column; }
.reader-toolbar { min-height: 66px; padding: 0 4.3%; border-bottom: 1px solid #e8e5dc; display: flex; align-items: center; justify-content: space-between; gap: 15px; }
.breadcrumb { font-size: 11px; color: #62655c; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumb-divider { margin: 0 9px; color: #b0afa5; }
.page-tools { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.text-button { padding: 8px 9px; border: 0; background: none; color: #72766a; cursor: pointer; font-size: 10px; }
.text-button:hover { color: var(--green-dark); }
.toolbar-divider { width: 1px; height: 20px; background: #deddd4; margin: 0 5px; }
.round-button { width: 29px; height: 29px; border: 1px solid #e2e0d7; border-radius: 50%; background: transparent; cursor: pointer; font-size: 14px; }
.page-counter { color: #999a91; font-size: 10px; white-space: nowrap; }
.page-counter input { width: 31px; border: 0; background: transparent; text-align: right; color: #5a5e54; outline: none; font-size: 11px; }
.page-counter input::-webkit-inner-spin-button { appearance: none; }
.paper-wrap { flex: 1; overflow: auto; padding: 35px 30px 28px; display: flex; justify-content: center; align-items: flex-start; }
.paper { width: min(720px, 100%); min-height: 490px; position: relative; background: var(--paper); padding: 57px clamp(28px, 7vw, 86px) 67px; box-shadow: 0 3px 20px #38372a0a; }
.paper-kicker { font-size: 9px; color: #b0ad9f; letter-spacing: .17em; font-weight: 700; margin-bottom: 35px; }
.paper-text { font: 18px/1.85 var(--serif); color: #3d4038; white-space: pre-wrap; overflow-wrap: anywhere; }
.paper-text.empty-page { color: #a2a197; font: 14px/1.7 var(--sans); }
.paper-footer { position: absolute; bottom: 25px; left: clamp(28px, 7vw, 86px); right: clamp(28px, 7vw, 86px); display: flex; justify-content: space-between; color: #b5b2a7; font-size: 8px; letter-spacing: .13em; }
.reader-bottom { padding: 14px 4.3%; background: #f8f6f0; border-top: 1px solid #e8e5dc; display: flex; justify-content: space-between; align-items: center; gap: 18px; }
.playback { display: flex; align-items: center; gap: 13px; min-width: 0; }
.play-button { min-height: 38px; padding: 0 15px; display: inline-flex; align-items: center; gap: 9px; border: 0; border-radius: 4px; background: var(--green); color: white; font-size: 11px; cursor: pointer; white-space: nowrap; }
.play-button:hover:not(:disabled) { background: var(--green-dark); }
.play-button:disabled, .chapter-play:disabled, .stop-button:disabled { opacity: .45; cursor: not-allowed; }
.play-symbol { font-size: 9px; }
.stop-button, .chapter-play { border: 0; background: none; color: #73776d; cursor: pointer; font-size: 10px; white-space: nowrap; }
.chapter-play { color: var(--green-dark); }
.playback-separator { height: 21px; width: 1px; background: #e1ded5; }
.playback-status { max-width: 110px; color: #96978e; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.voice-controls { display: flex; align-items: center; gap: 9px; color: #999a91; font-size: 8px; letter-spacing: .1em; white-space: nowrap; }
.voice-controls select { max-width: 150px; border: 1px solid #e4e1d8; border-radius: 3px; padding: 6px 20px 6px 7px; background: #fffefa; color: #64675f; font-size: 10px; letter-spacing: 0; }
.voice-controls input[type="range"] { width: 76px; accent-color: var(--green); }
.speed-value { width: 20px; color: #76786e; font-size: 10px; letter-spacing: 0; }

.drop-overlay { position: fixed; inset: 15px; z-index: 5; border: 2px dashed var(--green); border-radius: 12px; background: #f4f1e9ed; display: grid; place-items: center; color: var(--green-dark); font: 500 32px var(--serif); pointer-events: none; }
.toast { position: fixed; z-index: 10; left: 50%; bottom: 28px; transform: translateX(-50%); max-width: min(500px, 90vw); padding: 12px 17px; border-radius: 5px; color: white; background: #343b32; font-size: 12px; box-shadow: 0 5px 20px #0002; }

@media (max-width: 850px) {
  .reader { grid-template-columns: 210px 1fr; }
  .sidebar { padding-left: 20px; padding-right: 17px; }
  .reader-bottom { align-items: flex-start; flex-direction: column; }
  .voice-controls { align-self: flex-end; }
}
@media (max-width: 620px) {
  .topbar { height: 63px; padding: 0 6%; }
  .topbar-actions { gap: 10px; }
  .topbar-note { font-size: 10px; }
}
@media (max-width: 420px) {
  .topbar-note { display: none; }
  .upload-top-button { min-height: 33px; }
}
@media (max-width: 620px) {
  .welcome { width: 88%; margin-top: 45px; grid-template-columns: 1fr; }
  .welcome-copy { padding-bottom: 8px; }
  h1 { font-size: clamp(48px, 13vw, 68px); }
  .book-art { height: 290px; margin-top: 15px; }
  .art-book { transform: scale(.88) rotate(5deg); }
  .feature-row { gap: 13px; flex-wrap: wrap; margin-top: 20px; }
  .feature-row > div { font-size: 10px; }
  .reader { display: flex; flex-direction: column; min-height: calc(100vh - 100px); }
  .sidebar { min-height: 0; padding: 16px 18px 12px; border-right: 0; border-bottom: 1px solid #e1ded5; }
  .sidebar-heading { display: none; }
  .book-title { margin: 0 0 4px; font-size: 20px; }
  .sidebar-rule, .sidebar-bottom { display: none; }
  .contents-label { margin-top: 14px; }
  .chapter-list { display: flex; gap: 6px; margin: 7px 0 0; max-height: none; overflow-x: auto; }
  .chapter-item { flex: 0 0 auto; width: auto; padding: 7px 9px; background: #e8e6dd; font-size: 10px; white-space: nowrap; }
  .chapter-item small { display: none; }
  .reader-toolbar { min-height: 57px; padding: 0 15px; }
  .text-button { font-size: 0; width: 30px; }
  .text-button::first-letter { font-size: 15px; }
  .toolbar-divider { margin: 0; }
  .page-tools { gap: 5px; }
  .paper-wrap { padding: 16px 12px; }
  .paper { min-height: 60vh; padding: 35px 25px 55px; }
  .paper-text { font-size: 17px; }
  .paper-footer { left: 25px; right: 25px; }
  .reader-bottom { padding: 12px 15px; gap: 10px; }
  .playback { gap: 9px; flex-wrap: wrap; }
  .playback-status { display: none; }
  .voice-controls { align-self: flex-start; flex-wrap: wrap; }
  .voice-controls select { max-width: 125px; }
  .site-footer { padding: 15px; }
}

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