:root {
  --bg: #fafafa;
  --accent: #b23a5a;
  --header: #6d8f4e;
  --ink: #222222;
  --muted: #6b6b6b;
  --row: #f3f3f3;
  --line: #333333;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

a { color: var(--accent); }
a:visited { color: var(--accent); }
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.loading,
.error,
.empty {
  margin: 0;
  padding: 64px 20px;
  text-align: center;
  color: #555;
  line-height: 1.6;
}

.hero {
  min-height: 240px;
  padding: 52px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  background-color: var(--header);
  background-image: radial-gradient(1100px 220px at 50% 0%, rgba(255, 255, 255, 0.2), transparent 58%);
  background-position: center;
  background-size: cover;
}

body.read .hero {
  min-height: 168px;
  padding: 36px 20px 32px;
}

.hero-frame {
  border: 2px solid #fff;
  padding: 16px 28px;
  max-width: min(640px, 92vw);
}

.hero-frame h1 {
  margin: 0;
  font-size: clamp(20px, 3vw, 30px);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.tagline {
  margin: 16px 0 0;
  font-size: 15px;
  font-style: italic;
}

.nav {
  background: #fff;
  text-align: center;
  padding: 14px 12px;
  border-bottom: 1px solid #eee;
}

.nav a {
  display: inline-block;
  margin: 4px 14px;
  color: var(--accent);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.nav a.brand { text-transform: none; letter-spacing: 0.02em; }

.nav a:hover,
.nav a.current { text-decoration: underline; }

.lang-switch {
  display: inline-block;
  margin: 4px 14px;
}

.lang-switch button {
  background: none;
  border: 0;
  padding: 0 4px;
  color: var(--accent);
  font: inherit;
  font-size: 13px;
  letter-spacing: 0.08em;
  cursor: pointer;
}

.lang-switch button.current { text-decoration: underline; }

.wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 52px 20px 24px;
}

.wrap.home { padding-top: 32px; }

.wrap.read { max-width: 860px; }

.series-title {
  margin: 0;
  text-align: center;
  font-size: clamp(18px, 2.4vw, 24px);
  font-weight: 600;
  letter-spacing: 0.05em;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.rule {
  width: 68px;
  height: 2px;
  margin: 16px auto 28px;
  background: var(--line);
}

.author {
  margin: -12px 0 26px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.covers {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 14px;
  margin: 0 auto 28px;
}

.cover-open {
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: zoom-in;
  line-height: 0;
}

.covers img {
  width: auto;
  max-width: min(46vw, 280px);
  height: auto;
  display: block;
  background: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.covers.single img {
  max-width: min(100%, 560px);
}

body.lightbox-open { overflow: hidden; }

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  overflow: auto;
  padding: 56px 16px 24px;
  background: rgba(18, 18, 18, 0.94);
}

.lightbox[hidden] { display: none; }

.lightbox img {
  margin: auto;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 88px);
  width: auto;
  height: auto;
  cursor: zoom-in;
  background: #fff;
}

.lightbox img.zoomed {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}

.lightbox-close {
  position: fixed;
  top: 14px;
  right: 16px;
  z-index: 1;
  font: inherit;
  padding: 8px 12px;
  border: 0;
  background: #fff;
  color: #222;
  cursor: pointer;
}

.desc {
  margin: 0 0 16px;
  font-size: 16px;
  line-height: 1.7;
  color: #3a3a3a;
}

.continue {
  margin: 8px 0 0;
  text-align: center;
}

.continue a { text-decoration: none; }
.continue a:hover { text-decoration: underline; }

.chapters-heading {
  margin: 36px 0 16px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  scroll-margin-top: 16px;
}

.chapter-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chapter-list a {
  display: block;
  padding: 12px 16px;
  background: var(--row);
  color: var(--accent);
  text-align: center;
  text-decoration: none;
  font-size: 15.5px;
  line-height: 1.4;
}

.chapter-list a:hover {
  background: #ececec;
  text-decoration: underline;
}

.crumbs {
  margin: 0 0 22px;
  text-align: center;
  color: #888;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.crumbs a { text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }

.progress-note {
  margin: -10px 0 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  letter-spacing: 0.08em;
}

.reader-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  margin: 0 -20px 18px;
  padding: 10px 20px 4px;
  background: rgba(250, 250, 250, 0.95);
  border-bottom: 1px solid #eee;
  backdrop-filter: blur(10px);
}

.pager {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  margin: 0 0 20px;
  font-size: 14px;
}

.reader-bar .pager { margin-bottom: 8px; }

.pager .prev,
.pager .next {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pager .next { text-align: right; }

.pager a { text-decoration: none; }
.pager a:hover { text-decoration: underline; }

.mid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.pages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0 0 28px;
}

.pages img {
  width: 100%;
  height: auto;
  display: block;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.pages img:not([src]) { display: none; }

.form-title {
  margin: 8px 0 8px;
  font-size: 18px;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.upload-form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 36px;
}

.upload-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(100%, 420px);
  font-size: 14px;
}

.pair-row {
  display: flex;
  gap: 12px;
  width: min(100%, 420px);
}

.pair-row label {
  width: auto;
  min-width: 0;
  flex: 1;
}

.pair-row label:first-child { flex: 0 0 110px; }

.file-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  width: 100%;
  cursor: pointer;
}

.file-field input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.file-picker {
  padding: 8px 12px;
  border: 1px solid #ccc;
  background: #fff;
}

.file-names {
  color: var(--muted);
  font-size: 14px;
}

.arrange-box { width: min(100%, 640px); }

.arrange {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
  padding: 14px 28px;
  min-height: 152px;
}

.shot {
  position: relative;
  width: 92px;
  min-height: 124px;
  background: #fff;
  border: 1px solid #ddd;
  cursor: grab;
}

.shot.dragging { opacity: 0.45; }

.shot.insert-before { box-shadow: inset 3px 0 0 var(--accent); }

.arrange.insert-end .shot:last-child { box-shadow: inset -3px 0 0 var(--accent); }

.shot img,
.shot-fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 124px;
  object-fit: contain;
  background: #f3f3f3;
  color: #666;
  font-size: 12px;
  text-align: center;
  overflow-wrap: anywhere;
  padding: 4px;
}

.shot-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  line-height: 1;
  cursor: pointer;
}

.upload-form input[type="text"],
.upload-form input[type="number"] {
  font: inherit;
  padding: 8px 10px;
  border: 1px solid #ccc;
  background: #fff;
}

.upload-form button {
  font: inherit;
  padding: 10px 16px;
  border: 0;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.upload-form button:disabled { opacity: 0.6; cursor: wait; }

.upload-progress {
  width: min(100%, 420px);
  height: 8px;
  background: #e6e6e6;
  overflow: hidden;
}

.upload-progress[hidden] { display: none; }

.upload-progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent);
}

.text-button {
  font: inherit;
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  cursor: pointer;
}

.text-button:hover { text-decoration: underline; }

.form-status {
  margin: 0;
  min-height: 1.2em;
  color: var(--muted);
  font-size: 14px;
}

.footer {
  max-width: 720px;
  margin: 0 auto;
  padding: 8px 20px 48px;
  color: #888;
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

.hint { margin: 0 0 8px; }

.copy {
  margin: 0;
  font-size: 12px;
  letter-spacing: 0.04em;
}

.colophon {
  margin: 6px 0 0;
  letter-spacing: 0.14em;
}

.license {
  margin: 28px 0 0;
  padding: 12px 14px;
  background: #e4e4e4;
  color: #8a8a8a;
  font-size: 12px;
  line-height: 1.45;
  letter-spacing: 0;
  text-align: left;
}

.license p { margin: 0 0 8px; }

.license p:last-child { margin-bottom: 0; }

.license a,
.license a:visited {
  color: #8a8a8a;
}

@media (max-width: 640px) {
  .hero { min-height: 180px; padding: 36px 16px; }
  .wrap { padding-top: 36px; }
  .chapter-list a { font-size: 14.5px; }
  .pager { font-size: 13px; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}
