:root {
  --rp-primary: #1f6feb;
  --rp-primary-ink: #0b3d91;
  --rp-accent: #ff6a2b;
  --rp-ok: #16a34a;
  --rp-bad: #dc2626;
  --rp-ink: #14202e;
  --rp-sub: #4a5a6c;
  --rp-line: #e3e8ee;
  --rp-bg: #f5f7fa;
  --rp-card: #ffffff;
  --rp-hi-p: #ff3b30;
  --rp-hi-s: #ffb020;
  --topbar: 56px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--rp-ink);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--rp-bg); }
button, select, input { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------------- top bar */
.topbar {
  height: var(--topbar); display: flex; align-items: center; gap: 18px; padding: 0 18px;
  background: var(--rp-card); border-bottom: 1px solid var(--rp-line); position: relative; z-index: 3;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 800; letter-spacing: -0.01em; font-size: 18px; }
.brand-mark { width: 24px; height: 24px; border-radius: 6px; background: url(../img/mark-64.png) center/contain no-repeat; }
.drill-tabs { display: flex; gap: 6px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.drill-tabs::-webkit-scrollbar { display: none; }
.drill-tabs button {
  border: 1px solid var(--rp-line); background: var(--rp-card); border-radius: 999px; padding: 7px 14px; cursor: pointer;
  white-space: nowrap; font-size: 14px; font-weight: 600; color: var(--rp-sub);
}
.drill-tabs button[aria-current="true"] { background: var(--rp-primary); border-color: var(--rp-primary); color: #fff; }
.lang select { border: 1px solid var(--rp-line); border-radius: 10px; padding: 6px 10px; background: var(--rp-card); font-size: 14px; }

/* ---------------- layout */
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 400px; height: calc(100vh - var(--topbar)); height: calc(100dvh - var(--topbar)); }
body.embed .topbar { display: none; }
body.embed .layout { height: 100vh; height: 100dvh; }
/* embed=1 without panel=1: the host page renders the text, the iframe shows the stage only */
body.stage-only .panel { display: none; }
body.stage-only .layout { display: block; }
body.stage-only .stage { height: 100vh; height: 100dvh; }
.stage { position: relative; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; background: #dfe7ee; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; }
.stage canvas:active { cursor: grabbing; }
.panel { overflow-y: auto; padding: 22px 24px 32px; background: var(--rp-card); border-left: 1px solid var(--rp-line); }

/* ---------------- overlays */
.overlay { position: absolute; z-index: 2; display: flex; gap: 6px; }
.tl { top: 14px; left: 14px; }
.tr { top: 14px; right: 14px; flex-direction: column; align-items: flex-end; }
.seg { background: rgba(255, 255, 255, 0.86); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 12px; padding: 4px; box-shadow: 0 2px 10px rgba(20, 32, 46, 0.12); gap: 2px; }
.seg button { border: 0; background: transparent; border-radius: 9px; padding: 7px 11px; font-size: 13px; font-weight: 650; color: var(--rp-sub); cursor: pointer; min-height: 34px; }
.seg button[aria-pressed="true"] { background: var(--rp-ink); color: #fff; }
.pill {
  border: 0; border-radius: 999px; padding: 8px 14px 8px 12px; font-size: 13px; font-weight: 700; cursor: pointer; min-height: 36px;
  background: rgba(255, 255, 255, 0.9); box-shadow: 0 2px 10px rgba(20, 32, 46, 0.14); display: inline-flex; align-items: center; gap: 8px; color: var(--rp-ink);
}
.pill[hidden] { display: none; }
.body-seg button { display: inline-flex; align-items: center; gap: 5px; padding: 6px 10px 6px 8px; }
.body-seg svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.body-seg button[data-body="male"][aria-pressed="true"] { background: var(--rp-primary); }
.body-seg button[data-body="female"][aria-pressed="true"] { background: #14a38f; }
.pill::before { content: ""; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--rp-sub); }
.pill[aria-pressed="true"] { background: var(--rp-ink); color: #fff; }
.pill[aria-pressed="true"]::before { border-color: var(--rp-hi-p); background: var(--rp-hi-p); }
.hint { position: absolute; left: 50%; bottom: 76px; transform: translateX(-50%); font-size: 12px; color: rgba(20, 32, 46, 0.6); background: rgba(255, 255, 255, 0.7); padding: 4px 10px; border-radius: 99px; pointer-events: none; transition: opacity 0.6s; white-space: nowrap; }
.hint.gone { opacity: 0; }

.transport {
  position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 2; display: flex; align-items: center; gap: 12px;
  background: rgba(255, 255, 255, 0.9); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); border-radius: 14px; padding: 7px 10px; box-shadow: 0 2px 14px rgba(20, 32, 46, 0.14);
}
.transport .icon { width: 40px; height: 40px; border: 0; border-radius: 50%; background: var(--rp-primary); display: grid; place-items: center; cursor: pointer; flex: none; }
.transport .icon svg { width: 20px; height: 20px; fill: #fff; }
.transport input[type="range"] { flex: 1; min-width: 60px; accent-color: var(--rp-primary); height: 30px; }
.transport .time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--rp-sub); width: 56px; text-align: right; }
.transport .seg { box-shadow: none; background: #eef2f6; }

.labels { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.mlabel { position: absolute; left: 0; top: 0; will-change: transform; }
.mlabel .dot { position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--rp-hi-p); box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85); }
.mlabel.sec .dot { background: var(--rp-hi-s); }
.mlabel .txt {
  position: absolute; top: -12px; white-space: nowrap; font-size: 12px; font-weight: 700; line-height: 24px; padding: 0 9px; border-radius: 99px;
  background: rgba(20, 32, 46, 0.88); color: #fff;
}
.mlabel .txt::before { content: ""; position: absolute; top: 11.5px; width: 22px; height: 1.5px; background: rgba(20, 32, 46, 0.7); }
.mlabel.right .txt { left: 26px; }
.mlabel.right .txt::before { left: -23px; }
.mlabel.left .txt { right: 26px; }
.mlabel.left .txt::before { right: -23px; }

.compare-tags { position: absolute; inset: 0; pointer-events: none; z-index: 1; }
.compare-tags::after { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: rgba(255, 255, 255, 0.9); }
.compare-tags .tag { position: absolute; top: 62px; font-weight: 800; font-size: 14px; padding: 6px 12px; border-radius: 10px; color: #fff; max-width: 44%; }
.compare-tags .ok { left: 14px; background: var(--rp-ok); }
.compare-tags .bad { left: calc(50% + 14px); background: var(--rp-bad); }
.compare-tags[hidden] { display: none; }

.loading { position: absolute; inset: 0; display: grid; place-items: center; background: #dfe7ee; z-index: 4; font-weight: 600; color: var(--rp-sub); text-align: center; padding: 20px; }
.loading.done { display: none; }

/* ---------------- panel */
.meta { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; padding: 4px 10px; border-radius: 99px; background: #e8f0fe; color: var(--rp-primary-ink); }
.chip.dose { background: #fff1e9; color: #a33a0b; text-transform: none; letter-spacing: 0; }
.panel h1 { font-size: 26px; line-height: 1.15; margin: 12px 0 8px; letter-spacing: -0.02em; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--rp-sub); margin: 24px 0 10px; }
.summary { margin: 0; color: var(--rp-sub); line-height: 1.5; font-size: 15px; }
.disclaimer { margin: 14px 0 0; padding: 10px 12px; border-radius: 10px; background: #fff8e6; color: #7a5300; font-size: 13px; line-height: 1.45; border: 1px solid #f6e3b0; }
.cues { margin: 0; padding: 0; list-style: none; counter-reset: c; }
.cues li { counter-increment: c; position: relative; padding: 0 0 12px 36px; line-height: 1.45; font-size: 15px; }
.cues li::before { content: counter(c); position: absolute; left: 0; top: -1px; width: 24px; height: 24px; border-radius: 50%; background: var(--rp-primary); color: #fff; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.mistakes { display: grid; gap: 10px; }
.mistake { border: 1px solid var(--rp-line); border-radius: 12px; padding: 12px 14px; display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; }
.mistake.on { border-color: var(--rp-bad); box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.12); }
.mistake b { font-size: 15px; }
.mistake p { grid-column: 1 / -1; margin: 0; font-size: 14px; line-height: 1.45; color: var(--rp-sub); }
.mistake p span { font-weight: 700; color: var(--rp-ok); }
.mistake button { border: 0; border-radius: 9px; padding: 7px 12px; font-weight: 700; font-size: 13px; background: #fdecec; color: var(--rp-bad); cursor: pointer; min-height: 34px; }
.mistake.on button { background: var(--rp-bad); color: #fff; }
.muscles { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.muscles li { display: flex; align-items: center; gap: 10px; font-size: 15px; }
.muscles .sw { width: 14px; height: 14px; border-radius: 4px; background: var(--rp-hi-p); flex: none; }
.muscles .sec .sw { background: var(--rp-hi-s); }
.muscles small { color: var(--rp-sub); }
.proto { font-size: 12px; color: var(--rp-sub); margin: 18px 0 0; font-style: italic; }
.sources { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.5; }
.sources a { color: var(--rp-primary-ink); word-break: break-word; }

/* ---------------- face close-up for review screenshots (focus=face) */
body.portrait .topbar, body.portrait .panel, body.portrait .overlay, body.portrait .transport, body.portrait .hint { display: none; }
body.portrait .layout { display: block; height: 100vh; }
body.portrait .stage { height: 100vh; }

/* ---------------- phone / narrow */
@media (max-width: 860px) {
  :root { --topbar: 52px; }
  .topbar { gap: 10px; padding: 0 10px; }
  .brand { font-size: 0; gap: 0; }
  .layout { display: block; height: auto; }
  .stage { height: 64vh; height: 64svh; min-height: 380px; }
  body.embed .layout { height: auto; }
  body.embed .stage { height: 70vh; height: 70svh; }
  body.stage-only .layout { height: 100vh; height: 100dvh; }
  body.stage-only .stage { height: 100vh; height: 100dvh; min-height: 0; }
  .panel { border-left: 0; border-top: 1px solid var(--rp-line); padding: 18px 16px 28px; overflow: visible; }
  .tl { top: 10px; left: 10px; }
  .tr { top: 10px; right: 10px; }
  .seg button { padding: 6px 8px; font-size: 12px; }
  .pill { font-size: 12px; padding: 7px 11px 7px 9px; }
  .transport { left: 8px; right: 8px; bottom: 8px; gap: 8px; padding: 6px 8px; }
  .transport .time { display: none; }
  .transport .icon { width: 36px; height: 36px; }
  .hint { bottom: 64px; font-size: 11px; }
  .compare-tags .tag { top: 54px; font-size: 12px; padding: 5px 9px; }
  .compare-tags .ok { left: 8px; }
  .compare-tags .bad { left: calc(50% + 8px); }
  .mlabel .txt { font-size: 11px; line-height: 21px; top: -10.5px; padding: 0 7px; }
  .mlabel .txt::before { top: 10px; width: 14px; }
  .mlabel.right .txt { left: 18px; }
  .mlabel.right .txt::before { left: -15px; }
  .mlabel.left .txt { right: 18px; }
  .mlabel.left .txt::before { right: -15px; }
  .panel h1 { font-size: 22px; }
}
