/*
 * Airway Atlas v0.1
 * A quiet clinical workbench: ivory paper, ink green, and restrained copper.
 */

:root {
  color-scheme: light;
  --paper: #f4f0e8;
  --paper-deep: #e9e4d9;
  --panel: rgba(255, 253, 248, 0.9);
  --panel-solid: #fffdf8;
  --panel-muted: #efebe2;
  --ink: #173b33;
  --ink-soft: #48665d;
  --ink-faint: #789087;
  --line: rgba(23, 59, 51, 0.14);
  --line-strong: rgba(23, 59, 51, 0.24);
  --copper: #a96643;
  --copper-deep: #7f4930;
  --copper-pale: #ead4c5;
  --canvas: #dfe8df;
  --shadow-sm: 0 1px 2px rgba(37, 48, 41, 0.06), 0 6px 18px rgba(37, 48, 41, 0.04);
  --shadow-md: 0 16px 42px rgba(37, 48, 41, 0.11), 0 2px 7px rgba(37, 48, 41, 0.06);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --header-height: 76px;
  --controls-width: 260px;
  --inspector-width: 280px;
  --ui-font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono-font: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

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

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
  font-family: var(--ui-font);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 15% -10%, rgba(255, 255, 255, 0.74), transparent 30rem),
    linear-gradient(135deg, #f7f4ee 0%, var(--paper) 45%, #ebe9df 100%);
  color: var(--ink);
  font-size: 13px;
  line-height: 1.5;
  letter-spacing: 0.005em;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

button,
input[type="range"],
input[type="checkbox"],
input[type="radio"] {
  -webkit-tap-highlight-color: transparent;
}

button,
label,
input[type="range"],
input[type="checkbox"],
input[type="radio"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(169, 102, 67, 0.45);
  outline-offset: 3px;
}

button:disabled,
input:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.brandbar {
  position: relative;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: var(--header-height);
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(248, 246, 240, 0.82);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(16px);
}

.brandbar::before {
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--copper);
  content: "";
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 12px;
  min-width: 0;
}

.brand h1,
.brand > strong,
.brand > span:first-child {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1.1;
}

.brand-symbol {
  margin-right: -5px;
  color: var(--copper);
  font-family: var(--mono-font);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand .edition {
  color: var(--copper-deep);
  font-family: var(--mono-font);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  white-space: nowrap;
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-left: 20px;
}

.actions button,
.header-actions button {
  min-height: 34px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.68);
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.02em;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.actions button:hover,
.header-actions button:hover {
  border-color: var(--copper);
  background: var(--copper-pale);
  color: var(--copper-deep);
  transform: translateY(-1px);
}

.actions button[data-primary],
.actions .primary,
.header-actions .primary {
  border-color: var(--ink);
  background: var(--ink);
  color: #f8f5ed;
}

.actions button[data-primary]:hover,
.actions .primary:hover,
.header-actions .primary:hover {
  border-color: var(--ink);
  background: #24574b;
  color: #fffdf8;
}

.workspace {
  display: grid;
  grid-template-columns: var(--controls-width) minmax(0, 1fr) var(--inspector-width);
  gap: 14px;
  height: calc(100vh - var(--header-height));
  min-height: calc(100vh - var(--header-height));
  padding: 14px;
}

.controls,
.inspector {
  min-width: 0;
  max-height: calc(100vh - var(--header-height) - 28px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(12px);
}

.controls {
  align-self: start;
  padding: 23px 18px 22px;
}

.inspector {
  align-self: start;
  padding: 22px 18px 18px;
}

.eyebrow,
.section-label {
  display: block;
  margin: 0 0 8px;
  color: var(--copper-deep);
  font-family: var(--mono-font);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.14em;
  line-height: 1.3;
  text-transform: uppercase;
}

.controls h1 {
  max-width: 10ch;
  margin: 0;
  color: var(--ink);
  font-size: clamp(20px, 2.2vw, 26px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.13;
}

.intro {
  margin: 12px 0 23px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.65;
}

.control-group,
.controls > section,
.controls > .control,
.controls > fieldset {
  margin-top: 22px;
}

.control-group:first-of-type,
.controls > .section-label + .scenario-list {
  margin-top: 0;
}

.section-label {
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}

.scenario-list {
  display: grid;
  gap: 6px;
  margin: 0;
}

.scenario,
.scenario-list button {
  display: grid;
  gap: 1px;
  width: 100%;
  padding: 10px 11px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.scenario:hover,
.scenario-list button:hover {
  border-color: var(--line);
  background: rgba(239, 235, 226, 0.75);
  color: var(--ink);
}

.scenario.active,
.scenario-list button.active,
.scenario[aria-current="true"] {
  border-color: rgba(169, 102, 67, 0.46);
  background: linear-gradient(90deg, rgba(234, 212, 197, 0.72), rgba(234, 212, 197, 0.22));
  color: var(--ink);
  box-shadow: inset 3px 0 0 var(--copper);
}

.scenario strong,
.scenario-list button strong {
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.scenario small,
.scenario-list button small {
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.4;
}

.scenario.active small,
.scenario-list button.active small {
  color: var(--copper-deep);
}

.control {
  display: grid;
  gap: 9px;
}

.control > label,
.control > .label,
.control label:not(.toggle) {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 650;
}

.control output,
.value,
.readout {
  color: var(--copper-deep);
  font-family: var(--mono-font);
  font-size: 10px;
  font-weight: 600;
}

input[type="range"] {
  width: 100%;
  height: 20px;
  margin: 0;
  accent-color: var(--copper);
  background: transparent;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--copper) 0%, var(--copper) var(--range-progress, 50%), var(--paper-deep) var(--range-progress, 50%), var(--paper-deep) 100%);
}

input[type="range"]::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
  margin-top: -6px;
  border: 2px solid var(--panel-solid);
  border-radius: 50%;
  background: var(--copper);
  box-shadow: 0 0 0 1px var(--copper), 0 2px 6px rgba(127, 73, 48, 0.25);
  -webkit-appearance: none;
}

input[type="range"]::-moz-range-track {
  height: 4px;
  border-radius: 999px;
  background: var(--paper-deep);
}

input[type="range"]::-moz-range-progress {
  height: 4px;
  border-radius: 999px;
  background: var(--copper);
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 2px solid var(--panel-solid);
  border-radius: 50%;
  background: var(--copper);
  box-shadow: 0 0 0 1px var(--copper), 0 2px 6px rgba(127, 73, 48, 0.25);
}

.range-ends {
  display: flex;
  justify-content: space-between;
  color: var(--ink-faint);
  font-family: var(--mono-font);
  font-size: 9px;
  line-height: 1;
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.presets button,
.preset {
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-solid);
  color: var(--ink-soft);
  font-family: var(--mono-font);
  font-size: 9px;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.presets button:hover,
.presets button.active,
.preset:hover,
.preset.active {
  border-color: var(--copper);
  background: var(--copper-pale);
  color: var(--copper-deep);
}

.toggle {
  position: relative;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px 13px;
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.35;
}

.toggle label {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 20px;
  color: inherit;
  font-size: inherit;
  line-height: inherit;
}

.toggle input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.toggle label::before {
  width: 30px;
  height: 18px;
  flex: 0 0 auto;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--paper-deep);
  box-shadow: inset 0 1px 2px rgba(23, 59, 51, 0.08);
  content: "";
  transition: background-color 160ms ease, border-color 160ms ease;
}

.toggle label::after {
  position: absolute;
  top: 50%;
  left: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fffdf8;
  box-shadow: 0 1px 3px rgba(23, 59, 51, 0.2);
  content: "";
  transform: translateY(-50%);
  transition: transform 160ms ease;
}

.toggle label:has(input:checked)::before {
  border-color: var(--ink);
  background: var(--ink);
}

.toggle label:has(input:checked)::after {
  transform: translate(12px, -50%);
}

.toggle label:has(input:focus-visible) {
  outline: 3px solid rgba(169, 102, 67, 0.45);
  outline-offset: 3px;
}

.stage {
  position: relative;
  display: flex;
  align-self: start;
  min-width: 0;
  min-height: 620px;
  height: calc(100vh - 100px);
  overflow: hidden;
  isolation: isolate;
  border: 1px solid rgba(23, 59, 51, 0.2);
  border-radius: var(--radius-lg);
  background: var(--canvas);
  box-shadow: var(--shadow-md);
}

.stage::before,
.stage::after {
  position: absolute;
  z-index: 0;
  border: 1px solid rgba(23, 59, 51, 0.1);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.stage::before {
  width: 72%;
  aspect-ratio: 1;
  left: 14%;
  top: 13%;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.32), inset 0 0 60px rgba(255, 255, 255, 0.16);
}

.stage::after {
  width: 44%;
  aspect-ratio: 1;
  left: 28%;
  top: 27%;
  border-style: dashed;
  border-color: rgba(169, 102, 67, 0.18);
}

#viewport,
.stage canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  outline: none;
}

#labels {
  position: absolute;
  z-index: 2;
  inset: 0;
  pointer-events: none;
}

.anatomy-label {
  position: absolute;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: max-content;
  max-width: 170px;
  padding: 3px 6px 3px 7px;
  border: 1px solid rgba(23, 59, 51, 0.18);
  border-radius: 3px;
  background: rgba(255, 253, 248, 0.8);
  box-shadow: 0 3px 10px rgba(37, 48, 41, 0.08);
  color: var(--ink);
  font-size: 11px;
  line-height: 1.25;
  pointer-events: none;
  transform: translate(7px, -50%);
  backdrop-filter: blur(7px);
}

.anatomy-label::before {
  position: absolute;
  right: 100%;
  width: 24px;
  height: 1px;
  background: var(--copper);
  content: "";
  opacity: 0.8;
}

[hidden] {
  display: none !important;
}

.stage-top,
.stage-bottom {
  position: absolute;
  z-index: 2;
  right: 18px;
  left: 18px;
  display: flex;
  align-items: center;
  pointer-events: none;
}

.stage-top {
  top: 17px;
  z-index: 4;
  justify-content: space-between;
  gap: 14px;
}

.stage-bottom {
  bottom: 17px;
  z-index: 4;
  justify-content: space-between;
  gap: 14px;
}

.stage-top > *,
.stage-bottom > *,
.viewbar button {
  pointer-events: auto;
}

.viewbar {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(23, 59, 51, 0.16);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.74);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.viewbar button {
  min-height: 27px;
  padding: 4px 9px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink-soft);
  font-family: var(--mono-font);
  font-size: 9px;
  transition: background-color 160ms ease, color 160ms ease;
}

.viewbar button:hover,
.viewbar button.active,
.viewbar button[aria-pressed="true"] {
  background: var(--ink);
  color: #fffdf8;
}

.stage-top > div:first-child {
  display: grid;
  gap: 5px;
}

.stage-top .eyebrow {
  margin: 0;
}

.stage-top h2 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(16px, 2vw, 22px);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.stage-top .badge {
  justify-self: start;
}

.model-caption {
  position: absolute;
  z-index: 3;
  right: 18px;
  bottom: 59px;
  max-width: min(48%, 340px);
  margin-left: auto;
  padding: 9px 12px;
  border-left: 2px solid var(--copper);
  background: rgba(255, 253, 248, 0.74);
  box-shadow: var(--shadow-sm);
  color: var(--ink);
  font-size: 11px;
  line-height: 1.4;
  backdrop-filter: blur(10px);
}

.model-caption strong {
  display: block;
  font-size: 12px;
  font-weight: 700;
}

.model-caption small {
  display: block;
  margin-top: 2px;
  color: var(--ink-soft);
  font-size: 10px;
}

.stage-bottom {
  color: var(--ink-soft);
  font-family: var(--mono-font);
  font-size: 9px;
}

.stage-bottom > :first-child {
  padding: 5px 8px;
  border: 1px solid rgba(23, 59, 51, 0.14);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.62);
  backdrop-filter: blur(8px);
}

.loading {
  position: absolute;
  z-index: 5;
  top: 50%;
  left: 50%;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px;
  border: 1px solid rgba(23, 59, 51, 0.14);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.7);
  color: var(--ink-soft);
  font-family: var(--mono-font);
  font-size: 9px;
  transform: translate(-50%, -50%);
  backdrop-filter: blur(8px);
}

.loading::before {
  width: 8px;
  height: 8px;
  border: 1px solid rgba(169, 102, 67, 0.28);
  border-top-color: var(--copper);
  border-radius: 50%;
  animation: atlas-spin 900ms linear infinite;
  content: "";
}

.inspector h2 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 18px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.inspector h3 {
  margin: 17px 0 5px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 3px 7px;
  border: 1px solid rgba(169, 102, 67, 0.34);
  border-radius: 999px;
  background: var(--copper-pale);
  color: var(--copper-deep);
  font-family: var(--mono-font);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.metric {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: baseline;
  gap: 12px;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}

.metric:first-of-type {
  border-top: 0;
}

.metric dt,
.metric .label {
  color: var(--ink-soft);
  font-size: 11px;
}

.metric dd,
.metric .value {
  margin: 0;
  color: var(--ink);
  font-family: var(--mono-font);
  font-size: 12px;
  font-weight: 600;
  text-align: right;
}

.metric strong {
  color: var(--ink);
  font-family: var(--mono-font);
  font-size: 30px;
  font-weight: 650;
  letter-spacing: -0.08em;
  line-height: 1;
}

.metric > span {
  color: var(--ink-soft);
  font-size: 10px;
  text-align: right;
}

.note {
  margin: 13px 0 21px;
  padding: 11px 12px;
  border: 1px solid rgba(169, 102, 67, 0.2);
  border-radius: var(--radius-sm);
  background: rgba(234, 212, 197, 0.32);
  color: var(--copper-deep);
  font-size: 11px;
  line-height: 1.58;
}

.steps {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: atlas-step;
}

.steps button,
.step {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  min-height: 38px;
  padding: 7px 9px 7px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--ink-soft);
  text-align: left;
  font-size: 11px;
  line-height: 1.35;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease, transform 160ms ease;
  counter-increment: atlas-step;
}

.steps button::before,
.step::before {
  display: none;
  content: none;
}

.steps button > span:first-child,
.step > span:first-child {
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel-solid);
  color: var(--ink-faint);
  font-family: var(--mono-font);
  font-size: 9px;
  line-height: 1;
}

.steps button:hover,
.step:hover {
  border-color: var(--line);
  background: rgba(239, 235, 226, 0.75);
  color: var(--ink);
}

.steps button.active,
.steps button[aria-current="step"],
.step.active {
  border-color: rgba(169, 102, 67, 0.35);
  background: rgba(234, 212, 197, 0.38);
  color: var(--ink);
  box-shadow: inset 3px 0 0 var(--copper);
}

.steps button.active::before,
.steps button[aria-current="step"]::before,
.step.active::before {
  display: none;
}

.steps button.active > span:first-child,
.steps button[aria-current="step"] > span:first-child,
.step.active > span:first-child {
  border-color: var(--copper);
  background: var(--copper);
  color: #fffdf8;
}

.inspector .control {
  margin-top: 20px;
}

.inspector > .primary,
.inspector button.primary {
  width: 100%;
  min-height: 40px;
  margin-top: 5px;
  padding: 9px 13px;
  border: 1px solid var(--ink);
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fffdf8;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition: background-color 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.inspector > .primary:hover,
.inspector button.primary:hover {
  border-color: #24574b;
  background: #24574b;
  transform: translateY(-1px);
}

details {
  margin-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--ink-soft);
  font-size: 10px;
  line-height: 1.58;
}

details summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 0 9px;
  color: var(--ink);
  cursor: pointer;
  font-size: 11px;
  font-weight: 650;
  list-style: none;
}

details summary::-webkit-details-marker {
  display: none;
}

details summary::after {
  color: var(--copper);
  content: "+";
  font-family: var(--mono-font);
  font-size: 13px;
  font-weight: 400;
}

details[open] summary::after {
  content: "−";
}

details p {
  margin: 0 0 9px;
}

.sources {
  margin: 22px 0 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.55;
}

.sources a {
  color: var(--copper-deep);
  text-decoration: underline;
  text-decoration-color: rgba(169, 102, 67, 0.42);
  text-underline-offset: 2px;
}

.sources a:hover {
  color: var(--ink);
  text-decoration-color: var(--ink);
}

footer {
  margin-top: 22px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 10px;
  line-height: 1.5;
}

body > footer {
  padding: 0 28px 18px;
}

.model-caption .swatch {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin: 0 4px 0 8px;
  border-radius: 50%;
  vertical-align: 1px;
}

.model-caption .swatch:first-child {
  margin-left: 0;
}

.model-caption .swatch.bone {
  background: #d9cbb0;
}

.model-caption .swatch.tissue {
  background: #c78489;
}

.model-caption .swatch.airway {
  background: #82aaa1;
}

.model-caption .swatch.tool {
  background: #c48843;
}

footer a {
  color: var(--copper-deep);
}

@keyframes atlas-spin {
  to {
    transform: rotate(360deg);
  }
}

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

@media (max-width: 1120px) {
  :root {
    --controls-width: 232px;
    --inspector-width: 248px;
  }

  .brandbar {
    padding-right: 20px;
    padding-left: 24px;
  }

  .workspace {
    gap: 10px;
    padding: 10px;
  }

  .controls,
  .inspector {
    padding-right: 14px;
    padding-left: 14px;
  }
}

@media (max-width: 860px) {
  .brandbar {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
    padding-top: 17px;
    padding-bottom: 15px;
  }

  .actions {
    width: 100%;
    margin-left: 0;
  }

  .actions button,
  .header-actions button {
    flex: 1 1 auto;
  }

  .workspace {
    grid-template-columns: minmax(0, 1fr);
    height: auto;
    min-height: 0;
  }

  .controls,
  .inspector {
    max-height: none;
    overflow: visible;
  }

  .stage {
    grid-row: 1;
    min-height: 620px;
    height: min(76vh, 720px);
  }

  .controls {
    grid-row: 2;
  }

  .inspector {
    grid-row: 3;
  }

  .controls,
  .inspector {
    align-self: stretch;
  }

  .controls h1 {
    max-width: none;
  }

  .scenario-list,
  .steps {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  body {
    font-size: 12px;
  }

  .brandbar {
    min-height: 0;
  }

  .brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .actions {
    overflow-x: auto;
    justify-content: flex-start;
  }

  .actions button,
  .header-actions button {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .workspace {
    padding: 8px;
  }

  .stage {
    min-height: 620px;
    height: 74vh;
  }

  .stage-top,
  .stage-bottom {
    right: 11px;
    left: 11px;
  }

  .stage-top {
    align-items: flex-start;
    flex-direction: column;
  }

  .model-caption {
    max-width: 84%;
    margin-left: 0;
  }

  .stage-bottom {
    align-items: flex-end;
    flex-direction: column;
  }

  .scenario-list,
  .steps {
    grid-template-columns: 1fr;
  }
}

/* V0.2：名称仅随选择出现；图层控制和器械独立观察。 */
.selection-hint {font-size:12px;color:var(--ink-soft);padding:12px 0;border-bottom:1px solid var(--line)}
.selection-panel {margin:14px 0;padding:14px;background:#e6eee8;border:1px solid #b1c5b7;border-radius:10px}
.selection-heading {display:flex;align-items:center;justify-content:space-between;gap:8px}
.selection-heading h3 {margin:0;font-size:17px}
.selection-heading button {border-radius:50%;width:28px;height:28px;background:#fff9;color:#294a40;font-size:20px}
.selection-panel p {font-size:12px;margin:8px 0 0;overflow-wrap:anywhere}
#selectedSource {color:#688077;font-size:10px}
.selected-label {padding:7px 11px!important;border:1px solid #819e8c!important;background:#fbfcf5f2!important;font-size:12px!important;box-shadow:0 3px 14px #163c3314}
.motion-status {font-size:11px;line-height:1.65;color:#73583e;border-left:2px solid #b78b63;padding:6px 10px;margin:10px 0}
.layers {display:flex;flex-wrap:wrap;gap:5px!important;max-width:100%}
.layers label {padding:4px 6px;font-size:10px;white-space:nowrap}
.viewbar {flex-wrap:wrap;justify-content:flex-end;max-width:280px}
.stage-top {pointer-events:none}
.viewbar {pointer-events:auto}
.model-caption {pointer-events:none}
#viewport {touch-action:none}
.tool-focus {position:absolute;left:20px;top:112px;z-index:4;display:flex;gap:6px}
.tool-focus button {padding:7px 11px;border:1px solid var(--line);border-radius:18px;background:#fffaf1d9;color:var(--ink-soft);font-size:11px}
.tool-focus button:hover {background:#d8e7db}
.stage-bottom {flex-wrap:wrap;row-gap:6px}
.stage-bottom .layers {flex-basis:100%}
@media (max-width:560px){.tool-focus{top:155px;left:12px}}

.flow-transport{position:absolute;z-index:4;bottom:115px;left:24px;right:24px;display:flex;gap:12px;align-items:center;flex-wrap:wrap;background:#fffef4ed;padding:12px;border:1px solid #ddd9cc;border-radius:12px}.flow-transport .primary{width:auto;margin:0}.flow-transport label{font-size:12px}.flow-transport select{padding:6px;border:1px solid #ccc;border-radius:6px;background:white}.flow-state{padding:10px 12px;background:#e7efdf;border-radius:8px;font-weight:600}.flow-state[data-status="blocked"]{background:#f9e5df;color:#973f2f}.difficulty-panel,.comparison-panel,.reassess-panel{padding:14px;border-radius:10px;margin:12px 0;background:#f7e8e1;border:1px solid #e8bcae}.comparison-panel{background:#f5f0d9;border-color:#ded3a6}.reassess-panel{background:#e8efe2;border-color:#cbd7bf}.flow-actions{display:flex;gap:6px;flex-wrap:wrap}.flow-actions button{font-size:12px;padding:8px}.model-caption{bottom:185px!important}[hidden]{display:none!important}
