:root {
  --ink: #17212b;
  --muted: #5d6b78;
  --line: #d9e2ea;
  --panel: #ffffff;
  --soft: #eef6f8;
  --blue: #2864b4;
  --teal: #14876f;
  --amber: #b36b12;
  --rose: #b24b5a;
  --violet: #7251a5;
  --shadow: 0 16px 36px rgba(23, 33, 43, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background:
    linear-gradient(90deg, rgba(20, 135, 111, 0.08), transparent 38%),
    linear-gradient(180deg, #f8fbfc 0%, #edf3f5 100%);
}

button,
input,
select,
.progress-reset-box input {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 24px clamp(18px, 4vw, 56px) 12px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
}

.title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px;
}

.version-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 9px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.score-card {
  min-width: 112px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  box-shadow: var(--shadow);
  text-align: right;
}

.score-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.score-card strong {
  font-size: 28px;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 40px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: end;
  padding: 30px 0 24px;
  border-bottom: 1px solid var(--line);
}

.hero-copy h2 {
  max-width: 760px;
  margin-bottom: 8px;
  font-size: clamp(26px, 4vw, 48px);
  line-height: 1.05;
}

.hero-copy p {
  max-width: 640px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 18px;
}

.quick-actions,
.filter-group,
.quiz-actions,
.card-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.mode-button,
.filter,
.ghost,
.primary {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
}

.mode-button.active,
.filter.active,
.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.view {
  display: none;
  padding-top: 22px;
}

.view.active {
  display: block;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 16px;
  align-items: end;
  margin-bottom: 18px;
}

.search-box span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

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

.search-box textarea {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  color: var(--ink);
  line-height: 1.45;
  outline: none;
  resize: vertical;
}

select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

.search-box input:focus,
.search-box textarea:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(40, 100, 180, 0.12);
}

.pattern-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
  gap: 16px;
}

.pattern-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 18px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(23, 33, 43, 0.06);
}

.pattern-card header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.tag {
  height: fit-content;
  border-radius: 999px;
  padding: 4px 8px;
  color: #fff;
  font-size: 12px;
  font-weight: 800;
}

.tag.Practica { background: var(--blue); }
.tag.Principio { background: var(--teal); }
.tag.Dimension { background: var(--amber); }
.tag.Concepto { background: var(--rose); }
.tag.Cadena { background: var(--violet); }

.pattern-card h3 {
  margin-bottom: 4px;
  font-size: 20px;
}

.trigger-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0;
  padding: 0;
  list-style: none;
}

.trigger-list li {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  background: var(--soft);
  color: var(--ink);
  font-size: 13px;
}

.hint {
  margin-bottom: 0;
  color: var(--muted);
}

.quiz-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 18px;
}

.quiz-panel,
.side-panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.quiz-panel {
  padding: clamp(18px, 4vw, 32px);
}

.quiz-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  color: var(--muted);
  font-weight: 800;
}

#quizQuestion {
  min-height: 92px;
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.12;
}

.answers {
  display: grid;
  gap: 10px;
  margin: 18px 0;
}

.answer {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
  background: #fff;
  text-align: left;
}

.answer.correct {
  border-color: var(--teal);
  background: rgba(20, 135, 111, 0.12);
}

.answer.wrong {
  border-color: var(--rose);
  background: rgba(178, 75, 90, 0.12);
}

.answer.selected {
  border-color: var(--blue);
  background: rgba(42, 103, 191, 0.1);
}

.multi-hint {
  margin: 0;
  color: var(--muted);
  font-weight: 800;
}

.multi-submit {
  justify-self: start;
}

.feedback {
  min-height: 28px;
  color: var(--muted);
  font-weight: 700;
}

.exam-summary {
  display: grid;
  gap: 12px;
}

.exam-result-card,
.audit-line,
.history-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.exam-result-card strong {
  display: block;
  font-size: 30px;
}

.exam-review-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.exam-review-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--soft);
}

.exam-review-item strong,
.history-item strong,
.audit-line strong {
  display: block;
  margin-bottom: 4px;
}

.exam-review-item span,
.history-item span,
.audit-line span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.answer-search-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  align-items: stretch;
}

.answer-search-panel,
.answer-help,
.answer-best,
.answer-empty,
.answer-match {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.answer-search-panel {
  padding: clamp(18px, 4vw, 30px);
}

.answer-search-panel h2 {
  max-width: 780px;
  margin-bottom: 18px;
  font-size: clamp(26px, 4vw, 44px);
  line-height: 1.08;
}

.answer-search-box {
  display: block;
}

.answer-search-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.answer-help {
  padding: 18px;
}

.answer-help p,
.answer-empty p,
.answer-match p {
  color: var(--muted);
  line-height: 1.55;
}

.answer-results {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.answer-empty {
  padding: 22px;
}

.inline-example {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: var(--soft);
  color: var(--blue);
  font-weight: 800;
}

.answer-best {
  padding: clamp(18px, 4vw, 30px);
}

.answer-best-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.answer-best-head h2 {
  margin-bottom: 0;
  color: var(--blue);
  font-size: clamp(30px, 5vw, 56px);
  line-height: 1.02;
}

.answer-best-head > span {
  border-radius: 999px;
  padding: 6px 10px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.answer-best blockquote {
  margin: 0;
  border-left: 4px solid var(--teal);
  padding: 4px 0 4px 14px;
  font-size: clamp(18px, 2.2vw, 24px);
  line-height: 1.35;
}

.answer-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.answer-meta span,
.answer-option-list span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: #fff;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.answer-origin {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: var(--soft);
}

.answer-origin strong {
  color: var(--ink);
}

.answer-origin span,
.answer-origin a,
.answer-origin code {
  color: var(--muted);
  font-size: 13px;
}

.answer-origin a {
  width: fit-content;
  color: var(--blue);
  font-weight: 800;
}

.answer-origin code {
  white-space: normal;
  word-break: break-word;
}

.answer-option-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.answer-option-list span.is-correct {
  border-color: var(--teal);
  background: rgba(20, 135, 111, 0.13);
  color: var(--teal);
}

.answer-explanation {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--muted);
  line-height: 1.55;
}

.answer-explanation summary {
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
}

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

.answer-match-list h3 {
  margin-bottom: 0;
}

.answer-match {
  padding: 14px;
  box-shadow: none;
}

.answer-match div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.answer-match strong {
  color: var(--blue);
}

.answer-match span {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

.answer-match span a {
  color: var(--blue);
  font-weight: 800;
}

.progress-layout {
  display: grid;
  gap: 18px;
}

.progress-panel,
.progress-list-panel article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: clamp(18px, 4vw, 28px);
  box-shadow: var(--shadow);
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.progress-head h2 {
  margin-bottom: 0;
  font-size: clamp(26px, 4vw, 42px);
}

.progress-head > span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.progress-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.progress-stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--soft);
}

.progress-stats span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.progress-stats strong {
  font-size: 28px;
}

.progress-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.import-button {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}

.import-button input {
  display: none;
}

.progress-reset-box {
  margin-top: 16px;
}

.progress-reset-box label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.progress-reset-box input,
.progress-reset-box select {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  outline: none;
}

.progress-list-panel {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.progress-list-panel article {
  box-shadow: none;
}

.progress-list-panel h3 {
  margin-bottom: 6px;
}

.progress-list-panel p {
  color: var(--muted);
  line-height: 1.5;
}

.course-shell {
  display: grid;
  gap: 18px;
}

.course-hero,
.course-detail-card,
.course-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  padding: clamp(18px, 4vw, 28px);
  box-shadow: var(--shadow);
}

.course-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.course-hero h2,
.course-detail-card h2 {
  margin-bottom: 0;
  font-size: clamp(24px, 4vw, 40px);
}

.course-hero > span,
.course-status {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.course-status.passed,
.course-result.ok {
  background: rgba(53, 148, 74, 0.12);
  color: #236536;
}

.course-status.unlocked {
  background: rgba(61, 96, 223, 0.12);
  color: #2447b9;
}

.course-status.locked,
.course-result.warn {
  background: rgba(179, 107, 18, 0.12);
  color: #7a4809;
}

.course-notice {
  color: var(--muted);
  font-weight: 700;
}

.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.course-card.active {
  border-color: var(--blue);
}

.course-card.passed {
  background: linear-gradient(180deg, rgba(61, 96, 223, 0.05), rgba(255, 255, 255, 1));
}

.course-card-head,
.course-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.course-subtitle,
.course-summary,
.course-note {
  color: var(--muted);
  line-height: 1.55;
}

.course-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.course-tags-wrap {
  margin-top: 12px;
}

.course-tag {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #f7fafb;
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.course-subtitle {
  margin: 4px 0 0;
}

.course-stage-list {
  display: grid;
  gap: 14px;
}

.course-stage {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.88), rgba(250,248,244,1));
  padding: 14px;
  box-shadow: var(--shadow);
}

.course-stage.passed {
  border-color: rgba(53, 148, 74, 0.25);
}

.course-stage.locked {
  opacity: 0.72;
}

.course-stage-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 10px;
}

.course-stage h4,
.course-stage h5 {
  margin: 0;
}

.course-stage h5 {
  font-size: 15px;
  margin: 12px 0 8px;
}

.course-stage-actions {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.course-stage .small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}

.course-stage .course-summary {
  margin-top: 8px;
}

.course-card-actions,
.course-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.course-card .small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}

.course-two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
  margin-top: 18px;
}

.course-frameworks,
.course-questions {
  display: grid;
  gap: 10px;
}

.course-framework,
.course-question {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--soft);
  padding: 12px;
}

.course-framework strong {
  display: block;
  margin-bottom: 6px;
}

.course-framework p,
.course-question p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.course-question summary {
  cursor: pointer;
  font-weight: 800;
}

.course-question-bank .course-bank-answer {
  margin-top: 8px;
  padding: 12px 16px;
  background: #f8f6f3;
  border-radius: 8px;
  font-size: 0.92em;
  line-height: 1.5;
}
.course-question-bank .course-bank-options {
  padding-left: 20px;
  margin: 6px 0;
}
.course-question-bank .course-bank-options li {
  margin-bottom: 4px;
}
.course-question-bank .course-bank-correct {
  margin-top: 8px;
  color: #1a7a3a;
  font-weight: 600;
}
.course-question-bank .course-bank-explanation {
  margin-top: 6px;
  color: #444;
  font-size: 0.93em;
}
.course-question-bank .course-bank-source {
  margin-top: 6px;
  opacity: 0.5;
  font-size: 0.82em;
}

.course-list {
  margin: 0 0 0 18px;
  color: var(--text);
  line-height: 1.55;
}

.course-result {
  margin: 14px 0 0;
  font-weight: 800;
}

.progress-list {
  display: grid;
  gap: 10px;
  max-height: 520px;
  overflow: auto;
}

.progress-item {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: #fff;
}

.progress-item strong {
  display: block;
  line-height: 1.35;
}

.progress-item span {
  color: var(--muted);
  font-size: 13px;
}

.progress-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.progress-badges span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--soft);
  font-weight: 800;
}

.progress-badges .is-learned {
  border-color: var(--teal);
  background: rgba(20, 135, 111, 0.12);
  color: var(--teal);
}

.small {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 13px;
}

.progress-empty {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 12px;
}

.side-panel {
  padding: 18px;
}

.side-panel ol {
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.55;
}

.mini-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.bank-tools {
  display: grid;
  gap: 10px;
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.bank-tools h3,
.bank-tools p {
  margin-bottom: 0;
}

.bank-tools p {
  color: var(--muted);
}

.bank-tools label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.mini-stat strong {
  color: var(--blue);
  font-size: 32px;
}

.pattern-study {
  display: grid;
  grid-template-columns: 310px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.pattern-list-panel,
.evidence-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.pattern-list-panel {
  position: sticky;
  top: 14px;
  padding: 16px;
}

.pattern-list-panel p {
  color: var(--muted);
}

.pattern-list {
  display: grid;
  gap: 8px;
  max-height: 620px;
  overflow: auto;
  padding-right: 4px;
}

.pattern-list button {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #fff;
  color: var(--ink);
  text-align: left;
}

.pattern-list button.active {
  border-color: var(--blue);
  background: rgba(40, 100, 180, 0.1);
}

.pattern-list strong,
.pattern-list span {
  display: block;
}

.pattern-list span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.evidence-panel {
  padding: clamp(18px, 4vw, 30px);
}

.evidence-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  margin-bottom: 18px;
}

.evidence-head h2 {
  margin-bottom: 0;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1.05;
}

.trigger-focus,
.detect-box,
.question-evidence {
  border-top: 1px solid var(--line);
  padding-top: 18px;
  margin-top: 18px;
}

.trigger-focus {
  display: grid;
  gap: 6px;
}

.trigger-focus span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.trigger-focus strong {
  color: var(--teal);
  font-size: clamp(24px, 4vw, 38px);
  line-height: 1.05;
}

.study-flip-card {
  min-height: 430px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  perspective: 1000px;
  outline: none;
}

.study-flip-card:focus {
  box-shadow: 0 0 0 4px rgba(40, 100, 180, 0.12);
}

.study-flip-inner {
  position: relative;
  min-height: 430px;
  transition: transform 0.45s ease;
  transform-style: preserve-3d;
}

.study-flip-card.flipped .study-flip-inner {
  transform: rotateY(180deg);
}

.study-face {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow: auto;
  padding: clamp(18px, 4vw, 28px);
  backface-visibility: hidden;
}

.study-face h3 {
  margin-bottom: 14px;
  font-size: clamp(20px, 2.4vw, 30px);
  line-height: 1.18;
}

.study-face p {
  color: var(--muted);
  line-height: 1.5;
}

.flashcard-options {
  display: grid;
  gap: 8px;
  margin-bottom: 4px;
}

.flashcard-option-list {
  display: grid;
  gap: 8px;
}

.flashcard-option-list span,
.flashcard-options .empty {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.flashcard-options .empty {
  color: var(--muted);
}

.flashcard-option-hint {
  margin-bottom: 2px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
}

.study-back {
  transform: rotateY(180deg);
  background: #f4f8fb;
}

.card-origin {
  margin-top: 6px;
  border-top: 1px solid var(--line);
  padding-top: 12px;
  font-size: 13px;
  font-weight: 800;
}

.card-origin a {
  color: var(--blue);
}

.blank-answer {
  width: fit-content;
  max-width: 100%;
  border: 1px dashed var(--blue);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--blue);
  font-weight: 800;
}

.study-flip-card + .card-controls {
  margin-top: 12px;
}

.detect-box p {
  color: var(--muted);
  line-height: 1.55;
}

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

.matched-question {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfdfe;
}

.matched-question blockquote {
  margin: 0 0 8px;
  color: var(--ink);
  line-height: 1.45;
}

.matched-question footer {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.highlight {
  border-radius: 4px;
  padding: 1px 3px;
  background: rgba(179, 107, 18, 0.16);
  color: #7a4809;
  font-weight: 800;
}

@media (max-width: 780px) {
  .topbar,
  .hero,
  .toolbar,
  .quiz-layout,
  .pattern-study,
  .answer-search-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: flex-start;
  }

  .pattern-list-panel {
    position: static;
  }

  .score-card {
    text-align: left;
  }

  .quick-actions {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .quick-actions::-webkit-scrollbar,
  .filter-group::-webkit-scrollbar {
    display: none;
  }

  .filter-group {
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .mode-button,
  .filter,
  .ghost,
  .primary {
    flex: 0 0 auto;
  }

  .course-hero,
  .course-card-head,
  .course-detail-head {
    display: grid;
  }

  .course-card-actions,
  .course-actions {
    display: grid;
  }

  .course-card-actions > button,
  .course-actions > button {
    width: 100%;
  }

  .course-grid,
  .course-two-col,
  .pattern-grid {
    grid-template-columns: 1fr;
  }

  .answer-best-head,
  .answer-match div {
    display: grid;
  }

  .answer-match span {
    white-space: normal;
  }
}

/* ==================== SM-2 Spaced Repetition ==================== */

/* SM-2 Dashboard in Progress tab */
.sm2-dashboard {
  display: flex;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}
.sm2-stat {
  flex: 1;
  min-width: 100px;
  background: var(--surface, #1e1e2e);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.sm2-stat-value {
  display: block;
  font-size: 2rem;
  font-weight: 700;
  color: var(--accent, #d4a843);
  line-height: 1.2;
}
.sm2-stat-label {
  font-size: 0.8rem;
  color: var(--muted, #888);
  margin-top: 4px;
  display: block;
}

/* Weak categories bars */
.weak-categories {
  margin: 16px 0;
  background: var(--surface, #1e1e2e);
  border-radius: 12px;
  padding: 16px;
}
.weak-categories h4 {
  margin: 0 0 12px;
  font-size: 0.9rem;
  color: var(--text, #e0e0e0);
}
.weak-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.weak-label {
  flex: 0 0 140px;
  font-size: 0.8rem;
  color: var(--text, #ccc);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.weak-track {
  flex: 1;
  height: 8px;
  background: var(--bg, #2a2a3e);
  border-radius: 4px;
  overflow: hidden;
}
.weak-fill {
  height: 100%;
  background: linear-gradient(90deg, #e74c3c, #f39c12, #27ae60);
  border-radius: 4px;
  transition: width 0.3s ease;
}
.weak-pct {
  flex: 0 0 40px;
  text-align: right;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted, #888);
}
.sm2-all-strong {
  text-align: center;
  padding: 16px;
  color: var(--accent, #27ae60);
  font-weight: 500;
}

/* Quality rating buttons */
.sm2-quality {
  margin: 16px 0;
  padding: 12px;
  background: var(--surface, #1e1e2e);
  border-radius: 12px;
  border: 1px solid var(--border, #333);
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.sm2-quality-label {
  font-size: 0.85rem;
  color: var(--muted, #999);
  margin: 0;
}
.sm2-quality-buttons {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
}
.sm2-q-btn {
  padding: 6px 14px;
  border: 1px solid var(--border, #444);
  border-radius: 20px;
  background: var(--bg, #2a2a3e);
  color: var(--text, #ccc);
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s ease;
}
.sm2-q-btn:hover {
  border-color: var(--accent, #d4a843);
  color: var(--accent, #d4a843);
  background: rgba(212, 168, 67, 0.1);
}
.sm2-q-btn:active {
  transform: scale(0.95);
}
.sm2-q-0 { border-color: #e74c3c55; color: #e74c3c; }
.sm2-q-2 { border-color: #e67e2255; color: #e67e22; }
.sm2-q-3 { border-color: #f1c40f55; color: #f1c40f; }
.sm2-q-4 { border-color: #2ecc7155; color: #2ecc71; }
.sm2-q-5 { border-color: #27ae6055; color: #27ae60; }
