.demo-frame {
  --demo-scene-min: clamp(480px, calc(100svh - 340px), 560px);
  --demo-border: #343a36;
  min-width: 0;
  border: 1px solid #262b28;
  background: var(--black);
  color: var(--white);
  letter-spacing: 0;
}

.demo-frame .demo-topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  column-gap: 24px;
  height: auto;
  min-height: 54px;
  padding: 0 22px;
  border-bottom: 1px solid var(--demo-border);
}

.demo-frame .demo-brand {
  display: block;
  justify-self: start;
  width: 124px;
  max-width: 100%;
  height: auto;
}

.demo-frame .demo-tools {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  min-width: 0;
  gap: 16px;
}

.demo-frame .demo-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  line-height: 1.3;
  color: #e6eae7;
  white-space: nowrap;
}

.demo-frame .demo-label > span {
  width: 6px;
  height: 6px;
  flex: none;
  border-radius: 50%;
  background: var(--accent);
}

.demo-frame .demo-tools .icon-button {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
}

.demo-frame .demo-tools .icon { width: 16px; height: 16px; }
.demo-frame .demo-tools .icon-button:focus-visible { outline-offset: -4px; }

.demo-frame .demo-views {
  display: flex;
  align-items: stretch;
  align-self: stretch;
  justify-content: center;
  gap: 32px;
  min-height: 54px;
  margin: 0;
}

.demo-frame .demo-views button {
  position: relative;
  min-width: 52px;
  min-height: 54px;
  padding: 0 3px;
  font-size: 16px;
  line-height: 1.2;
  color: #a7b0ad;
}

.demo-frame .demo-views button::after {
  position: absolute;
  content: '';
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: transparent;
  transform: none;
  transition: none;
}

.demo-frame .demo-views button[aria-selected=true] { color: #fff; }
.demo-frame .demo-views button[aria-selected=true]::after { background: var(--accent); transform: none; }
.demo-frame .demo-views button:focus-visible { outline-offset: -5px; }

.demo-frame .demo-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 20px;
  height: auto;
  min-height: 34px;
  padding: 8px 22px;
  border-top: 1px solid var(--demo-border);
  color: #a7b0ad;
  font-size: 10px;
  line-height: 1.4;
}

.demo-frame .demo-statusbar > span { min-width: 0; overflow-wrap: break-word; }

.demo-frame .demo-scene-caption {
  position: absolute;
  top: 20px;
  right: 20px;
  left: 20px;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.demo-frame .demo-scene-caption > span {
  display: block;
  max-width: 70%;
  padding: 7px 9px;
  background: #080909dc;
  color: #e6eae7;
  font-size: 10px;
  line-height: 1.35;
}

.demo-frame .demo-scene-caption > span:last-child {
  display: block;
  max-width: 30%;
  text-align: right;
}

.demo-frame .demo-map-controls {
  position: absolute;
  bottom: 20px;
  left: 20px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  border: 1px solid #ffffff40;
  background: #080909e6;
}

.demo-frame .demo-map-controls .icon-button { width: 40px; height: 40px; border-bottom: 1px solid #ffffff20; }
.demo-frame .demo-map-controls .icon-button:last-child { border-bottom: 0; }
.demo-frame .demo-map-controls .icon { width: 17px; height: 17px; }
.demo-frame .demo-map-controls .icon-button:focus-visible { outline-offset: -4px; }
.demo-frame .demo-map-controls[hidden] { display: none; }

.demo-frame .demo-zoom-level {
  position: absolute;
  right: 20px;
  bottom: 20px;
  z-index: 3;
  width: auto;
  min-width: 36px;
  padding: 7px 9px;
  border: 0;
  background: #080909dc;
  color: #e6eae7;
  font-size: 10px;
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  text-align: center;
  text-shadow: none;
  white-space: nowrap;
  pointer-events: none;
}

.demo-frame .demo-zoom-level[hidden] { display: none; }

.demo-frame .demo-inspector {
  min-width: 0;
  padding: 24px;
  border-left: 1px solid #404641;
  overflow-wrap: break-word;
}

.demo-frame .demo-inspector :is(h3, #defense-insight-title) {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 400;
}

.demo-frame .demo-inspector :is(#object-observation, #defense-insight-copy) { font-size: 15px; line-height: 1.5; }

.demo-frame.app-frame .app-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  align-items: stretch;
  height: auto;
  min-height: var(--demo-scene-min);
}

.demo-frame.defense-demo .defense-workspace { grid-template-columns: minmax(0, 1fr) 360px; }
.demo-frame.app-frame .map-stage { height: auto; min-height: var(--demo-scene-min); }
.demo-frame .object-inspector { display: flex; flex-direction: column; }
.demo-frame .object-inspector .inspector-label { font-size: 11px; line-height: 1.4; }
.demo-frame .object-inspector h3 { min-height: 0; margin: 10px 0 0; }
.demo-frame .object-inspector .inspector-rule { margin: 18px 0; }
.demo-frame .object-inspector > p { min-height: 0; margin: 10px 0 20px; }
.demo-frame .object-inspector .detail-image { height: 118px; min-height: 118px; flex: none; }
.demo-frame .object-inspector dl { display: grid; gap: 14px; margin: 20px 0 18px; padding-top: 17px; border-top: 1px solid var(--demo-border); }
.demo-frame .object-inspector dl > div { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: baseline; gap: 18px; }
.demo-frame .object-inspector dt { font-size: 11px; line-height: 1.45; }
.demo-frame .object-inspector dd { max-width: 180px; font-size: 18px; line-height: 1.3; overflow-wrap: anywhere; }
.demo-frame .object-inspector .inspector-foot { display: flex; gap: 8px; font-size: 10px; line-height: 1.4; }

.demo-expanded-dialog {
  width: calc(100% - 48px);
  max-width: 1800px;
  max-height: calc(100svh - 48px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 1px solid #505952;
  background: var(--black);
  color: var(--white);
}

.demo-expanded-dialog::backdrop { background: #000b; backdrop-filter: blur(6px); }
.demo-expanded-dialog .demo-frame { width: 100%; max-width: none; margin: 0; border: 0; }
.demo-expanded-dialog .demo-frame.app-frame .app-workspace { height: auto; min-height: var(--demo-scene-min); }

@media (max-width: 1280px) {
  .demo-frame.app-frame .app-workspace { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .demo-frame.defense-demo .defense-workspace { grid-template-columns: 1fr; }
  .demo-frame.app-frame .map-stage { aspect-ratio: 1.8; height: auto; min-height: 0; max-height: 540px; }
  .demo-frame .demo-inspector { border-left: 0; border-top: 1px solid #404641; }
  .demo-frame .object-inspector { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(220px, 1fr); gap: 15px 36px; align-items: start; }
  .demo-frame .object-inspector .inspector-label:first-child { grid-column: 1; grid-row: 1; }
  .demo-frame .object-inspector h3 { grid-column: 1; grid-row: 2; margin: 0; }
  .demo-frame .object-inspector .inspector-rule { display: none; }
  .demo-frame .object-inspector .inspector-label:nth-of-type(3) { grid-column: 1; grid-row: 3; }
  .demo-frame .object-inspector > p { grid-column: 1; grid-row: 4; margin: 0; }
  .demo-frame .object-inspector .detail-image { grid-column: 2; grid-row: 1/5; align-self: stretch; height: auto; min-height: 150px; }
  .demo-frame .object-inspector dl { grid-column: 1/-1; grid-row: 5; grid-template-columns: repeat(3, minmax(0, 1fr)); margin: 4px 0 0; }
  .demo-frame .object-inspector dl > div { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
  .demo-frame .object-inspector dd { max-width: none; text-align: left; }
  .demo-frame .object-inspector .inspector-foot { grid-column: 1/-1; grid-row: 6; margin-top: 0; padding-top: 0; }
  .demo-expanded-dialog .demo-frame.app-frame .app-workspace { min-height: 0; }
}

@media (max-width: 800px) {
  .demo-frame .demo-topbar { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: 48px 44px; gap: 0 12px; min-height: 92px; padding: 0 14px; }
  .demo-frame .demo-brand { display: block; grid-column: 1; grid-row: 1; width: 110px; }
  .demo-frame .demo-tools { grid-column: 2; grid-row: 1; gap: 8px; }
  .demo-frame .demo-views { grid-column: 1/-1; grid-row: 2; gap: 28px; min-height: 44px; }
  .demo-frame .demo-views button { min-width: 48px; min-height: 44px; font-size: 14px; }
}

@media (max-width: 600px) {
  .demo-frame .demo-label { gap: 6px; font-size: 10px; }
  .demo-frame .demo-label > span { width: 5px; height: 5px; }
  .demo-frame .demo-tools .icon-button { width: 34px; height: 34px; }
  .demo-frame .demo-statusbar { padding: 8px 14px; gap: 6px 14px; min-height: 34px; font-size: 9px; }
  .demo-frame .demo-scene-caption { top: 12px; right: 12px; left: 12px; gap: 9px; }
  .demo-frame .demo-scene-caption > span { padding: 6px 7px; font-size: 9px; }
  .demo-frame .demo-map-controls { bottom: 12px; left: 12px; }
  .demo-frame .demo-map-controls .icon-button { width: 36px; height: 36px; }
  .demo-frame .demo-map-controls .icon { width: 15px; height: 15px; }
  .demo-frame .demo-zoom-level { right: 12px; bottom: 12px; padding: 6px 7px; font-size: 9px; }
  .demo-frame .demo-inspector { padding: 20px; }
  .demo-frame.app-frame .map-stage { aspect-ratio: auto; height: 330px; min-height: 330px; max-height: none; }
  .demo-frame .object-inspector { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .demo-frame .object-inspector > :is(.inspector-label, h3, p, .detail-image, dl, .inspector-foot) { grid-column: 1; grid-row: auto; }
  .demo-frame .object-inspector .inspector-label:nth-of-type(3) { margin-top: 6px; }
  .demo-frame .object-inspector .detail-image { height: 128px; min-height: 128px; }
  .demo-frame .object-inspector dl { grid-template-columns: 1fr; margin-top: 4px; }
  .demo-frame .object-inspector dl > div { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, auto); gap: 14px; }
  .demo-frame .object-inspector dl > div:last-child { display: grid; }
  .demo-frame .object-inspector dd { max-width: 160px; text-align: right; }
  .demo-frame .object-inspector .inspector-foot { display: flex; padding-top: 4px; }
  .demo-expanded-dialog { width: calc(100% - 16px); max-height: calc(100svh - 16px); }
}

@media (max-width: 370px) {
  .demo-frame .demo-topbar { padding-inline: 10px; column-gap: 8px; }
  .demo-frame .demo-brand { width: 102px; }
  .demo-frame .demo-tools { gap: 6px; }
  .demo-frame .demo-label { font-size: 9px; }
  .demo-frame .demo-views { gap: 24px; }
  .demo-frame .demo-inspector { padding: 18px; }
}
