:root {
  --paper: #f3ede0;
  --paper-deep: #e2d4bc;
  --ink: #261b14;
  --muted: #6a584d;
  --accent: #a6502f;
  --accent-deep: #6f2d17;
  --shadow: rgba(38, 27, 20, 0.12);
  --panel: rgba(255, 248, 238, 0.8);
  --line: rgba(111, 45, 23, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(166, 80, 47, 0.18), transparent 28%),
    radial-gradient(circle at bottom right, rgba(111, 45, 23, 0.22), transparent 24%),
    linear-gradient(180deg, #d5c2a7 0%, #ede2cf 30%, #f6f0e6 100%);
  min-height: 100vh;
}

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

.hero,
.sidebar-card,
.chapter-card {
  background: var(--panel);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 20px 60px var(--shadow);
}

.hero {
  border-radius: 28px;
  padding: 32px;
  margin-bottom: 24px;
}

.eyebrow,
.sidebar-label {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
  color: var(--accent-deep);
}

.hero h1,
.chapter-card h2 {
  margin: 0;
  font-weight: 700;
  line-height: 1.05;
}

.hero h1 {
  font-size: clamp(2.5rem, 6vw, 4.6rem);
}

.hero-copy {
  width: min(640px, 100%);
  font-size: 1.08rem;
  line-height: 1.6;
  color: var(--muted);
}

.hero-actions,
.chapter-actions,
.chapter-toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.hero-actions {
  margin: 24px 0;
}

.primary,
.secondary,
.toc-item {
  border: 0;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary,
.secondary {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 18px;
}

.primary {
  background: var(--accent);
  color: #fff9f4;
  box-shadow: 0 12px 30px rgba(166, 80, 47, 0.28);
}

.secondary,
.toc-item {
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  border: 1px solid rgba(111, 45, 23, 0.16);
}

.primary:hover,
.secondary:hover,
.toc-item:hover,
.toc-item.active {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(38, 27, 20, 0.12);
}

.toc-item.active {
  background: rgba(166, 80, 47, 0.12);
  border-color: rgba(166, 80, 47, 0.35);
}

.meta-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin: 0;
}

.meta-strip div {
  background: rgba(255, 255, 255, 0.46);
  border-radius: 18px;
  padding: 16px;
}

.meta-strip dt {
  font-size: 0.85rem;
  color: var(--muted);
}

.meta-strip dd {
  margin: 8px 0 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  gap: 24px;
}

.sidebar {
  position: sticky;
  top: 24px;
  align-self: start;
}

.sidebar-card,
.chapter-card {
  border-radius: 24px;
  padding: 22px;
}

.toc {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toc-item {
  width: 100%;
  padding: 12px 14px;
  text-align: left;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 10px;
  align-items: center;
}

.toc-index {
  color: var(--accent-deep);
  font-size: 0.85rem;
}

.toc-title {
  font-weight: 700;
}

.toc-status {
  grid-column: 1 / -1;
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.status-drafted,
.status-needs-shaping,
.status-awaiting-dad,
.status-editor-pass,
.status-ready-to-print {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.status-drafted { color: #71583f; }
.status-needs-shaping { color: #9b4e2a; }
.status-awaiting-dad { color: #8c6a18; }
.status-editor-pass { color: #8a2f55; }
.status-ready-to-print { color: #1c6c4b; }

.activity-list,
.entry-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.activity-item,
.entry-item {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
}

.activity-meta,
.entry-meta {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.84rem;
}

.activity-type {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.74rem;
  color: var(--accent-deep);
}

.activity-content,
.entry-content,
.empty-state,
.buddy-copy,
.chapter-meta,
.chapter-summary {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.chapter-content {
  margin: 20px 0 0;
  padding: clamp(28px, 4vw, 52px);
  overflow: auto;
  font: 1rem/1.82 "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(243, 237, 224, 0.88));
  border-radius: 18px;
  border: 1px solid rgba(111, 45, 23, 0.08);
  min-height: 65vh;
}

.chapter-meta {
  margin-top: 8px;
}

.chapter-summary {
  margin-top: 10px;
  max-width: 62ch;
}

.chapter-content > * {
  max-width: 36rem;
  margin-left: auto;
  margin-right: auto;
}

.chapter-content > :first-child {
  margin-top: 0;
}

.chapter-content h2,
.chapter-content h3,
.chapter-content h4 {
  color: var(--accent-deep);
  line-height: 1.2;
  margin-top: 2.2rem;
  margin-bottom: 0.9rem;
}

.chapter-content p,
.chapter-content li,
.chapter-content blockquote {
  font-size: 1.08rem;
}

.chapter-content p {
  margin: 0 0 1.1rem;
  text-wrap: pretty;
}

.chapter-content ul,
.chapter-content ol {
  margin: 0 0 1.2rem;
  padding-left: 1.4rem;
}

.chapter-content blockquote {
  margin: 1.4rem auto;
  padding: 0.2rem 0 0.2rem 1.2rem;
  border-left: 3px solid rgba(166, 80, 47, 0.35);
  color: var(--accent-deep);
}

.chapter-content hr {
  border: 0;
  border-top: 1px solid rgba(111, 45, 23, 0.18);
  margin: 2rem auto;
}

.chapter-content code {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.9em;
  background: rgba(111, 45, 23, 0.08);
  border-radius: 6px;
  padding: 0.12rem 0.34rem;
}

.status-wrap {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
  color: var(--muted);
}

.status-select,
.entry-form input,
.entry-form textarea {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  font: inherit;
}

.status-select {
  padding: 10px 12px;
}

.hidden {
  display: none;
}

.buddy-panel {
  margin-top: 24px;
  background: rgba(252, 247, 240, 0.86);
  border: 1px solid rgba(111, 45, 23, 0.16);
  border-radius: 24px;
  box-shadow: 0 20px 60px var(--shadow);
  padding: 24px;
}

.buddy-head,
.buddy-actions,
.writer-grid,
.entry-form {
  display: flex;
}

.buddy-head {
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  flex-wrap: wrap;
}

.buddy-head h3 {
  margin: 0 0 8px;
}

.buddy-actions {
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.writer-room-state {
  color: var(--muted);
  font-size: 0.92rem;
}

.writer-grid {
  gap: 16px;
  margin-top: 20px;
  flex-wrap: wrap;
}

.writer-card {
  flex: 1 1 280px;
  min-width: 0;
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
}

.entry-form {
  flex-direction: column;
  gap: 10px;
  margin-bottom: 14px;
}

.entry-form input,
.entry-form textarea {
  padding: 12px 14px;
}

.entry-form textarea {
  min-height: 120px;
  resize: vertical;
}

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

  .sidebar {
    position: static;
  }

  .meta-strip {
    grid-template-columns: 1fr;
  }

  .buddy-actions {
    align-items: flex-start;
  }
}