:root,
:root[data-bt-theme="light"] {
  --b12-bg: var(--b11-bg, #eef4fa);
  --b12-surface: var(--b11-surface, #fff);
  --b12-surface-raised: var(--b11-surface-2, #f4f8fc);
  --b12-control: var(--b11-control, #fff);
  --b12-text: var(--b11-text, #10253b);
  --b12-muted: var(--b11-muted, #536a80);
  --b12-line: var(--b11-line, #bccddd);
  --b12-accent: var(--b11-accent, #197de8);
  --b12-cyan: var(--b11-cyan, #43d2e4);
  --b12-success: #18864b;
  --b12-danger: #c23b4a;
  color-scheme: light;
}

:root[data-bt-theme="dark"] {
  --b12-bg: var(--b11-bg, #061424);
  --b12-surface: var(--b11-surface, #0b1d31);
  --b12-surface-raised: var(--b11-surface-2, #10253b);
  --b12-control: var(--b11-control, #10243a);
  --b12-text: var(--b11-text, #f1f6fb);
  --b12-muted: var(--b11-muted, #aebfd0);
  --b12-line: var(--b11-line, #31506c);
  --b12-accent: var(--b11-accent, #3c9cff);
  --b12-cyan: var(--b11-cyan, #4bd8e7);
  --b12-success: #4ddd86;
  --b12-danger: #ff7080;
  color-scheme: dark;
}

/* Block 1.2: every late-rendered legacy card consumes the same semantic surface tokens. */
:root.release-3-premium[data-bt-theme] :is(
  .global-rating,
  .student-overview-card,
  .assigned-exercise-card,
  .recommendation-card,
  .youth-card,
  .youth-metrics > div,
  .ghost-ball-in-hand,
  .ball-in-hand,
  .training-result-input,
  .result-selected-summary,
  .exercise-representation,
  .representation-option,
  .kg-editor details,
  details.structured-content,
  .skill-check
) {
  color: var(--b12-text);
  background: var(--b12-surface);
  border-color: var(--b12-line);
}

:root.release-3-premium[data-bt-theme] :is(
  .student-overview-card,
  .assigned-exercise-card,
  .recommendation-card,
  .youth-card,
  .exercise-representation,
  .representation-option
) :is(h2, h3, h4, strong, b, label) { color: var(--b12-text); }

:root.release-3-premium[data-bt-theme] :is(
  .student-overview-card,
  .assigned-exercise-card,
  .recommendation-card,
  .youth-card,
  .exercise-representation,
  .representation-option
) :is(p, small, .small, .muted) { color: var(--b12-muted); }

:root.release-3-premium[data-bt-theme] .skill-check {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  border: 1px solid var(--b12-line);
  border-radius: 9px;
  cursor: pointer;
}

:root.release-3-premium[data-bt-theme] .skill-check:has(input:checked) {
  background: color-mix(in srgb, var(--b12-accent) 16%, var(--b12-surface));
  border-color: var(--b12-accent);
}

:root.release-3-premium[data-bt-theme] .skill-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--b12-accent);
}

:root.release-3-premium[data-bt-theme] :is(.ghost-ball-in-hand, .ball-in-hand) {
  padding: 10px 12px;
  border: 1px solid var(--b12-line);
  border-radius: 9px;
}

/* Persistent product identity in public and authenticated shells. */
.public-brand,
.top .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
}

.public-brand img,
.top .brand .brand-logo {
  display: block;
  width: 34px;
  height: 34px;
  object-fit: cover;
  border: 1px solid color-mix(in srgb, var(--b12-cyan) 54%, transparent);
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0, 88, 190, .22);
}

.top .brand .version { order: 2; }

/* Public landing: vector icons and product previews replace decorative photography. */
.feature-icon svg {
  width: 29px;
  height: 29px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.public-product-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.public-product-card {
  display: grid;
  grid-template-columns: minmax(240px, .9fr) minmax(260px, 1fr);
  gap: 22px;
  align-items: center;
  padding: 22px;
  color: var(--b12-text);
  background: var(--b12-surface);
  border: 1px solid var(--b12-line);
  border-radius: 18px;
  box-shadow: 0 16px 38px rgba(3, 24, 46, .1);
}

.public-product-card h3 { margin: 6px 0 8px; }
.public-product-card p { color: var(--b12-muted); }
.public-product-preview {
  min-height: 210px;
  padding: 20px;
  color: #eef8ff;
  background: radial-gradient(circle at 75% 20%, rgba(50, 160, 255, .18), transparent 35%), linear-gradient(145deg, #07182b, #0d2845);
  border: 1px solid #28547b;
  border-radius: 15px;
  overflow: hidden;
}
.preview-kicker { display: block; margin-bottom: 14px; color: #55c9ff; font-size: .7rem; font-weight: 850; letter-spacing: .08em; }
.public-product-preview strong { display: block; color: #fff; font-size: 1.25rem; }
.preview-progress { height: 8px; margin: 34px 0 9px; overflow: hidden; background: #173a5c; border-radius: 99px; }
.preview-progress i { display: block; width: 70%; height: 100%; background: linear-gradient(90deg, #2488ff, #53dce8); border-radius: inherit; }
.preview-row { display: flex; justify-content: space-between; color: #b9cbe0; font-size: .78rem; }
.public-progress-preview strong { font-size: 2.3rem; }
.public-progress-preview svg { width: 100%; height: 120px; margin-top: 8px; overflow: visible; }
.preview-grid-line { fill: none; stroke: #294966; stroke-width: 1; stroke-dasharray: 4 5; }
.preview-chart-line { fill: none; stroke: #3c9cff; stroke-width: 4; stroke-linecap: round; stroke-linejoin: round; }
.public-progress-preview circle { fill: #07182b; stroke: #63dded; stroke-width: 3; }

/* Discrete result input: no numeric input, operating-system keyboard or stepper. */
.training-result-input { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--b12-line); border-radius: 12px; }
.result-selector-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.result-selector-heading span { color: var(--b12-muted); font-size: .82rem; }
.result-choice-scroll { max-height: min(260px, 35vh); overflow: auto; overscroll-behavior: contain; padding: 2px; }
.result-choice-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(48px, 1fr)); gap: 7px; }
.result-choice {
  min-height: 46px;
  color: var(--b12-text);
  background: var(--b12-control);
  border: 1px solid var(--b12-line);
  border-radius: 9px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}
.result-choice:hover { border-color: var(--b12-accent); }
.result-choice.selected { color: #fff; background: linear-gradient(115deg, var(--b12-accent), var(--b12-cyan)); border-color: transparent; }
.result-selected-summary { padding: 9px 11px; border: 1px solid var(--b12-line); border-radius: 8px; font-weight: 750; }
.result-target-feedback { min-height: 1.2em; color: var(--b12-success); }
.bt-workout-controls { align-items: start; }
.bt-workout-controls > * { min-width: 0; }

/* Renderer surfaces remain stable while canonical diagram_data is loading. */
.exercise-visual-loading,
.library-visual-skeleton {
  aspect-ratio: 2 / 1;
  background: linear-gradient(90deg, var(--b12-surface-raised), color-mix(in srgb, var(--b12-surface-raised) 65%, var(--b12-line)), var(--b12-surface-raised));
  background-size: 220% 100%;
  border: 1px solid var(--b12-line);
  border-radius: 12px;
  animation: b12-skeleton 1.3s ease-in-out infinite;
}
@keyframes b12-skeleton { to { background-position: -220% 0; } }

.diagram-placeholder {
  min-height: 150px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: .45rem;
  padding: 1.25rem;
  border: 1px dashed color-mix(in srgb, var(--b12-line) 82%, transparent);
  border-radius: var(--b12-radius-md);
  color: var(--b12-muted);
  background: color-mix(in srgb, var(--b12-panel) 88%, var(--b12-accent) 12%);
  text-align: center;
}
.diagram-placeholder svg {
  width: 30px;
  height: 30px;
  fill: none;
  stroke: var(--b12-accent);
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.diagram-placeholder span { color: var(--b12-text); font-weight: 800; }
.diagram-placeholder small { max-width: 28ch; }
.diagram-placeholder-blocked svg { stroke: var(--b12-muted); }

/* Builder viewport: the 2:1 table and save actions remain reachable at supported zooms. */
.premium-builder-shell { max-height: calc(100vh - 70px); overflow: hidden; }
.premium-builder-header,
.premium-builder-toolbar { position: sticky; top: 0; z-index: 12; background: var(--b12-surface); }
.premium-builder-footer,
.builder-position-bar { position: sticky; bottom: 0; z-index: 12; background: var(--b12-surface); }
.premium-builder-layout { min-height: 0; max-height: calc(100vh - 210px); overflow: auto; }
.builder-stage,
.diagram-view-canvas,
.canonical-diagram-visual { min-width: 0; }
.builder-stage svg,
.diagram-view-canvas svg,
.canonical-diagram-visual svg { display: block; width: 100%; height: auto; aspect-ratio: 2 / 1; }

@media (max-width: 1050px) {
  .public-product-grid { grid-template-columns: 1fr; }
  .public-product-card { grid-template-columns: minmax(220px, .8fr) minmax(0, 1fr); }
  .premium-builder-layout { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 720px) {
  .public-brand,
  .top .brand { gap: 7px; font-size: .96rem; }
  .public-brand img,
  .top .brand .brand-logo { width: 30px; height: 30px; border-radius: 8px; }
  .top .brand .version { display: none; }
  .public-product-card { grid-template-columns: 1fr; padding: 16px; }
  .public-product-preview { min-height: 170px; }
  .result-selector-heading { align-items: start; flex-direction: column; gap: 2px; }
  .result-choice-scroll { max-height: 230px; }
  .result-choice-grid { grid-template-columns: repeat(5, minmax(44px, 1fr)); }
  .premium-builder-shell { max-height: calc(100dvh - 24px); }
  .premium-builder-layout { max-height: calc(100dvh - 190px); }
}

@media (max-width: 390px) {
  .result-choice-grid { grid-template-columns: repeat(4, minmax(42px, 1fr)); }
}

@media (prefers-reduced-motion: reduce) {
  .exercise-visual-loading,
  .library-visual-skeleton { animation: none; }
}
