:root {
  --bg: #f5f3ee;
  --surface: #fffdf9;
  --ink: #2b2b2b;
  --muted: #8a8477;
  --line: #e2ddd2;
  --accent: #5a6b57;      /* приглушённый оливково-зелёный */
  --accent-ink: #fbfcf9;
  --error: #9d4b3f;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 1080px; margin: 0 auto; padding: 24px 20px 60px; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-weight: 600; margin: 0 0 12px; }
h2 { font-weight: 600; font-size: 1.05rem; }
.muted, .meta { color: var(--muted); font-size: .9rem; }
.back { font-size: .9rem; }

/* topbar */
.topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: .5px; }
.topbar nav { display: flex; gap: 16px; }
.topbar .user { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.who { color: var(--muted); font-size: .85rem; }

/* cards & forms */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; padding: 18px 20px; margin: 18px 0;
}
.card.narrow { max-width: 360px; margin: 60px auto; }
label { display: block; margin: 10px 0; font-size: .9rem; color: #4a4a44; }
input, textarea, select {
  width: 100%; margin-top: 4px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
  font: inherit; color: var(--ink);
}
textarea { resize: vertical; }
button {
  padding: 8px 16px; border: 1px solid var(--accent); border-radius: 6px;
  background: var(--accent); color: var(--accent-ink); font: inherit; cursor: pointer;
}
button:hover { filter: brightness(1.06); }
button.primary { padding: 10px 22px; font-weight: 600; }
button.link { background: none; border: none; color: var(--muted); padding: 0; }
button.save { background: #6d5a3f; border-color: #6d5a3f; }
.inline { display: inline; }
.error { color: var(--error); }

/* lists */
.booklist, .filelist { list-style: none; padding: 0; }
.booklist li { padding: 8px 0; border-bottom: 1px solid var(--line); }
.filelist li { padding: 3px 0; }

/* generate bar */
.genbar { display: flex; align-items: center; gap: 14px; margin: 16px 0; }

/* matrix */
.matrix { width: 100%; border-collapse: collapse; margin-top: 12px; }
.matrix th, .matrix td {
  border: 1px solid var(--line); padding: 12px; vertical-align: top; text-align: left;
}
.matrix thead th { background: #efe9dd; width: 42%; }
.matrix .rowlabel { width: 16%; background: #f3eee4; font-weight: 600; }
.content { white-space: pre-wrap; }
.summary { white-space: pre-wrap; max-height: 320px; overflow: auto; background: #faf8f2;
  padding: 10px; border-radius: 6px; font-size: .85rem; }

/* tools */
.tools { margin-top: 10px; }
.tools summary { cursor: pointer; color: var(--muted); font-size: .85rem; }
.tools form { margin: 8px 0; }
.regen { display: flex; gap: 6px; flex-wrap: wrap; }
.regen input { flex: 1 1 160px; }
.regen select { width: auto; }

/* badges */
.badge { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: .72rem; }
.badge.mock { background: #9d4b3f; color: #fff; }
.badge.saved { background: #6d5a3f; color: #fff; }

@media (max-width: 720px) {
  .matrix, .matrix thead, .matrix tbody, .matrix tr, .matrix th, .matrix td { display: block; }
  .matrix thead { display: none; }
  .matrix .rowlabel { width: auto; }
}
