:root {
  --page: oklch(0.97 0.008 78);
  --ink: oklch(0.2 0.015 70);
  --muted: oklch(0.43 0.018 70);
  --line: oklch(0.84 0.018 78);
  --surface: oklch(1 0 0);
  --accent: oklch(0.46 0.12 250);
  --serif: "Noto Serif SC", "Songti SC", serif;
  --sans: "Noto Sans SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: var(--sans); }
button, input, textarea { font: inherit; }
button { cursor: pointer; }

.reader-shell { width: min(100% - 40px, 860px); margin: 0 auto; padding: 70px 0; }
.novel-heading { padding-bottom: 42px; border-bottom: 1px solid var(--line); text-align: center; }
.novel-heading h1 { margin: 0; font-family: var(--serif); font-size: clamp(2.45rem, 6vw, 4.5rem); font-weight: 600; letter-spacing: -.03em; line-height: 1.16; text-wrap: balance; }
.novel-author { margin: 17px 0 0; color: var(--muted); font-family: var(--serif); font-size: 1.05rem; }
.novel-intro { max-width: 610px; margin: 28px auto 0; color: var(--muted); font-family: var(--serif); font-size: 1rem; line-height: 2; text-wrap: pretty; }
.chapter-view { padding-top: 52px; }
.chapter-number { margin: 0 0 15px; color: var(--muted); font-size: .75rem; letter-spacing: .12em; text-align: center; }
.chapter-view h2 { margin: 0 0 38px; font-family: var(--serif); font-size: 2rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.4; text-align: center; }
.chapter-content { max-width: 680px; margin: 0 auto; padding: 0 18px; overflow-wrap: anywhere; color: var(--ink); font-family: var(--serif); font-size: 1.1rem; line-height: 2.25; white-space: pre-wrap; word-break: break-word; }
.chapter-content p { margin: 0 0 30px; overflow-wrap: anywhere; text-indent: 2em; text-wrap: pretty; white-space: pre-wrap; word-break: break-word; }
.chapter-nav { max-width: 680px; display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 28px auto 0; padding-top: 22px; border-top: 1px solid var(--line); color: var(--muted); font-size: .78rem; }
.chapter-button { min-width: 92px; padding: 9px 0; color: var(--ink); background: transparent; border: 0; font-family: var(--serif); font-size: .9rem; }
.chapter-button:hover:not(:disabled) { color: var(--accent); }
.chapter-button:disabled { color: oklch(0.72 0.014 78); cursor: not-allowed; }
.chapter-button:focus-visible, input:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

.admin-page { background: oklch(0.985 0.003 250); }
.upload-shell { width: min(100% - 40px, 740px); margin: 0 auto; padding: 88px 0 110px; }
.upload-heading { margin-bottom: 50px; }
.upload-heading h1 { margin: 0; font-family: var(--serif); font-size: 2.7rem; font-weight: 600; letter-spacing: -.02em; }
.upload-heading p { margin: 14px 0 0; color: var(--muted); font-size: .92rem; }
.upload-form { display: grid; gap: 40px; }
.upload-section { padding-top: 22px; border-top: 1px solid var(--line); }
.upload-section h2 { margin: 0 0 24px; font-size: 1rem; font-weight: 600; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 24px; }
.section-heading h2 { margin: 0; }
.section-heading > span { color: var(--muted); font-size: .78rem; }
.metadata-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 22px; }
.upload-form label { display: grid; gap: 9px; color: var(--ink); font-size: .84rem; font-weight: 600; }
.upload-form input, .upload-form textarea { width: 100%; padding: 13px 14px; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; font-weight: 400; line-height: 1.5; transition: border-color .18s ease, box-shadow .18s ease; }
.upload-form textarea { min-height: 124px; resize: vertical; }
.upload-form input::placeholder, .upload-form textarea::placeholder { color: var(--muted); opacity: 1; }
.upload-form input:focus, .upload-form textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px oklch(0.46 0.12 250 / .14); outline: 0; }
.file-drop { min-height: 138px; display: flex !important; align-items: center; justify-content: center; padding: 24px; color: var(--muted) !important; background: var(--surface); border: 1px dashed oklch(0.6 0.03 250); border-radius: 6px; cursor: pointer; text-align: center; transition: border-color .18s ease, background .18s ease; }
.file-drop:hover { background: oklch(0.97 0.012 250); border-color: var(--accent); }
.file-drop input { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.file-drop strong { display: block; color: var(--ink); font-size: .96rem; }
.file-drop span { display: block; margin-top: 8px; font-size: .8rem; font-weight: 400; }
.upload-feedback { min-height: 20px; margin: 13px 0 0; color: var(--muted); font-size: .82rem; }
.upload-feedback[data-state="success"] { color: oklch(0.43 0.11 150); }
.upload-feedback[data-state="error"] { color: oklch(0.52 0.18 25); }
.chapter-section[hidden] { display: none; }
.chapter-list { max-height: 310px; margin: 0; padding: 0; overflow-y: auto; border: 1px solid var(--line); border-radius: 6px; list-style: none; }
.chapter-list li { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; align-items: center; min-height: 50px; border-bottom: 1px solid var(--line); }
.chapter-list li:last-child { border-bottom: 0; }
.chapter-list li > span { color: var(--muted); font-family: var(--serif); font-size: .76rem; text-align: center; }
.chapter-list input { padding: 7px 12px; background: transparent; border-color: transparent; border-radius: 3px; }
.chapter-list input:hover { border-color: var(--line); }
.chapter-list input:focus { border-color: var(--accent); }
.remove-chapter { margin-right: 12px; padding: 5px 8px; color: var(--muted); background: transparent; border: 0; border-radius: 4px; font-size: .76rem; }
.remove-chapter:hover { color: oklch(0.52 0.18 25); background: oklch(0.96 0.02 25); }
.upload-form > button { min-height: 50px; margin-top: 2px; color: oklch(1 0 0); background: var(--accent); border: 0; border-radius: 6px; font-weight: 600; transition: background .18s ease, transform .18s ease; }
.upload-form > button:hover:not(:disabled) { background: oklch(0.4 0.12 250); transform: translateY(-1px); }
.upload-form > button:disabled { opacity: .55; cursor: wait; }

@media (max-width: 560px) {
  .reader-shell, .upload-shell { width: min(100% - 32px, 480px); }
  .reader-shell { padding: 52px 0; }
  .novel-heading { padding-bottom: 36px; }
  .novel-intro { margin-top: 22px; font-size: .95rem; line-height: 1.95; }
  .chapter-view { padding-top: 45px; }
  .chapter-view h2 { margin-bottom: 28px; font-size: 1.7rem; }
  .chapter-content { padding: 0 5px; font-size: 1rem; line-height: 2.05; }
  .upload-shell { padding: 62px 0 76px; }
  .upload-heading { margin-bottom: 40px; }
  .upload-heading h1 { font-size: 2.3rem; }
  .metadata-grid { grid-template-columns: 1fr; gap: 22px; }
}

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