:root {
  --bg: #f7efe5;
  --paper: #fffaf3;
  --ink: #241815;
  --muted: #6f5a54;
  --accent: #b43f24;
  --accent-soft: #efc4a2;
  --line: rgba(36, 24, 21, 0.1);
  --shadow: 0 20px 45px rgba(98, 45, 22, 0.12);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "PingFang SC", "Hiragino Sans GB", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top right, rgba(239, 196, 162, 0.9), transparent 28%),
    radial-gradient(circle at bottom left, rgba(180, 63, 36, 0.08), transparent 32%),
    linear-gradient(180deg, #fff8ef 0%, var(--bg) 100%);
}

.app-shell {
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hero-card,
.panel {
  background: rgba(255, 250, 243, 0.92);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 28px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.85rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 6vw, 3.5rem);
  line-height: 1.02;
}

.hero-copy,
.panel-heading p,
.tip-box,
.status-text,
.chapter-meta {
  color: var(--muted);
}

.panel {
  padding: 22px;
  margin-bottom: 18px;
}

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

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field span {
  font-weight: 600;
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.88);
}

.file-field input {
  padding: 10px 12px;
}

.tip-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(239, 196, 162, 0.35), rgba(255, 255, 255, 0.65));
  border: 1px solid rgba(180, 63, 36, 0.12);
}

.button-row {
  display: flex;
  gap: 12px;
  margin-top: 18px;
}

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

button {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  font: inherit;
  font-weight: 700;
  color: #fffaf2;
  background: var(--accent);
  cursor: pointer;
  transition: transform 160ms ease, opacity 160ms ease, box-shadow 160ms ease;
  box-shadow: 0 12px 30px rgba(180, 63, 36, 0.28);
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.secondary-button {
  background: #2f2522;
  box-shadow: 0 12px 30px rgba(47, 37, 34, 0.18);
}

.primary-button {
  min-width: 140px;
}

.toolbar-button,
.mini-button {
  min-width: auto;
  padding: 10px 14px;
  border-radius: 14px;
  box-shadow: 0 8px 20px rgba(180, 63, 36, 0.18);
}

.mini-button {
  background: #8f3823;
  font-size: 0.92rem;
}

.danger-button {
  background: #5e2520;
}

.hidden {
  display: none;
}

.status-text {
  margin: 14px 2px 0;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 16px;
}

.stat-card {
  padding: 18px;
  border-radius: 20px;
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.78), rgba(239, 196, 162, 0.22));
  border: 1px solid var(--line);
}

.stat-card span {
  display: block;
  color: var(--muted);
  margin-bottom: 8px;
}

.stat-card strong {
  font-size: 1.8rem;
}

.chapter-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chapter-item,
.empty-state {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 16px 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
}

.chapter-main {
  flex: 1;
}

.chapter-header {
  display: flex;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.chapter-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chapter-edit {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.chapter-label {
  font-size: 0.92rem;
  color: var(--muted);
}

.chapter-title-input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  font: inherit;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.95);
}

.chapter-index {
  color: var(--accent);
  font-weight: 700;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 960px);
    padding-top: 16px;
  }

  .hero-card,
  .panel {
    padding: 18px;
  }

  .grid-two,
  .stats-row,
  .button-row {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

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

  .chapter-toolbar {
    justify-content: stretch;
  }

  .toolbar-button {
    width: 100%;
  }

  h1 {
    font-size: 2.2rem;
  }
}
