/* Grammar register + practice bank. Keeps the review desk palette. */

.grammar-hero { padding-top: 8px; margin-bottom: 28px; }
.grammar-hero.compact { margin-bottom: 18px; }
.grammar-hero h1 { max-width: 22ch; }
.grammar-hero h1 em { color: var(--accent-dark); font-style: italic; }
.grammar-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 20px; }
.grammar-progress-note { color: var(--muted); font-size: 0.82rem; font-family: var(--mono); }

.grammar-families {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 0 0 34px;
}
.grammar-family {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  color: var(--ink);
  background: #fbf7ef;
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.grammar-family:hover { text-decoration: none; border-color: var(--line-strong); }
.grammar-family-id { color: var(--accent-dark); font-family: var(--mono); font-size: 0.72rem; letter-spacing: 0.1em; }
.grammar-family strong { font-family: var(--serif); font-size: 1.05rem; }
.grammar-family small { color: var(--muted); font-size: 0.74rem; }
.grammar-family .progress { margin-top: 8px; }

.grammar-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 34px;
  align-items: start;
}
.grammar-sidebar { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 16px; max-height: calc(100vh - 110px); overflow: auto; }
.grammar-sidebar-card { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: #fbf7ef; }
.grammar-sidebar-card .toc { font-size: 0.8rem; }
.grammar-sidebar-card .toc ul { list-style: none; padding-left: 12px; margin: 4px 0; }
.grammar-sidebar-card .toc > ul { padding-left: 0; }
.grammar-sidebar-card .toc li { margin: 4px 0; }
.grammar-sidebar-card .toc a { color: var(--ink-soft); }
.grammar-sidebar-card .toc a:hover { color: var(--accent-dark); }
.grammar-sidebar-card .note { margin-bottom: 10px; }

.grammar-doc { min-width: 0; }
.grammar-doc > h1:first-child { display: none; }
.grammar-doc h1, .grammar-doc h2, .grammar-doc h3 { scroll-margin-top: 90px; }
.grammar-doc h2 { margin: 38px 0 12px; padding-top: 18px; border-top: 1px solid var(--line); }
.grammar-doc h3 { margin: 26px 0 10px; }
.grammar-doc p { margin: 10px 0; }
.grammar-doc ul, .grammar-doc ol { padding-left: 22px; }
.grammar-doc li { margin: 6px 0; }
.grammar-doc code { padding: 1px 5px; border: 1px solid var(--line); border-radius: 5px; background: #fbf7ef; }
.grammar-doc pre { overflow: auto; padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #26221c; color: #f4efe5; }
.grammar-doc pre code { border: 0; background: transparent; color: inherit; padding: 0; }
.grammar-doc table { width: 100%; border-collapse: collapse; margin: 16px 0; font-size: 0.85rem; }
.grammar-doc th, .grammar-doc td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.grammar-doc th { background: var(--paper-2); font-family: var(--sans); font-size: 0.72rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.grammar-doc tr:nth-child(even) td { background: #fbf7ef; }
.grammar-doc blockquote { margin: 16px 0; padding: 2px 16px; border-left: 3px solid var(--accent); color: var(--ink-soft); }
.grammar-doc a { text-decoration: underline; text-decoration-color: var(--line-strong); text-underline-offset: 3px; }
.grammar-doc hr { border: 0; border-top: 1px solid var(--line); margin: 28px 0; }

.rule-layout { grid-template-columns: minmax(0, 1fr) 300px; }
.rule-body { padding: 22px 24px; border: 1px solid var(--line); border-radius: 14px; background: #fbf7ef; box-shadow: var(--shadow); }
.rule-hero-id { color: var(--accent-dark); font-family: var(--mono); font-size: 0.55em; letter-spacing: 0.04em; }

.grammar-family-section { margin: 30px 0; }
.grammar-family-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.grammar-family-head h2 { margin: 0; }
.rule-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.rule-card { display: flex; flex-direction: column; gap: 8px; padding: 15px; border: 1px solid var(--line); border-radius: 12px; background: #fbf7ef; box-shadow: var(--shadow); }
.rule-card header { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.rule-id { color: var(--accent-dark); font-family: var(--mono); font-size: 0.72rem; }
.rule-score { color: var(--muted); font-family: var(--mono); font-size: 0.72rem; }
.rule-card h3 { margin: 0; font-size: 1rem; line-height: 1.25; }
.rule-card h3 a { color: var(--ink); }
.rule-card .progress { margin-top: auto; }
.rule-card footer { display: flex; align-items: center; gap: 8px; }
.rule-card footer .button.primary { margin-left: auto; }

.grammar-filter { margin: 18px 0 24px; }
.grammar-total { height: 8px; margin-bottom: 22px; }
.rule-exercise-list { list-style: none; padding: 0; margin: 0; }
.rule-exercise-list li { display: flex; justify-content: space-between; gap: 8px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 0.78rem; }
.rule-exercise-list li:last-child { border-bottom: 0; }
.rule-exercise-list a { font-family: var(--mono); font-size: 0.72rem; }
.rule-exercise-list li span { color: var(--muted); }
.rule-exercise-list li.is-correct a { color: var(--green); }
.rule-exercise-list li.is-correct::after { content: "✓"; color: var(--green); }
.rule-exercise-list li.is-tried a { color: var(--red); }

.exercise-shell { max-width: 850px; margin: 0 auto; }
.exercise-head { display: flex; align-items: end; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.exercise-head h1 { font-family: var(--mono); font-size: clamp(1.2rem, 2.2vw, 1.7rem); letter-spacing: 0; }
.exercise-score { text-align: right; }
.exercise-score strong { display: block; font-family: var(--mono); font-size: 1.2rem; }
.exercise-score span { color: var(--muted); font-size: 0.72rem; }
.exercise-card { margin-top: 22px; padding: clamp(20px, 4vw, 34px); border: 1px solid var(--line); border-radius: 14px; background: #fbf7ef; box-shadow: var(--shadow); }
.exercise-meta { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.exercise-meta .badge.ok { border-color: var(--green); color: var(--green); }
.exercise-prompt { font-family: var(--serif); font-size: clamp(1.18rem, 2.4vw, 1.55rem); line-height: 1.35; margin: 8px 0 22px; }
.exercise-prompt p { margin: 0; }
.exercise-prompt code { font-size: 0.88em; }
.answer-label { display: block; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.12em; text-transform: uppercase; margin-bottom: 6px; }
.answer-input { width: 100%; padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 9px; background: #fffdf8; font: inherit; font-size: 1.05rem; }
.answer-input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.choice-list { display: flex; flex-direction: column; gap: 8px; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: #fffdf8; cursor: pointer; }
.choice:hover { border-color: var(--line-strong); }
.choice input { margin-top: 4px; accent-color: var(--accent); }
.choice code { padding: 1px 4px; border: 1px solid var(--line); border-radius: 4px; }
.exercise-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 20px; }
.exercise-actions .link { margin-left: auto; font-size: 0.8rem; }
.answer-result { margin-top: 22px; padding: 15px 17px; border: 1px solid var(--line); border-left: 4px solid var(--muted); border-radius: 10px; background: #fffdf8; }
.answer-result.correct { border-left-color: var(--green); }
.answer-result.wrong { border-left-color: var(--red); }
.answer-result strong { display: block; margin-bottom: 4px; }
.answer-result p { margin: 8px 0; }
.answer-result small { color: var(--muted); }
.exercise-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; margin-top: 20px; }

@media (max-width: 980px) {
  .grammar-families { grid-template-columns: repeat(2, 1fr); }
  .grammar-layout, .rule-layout { grid-template-columns: 1fr; }
  .grammar-sidebar { position: static; max-height: none; order: 2; }
  .grammar-doc { order: 1; }
  .rule-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .grammar-families, .rule-grid { grid-template-columns: 1fr; }
  .grammar-actions .button { width: 100%; text-align: center; }
  .grammar-progress-note { width: 100%; }
  .exercise-head { align-items: start; }
  .exercise-score { display: none; }
  .exercise-actions .link { margin-left: 0; }
}

/* ---------- scores ---------- */

.score-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 18px 0;
}
.score-strip > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 13px 15px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fbf7ef;
}
.score-strip strong { font-family: var(--mono); font-size: 1.45rem; line-height: 1; }
.score-strip span { color: var(--muted); font-size: 0.72rem; }
.score-strip .score-link { align-items: center; justify-content: center; }
.score-table .rank { display: inline-grid; place-items: center; min-width: 26px; height: 26px; border-radius: 999px; background: var(--paper-2); font-family: var(--mono); font-size: 0.74rem; }
.score-table tr.is-me td { background: #fff8e8; }
.score-table td { vertical-align: middle; }
.score-table td:nth-child(3) strong { font-family: var(--mono); font-size: 1.05rem; }
.score-note { margin-top: 16px; }
