/* ============================================================================
   Rx checking (prescription verification) — immersive station experience.
   Uses the global Ready Line tokens (variables.css) so it themes with the app.
   The clinical board is the dominant surface; controls stay compact and quiet.
   ============================================================================ */

/* Rx checking runs inside the app content column; keep the real sidebar normal
   (no dimming) and hide the floating chat so it can't cover the Next button. */
body.rx-route .aura-chat-root { display: none !important; }
body.rx-route .zoom-banner { display: none !important; }

.rx-app {
  --rx-gap: clamp(12px, 1.6vw, 22px);
  position: fixed; inset: 0; z-index: 1200;
  display: flex; flex-direction: column;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-body);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.rx-stage { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }

.rx-kicker { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase; color: var(--accent); }

/* ---- shared buttons ---- */
.rx-primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border: 0; border-radius: var(--radius-sm); background: var(--accent); color: #fff; font: inherit; font-weight: 700; font-size: 0.92rem; cursor: pointer; transition: background 0.16s, transform 0.16s; }
.rx-primary:hover { background: var(--accent-hover); transform: translateY(-1px); }
.rx-primary:focus-visible, .rx-ghost:focus-visible, .rx-icon-btn:focus-visible,
.rx-exit:focus-visible, .rx-verdict:focus-visible, .rx-pip:focus-visible,
.rx-region-tab:focus-visible, .rx-seg button:focus-visible {
  outline: 3px solid var(--accent-dim);
  outline-offset: 2px;
}
.rx-primary:disabled { background: var(--bg-input); color: var(--text-muted); cursor: not-allowed; transform: none; }
.rx-ghost { display: inline-flex; align-items: center; gap: 7px; padding: 10px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: transparent; color: var(--text-secondary); font: inherit; font-weight: 600; font-size: 0.86rem; cursor: pointer; transition: border-color 0.16s, color 0.16s, background 0.16s; }
.rx-ghost:hover:not(:disabled) { color: var(--text-primary); border-color: var(--border-light); background: var(--bg-card); }
.rx-ghost:disabled { opacity: 0.45; cursor: not-allowed; }
.rx-icon-btn { display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 999px; background: color-mix(in srgb, var(--bg-card) 90%, transparent); color: var(--text-secondary); font: inherit; font-size: 0.78rem; font-weight: 700; cursor: pointer; }
.rx-icon-btn:hover { color: var(--text-primary); border-color: var(--accent); }
.rx-icon-btn svg { width: 16px; height: 16px; }
.rx-primary svg, .rx-ghost svg { width: 16px; height: 16px; }

.rx-exit { position: absolute; top: 18px; left: 20px; z-index: 6; display: inline-flex; align-items: center; gap: 7px; padding: 9px 15px; border: 1px solid var(--border); border-radius: 999px; background: color-mix(in srgb, var(--bg-card) 80%, transparent); color: var(--text-secondary); font: inherit; font-size: 0.84rem; font-weight: 600; cursor: pointer; -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); }
.rx-exit:hover { color: var(--text-primary); border-color: var(--border-light); }
.rx-exit svg { width: 15px; height: 15px; }

/* ================= door / brief ================= */
.rx-door { max-width: 560px; margin: auto; padding: 40px clamp(20px, 4vw, 40px); text-align: left; animation: rx-fade 0.35s ease; }
.rx-door-title { margin: 10px 0 22px; font-family: var(--font-display); font-weight: 600; font-size: clamp(2rem, 1.4rem + 2vw, 2.8rem); line-height: 1.02; }
.rx-door-facts { display: grid; grid-template-columns: repeat(3, auto); gap: 26px; padding: 18px 0; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); margin-bottom: 22px; }
.rx-door-facts > div { display: flex; flex-direction: column; gap: 7px; }
.rx-door-facts span { font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-muted); }
.rx-door-facts strong { font-family: var(--font-mono); font-size: 1.3rem; font-weight: 800; color: var(--text-primary); }
.rx-door-note { color: var(--text-secondary); font-size: 0.96rem; line-height: 1.6; margin: 0 0 26px; }
.rx-door-sub { margin: 14px 0 0; color: var(--text-muted); font-size: 0.8rem; }
.rx-enter { width: 100%; padding: 15px; font-size: 1rem; }

.rx-seg { display: inline-grid; grid-auto-flow: column; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-secondary); }
.rx-seg button { border: 0; border-radius: 7px; padding: 8px 16px; background: transparent; color: var(--text-muted); font: inherit; font-size: 0.84rem; font-weight: 700; cursor: pointer; }
.rx-seg button.on { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-soft); }

/* ================= preparing ================= */
.rx-prepare { margin: auto; display: grid; place-items: center; gap: 14px; text-align: center; color: var(--text-secondary); padding: 40px; }
.rx-prepare-ring { width: 40px; height: 40px; border-radius: 999px; border: 3px solid var(--border); border-top-color: var(--accent); animation: rx-spin 0.8s linear infinite; }
.rx-prepare-sub { color: var(--text-muted); font-size: 0.82rem; }

/* ================= timed station ================= */
.rx-station { flex: 1; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.rx-bar { display: flex; align-items: center; gap: 16px; padding: 14px clamp(16px, 3vw, 34px); border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg-card) 60%, transparent); }
.rx-station .rx-bar { padding-left: 150px; }
.rx-bar-left { display: flex; align-items: center; gap: 14px; }
.rx-bar-right { margin-left: auto; }
.rx-pos { font-size: 0.9rem; color: var(--text-secondary); }
.rx-pos strong { font-family: var(--font-mono); color: var(--text-primary); font-size: 1.05rem; }
.rx-saved { display: inline-flex; align-items: center; gap: 5px; font-size: 0.72rem; font-weight: 700; color: var(--success); opacity: 0; transition: opacity 0.2s ease; }
.rx-saved.is-on { opacity: 1; }
.rx-saved svg { width: 13px; height: 13px; }
.rx-clock { font-family: var(--font-mono); font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--text-primary); padding: 4px 16px; border: 1px solid var(--border); border-radius: 999px; background: var(--bg-secondary); }
.rx-clock.is-low { color: var(--error); border-color: color-mix(in srgb, var(--error) 45%, var(--border)); }
.rx-submit { padding: 11px 18px; }

/* board area */
.rx-board-wrap { min-height: 0; display: flex; padding: var(--rx-gap) clamp(16px, 3vw, 34px); }
.rx-board { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; margin: 0; }
.rx-board-tools { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.rx-regions { display: none; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-secondary); }
.rx-region-tab { border: 0; border-radius: 7px; padding: 8px 12px; background: transparent; color: var(--text-muted); font: inherit; font-size: 0.78rem; font-weight: 700; cursor: pointer; }
.rx-region-tab.on { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow-soft); }
.rx-board-view { flex: 1; min-height: 0; display: flex; align-items: center; justify-content: center; padding: 0; border: 1px solid var(--border); border-radius: var(--radius-md); background: #f7f4ee; overflow: hidden; cursor: zoom-in; box-shadow: var(--shadow-soft); }
.rx-board-img { max-width: 100%; max-height: 100%; width: auto; height: auto; object-fit: contain; display: block; }
.rx-board-hint { text-align: center; color: var(--text-muted); font-size: 0.74rem; }

/* answer bar */
.rx-answer { display: flex; flex-direction: column; gap: 12px; padding: 14px clamp(16px, 3vw, 34px) 18px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg-card) 60%, transparent); }
.rx-answer-main { display: flex; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.rx-verdicts { display: inline-grid; grid-auto-flow: column; gap: 6px; padding: 5px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-secondary); flex: none; }
.rx-verdict { border: 0; border-radius: 8px; padding: 11px 20px; background: transparent; color: var(--text-secondary); font: inherit; font-weight: 700; font-size: 0.9rem; cursor: pointer; transition: background 0.14s, color 0.14s; }
.rx-verdict.on { background: var(--accent); color: #fff; }
.rx-verdict-err.on { background: var(--error); color: #fff; }
.rx-correction { flex: 1; min-width: 260px; display: grid; gap: 5px; }
.rx-correction.is-hidden { display: none; }
.rx-correction label { font-size: 0.76rem; font-weight: 700; color: var(--text-muted); }
.rx-correction textarea { width: 100%; resize: vertical; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-card); color: var(--text-primary); font: inherit; font-size: 0.9rem; line-height: 1.4; }
.rx-correction textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.rx-nav { display: flex; align-items: center; gap: 14px; }
.rx-nav .rx-primary, .rx-nav .rx-ghost { min-width: 92px; }
.rx-progress { display: flex; gap: 8px; margin: 0 auto; }
.rx-pip { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-card); color: var(--text-muted); font-family: var(--font-mono); font-weight: 800; font-size: 0.85rem; cursor: pointer; transition: border-color 0.14s, color 0.14s, background 0.14s, box-shadow 0.14s; }
.rx-pip:hover { border-color: var(--border-light); color: var(--text-secondary); }
.rx-pip.is-answered { color: var(--text-primary); border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); background: var(--accent-dim); }
.rx-pip.is-current { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

/* ================= debrief ================= */
.rx-debrief { width: min(880px, 100%); margin: 0 auto; padding: 46px clamp(18px, 4vw, 34px) 60px; animation: rx-fade 0.3s ease; }
.rx-debrief-head { margin-bottom: 26px; }
.rx-debrief-head h1 { margin: 8px 0 0; font-family: var(--font-display); font-weight: 600; font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.1rem); line-height: 1.15; }
.rx-debrief-head strong { color: var(--accent); }
.rx-debrief-head p { margin: 9px 0 0; color: var(--text-secondary); font-size: 0.9rem; }
.rx-cards { display: grid; gap: 14px; }
.rx-card { border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg-card); padding: 18px 20px; }
.rx-card-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.rx-num { width: 30px; height: 30px; display: grid; place-items: center; border-radius: 8px; background: var(--bg-secondary); color: var(--text-secondary); font-family: var(--font-mono); font-weight: 800; font-size: 0.86rem; }
.rx-verdict-chip { padding: 5px 12px; border-radius: 999px; font-size: 0.76rem; font-weight: 800; letter-spacing: 0.02em; }
.rx-review-btn { margin-left: auto; }
.rx-card-body { margin: 0; display: grid; gap: 12px; }
.rx-card-body > div { display: grid; grid-template-columns: 140px 1fr; gap: 14px; }
.rx-card-body dt { color: var(--text-muted); font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; padding-top: 2px; }
.rx-card-body dd { margin: 0; color: var(--text-primary); font-size: 0.92rem; line-height: 1.5; }
.rx-expected { margin: 0; padding-left: 18px; display: grid; gap: 6px; }
.rx-expected li { color: var(--text-primary); font-size: 0.9rem; line-height: 1.45; }
.rx-credit { display: inline-block; margin: 0 7px 2px 0; padding: 1px 7px; border-radius: 999px; font-size: 0.65rem; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; vertical-align: middle; }
.rx-expected li.is-matched .rx-credit { color: var(--success); background: var(--success-dim); }
.rx-expected li.is-missed .rx-credit { color: var(--error); background: var(--error-dim); }
.rx-sec { display: inline-block; margin-left: 4px; padding: 1px 8px; border-radius: 999px; background: var(--bg-secondary); color: var(--text-muted); font-size: 0.68rem; font-weight: 700; }
.rx-alsonoted { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--border-light); color: var(--text-secondary); font-size: 0.86rem; }
.rx-alsonoted span { font-weight: 700; color: var(--text-primary); }
.rx-alsonoted em { color: var(--text-muted); font-style: normal; }
.rx-rating { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border-light); display: grid; grid-template-columns: minmax(220px, 1fr) auto; align-items: center; gap: 12px 18px; }
.rx-rating-copy { display: grid; gap: 3px; }
.rx-rating-copy strong { color: var(--text-primary); font-size: 0.88rem; }
.rx-rating-copy span { color: var(--text-muted); font-size: 0.75rem; line-height: 1.4; }
.rx-rating-controls { display: flex; align-items: center; gap: 10px; }
.rx-rating-actions { display: flex; gap: 6px; }
.rx-rating-btn { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-secondary); color: var(--text-muted); cursor: pointer; transition: border-color 0.14s, color 0.14s, background 0.14s, transform 0.14s; }
.rx-rating-btn svg { width: 18px; height: 18px; }
.rx-rating-btn:hover:not(:disabled) { color: var(--text-primary); border-color: var(--border-light); transform: translateY(-1px); }
.rx-rating-btn:disabled { cursor: wait; opacity: 0.6; }
.rx-rating-up.is-selected { color: var(--success); border-color: color-mix(in srgb, var(--success) 46%, var(--border)); background: var(--success-dim); }
.rx-rating-down.is-selected { color: var(--error); border-color: color-mix(in srgb, var(--error) 46%, var(--border)); background: var(--error-dim); }
.rx-rating-status { min-width: 92px; color: var(--text-muted); font-size: 0.72rem; }
.rx-rating-note { grid-column: 1 / -1; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 7px 10px; }
.rx-rating-note label { grid-column: 1 / -1; color: var(--text-secondary); font-size: 0.76rem; font-weight: 700; }
.rx-rating-note label span { color: var(--text-muted); font-weight: 500; }
.rx-rating-note textarea { width: 100%; min-height: 64px; resize: vertical; padding: 9px 11px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--bg-secondary); color: var(--text-primary); font: inherit; font-size: 0.82rem; line-height: 1.4; }
.rx-rating-note textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.rx-rating-note .rx-ghost { min-height: 40px; }
.rx-debrief-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }

/* verdict tones */
.rx-tone-good .rx-verdict-chip { background: var(--success-dim); color: var(--success); }
.rx-tone-warn .rx-verdict-chip { background: var(--warning-dim); color: var(--warning); }
.rx-tone-bad .rx-verdict-chip { background: var(--error-dim); color: var(--error); }

/* ================= quick check ================= */
.rx-quickcheck { flex: 1; min-height: 0; display: grid; grid-template-rows: auto minmax(0,1fr) auto; }
.rx-qc-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; flex-wrap: wrap; padding: 20px clamp(16px, 3vw, 34px) 8px; }
.rx-qc-head { padding-left: 150px; }
.rx-qc-head h1 { margin: 6px 0 0; font-family: var(--font-display); font-weight: 600; font-size: 1.4rem; }
.rx-qc-stats { display: flex; gap: 22px; }
.rx-qc-stats > div { display: flex; flex-direction: column; align-items: center; }
.rx-qc-stats strong { font-family: var(--font-mono); font-size: 1.2rem; font-weight: 800; color: var(--text-primary); }
.rx-qc-stats span { font-size: 0.64rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.rx-board-wrap--qc { padding-top: 8px; }
.rx-answer--qc { border-top: 1px solid var(--border); }
.rx-nav--qc { justify-content: flex-end; }
.rx-qc-feedback { display: grid; gap: 10px; padding: 16px clamp(16px, 3vw, 34px) 20px; border-top: 1px solid var(--border); background: color-mix(in srgb, var(--bg-card) 60%, transparent); }
.rx-qc-fb-head { display: flex; align-items: center; gap: 12px; }
.rx-qc-feedback p { margin: 0; color: var(--text-secondary); font-size: 0.9rem; line-height: 1.5; }
.rx-qc-feedback .rx-primary { justify-self: start; }

/* ================= full-screen viewer ================= */
.rx-viewer { position: fixed; inset: 0; z-index: 1400; background: color-mix(in srgb, #05060a 82%, transparent); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); display: flex; flex-direction: column; animation: rx-fade 0.2s ease; }
.rx-viewer-tools { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 18px; }
.rx-viewer-tools .rx-icon-btn { background: rgba(20, 24, 22, 0.7); color: #eef2ee; border-color: rgba(255,255,255,0.18); }
.rx-viewer-tools .rx-icon-btn:hover { border-color: var(--accent); }
.rx-viewer-canvas { flex: 1; min-height: 0; overflow: hidden; display: grid; place-items: center; touch-action: none; }
.rx-viewer-img { max-width: 94%; max-height: 100%; object-fit: contain; cursor: grab; transition: transform 0.06s linear; will-change: transform; user-select: none; }

/* ================= modal ================= */
.rx-modal { position: absolute; inset: 0; z-index: 1300; display: grid; place-items: center; background: color-mix(in srgb, var(--bg-primary) 72%, transparent); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
.rx-modal-card { width: min(440px, 90vw); padding: 26px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--bg-card); box-shadow: var(--shadow-strong); }
.rx-modal-card h2 { margin: 0 0 10px; font-family: var(--font-display); font-weight: 600; font-size: 1.25rem; }
.rx-modal-card p { margin: 0 0 20px; color: var(--text-secondary); line-height: 1.5; font-size: 0.92rem; }
.rx-modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.rx-error { margin: auto; text-align: center; display: grid; gap: 16px; color: var(--text-secondary); max-width: 420px; padding: 40px; }
.rx-error-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }

@keyframes rx-fade { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes rx-spin { to { transform: rotate(360deg); } }

/* ================= responsive ================= */
@media (max-width: 760px) {
  .rx-regions { display: inline-grid; grid-auto-flow: column; }
  .rx-board-view { cursor: pointer; }
  .rx-board-img { max-height: none; height: 100%; }
  .rx-answer-main { flex-direction: column; }
  .rx-verdicts { width: 100%; grid-auto-flow: column; }
  .rx-verdict { flex: 1; }
  .rx-correction { min-width: 0; width: 100%; }
  .rx-nav { flex-wrap: wrap; }
  .rx-progress { order: -1; width: 100%; justify-content: center; }
  .rx-nav .rx-primary, .rx-nav .rx-ghost { flex: 1; }
  .rx-card-body > div { grid-template-columns: 1fr; gap: 4px; }
  .rx-rating { grid-template-columns: 1fr; align-items: start; }
  .rx-rating-controls { justify-content: space-between; }
  .rx-rating-note { grid-template-columns: 1fr; }
  .rx-rating-note .rx-ghost { justify-self: start; }
  .rx-bar { flex-wrap: wrap; }
  .rx-station .rx-bar { padding-left: 124px; }
  .rx-qc-head { padding-left: 124px; }
  .rx-clock { order: 3; }
}

@media (prefers-reduced-motion: reduce) {
  .rx-app *, .rx-viewer-img { animation: none !important; transition: none !important; }
}
