:root {
  --bg: #f5f5f5;
  --paper: #ffffff;
  --soft: #f1f3f4;
  --soft-blue: #eef4fb;
  --ink: #2d3b45;
  --muted: #6b7780;
  --line: #c7cdd1;
  --accent: #a6192e;
  --accent-dark: #7d1425;
  --accent-soft: #f8e6ea;
  --link: #2d6dcc;
  --amber: #8a5200;
  --amber-soft: #fff2d8;
  --red: #ad2f2f;
  --shadow: 0 2px 8px rgba(45, 59, 69, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
  line-height: 1.55;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 18px;
  align-items: end;
  margin-bottom: 14px;
}

h1 {
  margin: 0;
  font-size: 2rem;
  line-height: 1.15;
  letter-spacing: 0;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.toolbar {
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.search-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 42px auto;
  gap: 8px;
  align-items: end;
}

.search-box {
  display: grid;
  gap: 5px;
}

.search-box span {
  color: var(--muted);
  font-size: 0.82rem;
}

.search-box input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 12px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

.search-box input:focus {
  border-color: var(--link);
  box-shadow: 0 0 0 2px rgba(45, 109, 204, 0.18);
}

.icon-btn,
.command-btn,
.segmented button {
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: var(--paper);
  cursor: pointer;
}

.icon-btn {
  width: 42px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
}

.command-btn {
  padding: 0 14px;
}

.icon-btn:hover,
.command-btn:hover,
.segmented button:hover {
  border-color: var(--link);
  color: var(--link);
}

.filter-grid {
  display: grid;
  grid-template-columns: auto auto auto;
  gap: 10px 14px;
  align-items: end;
  margin-top: 10px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(4, minmax(58px, auto));
  gap: 6px;
}

.segmented button {
  padding: 0 12px;
  white-space: nowrap;
}

.segmented button[aria-pressed="true"] {
  color: #fff;
  background: var(--link);
  border-color: var(--link);
}

.check-field {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  white-space: nowrap;
}

.check-field input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

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

.canvas-panel {
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.panel-head {
  min-height: 56px;
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-head h2,
.quiz-head h2 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.25;
}

.project-list {
  display: grid;
}

.project-row {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 10px 16px;
  align-items: center;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--ink);
  background: var(--paper);
  text-align: left;
  cursor: pointer;
}

.project-row:last-child {
  border-bottom: 0;
}

.project-row:hover,
.project-row:focus {
  color: var(--link);
  background: #f8fafc;
  outline: none;
}

.project-title {
  display: block;
  font-weight: 700;
  font-size: 1rem;
}

.project-action {
  color: var(--muted);
  font-size: 0.9rem;
}

.quiz-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

.back-btn {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 10px;
  color: var(--link);
  background: var(--paper);
  cursor: pointer;
}

.back-btn:hover {
  border-color: var(--link);
}

.question-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
}

.question-card.is-picked {
  outline: 3px solid rgba(45, 109, 204, 0.18);
}

.question-card.is-conflict {
  border-color: #e5bc76;
  background: linear-gradient(0deg, #fffaf0, #fff);
}

.card-head {
  display: flex;
  gap: 7px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.badge {
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  color: var(--muted);
  background: var(--soft);
  font-size: 0.78rem;
}

.badge.type {
  color: #184b77;
  border-color: #c8d8e8;
  background: var(--soft-blue);
}

.badge.warn {
  color: var(--amber);
  border-color: #efd19a;
  background: var(--amber-soft);
}

.question-card h2 {
  margin: 0 0 10px;
  font-size: 1rem;
  line-height: 1.65;
  letter-spacing: 0;
}

.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 0 0 10px;
  padding: 0;
  list-style: none;
}

.option {
  min-height: 38px;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  gap: 7px;
  align-items: start;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfcfa;
}

.option.correct {
  border-color: #95c8ac;
  background: #edf8f2;
}

.option-label {
  width: 24px;
  height: 24px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: #184b77;
  background: var(--soft-blue);
  font-size: 0.78rem;
  font-weight: 700;
}

.answer {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  color: var(--accent-dark);
  font-weight: 700;
}

.answer.is-hidden {
  color: var(--muted);
  font-weight: 500;
}

.conflict-note {
  color: var(--amber);
  font-weight: 600;
}

.empty {
  padding: 32px 16px;
  border: 1px dashed var(--line);
  border-radius: 4px;
  color: var(--muted);
  background: var(--paper);
  text-align: center;
}

mark {
  padding: 0 2px;
  border-radius: 3px;
  color: inherit;
  background: #ffe27a;
}

@media (max-width: 820px) {
  .topbar,
  .filter-grid {
    grid-template-columns: 1fr;
  }

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

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

  .project-row {
    grid-template-columns: 1fr;
  }

  .quiz-head {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 14px;
  }

  h1 {
    font-size: 1.45rem;
  }

  .search-row {
    grid-template-columns: minmax(0, 1fr) 42px;
  }

  .command-btn {
    grid-column: 1 / -1;
  }

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