.sd {
  display: grid;
  grid-template-columns: minmax(0, 55fr) minmax(0, 45fr);
  gap: calc(var(--fit, 1) * clamp(.8rem, 2cqw, 1.6rem));
  height: calc(var(--fit, 1) * 48cqh);
  flex-shrink: 0;
  color: var(--text-dim);
}

.sd-view { container-type: size; min-width: 0; display: grid; place-items: center; }
.sd-frame {
  position: relative;
  width: min(100cqw, calc(100cqh * 600 / 280));
  aspect-ratio: 600 / 280;
  container-type: inline-size;
}
.sd-box {
  position: absolute;
  inset: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  background: radial-gradient(120% 90% at 50% 35%, color-mix(in srgb, var(--ai) 9%, var(--surface)) 0%, var(--surface) 55%, var(--bg) 100%);
  box-shadow: 0 18px 40px -24px color-mix(in srgb, var(--bg) 70%, transparent);
}
.sd-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.sd-gridline { fill: none; stroke: var(--line); stroke-width: 1; }
.sd-gridbg { opacity: .45; }
.sd-ground { stroke: var(--line); stroke-width: 2; }
.sd-shadow { fill: var(--text); opacity: .07; }
.sd-finder { fill: none; stroke: var(--text-dim); stroke-width: 2.5; stroke-linecap: round; opacity: 0; }

.sd-fig line, .sd-fig circle { stroke-linecap: round; }
.sd-bone { stroke: var(--text); stroke-width: 6; stroke-dasharray: 1; }
.sd-bat { stroke: var(--light); stroke-width: 6.5; stroke-dasharray: 1; }
.sd-head { fill: var(--surface-2); stroke: var(--text); stroke-width: 4; }
.sd-joint { fill: var(--ai); stroke: var(--surface); stroke-width: 1.5; transform-box: fill-box; transform-origin: center; }
.sd-joint--bat { fill: var(--light); }
.sd-player { filter: drop-shadow(0 0 5px color-mix(in srgb, var(--ai) 45%, transparent)); }
:root[data-theme="light"] .sd-player,
:root[data-theme="light"] .sd-ghost { filter: none; }

.sd-ghost { filter: drop-shadow(0 0 6px color-mix(in srgb, var(--ai) 70%, transparent)); }
.sd-ghost .sd-bone, .sd-ghost .sd-bat { stroke: var(--ai); stroke-width: 5; }
.sd-ghost .sd-bat { stroke-width: 6.5; }
.sd-ghost .sd-head { fill: color-mix(in srgb, var(--ai) 18%, transparent); stroke: var(--ai); stroke-width: 3.5; }
.sd-static .sd-player { opacity: .5; }
.sd-ghost .sd-joint { display: none; }

.sd-leader { fill: none; stroke: var(--light); stroke-width: 1.5; stroke-dasharray: 1; opacity: .9; }
.sd-stroke { fill: none; stroke: var(--light); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; }
.sd-stroke--thin { stroke-width: 1.5; opacity: .8; }
.sd-zone { fill: color-mix(in srgb, var(--light) 8%, transparent); stroke: var(--light); stroke-width: 1.2; stroke-dasharray: 4 4; opacity: .8; }
.sd-dot { fill: var(--light); }
.sd-anchor { fill: var(--surface); stroke: var(--light); stroke-width: 2.5; }
.sd-scan { fill: color-mix(in srgb, var(--ai) 35%, transparent); opacity: 0; }

.sd-chip {
  position: absolute;
  display: flex;
  align-items: center;
  gap: .45em;
  font-size: 2.3cqw;
  font-weight: 600;
  letter-spacing: .04em;
  line-height: 1.2;
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 85%, transparent);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: .2em .7em;
  font-variant-numeric: tabular-nums;
}
.sd-hud { left: 50%; top: 3%; transform: translateX(-50%); opacity: 0; }
.sd-rec-dot { width: .7em; height: .7em; border-radius: 50%; background: var(--seam); }
.sd-upload { left: 28%; width: 44%; bottom: 6%; opacity: 0; }
.sd-upload svg { width: 1.3em; height: 1.3em; fill: none; stroke: var(--ai); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.sd-upload-track { flex: 1; height: .45em; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.sd-upload-bar { display: block; height: 100%; background: var(--ai); transform-origin: 0 50%; }
.sd-pct { min-width: 3.2ch; text-align: right; }
.sd-caption { right: 2%; top: 3%; font-weight: 500; font-size: 2cqw; color: var(--text-dim); border-style: dashed; }

.sd-checks { position: absolute; inset: 0; pointer-events: none; }
.sd-check {
  position: absolute;
  width: 28%;
  display: flex;
  flex-direction: column;
  gap: .15em;
  padding: .45em .65em .5em;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border: 1px solid color-mix(in srgb, var(--light) 55%, var(--line));
  border-radius: 8px;
  box-shadow: 0 8px 18px -12px color-mix(in srgb, var(--bg) 80%, transparent);
}
.sd-check--l { border-left: 3px solid var(--light); }
.sd-check--r { border-right: 3px solid var(--light); text-align: right; }
.sd-check-label {
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  line-height: 1.1;
  color: var(--light);
  font-size: 2.15cqw;
}
.sd-check-finding { color: var(--text); font-size: 2.6cqw; line-height: 1.25; font-weight: 500; }

.sd-side { display: flex; flex-direction: column; gap: calc(var(--fit, 1) * clamp(.5rem, 1.4cqh, .9rem)); min-width: 0; min-height: 0; }

.sd-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: calc(var(--fit, 1) * .4rem); }
.sd-step {
  width: 100%;
  min-height: 44px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  column-gap: .4em;
  row-gap: .3em;
  padding: .4em .55em .45em;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text-dim);
  font-family: var(--font-display);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  font-size: calc(var(--fit, 1) * clamp(.8rem, 1.45cqw, 1.05rem));
  text-align: left;
  transition: background-color .25s ease-out, border-color .25s ease-out, color .25s ease-out, transform .15s ease-out;
}
.sd-step:hover { border-color: var(--ai); color: var(--text); }
.sd-step:active { transform: scale(.97); }
.sd-step-num {
  display: inline-grid;
  place-items: center;
  width: 1.5em;
  height: 1.5em;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  font-size: .85em;
  font-variant-numeric: tabular-nums;
  transition: background-color .25s ease-out, color .25s ease-out;
}
.sd-step-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sd-step-bar { grid-column: 1 / -1; height: 3px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.sd-step-bar > span { display: block; height: 100%; background: var(--ai); transform-origin: 0 50%; transform: scaleX(var(--sd-p, 1)); }
.sd-step[aria-current="step"] { border-color: var(--ai); color: var(--text); background: color-mix(in srgb, var(--ai) 14%, var(--surface)); }
.sd-step[aria-current="step"] .sd-step-num { background: var(--ai); border-color: var(--ai); color: var(--on-accent); }

.sd-improve { display: flex; flex-direction: column; gap: calc(var(--fit, 1) * clamp(.4rem, 1.1cqh, .7rem)); flex: 1; min-height: 0; }
.sd-card {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .8em;
  min-height: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius, 12px);
  padding: calc(var(--fit, 1) * .5rem) calc(var(--fit, 1) * .85rem);
  transition: border-color .3s ease-out;
}
.sd-card-icon {
  flex: none;
  display: grid;
  place-items: center;
  width: calc(var(--fit, 1) * clamp(2rem, 3.4cqw, 2.6rem));
  aspect-ratio: 1;
  border-radius: 10px;
  background: color-mix(in srgb, var(--ai) 14%, var(--surface-2));
  color: var(--ai);
}
.sd-card-icon svg { width: 58%; height: 58%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sd-card-body { display: flex; flex-direction: column; gap: .1em; min-width: 0; }
.sd-card-title { font-family: var(--font-display); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; line-height: 1.1; color: var(--text); font-size: calc(var(--fit, 1) * clamp(.95rem, 1.6cqw, 1.2rem)); }
.sd-card-text { color: var(--text-dim); line-height: 1.3; font-size: calc(var(--fit, 1) * clamp(.8rem, 1.35cqw, 1rem)); }
.sd[data-stage="3"] .sd-card { border-color: color-mix(in srgb, var(--ai) 45%, var(--line)); }

.sd-static[data-stage="0"] .sd-hud,
.sd-static[data-stage="0"] .sd-finder,
.sd-static[data-stage="1"] .sd-upload { opacity: 1; }

@media (max-width: 699.98px) {
  .sd { grid-template-columns: minmax(0, 1fr); height: auto; gap: 1rem; }
  .sd-view { container-type: normal; display: block; }
  .sd-frame { width: 100%; aspect-ratio: auto; display: flex; flex-direction: column; gap: .6rem; }
  .sd-box { position: relative; inset: auto; aspect-ratio: 600 / 280; }
  .sd-chip { font-size: .68rem; }
  .sd-checks { position: static; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: .5rem; pointer-events: auto; }
  .sd-check { position: static; width: auto; text-align: left; }
  .sd-check--r { border-right-width: 1px; border-left: 3px solid var(--light); }
  .sd-check-label { font-size: .75rem; }
  .sd-check-finding { font-size: .9rem; }
  .sd-leader { display: none; }
  .sd-steps { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sd-step { font-size: .95rem; }
  .sd-card { padding: .65rem .85rem; }
  .sd-card-icon { width: 2.4rem; }
  .sd-card-title { font-size: 1rem; }
  .sd-card-text { font-size: .9rem; }
}
