/* Grammar app styles */

/* ==== Mode picker ==== */
.mode-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px;
  margin-bottom: 24px;
}
.mode-card {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all .15s;
  display: block;
}
.mode-card:hover { border-color: var(--accent); }
.mode-card input { position: absolute; opacity: 0; }
.mode-card input:checked + .mode-body h3::before { content: "✓ "; color: var(--accent); }
.mode-card:has(input:checked) { border-color: var(--accent); background: var(--accent-light); }
.mode-body h3 { font-size: 15px; margin: 0 0 4px; }
.mode-body p { font-size: 13px; color: var(--text-soft); margin: 0; }

/* ==== Part grid ==== */
.part-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
}
.part-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  transition: all .15s;
  position: relative;
  text-align: left;
  border-left: 4px solid var(--accent);
}
.part-card:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.part-card h3 { font-size: 16px; margin: 0 0 4px; }
.part-card .part-meta { font-size: 12px; color: var(--text-soft); }
.part-card .best-score {
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 11px;
  background: var(--accent-light);
  color: var(--accent-dark);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

/* ==== Quiz view ==== */
.quiz-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.quiz-info { font-size: 13px; color: var(--text-soft); flex: 1; }
.quiz-info .dot { margin: 0 6px; }
.quiz-progress { display: flex; align-items: center; gap: 8px; min-width: 180px; }
#quiz-counter { font-size: 13px; color: var(--text-soft); white-space: nowrap; }
.quiz-progress .progress-bar { flex: 1; height: 6px; background: #e6e0dd; border-radius: 999px; overflow: hidden; }
#progress-fill {
  height: 100%;
  background: var(--accent);
  width: 0;
  transition: width .3s;
}

.back-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 14px;
  color: var(--text-soft);
  font-size: 13px;
}
.back-btn:hover { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }

.question-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px 22px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  min-height: 240px;
}
.q-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.q-id {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-light);
  padding: 2px 10px;
  border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.q-type { font-size: 12px; color: var(--text-soft); }
.q-prompt {
  font-size: 18px;
  line-height: 1.6;
  margin: 0 0 18px;
  color: #1a1a1a;
}
.q-prompt .cn { font-family: "PingFang SC", "Microsoft YaHei", "Hiragino Sans GB", serif; font-size: 22px; }
.q-prompt .blank {
  display: inline-block;
  min-width: 60px;
  border-bottom: 2px solid var(--accent);
  margin: 0 4px;
  color: var(--accent);
  font-weight: 700;
  text-align: center;
  padding: 0 4px;
}

/* ==== Inputs ==== */
.q-input {
  width: 100%;
  padding: 12px 14px;
  border: 2px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  transition: border-color .15s;
}
.q-input:focus { outline: none; border-color: var(--accent); }
.q-input.is-correct { border-color: var(--success); background: var(--success-bg); }
.q-input.is-wrong { border-color: var(--error); background: var(--error-bg); }
.q-input[disabled] { background: #f6f3f1; cursor: default; }
.q-cn-input { font-family: "PingFang SC", "Microsoft YaHei", serif; }

.q-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 6px;
}
.opt-btn {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  text-align: left;
  font-size: 15px;
  transition: all .15s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.opt-btn:hover { border-color: var(--accent); }
.opt-btn .opt-label {
  font-weight: 700;
  color: var(--accent);
  font-family: ui-monospace, monospace;
  min-width: 22px;
}
.opt-btn.selected { border-color: var(--accent); background: var(--accent-light); }
.opt-btn.is-correct { border-color: var(--success); background: var(--success-bg); }
.opt-btn.is-wrong { border-color: var(--error); background: var(--error-bg); }

.code-table {
  background: #fff8f3;
  border: 1px dashed var(--accent);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 4px 12px;
  font-size: 13px;
}
.code-table .code-row { display: flex; align-items: center; gap: 6px; }
.code-table code {
  background: #fff;
  color: var(--accent);
  font-weight: 700;
  padding: 1px 8px;
  border-radius: 6px;
  font-family: ui-monospace, monospace;
  min-width: 32px;
  text-align: center;
  border: 1px solid var(--accent-light);
}
.code-table .code-word { font-family: "PingFang SC", "Microsoft YaHei", serif; }

/* ==== Feedback ==== */
.feedback {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  display: none;
}
.feedback.show { display: block; }
.feedback.correct { background: var(--success-bg); color: #0a5a32; border-left: 4px solid var(--success); }
.feedback.wrong { background: var(--error-bg); color: #7a0a1e; border-left: 4px solid var(--error); }
.feedback .lbl { font-weight: 700; margin-bottom: 4px; }
.feedback .ans { font-family: "PingFang SC", "Microsoft YaHei", serif; font-size: 16px; font-weight: 600; }
.feedback .note { font-size: 13px; margin-top: 6px; color: inherit; opacity: .85; }

.dialogue {
  background: #faf6f1;
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 14px;
}
.dialogue .dline {
  margin: 6px 0;
  display: flex;
  gap: 8px;
  align-items: baseline;
  flex-wrap: wrap;
}
.dialogue .speaker {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 12px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  text-align: center;
  line-height: 22px;
  flex-shrink: 0;
}
.dialogue .speaker.b { background: #1a6e9a; }
.dialogue .text { font-family: "PingFang SC", "Microsoft YaHei", serif; font-size: 17px; }
.dialogue .text .blank {
  display: inline-block;
  min-width: 50px;
  border-bottom: 2px solid var(--accent);
  color: var(--accent);
  font-weight: 700;
  text-align: center;
  margin: 0 2px;
  padding: 0 4px;
}
.dialogue .text .blank.is-correct { border-color: var(--success); color: var(--success); background: var(--success-bg); }
.dialogue .text .blank.is-wrong { border-color: var(--error); color: var(--error); background: var(--error-bg); }

/* ==== Quiz nav ==== */
.quiz-nav {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  flex-wrap: wrap;
}
.primary-btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  padding: 11px 22px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  transition: all .15s;
  flex: 1;
  min-width: 120px;
}
.primary-btn:hover { background: var(--accent-dark); }
.primary-btn.success { background: var(--success); }
.primary-btn.success:hover { background: #066434; }
.ghost-btn {
  background: transparent;
  color: var(--text-soft);
  border: 1px solid var(--border);
  padding: 11px 18px;
  border-radius: 10px;
  font-size: 14px;
}
.ghost-btn:hover { border-color: var(--accent); color: var(--accent); }
.danger-btn {
  background: transparent;
  color: var(--error);
  border: 1px solid var(--error);
  padding: 10px 16px;
  border-radius: 10px;
}
.danger-btn:hover { background: var(--error); color: #fff; }

/* ==== Result view ==== */
.result-hero {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 24px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-bottom: 18px;
}
.result-hero .score {
  font-size: 56px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}
.result-hero .score-sub { font-size: 14px; color: var(--text-soft); margin-top: 4px; }
.result-hero .verdict { font-size: 18px; font-weight: 600; margin: 8px 0; }
.result-hero .verdict.good { color: var(--success); }
.result-hero .verdict.ok { color: var(--warning); }
.result-hero .verdict.bad { color: var(--error); }
.result-actions { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.result-actions button { flex: 0 0 auto; }

.result-list { list-style: none; padding: 0; margin: 0; }
.result-list li {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  border-left: 4px solid var(--border);
}
.result-list li.correct { border-left-color: var(--success); }
.result-list li.wrong { border-left-color: var(--error); }
.result-list .rid { font-size: 12px; color: var(--accent); font-weight: 700; font-family: ui-monospace, monospace; }
.result-list .rprompt { font-size: 15px; margin: 4px 0; }
.result-list .rans { font-size: 14px; }
.result-list .rans .lbl { color: var(--text-soft); margin-right: 4px; }
.result-list .rans .val { font-family: "PingFang SC", "Microsoft YaHei", serif; }
.result-list .rans .ok { color: var(--success); font-weight: 600; }
.result-list .rans .ng { color: var(--error); font-weight: 600; }

/* ==== Answer key view ==== */
.answer-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.answer-tab {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 14px;
  font-size: 13px;
  color: var(--text-soft);
}
.answer-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 600; }
.answer-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.answer-table th, .answer-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.answer-table th { background: var(--accent-light); color: var(--accent-dark); font-weight: 700; position: sticky; top: 0; }
.answer-table td.cn,
.answer-table .cn { font-family: "PingFang SC", "Microsoft YaHei", serif; }
.answer-table td.vn { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; }
.answer-table tr:hover td { background: #fff8f3; }
.answer-table .rid { font-family: ui-monospace, monospace; color: var(--accent); font-weight: 700; white-space: nowrap; }

/* ==== Stats view ==== */
.stats-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.stat-card .v { font-size: 22px; font-weight: 700; color: var(--accent); }
.stat-card .l { font-size: 12px; color: var(--text-soft); }
.stats-list { list-style: none; padding: 0; margin: 0; }
.stats-list li {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 6px;
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.stats-list .meta { color: var(--text-soft); font-size: 12px; }


