:root {
  color-scheme: light;
  --ink: #122235;
  --muted: #647386;
  --line: #dce4ed;
  --line-strong: #c9d4e1;
  --paper: #ffffff;
  --canvas: #f3f6fa;
  --navy: #10243c;
  --navy-soft: #1a3451;
  --blue: #246bfd;
  --blue-deep: #1854d1;
  --cyan: #20b7b2;
  --cyan-soft: #e5f8f6;
  --danger: #b73a48;
  --danger-soft: #fff0f2;
  --shadow: 0 14px 38px rgba(21, 46, 76, 0.08);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(21, 49, 78, 0.025) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--canvas);
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 72px;
  padding: 0 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  color: #fff;
  background: var(--navy);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.brand,
.brand > div,
.account-status,
.panel-heading,
.heading-group,
.user-card,
.search-actions,
.progress-copy,
.results-heading,
.book-title-row,
.book-meta,
.section-label,
.chapter-summary,
.chapter-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 9px 9px 9px 2px;
  color: var(--navy);
  background: #67e0d8;
  font-size: 1.05rem;
  font-weight: 900;
}

.brand > div {
  align-items: flex-start;
  flex-direction: column;
  gap: 1px;
}

.brand strong {
  font-size: 1rem;
  letter-spacing: 0.02em;
}

.brand span:last-child {
  color: #9fb3c9;
  font-size: 0.75rem;
}

.account-status {
  gap: 9px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  color: #c3d0df;
  font-size: 0.875rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7f91a7;
}

.account-status.is-online .status-dot {
  background: #54dfaf;
  box-shadow: 0 0 0 4px rgba(84, 223, 175, 0.12);
}

.account-status.is-online {
  color: #e4fff5;
}

.topbar-actions,
.topnav,
.results-actions {
  display: flex;
  align-items: center;
}

.topbar-actions {
  gap: 12px;
}

.topnav {
  gap: 4px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.045);
}

.topnav a {
  padding: 7px 11px;
  border-radius: 6px;
  color: #aebed0;
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 700;
}

.topnav a:hover,
.topnav a.is-active {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
}

.topbar-logout {
  padding: 7px 10px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 7px;
  color: #c7d4e2;
  background: transparent;
  font-size: 0.78rem;
  font-weight: 700;
}

.topbar-logout:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

.workspace {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 28px 32px 56px;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.sidebar {
  position: sticky;
  top: 100px;
}

.main-column {
  min-width: 0;
  display: grid;
  gap: 20px;
}

.panel {
  padding: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.panel-heading {
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 24px;
}

.panel-heading-row {
  justify-content: space-between;
}

.heading-group {
  gap: 14px;
  align-items: flex-start;
}

.step-number,
.empty-index {
  flex: 0 0 auto;
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--blue);
}

.step-number {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid #b9cdfa;
  border-radius: 50%;
  background: #f1f6ff;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.panel-heading h1,
.panel-heading h2 {
  margin: 0 0 4px;
  font-size: 1.05rem;
  line-height: 1.35;
}

.panel-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
}

.field > span:first-child {
  color: #35475c;
  font-size: 0.875rem;
  font-weight: 700;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 9px;
  color: var(--ink);
  background: #fbfcfe;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input {
  min-height: 46px;
  padding: 0 13px;
}

textarea {
  min-height: 116px;
  padding: 13px;
  resize: vertical;
  line-height: 1.65;
}

input:focus,
textarea:focus {
  border-color: var(--blue);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(36, 107, 253, 0.1);
}

.field small {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
}

.password-wrap {
  position: relative;
  display: block;
}

.password-wrap input {
  padding-right: 62px;
}

.text-button {
  position: absolute;
  right: 10px;
  top: 50%;
  padding: 5px;
  border: 0;
  color: var(--blue);
  background: transparent;
  transform: translateY(-50%);
  font-size: 0.8rem;
  font-weight: 700;
}

.button {
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.875rem;
  font-weight: 750;
  transition: transform 120ms ease, background 160ms ease, border-color 160ms ease;
  text-decoration: none;
}

.button:not(:disabled):active {
  transform: translateY(1px);
}

.button-primary {
  color: #fff;
  background: var(--navy-soft);
}

.button-primary:hover:not(:disabled) {
  background: #224263;
}

.button-accent {
  min-width: 132px;
  color: #fff;
  background: var(--blue);
}

.button-accent:hover:not(:disabled) {
  background: var(--blue-deep);
}

.button-secondary,
.copy-button {
  color: #34506e;
  background: #fff;
  border-color: var(--line-strong);
}

.button-secondary:hover:not(:disabled),
.copy-button:hover:not(:disabled) {
  color: var(--blue);
  border-color: #9bb6ee;
  background: #f6f9ff;
}

.button-danger {
  color: #fff;
  background: var(--danger);
}

.button-danger:hover:not(:disabled) {
  background: #982b38;
}

.button-full {
  width: 100%;
}

.logged-in-actions {
  display: grid;
  gap: 16px;
}

.logged-in-actions[hidden] {
  display: none;
}

.user-card {
  gap: 11px;
  padding: 12px;
  border-radius: 10px;
  background: var(--cyan-soft);
}

.user-avatar {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #0c6966;
  background: #bcefeb;
  font-weight: 850;
}

.user-card > div {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.user-card strong,
.user-card span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-card strong {
  font-size: 0.9rem;
}

.user-card span:last-child {
  color: #52716f;
  font-size: 0.75rem;
}

.privacy-note {
  margin-top: 15px;
  padding: 0 8px;
  display: flex;
  gap: 10px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.6;
}

.privacy-note span {
  color: var(--cyan);
}

.privacy-note p {
  margin: 0;
}

.limit-badge,
.tag {
  border-radius: 999px;
  white-space: nowrap;
}

.limit-badge {
  padding: 6px 10px;
  color: #53667b;
  background: #eef2f7;
  font-size: 0.75rem;
  font-weight: 700;
}

.search-actions {
  justify-content: space-between;
  gap: 16px;
}

.search-actions span {
  color: var(--muted);
  font-size: 0.82rem;
}

.progress-panel {
  border-left: 4px solid var(--cyan);
}

.progress-copy {
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
}

.progress-copy > div {
  display: grid;
  gap: 5px;
}

.eyebrow {
  color: var(--blue);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

#progressMessage {
  font-size: 0.95rem;
}

#progressPercent {
  color: var(--navy);
  font-size: 1.4rem;
  font-weight: 850;
}

.progress-track {
  height: 8px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef4;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--cyan));
  transition: width 260ms ease;
}

.progress-meta {
  min-height: 18px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.78rem;
}

.empty-state {
  min-height: 260px;
  padding: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 22px;
  border: 1px dashed #bac7d6;
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.45);
}

.empty-index {
  font-size: 2.5rem;
  color: #c1ccd8;
}

.empty-state h2 {
  margin-bottom: 8px;
  color: #465b72;
  font-size: 1rem;
}

.empty-state p {
  max-width: 520px;
  margin-bottom: 0;
  line-height: 1.7;
}

.results-section {
  display: grid;
  gap: 16px;
}

.results-section[hidden] {
  display: none;
}

.results-heading {
  justify-content: space-between;
  gap: 20px;
  padding: 4px 2px;
}

.results-actions {
  gap: 9px;
}

.results-heading h2 {
  margin: 4px 0 0;
  font-size: 1.25rem;
}

.results-list {
  display: grid;
  gap: 20px;
}

.book-card {
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.book-header {
  padding: 24px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(130deg, #fff 62%, #edf5ff);
}

.book-header-layout {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.book-header-content {
  min-width: 0;
}

.result-cover {
  position: relative;
  width: 92px;
  height: 128px;
  overflow: hidden;
  border: 1px solid #c7d5e4;
  border-radius: 4px 9px 9px 4px;
  background: linear-gradient(145deg, #dbe9fa, #eef5fd);
  box-shadow: 4px 5px 0 #dce4ed;
}

.result-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.result-cover-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #24496f;
  font-family: ui-serif, Georgia, "Songti SC", serif;
  font-size: 2rem;
  font-weight: 800;
}

.result-cover.has-image .result-cover-fallback {
  display: none;
}

.book-title-row {
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
}

.book-title-row h3 {
  margin: 0;
  font-size: clamp(1.1rem, 2vw, 1.42rem);
  line-height: 1.4;
}

.book-meta {
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.tag {
  padding: 5px 9px;
  color: #53677d;
  background: #edf2f7;
  font-size: 0.75rem;
}

.tag-accent {
  color: #126d69;
  background: var(--cyan-soft);
}

.book-body {
  padding: 24px;
  display: grid;
  gap: 26px;
}

.section-label {
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 11px;
}

.section-label strong {
  font-size: 0.92rem;
}

.copy-button {
  min-height: 32px;
  padding: 0 10px;
  border-style: solid;
  border-width: 1px;
  border-radius: 7px;
  font-size: 0.75rem;
  font-weight: 750;
}

.description-text,
.chapter-content {
  margin: 0;
  color: #3f5267;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.8;
}

.description-text {
  max-height: 260px;
  padding: 15px 17px;
  overflow: auto;
  border-radius: 9px;
  background: #f6f8fb;
  font-size: 0.9rem;
}

.chapter-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.chapter-list {
  display: grid;
  gap: 9px;
}

.chapter-item {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}

.chapter-item[open] {
  border-color: #b9cae0;
  box-shadow: 0 7px 20px rgba(25, 54, 87, 0.06);
}

.chapter-summary {
  min-height: 54px;
  padding: 10px 12px 10px 16px;
  justify-content: space-between;
  gap: 16px;
  list-style: none;
  cursor: pointer;
}

.chapter-summary::-webkit-details-marker {
  display: none;
}

.chapter-name {
  min-width: 0;
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.chapter-index {
  color: #8a9aab;
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.chapter-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.88rem;
}

.chapter-actions {
  flex: 0 0 auto;
  gap: 7px;
}

.chapter-content-wrap {
  padding: 4px 18px 20px 66px;
}

.chapter-content {
  max-height: 540px;
  padding: 17px;
  overflow: auto;
  border-left: 3px solid #b8d0ff;
  background: #f7f9fc;
  font-family: ui-serif, Georgia, "Songti SC", serif;
  font-size: 1rem;
}

.error-list {
  padding: 14px 17px;
  border: 1px solid #efbec4;
  border-radius: 10px;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 0.875rem;
  line-height: 1.7;
}

.error-list[hidden] {
  display: none;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 30;
  padding: 11px 16px;
  border-radius: 9px;
  color: #fff;
  background: #172b43;
  box-shadow: 0 12px 36px rgba(12, 31, 52, 0.26);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition: opacity 180ms ease, transform 180ms ease;
  font-size: 0.875rem;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

body.drawer-open {
  overflow: hidden;
}

.library-workspace {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 34px 32px 64px;
}

.library-heading {
  margin-bottom: 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 28px;
}

.library-heading h1 {
  margin: 5px 0 7px;
  font-size: clamp(1.7rem, 3vw, 2.35rem);
  letter-spacing: -0.035em;
}

.library-heading p {
  max-width: 680px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.7;
}

.library-heading-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.library-count {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #53677d;
  background: #fff;
  font-size: 0.82rem;
  font-weight: 750;
  white-space: nowrap;
}

.library-loading,
.library-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 22px;
}

.library-loading[hidden],
.library-grid[hidden],
.library-empty[hidden] {
  display: none;
}

.loading-line {
  height: 430px;
  border: 1px solid var(--line);
  border-radius: 5px 14px 14px 5px;
  background: linear-gradient(100deg, #eef2f6 20%, #f8fafc 38%, #eef2f6 56%) 0 0 / 200% 100%;
  animation: library-shimmer 1.2s linear infinite;
}

@keyframes library-shimmer {
  to {
    background-position: -200% 0;
  }
}

.library-card {
  position: relative;
  min-height: 430px;
  padding: 0;
  overflow: hidden;
  border: 1px solid #cad6e3;
  border-radius: 5px 14px 14px 5px;
  color: var(--ink);
  background: #fff;
  box-shadow: 0 14px 32px rgba(20, 47, 77, 0.09), 6px 6px 0 #e6ebf1;
  text-align: left;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.library-card::after {
  position: absolute;
  right: 6px;
  bottom: 7px;
  left: 17px;
  height: 5px;
  border-top: 1px solid #dce4ec;
  border-bottom: 1px solid #e8edf2;
  content: "";
}

.library-card:hover,
.library-card:focus-visible {
  border-color: #98b5dc;
  box-shadow: 0 22px 42px rgba(20, 47, 77, 0.14), 7px 7px 0 #dce4ed;
  outline: none;
  transform: translateY(-4px);
}

.book-spine {
  position: absolute;
  inset: 0 auto 0 0;
  width: 13px;
  background: linear-gradient(90deg, #173757, #2d5b86 72%, #15324d);
}

.library-card-cover {
  position: relative;
  height: 220px;
  margin-left: 13px;
  display: block;
  overflow: hidden;
  border-bottom: 1px solid #d9e2ec;
  background: linear-gradient(145deg, #dbe9fa, #f3f7fc);
}

.library-card-cover img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 24%;
  transition: transform 260ms ease;
}

.library-card:hover .library-card-cover img {
  transform: scale(1.025);
}

.library-cover-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #24496f;
  font-family: ui-serif, Georgia, "Songti SC", serif;
  font-size: 3rem;
  font-weight: 850;
}

.library-card-cover.has-image .library-cover-fallback {
  display: none;
}

.book-spine::after {
  position: absolute;
  inset: 0 2px auto;
  height: 58px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  content: "";
}

.library-card-content {
  min-height: 210px;
  padding: 20px 24px 26px 34px;
  display: flex;
  flex-direction: column;
}

.card-eyebrow {
  color: var(--blue);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.library-card-title {
  margin-top: 11px;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  font-family: ui-serif, Georgia, "Songti SC", serif;
  font-size: 1.3rem;
  line-height: 1.42;
}

.library-card-description {
  margin-top: 10px;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.65;
}

.library-card-footer {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #718195;
  font-size: 0.74rem;
  font-weight: 700;
}

.library-card-footer span:last-child {
  max-width: 62%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-empty {
  min-height: 420px;
  padding: 50px 24px;
  border: 1px dashed #b8c6d5;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  background: rgba(255, 255, 255, 0.55);
}

.empty-book-mark {
  width: 64px;
  height: 78px;
  display: grid;
  place-items: center;
  border-left: 8px solid #173757;
  border-radius: 3px 9px 9px 3px;
  color: #173757;
  background: #dfeafb;
  box-shadow: 5px 5px 0 #d3dce7;
  font-size: 1.5rem;
  font-weight: 900;
}

.library-empty h2 {
  margin: 22px 0 7px;
  font-size: 1.15rem;
}

.library-empty p {
  max-width: 480px;
  margin-bottom: 22px;
  color: var(--muted);
  line-height: 1.7;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  justify-content: flex-end;
  visibility: hidden;
  background: rgba(8, 23, 39, 0.46);
  opacity: 0;
  transition: opacity 240ms ease, visibility 240ms ease;
}

.drawer-backdrop.is-open {
  visibility: visible;
  opacity: 1;
}

.novel-drawer {
  width: 80vw;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--canvas);
  box-shadow: -20px 0 60px rgba(7, 23, 41, 0.24);
  outline: none;
  transform: translateX(100%);
  transition: transform 320ms cubic-bezier(0.22, 1, 0.36, 1);
}

.drawer-backdrop.is-open .novel-drawer {
  transform: translateX(0);
}

.drawer-header {
  min-height: 148px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  background: #fff;
}

.drawer-book-heading {
  min-width: 0;
  display: flex;
  align-items: flex-start;
  gap: 20px;
}

.drawer-cover-wrap {
  flex: 0 0 auto;
  width: 78px;
  height: 108px;
  overflow: hidden;
  border: 1px solid #c7d5e4;
  border-radius: 4px 9px 9px 4px;
  background: linear-gradient(145deg, #dbe9fa, #eef5fd);
  box-shadow: 4px 5px 0 #dce4ed;
}

.drawer-cover-wrap img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.drawer-cover-wrap img[hidden],
.drawer-cover-fallback[hidden] {
  display: none;
}

.drawer-cover-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #24496f;
  font-family: ui-serif, Georgia, "Songti SC", serif;
  font-size: 1.8rem;
  font-weight: 850;
}

.drawer-title-wrap {
  min-width: 0;
}

.drawer-title-wrap h2 {
  margin: 4px 0 8px;
  overflow-wrap: anywhere;
  font-size: clamp(1.25rem, 2.2vw, 1.8rem);
  line-height: 1.35;
}

.drawer-close {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: #506177;
  background: #fff;
  font-size: 1.7rem;
  line-height: 1;
}

.drawer-close:hover {
  color: var(--ink);
  background: #f2f5f8;
}

.drawer-body {
  min-height: 0;
  padding: 28px;
  overflow-y: auto;
}

.drawer-section {
  margin: 0 auto 26px;
  max-width: 1100px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: var(--shadow);
}

.drawer-description {
  max-height: none;
}

.drawer-chapter-list .chapter-content {
  max-height: none;
}

.drawer-loading {
  min-height: 240px;
  display: grid;
  place-items: center;
  color: var(--muted);
}

.drawer-footer {
  min-height: 76px;
  padding: 15px 28px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  background: #fff;
}

.confirm-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  visibility: hidden;
  padding: 20px;
  background: rgba(8, 23, 39, 0.62);
  opacity: 0;
  transition: opacity 180ms ease, visibility 180ms ease;
}

.confirm-backdrop.is-open {
  visibility: visible;
  opacity: 1;
}

.confirm-dialog {
  width: min(440px, 100%);
  padding: 28px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(3, 18, 34, 0.3);
  outline: none;
  text-align: center;
  transform: scale(0.96) translateY(8px);
  transition: transform 180ms ease;
}

.confirm-backdrop.is-open .confirm-dialog {
  transform: scale(1) translateY(0);
}

.confirm-icon {
  width: 46px;
  height: 46px;
  margin: 0 auto 16px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--danger);
  background: var(--danger-soft);
  font-size: 1.25rem;
  font-weight: 900;
}

.confirm-dialog h2 {
  margin-bottom: 9px;
  font-size: 1.18rem;
}

.confirm-dialog p {
  margin-bottom: 23px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.7;
}

.confirm-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

@media (max-width: 860px) {
  .topbar {
    padding: 0 18px;
  }

  .brand span:last-child {
    display: none;
  }

  .workspace {
    padding: 18px 16px 40px;
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    gap: 7px;
  }

  .topnav a {
    padding: 7px 8px;
  }

  .library-workspace {
    padding: 26px 16px 48px;
  }

  .library-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .library-loading,
  .library-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .novel-drawer {
    width: 92vw;
  }

  .sidebar {
    position: static;
  }

  .empty-state {
    min-height: 200px;
    padding: 32px 24px;
  }
}

@media (max-width: 560px) {
  .topbar {
    min-height: 64px;
  }

  .account-status {
    padding: 7px 9px;
  }

  .topnav {
    order: 2;
    width: 100%;
    justify-content: center;
  }

  .topbar {
    padding-top: 10px;
    padding-bottom: 10px;
    flex-wrap: wrap;
  }

  .topbar-actions {
    flex: 1 1 100%;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .topbar-logout {
    order: 1;
  }

  #accountStatusText {
    max-width: 95px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .panel,
  .book-header,
  .book-body {
    padding: 18px;
  }

  .panel-heading-row,
  .results-heading,
  .book-title-row,
  .search-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .limit-badge {
    align-self: flex-start;
  }

  .search-actions .button,
  .results-heading .button,
  .book-title-row .copy-button {
    width: 100%;
  }

  .results-actions,
  .library-heading-actions {
    width: 100%;
    align-items: stretch;
    flex-direction: column;
  }

  .library-loading,
  .library-grid {
    grid-template-columns: 1fr;
  }

  .library-card {
    min-height: 410px;
  }

  .library-card-content {
    min-height: 190px;
  }

  .novel-drawer {
    width: 96vw;
  }

  .drawer-header,
  .drawer-body,
  .drawer-footer {
    padding-right: 16px;
    padding-left: 16px;
  }

  .drawer-section {
    padding: 17px;
  }

  .book-header-layout {
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .result-cover {
    width: 70px;
    height: 98px;
  }

  .drawer-cover-wrap {
    width: 58px;
    height: 82px;
  }

  .drawer-book-heading {
    gap: 13px;
  }

  .drawer-footer .button {
    flex: 1;
  }

  .confirm-actions {
    flex-direction: column-reverse;
  }

  .confirm-actions .button {
    width: 100%;
  }

  .empty-index {
    display: none;
  }

  .chapter-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .chapter-actions {
    width: 100%;
  }

  .chapter-actions .copy-button {
    flex: 1;
  }

  .chapter-content-wrap {
    padding: 4px 12px 14px;
  }
}

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