/* ============================================================
   sqe-trainer — component & layout styles
   ============================================================ */

/* ---------- App shell ---------- */
.shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: var(--s5);
  padding: 0 var(--s5);
  height: 56px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 20;
}
.wordmark {
  font-family: var(--font-reading);
  font-weight: 600; font-size: 17px; letter-spacing: -0.01em;
  color: var(--text); text-decoration: none;
  display: flex; align-items: baseline; gap: 7px;
  background: none; border: none; padding: 0; cursor: pointer;
  white-space: nowrap;
}
.wordmark small {
  font-family: var(--font-ui); font-weight: 500; font-size: 10.5px;
  text-transform: uppercase; letter-spacing: .12em; color: var(--muted);
}
.topnav { display: flex; gap: var(--s2); margin-left: var(--s4); }
.topnav button {
  background: none; border: none; cursor: pointer;
  font-family: var(--font-ui); font-size: var(--fs-body-ui);
  color: var(--muted); padding: 6px 10px; border-radius: var(--r-ctrl);
  transition: color .15s var(--ease), background .15s var(--ease);
}
.topnav button:hover { color: var(--text); background: var(--surface-2); }
.topnav button.active { color: var(--text); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: var(--s3); }

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: var(--muted);
}

.page {
  width: 100%; max-width: 880px; margin: 0 auto;
  padding: var(--s7) var(--s5) var(--s9);
  flex: 1;
}
.page-narrow { max-width: 760px; }

.page-head { margin-bottom: var(--s6); }
.page-head .t-small { margin-top: var(--s2); display: block; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: var(--font-ui); font-size: var(--fs-body-ui); font-weight: 600;
  border-radius: var(--r-ctrl); cursor: pointer;
  padding: 9px 18px; min-height: 38px;
  border: 1px solid transparent;
  transition: background .15s var(--ease), border-color .15s var(--ease),
              color .15s var(--ease), opacity .15s var(--ease);
  text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { filter: brightness(1.08); }
.btn-primary:active { filter: brightness(.95); }
.btn-primary:disabled { opacity: .45; cursor: not-allowed; filter: none; }

.btn-secondary {
  background: var(--surface); color: var(--text);
  border-color: var(--border-strong);
}
.btn-secondary:hover { border-color: var(--muted); background: var(--surface-2); }
.btn-secondary:disabled { opacity: .45; cursor: not-allowed; }

.btn-ghost { background: none; color: var(--muted); padding: 9px 12px; }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }

.btn-lg { padding: 12px 24px; font-size: 15px; min-height: 46px; }
.btn-block { width: 100%; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--shadow-card);
}
.card-pad { padding: var(--s5); }

/* ---------- Form inputs ---------- */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: var(--fs-small); font-weight: 600; color: var(--text); }
.input, .select {
  font-family: var(--font-ui); font-size: var(--fs-body-ui);
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-ctrl);
  padding: 9px 12px; min-height: 40px;
  width: 100%;
  transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.input::placeholder { color: var(--muted); }
.input:focus, .select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* ---------- Status pill ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 600;
  padding: 3px 10px; border-radius: 99px;
  border: 1px solid var(--border);
  color: var(--muted); background: var(--surface);
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); }
.pill-ready { color: var(--correct); border-color: transparent; background: var(--correct-soft); }
.pill-ready .dot { background: var(--correct); }
.pill-processing { color: var(--muted); background: var(--surface-2); border-color: transparent; }
.pill-processing .dot { background: var(--muted); animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: 1; } }

/* ---------- Theme toggle ---------- */
.theme-toggle {
  display: inline-flex; align-items: center;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 99px; padding: 2px; cursor: pointer; gap: 2px;
}
.theme-toggle span {
  width: 26px; height: 26px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 13px;
  transition: background .2s var(--ease), color .2s var(--ease);
}
.theme-toggle span.on {
  background: var(--surface); color: var(--text);
  box-shadow: var(--shadow-card); border: 1px solid var(--border);
}

/* ---------- Option cards (A–E) ---------- */
.options { display: flex; flex-direction: column; gap: var(--s3); max-width: var(--measure); }
.option {
  display: flex; gap: var(--s4); align-items: flex-start;
  width: 100%; text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  padding: var(--s4) var(--s5);
  cursor: pointer;
  font-family: var(--font-reading);
  font-size: calc(var(--fs-body-reading) - 1px);
  line-height: 1.6;
  color: var(--text);
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.option:hover { border-color: var(--border-strong); background: var(--surface-2); }
.option .opt-key {
  flex: none;
  width: 28px; height: 28px; margin-top: 1px;
  border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-ui); font-size: 13px; font-weight: 600;
  color: var(--muted);
  transition: all .15s var(--ease);
}
.option.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.option.selected .opt-key { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* review states */
.option.correct {
  border-color: var(--correct);
  background: var(--correct-soft);
  cursor: default;
}
.option.correct .opt-key { background: var(--correct); border-color: var(--correct); color: #fff; }
.option.incorrect {
  border-color: var(--incorrect);
  background: var(--incorrect-soft);
  cursor: default;
}
.option.incorrect .opt-key { background: var(--incorrect); border-color: var(--incorrect); color: #fff; }
.option.dim { cursor: default; }
.option.dim:hover { border-color: var(--border); background: var(--surface); }

.opt-flag {
  margin-left: auto; flex: none; align-self: center;
  font-family: var(--font-ui); font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: .08em;
}
.opt-flag.ok { color: var(--correct); }
.opt-flag.bad { color: var(--incorrect); }

/* ---------- Exam chrome ---------- */
.exam-bar {
  display: flex; align-items: center; gap: var(--s5);
  padding: 0 var(--s5); height: 52px;
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 20;
}
.exam-progress { display: flex; flex-direction: column; gap: 5px; flex: 1; max-width: 320px; }
.exam-progress .track {
  height: 3px; border-radius: 2px; background: var(--border);
  overflow: hidden;
}
.exam-progress .fill {
  height: 100%; background: var(--accent); border-radius: 2px;
  transition: width .35s var(--ease);
}

.timer {
  display: inline-flex; align-items: center; gap: 8px;
  font-variant-numeric: tabular-nums;
  font-size: 14px; color: var(--muted);
  background: none; border: none; cursor: pointer;
  padding: 6px 10px; border-radius: 99px;
  font-family: var(--font-ui);
  transition: background .15s var(--ease);
}
.timer:hover { background: var(--surface-2); }
.timer .timer-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); opacity: .6; }
.timer.low { color: var(--text); }
.timer.low .timer-dot { background: var(--incorrect); opacity: 1; }

.exam-body { padding: var(--s7) var(--s5) 140px; max-width: 820px; margin: 0 auto; }
.scenario-block { margin-bottom: var(--s6); }

.exam-footer {
  position: fixed; bottom: 0; left: 0; right: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: var(--s4) var(--s5);
  display: flex; justify-content: center;
  z-index: 20;
}
.exam-footer-inner {
  width: 100%; max-width: 820px;
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
}

/* ---------- Dropzone ---------- */
.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-card);
  background: var(--surface);
  padding: var(--s7) var(--s5);
  display: flex; flex-direction: column; align-items: center; gap: var(--s3);
  text-align: center; cursor: pointer;
  transition: border-color .15s var(--ease), background .15s var(--ease);
}
.dropzone:hover, .dropzone.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone .dz-icon {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--muted);
}
.dropzone.over .dz-icon { background: var(--surface); }

/* ---------- Lists / rows ---------- */
.rowlist { display: flex; flex-direction: column; }
.rowlist > * + * { border-top: 1px solid var(--border); }
.listrow {
  display: flex; align-items: center; gap: var(--s4);
  padding: var(--s4) var(--s5);
  background: none; border: none; width: 100%; text-align: left;
  font-family: var(--font-ui); font-size: var(--fs-body-ui); color: var(--text);
  cursor: pointer; transition: background .15s var(--ease);
}
.listrow:hover { background: var(--surface-2); }
.listrow.static { cursor: default; }
.listrow.static:hover { background: none; }

/* ---------- Segmented control ---------- */
.segmented {
  display: inline-flex; padding: 3px; gap: 2px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: calc(var(--r-ctrl) + 3px);
}
.segmented button {
  font-family: var(--font-ui); font-size: var(--fs-small); font-weight: 600;
  color: var(--muted); background: none;
  border: 1px solid transparent; border-radius: var(--r-ctrl);
  padding: 7px 16px; cursor: pointer;
  transition: all .15s var(--ease);
}
.segmented button.on {
  background: var(--surface); color: var(--text);
  border-color: var(--border); box-shadow: var(--shadow-card);
}

/* ---------- Score ---------- */
.score-hero { display: flex; align-items: baseline; gap: var(--s3); }
.score-hero .big {
  font-family: var(--font-reading); font-weight: 600;
  font-size: 64px; line-height: 1; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.score-hero .of { font-size: 22px; color: var(--muted); font-family: var(--font-reading); }

.qdot {
  width: 30px; height: 30px; border-radius: var(--r-ctrl);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
  border: 1px solid var(--border); color: var(--muted); background: var(--surface);
  cursor: pointer; transition: transform .1s var(--ease);
  font-family: var(--font-ui);
}
.qdot:hover { transform: translateY(-1px); }
.qdot.ok { background: var(--correct-soft); color: var(--correct); border-color: transparent; }
.qdot.bad { background: var(--incorrect-soft); color: var(--incorrect); border-color: transparent; }

/* ---------- Login ---------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: var(--s5);
}
.login-card { width: 100%; max-width: 380px; }

/* ---------- Explanation blocks ---------- */
.expl {
  display: flex; gap: var(--s4);
  padding: var(--s4) 0;
}
.expl + .expl { border-top: 1px solid var(--border); }
.expl .opt-key { margin-top: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  .topbar { padding: 0 var(--s4); gap: var(--s3); }
  .topnav { display: none; }
  .mobile-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    display: flex; justify-content: space-around;
    background: var(--bg); border-top: 1px solid var(--border);
    padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  }
  .mobile-nav button {
    background: none; border: none; cursor: pointer;
    font-family: var(--font-ui); font-size: 11px; font-weight: 600;
    color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: 3px;
    padding: 6px 14px; border-radius: var(--r-ctrl); min-width: 64px;
  }
  .mobile-nav button.active { color: var(--accent); }
  .page { padding: var(--s5) var(--s4) calc(var(--s9) + 56px); }
  .exam-body { padding: var(--s5) var(--s4) 150px; }
  .option { padding: var(--s4); gap: var(--s3); }
  .exam-bar { gap: var(--s3); }
  .exam-progress { max-width: none; }
  .score-hero .big { font-size: 48px; }
}
@media (min-width: 641px) {
  .mobile-nav { display: none; }
}
