:root {
  --ink: #151515;
  --paper: #ebe7dc;
  --coral: #ff6c4b;
  --lime: #c8f542;
  --panel: #3d3d3d;
  --muted: #717171;
  --line: #505050;
  --white: #d9d9d9;
  --display: "Mavora Sans", "Arial Black", "Helvetica Neue", Arial, sans-serif;
  --body: Inter, "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --wordmark: Rosseti, "Bodoni 72 Smallcaps", Georgia, serif;
  background: var(--ink);
  color: var(--white);
  font-family: var(--body);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; margin: 0; overscroll-behavior: none; }
body { min-height: 100dvh; background: var(--ink); }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { display: block; }
[hidden] { display: none !important; }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }

.pilcrow-app {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  overflow: clip;
  background: var(--ink);
}

.pilcrow-header {
  display: grid;
  grid-template-columns: minmax(56px, 1fr) auto minmax(33px, 1fr);
  align-items: center;
  gap: 14px;
  min-height: 103px;
  padding: calc(env(safe-area-inset-top) + 18px) 25px 18px;
}
.wordmark {
  margin: 0;
  color: white;
  font-family: var(--wordmark);
  font-size: 24px;
  font-weight: 300;
  letter-spacing: -1.4px;
  line-height: .75;
  white-space: nowrap;
}
.space-switcher {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: min(188px, 47vw);
  min-height: 33px;
  padding: 3px;
  border-radius: 24px;
  background: var(--panel);
}
.switcher-choice {
  display: grid;
  min-height: 27px;
  place-items: center;
  border-radius: 22px;
  color: var(--white);
  font-family: var(--display);
  font-size: 12px;
  font-weight: 400;
  letter-spacing: -.12px;
  line-height: .85;
}
.switcher-choice.is-active { color: var(--ink); background: var(--coral); }
.avatar-mark { position: relative; justify-self: end; width: 33px; height: 33px; }
.avatar-ring, .avatar-user { position: absolute; inset: 0; width: 100%; height: 100%; }
.avatar-user { inset: 7px; width: 19px; height: 19px; }

.bookspace-hero { position: relative; padding: 162px 41px 60px; }
.bookspace-hero h1,
.reader-library h1 {
  max-width: 341px;
  margin: 0;
  color: var(--white);
  font-family: var(--display);
  font-size: clamp(42px, 12.2vw, 48px);
  font-weight: 800;
  letter-spacing: -1.1px;
  line-height: .83;
}
.bookspace-hero h1 { max-width: 310px; }
.bookspace-hero p {
  max-width: 260px;
  margin: 20px 0 0;
  color: rgb(217 217 217 / 50%);
  font-size: 14px;
  line-height: 1.45;
}
.bookspace-heart { position: absolute; top: 62px; right: 54px; width: 75px; height: 69px; }
.bookspace-underline { width: 115px; height: 17px; margin: 16px 0 0; }

.library-screen { display: flex; min-height: 100dvh; flex-direction: column; }
.reader-library { padding: 10px 33px 0; }
.reader-intro { margin: 16px 4px 22px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.reader-intro strong { color: var(--coral); font-weight: 800; }
.reader-intro span { color: var(--muted); }
.library-filters { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; margin: 0 0 14px; }
.library-filters button { min-height: 30px; padding: 0 5px; border: 1px solid #505050; border-radius: 16px; background: #242424; color: #aaa; font-size: 11px; line-height: 1; }
.library-filters button.is-active { border-color: var(--lime); background: var(--lime); color: var(--ink); font-family: var(--display); font-weight: 800; }
.featured-book-card {
  position: relative;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  column-gap: 16px;
  min-height: 159px;
  padding: 16px;
  border: 1px solid #5d5d5d;
  border-radius: 26px;
  background: var(--panel);
  color: var(--white);
  text-align: left;
}
.featured-book-card > .book-open { position: absolute; inset: 0; z-index: 0; border: 0; border-radius: inherit; background: transparent; }
.book-cover, .cover-fallback { position: relative; z-index: 1; width: 96px; height: 128px; border-radius: 12px; object-fit: cover; background: #717171; }
.cover-fallback { display: grid; place-items: center; color: var(--white); font-size: 11px; font-weight: 800; letter-spacing: .12em; }
.featured-book-copy { position: relative; z-index: 1; display: flex; min-width: 0; min-height: 128px; flex-direction: column; padding: 4px 0 21px; pointer-events: none; }
.featured-book-copy h2 { display: -webkit-box; overflow: hidden; margin: 0; color: var(--white); font-family: var(--display); font-size: 14px; font-weight: 800; letter-spacing: -.38px; line-height: 1.08; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.featured-book-copy p { overflow: hidden; margin: 5px 0 0; color: #a9a9a9; font-size: 10px; line-height: 1.15; text-overflow: ellipsis; white-space: nowrap; }
.book-meta { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: auto; pointer-events: auto; }
.book-status-chip { min-height: 36px; padding: 0 14px; border: 0; border-radius: 18px; background: var(--ink); color: var(--lime); font-family: var(--display); font-size: 14px; font-weight: 800; letter-spacing: -.2px; }
.book-status-chip[data-status="want"] { color: var(--coral); }
.book-status-chip[data-status="finished"] { color: var(--white); }
.book-percent { color: var(--white); font-family: var(--display); font-size: 18px; font-weight: 800; }
.progress-track { position: absolute; z-index: 1; right: 51px; bottom: 17px; left: 128px; height: 10px; margin: 0; overflow: hidden; border-radius: 10px; background: #717171; pointer-events: none; }
.progress-fill { height: 100%; border-radius: inherit; background: var(--lime); }
.progress-fill[data-status="want"] { background: var(--coral); }
.progress-fill[data-status="finished"] { background: var(--white); }
.status-menu {
  position: absolute;
  z-index: 5;
  right: 54px;
  bottom: -66px;
  display: grid;
  min-width: 148px;
  gap: 0;
  padding: 10px 0;
  border: 1px solid #505050;
  border-radius: 12px;
  background: var(--ink);
  box-shadow: 0 14px 30px rgb(0 0 0 / 30%);
}
.status-menu button { min-height: 28px; padding: 0 13px; border: 0; background: transparent; color: var(--white); font-size: 12px; text-align: left; }
.status-menu button.is-active { color: var(--lime); font-family: var(--display); font-weight: 800; }
.status-menu .remove-book { margin-top: 5px; color: var(--coral); }
.library-list { display: grid; gap: 10px; margin-top: 12px; }
.library-card { display: grid; grid-template-columns: 46px minmax(0, 1fr) auto; align-items: center; gap: 10px; padding: 10px; border: 1px solid #505050; border-radius: 16px; background: #252525; }
.library-card .book-cover, .library-card .cover-fallback { width: 46px; height: 62px; border-radius: 8px; }
.library-card-copy { min-width: 0; }
.library-card-copy h2 { overflow: hidden; margin: 0; font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.library-card-copy p { overflow: hidden; margin: 4px 0 0; color: var(--muted); font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.library-card button { min-height: 34px; padding: 0 12px; border: 0; border-radius: 18px; background: var(--coral); color: var(--ink); font-weight: 800; }
.library-empty { margin-top: 22px; color: var(--muted); font-size: 14px; }
.library-empty p { margin: 0; }
.reader-footer { display: grid; gap: 16px; margin-top: auto; padding: 30px 26px calc(env(safe-area-inset-bottom) + 31px); text-align: center; }
.add-book-button { min-height: 56px; border: 0; border-radius: 32px; background: var(--coral); color: var(--ink); font-family: var(--display); font-size: 21px; font-weight: 600; letter-spacing: -.45px; }
.reader-footer p { margin: 0; color: var(--muted); font-size: 13px; }

.reader-shell {
  --reader-paper: #ebe7dc;
  --reader-ink: #151515;
  --reader-muted: #77736b;
  --reader-control: #151515;
  --reader-control-ink: #d9d9d9;
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  min-height: 100dvh;
  flex-direction: column;
  background: var(--reader-paper);
  color: var(--reader-ink);
  transition: background .18s ease, color .18s ease;
}
.reader-shell[data-theme="light"] { --reader-paper: #fbfbf8; --reader-ink: #151515; --reader-muted: #77736b; --reader-control: #151515; --reader-control-ink: #f7f7f3; }
.reader-shell[data-theme="black"] { --reader-paper: #151515; --reader-ink: #f4f0e7; --reader-muted: #b6b1a9; --reader-control: #f4f0e7; --reader-control-ink: #151515; color-scheme: dark; }
.reading-header { position: relative; z-index: 5; display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; min-height: 91px; padding: calc(env(safe-area-inset-top) + 13px) 28px 15px; background: var(--ink); color: var(--white); transition: min-height .16s ease, padding .16s ease, opacity .16s ease; }
.reading-back { display: grid; width: 28px; height: 28px; padding: 0; border: 0; place-items: center; background: transparent; }
.reading-back img { width: 28px; height: 28px; }
.reading-title { overflow: hidden; margin: 0; color: var(--white); font-family: var(--display); font-size: 15px; font-weight: 800; letter-spacing: -.3px; line-height: 1.05; text-overflow: ellipsis; white-space: nowrap; }
.reading-percent { margin: 0; color: var(--white); font-family: var(--display); font-size: 24px; font-weight: 800; letter-spacing: -.7px; }
.reading-author { position: absolute; top: calc(env(safe-area-inset-top) + 49px); left: 64px; overflow: hidden; max-width: calc(100% - 152px); margin: 0; color: rgb(217 217 217 / 56%); font-size: 9px; line-height: 1; text-overflow: ellipsis; white-space: nowrap; }
.reader-controls-hidden .reading-header { min-height: 0; height: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; opacity: 0; pointer-events: none; }
.reader-stage { position: relative; min-height: 0; flex: 1; overflow: hidden; background: var(--reader-paper); }
foliate-view, .epub-reader { display: block; width: 100%; height: 100%; min-height: 100%; background: var(--reader-paper); }
.epub-reader iframe { border: 0; }
.epub-reader .epub-container { -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.epub-reader[data-mode="pages"] .epub-container { overflow: hidden !important; touch-action: pan-x; }
.fb2-reader { width: 100%; height: 100%; overflow-y: auto; padding: 12px 44px 110px; color: var(--reader-ink); background: var(--reader-paper); font: 20px/1.62 var(--body); -webkit-overflow-scrolling: touch; }
.fb2-reader p { margin: 0 0 1em; }
.reader-loading { position: absolute; inset: 0; display: grid; place-items: center; margin: 0; color: var(--reader-muted); font-size: 14px; pointer-events: none; }
.page-mode-hint { position: absolute; z-index: 2; right: 50%; bottom: 9px; width: max-content; max-width: calc(100% - 30px); margin: 0; padding: 6px 10px; border-radius: 14px; transform: translateX(50%); background: rgb(0 0 0 / 14%); color: var(--reader-muted); font-size: 11px; pointer-events: none; }
.page-turn-zones { position: absolute; z-index: 3; inset: 0; display: grid; grid-template-columns: 1fr .9fr 1fr; }
.page-turn-zones button { min-width: 0; padding: 0; border: 0; background: transparent; touch-action: none; -webkit-tap-highlight-color: transparent; }
.reader-center-tap-zone { position: absolute; z-index: 4; top: 31%; left: 50%; width: min(44%, 180px); height: 38%; padding: 0; border: 0; transform: translateX(-50%); background: transparent; touch-action: none; -webkit-tap-highlight-color: transparent; }
.reader-homebar { position: relative; z-index: 5; display: grid; grid-template-columns: 1fr 1fr; gap: 11px 15px; padding: 14px 66px calc(env(safe-area-inset-bottom) + 15px); border-radius: 27px 27px 0 0; background: var(--ink); color: var(--white); transition: max-height .16s ease, padding .16s ease, opacity .16s ease; }
.reader-page-meta { grid-column: 1 / -1; display: grid; justify-items: center; gap: 3px; min-width: 0; }
.reader-page-meta strong { color: var(--white); font-family: var(--display); font-size: 15px; font-weight: 800; line-height: 1; }
.reader-page-meta span { overflow: hidden; max-width: 100%; color: rgb(217 217 217 / 86%); font-size: 12px; line-height: 1.15; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.reader-homebar button { min-width: 0; min-height: 39px; padding: 0 10px; border: 0; border-radius: 22px; background: var(--coral); color: var(--ink); font-size: 16px; }
.reader-homebar button:hover, .reader-homebar button:focus-visible { outline: 0; filter: brightness(.94); }
.reader-controls-hidden .reader-homebar { max-height: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; opacity: 0; pointer-events: none; }

.reader-sheet-layer { position: absolute; z-index: 6; inset: 0; display: flex; align-items: flex-end; }
.reader-sheet-backdrop { position: absolute; inset: 0; border: 0; background: rgb(0 0 0 / 34%); }
.reader-sheet { position: relative; width: 100%; max-height: min(76dvh, 660px); overflow-y: auto; padding: 24px 22px calc(env(safe-area-inset-bottom) + 25px); border: 1px solid #565656; border-bottom: 0; border-radius: 28px 28px 0 0; background: #202020; color: #f3f2ed; box-shadow: 0 -20px 55px rgb(0 0 0 / 28%); -webkit-overflow-scrolling: touch; }
.reader-sheet-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 23px; }
.reader-sheet-kicker { margin: 0 0 4px; color: #9b9b9b; font-size: 12px; letter-spacing: .02em; }
.reader-sheet h2 { margin: 0; color: #f3f2ed; font-family: var(--display); font-size: 28px; font-weight: 800; letter-spacing: -.8px; line-height: .96; }
.reader-sheet-close { display: grid; width: 36px; height: 36px; padding: 0; border: 1px solid #5d5d5d; border-radius: 50%; place-items: center; background: transparent; color: #f3f2ed; font-size: 26px; line-height: 1; }
.settings-group { margin: 0 0 25px; }
.settings-label, .settings-field > span, .settings-range > span { display: block; margin: 0 0 10px; color: #f3f2ed; font-family: var(--display); font-size: 16px; font-weight: 800; letter-spacing: -.25px; }
.theme-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.theme-options button { min-height: 42px; border: 1px solid #616161; border-radius: 22px; background: #373737; color: #e9e7e1; font-size: 13px; }
.theme-options button[data-reader-theme="warm"] { background: #ebe7dc; color: #151515; }
.theme-options button[data-reader-theme="light"] { background: #fbfbf8; color: #151515; }
.theme-options button[data-reader-theme="black"] { background: #101010; color: #f3f2ed; }
.theme-options button.is-active { outline: 2px solid var(--coral); outline-offset: 2px; }
.mode-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.mode-options button { min-height: 42px; border: 1px solid #616161; border-radius: 22px; background: #373737; color: #e9e7e1; font-size: 13px; }
.mode-options button span { color: #bdbbb5; font-size: 10px; }
.mode-options button.is-active { border-color: var(--coral); background: var(--coral); color: #151515; font-weight: 800; }
.mode-options button.is-active span { color: #151515; }
.settings-field, .settings-range { display: grid; margin: 0 0 22px; }
.settings-field select { width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid #616161; border-radius: 13px; background: #373737; color: #f3f2ed; font-size: 15px; }
.settings-range { grid-template-columns: 1fr auto; gap: 0 10px; }
.settings-range input { grid-column: 1 / -1; width: 100%; height: 22px; accent-color: var(--coral); }
.settings-range output { color: #bfbfba; font-size: 13px; }
.settings-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 4px 0 24px; padding: 15px 0; border-top: 1px solid #4b4b4b; border-bottom: 1px solid #4b4b4b; }
.settings-switch-row p { margin: 0 0 3px; color: #f3f2ed; font-family: var(--display); font-size: 16px; font-weight: 800; }
.settings-switch-row span { color: #a6a6a0; font-size: 12px; }
.settings-switch { width: 49px; height: 30px; padding: 3px; border: 0; border-radius: 16px; background: #616161; transition: background .16s ease; }
.settings-switch span { display: block; width: 24px; height: 24px; border-radius: 50%; background: #f3f2ed; transition: transform .16s ease; }
.settings-switch[aria-checked="true"] { background: var(--coral); }
.settings-switch[aria-checked="true"] span { transform: translateX(19px); }
.reset-settings { width: 100%; min-height: 44px; border: 1px solid #656565; border-radius: 22px; background: transparent; color: #d8d6cf; font-size: 14px; }
.contents-list { display: grid; gap: 8px; }
.contents-list p { margin: 0; color: #a6a6a0; font-size: 14px; line-height: 1.45; }
.contents-list button { width: 100%; min-height: 48px; padding: 10px 14px; border: 0; border-radius: 12px; background: #3d3d3d; color: #f3f2ed; font-size: 15px; line-height: 1.22; text-align: left; }
.contents-list button[data-level="1"] { padding-left: 27px; color: #c9c8c2; font-size: 14px; }
.contents-list button[data-level="2"] { padding-left: 40px; color: #aaa9a4; font-size: 13px; }

.import-dialog { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 26px; }
.import-backdrop { position: absolute; inset: 0; background: rgb(0 0 0 / 82%); }
.import-card { position: relative; z-index: 1; display: grid; grid-template-columns: 102px minmax(0, 1fr); gap: 22px; width: min(100%, 346px); min-height: 170px; padding: 17px; border: 1px solid #717171; border-radius: 28px; background: #3d3d3d; color: var(--white); }
.import-cover .book-cover, .import-cover .cover-fallback { width: 102px; height: 137px; border-radius: 14px; }
.import-copy { display: flex; min-width: 0; flex-direction: column; padding-top: 13px; }
.import-copy h2 { overflow: hidden; margin: 0; font-family: var(--display); font-size: 28px; font-weight: 800; letter-spacing: -1px; line-height: .95; text-overflow: ellipsis; white-space: nowrap; }
.import-copy p { overflow: hidden; margin: 7px 0 0; color: #a9a9a9; font-size: 17px; text-overflow: ellipsis; white-space: nowrap; }
.import-read { min-height: 53px; margin-top: auto; border: 0; border-radius: 28px; background: var(--coral); color: var(--ink); font-size: 21px; }
.import-close { position: absolute; top: 11px; right: 14px; width: 30px; height: 30px; padding: 0; border: 0; background: transparent; color: var(--white); font-size: 29px; font-weight: 300; line-height: 1; }
.reader-toast { position: fixed; z-index: 20; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 14px); width: max-content; max-width: calc(100% - 40px); margin: 0; padding: 9px 14px; border-radius: 20px; transform: translateX(-50%); background: rgb(21 21 21 / 92%); color: var(--white); font-size: 12px; line-height: 1.25; text-align: center; opacity: 0; pointer-events: none; transition: opacity .2s ease; }
.reader-toast.is-visible { opacity: 1; }
.reader-toast[data-kind="error"] { color: #ffb0a0; }

@media (min-width: 720px) {
  body { padding: 22px; }
  .pilcrow-app { width: 390px; min-height: 844px; margin: 0 auto; border-radius: 32px; box-shadow: 0 20px 80px rgb(0 0 0 / 35%); }
  .library-screen, .reader-shell { min-height: 844px; }
  .import-dialog { position: absolute; border-radius: 32px; }
}
@media (max-width: 360px) {
  .pilcrow-header { padding-inline: 18px; gap: 8px; }
  .reader-library { padding-inline: 25px; }
  .featured-book-card { grid-template-columns: 78px minmax(0, 1fr); }
  .book-cover, .cover-fallback { width: 78px; height: 112px; }
  .featured-book-copy { min-height: 112px; padding-bottom: 17px; }
  .featured-book-copy h2 { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; } }
