:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --surface: #ffffff;
  --text: #152033;
  --muted: #5f6b7c;
  --line: #dbe3ef;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --shadow: 0 18px 50px rgba(21, 32, 51, 0.08);
  --radius: 18px;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.12), transparent 28%),
    linear-gradient(180deg, #eef4ff 0%, var(--bg) 42%, #f8fafc 100%);
  color: var(--text);
  min-height: 100vh;
}

.page {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 48px;
}

.hero {
  text-align: center;
  margin-bottom: 28px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--text);
  color: #fff;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.domain {
  color: var(--muted);
  font-size: 0.95rem;
}

.hero h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.1;
}

.lead {
  margin: 0 auto 18px;
  max-width: 680px;
  color: var(--muted);
  font-size: 1.05rem;
  line-height: 1.7;
}

.mode-tabs {
  display: inline-flex;
  gap: 8px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
}

.mode-tab {
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 999px;
  cursor: pointer;
}

.mode-tab.is-active {
  background: var(--accent);
  color: #fff;
}

.mode-tab:hover:not(.is-active) {
  color: var(--text);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.upload-card,
.loading-card {
  padding: 28px;
}

.dropzone {
  border: 2px dashed #bfd0ea;
  border-radius: calc(var(--radius) - 4px);
  background: linear-gradient(180deg, #fbfdff, #f7faff);
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.dropzone:hover,
.dropzone:focus-visible,
.dropzone.dragover {
  border-color: var(--accent);
  background: #f3f8ff;
  transform: translateY(-1px);
  outline: none;
}

.dropzone-inner {
  padding: 48px 24px;
  text-align: center;
}

.dropzone-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 800;
  font-size: 1.1rem;
}

.dropzone-title {
  margin: 0 0 8px;
  font-size: 1.15rem;
  font-weight: 600;
}

.dropzone-hint {
  margin: 0;
  color: var(--muted);
}

.book-upload-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  flex-wrap: wrap;
}

.outline-preview-list {
  margin: 0;
  padding: 14px 16px 14px 28px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #f8fbff;
  max-height: 420px;
  overflow: auto;
  line-height: 1.7;
}

.outline-preview-more {
  color: var(--muted);
  list-style: none;
  margin-left: -16px;
}

.outline-options {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 18px;
}

.outline-options label {
  color: var(--muted);
  font-weight: 600;
}

.outline-options select {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  background: #fff;
}

.loading-card {
  display: grid;
  place-items: center;
  gap: 16px;
  min-height: 180px;
  color: var(--muted);
}

.spinner {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 4px solid #dbeafe;
  border-top-color: var(--accent);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 16px;
  margin-bottom: 18px;
}

.preview-header h2 {
  margin: 0 0 6px;
  font-size: 1.5rem;
}

.meta,
.status {
  margin: 0;
  color: var(--muted);
}

.compare-grid {
  display: grid;
  gap: 18px;
}

.preview-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.preview-card img {
  display: block;
  width: 100%;
  height: auto;
  background: #eef2f7;
}

.preview-label {
  padding: 12px 16px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  background: #f8fbff;
}

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

.preset-card {
  background: var(--surface);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow);
}

.preset-card:hover {
  transform: translateY(-2px);
}

.preset-card.selected {
  border-color: var(--accent);
  box-shadow: 0 18px 40px rgba(37, 99, 235, 0.18);
}

.preset-card img {
  display: block;
  width: 100%;
  height: auto;
  background: #eef2f7;
}

.preset-copy {
  padding: 14px 16px 16px;
}

.preset-copy h3 {
  margin: 0 0 6px;
  font-size: 1.05rem;
}

.preset-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.actions {
  margin-top: 24px;
  display: grid;
  gap: 10px;
}

.primary-btn,
.ghost-btn {
  border: none;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease;
}

.primary-btn {
  padding: 14px 22px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

.primary-btn:hover:not(:disabled) {
  background: var(--accent-dark);
  transform: translateY(-1px);
}

.primary-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.ghost-btn {
  padding: 10px 16px;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
}

.ghost-btn:hover {
  color: var(--text);
  border-color: #b8c7de;
}

.error {
  margin: 14px 0 0;
  color: var(--danger);
}

footer {
  margin-top: 36px;
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.epub-work-card {
  padding: 24px;
}

.epub-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr);
  gap: 18px;
}

.epub-panel h3 {
  margin: 0 0 10px;
  font-size: 1.05rem;
}

.hint {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.6;
}

.code-block {
  margin: 0;
  padding: 14px;
  border-radius: 12px;
  background: #0f172a;
  color: #e2e8f0;
  font-size: 0.82rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 320px;
  overflow: auto;
}

.yaml-editor {
  width: 100%;
  min-height: 420px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: 0.88rem/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
  resize: vertical;
  box-sizing: border-box;
}

@media (max-width: 900px) {
  .epub-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1100px) {
  .preset-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .preset-grid {
    grid-template-columns: 1fr;
  }

  .preview-header {
    flex-direction: column;
  }
}

.detect-result-card {
  display: grid;
  gap: 14px;
}

.detect-results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.detect-panel {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: calc(var(--radius) - 6px);
  background: #fbfdff;
}

.detect-panel h3 {
  margin: 0 0 12px;
  font-size: 1rem;
}

.detect-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 10px 16px;
  border-radius: 999px;
  font-weight: 700;
}

.detect-badge--ok {
  background: #dcfce7;
  color: #166534;
}

.detect-badge--bad {
  background: #fee2e2;
  color: #991b1b;
}

.detect-verdict {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

@media (max-width: 900px) {
  .detect-results-grid {
    grid-template-columns: 1fr;
  }
}
