:root {
  --fg: #1a1a1a;
  --muted: #6b7280;
  --bg: #f7f7f8;
  --card: #ffffff;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-soft: #dbeafe;
  --good: #16a34a;
  --warn: #d97706;
}

* { box-sizing: border-box; }

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

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 24px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 600; }

.wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.muted { color: var(--muted); font-size: 0.9em; }

.foot {
  text-align: center;
  padding: 24px;
  border-top: 1px solid var(--line);
  margin-top: 32px;
}

/* ---- buttons ---- */
.btn {
  display: inline-block;
  padding: 10px 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 1em;
  cursor: pointer;
  text-decoration: none;
}
.btn:hover { background: #1d4ed8; }
.btn.ghost {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

/* ---- forms ---- */
label { display: block; font-weight: 500; margin: 12px 0 6px; }
input[type="text"], textarea, select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 1em;
  background: var(--card);
}
.radio-row { display: flex; gap: 16px; flex-wrap: wrap; margin: 6px 0; }
.radio-row label {
  font-weight: 400;
  margin: 0;
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
}
.radio-row input { margin-right: 6px; }

/* ---- study page: two columns ---- */
.study-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 16px 0;
}
.col {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.col h3 {
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--accent);
}

/* ---- recommendation card ---- */
.rec {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin-bottom: 8px;
  background: #fafafa;
}
.rec .rank {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9em;
}
.rec .body { flex: 1; }
.rec .title { font-weight: 600; font-size: 0.95rem; }
.rec .subtitle { margin-top: 1px; line-height: 1.3; }
.rec .subtitle .zh { display: block; font-size: 0.85rem; color: #1f2937; }
.rec .subtitle .en { display: block; font-size: 0.8rem; color: var(--muted); font-style: italic; }
.rec .reason {
  color: var(--muted);
  font-size: 0.85em;
  margin-top: 2px;
}
.rec .meta {
  display: flex;
  gap: 12px;
  font-size: 0.8em;
  color: var(--muted);
  margin-top: 4px;
}
.rec .diff-label { font-size: 0.72rem; font-weight: 600; padding: 1px 7px; border-radius: 4px; color: #fff; }
.rec .diff-label.easy { background: var(--good); }
.rec .diff-label.normal { background: var(--warn); }
.rec .diff-label.hard { background: #dc2626; }

/* pick-as-next-step: whole card is a radio */
.form-label { display: block; font-size: 0.88rem; font-weight: 500; color: #1f2937; margin: 6px 0 8px; }

/* admin results: download links, checks, open comments, raw dump */
.dl a { color: var(--accent); text-decoration: none; font-weight: 500; }
.dl a:hover { text-decoration: underline; }
.checks { font-size: 0.9rem; line-height: 1.9; }
.checks code { background: #f3f4f6; padding: 0 5px; border-radius: 3px; }
.open-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.open-cols h3 { font-size: 0.88rem; margin: 0 0 6px; }
.open-cols ul { margin: 0; padding-left: 18px; font-size: 0.82rem; line-height: 1.5; }
.raw-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 6px; }
.raw th, .raw td { white-space: nowrap; font-size: 0.74rem; padding: 4px 8px; }
@media (max-width: 900px) { .open-cols { grid-template-columns: 1fr; } }

/* --- persona card: concept chips + attempt list ------------------------- */
.persona-block { margin: 12px 0; }
.persona-block > strong { display: block; margin-bottom: 7px; font-size: 0.9rem; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-block; padding: 3px 11px; border-radius: 999px;
  background: var(--bg); border: 1px solid var(--line);
  font-size: 0.8rem; line-height: 1.5;
}
.attempts { list-style: none; padding-left: 0; margin: 2px 0 0; }
.attempt { display: flex; align-items: baseline; gap: 8px; padding: 3px 0; font-size: 0.88rem; }
.attempt-mark { font-weight: 700; flex: none; width: 1em; }
.attempt.ok .attempt-mark { color: #16a34a; }
.attempt.bad .attempt-mark { color: #dc2626; }
.attempt-title { flex: 1; }
.attempt-en { color: var(--muted); font-size: 0.8rem; }
.attempt-band { margin-top: 10px; }
.band-label {
  display: inline-block; font-size: 0.76rem; font-weight: 600;
  color: var(--muted); padding: 1px 8px; margin-bottom: 2px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 5px;
}

.rec.pickable { cursor: pointer; position: relative; transition: border-color 0.12s, background 0.12s, box-shadow 0.12s; }
.rec.pickable:hover { border-color: #93c5fd; background: #f4f8ff; }
.rec .pick-radio {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--accent);
}
.rec.pickable:has(.pick-radio:checked) {
  border-color: var(--accent);
  background: #eef4ff;
  box-shadow: 0 0 0 1px var(--accent);
}

/* ---- Likert ---- */
.likert {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-top: 24px;
}
.likert h3 { margin-top: 0; }
.likert-legend { font-size: 0.78rem; color: var(--muted); margin: 2px 0 6px; }
.likert-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px 4px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.likert-grid .q {
  grid-column: 1 / -1;
  font-size: 0.85rem;
  line-height: 1.32;
  margin-bottom: 2px;
}
.likert-grid .opt { text-align: center; }
.likert-grid .opt input { margin: 0; cursor: pointer; width: 17px; height: 17px; }
.likert-grid label.opt {
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 7px 0;
  border-radius: 6px;
  transition: background 0.12s;
}
.likert-grid label.opt:hover { background: #eef2f7; }
.likert-grid label.opt:has(input:checked) { background: #d3e2fb; }
.likert-head { padding: 0 0 4px; border-bottom: 2px solid var(--line); }
.likert-head .likert-num { font-weight: 600; color: var(--muted); font-size: 0.78rem; }
.pick-label { display: block; margin: 14px 0 4px; font-size: 0.88rem; font-weight: 500; }
.attention-grid { grid-template-columns: repeat(5, 44px); max-width: 300px; }

.section-divider {
  margin: 20px 0;
  border: none;
  border-top: 1px dashed var(--line);
}

/* ---- results (admin) ---- */
table.results {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}
table.results th, table.results td {
  padding: 8px 12px;
  border: 1px solid var(--line);
  text-align: left;
}
table.results th { background: var(--accent-soft); font-weight: 600; }
table.results td.num { text-align: right; font-variant-numeric: tabular-nums; }

.callout {
  padding: 12px 16px;
  background: var(--accent-soft);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  margin: 12px 0;
}

/* ---- three-column study layout (T1b, STUDY_PLAN §3.4) ---- */
.study-grid-3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 18px;
  margin: 18px 0;
}
@media (max-width: 960px) {
  .study-grid-3 { grid-template-columns: 1fr; }
}
.study-grid-3 .col { min-width: 0; }

/* ---- overall preference (Q8): three list cards in a row ---- */
.overall-pick {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 8px 0 12px;
}
.overall-pick .rec { flex: 1 1 120px; min-width: 120px; }

/* ---- persona card (onboarding) ---- */
.persona {
  background: #f0f9ff;
  border-left: 4px solid #1d4ed8;
}
.persona h3 { margin-top: 0; color: #1d4ed8; }
