:root {
  color-scheme: dark;
  --bg: #0c1118;
  --panel: #121a24;
  --panel-2: #182330;
  --line: #29384a;
  --text: #eaf1f8;
  --muted: #94a7ba;
  --accent: #62c7ff;
  --accent-2: #b6ff68;
  --danger: #ff6f7d;
  --shadow: 0 14px 35px rgba(0,0,0,.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
button, input, select { font: inherit; }
button { color: var(--text); background: #1d2a38; border: 1px solid #31465c; border-radius: 8px; padding: 7px 10px; cursor: pointer; }
button:hover:not(:disabled) { border-color: var(--accent); background: #213449; }
button:disabled { opacity: .4; cursor: not-allowed; }
select, input[type="number"], input[type="text"], input[type="file"] { width: 100%; color: var(--text); background: #0d151f; border: 1px solid #2c4053; border-radius: 7px; padding: 7px 8px; }
input[type="range"] { width: 100%; }

.topbar { height: 66px; display: flex; align-items: center; justify-content: space-between; padding: 0 16px; background: #0e151e; border-bottom: 1px solid var(--line); box-shadow: var(--shadow); position: relative; z-index: 3; }
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 10px; color: #05101a; background: linear-gradient(135deg, var(--accent), var(--accent-2)); font-weight: 900; font-size: 22px; }
.brand h1 { margin: 0; font-size: 18px; letter-spacing: .01em; }
.brand p { margin: 2px 0 0; color: var(--muted); font-size: 12px; }
.top-actions { display: flex; align-items: center; gap: 7px; }
.compact-field { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.compact-field select { width: 190px; }

.workspace { display: grid; grid-template-columns: 222px minmax(460px, 1fr) 370px; height: calc(100vh - 66px); }
.toolbar, .inspector { background: var(--panel); overflow-y: auto; }
.toolbar { border-right: 1px solid var(--line); padding: 14px; }
.inspector { border-left: 1px solid var(--line); padding: 14px; }
h2 { margin: 0; font-size: 13px; text-transform: uppercase; letter-spacing: .09em; color: #bed0e0; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 10px; }
.tool { min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 21px; background: #151f2b; }
.tool span { font-size: 10px; color: var(--muted); line-height: 1.1; }
.tool.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px rgba(98,199,255,.34); background: #173047; }
.tool.active span { color: #dff5ff; }
.view-settings, .help-card, .physics-note { border-top: 1px solid var(--line); margin-top: 16px; padding-top: 14px; }
.view-settings label { display: block; margin-top: 9px; color: #cbd8e4; font-size: 12px; }
.view-settings label.stacked select { margin-top: 5px; }
.help-card p, .physics-note p { color: var(--muted); font-size: 11px; line-height: 1.45; margin: 8px 0 0; }

.stage-wrap { position: relative; min-width: 0; min-height: 0; background: radial-gradient(circle at 50% 40%, #142130, #081018 70%); }
#benchCanvas { width: 100%; height: 100%; display: block; outline: none; }
.stage-status { position: absolute; bottom: 8px; left: 9px; right: 9px; display: flex; justify-content: space-between; pointer-events: none; color: #a9bbcb; font-size: 11px; background: rgba(7,12,18,.76); border: 1px solid rgba(62,84,105,.55); border-radius: 8px; padding: 6px 9px; backdrop-filter: blur(7px); }

.inspector-head, .detector-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.inspector-head h2, .detector-head h2 { text-transform: none; letter-spacing: .02em; font-size: 15px; color: var(--text); }
.inspector-head p, .detector-head p { margin: 3px 0 0; font-size: 11px; color: var(--muted); }
.inspector-actions { display: flex; gap: 5px; }
.inspector-actions button { padding: 5px 8px; }
.property-panel { margin-top: 14px; }
.property-panel.empty-state { min-height: 110px; display: grid; place-items: center; text-align: center; border: 1px dashed #314355; border-radius: 10px; padding: 16px; color: var(--muted); font-size: 12px; }
.property-group { border: 1px solid #26384a; border-radius: 10px; padding: 10px; margin-bottom: 9px; background: #101923; }
.property-group h3 { margin: 0 0 9px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #8fa8bd; }
.property-row { display: grid; grid-template-columns: minmax(110px, 1fr) 116px; align-items: center; gap: 9px; margin: 8px 0; }
.property-row label { color: #cfdae5; font-size: 11px; }
.property-row .unit-wrap { position: relative; }
.property-row .unit-wrap input { padding-right: 35px; }
.property-row .unit { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); color: #647b90; font-size: 10px; pointer-events: none; }
.property-row.checkbox-row { grid-template-columns: 1fr auto; }
.property-row input[type="checkbox"] { width: 17px; height: 17px; }
.property-help { margin: 6px 0 0; color: #73899d; font-size: 10px; line-height: 1.4; }

.detector-section { border-top: 1px solid var(--line); margin-top: 17px; padding-top: 14px; }
#detectorCanvas { width: 100%; height: 240px; display: block; margin-top: 10px; background: #08111a; border: 1px solid #26394a; border-radius: 9px; }
.detector-tabs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 5px; margin-top: 6px; }
.detector-tab { padding: 5px; font-size: 11px; }
.detector-tab.active { border-color: var(--accent); background: #173047; }

.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; padding: 9px 13px; border-radius: 8px; background: #e7f6ff; color: #07111b; font-size: 12px; box-shadow: var(--shadow); transition: .2s ease; z-index: 10; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 185px minmax(400px, 1fr) 320px; }
  .toolbar { padding: 10px; }
  .inspector { padding: 11px; }
}

.detector-export-actions { display:flex; gap:5px; }
.detector-picker-label { display:block; margin-top:9px; color:#9fb2c4; font-size:10px; text-transform:uppercase; letter-spacing:.07em; }
.detector-picker-label select { margin-top:5px; text-transform:none; letter-spacing:normal; }
.image-upload { border:1px dashed #365066; border-radius:9px; padding:9px; background:#0c151e; }
.image-upload-preview { width:100%; max-height:118px; object-fit:contain; display:block; border-radius:6px; background:#05090d; margin-bottom:8px; }
.image-upload-empty { min-height:64px; display:grid; place-items:center; color:#71879a; font-size:10px; text-align:center; margin-bottom:8px; }
.image-upload-actions { display:flex; gap:6px; }
.image-upload-actions button { flex:1; font-size:10px; padding:6px; }
.image-upload-meta { margin:7px 0 0; color:#7890a4; font-size:9px; line-height:1.35; word-break:break-word; }
.property-row.full-row { display:block; }
.property-row.full-row > label { display:block; margin-bottom:6px; }
