:root {
  --paper: #f7f8f5;
  --surface: #ffffff;
  --surface-soft: #edf5ef;
  --ink: #202723;
  --muted: #68746d;
  --line: #dce4df;
  --green: #1f7a5a;
  --blue: #315f96;
  --coral: #bd5550;
  --gold: #aa731e;
  --violet: #7164a6;
  --shadow: 0 18px 48px rgba(32, 39, 35, 0.09);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  background:
    linear-gradient(90deg, rgba(31, 122, 90, 0.05), transparent 34%),
    linear-gradient(180deg, #fbfcfa 0, var(--paper) 360px);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  line-height: 1.5;
  margin: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
select {
  cursor: pointer;
}

img {
  display: block;
  max-width: 100%;
}

.app-top {
  align-items: center;
  background: rgba(255, 255, 255, 0.86);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(14px);
  display: flex;
  justify-content: space-between;
  min-height: 76px;
  padding: 14px clamp(16px, 4vw, 42px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand-line {
  align-items: center;
  display: inline-flex;
  gap: 12px;
}

.brand-mark {
  align-items: center;
  background:
    linear-gradient(135deg, var(--green), var(--blue));
  border-radius: 8px;
  color: #fff;
  display: inline-grid;
  font-weight: 900;
  height: 44px;
  place-items: center;
  width: 44px;
}

.brand-line strong,
.brand-line small {
  display: block;
}

.brand-line strong {
  font-size: 18px;
}

.brand-line small,
.muted,
.role-switch span,
.meta-line,
.metric-row,
.book-admin-card p,
.timeline small,
.queue-item small {
  color: var(--muted);
}

.role-switch label {
  align-items: center;
  display: flex;
  gap: 10px;
}

select,
input,
textarea {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 42px;
  padding: 10px 11px;
  width: 100%;
}

textarea {
  min-height: 118px;
  resize: vertical;
}

.app-shell {
  margin: 0 auto;
  max-width: 1260px;
  padding: 22px clamp(14px, 3vw, 32px) 54px;
}

.app-nav {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: flex;
  gap: 6px;
  margin-bottom: 22px;
  overflow-x: auto;
  padding-bottom: 9px;
}

.app-nav a {
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  padding: 9px 13px;
  white-space: nowrap;
}

.app-nav a.active {
  background: var(--ink);
  color: #fff;
}

.notice {
  border-radius: 8px;
  margin: 0 0 18px;
  padding: 12px 14px;
}

.notice.ok {
  background: #e6f5ed;
  border: 1px solid #b5dfc7;
  color: #176246;
}

.notice.danger {
  background: #fff0ef;
  border: 1px solid #e5b9b6;
  color: #9c3939;
}

.page-head {
  align-items: flex-end;
  display: flex;
  gap: 20px;
  justify-content: space-between;
  margin: 12px 0 22px;
}

.page-head h1 {
  font-size: clamp(30px, 4vw, 56px);
  letter-spacing: 0;
  line-height: 1;
  margin: 5px 0 0;
  max-width: 840px;
}

.eyebrow {
  color: var(--green);
  display: inline-block;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.mini-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.mini-stats span {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  color: var(--muted);
  padding: 10px 12px;
}

.mini-stats strong {
  color: var(--ink);
}

.book-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
}

.book-card,
.panel,
.chapter-row,
.empty-state,
.timeline article,
.reader-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.book-card {
  display: grid;
  grid-template-rows: 220px 1fr;
  overflow: hidden;
}

.cover {
  background: var(--surface-soft);
  display: block;
  overflow: hidden;
}

.cover img,
.detail-cover img {
  height: 100%;
  object-fit: cover;
  transition: transform 180ms ease;
  width: 100%;
}

.book-card:hover .cover img {
  transform: scale(1.035);
}

.book-card-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
}

.book-card h2,
.panel h2,
.detail-copy h1,
.reader-card h1,
.chapter-row h3,
.queue-item h3 {
  margin: 0;
}

.book-card h2 {
  font-size: 22px;
  line-height: 1.1;
}

.book-card p,
.detail-copy p,
.queue-item p {
  color: var(--muted);
  margin: 0;
}

.meta-line,
.metric-row,
.actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.metric-row {
  font-size: 13px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  display: inline-flex;
  font-size: 12px;
  font-weight: 900;
  line-height: 1;
  padding: 7px 9px;
}

.pill.good {
  background: #e7f5ed;
  border-color: #b8dfca;
  color: var(--green);
}

.pill.warn {
  background: #fff7e8;
  border-color: #e7c889;
  color: var(--gold);
}

.pill.danger {
  background: #fff0ef;
  border-color: #e5b9b6;
  color: var(--coral);
}

.pill.neutral {
  background: var(--surface-soft);
  color: var(--muted);
}

.progress-wrap {
  display: grid;
  gap: 6px;
}

.progress-copy {
  color: var(--muted);
  display: flex;
  font-size: 12px;
  justify-content: space-between;
}

.progress {
  background: #e6ece8;
  border-radius: 999px;
  height: 9px;
  overflow: hidden;
}

.progress span {
  background: linear-gradient(90deg, var(--blue), var(--violet));
  display: block;
  height: 100%;
}

.button {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 8px;
  display: inline-flex;
  font-weight: 900;
  justify-content: center;
  min-height: 40px;
  padding: 9px 13px;
  white-space: nowrap;
}

.button.primary {
  background: var(--ink);
  color: #fff;
}

.button.secondary {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.button.ghost {
  background: var(--surface-soft);
  color: var(--green);
}

.button.warn {
  background: var(--gold);
  color: #fff;
}

.button.danger {
  background: var(--coral);
  color: #fff;
}

.two-column {
  align-items: start;
  display: grid;
  gap: 20px;
  grid-template-columns: minmax(300px, 0.85fr) minmax(420px, 1.15fr);
}

.panel {
  padding: 18px;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid label {
  display: grid;
  gap: 6px;
}

.form-grid label span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 900;
}

.form-pair {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.stack {
  display: grid;
  gap: 16px;
}

.card-head {
  align-items: flex-start;
  display: flex;
  gap: 14px;
  justify-content: space-between;
}

.inline-form,
.chapter-mini {
  border-top: 1px solid var(--line);
  margin-top: 14px;
  padding-top: 14px;
}

.book-detail {
  align-items: stretch;
  display: grid;
  gap: 22px;
  grid-template-columns: minmax(260px, 360px) 1fr;
  margin-bottom: 26px;
}

.detail-cover {
  aspect-ratio: 4 / 5;
  background: var(--surface-soft);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.detail-copy {
  align-content: center;
  display: grid;
  gap: 16px;
}

.detail-copy h1 {
  font-size: clamp(34px, 5vw, 72px);
  letter-spacing: 0;
  line-height: 0.95;
}

.detail-copy p {
  font-size: 18px;
  max-width: 780px;
}

.chapter-list {
  display: grid;
  gap: 12px;
}

.section-title {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.section-title h2 {
  margin: 0;
}

.chapter-row {
  align-items: center;
  display: grid;
  gap: 14px;
  grid-template-columns: 56px 1fr auto;
  padding: 13px;
}

.chapter-no {
  align-items: center;
  background: linear-gradient(135deg, #e8f4ef, #edf0fb);
  border-radius: 8px;
  color: var(--blue);
  display: grid;
  font-weight: 900;
  height: 48px;
  place-items: center;
  width: 48px;
}

.revision-box {
  border-top: 1px solid var(--line);
  grid-column: 1 / -1;
  padding-top: 12px;
}

.revision-box summary {
  color: var(--green);
  cursor: pointer;
  font-weight: 900;
  margin-bottom: 10px;
}

.reader-page {
  display: grid;
  gap: 16px;
  margin: 0 auto;
  max-width: 900px;
}

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

.reader-card {
  padding: clamp(24px, 5vw, 54px);
}

.reader-card h1 {
  font-size: clamp(34px, 6vw, 68px);
  line-height: 0.98;
}

.reading-content {
  color: #27322d;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 21px;
  margin-top: 26px;
}

.reading-content p {
  margin: 0 0 20px;
}

.reader-actions {
  border-top: 1px solid var(--line);
  margin-top: 28px;
  padding-top: 16px;
}

.comments {
  display: grid;
  gap: 14px;
}

.comment-form {
  display: grid;
  gap: 10px;
}

.comment-list {
  display: grid;
  gap: 10px;
}

.comment-list article {
  background: var(--surface-soft);
  border-radius: 8px;
  padding: 12px;
}

.comment-list p {
  margin: 5px 0;
}

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

.queue-column {
  align-content: start;
  display: grid;
  gap: 12px;
}

.queue-item {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 9px;
  padding-top: 12px;
}

.decision-form {
  display: grid;
  gap: 8px;
}

.decision-form textarea {
  min-height: 78px;
}

.timeline {
  display: grid;
  gap: 12px;
}

.timeline article {
  align-items: center;
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 14px;
}

.timeline p {
  color: var(--muted);
  margin: 4px 0 0;
}

.empty-state {
  padding: 32px;
  text-align: center;
}

.empty-state h2 {
  margin: 0 0 8px;
}

.empty-state p {
  color: var(--muted);
  margin: 0;
}

.installer {
  min-height: 100vh;
}

.install-shell {
  display: grid;
  min-height: 100vh;
  padding: 22px;
  place-items: center;
}

.install-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 18px;
  max-width: 520px;
  padding: 24px;
  width: 100%;
}

.checkline {
  align-items: center;
  display: flex;
  gap: 10px;
}

.checkline input {
  min-height: auto;
  width: auto;
}

@media (max-width: 940px) {
  .app-top,
  .page-head,
  .card-head {
    align-items: stretch;
    flex-direction: column;
  }

  .role-switch label {
    align-items: stretch;
    flex-direction: column;
  }

  .two-column,
  .book-detail,
  .queue-grid {
    grid-template-columns: 1fr;
  }

  .detail-cover {
    max-height: 420px;
  }

  .chapter-row {
    grid-template-columns: 48px 1fr;
  }

  .chapter-row .actions {
    grid-column: 1 / -1;
  }

  .form-pair {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding-inline: 12px;
  }

  .book-grid {
    grid-template-columns: 1fr;
  }

  .page-head h1,
  .detail-copy h1,
  .reader-card h1 {
    font-size: 34px;
  }

  .actions,
  .reader-toolbar,
  .reader-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .button,
  .actions form {
    width: 100%;
  }
}
