/* ==========================================================================
 * Partner KOL Compliance Mini-Exam — Design System & Mobile-Native Styles
 * Palette: Deep Legal Navy (#0B2340) + Crisp Paper (#F6F7F9) + Muted Gold Seal
 * All text contrasts verified >= 4.5:1 (WCAG AA).
 * ========================================================================== */

:root {
  --navy-950: #061527;
  --navy-900: #0B2340;
  --navy-800: #113259;
  --navy-700: #1A4A80;
  --navy-100: #E7F0FA;
  --navy-050: #F2F6FB;

  --gold-700: #8A6A12;   /* >= 5.0:1 on white */
  --gold-500: #C9A227;   /* dark surface accent only */
  --gold-300: #EBD48C;   /* >= 10:1 on #0B2340 */
  --gold-100: #FAF2D8;

  --paper: #F6F7F9;
  --surface: #FFFFFF;
  --surface-subtle: #F9FAFC;

  --ink-900: #111827;
  --ink-700: #374151;
  --ink-500: #556173;
  --line-200: #E2E7EE;
  --line-300: #CBD5E1;

  --pass-text: #157A50;
  --pass-bg: #EBF7F1;
  --pass-line: #B7E4CE;

  --fail-text: #B53434;
  --fail-bg: #FDF0F0;
  --fail-line: #F5C2C2;

  --warn-text: #965D06;
  --warn-bg: #FDF4E3;
  --warn-line: #F3D5A3;

  --font-sans: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Inter", system-ui, -apple-system, sans-serif;
  --font-num: "SF Mono", "JetBrains Mono", Consolas, ui-monospace, monospace;

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 14px;
  --r-pill: 999px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
  background: var(--paper);
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-900);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}

::selection {
  background: var(--navy-100);
  color: var(--navy-900);
}

input, textarea, select, button {
  font-family: inherit;
}

input, textarea, select {
  font-size: 16px; /* prevents iOS Safari auto-zoom on focus */
}

button, a, [role="button"] {
  touch-action: manipulation;
  cursor: pointer;
}

button, [role="button"] {
  user-select: none;
  -webkit-user-select: none;
}

:focus-visible {
  outline: 2px solid var(--navy-700);
  outline-offset: 2px;
}

.num {
  font-variant-numeric: tabular-nums;
}

.code-mono {
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line-300); border-radius: 999px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Shell & Sticky Institutional Top Bar ---------- */
.app-shell {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--navy-900);
  color: #FFFFFF;
  padding-top: env(safe-area-inset-top, 0px);
}

.top-bar-inner {
  max-width: 720px;
  margin: 0 auto;
  height: 54px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-seal {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(235, 212, 140, 0.35);
  color: var(--gold-300);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-bar-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.85);
  flex-shrink: 0;
}

.top-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  background: rgba(255, 255, 255, 0.1);
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 500;
}

.top-link {
  color: var(--gold-300);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--r-sm);
}

.progress-rail {
  height: 3px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gold-500);
  transition: width 220ms var(--ease-out);
}

/* ---------- Main Stage ---------- */
.main-stage {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 36px;
}

.main-stage.has-sticky-footer {
  padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px));
}

/* ---------- Folio Sheet Container (Single Elevation, No Nested Cards) ---------- */
.folio {
  background: var(--surface);
  border: 1px solid var(--line-200);
  border-radius: var(--r-lg);
  overflow: hidden;
}

.folio-head {
  padding: 28px 24px 22px;
  border-bottom: 1px solid var(--line-200);
}

.folio-title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.35;
  letter-spacing: -0.02em;
  color: var(--ink-900);
}

.folio-lead {
  margin: 0;
  font-size: 14.5px;
  color: var(--ink-500);
  max-width: 60ch;
}

/* ---------- Exam Rule Bar (Clean Key-Value Table, Not Metric Cards) ---------- */
.rule-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--line-200);
  background: var(--surface-subtle);
}

.rule-cell {
  padding: 14px 16px;
  border-right: 1px solid var(--line-200);
}

.rule-cell:last-child {
  border-right: none;
}

.rule-label {
  display: block;
  font-size: 12px;
  color: var(--ink-500);
  margin-bottom: 2px;
}

.rule-val {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-900);
}

.rule-val.highlight {
  color: var(--navy-700);
}

/* ---------- Check-in Form ---------- */
.form-section {
  padding: 24px;
}

.field {
  margin-bottom: 18px;
}

.field:last-of-type {
  margin-bottom: 24px;
}

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-900);
}

.field-req {
  color: var(--fail-text);
  margin-left: 3px;
}

.field-opt {
  font-size: 12px;
  font-weight: 400;
  color: var(--ink-500);
}

.field-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-300);
  border-radius: var(--r-sm);
  background: var(--surface);
  color: var(--ink-900);
  transition: border-color 140ms var(--ease-out), box-shadow 140ms var(--ease-out);
}

.field-input::placeholder {
  color: #6B7788;
}

.field-input:focus {
  outline: none;
  border-color: var(--navy-700);
  box-shadow: 0 0 0 3px rgba(26, 74, 128, 0.14);
}

.field-error {
  margin: 6px 0 0;
  font-size: 13px;
  color: var(--fail-text);
}

.paper-note {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line-200);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  color: var(--ink-500);
}

/* ---------- QR Scan-to-Test Section ---------- */
.qr-jump-section {
  padding: 20px 24px 22px;
  border-top: 1px solid var(--line-200);
  background: var(--surface-subtle);
  display: flex;
  align-items: center;
  gap: 20px;
}

.qr-jump-frame {
  width: 128px;
  height: 128px;
  padding: 8px;
  border-radius: var(--r-md);
  background: var(--surface);
  border: 1px solid var(--line-200);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.qr-jump-img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.qr-jump-info {
  flex: 1;
  min-width: 0;
}

.qr-jump-title {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink-900);
}

.qr-jump-desc {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--ink-500);
  line-height: 1.55;
}

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

.btn-sm {
  min-height: 36px;
  padding: 0 13px;
  font-size: 13px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 20px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  transition: transform 110ms var(--ease-out), background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.btn:active {
  transform: scale(0.985);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.btn-full {
  width: 100%;
}

.btn-primary {
  background: var(--navy-900);
  color: #FFFFFF;
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--line-300);
  color: var(--ink-900);
}

.btn-subtle {
  background: var(--navy-050);
  border-color: var(--navy-100);
  color: var(--navy-900);
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled) {
    background: var(--navy-800);
  }
  .btn-secondary:hover:not(:disabled) {
    background: var(--surface-subtle);
    border-color: var(--navy-700);
  }
  .btn-subtle:hover:not(:disabled) {
    background: var(--navy-100);
  }
  .top-link:hover {
    background: rgba(255, 255, 255, 0.1);
  }
}

/* ---------- Question Navigator Strip ---------- */
.q-nav-strip {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 6px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-200);
  background: var(--surface-subtle);
}

.q-dot {
  height: 34px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-200);
  background: var(--surface);
  color: var(--ink-500);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform 100ms var(--ease-out), background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.q-dot:active {
  transform: scale(0.95);
}

.q-dot.is-answered {
  background: var(--navy-100);
  border-color: #B9D1EC;
  color: var(--navy-900);
}

.q-dot.is-current {
  background: var(--navy-900);
  border-color: var(--navy-900);
  color: #FFFFFF;
}

@media (hover: hover) and (pointer: fine) {
  .q-dot:hover:not(.is-current) {
    border-color: var(--navy-700);
    color: var(--navy-900);
  }
}

/* ---------- Active Question Area ---------- */
.q-body {
  padding: 24px 24px 28px;
}

.q-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-pill);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.4;
  white-space: nowrap;
}

.badge-type {
  background: var(--navy-100);
  color: var(--navy-900);
}

.badge-multi {
  background: var(--warn-bg);
  color: var(--warn-text);
  border: 1px solid var(--warn-line);
}

.badge-cat {
  background: var(--surface-subtle);
  color: var(--ink-700);
  border: 1px solid var(--line-200);
  font-weight: 500;
}

.badge-pass {
  background: var(--pass-bg);
  color: var(--pass-text);
  border: 1px solid var(--pass-line);
}

.badge-fail {
  background: var(--fail-bg);
  color: var(--fail-text);
  border: 1px solid var(--fail-line);
}

.q-stem {
  margin: 0 0 22px;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.65;
  color: var(--ink-900);
  max-width: 65ch;
}

.q-hint {
  margin: -14px 0 18px;
  font-size: 13px;
  color: var(--ink-500);
}

/* ---------- Option List ---------- */
.option-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.option-row {
  width: 100%;
  min-height: 52px;
  padding: 13px 16px;
  border-radius: var(--r-md);
  border: 1px solid var(--line-200);
  background: var(--surface);
  color: var(--ink-900);
  text-align: left;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 15px;
  line-height: 1.55;
  transition: transform 110ms var(--ease-out), border-color 140ms var(--ease-out), background-color 140ms var(--ease-out);
}

.option-row:active {
  transform: scale(0.99);
}

.option-key {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  border: 1px solid var(--line-300);
  background: var(--surface-subtle);
  color: var(--ink-700);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
  transition: background-color 140ms var(--ease-out), border-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.option-text {
  flex: 1;
  min-width: 0;
}

.option-check {
  width: 20px;
  height: 20px;
  color: var(--navy-700);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  opacity: 0;
  margin-top: 3px;
  transition: opacity 140ms var(--ease-out);
}

.option-row.is-selected {
  border-color: var(--navy-700);
  background: var(--navy-050);
}

.option-row.is-selected .option-key {
  background: var(--navy-900);
  border-color: var(--navy-900);
  color: #FFFFFF;
}

.option-row.is-selected .option-check {
  opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
  .option-row:hover:not(.is-selected) {
    border-color: var(--navy-700);
    background: var(--surface-subtle);
  }
}

/* ---------- Sticky Bottom Navigation Bar ---------- */
.sticky-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line-200);
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
}

.sticky-footer-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.footer-status {
  font-size: 13px;
  color: var(--ink-500);
}

.footer-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ---------- Result Certificate / Official Verdict ---------- */
.verdict-banner {
  padding: 28px 24px;
  color: #FFFFFF;
  background: var(--navy-900);
  position: relative;
}

.verdict-banner.is-pass {
  background: #0B2A38;
}

.verdict-banner.is-fail {
  background: #3A161A;
}

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

.verdict-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 12px;
}

.verdict-banner.is-pass .verdict-status {
  background: rgba(183, 228, 206, 0.16);
  border: 1px solid rgba(183, 228, 206, 0.4);
  color: #D1FAE5;
}

.verdict-banner.is-fail .verdict-status {
  background: rgba(245, 194, 194, 0.16);
  border: 1px solid rgba(245, 194, 194, 0.4);
  color: #FEE2E2;
}

.verdict-heading {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.verdict-sub {
  margin: 0;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.8);
}

.score-seal {
  text-align: right;
  flex-shrink: 0;
}

.score-big {
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  color: var(--gold-300);
}

.verdict-banner.is-fail .score-big {
  color: #FCA5A5;
}

.score-unit {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.78);
  margin-top: 6px;
}

.cert-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  border-bottom: 1px solid var(--line-200);
  background: var(--surface-subtle);
}

.cert-cell {
  padding: 13px 20px;
  border-bottom: 1px solid var(--line-200);
  border-right: 1px solid var(--line-200);
}

.cert-cell:nth-child(even) {
  border-right: none;
}

.cert-cell:nth-last-child(-n+2) {
  border-bottom: none;
}

.cert-label {
  display: block;
  font-size: 12px;
  color: var(--ink-500);
  margin-bottom: 2px;
}

.cert-value {
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-900);
  word-break: break-word;
}

.result-actions {
  padding: 18px 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  border-bottom: 1px solid var(--line-200);
}

/* ---------- Review Section ---------- */
.review-head {
  padding: 18px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line-200);
}

.review-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ink-900);
}

.seg-group {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--r-sm);
  background: var(--paper);
  border: 1px solid var(--line-200);
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--ink-700);
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  transition: background-color 140ms var(--ease-out), color 140ms var(--ease-out);
}

.seg-btn.is-active {
  background: var(--surface);
  color: var(--navy-900);
  box-shadow: 0 1px 2px rgba(11, 35, 64, 0.08);
}

.review-item {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line-200);
}

.review-item:last-child {
  border-bottom: none;
}

.review-q-title {
  margin: 10px 0 12px;
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink-900);
  line-height: 1.6;
}

.review-opts {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.review-opt {
  padding: 8px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line-200);
  font-size: 14px;
  color: var(--ink-700);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.review-opt.is-right {
  background: var(--pass-bg);
  border-color: var(--pass-line);
  color: var(--ink-900);
}

.review-opt.is-wrong-picked {
  background: var(--fail-bg);
  border-color: var(--fail-line);
  color: var(--fail-text);
}

.review-opt-tag {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.review-explain {
  padding: 12px 14px;
  border-radius: var(--r-sm);
  background: var(--surface-subtle);
  border: 1px solid var(--line-200);
  font-size: 13.5px;
  color: var(--ink-700);
}

.review-explain p {
  margin: 0 0 6px;
}

.review-explain p:last-child {
  margin-bottom: 0;
}

.review-basis {
  color: var(--navy-700);
  font-weight: 500;
}

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(6, 21, 39, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-sheet {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--line-200);
  border-radius: var(--r-lg);
  padding: 24px;
}

.modal-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--ink-900);
}

.modal-desc {
  margin: 0 0 20px;
  font-size: 14.5px;
  color: var(--ink-500);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ---------- Toast ---------- */
.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  z-index: 80;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
}

.toast-item {
  background: var(--navy-950);
  color: #FFFFFF;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(6, 21, 39, 0.22);
}

/* ---------- Empty / Loading State ---------- */
.empty-box {
  padding: 40px 24px;
  text-align: center;
  color: var(--ink-500);
}

/* ---------- Responsive Mobile ---------- */
@media (max-width: 600px) {
  .main-stage {
    padding: 14px 12px 28px;
  }
  .folio-head, .form-section, .qr-jump-section, .q-body, .verdict-banner, .review-head, .review-item, .result-actions {
    padding-left: 16px;
    padding-right: 16px;
  }
  .qr-jump-section {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
  }
  .qr-jump-frame {
    width: 136px;
    height: 136px;
  }
  .rule-strip {
    grid-template-columns: repeat(2, 1fr);
  }
  .rule-cell:nth-child(2) {
    border-right: none;
  }
  .rule-cell:nth-child(-n+2) {
    border-bottom: 1px solid var(--line-200);
  }
  .q-nav-strip {
    grid-template-columns: repeat(5, 1fr);
    padding: 12px 16px;
  }
  .cert-meta {
    grid-template-columns: 1fr;
  }
  .cert-cell {
    border-right: none;
    border-bottom: 1px solid var(--line-200);
    padding: 11px 16px;
  }
  .cert-cell:last-child {
    border-bottom: none;
  }
  .verdict-top {
    flex-direction: column;
    gap: 14px;
  }
  .score-seal {
    text-align: left;
  }
  .sticky-footer-inner {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .footer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .footer-status {
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
