:root {
  color-scheme: dark;
  --ink: #eaf4ef;
  --muted: #8aa097;
  --subtle: #5f756d;
  --panel: #0b1c17;
  --panel-raised: #10251f;
  --panel-soft: #142b24;
  --line: rgba(202, 224, 215, 0.12);
  --acid: #d8ff4f;
  --acid-strong: #c9f530;
  --orange: #ff7a1a;
  --danger: #ff716c;
  --warning: #ffc85a;
  --good: #69e39c;
  --shadow: 0 26px 70px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

/* Das HTML-hidden-Attribut muss immer Vorrang vor Komponenten-Layouts haben. */
[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: #06120f;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  overflow-x: clip;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 8%, rgba(44, 103, 81, 0.17), transparent 28rem),
    #071713;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input[type="range"] {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
canvas:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(216, 255, 79, 0.5);
  outline-offset: 2px;
}

.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
}

.topbar {
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 23, 19, 0.88);
  backdrop-filter: blur(18px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 39px;
  height: 39px;
  border: 1px solid rgba(216, 255, 79, 0.35);
  border-radius: 12px;
  background: linear-gradient(145deg, rgba(216, 255, 79, 0.12), rgba(216, 255, 79, 0.02));
  overflow: hidden;
}

.brand-mark::before {
  content: "";
  position: absolute;
  width: 31px;
  height: 11px;
  border-top: 2px solid var(--acid);
  border-radius: 50%;
  transform: rotate(-24deg) translate(-1px, 4px);
}

.brand-mark span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--orange);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), 0 0 18px rgba(255, 122, 26, 0.8);
  transform: translate(8px, -5px);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 17px;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 750;
  letter-spacing: 0.22em;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--subtle);
  box-shadow: 0 0 0 4px rgba(95, 117, 109, 0.12);
}

.status-dot.is-ready {
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(105, 227, 156, 0.13), 0 0 14px rgba(105, 227, 156, 0.55);
}

.status-dot.is-live {
  background: var(--orange);
  box-shadow: 0 0 0 4px rgba(255, 122, 26, 0.14), 0 0 14px rgba(255, 122, 26, 0.6);
  animation: pulse 1.8s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.5; }
}

.workspace {
  display: grid;
  grid-template-columns: 356px minmax(0, 1fr);
  max-width: 1550px;
  min-height: calc(100vh - 76px);
  min-height: calc(100dvh - 76px);
  margin: 0 auto;
}

.setup-panel {
  padding: 36px 28px 42px 34px;
  border-right: 1px solid var(--line);
  background: rgba(7, 23, 19, 0.48);
}

.panel-heading,
.dialog-header,
.stage-toolbar,
.step-title-row,
.live-title-row,
.setting-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 9px;
  color: var(--acid);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.19em;
}

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

.panel-heading h1 {
  margin-bottom: 0;
  font-size: clamp(25px, 2vw, 31px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
  font-size: 15px;
  font-weight: 700;
}

.icon-button:hover {
  color: var(--ink);
  border-color: rgba(216, 255, 79, 0.25);
  background: rgba(216, 255, 79, 0.07);
}

.steps {
  margin: 31px 0 0;
  padding: 0;
  list-style: none;
}

.step {
  position: relative;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  gap: 13px;
  padding-bottom: 27px;
}

.step:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 34px;
  bottom: 3px;
  left: 16px;
  width: 1px;
  background: var(--line);
}

.step-number {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--subtle);
  background: #0a1b16;
  font-size: 11px;
  font-weight: 800;
}

.step.is-active .step-number {
  border-color: var(--acid);
  color: #142000;
  background: var(--acid);
  box-shadow: 0 0 0 5px rgba(216, 255, 79, 0.07);
}

.step.is-complete .step-number {
  border-color: rgba(105, 227, 156, 0.35);
  color: var(--good);
  background: rgba(105, 227, 156, 0.1);
}

.step.is-complete .step-number {
  font-size: 0;
}

.step.is-complete .step-number::after {
  content: "✓";
  font-size: 13px;
}

.step-content {
  min-width: 0;
  padding-top: 5px;
}

.step-title-row h2 {
  margin: 0;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.step-state {
  color: var(--subtle);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.step.is-active .step-state {
  color: var(--acid);
}

.step.is-complete .step-state {
  color: var(--good);
}

.step-content > p {
  margin: 7px 0 15px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.55;
}

#webcamSourcePanel > p,
#videoSourcePanel > p {
  margin: 10px 0 13px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.source-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.12);
}

.source-option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 31px;
  padding: 0 8px;
  border: 0;
  border-radius: 6px;
  color: var(--subtle);
  background: transparent;
  font-size: 8px;
  font-weight: 780;
}

.source-option svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.source-option.is-selected {
  color: var(--ink);
  background: rgba(216, 255, 79, 0.1);
  box-shadow: inset 0 0 0 1px rgba(216, 255, 79, 0.15);
}

.video-file-card {
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 9px;
  border: 1px solid rgba(79, 215, 255, 0.16);
  border-radius: 8px;
  background: rgba(79, 215, 255, 0.04);
}

.video-file-card:not([hidden]) {
  display: flex;
}

.video-file-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  border-radius: 7px;
  color: #08222b;
  background: #4fd7ff;
  font-size: 8px;
}

.video-file-card > span:last-child {
  min-width: 0;
}

.video-file-card strong,
.video-file-card small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.video-file-card strong {
  max-width: 205px;
  color: var(--ink);
  font-size: 8px;
}

.video-file-card small {
  margin-top: 2px;
  color: var(--subtle);
  font-size: 7px;
}

.step.is-locked .step-content {
  opacity: 0.47;
}

.field-label {
  display: block;
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.table-dimensions {
  margin: -3px 0 11px;
  padding: 9px 10px;
  border: 1px solid rgba(216, 255, 79, 0.17);
  border-radius: 8px;
  background: rgba(216, 255, 79, 0.035);
}

.table-dimensions-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.table-dimensions-title strong {
  color: var(--ink);
  font-size: 9px;
}

.table-dimensions-title span {
  color: var(--acid);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.table-dimensions dl {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  margin: 8px 0 0;
}

.table-dimensions dl > div {
  min-width: 0;
  padding: 6px 7px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.025);
}

.table-dimensions dt {
  color: var(--subtle);
  font-size: 7px;
}

.table-dimensions dd {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 11px;
  font-weight: 780;
  font-variant-numeric: tabular-nums;
}

.table-dimensions p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 7px;
  line-height: 1.45;
}

.table-dimensions p strong {
  color: var(--ink);
}

.camera-mode-label {
  margin-top: 10px;
}

.camera-mode-help {
  margin: 6px 1px 0 !important;
  color: var(--subtle) !important;
  font-size: 8px !important;
  line-height: 1.45;
}

.camera-mode-result {
  display: grid;
  gap: 3px;
  margin-top: 9px;
  padding: 9px 10px;
  border: 1px solid rgba(105, 227, 156, 0.2);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(105, 227, 156, 0.06);
  font-size: 8px;
  line-height: 1.45;
}

.camera-mode-result strong {
  color: var(--good);
  font-size: 9px;
}

.camera-mode-result.is-limited {
  border-color: rgba(255, 200, 90, 0.26);
  background: rgba(255, 200, 90, 0.06);
}

.camera-mode-result.is-limited strong {
  color: var(--warning);
}

.select-control,
.text-control {
  width: 100%;
  height: 39px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: #0e221c;
  font-size: 11px;
  font-weight: 600;
}

.select-control {
  appearance: none;
  padding-right: 30px;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 16px, calc(100% - 11px) 16px;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

.inline-fields {
  display: grid;
  grid-template-columns: 1fr 78px;
  gap: 8px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 39px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 780;
  letter-spacing: 0.015em;
  transition: transform 130ms ease, background 130ms ease, border-color 130ms ease, opacity 130ms ease;
}

.button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.button:active:not(:disabled) {
  transform: translateY(0);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.38;
}

.button svg,
.stat-icon svg,
.quality-message svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.button-primary {
  color: #122000;
  background: var(--acid);
  box-shadow: 0 8px 24px rgba(197, 239, 49, 0.11);
}

.button-primary svg,
.button-accent svg {
  fill: currentColor;
  stroke: none;
}

.button-secondary {
  color: var(--ink);
  border-color: rgba(216, 255, 79, 0.26);
  background: rgba(216, 255, 79, 0.07);
}

.button-ghost {
  color: var(--muted);
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.button-accent {
  min-width: 143px;
  color: #142000;
  background: var(--acid);
}

.button-full {
  width: 100%;
  margin-top: 9px;
}

.calibration-result {
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  padding: 8px 10px;
  border: 1px solid rgba(105, 227, 156, 0.16);
  border-radius: 8px;
  background: rgba(105, 227, 156, 0.06);
}

.calibration-result:not([hidden]) {
  display: flex;
}

.check-icon {
  display: grid;
  place-items: center;
  width: 21px;
  height: 21px;
  border-radius: 50%;
  color: #062215;
  background: var(--good);
  font-size: 11px;
  font-weight: 900;
}

.calibration-result strong,
.calibration-result small {
  display: block;
}

.calibration-result strong {
  color: var(--good);
  font-size: 10px;
}

.calibration-result small {
  margin-top: 1px;
  color: var(--muted);
  font-size: 8px;
}

.beta-toggle {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  margin-top: 11px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.018);
  cursor: pointer;
}

.beta-toggle > input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.toggle-track {
  position: relative;
  width: 34px;
  height: 19px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  background: #0a1915;
  transition: background 140ms ease, border-color 140ms ease;
}

.toggle-track i {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--subtle);
  transition: transform 140ms ease, background 140ms ease;
}

.beta-toggle > input:checked + .toggle-track {
  border-color: rgba(79, 215, 255, 0.5);
  background: rgba(79, 215, 255, 0.16);
}

.beta-toggle > input:checked + .toggle-track i {
  background: #4fd7ff;
  transform: translateX(15px);
}

.beta-toggle > input:focus-visible + .toggle-track {
  outline: 3px solid rgba(216, 255, 79, 0.5);
  outline-offset: 2px;
}

.toggle-copy strong,
.toggle-copy small {
  display: block;
}

.toggle-copy strong {
  color: var(--ink);
  font-size: 9px;
}

.toggle-copy strong em {
  margin-left: 4px;
  padding: 2px 4px;
  border-radius: 3px;
  color: #08222b;
  background: #4fd7ff;
  font-size: 6px;
  font-style: normal;
  letter-spacing: 0.08em;
}

.toggle-copy small {
  margin-top: 2px;
  color: var(--subtle);
  font-size: 7px;
}

.depth-calibration {
  margin-top: 8px;
  padding: 11px;
  border: 1px solid rgba(79, 215, 255, 0.17);
  border-radius: 9px;
  background: rgba(79, 215, 255, 0.035);
}

.depth-intro,
.beta-caveat {
  color: var(--muted);
  font-size: 8px;
  line-height: 1.45;
}

.depth-intro {
  margin-bottom: 10px;
}

.button-depth {
  color: #bdefff;
  border-color: rgba(79, 215, 255, 0.3);
  background: rgba(79, 215, 255, 0.075);
}

.depth-result {
  border-color: rgba(79, 215, 255, 0.2);
  background: rgba(79, 215, 255, 0.06);
}

.depth-result .check-icon {
  background: #4fd7ff;
}

.depth-result strong {
  color: #7be2ff;
}

.beta-caveat {
  margin: 9px 0 0;
  color: #6f969d;
}

.color-options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.color-option {
  min-width: 0;
  padding: 8px 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.02);
  font-size: 8px;
  font-weight: 700;
}

.color-option:hover,
.color-option.is-selected {
  color: var(--ink);
  border-color: rgba(216, 255, 79, 0.3);
  background: rgba(216, 255, 79, 0.07);
}

.color-swatch,
.sample-icon {
  display: block;
  width: 15px;
  height: 15px;
  margin: 0 auto 5px;
  border-radius: 50%;
}

.swatch-orange {
  background: var(--orange);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.36);
}

.swatch-white {
  background: #f4f1e9;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.13);
}

.sample-icon {
  display: grid;
  place-items: center;
  border: 1px dashed var(--muted);
  font-size: 12px;
  font-weight: 400;
}

.advanced-settings {
  border-top: 1px solid var(--line);
}

.advanced-settings summary {
  display: flex;
  justify-content: space-between;
  padding: 16px 0;
  color: var(--muted);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  list-style: none;
}

.advanced-settings summary::-webkit-details-marker {
  display: none;
}

.advanced-content {
  display: grid;
  gap: 17px;
  padding: 0 1px 14px;
}

.setting-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 9px;
}

.setting-label output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 3px;
  appearance: none;
  border-radius: 2px;
  background: linear-gradient(to right, var(--acid) var(--range-progress, 50%), rgba(255, 255, 255, 0.12) var(--range-progress, 50%));
}

input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  appearance: none;
  border: 3px solid #0c1e19;
  border-radius: 50%;
  background: var(--acid);
  box-shadow: 0 0 0 1px rgba(216, 255, 79, 0.25);
}

.measurement-panel {
  min-width: 0;
  padding: 36px 38px 34px;
}

.stage-toolbar {
  gap: 20px;
  margin-bottom: 19px;
}

.live-title-row {
  justify-content: flex-start;
  gap: 10px;
}

.live-title-row h2 {
  margin: 0;
  font-size: 23px;
  letter-spacing: -0.035em;
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 7px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--subtle);
  font-size: 7px;
  font-weight: 850;
  letter-spacing: 0.11em;
}

.live-pill span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.live-pill.is-live {
  color: var(--orange);
  border-color: rgba(255, 122, 26, 0.24);
  background: rgba(255, 122, 26, 0.07);
}

.toolbar-actions {
  display: flex;
  gap: 8px;
}

.camera-stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 360px;
  border: 1px solid rgba(203, 226, 216, 0.13);
  border-radius: 13px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.012) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.012) 1px, transparent 1px),
    radial-gradient(circle at center, #142720, #091712 78%);
  background-size: 38px 38px, 38px 38px, auto;
  overflow: hidden;
  box-shadow: var(--shadow);
}

#cameraCanvas {
  display: block;
  width: 100%;
  height: auto;
  max-height: min(66vh, 720px);
  max-height: min(66dvh, 720px);
  object-fit: contain;
  touch-action: pan-y pinch-zoom;
  background: transparent;
}

.camera-stage.is-marking #cameraCanvas {
  touch-action: none;
}

.empty-camera {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  pointer-events: none;
}

.camera-glyph {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--subtle);
  background: rgba(255, 255, 255, 0.025);
}

.camera-glyph svg {
  width: 31px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.empty-camera h3 {
  margin-bottom: 7px;
  font-size: 15px;
}

.empty-camera p {
  margin-bottom: 0;
  color: var(--subtle);
  font-size: 10px;
}

.stage-badges {
  position: absolute;
  top: 14px;
  left: 14px;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.stage-badges:not([hidden]) {
  display: flex;
}

.stage-badge {
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 6px;
  color: rgba(255, 255, 255, 0.76);
  background: rgba(3, 12, 10, 0.66);
  backdrop-filter: blur(8px);
  font-size: 8px;
  font-weight: 750;
  letter-spacing: 0.035em;
}

.quality-badge {
  display: flex;
  align-items: center;
  gap: 5px;
}

.quality-badge i {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--subtle);
}

.quality-badge.is-good i { background: var(--good); }
.quality-badge.is-limited i { background: var(--warning); }
.quality-badge.is-poor i { background: var(--danger); }

.mode-badge.is-beta {
  color: #7be2ff;
  border-color: rgba(79, 215, 255, 0.28);
  background: rgba(8, 35, 43, 0.76);
}

.canvas-instruction {
  position: absolute;
  top: 18px;
  left: 50%;
  min-width: min(92%, 360px);
  padding: 11px 45px 11px 14px;
  border: 1px solid rgba(216, 255, 79, 0.34);
  border-radius: 9px;
  color: var(--ink);
  background: rgba(8, 23, 18, 0.9);
  backdrop-filter: blur(12px);
  transform: translateX(-50%);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.canvas-instruction strong,
.canvas-instruction span {
  display: block;
}

.canvas-instruction strong {
  margin-bottom: 3px;
  color: var(--acid);
  font-size: 10px;
}

.canvas-instruction span {
  color: var(--muted);
  font-size: 9px;
}

.canvas-instruction button {
  position: absolute;
  top: 9px;
  right: 9px;
  padding: 3px;
  border: 0;
  color: var(--muted);
  background: transparent;
  font-size: 8px;
  pointer-events: auto;
}

.speed-hud {
  position: absolute;
  left: 17px;
  bottom: 16px;
  min-width: 132px;
  padding: 11px 14px 10px;
  border-left: 2px solid var(--acid);
  border-radius: 2px 8px 8px 2px;
  background: rgba(3, 12, 9, 0.72);
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.speed-label {
  display: block;
  margin-bottom: -2px;
  color: var(--muted);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

.speed-hud div {
  display: flex;
  align-items: baseline;
  gap: 7px;
}

.speed-hud strong {
  font-size: 34px;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  letter-spacing: -0.06em;
}

.speed-hud div span {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.tracking-status {
  position: absolute;
  right: 16px;
  bottom: 16px;
  align-items: center;
  gap: 7px;
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 7px;
  color: rgba(255, 255, 255, 0.72);
  background: rgba(3, 12, 9, 0.64);
  backdrop-filter: blur(10px);
  font-size: 8px;
  pointer-events: none;
}

.tracking-status:not([hidden]) {
  display: flex;
}

.tracking-status span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
}

.tracking-status.is-tracking span {
  background: var(--good);
  box-shadow: 0 0 10px rgba(105, 227, 156, 0.65);
}

.quality-message {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 11px 0 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 200, 90, 0.15);
  border-radius: 8px;
  color: #a8aaa0;
  background: rgba(255, 200, 90, 0.045);
  font-size: 9px;
  line-height: 1.45;
}

.video-controls {
  display: grid;
  grid-template-columns: 32px 32px auto minmax(90px, 1fr) auto 58px minmax(180px, auto);
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  padding: 8px 10px;
  border: 1px solid rgba(79, 215, 255, 0.14);
  border-radius: 8px;
  background: rgba(79, 215, 255, 0.035);
}

.video-controls[hidden] {
  display: none !important;
}

.video-control-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid rgba(79, 215, 255, 0.2);
  border-radius: 7px;
  color: #91e8ff;
  background: rgba(79, 215, 255, 0.06);
}

.video-control-button svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.video-control-button .video-play-symbol {
  fill: currentColor;
  stroke: none;
}

.video-time {
  color: var(--muted);
  font-size: 8px;
  font-variant-numeric: tabular-nums;
}

.playback-rate {
  height: 28px;
  padding: 0 5px;
  border: 1px solid rgba(79, 215, 255, 0.18);
  border-radius: 6px;
  color: #91e8ff;
  background: #0c211c;
  font-size: 8px;
  font-weight: 700;
}

.video-controls input[type="range"] {
  min-width: 80px;
}

.video-help {
  color: var(--subtle);
  font-size: 7px;
  line-height: 1.35;
  text-align: right;
}

.quality-message svg {
  flex: 0 0 auto;
  width: 14px;
  height: 14px;
  color: var(--warning);
}

.quality-message strong {
  color: #d1c89f;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.stat-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.012));
}

.stat-card.stat-primary {
  border-color: rgba(216, 255, 79, 0.2);
  background: linear-gradient(145deg, rgba(216, 255, 79, 0.085), rgba(216, 255, 79, 0.025));
}

.stat-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.045);
}

.stat-primary .stat-icon {
  color: var(--acid);
  background: rgba(216, 255, 79, 0.09);
}

.stat-card > div:last-child {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  min-width: 0;
}

.stat-card span {
  grid-column: 1 / -1;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 650;
}

.stat-card strong {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: -0.045em;
}

.stat-card small {
  margin-left: 5px;
  color: var(--subtle);
  font-size: 8px;
  font-weight: 700;
}

.measurement-note {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  margin-top: 18px;
  color: var(--subtle);
}

.measurement-note p {
  margin: 0;
  font-size: 8px;
}

.measurement-note strong {
  color: var(--muted);
}

.note-mark {
  padding: 3px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font-size: 7px;
  font-weight: 800;
}

.help-dialog {
  width: min(92vw, 580px);
  padding: 0;
  border: 1px solid rgba(216, 255, 79, 0.17);
  border-radius: 16px;
  color: var(--ink);
  background: #0c201a;
  box-shadow: 0 38px 100px rgba(0, 0, 0, 0.62);
}

.help-dialog::backdrop {
  background: rgba(1, 8, 6, 0.76);
  backdrop-filter: blur(6px);
}

.help-dialog form {
  padding: 26px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: -0.03em;
}

.setup-illustration {
  position: relative;
  height: 140px;
  margin: 23px 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background:
    linear-gradient(transparent 49.7%, rgba(216, 255, 79, 0.08) 50%, transparent 50.3%),
    #0a1915;
  overflow: hidden;
}

.illustration-camera {
  position: absolute;
  top: 55px;
  left: 25px;
  z-index: 2;
  width: 54px;
  padding: 9px 0;
  border: 1px solid rgba(216, 255, 79, 0.3);
  border-radius: 6px;
  color: var(--acid);
  background: #11271f;
  text-align: center;
  font-size: 6px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.view-line {
  position: absolute;
  top: 69px;
  left: 78px;
  width: 270px;
  border-top: 1px dashed rgba(216, 255, 79, 0.35);
}

.illustration-table {
  position: absolute;
  right: 28px;
  bottom: 28px;
  width: 220px;
  height: 10px;
  border-radius: 2px;
  background: #2b6655;
}

.illustration-table::before,
.illustration-table::after {
  content: "";
  position: absolute;
  top: 9px;
  width: 3px;
  height: 27px;
  background: #41675c;
}

.illustration-table::before { left: 18px; }
.illustration-table::after { right: 18px; }

.illustration-table span {
  position: absolute;
  left: 50%;
  bottom: 8px;
  width: 2px;
  height: 29px;
  background: #b9d2c8;
}

.flight-line {
  position: absolute;
  right: 44px;
  top: 34px;
  width: 185px;
  height: 48px;
  border-top: 2px dashed rgba(255, 122, 26, 0.62);
  border-radius: 50%;
  transform: rotate(4deg);
}

.flight-line i {
  position: absolute;
  top: -7px;
  left: 55px;
  width: 12px;
  height: 12px;
  border: 2px solid white;
  border-radius: 50%;
  background: var(--orange);
}

.help-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  margin: 0 0 21px;
  padding: 0;
  list-style: none;
}

.help-list li {
  display: grid;
  grid-template-columns: 25px 1fr;
  gap: 8px;
}

.help-list li > span {
  color: var(--acid);
  font-size: 9px;
  font-weight: 850;
}

.help-list p {
  margin: 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.45;
}

.help-list strong {
  display: block;
  margin-bottom: 3px;
  color: var(--ink);
  font-size: 10px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 100;
  max-width: min(390px, calc(100vw - 48px));
  padding: 12px 15px;
  border: 1px solid rgba(216, 255, 79, 0.22);
  border-radius: 9px;
  color: var(--ink);
  background: #10251f;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.45);
  font-size: 10px;
  line-height: 1.45;
}

.toast.is-error {
  border-color: rgba(255, 113, 108, 0.35);
}

@media (max-width: 1050px) {
  .workspace {
    grid-template-columns: 310px minmax(0, 1fr);
  }

  .setup-panel {
    padding-left: 24px;
    padding-right: 24px;
  }

  .measurement-panel {
    padding: 31px 26px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  .video-controls {
    grid-template-columns: 32px 32px auto minmax(80px, 1fr) auto 58px;
  }

  .video-help {
    display: none;
  }
}

@media (max-width: 780px) {
  .camera-mode-help,
  .camera-mode-result {
    font-size: 11px !important;
  }

  .camera-mode-result strong {
    font-size: 12px;
  }

  .table-dimensions-title strong,
  .table-dimensions dd {
    font-size: 12px;
  }

  .table-dimensions-title span,
  .table-dimensions dt,
  .table-dimensions p {
    font-size: 10px;
  }

  .topbar {
    height: auto;
    min-height: 64px;
    padding: env(safe-area-inset-top) calc(18px + env(safe-area-inset-right)) 0 calc(18px + env(safe-area-inset-left));
  }

  .topbar-status {
    font-size: 10px;
  }

  .workspace {
    display: block;
  }

  .setup-panel {
    padding: 25px 19px 7px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .steps {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
  }

  .step {
    display: block;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
  }

  .step::after,
  .step-number {
    display: none;
  }

  .step-content {
    padding-top: 0;
  }

  .color-options {
    grid-template-columns: 1fr;
  }

  .color-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }

  .color-swatch,
  .sample-icon {
    display: inline-grid;
    margin: 0;
  }

  .advanced-settings {
    margin-top: 12px;
  }

  .measurement-panel {
    padding: 27px calc(18px + env(safe-area-inset-right)) calc(34px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
  }

  .stage-toolbar {
    flex-wrap: wrap;
  }

  .toolbar-actions {
    margin-left: auto;
  }

  .button,
  select,
  input:not([type="range"]) {
    min-height: 44px;
  }

  input:not([type="range"]),
  select {
    font-size: 16px;
  }

  .camera-stage.is-marking .stage-badges {
    display: none;
  }

  .camera-stage.is-marking .canvas-instruction button {
    top: 4px;
    right: 4px;
    min-width: 44px;
    min-height: 44px;
  }

  .video-controls input[type="range"] {
    min-width: 0;
  }
}

@media (max-width: 590px) {
  .topbar-status {
    max-width: 130px;
    text-align: right;
  }

  .steps {
    display: block;
  }

  .step {
    margin-bottom: 9px;
  }

  .color-options {
    grid-template-columns: repeat(3, 1fr);
  }

  .color-option {
    display: block;
  }

  .color-swatch,
  .sample-icon {
    display: grid;
    margin: 0 auto 5px;
  }

  .stage-toolbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: stretch;
    gap: 12px;
  }

  .toolbar-actions {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr);
    width: 100%;
    margin-left: 0;
  }

  .button-ghost {
    width: 44px;
    padding: 0;
    font-size: 0;
  }

  .button-accent {
    width: 100%;
    min-width: 0;
  }

  .camera-stage {
    min-height: 220px;
  }

  .speed-hud {
    left: 10px;
    bottom: 10px;
    min-width: 110px;
  }

  .speed-hud strong {
    font-size: 28px;
  }

  .tracking-status {
    right: 10px;
    bottom: 10px;
  }

  .stage-badges {
    top: 9px;
    left: 9px;
  }

  .quality-badge {
    display: none;
  }

  .stats-grid {
    gap: 7px;
  }

  .stat-card {
    padding: 12px;
  }

  .stat-icon {
    display: none;
  }

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

  .video-controls {
    grid-template-columns: 44px 44px auto minmax(54px, 1fr) auto 56px;
    gap: 6px;
  }
}

@media (max-width: 390px) {
  .brand {
    gap: 9px;
  }

  .brand small {
    letter-spacing: 0.15em;
  }

  .topbar-status {
    max-width: 108px;
    font-size: 9px;
  }

  .video-controls {
    grid-template-columns: 44px 44px auto minmax(40px, 1fr) auto;
  }

  .playback-rate {
    display: none;
  }
}

@media (pointer: coarse) {
  input[type="range"] {
    height: 44px;
    background: linear-gradient(to right, var(--acid) var(--range-progress, 50%), rgba(255, 255, 255, 0.12) var(--range-progress, 50%)) center / 100% 3px no-repeat;
  }

  input[type="range"]::-webkit-slider-thumb {
    width: 22px;
    height: 22px;
  }

  .video-control-button {
    width: 44px;
    height: 44px;
  }
}

@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;
  }
}
