/* components.css — shared component classes (contract with workers A/B/C) */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  min-width: 0;
}
.card h3 { margin-top: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  min-width: 44px;
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: .95rem;
  line-height: 1.2;
  text-align: center;
}
.btn:hover { background: var(--surface2); text-decoration: none; }
.btn-primary { background: var(--blue); border-color: var(--blue); color: #081226; }
.btn-primary:hover { filter: brightness(1.08); background: var(--blue); }
.btn-gold { background: var(--gold); border-color: var(--gold); color: var(--gold-ink); }
.btn-gold:hover { filter: brightness(1.08); background: var(--gold); }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-danger:hover { background: rgba(248, 113, 113, .12); }
.btn-block { width: 100%; }
.btn-sm { min-height: 40px; padding: 8px 12px; font-size: .88rem; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: .88rem;
  font-weight: 600;
}
.chip[aria-pressed="true"], .chip.active, .chip.on {
  background: var(--gold);
  border-color: var(--gold);
  color: var(--gold-ink);
}

.tag {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--surface2);
  border: 1px solid var(--border);
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.tag.gold { color: var(--gold); border-color: var(--gold); }
.tag.green { color: var(--green); border-color: var(--green); }
.tag.red { color: var(--red); border-color: var(--red); }
.tag.blue { color: var(--blue); border-color: var(--blue); }

/* ---- Question block (shared by practice / exam / results) ---- */
.qblock { margin-bottom: 16px; }
.qtext { font-size: 1.08rem; font-weight: 600; line-height: 1.7; overflow-wrap: break-word; }
.qtext u { text-decoration-thickness: 2px; text-underline-offset: 3px; }

.opts { display: grid; gap: 10px; margin: 14px 0; list-style: none; padding: 0; }
.opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  text-align: start;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: break-word;
}
.opt:hover:not(.disabled) { border-color: var(--gold); background: var(--surface2); }
.opt .opt-letter {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--surface2);
  font-weight: 800;
  font-size: .92rem;
}
.opt.selected { border-color: var(--blue); background: rgba(96, 165, 250, .14); }
.opt.correct { border-color: var(--green); background: rgba(74, 222, 128, .14); }
.opt.correct .opt-letter { background: var(--green); color: #081226; }
.opt.wrong { border-color: var(--red); background: rgba(248, 113, 113, .14); }
.opt.wrong .opt-letter { background: var(--red); color: #2b0a0a; }
.opt.disabled { cursor: default; }
.opt.dim { opacity: .55; }

.ans {
  border-radius: 12px;
  padding: 12px 14px;
  margin: 12px 0;
  font-weight: 700;
  line-height: 1.6;
}
.ans.ok { background: rgba(74, 222, 128, .14); border: 1px solid var(--green); color: var(--green); }
.ans.bad { background: rgba(248, 113, 113, .14); border: 1px solid var(--red); color: var(--red); }
.ans.warn { background: rgba(251, 191, 36, .12); border: 1px solid var(--amber); color: var(--amber); }

.qfig { margin: 0 0 12px; }
.qimg {
  display: block;
  width: 100%;
  max-width: 620px;
  height: auto;
  margin: 0 auto;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.qcap {
  font-size: .85rem;
  color: var(--muted);
  text-align: center;
  margin-top: 6px;
  line-height: 1.5;
}

/* Explanation / basic / related sections */
.sec { margin: 14px 0; padding: 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.sec h4 { font-size: .98rem; margin-bottom: 6px; }
.sec p:last-child { margin-bottom: 0; }
.sec.expl { border-inline-start: 4px solid var(--blue); }
.sec.basic { border-inline-start: 4px solid var(--gold); }
.sec.rel { border-inline-start: 4px solid var(--purple); }
.note {
  border-radius: 12px;
  padding: 10px 14px;
  margin: 12px 0;
  background: rgba(251, 191, 36, .1);
  border: 1px solid var(--amber);
  font-size: .92rem;
  line-height: 1.6;
}

.step { display: flex; gap: 8px; margin: 6px 0; align-items: flex-start; }
.step .snum { font-weight: 800; color: var(--gold); min-width: 28px; text-align: end; flex: 0 0 auto; }

/* ---- Math (formatMath output — values from the interactive edition) ---- */
.mathvar { font-family: Georgia, "Times New Roman", serif; font-style: italic; font-weight: 700; }
.mathfrac {
  display: inline-flex; flex-direction: column; align-items: center;
  vertical-align: middle; line-height: 1.1; font-size: .82em;
  text-align: center; margin: 0 1px;
}
.mathfracnum, .mathfracden { display: block; width: 100%; text-align: center; padding: 0 2px; }
.mathfracden { border-top: 1.5px solid currentColor; }
.mathroot { border-top: 1.5px solid currentColor; padding: 0 1px; }
sup { line-height: 0; }

/* ---- Palette (exam) ---- */
.palette { display: grid; grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 8px; }
.pal-btn {
  min-width: 48px; min-height: 48px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  font-size: .95rem;
  display: grid; place-items: center;
  position: relative;
}
.pal-btn.pal-notvisited { color: var(--muted); }
.pal-btn.pal-visited { border-color: var(--amber); color: var(--amber); }
.pal-btn.pal-answered { background: var(--green); border-color: var(--green); color: #081226; }
.pal-btn.pal-marked { background: var(--purple); border-color: var(--purple); color: #1e1033; }
.pal-btn.pal-answered.pal-marked::after {
  content: "";
  position: absolute;
  top: 4px; inset-inline-end: 4px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--green);
  border: 1.5px solid #1e1033;
}
.pal-btn.pal-current { box-shadow: 0 0 0 2px var(--gold); }

/* ---- Stats / badges / progress ---- */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; min-width: 0; }
.stat-num { font-size: 1.5rem; font-weight: 800; line-height: 1.2; color: var(--gold); overflow-wrap: break-word; }
.stat-label { font-size: .82rem; color: var(--muted); margin-top: 2px; line-height: 1.4; }

.badge {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 999px;
  background: rgba(245, 158, 11, .16);
  border: 1px solid var(--gold);
  color: var(--gold);
  font-size: .85rem; font-weight: 700;
}

.progress { height: 10px; border-radius: 999px; background: var(--surface2); overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; background: var(--gold); transition: width .3s ease; }
.progress-bar.green { background: var(--green); }
.progress-bar.blue { background: var(--blue); }

.view-head { margin-bottom: 16px; }
.view-head h1, .view-head h2 { font-size: 1.35rem; }
.view-head p { color: var(--muted); margin-bottom: 0; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}
.empty .empty-icon { font-size: 2.2rem; display: block; margin-bottom: 8px; }

/* ---- Toasts & modal ---- */
#toast-root {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + 16px);
  transform: translateX(-50%);
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(92vw, 480px);
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
  font-weight: 600;
  font-size: .94rem;
  animation: toast-in .25s ease;
}
.toast .toast-action {
  margin-inline-start: auto;
  flex: 0 0 auto;
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 9px;
  border: none;
  background: var(--gold);
  color: var(--gold-ink);
  font-weight: 800;
}
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

#modal-root:empty { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 130;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, .6);
}
.modal-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 22px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .5);
}
.modal-card h2 { font-size: 1.15rem; margin-bottom: 8px; }
.modal-card p { color: var(--muted); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 700; margin-bottom: 6px; font-size: .92rem; }
.field input[type="text"], .field input[type="number"], .field input[type="search"],
.field select, .field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
}
.field input[type="checkbox"], .field input[type="radio"] { width: 22px; height: 22px; accent-color: var(--gold); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; }

/* ---- Integration patch (coordinator): classes used by view modules that
 * the design system did not define. Kept in one block for easy review. ---- */
.mut { color: var(--muted); font-size: .92em; }
.pill { display: inline-flex; align-items: center; min-height: 28px; padding: 2px 10px; border-radius: 999px; background: var(--surface2); border: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.btn.danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn.danger:hover { background: rgba(248, 113, 113, .12); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .grid2 { grid-template-columns: 1fr; } }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.set-row:last-child { border-bottom: 0; }
.set-row > span { flex: 1; }
.set-row select, .set-row input[type="number"] { max-width: 180px; }
.set-head { display: flex; gap: 12px; align-items: center; margin-bottom: 8px; }
.set-no { flex: 0 0 auto; width: 44px; height: 44px; border-radius: 12px; display: flex; align-items: center; justify-content: center; background: var(--gold); color: var(--gold-ink); font-weight: 700; font-size: 18px; }
.set-info { flex: 1; min-width: 0; }
.subj-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.subj-row:last-child { border-bottom: 0; }
.subj-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
.lib-search { width: 100%; margin-bottom: 10px; }
.lib-filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
.lib-sort { margin-left: auto; }
.lib-count { color: var(--muted); font-size: 14px; }
.chart-row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.chart-side { flex: 1; min-width: 160px; }
.chart-donut { flex: 0 0 auto; }
.chart-num { font-size: 26px; font-weight: 700; line-height: 1.2; }
.chart-cap { color: var(--muted); font-size: 13px; }
.chart-line { width: 100%; height: auto; display: block; }
.backup-slot { display: flex; flex-direction: column; gap: 10px; }
.backup-file { width: 100%; }
.backup-status { color: var(--muted); font-size: 14px; }
.haptic-test { margin-top: 8px; }
.reset-progress { margin-top: 4px; }
.reset-status { color: var(--muted); font-size: 14px; min-height: 1.4em; }
.qcard { margin-bottom: 18px; }
.qmeta { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.qactions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.qnav { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.resline { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.resline:last-child { border-bottom: 0; }
.timer { font-size: clamp(22px, 6vw, 28px); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.pal-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--green); margin-left: 4px; vertical-align: middle; }
.pal-legend { display: inline-flex; align-items: center; gap: 6px; margin-right: 12px; font-size: 13px; }
.pal-legend::before { content: ""; width: 12px; height: 12px; border-radius: 4px; background: var(--border); display: inline-block; }
.pal-legend.pal-visited::before { background: var(--amber); }
.pal-legend.pal-answered::before { background: var(--green); }
.pal-legend.pal-marked::before { background: var(--purple); }
