:root {
  color-scheme: dark;
  --bg: #101316;
  --ink: #f5f7f8;
  --muted: #aeb8bd;
  --panel: rgba(18, 22, 25, 0.86);
  --line: rgba(255, 255, 255, 0.13);
  --accent: #49c16d;
  --warn: #ffc633;
  --danger: #ff4c38;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  width: 100vw;
  height: 100vh;
}

.viewport {
  position: relative;
  min-width: 0;
  background: #cfd7d7;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
  grid-row: 2;
  min-height: 0;
}

.title-layer {
  position: relative;
  grid-row: 1;
  padding: 24px 28px 0;
  pointer-events: none;
  text-shadow: 0 2px 8px rgba(255, 255, 255, 0.42);
}

.protection-guide {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px 20px;
  max-width: 880px;
  margin: 14px 0 0;
  color: #40545f;
  font-size: 11px;
  line-height: 1.4;
}
.protection-guide dt { color: #243e4b; font-weight: 700; }
.protection-guide dd { margin: 2px 0 0; }
.protection-guide > div { position: relative; padding-left: 40px; min-height: 34px; }
.protection-guide dt img { position: absolute; top: 2px; left: 0; width: 32px; height: 32px; object-fit: contain; }

.title-layer h1 {
  margin: 0;
  color: #153241;
  font-size: 42px;
  line-height: 1;
  letter-spacing: 0;
}

.title-layer p {
  margin: 7px 0 0;
  color: #40545f;
  font-size: 15px;
  font-weight: 700;
}

.material-labels {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.material-labels span {
  position: absolute;
  left: 0;
  top: 0;
  color: #ff1f1f;
  font-size: 18px;
  font-weight: 900;
  text-align: center;
  letter-spacing: 0;
  white-space: nowrap;
  text-shadow:
    0 1px 0 #ffffff,
    0 3px 8px rgba(0, 0, 0, 0.42);
  transform: translate(-50%, -50%);
  transition: opacity 120ms ease;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 22px;
  border-left: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: -18px 0 35px rgba(0, 0, 0, 0.28);
  z-index: 2;
  overflow-y: auto;
  min-height: 0;
}

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

.panel > * { flex-shrink: 0; }

.panel-header div {
  display: grid;
  gap: 4px;
}

.panel-header strong {
  font-size: 23px;
}

.panel-header span {
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
}

.language-toggle {
  min-width: 48px;
  min-height: 40px;
  border-color: rgba(73, 193, 109, 0.58);
  color: #dff8e6;
  background: rgba(73, 193, 109, 0.14);
  font-size: 13px;
  font-weight: 900;
}

.control-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-block span,
.metrics span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.control-block strong {
  font-size: 24px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--warn);
}

.scale {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  height: 38px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 6px;
}

.scale span {
  display: grid;
  place-items: center;
  color: #111;
  font-size: 12px;
  font-weight: 800;
  border-right: 1px solid rgba(0, 0, 0, 0.22);
}

.scale span.active {
  outline: 3px solid #fff;
  outline-offset: -4px;
}

.floor-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
}

.floor-title {
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  text-transform: uppercase;
}

.floor-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.floor-controls label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.07);
}

.floor-controls span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.floor-controls input {
  width: 48px;
  min-height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 5px;
  color: var(--ink);
  background: rgba(0, 0, 0, 0.24);
  font-weight: 800;
  text-align: center;
}

.protection-controls {
  margin: 0;
  padding: 12px 0 0;
  border: 0;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 9px;
  min-width: 0;
}
.protection-controls legend, .response-table caption {
  font-size: 14px;
  font-weight: 700;
  text-align: left;
  padding: 0 0 10px;
}
.protection-controls label {
  display: grid;
  grid-template-columns: 75px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.protection-controls select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #252b30;
  font: inherit;
  padding: 5px;
}
.protection-controls .strength-control { grid-template-columns: 1fr auto; }
.strength-control input { grid-column: 1 / -1; }
.strength-control output { color: #71d3e0; }
.protection-controls .protection-row { grid-template-columns: 64px minmax(0, 1fr); gap: 5px 10px; }
.protection-row > img { grid-row: span 2; }
.protection-row > span { color: var(--ink); font-weight: 700; }
.protection-row img, .component-key img { width: 64px; height: 54px; object-fit: contain; border-radius: 4px; background: #edf2f2; }
.protection-row select { grid-column: 2; font-size: 12px; }
.component-key { font-size: 12px; color: var(--muted); }
.component-key summary { cursor: pointer; padding: 5px 0; color: var(--ink); }
.component-key > div { display: grid; grid-template-columns: 64px minmax(0, 1fr); gap: 10px; align-items: center; margin-top: 8px; line-height: 1.4; }
.response-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.response-table th, .response-table td {
  text-align: right;
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}
.response-table th { color: var(--muted); font-weight: 400; }
.response-table th:first-child, .response-table td:first-child { text-align: left; }
.title-layer { max-width: 100%; }
.title-layer p { max-width: 470px; line-height: 1.4; }
.title-layer h1 { font-size: 32px; }
@media (max-width: 420px) {
  .panel { padding: 16px; }
  .floor-card { padding: 10px; }
  .floor-controls { grid-template-columns: 1fr; }
  .title-layer { padding: 16px 16px 0; }
  .title-layer h1 { font-size: 26px; }
  .title-layer p { font-size: 12px; }
}

.camera-controls {
  display: grid;
  gap: 10px;
}

.camera-controls label {
  display: grid;
  gap: 6px;
}

.camera-controls span {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.run-controls { display: grid; gap: 8px; }
.run-controls button { min-height: 38px; font-size: 13px; }

button {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

button:first-child {
  color: #07110b;
  border-color: transparent;
  background: var(--accent);
  font-weight: 800;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.metrics div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  padding: 5px 0 8px;
  border-bottom: 1px solid var(--line);
}

.metrics strong {
  text-align: right;
  font-size: 12px;
  white-space: nowrap;
}
.metrics span { font-size: 10px; }

.model-note {
  display: grid;
  gap: 6px;
  margin-top: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
}

.model-note strong {
  color: var(--ink);
  font-size: 13px;
  text-transform: uppercase;
}

.model-note p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

@media (max-width: 860px) {
  html, body {
    overflow: visible;
    height: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto;
    min-height: 100vh;
    height: auto;
  }
  .viewport { height: 740px; }
  .protection-guide { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; }

  .panel {
    border-top: 1px solid var(--line);
    border-left: 0;
    overflow: visible;
  }

  .title-layer h1 {
    font-size: 34px;
  }
}
