:root {
  --page-bg: #eef2f5;
  --card-bg: #ffffff;
  --text-main: #1f2933;
  --text-muted: #5f6b7a;
  --line: #d8e0e7;
  --accent: #246b8f;
  --accent-dark: #174e6c;
  --accent-soft: #e6f1f6;
  --success-soft: #e6f3ed;
  --success-text: #2f6f52;
  --warning-soft: #fff7e8;
  --warning-text: #8a5a12;
  --low-soft: #eef1f8;
  --low-text: #4d5e86;
  --open-soft: #f2f5f7;
  --open-text: #6b7480;
  --shadow: 0 18px 44px rgba(31, 41, 51, 0.12);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--page-bg);
  color: var(--text-main);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  display: flex;
  position: sticky;
  top: 0;
  z-index: 20;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 8px clamp(14px, 3vw, 28px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(14px);
}

.topbar-main {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 280px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.05rem, 1.6vw, 1.32rem);
  line-height: 1.15;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.05rem;
  line-height: 1.25;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid #bed9cc;
  border-radius: 999px;
  background: var(--success-soft);
  color: var(--success-text);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.case-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid rgba(36, 107, 143, 0.18);
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  white-space: nowrap;
}

.global-logo-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: min(210px, 22vw);
  min-height: 64px;
  padding: 5px 10px;
  border: 1px solid rgba(178, 190, 201, 0.74);
  border-radius: 8px;
  background: #f6f8fa;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 900;
}

.global-logo-slot img {
  max-width: 100%;
  max-height: 64px;
  object-fit: contain;
}

.global-logo-slot img[hidden],
.global-logo-slot span[hidden] {
  display: none;
}

.header-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.app-layout {
  height: calc(100vh - 56px);
  padding: 12px clamp(12px, 2vw, 22px) 16px;
}

.viewer-card,
.task-panel,
.help-modal {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--card-bg);
  box-shadow: var(--shadow);
}

.viewer-card {
  position: relative;
  width: 100%;
  height: 100%;
  min-width: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.95), transparent 34%),
    linear-gradient(135deg, #f9fbfc 0%, #eef4f7 100%);
}

.workspace-task-card {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 5;
  width: min(370px, calc(100% - 32px));
  padding: 14px 15px;
}

.viewer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.viewer-toolbar p,
.task-block p,
.help-modal p {
  margin-bottom: 0;
  color: var(--text-muted);
}

.image-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  padding: 88px 18px 86px;
  background: transparent;
}

.image-stack {
  position: relative;
  display: inline-flex;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  border: 1px solid #cbd6df;
  border-radius: var(--radius);
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(31, 41, 51, 0.14);
  cursor: crosshair;
  z-index: 1;
}

.image-stack img {
  display: block;
  width: auto;
  max-width: 100%;
  max-height: 100%;
  height: auto;
  object-fit: contain;
  user-select: none;
}

.image-stack.is-panning {
  cursor: grabbing;
}

.image-stack canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.image-stage > canvas {
  position: absolute;
  z-index: 2;
  display: block;
  cursor: crosshair;
  touch-action: none;
}

.workspace-action-bar {
  position: absolute;
  left: 50%;
  bottom: 16px;
  z-index: 5;
  display: grid;
  width: min(920px, calc(100% - 32px));
  gap: 9px;
  padding: 10px 12px;
  transform: translateX(-50%);
}

.hud-card,
.action-dock,
.detail-drawer {
  border: 1px solid rgba(216, 224, 231, 0.88);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 16px 42px rgba(31, 41, 51, 0.14);
  backdrop-filter: blur(14px);
}

.utility-card {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: min(360px, calc(100% - 32px));
  padding: 8px;
}

.zoom-controls {
  position: absolute;
  left: 16px;
  bottom: 12px;
  z-index: 6;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  max-width: min(620px, calc(100% - 32px));
  padding: 8px;
}

.debug-jump-controls {
  position: absolute;
  left: 16px;
  bottom: 62px;
  z-index: 7;
  display: flex;
  max-width: calc(100% - 32px);
  align-items: center;
  gap: 5px;
  padding: 7px;
  overflow-x: auto;
}

.debug-jump-label {
  padding: 0 3px;
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.debug-jump-controls button {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 4px 8px;
  font-size: 0.7rem;
}

.debug-jump-message {
  flex: 0 0 auto;
  color: var(--warning-text);
  font-size: 0.7rem;
  font-weight: 700;
}

.evaluation-workspace {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: 16px;
  padding: 72px 18px 24px;
  background: linear-gradient(135deg, rgba(249, 251, 252, 0.96), rgba(238, 244, 247, 0.94));
}

.evaluation-workspace[hidden] {
  display: none;
}

.canvas-workspace.is-evaluation-phase .image-stage {
  opacity: 0.1;
  pointer-events: none;
}

.evaluation-sheet-panel {
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 16px;
  border: 1px solid rgba(216, 224, 231, 0.9);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 18px 44px rgba(31, 41, 51, 0.12);
}

.evaluation-sheet-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
}

.evaluation-sheet-header h2 {
  margin: 0;
}

.evaluation-table-wrap {
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.evaluation-table {
  width: 100%;
  min-width: 820px;
  border-collapse: collapse;
  font-size: 0.84rem;
}

.evaluation-table th,
.evaluation-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.evaluation-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f5f8fa;
  color: var(--accent-dark);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: uppercase;
}

.evaluation-table tr.is-current td {
  background: rgba(230, 241, 246, 0.72);
}

.evaluation-table tr.is-active td {
  background: rgba(230, 241, 246, 0.86);
  box-shadow: inset 3px 0 0 var(--accent);
}

.evaluation-table tr.is-normal td {
  background: rgba(230, 243, 237, 0.5);
}

.evaluation-table tr.is-active.is-normal td {
  background: rgba(230, 243, 237, 0.72);
}

.evaluation-table tr.is-low td,
.evaluation-table tr.is-high td {
  background: rgba(255, 247, 232, 0.58);
}

.evaluation-table tr.is-unavailable td {
  color: var(--text-muted);
  background: rgba(242, 245, 247, 0.72);
}

.evaluation-group-row th {
  position: sticky;
  top: 31px;
  z-index: 1;
  padding: 8px 10px;
  background: #eef4f7;
  color: var(--accent-dark);
  font-size: 0.74rem;
  font-weight: 900;
  text-transform: none;
}

.evaluation-table td strong,
.evaluation-table td span {
  display: block;
}

.evaluation-table td span {
  margin-top: 2px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.evaluation-help-panel {
  align-self: stretch;
  display: grid;
  min-width: 0;
  min-height: 0;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  padding: 16px;
  overflow: auto;
}

.evaluation-help-header h2 {
  margin: 2px 0 0;
  font-size: 1.05rem;
}

.evaluation-help-meta {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid rgba(216, 224, 231, 0.82);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text-main);
  font-size: 0.84rem;
}

.evaluation-help-meta span {
  display: block;
}

.evaluation-help-content {
  display: grid;
  align-content: start;
  gap: 10px;
  min-height: 0;
}

.evaluation-help-content section {
  padding: 10px;
  border: 1px solid rgba(216, 224, 231, 0.82);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.74);
}

.evaluation-help-content h3 {
  margin: 0 0 5px;
  color: var(--accent-dark);
  font-size: 0.78rem;
}

.evaluation-help-content p {
  margin: 0;
  color: var(--text-main);
  font-size: 0.86rem;
}

.zoom-button {
  display: inline-grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #ffffff;
  color: var(--accent-dark);
  font-size: 1.05rem;
  font-weight: 800;
}

.zoom-button:hover,
.zoom-button:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.zoom-level {
  min-width: 48px;
  color: var(--text-main);
  font-size: 0.82rem;
  font-weight: 800;
  text-align: center;
}

.pan-hint {
  max-width: min(360px, 52vw);
  padding: 0 4px;
  color: rgba(78, 90, 102, 0.78);
  font-size: 0.76rem;
  font-weight: 700;
  line-height: 1.2;
}

.angle-composer {
  position: absolute;
  left: 50%;
  bottom: 18px;
  z-index: 8;
  display: grid;
  width: min(640px, calc(100% - 360px));
  min-width: 0;
  gap: 10px;
  padding: 12px;
  transform: translateX(-50%);
}

.angle-composer[hidden] {
  display: none;
}

.angle-composer-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  min-width: 0;
}

.angle-composer-head strong {
  overflow: hidden;
  color: var(--text-main);
  font-size: 0.98rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.angle-composer-slots {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: stretch;
  gap: 8px;
  min-width: 0;
}

.angle-composer-slot-wrap {
  position: relative;
  min-width: 0;
}

.angle-composer-slot {
  display: grid;
  width: 100%;
  min-height: 46px;
  min-width: 0;
  align-content: center;
  gap: 2px;
  border: 1px dashed rgba(178, 190, 201, 0.86);
  border-radius: 8px;
  padding: 7px 34px 7px 10px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--open-text);
  text-align: left;
}

.angle-composer-slot:hover,
.angle-composer-slot:focus-visible,
.angle-composer-slot.is-active {
  border-color: rgba(36, 107, 143, 0.46);
  background: rgba(230, 241, 246, 0.72);
  color: var(--accent-dark);
}

.angle-composer-slot.is-filled {
  border-style: solid;
  border-color: rgba(183, 121, 31, 0.38);
  background: rgba(255, 247, 232, 0.86);
  color: #8a5a12;
}

.angle-composer-slot.is-warning {
  border-color: rgba(155, 58, 58, 0.42);
  background: rgba(255, 241, 239, 0.84);
  color: #8b4b45;
}

.angle-composer-slot .angle-slot-label {
  color: inherit;
  opacity: 0.72;
}

.angle-composer-slot strong,
.angle-composer-slot span:last-child {
  overflow: hidden;
  font-size: 0.92rem;
  font-weight: 900;
  overflow-wrap: anywhere;
  white-space: normal;
}

.angle-slot-remove {
  position: absolute;
  top: 50%;
  right: 8px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid rgba(183, 121, 31, 0.28);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  color: #8a5a12;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
  transform: translateY(-50%);
}

.angle-slot-remove:hover,
.angle-slot-remove:focus-visible {
  border-color: rgba(155, 58, 58, 0.35);
  color: #8b4b45;
}

.angle-slot-plus {
  display: grid;
  width: 28px;
  place-items: center;
  color: rgba(95, 107, 122, 0.72);
  font-size: 1.05rem;
  font-weight: 900;
}

.angle-composer-feedback {
  padding: 8px 10px;
  border: 1px solid #bed9cc;
  border-radius: 7px;
  background: var(--success-soft);
  color: var(--success-text);
  font-size: 0.82rem;
  font-weight: 800;
}

.angle-composer-feedback.is-warning {
  border-color: #edd59f;
  background: var(--warning-soft);
  color: var(--warning-text);
}

.angle-composer-result {
  display: grid;
  gap: 4px;
  min-width: 0;
  padding: 9px 10px;
  border: 1px solid rgba(190, 217, 204, 0.9);
  border-radius: 8px;
  background: rgba(230, 243, 237, 0.78);
  color: var(--text-main);
  font-size: 0.86rem;
}

.angle-composer-result[hidden] {
  display: none;
}

.angle-composer-result strong {
  color: var(--success-text);
}

.angle-composer-result small {
  color: var(--text-muted);
  line-height: 1.35;
}

.angle-composer-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.angle-line-picker {
  position: absolute;
  left: 50%;
  bottom: 178px;
  z-index: 9;
  display: grid;
  width: min(700px, calc(100% - 360px));
  min-width: 0;
  gap: 10px;
  padding: 12px;
  transform: translateX(-50%);
}

.angle-line-picker[hidden] {
  display: none;
}

.angle-picker-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.angle-picker-header strong {
  overflow: hidden;
  color: var(--text-main);
  font-size: 0.92rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.angle-picker-groups {
  display: grid;
  gap: 9px;
  min-width: 0;
  overflow-x: hidden;
}

.detail-drawer {
  position: absolute;
  top: 74px;
  right: 16px;
  bottom: 88px;
  z-index: 7;
  display: flex;
  width: min(276px, calc(100% - 32px));
  max-width: calc(100% - 32px);
  min-height: 0;
  min-width: 0;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 28px));
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.detail-drawer.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: 0 0 auto;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.drawer-header strong {
  display: block;
  color: var(--text-main);
  font-size: 1rem;
}

.compact-button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 0.8rem;
}

.compact-button.has-panel-message {
  border-color: #edd59f;
  background: var(--warning-soft);
  color: var(--warning-text);
}

.sticky-task-card {
  position: sticky;
  top: 0;
  z-index: 3;
  flex: 0 0 auto;
  padding: 18px 20px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--card-bg);
}

.phase-stepper {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  justify-content: flex-end;
  margin-bottom: 0;
}

.phase-step {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 9px;
  background: #f7fafc;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 800;
  cursor: default;
  user-select: none;
}

.phase-step.is-current {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.phase-step.is-complete {
  border-color: #bed9cc;
  background: var(--success-soft);
  color: var(--success-text);
}

.phase-step.is-locked {
  opacity: 0.56;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.workspace-task-card .panel-header {
  padding-bottom: 0;
  border-bottom: 0;
}

.task-help-button {
  flex: 0 0 auto;
  border-color: rgba(36, 107, 143, 0.22);
  background: rgba(255, 255, 255, 0.86);
  color: var(--accent-dark);
  font-size: 1rem;
}

.task-help-button:hover,
.task-help-button:focus-visible {
  border-color: rgba(36, 107, 143, 0.58);
  background: var(--accent-soft);
}

.workspace-task-card h2 {
  margin-bottom: 0;
  font-size: 1rem;
}

.workspace-task-card .phase-label,
.workspace-task-card .block-label {
  margin-bottom: 4px;
  font-size: 0.72rem;
}

.workspace-task-card .task-block,
.workspace-task-card .progress-block {
  margin-top: 10px;
}

.workspace-task-card .task-block p,
.workspace-task-card .progress-detail {
  font-size: 0.84rem;
}

.workspace-task-card .progress-track {
  height: 6px;
}

.phase-label,
.block-label {
  display: block;
  margin-bottom: 6px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.task-block,
.feedback-card,
.progress-block,
.training-list-block,
.result-block,
.interpretation-block {
  margin-top: 18px;
}

.sticky-task-card .task-block,
.sticky-task-card .feedback-card,
.sticky-task-card .progress-block,
.sticky-task-card .calibration-card,
.sticky-task-card .angle-question-card,
.sticky-task-card .angle-line-card {
  margin-top: 14px;
}

.workspace-task-card .task-block,
.workspace-task-card .progress-block {
  margin-top: 12px;
}

.calibration-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.calibration-card[hidden] {
  display: none;
}

.workspace-action-bar .calibration-card {
  max-width: 360px;
  padding: 10px 12px;
  justify-self: center;
}

.calibration-field {
  display: grid;
  gap: 7px;
}

.calibration-field > span:first-child {
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 700;
}

.calibration-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.calibration-input-row input {
  width: 100%;
  min-height: 38px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text-main);
}

.calibration-input-row input:focus-visible {
  outline: 2px solid #8fc0d8;
  outline-offset: 2px;
}

.feedback-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.feedback-card.is-warning {
  border-color: #edd59f;
  background: var(--warning-soft);
}

.feedback-card.is-success {
  border-color: #bed9cc;
  background: var(--success-soft);
}

.feedback-card.is-info {
  border-color: #b8d4e2;
  background: var(--accent-soft);
}

.feedback-card.is-error {
  border-color: #e4b3a9;
  background: #fff1ef;
}

#feedbackMessage {
  margin-bottom: 0;
  color: var(--text-main);
  font-weight: 700;
}

.feedback-list {
  margin: 8px 0 0;
  padding-left: 18px;
  color: var(--text-main);
  font-size: 0.86rem;
}

.feedback-list:empty {
  display: none;
}

.feedback-list li + li {
  margin-top: 3px;
}

.angle-question-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  min-width: 0;
  overflow: hidden;
}

.angle-line-card {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
  min-width: 0;
  overflow: hidden;
}

.angle-question-card[hidden] {
  display: none;
}

.angle-line-card[hidden] {
  display: none;
}

.angle-measurement-summary {
  display: grid;
  gap: 5px;
  color: var(--text-main);
  font-size: 0.9rem;
}

.angle-measurement-summary strong {
  color: var(--accent-dark);
}

.angle-question {
  margin: 0;
  color: var(--text-main);
  font-weight: 800;
}

.angle-options {
  display: grid;
  gap: 8px;
}

.angle-line-options {
  display: grid;
  gap: 8px;
  min-width: 0;
  overflow-x: hidden;
}

.angle-option,
.angle-line-option {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--text-main);
  font-weight: 700;
  text-align: left;
}

.angle-option:hover,
.angle-option:focus-visible,
.angle-option.is-selected,
.angle-line-option:hover,
.angle-line-option:focus-visible,
.angle-line-option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.angle-option:disabled,
.angle-line-option:disabled {
  cursor: default;
  opacity: 0.88;
}

.angle-feedback {
  padding: 10px;
  border: 1px solid #bed9cc;
  border-radius: 7px;
  background: var(--success-soft);
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 700;
}

.angle-feedback.is-warning {
  border-color: #edd59f;
  background: var(--warning-soft);
  color: var(--warning-text);
}

.angle-builder {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.angle-slots {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.angle-slot-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.angle-slot-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.angle-slot-placeholder,
.angle-slot-chip {
  min-width: 0;
  min-height: 28px;
  border: 1px dashed rgba(178, 190, 201, 0.8);
  border-radius: 6px;
  padding: 5px 8px;
  background: #ffffff;
  color: var(--open-text);
  font-size: 0.78rem;
  font-weight: 800;
}

.angle-slot-chip {
  border-style: solid;
  border-color: rgba(183, 121, 31, 0.35);
  background: rgba(255, 247, 232, 0.78);
  color: #8a5a12;
  text-align: left;
}

.angle-slot-chip:hover,
.angle-slot-chip:focus-visible {
  border-color: rgba(183, 121, 31, 0.58);
  background: rgba(255, 243, 215, 0.95);
}

.angle-builder-feedback {
  padding: 8px;
  border: 1px solid #bed9cc;
  border-radius: 7px;
  background: var(--success-soft);
  color: var(--success-text);
  font-size: 0.78rem;
  font-weight: 800;
}

.angle-builder-feedback.is-warning {
  border-color: #edd59f;
  background: var(--warning-soft);
  color: var(--warning-text);
}

.angle-line-library {
  display: grid;
  gap: 8px;
  min-width: 0;
  overflow-x: hidden;
}

.angle-library-group {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.angle-library-title {
  margin: 0;
  overflow: hidden;
  color: #40505c;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.angle-library-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.angle-library-chip {
  flex: 0 1 auto;
  max-width: 100%;
  min-width: 48px;
  min-height: 34px;
  border: 1px solid rgba(216, 224, 231, 0.95);
  border-radius: 6px;
  padding: 6px 10px;
  background: #ffffff;
  color: #40505c;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1.1;
  overflow: hidden;
  overflow-wrap: anywhere;
  text-align: center;
  white-space: normal;
}

.angle-library-chip:hover,
.angle-library-chip:focus-visible {
  border-color: rgba(36, 107, 143, 0.45);
  background: var(--accent-soft);
  color: var(--accent-dark);
}

.angle-library-chip.is-selected {
  border-color: rgba(183, 121, 31, 0.45);
  background: rgba(255, 247, 232, 0.9);
  color: #8a5a12;
}

.angle-library-chip.is-warning {
  border-color: rgba(155, 58, 58, 0.38);
  background: rgba(255, 241, 239, 0.82);
  color: #8b4b45;
}

.angle-library-empty {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.angle-direction-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.angle-summary-list {
  gap: 6px;
}

.angle-summary-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px 8px;
  min-width: 0;
  padding: 7px 8px;
  border: 1px solid rgba(216, 224, 231, 0.82);
  border-radius: 7px;
  background: #ffffff;
  font-size: 0.78rem;
}

.angle-summary-item span:first-child {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.angle-summary-item strong {
  color: var(--accent-dark);
}

.angle-summary-item span:last-child {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: 0.72rem;
}

.feedback-card.is-warning #feedbackMessage {
  color: var(--warning-text);
}

.feedback-card.is-success #feedbackMessage {
  color: var(--success-text);
}

.feedback-card.is-info #feedbackMessage {
  color: var(--accent-dark);
}

.feedback-card.is-error #feedbackMessage {
  color: #9b3a3a;
}

.progress-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.progress-row strong {
  color: var(--text-main);
  text-align: right;
}

.progress-detail {
  margin: -2px 0 9px;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.progress-detail:empty {
  display: none;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #dce4ea;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background: var(--accent);
}

.training-list {
  display: grid;
  gap: 8px;
  min-width: 0;
  overflow-x: hidden;
  margin: 0;
  padding: 0;
  list-style: none;
}

.training-list-block {
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 0;
  overflow: visible;
  padding: 18px 20px 20px;
}

.result-block,
.interpretation-block {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
  margin-top: 0;
  overflow: visible;
  padding: 18px 20px 20px;
}

.scrollable-panel-content {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 18px 20px 20px;
}

.scrollable-panel-content .feedback-card,
.scrollable-panel-content .angle-line-card,
.scrollable-panel-content .angle-question-card,
.scrollable-panel-content .training-list-block,
.scrollable-panel-content .result-block,
.scrollable-panel-content .interpretation-block {
  margin-top: 0;
}

.scrollable-panel-content .training-list-block,
.scrollable-panel-content .result-block,
.scrollable-panel-content .interpretation-block {
  padding: 0;
}

.scrollable-panel-content > * + * {
  margin-top: 14px;
}

.phase-navigator-list {
  gap: 6px;
  min-width: 0;
  overflow-x: hidden;
}

.phase-nav-group {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 7px;
  border: 1px solid rgba(216, 224, 231, 0.68);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.48);
}

.phase-nav-group.is-current {
  border-color: rgba(36, 107, 143, 0.28);
  background: rgba(230, 241, 246, 0.46);
}

.phase-nav-group.is-muted {
  opacity: 0.62;
}

.phase-nav-group.is-complete:not(.is-current) {
  background: rgba(230, 243, 237, 0.32);
}

.phase-nav-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.phase-nav-group-title {
  min-width: 0;
  overflow: hidden;
  color: #40505c;
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.phase-nav-group.is-current .phase-nav-group-title {
  color: var(--accent-dark);
}

.phase-nav-group-progress {
  color: rgba(95, 107, 122, 0.82);
  font-size: 0.64rem;
  font-weight: 700;
}

.phase-nav-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
  max-width: 100%;
  overflow-x: hidden;
}

.phase-nav-chip {
  display: inline-grid;
  place-items: center;
  flex: 0 1 auto;
  max-width: 100%;
  overflow: hidden;
  min-width: 28px;
  min-height: 24px;
  padding: 3px 6px;
  border: 1px solid rgba(178, 190, 201, 0.66);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
  color: rgba(78, 90, 102, 0.82);
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.15;
  overflow-wrap: anywhere;
  text-align: center;
  white-space: normal;
}

.phase-nav-chip.is-complete {
  border-color: rgba(183, 121, 31, 0.28);
  background: rgba(255, 247, 232, 0.72);
  color: #8a5a12;
}

.phase-nav-chip.is-current {
  border-color: rgba(36, 107, 143, 0.62);
  box-shadow: 0 0 0 2px rgba(36, 107, 143, 0.1);
}

.phase-nav-chip.is-constructed {
  border-style: dashed;
}

.phase-nav-chip.is-correct {
  border-color: rgba(47, 111, 82, 0.3);
  background: rgba(230, 243, 237, 0.66);
  color: #2f6f52;
}

.phase-nav-chip.is-incorrect {
  border-color: rgba(155, 58, 58, 0.4);
  background: rgba(255, 241, 239, 0.72);
  color: #8b4b45;
}

.phase-nav-chip.is-missing {
  opacity: 0.42;
}

.angle-navigator-list .phase-nav-chip {
  max-width: 92px;
}

.landmark-group-heading {
  display: grid;
  gap: 3px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f5f8fa;
}

.landmark-group-heading.is-current {
  border-color: #8fc0d8;
  background: var(--accent-soft);
}

.landmark-group-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--accent-dark);
  font-size: 0.86rem;
  font-weight: 800;
}

.landmark-group-description {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
}

.training-item {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
}

.training-item.is-current {
  border-color: #8fc0d8;
  background: var(--accent-soft);
}

.training-item.is-complete {
  border-color: #c4d7e3;
  background: #fbfcfd;
}

.training-item.is-missing {
  opacity: 0.66;
}

.training-item.is-correct {
  border-color: #bed9cc;
  background: var(--success-soft);
}

.training-item.is-incorrect {
  border-color: #e4b3a9;
  background: #fff1ef;
}

.item-short {
  display: inline-grid;
  place-items: center;
  min-width: 36px;
  height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--open-soft);
  color: var(--open-text);
  font-size: 0.84rem;
  font-weight: 800;
}

.is-current .item-short {
  background: var(--accent);
  color: #ffffff;
}

.is-complete .item-short {
  background: var(--accent-dark);
  color: #ffffff;
}

.is-correct .item-short {
  background: var(--success-text);
  color: #ffffff;
}

.is-incorrect .item-short {
  background: #9b3a3a;
  color: #ffffff;
}

.item-name {
  min-width: 0;
  font-weight: 700;
}

.item-status {
  color: var(--open-text);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

.is-current .item-status {
  color: var(--accent-dark);
}

.is-complete .item-status {
  color: var(--success-text);
}

.is-incorrect .item-status {
  color: #9b3a3a;
}

.is-missing .item-status {
  color: var(--open-text);
}

.result-list {
  display: grid;
  gap: 8px;
}

.result-item {
  display: grid;
  gap: 6px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
}

.result-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.result-name {
  font-weight: 800;
}

.result-value {
  color: var(--accent-dark);
  font-weight: 800;
}

.result-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.84rem;
}

.classification {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--open-soft);
  color: var(--open-text);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.classification.is-normal {
  background: var(--success-soft);
  color: var(--success-text);
}

.classification.is-low {
  background: var(--low-soft);
  color: var(--low-text);
}

.classification.is-high {
  background: var(--warning-soft);
  color: var(--warning-text);
}

.result-empty {
  margin: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  color: var(--text-muted);
}

.measurement-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 7px;
}

.measurement-table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
  background: #ffffff;
  font-size: 0.84rem;
}

.measurement-table th,
.measurement-table td {
  padding: 9px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.measurement-table th {
  background: #f5f8fa;
  color: var(--accent-dark);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.measurement-table tr:last-child td {
  border-bottom: 0;
}

.measurement-name,
.measurement-value {
  font-weight: 800;
}

.measurement-value {
  color: var(--accent-dark);
}

.measurement-meaning {
  color: var(--text-muted);
}

.form-field {
  display: grid;
  gap: 6px;
}

.form-field span {
  color: var(--text-main);
  font-size: 0.88rem;
  font-weight: 700;
}

.form-field input,
.form-field select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text-main);
}

.form-field input:focus-visible,
.form-field select:focus-visible {
  outline: 2px solid #8fc0d8;
  outline-offset: 2px;
}

.primary-button,
.secondary-button {
  min-height: 40px;
  border-radius: 6px;
  padding: 9px 14px;
  border: 1px solid transparent;
  font-weight: 700;
}

.primary-button {
  width: 100%;
  margin-top: 22px;
  background: var(--accent);
  color: #ffffff;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: var(--accent-dark);
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 0;
}

.panel-actions .primary-button,
.panel-actions .secondary-button {
  flex: 0 1 auto;
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.86rem;
  margin-top: 0;
  white-space: normal;
}

.panel-actions .is-primary-action {
  flex-basis: 210px;
}

.panel-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.secondary-button {
  background: var(--accent-soft);
  border-color: #bad7e5;
  color: var(--accent-dark);
  white-space: nowrap;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: var(--accent);
  background: #d7ebf4;
}

.secondary-button.is-primary-action {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.secondary-button.is-primary-action:hover,
.secondary-button.is-primary-action:focus-visible {
  border-color: var(--accent-dark);
  background: var(--accent-dark);
}

.quiet-button {
  border-color: #d7dee5;
  background: #f6f8fa;
  color: var(--text-muted);
}

.quiet-button:hover,
.quiet-button:focus-visible {
  border-color: #b8c4ce;
  background: #edf2f5;
  color: var(--text-main);
}

.secondary-link {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid #bad7e5;
  border-radius: 6px;
  padding: 9px 14px;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}

.secondary-link:hover,
.secondary-link:focus-visible {
  border-color: var(--accent);
  background: #d7ebf4;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #ffffff;
  color: var(--accent-dark);
  font-weight: 800;
}

.icon-button:hover,
.icon-button:focus-visible {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(31, 41, 51, 0.34);
  z-index: 10;
}

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

.help-modal {
  width: min(560px, 100%);
  padding: 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.modal-header h2 {
  margin-bottom: 0;
}

.help-list {
  margin: 12px 0 0;
  padding-left: 20px;
  color: var(--text-muted);
}

.help-list li + li {
  margin-top: 8px;
}

.calibration-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(430px, 520px);
  gap: 24px;
  height: auto;
  min-height: calc(100vh - 72px);
  padding: 18px clamp(18px, 4vw, 48px) 36px;
}

.calibration-layout .viewer-card {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: auto;
  max-height: calc(100vh - 126px);
  overflow: hidden;
  background: var(--card-bg);
}

.calibration-layout .image-stage {
  position: static;
  inset: auto;
  overflow: auto;
  padding: 16px 20px;
  background: #f8fafb;
}

.calibration-layout .image-stack {
  display: block;
  width: 100%;
  max-width: 980px;
  max-height: none;
}

.calibration-layout .image-stack img {
  width: 100%;
  max-width: 100%;
  max-height: none;
}

.calibration-layout .task-panel {
  position: static;
  width: auto;
  opacity: 1;
  pointer-events: auto;
  transform: none;
}

.calibration-panel {
  max-height: calc(100vh - 126px);
  overflow: auto;
}

.tolerance-field {
  margin-top: 18px;
}

.tolerance-field input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text-main);
}

.calibration-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.calibration-actions .primary-button {
  grid-column: 1 / -1;
  margin-top: 0;
}

.calibration-actions .secondary-button {
  white-space: normal;
}

.calibration-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.calibration-point-list .training-item {
  grid-template-columns: 76px minmax(0, 1fr) auto;
}

.code-output-block {
  margin-top: 18px;
}

#codeOutput {
  width: 100%;
  min-height: 280px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  color: var(--text-main);
  font-family: "Courier New", Courier, monospace;
  font-size: 0.84rem;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    min-height: 88px;
  }

  .phase-stepper {
    justify-content: flex-start;
  }

  .app-layout {
    height: calc(100vh - 88px);
  }

  .calibration-layout {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .calibration-layout .viewer-card,
  .calibration-panel {
    max-height: none;
  }

  .workspace-task-card {
    width: min(360px, calc(100% - 32px));
  }

  .utility-card {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 260px;
  }

  .detail-drawer {
    top: auto;
    right: 12px;
    bottom: 86px;
    left: 12px;
    width: auto;
    height: min(62vh, 560px);
    transform: translateY(calc(100% + 24px));
  }

  .detail-drawer.is-open {
    transform: translateY(0);
  }
}

@media (max-width: 700px) {
  body {
    overflow-y: auto;
  }

  .app-header {
    position: static;
  }

  .topbar-main {
    width: 100%;
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .app-layout {
    height: auto;
    min-height: calc(100vh - 110px);
    padding: 10px;
  }

  .viewer-card {
    min-height: 760px;
  }

  .workspace-task-card {
    top: 10px;
    left: 10px;
    width: calc(100% - 20px);
  }

  .utility-card {
    top: auto;
    right: 10px;
    bottom: 112px;
    left: 10px;
    justify-content: center;
    max-width: none;
  }

  .workspace-action-bar {
    bottom: 10px;
    width: calc(100% - 20px);
    max-height: 88px;
    overflow-y: auto;
  }

  .image-stage {
    padding: 128px 10px 218px;
  }

  .secondary-button,
  .secondary-link {
    white-space: normal;
  }
}

/* Einzelne PNG-Hilfekarte */
.help-card-backdrop {
  z-index: 100;
  padding: 20px;
  background: rgba(13, 20, 27, 0.76);
}

.help-card-modal {
  display: grid;
  width: min(96vw, 1280px);
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  grid-template-rows: auto minmax(0, 1fr);
  padding: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #ffffff;
}

.help-card-modal .modal-header {
  min-height: 58px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
}

.help-card-modal .modal-header h2 {
  margin: 0;
  overflow: hidden;
  font-size: 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.help-card-content {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: auto;
  padding: clamp(10px, 1.8vw, 18px);
  background: #eef2f5;
}

.help-card-content img {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  max-height: calc(100vh - 116px);
  max-height: calc(100dvh - 116px);
  object-fit: contain;
}

.help-card-content img[hidden],
.help-card-fallback[hidden] {
  display: none;
}

.help-card-fallback {
  margin: 0;
  padding: 18px;
  color: var(--text-muted);
  text-align: center;
}

@media (max-width: 700px) {
  .help-card-backdrop {
    padding: 10px;
  }

  .help-card-modal {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
  }

  .help-card-content {
    padding: 8px;
  }
}

/* FRS-first HUD layout */
html,
body {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #e8edf1;
}

.app-header {
  position: relative;
  display: grid;
  grid-template-columns: minmax(250px, auto) minmax(280px, 1fr) auto;
  flex: 0 0 auto;
  min-height: 76px;
  height: 76px;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  padding: 6px clamp(10px, 1.5vw, 18px);
  border-bottom: 1px solid rgba(127, 140, 153, 0.28);
  background: rgba(248, 250, 251, 0.92);
  box-shadow: 0 8px 24px rgba(31, 41, 51, 0.06);
}

.topbar-main {
  min-width: 0;
  gap: 8px;
  flex-wrap: wrap;
}

.global-logo-slot {
  width: clamp(150px, 15vw, 220px);
  min-height: 64px;
  height: 64px;
  padding: 4px 10px;
  font-size: 0.78rem;
}

.global-logo-slot img {
  max-height: 62px;
}

.header-tools {
  height: 100%;
}

h1 {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1;
  white-space: nowrap;
}

.status-badge {
  min-height: 22px;
  padding: 3px 7px;
  border-color: rgba(47, 111, 82, 0.28);
  font-size: 0.68rem;
}

.phase-stepper {
  min-width: 0;
  flex-wrap: nowrap;
  gap: 4px;
  justify-content: center;
  overflow-x: auto;
  scrollbar-width: none;
}

.phase-stepper::-webkit-scrollbar {
  display: none;
}

.phase-step {
  min-height: 23px;
  padding: 3px 7px;
  border-color: rgba(127, 140, 153, 0.26);
  background: rgba(255, 255, 255, 0.62);
  font-size: 0.68rem;
  line-height: 1;
}

.phase-step.is-current {
  border-color: rgba(36, 107, 143, 0.82);
  background: rgba(36, 107, 143, 0.92);
}

.phase-step.is-complete {
  border-color: rgba(47, 111, 82, 0.22);
  background: rgba(230, 243, 237, 0.72);
}

.app-layout {
  flex: 1 1 auto;
  height: calc(100vh - 76px);
  height: calc(100dvh - 76px);
  min-height: 0;
  overflow: hidden;
  padding: 0;
}

.viewer-card {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: #e8edf1;
  box-shadow: none;
}

.image-stage {
  inset: 0;
  min-height: 0;
  padding: 4px;
  background: #e8edf1;
}

.canvas-workspace .image-stack {
  max-width: 100%;
  max-height: 100%;
  border: 0;
  outline: 1px solid rgba(103, 116, 128, 0.34);
  border-radius: 6px;
  background: #f9fbfc;
  box-shadow: 0 14px 34px rgba(31, 41, 51, 0.16);
  cursor: crosshair;
  transform-origin: top left;
  will-change: transform;
}

.canvas-workspace .image-stack img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
}

.canvas-workspace .image-stack canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.canvas-workspace .image-stack.is-pan-ready,
.canvas-workspace .image-stack.is-pan-ready canvas {
  cursor: grab;
}

.canvas-workspace .image-stack.is-panning,
.canvas-workspace .image-stack.is-panning canvas {
  cursor: grabbing;
}

#overlayCanvas {
  width: 100%;
  height: 100%;
}

.hud-card,
.action-dock,
.detail-drawer {
  border-color: rgba(178, 190, 201, 0.58);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 14px 34px rgba(31, 41, 51, 0.14);
  backdrop-filter: blur(16px) saturate(118%);
}

.workspace-task-card {
  top: 8px;
  left: 8px;
  width: min(300px, calc(100% - 16px));
  max-height: min(34vh, 170px);
  overflow: hidden;
  padding: 8px 10px;
}

.workspace-task-card .panel-header {
  padding: 0;
}

.workspace-task-card h2 {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #172330;
  font-size: 0.9rem;
  line-height: 1.15;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.workspace-task-card .phase-label,
.workspace-task-card .block-label {
  margin-bottom: 2px;
  color: #31566b;
  font-size: 0.64rem;
}

.workspace-task-card .task-block,
.workspace-task-card .progress-block {
  margin-top: 6px;
}

.workspace-task-card .task-block p,
.workspace-task-card .progress-detail {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #4d5965;
  font-size: 0.74rem;
  line-height: 1.22;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.workspace-task-card .progress-row {
  margin-bottom: 4px;
  font-size: 0.74rem;
}

.workspace-task-card .progress-row strong {
  white-space: nowrap;
}

.workspace-task-card .progress-detail {
  margin-bottom: 4px;
  -webkit-line-clamp: 1;
}

.workspace-task-card .progress-track {
  height: 4px;
  background: rgba(117, 132, 145, 0.22);
}

.utility-card {
  top: 8px;
  right: 8px;
  max-width: min(280px, calc(100% - 24px));
  padding: 6px;
  gap: 6px;
}

.icon-button {
  width: 29px;
  height: 29px;
  flex-basis: 29px;
  background: rgba(255, 255, 255, 0.8);
}

.compact-button {
  min-height: 29px;
  padding: 4px 7px;
  font-size: 0.72rem;
}

.zoom-controls {
  bottom: 12px;
  left: 12px;
  max-width: min(620px, calc(100% - 24px));
  padding: 6px;
  gap: 5px;
}

.zoom-button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
}

.zoom-button[hidden] {
  display: none;
}

.zoom-level {
  min-width: 44px;
  font-size: 0.76rem;
}

.pan-hint {
  max-width: min(340px, 54vw);
  font-size: 0.72rem;
}

.workspace-action-bar {
  bottom: 8px;
  width: auto;
  max-width: min(680px, calc(100% - 320px));
  min-width: min(280px, calc(100% - 32px));
  padding: 5px;
  gap: 5px;
}

.workspace-action-bar .calibration-card {
  width: min(340px, 100%);
  padding: 6px 8px;
  border-color: rgba(178, 190, 201, 0.48);
  background: rgba(251, 252, 253, 0.86);
}

.calibration-field {
  gap: 5px;
}

.calibration-field > span:first-child {
  font-size: 0.78rem;
}

.calibration-input-row input {
  min-height: 32px;
  padding: 6px 8px;
}

.panel-actions {
  flex-wrap: nowrap;
  justify-content: flex-start;
  gap: 5px;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
}

.panel-actions .primary-button,
.panel-actions .secondary-button {
  flex: 0 0 auto;
  min-height: 29px;
  padding: 5px 8px;
  font-size: 0.74rem;
  line-height: 1.1;
  white-space: nowrap;
}

.panel-actions .is-primary-action {
  flex: 0 1 auto;
  min-width: auto;
  padding-right: 11px;
  padding-left: 11px;
}

.secondary-button {
  border-color: rgba(36, 107, 143, 0.24);
  background: rgba(230, 241, 246, 0.82);
}

.quiet-button {
  border-color: rgba(121, 136, 150, 0.24);
  background: rgba(248, 250, 251, 0.74);
}

.detail-drawer {
  top: 50px;
  right: 12px;
  bottom: 56px;
  width: min(264px, calc(100% - 24px));
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.86);
}

.drawer-header {
  padding: 8px 10px;
}

.drawer-header strong {
  font-size: 0.86rem;
}

.scrollable-panel-content {
  overscroll-behavior: contain;
  padding: 9px;
}

.scrollable-panel-content > * + * {
  margin-top: 8px;
}

.training-item {
  grid-template-columns: 64px minmax(0, 1fr) auto;
  min-height: 40px;
  padding: 7px 8px;
  gap: 8px;
}

.landmark-group-heading,
.feedback-card,
.angle-question-card,
.angle-line-card,
.result-item,
.result-empty {
  border-radius: 7px;
  background: rgba(251, 252, 253, 0.88);
}

.modal-backdrop {
  z-index: 50;
  background: rgba(31, 41, 51, 0.42);
}

.help-modal {
  max-height: min(78vh, 620px);
  overflow: auto;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
}

@media (max-width: 980px) {
  body {
    overflow: hidden;
  }

  .app-header {
    grid-template-columns: minmax(190px, auto) minmax(180px, 1fr) auto;
    height: 68px;
    min-height: 68px;
    gap: 7px;
    padding: 4px 8px;
  }

  .phase-stepper {
    overflow-x: auto;
    justify-content: flex-end;
    scrollbar-width: none;
  }

  .phase-stepper::-webkit-scrollbar {
    display: none;
  }

  .app-layout {
    height: calc(100vh - 68px);
    height: calc(100dvh - 68px);
  }

  .workspace-action-bar {
    max-width: calc(100% - 220px);
  }

  .global-logo-slot {
    width: 120px;
    min-height: 56px;
    height: 56px;
  }

  .global-logo-slot img {
    max-height: 54px;
  }

  .detail-drawer {
    top: auto;
    right: 10px;
    bottom: 54px;
    left: 10px;
    width: auto;
    height: min(48vh, 420px);
  }
}

@media (max-width: 700px) {
  body {
    overflow: hidden;
  }

  .app-header {
    position: relative;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 48px 28px;
    height: 88px;
    min-height: 88px;
    gap: 2px 8px;
    padding: 4px 8px;
  }

  .topbar-main {
    grid-column: 1;
    grid-row: 1;
    width: 100%;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
  }

  .header-tools {
    grid-column: 2;
    grid-row: 1;
    gap: 5px;
  }

  .global-logo-slot {
    position: static;
    width: 88px;
    min-height: 44px;
    height: 44px;
    padding: 2px 6px;
    font-size: 0.64rem;
  }

  .global-logo-slot img {
    max-height: 42px;
  }

  h1 {
    font-size: 0.92rem;
  }

  .status-badge {
    display: none;
  }

  .topbar-main h1 {
    display: none;
  }

  .case-badge {
    max-width: 100%;
    min-height: 26px;
    padding: 3px 7px;
    overflow: hidden;
    font-size: 0.68rem;
    text-overflow: ellipsis;
  }

  .phase-stepper {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    justify-content: flex-start;
  }

  .phase-step {
    flex: 0 0 auto;
  }

  .app-layout {
    height: calc(100vh - 88px);
    height: calc(100dvh - 88px);
    min-height: 0;
    padding: 0;
  }

  .viewer-card {
    min-height: 0;
  }

  .image-stage {
    padding: 84px 5px 98px;
  }

  .workspace-task-card {
    top: 6px;
    left: 6px;
    width: calc(100% - 12px);
    max-height: 78px;
    padding: 7px 8px;
  }

  .workspace-task-card .task-block {
    margin-top: 6px;
  }

  .workspace-task-card .progress-block {
    display: none;
  }

  .utility-card {
    top: auto;
    right: 8px;
    bottom: 62px;
    left: auto;
    max-width: calc(100% - 16px);
  }

  .zoom-controls {
    bottom: 62px;
    left: 8px;
  }

  .debug-jump-controls {
    bottom: 108px;
    left: 8px;
    max-width: calc(100% - 16px);
  }

  .workspace-action-bar {
    right: 8px;
    bottom: 8px;
    left: 8px;
    width: auto;
    min-width: 0;
    max-width: none;
    transform: none;
  }

  .panel-actions {
    max-height: 52px;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .detail-drawer {
    right: 8px;
    bottom: 54px;
    left: 8px;
    height: min(48vh, 360px);
    width: auto;
  }
}

@media (max-height: 800px) and (min-width: 701px) {
  .app-header {
    height: 64px;
    min-height: 64px;
    padding-top: 3px;
    padding-bottom: 3px;
  }

  h1 {
    font-size: 0.88rem;
  }

  .status-badge {
    min-height: 20px;
    padding: 2px 6px;
    font-size: 0.64rem;
  }

  .phase-step {
    min-height: 21px;
    padding: 2px 6px;
    font-size: 0.64rem;
  }

  .app-layout {
    height: calc(100vh - 64px);
    height: calc(100dvh - 64px);
  }

  .global-logo-slot {
    min-height: 52px;
    height: 52px;
  }

  .global-logo-slot img {
    max-height: 50px;
  }

  .image-stage {
    padding: 3px;
  }

  .workspace-task-card {
    top: 6px;
    left: 6px;
    width: min(284px, calc(100% - 12px));
    max-height: min(32vh, 142px);
    padding: 7px 8px;
  }

  .workspace-task-card h2 {
    font-size: 0.84rem;
  }

  .workspace-task-card .task-block,
  .workspace-task-card .progress-block {
    margin-top: 4px;
  }

  .workspace-task-card .task-block p,
  .workspace-task-card .progress-detail,
  .workspace-task-card .progress-row {
    font-size: 0.7rem;
  }

  .workspace-action-bar {
    bottom: 6px;
    padding: 4px;
  }

  .panel-actions {
    gap: 4px;
  }

  .panel-actions .primary-button,
  .panel-actions .secondary-button {
    min-height: 27px;
    padding: 4px 7px;
    font-size: 0.7rem;
  }

  .detail-drawer {
    top: 46px;
    bottom: 48px;
  }

  .drawer-header {
    padding: 7px 9px;
  }

  .scrollable-panel-content {
    padding: 8px;
  }

  .phase-nav-group {
    padding: 6px;
  }

  .phase-nav-chip {
    min-width: 26px;
    height: 22px;
    padding: 0 5px;
    font-size: 0.66rem;
  }
}

@media (max-width: 1120px) {
  .angle-composer,
  .angle-line-picker {
    width: min(680px, calc(100% - 32px));
  }
}

@media (max-width: 820px) {
  .angle-composer {
    right: 8px;
    bottom: 58px;
    left: 8px;
    width: auto;
    transform: none;
  }

  .angle-line-picker {
    right: 8px;
    bottom: 230px;
    left: 8px;
    width: auto;
    max-height: min(42vh, 360px);
    overflow-y: auto;
    transform: none;
  }

  .angle-composer-slots {
    grid-template-columns: minmax(0, 1fr);
  }

  .angle-slot-plus {
    width: 100%;
    height: 14px;
  }

}

@media (max-height: 800px) {
  .angle-composer {
    gap: 7px;
    padding: 9px;
  }

  .angle-composer-slot {
    min-height: 38px;
    padding-top: 5px;
    padding-bottom: 5px;
  }

  .angle-line-picker {
    bottom: 158px;
    max-height: min(44vh, 330px);
    overflow-y: auto;
    padding: 9px;
  }

  .angle-library-chip {
    min-height: 30px;
    padding: 5px 8px;
    font-size: 0.78rem;
  }
}

/* Final UI polish: clinical header, case library, info drawer and evaluation rows. */
.app-header {
  min-height: 94px;
  height: 94px;
  grid-template-columns: minmax(290px, 380px) minmax(360px, 1fr) minmax(210px, 270px);
  gap: 18px;
  padding: 7px 18px;
  border-bottom-color: rgba(110, 127, 140, 0.28);
  background: rgba(250, 252, 253, 0.97);
  box-shadow: 0 8px 24px rgba(31, 41, 51, 0.07);
}

.app-layout {
  height: calc(100vh - 94px);
  height: calc(100dvh - 94px);
}

.topbar-main {
  display: grid;
  min-width: 0;
  align-content: center;
  justify-items: start;
  gap: 5px;
  overflow: visible;
}

.app-brand-copy {
  display: grid;
  min-width: 0;
  gap: 3px;
}

.app-brand-copy h1 {
  display: block;
  color: #17384a;
  font-size: 1.18rem;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
}

.usage-notice {
  display: inline-flex;
  width: fit-content;
  color: #667681;
  font-size: 0.66rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

.case-badge {
  max-width: 100%;
  min-height: 24px;
  padding: 3px 8px;
  border-color: rgba(36, 107, 143, 0.16);
  background: #edf4f7;
  font-size: 0.7rem;
}

.phase-stepper {
  justify-content: center;
  gap: 6px;
}

.phase-step {
  min-height: 28px;
  padding: 5px 9px;
  border-radius: 7px;
  font-size: 0.71rem;
}

.header-tools {
  height: auto;
  justify-content: flex-end;
}

.global-logo-slot {
  width: 100%;
  min-width: 210px;
  max-width: 270px;
  min-height: 82px;
  height: 82px;
  padding: 6px 12px;
  border-color: rgba(153, 170, 181, 0.5);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 5px 16px rgba(31, 41, 51, 0.06);
}

.global-logo-slot img {
  width: 100%;
  max-width: 100%;
  max-height: 68px;
  object-fit: contain;
}

.case-selection-workspace {
  padding: 42px 32px 56px;
  background: #edf2f5;
}

.case-selection-header {
  width: min(1240px, 100%);
  margin-bottom: 24px;
}

.case-selection-header h2 {
  color: #17384a;
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: 0;
}

.case-selection-list {
  width: min(1240px, 100%);
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: stretch;
  gap: 18px;
}

.case-selection-card {
  grid-template-rows: auto auto auto 1fr auto;
  gap: 10px;
  min-height: 100%;
  padding: 16px;
  border-color: rgba(166, 180, 190, 0.62);
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(31, 41, 51, 0.07);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.case-selection-card:not(.is-placeholder):hover {
  border-color: rgba(36, 107, 143, 0.46);
  box-shadow: 0 16px 34px rgba(31, 41, 51, 0.12);
  transform: translateY(-2px);
}

.case-selection-card img,
.case-selection-placeholder-media {
  width: 100%;
  height: 196px;
  border: 1px solid rgba(166, 180, 190, 0.58);
  border-radius: 6px;
  background: #f1f4f6;
}

.case-selection-card img {
  object-fit: contain;
}

.case-selection-card h3 {
  min-width: 0;
  color: #1f3440;
  font-size: 1.04rem;
  line-height: 1.32;
  overflow-wrap: anywhere;
  white-space: normal;
}

.case-selection-description {
  line-height: 1.45;
}

.case-selection-card .primary-button {
  grid-row: 5;
  align-self: end;
  min-height: 40px;
}

.case-selection-card.is-placeholder {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: none;
}

.case-selection-placeholder-media {
  display: grid;
  place-items: center;
  color: #92a0aa;
  font-size: 2.2rem;
  font-weight: 800;
}

.case-selection-coming-soon {
  display: inline-flex;
  grid-row: 5;
  width: fit-content;
  min-height: 30px;
  align-items: center;
  padding: 5px 9px;
  border: 1px solid rgba(151, 164, 174, 0.45);
  border-radius: 6px;
  background: #f1f4f6;
  color: #6c7982;
  font-size: 0.76rem;
  font-weight: 800;
}

.detail-drawer {
  border-color: rgba(151, 167, 178, 0.62);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 18px 42px rgba(31, 41, 51, 0.16);
}

.drawer-header {
  padding: 12px 14px;
  background: #f6f9fa;
}

.drawer-header .block-label {
  color: #567080;
}

.feedback-card {
  border-color: rgba(166, 180, 190, 0.62);
  background: #f8fafb;
}

.evaluation-sheet-panel {
  border-radius: 8px;
}

.evaluation-table-hint {
  margin: 3px 0 0;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 700;
}

.evaluation-table {
  min-width: 720px;
}

.evaluation-table tbody tr[data-analysis-key] {
  cursor: pointer;
  transition:
    filter 140ms ease,
    box-shadow 140ms ease;
}

.evaluation-table tbody tr[data-analysis-key]:hover td {
  filter: brightness(0.98);
  box-shadow: inset 0 1px 0 rgba(36, 107, 143, 0.18), inset 0 -1px 0 rgba(36, 107, 143, 0.18);
}

.evaluation-table tbody tr[data-analysis-key]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.evaluation-table tbody tr[data-analysis-key]:focus-visible td:first-child {
  box-shadow: inset 3px 0 0 var(--accent);
}

@media (max-width: 1100px) {
  .app-header {
    min-height: 82px;
    height: 82px;
    grid-template-columns: minmax(235px, 310px) minmax(300px, 1fr) minmax(155px, 190px);
    gap: 10px;
    padding-inline: 10px;
  }

  .app-layout {
    height: calc(100vh - 82px);
    height: calc(100dvh - 82px);
  }

  .app-brand-copy h1 {
    font-size: 1.04rem;
  }

  .usage-notice {
    font-size: 0.61rem;
  }

  .global-logo-slot {
    min-width: 155px;
    max-width: 190px;
    min-height: 64px;
    height: 64px;
  }

  .global-logo-slot img {
    max-height: 60px;
  }
}

@media (max-width: 760px) {
  .app-header {
    min-height: 108px;
    height: 108px;
    grid-template-columns: minmax(0, 1fr) 122px;
    grid-template-rows: 72px 28px;
    gap: 4px 8px;
    padding: 4px 8px;
  }

  .app-layout {
    height: calc(100vh - 108px);
    height: calc(100dvh - 108px);
  }

  .topbar-main {
    grid-column: 1;
    grid-row: 1;
    gap: 3px;
  }

  .app-brand-copy h1,
  .topbar-main h1 {
    display: block;
    font-size: 0.94rem;
  }

  .usage-notice {
    max-width: 100%;
    font-size: 0.57rem;
    white-space: normal;
  }

  .case-badge {
    min-height: 21px;
    padding: 2px 6px;
    font-size: 0.63rem;
  }

  .header-tools {
    grid-column: 2;
    grid-row: 1;
  }

  .global-logo-slot {
    width: 122px;
    min-width: 122px;
    min-height: 62px;
    height: 62px;
    padding: 4px 7px;
  }

  .global-logo-slot img {
    max-height: 58px;
  }

  .phase-stepper {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
  }

  .phase-step {
    min-height: 24px;
    padding: 3px 7px;
    font-size: 0.65rem;
  }

  .case-selection-workspace {
    padding: 24px 12px 36px;
  }

  .case-selection-list {
    grid-template-columns: 1fr;
  }
}

/* Finaler Vorrang vor den älteren generischen Hilfe-Modalregeln. */
.help-modal.help-card-modal {
  width: min(96vw, 1280px);
  max-width: calc(100vw - 40px);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  padding: 0;
  overflow: hidden;
  border-radius: 8px;
  background: #ffffff;
}

/* Fallbibliothek und Rollenfluss */
.case-selection-workspace {
  position: absolute;
  inset: 0;
  z-index: 12;
  overflow: auto;
  padding: clamp(24px, 5vw, 64px);
  background: #eef2f5;
}

.case-selection-workspace[hidden] {
  display: none;
}

.case-selection-header {
  width: min(1120px, 100%);
  margin: 0 auto 22px;
}

.case-selection-header h2 {
  margin-bottom: 6px;
  font-size: clamp(1.45rem, 2.4vw, 2rem);
}

.case-selection-header p:last-child {
  margin-bottom: 0;
  color: var(--text-muted);
}

.case-selection-list {
  display: grid;
  width: min(1120px, 100%);
  margin: 0 auto;
  grid-template-columns: repeat(auto-fill, minmax(260px, 360px));
  justify-content: start;
  gap: 14px;
}

.case-selection-card {
  display: grid;
  min-width: 0;
  align-content: start;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 28px rgba(31, 41, 51, 0.08);
}

.case-selection-card img {
  width: 100%;
  height: 170px;
  border: 1px solid var(--line);
  border-radius: 6px;
  object-fit: contain;
  background: #eef2f5;
}

.case-selection-card h3,
.case-selection-card p {
  margin: 0;
}

.case-selection-card h3 {
  font-size: 1rem;
}

.case-selection-meta {
  color: var(--accent-dark);
  font-size: 0.84rem;
  font-weight: 800;
}

.case-selection-description,
.case-selection-empty {
  color: var(--text-muted);
  font-size: 0.86rem;
}

.case-selection-card .primary-button {
  width: 100%;
  margin-top: 4px;
}

.canvas-workspace.is-case-selection-phase .image-stage,
.canvas-workspace.is-case-selection-phase .utility-card,
.canvas-workspace.is-case-selection-phase .workspace-action-bar,
.canvas-workspace.is-case-selection-phase .zoom-controls,
.canvas-workspace.is-evaluation-phase .zoom-controls {
  display: none;
}

.canvas-workspace.is-evaluation-phase .debug-jump-controls {
  bottom: 12px;
}

/* Zentrale strukturierte Hilfe */
.structured-help {
  display: grid;
  gap: 12px;
}

.structured-help[hidden],
.structured-help [hidden] {
  display: none;
}

.structured-help p,
.help-construction-steps {
  margin: 0;
}

.help-construction-steps {
  padding-left: 22px;
  color: var(--text-main);
}

.help-interpretations {
  display: grid;
  gap: 8px;
}

.help-interpretations section {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9fa;
}

.help-interpretations h3,
.help-interpretations p {
  margin: 0;
}

.help-interpretations h3 {
  margin-bottom: 4px;
  font-size: 0.82rem;
}

.help-image-block {
  margin: 0;
}

.help-image-block img {
  display: block;
  max-width: 100%;
  max-height: 48vh;
  margin: 0 auto;
  object-fit: contain;
}

.help-image-block figcaption,
.help-source {
  margin-top: 6px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.evaluation-help-image {
  display: block;
  width: 100%;
  max-height: 260px;
  object-fit: contain;
}

.help-fallback {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #f7f9fa;
  color: var(--text-muted);
}

/* Größeres, dauerhaftes Logo in der oberen Werkzeugleiste */
.app-header {
  min-height: 104px;
  height: 104px;
  grid-template-columns: minmax(280px, 400px) minmax(0, 1fr) auto;
}

.app-layout {
  height: calc(100vh - 104px);
  height: calc(100dvh - 104px);
}

.global-logo-slot {
  width: clamp(240px, 22vw, 320px);
  min-height: 92px;
  height: 92px;
  padding: 5px 12px;
}

.global-logo-slot img {
  max-width: 100%;
  max-height: 90px;
}

.topbar-main {
  overflow: hidden;
}

.case-badge {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Fallvorbereitung in calibrate.html */
.calibration-document {
  height: auto;
  min-height: 100%;
  overflow: auto;
}

.calibration-tool {
  height: auto;
  min-height: 100vh;
  overflow: visible;
}

.calibration-tool .app-header {
  position: sticky;
  display: flex;
  min-height: 72px;
  height: auto;
  justify-content: space-between;
}

.calibration-tool .app-layout {
  height: auto;
  min-height: calc(100vh - 72px);
  overflow: visible;
}

.calibration-tool .calibration-layout {
  grid-template-columns: minmax(0, 1fr) minmax(420px, 540px);
  gap: 18px;
  padding: 18px;
}

.calibration-tool .calibration-layout .viewer-card,
.calibration-tool .calibration-panel {
  max-height: calc(100vh - 108px);
}

.case-preparation-section {
  display: grid;
  gap: 12px;
  padding-bottom: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--line);
}

.case-form-grid,
.scale-calibration-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.scale-calibration-row {
  align-items: end;
}

.form-field textarea {
  width: 100%;
  resize: vertical;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text-main);
  font: inherit;
}

.field-note {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.78rem;
}

@media (max-width: 1100px) {
  .app-header {
    grid-template-columns: minmax(220px, 300px) minmax(0, 1fr) auto;
    min-height: 88px;
    height: 88px;
  }

  .app-layout {
    height: calc(100vh - 88px);
    height: calc(100dvh - 88px);
  }

  .global-logo-slot {
    width: 190px;
    min-height: 76px;
    height: 76px;
  }

  .global-logo-slot img {
    max-height: 74px;
  }

  .calibration-tool .calibration-layout {
    grid-template-columns: 1fr;
  }

  .calibration-tool .calibration-layout .viewer-card,
  .calibration-tool .calibration-panel {
    max-height: none;
  }
}

@media (max-width: 700px) {
  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: 58px 30px;
    min-height: 96px;
    height: 96px;
  }

  .app-layout {
    height: calc(100vh - 96px);
    height: calc(100dvh - 96px);
  }

  .global-logo-slot {
    width: 126px;
    min-height: 54px;
    height: 54px;
  }

  .global-logo-slot img {
    max-height: 52px;
  }

  .case-selection-workspace {
    padding: 18px 10px;
  }

  .case-form-grid,
  .scale-calibration-row {
    grid-template-columns: 1fr;
  }
}

/* Winkelphase: Composer und Picker bleiben an der linken Aufgabenkarte, damit das FRS frei bleibt. */
.workspace-task-card.is-angle-task {
  z-index: 8;
  width: min(318px, calc(100% - 16px));
  max-height: none;
  overflow: visible;
}

.workspace-task-card.is-angle-task .task-block {
  display: none;
}

.workspace-task-card.is-angle-task .progress-block {
  margin-top: 7px;
}

.workspace-task-card.is-angle-task .progress-row {
  margin-bottom: 0;
}

.workspace-task-card.is-angle-task .progress-row span,
.workspace-task-card.is-angle-task .progress-detail,
.workspace-task-card.is-angle-task .progress-track {
  display: none;
}

.workspace-task-card.is-angle-task .progress-row strong {
  color: var(--text-muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.task-subtitle {
  margin: 2px 0 0;
  color: var(--accent-dark);
  font-size: 0.76rem;
  font-weight: 800;
}

.task-subtitle[hidden] {
  display: none;
}

.workspace-task-card.is-xi-task {
  width: min(430px, calc(100% - 16px));
  max-height: min(48vh, 330px);
  overflow: auto;
}

.workspace-task-card.is-xi-task .task-block p,
.workspace-task-card.is-xi-task .progress-detail {
  display: block;
  overflow: visible;
  -webkit-line-clamp: unset;
}

.workspace-task-card.is-xi-task .progress-block {
  display: block;
}

.workspace-task-card.is-xi-task .progress-row {
  display: block;
}

.workspace-task-card.is-xi-task .progress-row strong {
  display: block;
  margin-top: 3px;
  white-space: normal;
  line-height: 1.35;
}

.workspace-task-card.is-evaluation-help-only {
  width: auto;
  min-width: 72px;
  max-height: none;
  overflow: visible;
  padding: 10px;
}

.workspace-task-card.is-evaluation-help-only .panel-header {
  justify-content: center;
}

.workspace-task-card.is-evaluation-help-only .panel-header > div,
.workspace-task-card.is-evaluation-help-only .task-block,
.workspace-task-card.is-evaluation-help-only .progress-block,
.workspace-task-card.is-evaluation-help-only .angle-composer {
  display: none;
}

.workspace-task-card.is-evaluation-help-only .task-help-button {
  width: 48px;
  height: 48px;
  border-color: rgba(36, 107, 143, 0.36);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--accent-dark);
  font-size: 1.2rem;
  font-weight: 900;
}

.workspace-task-card .angle-composer {
  position: static;
  display: grid;
  width: 100%;
  min-width: 0;
  gap: 8px;
  margin-top: 9px;
  padding: 0;
  transform: none;
}

.workspace-task-card .angle-composer[hidden] {
  display: none;
}

.workspace-task-card .angle-composer-head {
  display: none;
}

.workspace-task-card .angle-composer-slots {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.workspace-task-card .angle-slot-plus {
  display: none;
}

.workspace-task-card .angle-composer-slot {
  grid-template-columns: auto minmax(0, 1fr);
  min-height: 34px;
  align-items: center;
  gap: 8px;
  padding: 6px 32px 6px 9px;
}

.workspace-task-card .angle-composer-slot .angle-slot-label {
  font-size: 0.68rem;
  font-weight: 800;
  white-space: nowrap;
}

.workspace-task-card .angle-composer-slot strong,
.workspace-task-card .angle-composer-slot span:last-child {
  font-size: 0.82rem;
}

.workspace-task-card .angle-slot-remove {
  right: 6px;
  width: 22px;
  height: 22px;
}

.workspace-task-card .angle-composer-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}

.workspace-task-card .angle-composer-actions .secondary-button {
  min-height: 32px;
  padding: 6px 9px;
  font-size: 0.8rem;
}

.workspace-task-card .angle-composer-feedback {
  padding: 7px 8px;
  font-size: 0.76rem;
  line-height: 1.25;
}

.workspace-task-card .angle-composer-result {
  max-height: min(32vh, 230px);
  overflow-y: auto;
  padding: 8px;
  font-size: 0.78rem;
}

.workspace-task-card .angle-composer-result small {
  font-size: 0.72rem;
}

.workspace-task-card .angle-summary-list {
  max-height: 160px;
  overflow-y: auto;
}

.workspace-task-card .angle-line-picker {
  position: absolute;
  top: 0;
  bottom: auto;
  left: calc(100% + 10px);
  z-index: 10;
  width: min(330px, calc(100vw - 360px));
  max-height: min(78vh, 520px);
  min-width: 280px;
  gap: 8px;
  overflow-y: auto;
  padding: 10px;
  transform: none;
}

.workspace-task-card .angle-line-picker[hidden] {
  display: none;
}

.workspace-task-card .angle-picker-groups {
  gap: 8px;
}

.workspace-task-card .angle-library-group {
  gap: 5px;
}

.workspace-task-card .angle-library-chip-row {
  gap: 5px;
}

.workspace-task-card .angle-library-chip {
  min-height: 31px;
  min-width: 46px;
  padding: 5px 8px;
  font-size: 0.78rem;
}

.angle-navigator-list .phase-nav-group {
  gap: 7px;
}

.angle-navigator-list .phase-nav-chip-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
}

.angle-navigator-list .phase-nav-chip.angle-progress-chip {
  display: grid;
  width: 100%;
  max-width: none;
  min-height: 27px;
  height: auto;
  grid-template-columns: auto minmax(0, 1fr) auto;
  justify-items: stretch;
  align-items: center;
  gap: 6px;
  padding: 4px 7px;
  text-align: left;
}

.angle-progress-marker {
  color: inherit;
  font-size: 0.74rem;
}

.angle-progress-chip.is-missing .angle-progress-marker,
.angle-progress-chip.is-missing .angle-progress-value {
  color: var(--open-text);
}

.angle-progress-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.angle-progress-value {
  color: inherit;
  font-size: 0.68rem;
  font-weight: 900;
  opacity: 0.82;
}

@media (max-width: 980px) {
  .workspace-task-card.is-angle-task {
    width: min(306px, calc(100% - 16px));
  }

  .evaluation-workspace {
    grid-template-columns: 1fr;
    overflow: auto;
    padding-top: 68px;
  }

  .workspace-task-card .angle-line-picker {
    top: calc(100% + 8px);
    left: 0;
    width: min(330px, calc(100vw - 16px));
    max-height: min(46vh, 340px);
    min-width: 0;
  }
}

@media (max-width: 700px) {
  .workspace-task-card.is-angle-task {
    max-height: none;
  }

  .evaluation-workspace {
    gap: 10px;
    padding: 66px 8px 14px;
  }

  .workspace-task-card.is-angle-task .progress-block {
    display: block;
  }

  .workspace-task-card .angle-line-picker {
    width: min(100%, calc(100vw - 12px));
  }
}

@media (max-height: 800px) {
  .workspace-task-card.is-angle-task {
    width: min(300px, calc(100% - 12px));
  }

  .workspace-task-card .angle-composer {
    gap: 6px;
    margin-top: 7px;
    padding: 0;
  }

  .workspace-task-card .angle-composer-slot {
    min-height: 31px;
    padding-top: 5px;
    padding-bottom: 5px;
  }

  .workspace-task-card .angle-line-picker {
    max-height: min(72vh, 430px);
    padding: 8px;
  }
}

/* UI overrides must remain last so legacy layout rules cannot replace them. */
.app-header {
  min-height: 88px;
  height: 88px;
  grid-template-columns: minmax(290px, 380px) minmax(360px, 1fr) minmax(190px, 250px);
  gap: 18px;
  padding: 7px 18px;
  background: rgba(250, 252, 253, 0.97);
}

.app-layout {
  height: calc(100vh - 88px);
  height: calc(100dvh - 88px);
}

.topbar-main {
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 5px;
  overflow: visible;
}

.app-brand-copy h1 {
  display: block;
  font-size: 1.18rem;
}

.case-badge {
  max-width: 100%;
  min-height: 24px;
  padding: 3px 8px;
  overflow: visible;
  font-size: 0.7rem;
  text-overflow: clip;
  white-space: normal;
}

.global-logo-slot {
  width: 100%;
  min-width: 190px;
  max-width: 250px;
  min-height: 72px;
  height: 72px;
  padding: 6px 12px;
}

.global-logo-slot img {
  max-height: 78px;
  object-fit: contain;
}

.case-selection-workspace {
  padding: 30px 32px 56px;
  background: #edf2f5;
}

.case-selection-header,
.case-selection-list {
  width: min(1240px, 100%);
}

.case-selection-header {
  margin-bottom: 16px;
}

.case-selection-header h2 {
  margin: 0;
  color: #526873;
  font-size: 0.94rem;
  font-weight: 800;
  text-transform: uppercase;
}

.case-selection-list {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  align-items: stretch;
  justify-content: stretch;
  gap: 18px;
}

.case-selection-card {
  grid-template-rows: auto auto auto 1fr auto;
  min-height: 100%;
  gap: 10px;
  padding: 16px;
}

.case-selection-card img,
.case-selection-placeholder-media {
  height: 196px;
}

.case-selection-card h3 {
  font-size: 1.04rem;
  line-height: 1.32;
  overflow: visible;
  overflow-wrap: anywhere;
  text-overflow: clip;
  white-space: normal;
}

.case-selection-card .primary-button,
.case-selection-coming-soon {
  grid-row: 5;
}

.case-selection-card.is-placeholder {
  grid-template-rows: 196px auto auto;
  align-content: start;
  min-height: 310px;
  border-color: rgba(151, 167, 178, 0.42);
  background: rgba(247, 249, 250, 0.68);
  opacity: 0.72;
}

.case-selection-card.is-placeholder:hover {
  transform: none;
}

.case-selection-placeholder-media {
  background: #f3f6f7;
}

.case-placeholder-image {
  position: relative;
  display: block;
  width: 68%;
  height: 58%;
  border: 1px solid rgba(145, 160, 170, 0.42);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
}

.case-placeholder-image::before,
.case-placeholder-image::after {
  position: absolute;
  content: "";
  border-radius: 4px;
  background: #e3e9ec;
}

.case-placeholder-image::before {
  inset: 18% 16% 42%;
}

.case-placeholder-image::after {
  right: 16%;
  bottom: 18%;
  left: 16%;
  height: 12%;
}

.case-placeholder-line {
  display: block;
  height: 10px;
  border-radius: 5px;
  background: #e2e8eb;
}

.case-placeholder-line.is-title {
  width: 68%;
}

.case-placeholder-line.is-meta {
  width: 42%;
  height: 8px;
}

.evaluation-workspace {
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
}

.evaluation-sheet-panel {
  width: min(1500px, 100%);
  margin: 0 auto;
}

.evaluation-table {
  min-width: 720px;
}

@media (max-width: 1100px) {
  .app-header {
    min-height: 86px;
    height: 86px;
    grid-template-columns: minmax(235px, 310px) minmax(300px, 1fr) minmax(170px, 210px);
    gap: 10px;
    padding-inline: 10px;
  }

  .app-layout {
    height: calc(100vh - 86px);
    height: calc(100dvh - 86px);
  }

  .app-brand-copy h1 {
    font-size: 1.04rem;
  }

  .global-logo-slot {
    min-width: 170px;
    max-width: 210px;
    min-height: 70px;
    height: 70px;
  }

  .global-logo-slot img {
    max-height: 66px;
  }
}

@media (max-width: 760px) {
  .app-header {
    min-height: 110px;
    height: 110px;
    grid-template-columns: minmax(0, 1fr) 122px;
    grid-template-rows: 72px 28px;
    gap: 4px 8px;
    padding: 4px 8px;
  }

  .app-layout {
    height: calc(100vh - 110px);
    height: calc(100dvh - 110px);
  }

  .topbar-main {
    grid-column: 1;
    grid-row: 1;
  }

  .app-brand-copy h1,
  .topbar-main h1 {
    display: block;
    font-size: 0.94rem;
  }

  .case-badge {
    min-height: 21px;
    padding: 2px 6px;
    font-size: 0.63rem;
  }

  .header-tools {
    grid-column: 2;
    grid-row: 1;
  }

  .global-logo-slot {
    width: 122px;
    min-width: 122px;
    max-width: 122px;
    min-height: 66px;
    height: 66px;
  }

  .global-logo-slot img {
    max-height: 62px;
  }

  .phase-stepper {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: flex-start;
  }

  .case-selection-workspace {
    padding: 24px 12px 36px;
  }

  .case-selection-list {
    grid-template-columns: 1fr;
  }
}

/* Definitive header sizing for the integrated logo. */
.app-header {
  min-height: 94px;
  height: 94px;
  grid-template-columns: minmax(290px, 380px) minmax(360px, 1fr) minmax(210px, 270px);
}

.app-layout {
  height: calc(100vh - 94px);
  height: calc(100dvh - 94px);
}

.global-logo-slot {
  min-width: 210px;
  max-width: 270px;
  min-height: 82px;
  height: 82px;
}

.global-logo-slot img {
  max-height: 78px;
}

@media (max-width: 1100px) {
  .app-header {
    min-height: 86px;
    height: 86px;
    grid-template-columns: minmax(235px, 310px) minmax(300px, 1fr) minmax(170px, 210px);
  }

  .app-layout {
    height: calc(100vh - 86px);
    height: calc(100dvh - 86px);
  }

  .global-logo-slot {
    min-width: 170px;
    max-width: 210px;
    min-height: 70px;
    height: 70px;
  }

  .global-logo-slot img {
    max-height: 66px;
  }
}

@media (max-width: 760px) {
  .app-header {
    min-height: 110px;
    height: 110px;
  }

  .app-layout {
    height: calc(100vh - 110px);
    height: calc(100dvh - 110px);
  }

  .global-logo-slot {
    min-width: 122px;
    max-width: 122px;
    min-height: 66px;
    height: 66px;
  }

  .global-logo-slot img {
    max-height: 62px;
  }
}
