.topbar { background: #fdfdff; }
.brand-symbol { background: var(--accent); }
.connection-note { margin: 0 0 14px; padding: 7px 11px; border: 1px solid #e9ddfa; background: #f5effc; color: #5e4783; font-size: .83rem; }
.startup-label { display: grid; place-items: center; min-height: 65vh; color: var(--muted); }
.book-link .cover { }

.auth-layout { display: grid; grid-template-columns: minmax(0, 1.08fr) minmax(0, 1fr); max-width: 960px; margin: 14px auto; overflow: hidden; border: 1px solid var(--line); box-shadow: 0 18px 48px #322b5312; background: var(--surface); }
.auth-form.form-panel { gap: 12px; padding: clamp(18px, 4vw, 48px); border: 0; }
.auth-form h1 { font: 700 clamp(2rem, 4.2vw, 3.2rem)/1.08 var(--sans); letter-spacing: -.045em; }
.auth-form > p { color: var(--muted); font-size: .93rem; }
.auth-form form { display: grid; gap: 11px; }
.auth-form form .button { width: 100%; margin-top: 3px; }
.auth-switch a { color: var(--accent-ink); font-weight: 800; }
.auth-switch a:hover { text-decoration: underline; }
.auth-art {
  position: relative;
  isolation: isolate;
  display: grid;
  place-items: center;
  overflow: hidden;
  min-height: 100%;
  background: radial-gradient(ellipse at 50% 40%, #60498c, #32284e 60%, #232339);
}
.auth-art::before { content: ''; position: absolute; z-index: -1; width: 112%; height: 58%; border: 1px solid #dfc9ff74; border-radius: 50%; transform: rotate(-25deg); box-shadow: 0 0 0 21px #fcf0ff0c, 0 0 0 22px #dfc9ff48; }
.auth-art .cover { position: absolute; width: min(47%, 188px); box-shadow: 0 12px 28px #160f29a0; }
.auth-art .cover:nth-of-type(1) { z-index: 1; transform: translate(-28%, -12%) rotate(-13deg); }
.auth-art .cover:nth-of-type(2) { transform: translate(39%, 12%) rotate(13deg); }
.auth-art .star { background: #decaff; }
.role-options { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; border: 0; padding: 0; min-width: 0; margin: 1px 0 0; }
.role-options legend { padding: 0; margin-bottom: 5px; font-size: .87rem; font-weight: 750; }
.role-options .access-choice { min-height: 66px; }
.auth-callout, .import-local {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 0 0 17px;
  padding: 13px;
  border: 1px solid #e7ddf4;
  background: #f8f4fc;
}
.auth-callout p, .import-local p { color: var(--muted); font-size: .85rem; }
.auth-callout .row-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.import-local { margin: 17px 0 0; }
.account-preferences .muted-link { color: #795164; }

.reader {
  --paper-bg: #fffefa;
  --page-shadow: #261c3d20;
  --page-font: var(--serif);
  --line-room: 1.64;
}
.reader[data-font="sans"] { --page-font: var(--sans); }
.reader[data-spacing="compact"] { --line-room: 1.43; }
.reader[data-spacing="wide"] { --line-room: 1.88; }
.reader[data-theme="sepia"] { --paper-bg: #fbf0da; }
.reader[data-theme="night"] { --paper-bg: #2b2531; --page-shadow: #09070e80; }
.reader-bar { padding-top: var(--safe-top); }
.reader-bar-inner { --reader-bar-gutter: 24px; padding-inline: max(var(--reader-bar-gutter), var(--safe-left)) max(var(--reader-bar-gutter), var(--safe-right)); }
.reader-scroll .reading-content { width: min(100% - 2 * max(21px, var(--safe-left), var(--safe-right)), 680px); padding-bottom: calc(70px + var(--safe-bottom)); }
.reader .reading-text { font: 400 var(--reader-size)/var(--line-room) var(--page-font); }
.reader .reader-tools .icon-button { color: var(--reading-accent); }
.reader .reader-tools .icon-button:hover { background: color-mix(in srgb, var(--reading-accent) 14%, transparent); }
.reader-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}
.reader-page .reader-bar { flex: none; position: static; }
.page-stage {
  --page-stage-gutter: clamp(10px, 2vw, 24px);
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 48px minmax(0, 800px) 48px;
  grid-template-rows: minmax(0, 1fr);
  justify-content: center;
  align-items: center;
  min-height: 0;
  padding-block: clamp(9px, 2.15vh, 26px);
  padding-inline: max(var(--page-stage-gutter), var(--safe-left)) max(var(--page-stage-gutter), var(--safe-right));
  gap: clamp(6px, 1.7vw, 20px);
}
.page-surface {
  position: relative;
  align-self: stretch;
  min-width: 0;
  min-height: 0;
  padding: clamp(16px, 4.6vh, 46px) clamp(20px, 6.4vw, 95px);
  border: 1px solid var(--reading-edge);
  background: var(--paper-bg);
  box-shadow: 0 8px 25px var(--page-shadow), inset 3px 0 0 color-mix(in srgb, var(--reading-edge) 55%, transparent);
  touch-action: pan-y pinch-zoom;
}
.page-fit { display: flow-root; height: 100%; min-height: 0; overflow: hidden; }
.page-fit p { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }
.page-fit p + p { margin-top: .82em; }
.page-measure { position: absolute; top: 0; left: 0; visibility: hidden; pointer-events: none; }
.page-fit .chapter-heading { margin: 0 0 clamp(14px, 3.4vh, 30px); }
.page-fit .reading-kicker { font-size: .72rem; }
.page-fit h1 {
  margin-top: 8px;
  text-align: center;
  font: 680 clamp(1.36rem, min(5vw, 5.1vh), 2.75rem)/1.12 var(--serif);
  letter-spacing: -.038em;
  overflow-wrap: anywhere;
}
.page-author-note { font-style: italic; color: var(--reading-muted); }
.page-edge {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--reading-edge);
  color: var(--reading-accent);
  background: var(--paper-bg);
}
.page-edge:hover, .page-footer .icon-button:hover { background: color-mix(in srgb, var(--reading-accent) 12%, var(--paper-bg)); }
.page-footer {
  --page-footer-gutter: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  gap: 10px;
  min-height: 58px;
  padding-block: 4px max(7px, var(--safe-bottom));
  padding-inline: max(var(--page-footer-gutter), var(--safe-left)) max(var(--page-footer-gutter), var(--safe-right));
}
.page-navigation { display: grid; gap: 4px; width: min(100%, 410px); min-width: 0; }
.page-status { display: flex; justify-content: center; align-items: baseline; flex-wrap: wrap; gap: 6px 12px; color: var(--reading-muted); font-size: .81rem; font-weight: 750; }
.page-status button { color: var(--reading-accent); font-size: inherit; }
.page-navigation input { width: 100%; margin: 0; accent-color: var(--reading-accent); min-height: 14px; }
.page-navigation input:disabled { opacity: .43; }
.page-footer .icon-button { color: var(--reading-accent); width: 38px; min-height: 36px; }
.page-footer .page-mobile-step { display: none; }
.reading-focus :is(.reader-bar-inner, .page-footer, .page-edge) { visibility: hidden; }
.reader-options { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 16px; }
.reader-options label { display: grid; gap: 5px; font-size: .83rem; font-weight: 750; }
.reader-options select, .chapter-search input { min-width: 0; padding: 7px; border: 1px solid #e4dbee; background: var(--surface); color: var(--ink); font-size: .88rem; }
.reader-options .reader-toggle { display: flex; grid-column: 1 / -1; align-items: center; gap: 7px; }
.reader-toggle input { accent-color: var(--accent); }
.chapter-search { display: flex; align-items: center; gap: 7px; color: var(--accent-ink); margin-bottom: 12px; }
.chapter-search input { flex: 1; }
.chapter-search-results { display: grid; gap: 6px; }
.chapter-search-results button { border: 1px solid var(--line); padding: 8px; background: var(--surface); text-align: left; overflow-wrap: anywhere; font-size: .86rem; }
.chapter-search-results button:hover { border-color: #cab8ed; }
.chapter-search-results mark, .page-fit mark { color: #443217; background: #f6dfa0; }
#modal > .chapter-end { margin-top: 10px; padding-top: 9px; border-top: 1px solid var(--line); }

@media (max-width: 800px), (max-width: 960px) and (max-height: 500px) and (pointer: coarse) {
  .auth-layout { margin: 0 auto; }
}
@media (max-width: 620px) {
  .auth-layout { grid-template-columns: 1fr; }
  .auth-art { display: none; }
  .auth-form.form-panel { padding: 17px; }
  .page-stage { --page-stage-gutter: 7px; grid-template-columns: minmax(0, 1fr); padding-block: 7px; }
  .page-surface { padding: clamp(9px, 2.1vh, 24px) clamp(16px, 4.6vw, 31px); }
  .page-edge { display: none; }
  .page-footer { --page-footer-gutter: 9px; gap: 3px; }
  .page-footer .page-mobile-step { display: inline-flex; }
  .page-footer .focus-button { display: none; }
  .reader-bar-inner { --reader-bar-gutter: 8px; grid-template-columns: auto minmax(0, 1fr) auto; gap: 4px; }
  .reader-tools .icon-button { width: 32px; }
}
@media (max-height: 440px) {
  .page-surface { padding-block: 8px; }
  .page-fit .chapter-heading { margin-bottom: 10px; }
  .page-footer { min-height: 40px; }
}

.card-footer, .card-community, .detail-community, .community-line, .book-rating, .book-readers {
  display: flex;
  align-items: center;
}
.card-footer { gap: 5px 7px; justify-content: space-between; flex-wrap: wrap; margin-top: 7px; }
.card-community { gap: 6px; font-size: .75rem; color: var(--muted); }
.community-line { gap: 9px 17px; flex-wrap: wrap; margin-top: 14px; }
.detail-community { gap: 13px; flex-wrap: wrap; }
.book-rating, .book-readers { gap: 4px; white-space: nowrap; color: var(--muted); }
.book-rating svg { color: #91601d; fill: #f5dfad; }
.book-rating strong { color: var(--ink); }
.book-rating small { font-size: .86em; }
.book-readers svg { color: var(--accent-ink); }

.review-section { max-width: 820px; margin-top: 32px; scroll-margin-top: 16px; }
.review-section .section-head { align-items: center; }
.review-summary { color: var(--muted); font-size: .84rem; margin-top: 3px; }
.review-list { display: grid; gap: 10px; }
.review-card, .review-empty {
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.review-empty { color: var(--muted); font-size: .9rem; }
.review-author { display: flex; align-items: center; gap: 9px; }
.review-author > div { flex: 1; min-width: 0; }
.review-author .avatar { flex: none; }
.review-author strong { display: block; overflow-wrap: anywhere; font-size: .88rem; }
.review-author time { display: block; color: var(--muted); font-size: .76rem; }
.review-card p { margin-top: 10px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: .94rem; }
.review-more { margin-top: 12px; }
.rating-input { border: 0; margin: 0; padding: 0; min-width: 0; }
.rating-input legend { padding: 0; font-size: .86rem; font-weight: 750; }
.rate-stars { display: flex; gap: 3px; padding: 3px 0 7px; }
.rate-stars label { cursor: pointer; }
.rate-stars span {
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  color: #8d611f;
}
.rate-stars label:has(input:checked) svg,
.rate-stars label:has(~ label input:checked) svg { fill: #f1ce78; }
.rate-stars input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -1px; }
.rate-stars label:hover span { background: #fbf0d9; }
.rating-input .text-link { font-size: .77rem; }
#book-review-form .dialog-actions { margin-top: 0; }

@media (max-width: 570px) {
  .book-rating small { display: none; }
  .review-section .section-head { align-items: flex-start; }
  .review-section .section-head .button { min-height: 35px; padding: 6px 8px; font-size: .77rem; flex: 0 1 auto; }
}

.catalog-byline { color: var(--muted); margin-top: 2px; font-size: .81rem; line-height: 1.45; overflow-wrap: anywhere; }
.author-byline:hover { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 2px; }
.detail-author .author-byline { text-decoration: underline; text-decoration-color: #b8a6e0; text-underline-offset: 3px; }

.public-writer-banner { justify-content: flex-start; min-height: 180px; }
.writer-avatar { width: clamp(54px, 8vw, 96px); margin: 0; }
.writer-name { flex: 1 1 auto; min-width: 0; }
.writer-metrics { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 13px; margin-top: 9px; color: #5b4970; font-size: .9rem; font-weight: 750; }
.writer-metrics > span { display: inline-flex; align-items: center; gap: 5px; }
.writer-actions { flex: none; }
.writer-bio {
  max-width: 820px;
  padding: 15px 18px;
  margin: 0 0 24px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.writer-bio h2 { margin-bottom: 6px; font: 680 1.33rem/1.2 var(--sans); }
.writer-bio p { color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.followed-author .avatar { flex: none; }
.followed-author .button[aria-pressed="true"]:hover { border-color: #ae98d7; }
.editor-byline {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 2px 9px;
  min-width: 0;
  padding: 7px 10px;
  border: 1px solid #e9e1f3;
  background: #faf7fe;
  font-size: .86rem;
}
.editor-byline span { color: var(--muted); }
.editor-byline strong { overflow-wrap: anywhere; }
.editor-byline a { margin-left: auto; font-size: .82rem; }
.studio-public-link { margin-top: 12px; }

@media (max-width: 570px) {
  .public-writer-banner { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 10px; min-height: 0; }
  .writer-actions { grid-column: 1 / -1; }
  .writer-metrics { font-size: .8rem; gap: 4px 9px; }
  .writer-metrics svg { width: 15px; height: 15px; }
  .writer-bio { padding: 12px; }
}

.author-photo-field { display: flex; align-items: center; gap: 14px; min-width: 0; }
.author-photo-field .writer-avatar { flex: none; width: 74px; }
.author-photo-controls { display: grid; justify-items: start; gap: 6px; }
.author-photo-controls .file-label { padding-inline: 9px; min-height: 36px; }
.writer-avatar, .followed-author .avatar { overflow: hidden; }
.writer-avatar img, .followed-author .avatar img { width: 100%; height: 100%; object-fit: cover; }
.import-status:empty { display: none; }

.studio-view-tabs { display: none; }
.insight-overview, .insight-charts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.insight-preview, .insight-panel {
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--line);
  background: var(--surface);
}
.insight-preview > div:first-child { display: flex; align-items: center; gap: 8px; color: var(--accent-ink); }
.insight-overview-value { margin-top: 6px; font: 690 1.72rem/1.15 var(--sans); overflow-wrap: anywhere; }
.insight-preview p { margin: 5px 0 9px; color: var(--muted); font-size: .87rem; }
.insight-filters { display: flex; flex-wrap: wrap; gap: 9px 13px; margin-bottom: 15px; }
.insight-filters label { display: grid; gap: 4px; min-width: 0; font-size: .87rem; font-weight: 750; }
.insight-filters select {
  max-width: min(100%, 360px);
  min-height: 42px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: .9rem;
}
.insight-secondary { margin-top: 11px; color: var(--muted); font-size: .86rem; }
.chart-panel h3 { margin-bottom: 9px; font-size: .92rem; }
.history-chart {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 3px;
  height: 108px;
  border-bottom: 1px solid #dbd1ec;
  background: repeating-linear-gradient(to top, transparent 0, transparent 25px, #eee8f62b 25px, #eee8f6 26px);
}
.chart-day { display: flex; align-items: flex-end; justify-content: stretch; min-width: 0; }
.chart-day span { width: 100%; height: var(--bar); min-height: 2px; background: #8262c6; }
.chart-panel:nth-child(2) .chart-day span { background: #64866d; }
.chart-dates { display: flex; justify-content: space-between; margin-top: 4px; color: var(--muted); font-size: .79rem; }

.insight-table-panel { max-width: 100%; overflow-x: auto; border: 1px solid var(--line); background: var(--surface); }
.insight-table { width: 100%; border-collapse: collapse; text-align: right; font-size: .86rem; }
.insight-table :is(th, td) { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; white-space: nowrap; }
.insight-table th:first-child { max-width: 275px; text-align: left; white-space: normal; overflow-wrap: anywhere; }
.insight-table thead th { color: var(--muted); background: #faf8fe; font-size: .79rem; }
.insight-table tbody tr:last-child :is(th, td) { border-bottom: 0; }
.insight-table th small { display: block; color: var(--muted); margin-top: 2px; font-size: .72rem; }
.insight-table td:last-child { font-weight: 800; }
.balance-banner { min-height: 163px; }
.balance-banner h2 { margin: 3px 0 5px; color: #fff7fc; font: 690 clamp(2rem, 5vw, 3.6rem)/1.07 var(--sans); }
.ledger-amount { flex: none; }
.ledger-amount.credit { color: #315f45; }
.ledger-amount.debit { color: #80506a; }

@media (max-width: 800px), (max-width: 960px) and (max-height: 500px) and (pointer: coarse) {
  .studio-navigation a:is([href="#author/stats"], [href="#author/balance"], [href="#edit"]) { display: none; }
  .studio-view-tabs { display: flex; }
}
@media (max-width: 570px) {
  .insight-overview, .insight-charts { grid-template-columns: 1fr; gap: 8px; }
  .insight-filters label, .insight-filters select { width: 100%; }
  .insight-table :is(th, td) { padding: 8px; }
  .insight-table th:first-child { min-width: 123px; }
  .balance-banner { min-height: 131px; flex-wrap: wrap; }
  .balance-banner .button { min-height: 36px; }
}
