:root {
  --bg: #f7f4ee;
  --panel: #fffdf8;
  --ink: #27323a;
  --muted: #69747d;
  --line: #ded8cc;
  --primary: #1f766d;
  --primary-dark: #155a54;
  --accent: #b4584a;
  --gold: #b9862f;
  --blue: #365f86;
  --shadow: 0 16px 44px rgba(39, 50, 58, .12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", Arial, sans-serif;
  line-height: 1.65;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 22px;
  align-items: center;
  padding: 14px min(5vw, 54px);
  border-bottom: 1px solid rgba(39, 50, 58, .12);
  background: rgba(255, 253, 248, .94);
  backdrop-filter: blur(12px);
}

.brand,
.userbar,
.nav {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 800;
  font-size: 20px;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--primary);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .12);
}

.nav {
  gap: 8px;
  flex-wrap: wrap;
}

.nav a {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 700;
}

.nav a.is-active,
.nav a:hover {
  color: var(--ink);
  background: #ece6da;
}

.userbar {
  gap: 10px;
  justify-content: flex-end;
  min-width: 0;
}

.user-name {
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page {
  width: min(1180px, calc(100% - 32px));
  min-height: calc(100vh - 140px);
  margin: 0 auto;
  padding: 28px 0 54px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 46%);
  gap: 28px;
  align-items: stretch;
  margin-bottom: 28px;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 360px;
}

.eyebrow {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: .04em;
}

h1,
h2,
h3 {
  margin: 0 0 12px;
  line-height: 1.25;
}

h1 {
  font-size: clamp(34px, 6vw, 62px);
}

h2 {
  font-size: 26px;
}

h3 {
  font-size: 19px;
}

p {
  margin: 0 0 14px;
}

.muted {
  color: var(--muted);
}

.hero-media {
  min-height: 360px;
  border-radius: 8px;
  background: url("reading-room.png") center/cover no-repeat;
  box-shadow: var(--shadow);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 18px;
}

.button,
button {
  display: inline-flex;
  min-height: 38px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  transition: .16s ease;
}

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

.button-primary:hover {
  background: var(--primary-dark);
}

.button-secondary {
  color: #fff;
  background: var(--blue);
}

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

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

.button-small {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 14px;
}

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

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.panel,
.card,
.stat,
.form-box,
.reader-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 26px rgba(39, 50, 58, .06);
}

.panel,
.form-box,
.reader-box {
  padding: 22px;
}

.card {
  display: flex;
  flex-direction: column;
  min-height: 260px;
  padding: 18px;
}

.card h3 {
  margin-bottom: 8px;
}

.card .summary {
  flex: 1;
  color: var(--muted);
}

.meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin: 10px 0;
  color: var(--muted);
  font-size: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.badge-reader {
  color: #14514c;
  background: #dcefe9;
}

.badge-author {
  color: #70440c;
  background: #f1dfbd;
}

.badge-admin {
  color: #72372f;
  background: #f1d6d0;
}

.badge-muted {
  color: var(--muted);
  background: #ece6da;
}

.tag {
  display: inline-flex;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  background: #fffaf0;
  font-size: 13px;
}

.stat {
  padding: 16px;
}

.stat strong {
  display: block;
  margin-top: 4px;
  font-size: 28px;
  line-height: 1.1;
}

.toolbar {
  display: flex;
  gap: 12px;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  margin: 24px 0 18px;
}

form.inline,
.filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
}

label {
  font-weight: 800;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid #cfc8bb;
  border-radius: 8px;
  color: var(--ink);
  background: #fffefb;
  font: inherit;
}

input[type="checkbox"],
input[type="radio"] {
  width: auto;
  min-height: auto;
  accent-color: var(--primary);
}

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

.chapter-editor {
  min-height: 420px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin: 14px 0 18px;
}

.tab {
  flex: 1;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: center;
  font-weight: 800;
  background: #fffaf0;
}

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

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 14px;
}

.flash {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 700;
}

.flash-success {
  color: #14514c;
  background: #dcefe9;
}

.flash-warning {
  color: #70440c;
  background: #f1dfbd;
}

.flash-error {
  color: #72372f;
  background: #f1d6d0;
}

.reader-box {
  max-width: 820px;
  margin: 0 auto;
  font-size: 18px;
  line-height: 1.95;
}

.reader-content {
  white-space: pre-wrap;
}

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

.chapter-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

.footer {
  padding: 22px;
  color: var(--muted);
  text-align: center;
}

.install-shell {
  width: min(980px, calc(100% - 28px));
  margin: 32px auto;
}

.install-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.install-step {
  padding: 12px;
  border-radius: 8px;
  background: #ece6da;
  font-weight: 800;
}

.install-step.is-active {
  color: #fff;
  background: var(--primary);
}

@media (max-width: 860px) {
  .topbar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .userbar {
    justify-content: flex-start;
  }

  .hero,
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr;
  }

  .hero-copy,
  .hero-media {
    min-height: 260px;
  }

  .toolbar {
    align-items: stretch;
  }

  .filters,
  .filters .field,
  .filters input,
  .filters select,
  .filters button {
    width: 100%;
  }
}
