:root {
  color-scheme: light dark;
  --fg: #1a1a1a;
  --bg: #ffffff;
  --muted: #6b6b6b;
  --border: #d8d8d8;
  --accent: #2b5fb8;
  --error: #b32424;
  --card-bg: #f6f7f9;
  --success-bg: #eafbea;
  --warn: #9a6b00;
}

@media (prefers-color-scheme: dark) {
  :root {
    --fg: #e8e8e8;
    --bg: #16181c;
    --muted: #9a9a9a;
    --border: #33363c;
    --accent: #7aa6ff;
    --error: #ff7b7b;
    --card-bg: #1f2227;
    --success-bg: #17301a;
    --warn: #e0b74f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--fg);
  background: var(--bg);
}

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1.5rem;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.brand { font-weight: 600; }

nav { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
nav a { color: var(--accent); text-decoration: none; }
nav a:hover { text-decoration: underline; }
.who { color: var(--muted); font-size: 0.9rem; }

.inline-form { display: inline; }
.link-button {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  font: inherit;
  padding: 0;
}

main {
  max-width: 960px;
  margin: 0 auto;
  padding: 1.5rem;
}

.card {
  display: block;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  background: var(--card-bg);
  color: inherit;
  text-decoration: none;
  margin-bottom: 1rem;
}

.card.narrow { max-width: 360px; margin: 2rem auto; }

.cards { display: grid; gap: 1rem; grid-template-columns: repeat(5, 1fr); }
.cards .card h2 { margin: 0 0 0.25rem; font-size: 2rem; }
.cards .card p { margin: 0; color: var(--muted); }
@media (max-width: 700px) { .cards { grid-template-columns: repeat(2, 1fr); } }

form { display: flex; flex-direction: column; gap: 0.85rem; }

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--muted);
}

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

input[type="text"], input[type="email"], input[type="password"], select, textarea {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
}

button[type="submit"] {
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  align-self: flex-start;
}

.error { color: var(--error); }
.success { color: var(--accent); }
.hint { color: var(--muted); font-size: 0.85rem; }
.hint a.filter-active { font-weight: 600; text-decoration: underline; }

table.submissions {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
table.submissions th, table.submissions td {
  text-align: left;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border);
}
table.submissions a { color: var(--accent); text-decoration: none; }
table.submissions a:hover { text-decoration: underline; }

.status {
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8rem;
  background: var(--card-bg);
  border: 1px solid var(--border);
}

.draft-detail {
  display: grid;
  grid-template-columns: 12rem 1fr;
  gap: 0.5rem 1rem;
  margin-bottom: 1.5rem;
}
.draft-detail dt {
  color: var(--muted);
  font-size: 0.85rem;
  align-self: start;
}
.draft-detail dd {
  margin: 0;
}

.answer-list {
  margin: 0;
  padding-left: 1.25rem;
}
.answer-list li.correct-answer {
  font-weight: 600;
  color: var(--accent);
}

.review-actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.review-actions button {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card-bg);
  color: var(--muted);
  cursor: not-allowed;
}
.review-actions button:not([disabled]) {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  cursor: pointer;
}
.review-actions button:not([disabled]):hover {
  opacity: 0.9;
}

.hint.warning {
  color: var(--warn);
  font-weight: 600;
}

.publish-form { margin-bottom: 0.5rem; }
.publish-button {
  padding: 0.5rem 0.9rem;
  border: 1px solid var(--warn);
  border-radius: 6px;
  background: var(--warn);
  color: #1a1a1a;
  cursor: pointer;
}
.publish-button:hover {
  opacity: 0.9;
}

section + section { margin-top: 1.5rem; }

.button {
  display: inline-block;
  padding: 0.6rem 1rem;
  border: none;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  font: inherit;
  text-align: center;
}
.button:hover { opacity: 0.9; }
.button.secondary {
  background: var(--card-bg);
  border: 1px solid var(--border);
  color: var(--fg);
}
.button[aria-disabled="true"] {
  opacity: 0.45;
  pointer-events: none;
}

.filter-form {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem 1rem;
}
.filter-form label { flex: 0 0 auto; min-width: 9rem; }
.filter-actions { display: flex; gap: 0.75rem; align-items: center; }

.health-cards { grid-template-columns: repeat(6, 1fr); }
.health-cards .card h2 { font-size: 1.5rem; }
@media (max-width: 900px) { .health-cards { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 500px) { .health-cards { grid-template-columns: repeat(2, 1fr); } }

.quality-overview {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(20rem, 1fr);
  gap: 1rem;
  align-items: stretch;
}
.quality-score-card, .quality-actions {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem;
}
.quality-score-card { display: flex; align-items: center; gap: 1.25rem; }
.health-score-ring {
  --score: 0;
  width: 148px;
  height: 148px;
  flex: 0 0 148px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(#26834a calc(var(--score) * 1%), #e8edf2 0);
}
.health-score-ring > div {
  width: 112px;
  height: 112px;
  border-radius: 50%;
  background: var(--bg);
  display: grid;
  place-content: center;
  text-align: center;
}
.health-score-ring strong { font-size: 1.65rem; }
.health-score-ring span { color: var(--muted); font-size: 0.76rem; }
.quality-actions { display: flex; flex-direction: column; gap: 0.5rem; }
.quality-actions h2, .quality-score-card h2 { margin-top: 0; }
.health-action {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  border-radius: 9px;
  border-left: 5px solid #64748b;
  background: #f8fafc;
  color: inherit;
  text-decoration: none;
}
.health-action span { color: var(--muted); font-size: 0.84rem; }
.health-action.action-danger { border-left-color: #b91c1c; }
.health-action.action-warn { border-left-color: #d97706; }
.health-action.action-info { border-left-color: #2563eb; }
.health-action.action-opportunity { border-left-color: #059669; }
@media (max-width: 850px) {
  .quality-overview { grid-template-columns: 1fr; }
  .quality-score-card { align-items: flex-start; }
}
@media (max-width: 500px) {
  .quality-score-card { flex-direction: column; }
}

.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.question-thumb {
  max-width: 220px;
  max-height: 160px;
  display: block;
  border-radius: 6px;
  border: 1px solid var(--border);
}

.status-archived { color: var(--muted); }
.status-active { color: var(--accent); }
.status-needs_review { color: var(--warn); }
.status-reviewed { color: var(--accent); }

/* Phase 8B.7: chapter purpose-tag chips */
.tag-chip {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  margin: 0 0.15rem 0.25rem 0;
  border-radius: 0.75rem;
  background: var(--surface, #eef);
  border: 1px solid var(--border, #ccd);
  font-size: 0.85rem;
  white-space: nowrap;
}

/* Phase 8B.8: content-health recommendation badges */
.rec {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 0.4rem;
  font-size: 0.82rem;
  white-space: nowrap;
}
.rec-ok     { background: #e6f4ea; color: #1e7e34; border: 1px solid #b7dfc2; }
.rec-action { background: #e7f0ff; color: #1857c4; border: 1px solid #b9d0f6; }
.rec-info   { background: #eef; color: #3b3bbf; border: 1px solid #ccd; }
.rec-warn   { background: #fdecec; color: #b02a37; border: 1px solid #f2c2c6; }
.rec-muted  { background: #f1f1f1; color: #666; border: 1px solid #ddd; }
.checkbox-label { display: flex; align-items: center; gap: 0.35rem; }
