*{box-sizing:border-box}
html,body{height:100%}
html{color-scheme:dark}
body{font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Helvetica,Arial,sans-serif;margin:0;background:#0b0b0b;color:#e6e6e6;display:flex;flex-direction:column}
button,.btn-link{display:inline-block;padding:8px 12px;border:1px solid #3a3a3a;border-radius:6px;background:#1e1e1e;color:#e6e6e6;cursor:pointer;font-size:inherit;font-family:inherit;line-height:1.2;text-decoration:none}
button:hover:enabled,.btn-link:hover{background:#252525;border-color:#4a4a4a}
button:active:enabled{background:#2c2c2c}
button:disabled{opacity:.5;cursor:not-allowed}
.grow{flex:1 1 auto}
.row{display:flex;gap:8px;align-items:center}
input[type=text],input[type=password],input[type=number]{width:100%;padding:8px;border:1px solid #3a3a3a;border-radius:6px;font-family:inherit;background:#161616;color:#e6e6e6}
main{position:relative;flex:1 1 auto;min-height:0;display:flex;flex-direction:column}

/* simulation layout */
.sim-layout{flex:1 1 auto;display:flex;min-height:0}
#viewport{flex:1 1 auto;min-height:0;position:relative}
.flight-telemetry{
  --flight-accent:#8fd4ff;
  --flight-accent-soft:rgba(143,212,255,.22);
  --flight-accent-strong:#e9f6ff;
  --flight-accent-chip-bg:rgba(19,46,70,.72);
  --flight-vsi-pos:50%;
  --flight-g-pos:0%;
  --flight-pressure-pos:0%;
  position:absolute;
  top:0;
  left:50%;
  transform:translateX(-50%);
  z-index:11;
  pointer-events:none;
}
.flight-telemetry.trend-ascent{
  --flight-accent:#72f0c5;
  --flight-accent-soft:rgba(114,240,197,.22);
  --flight-accent-strong:#eafff6;
  --flight-accent-chip-bg:rgba(14,52,44,.78);
}
.flight-telemetry.trend-descent{
  --flight-accent:#ffb37c;
  --flight-accent-soft:rgba(255,179,124,.22);
  --flight-accent-strong:#fff1e7;
  --flight-accent-chip-bg:rgba(67,35,20,.78);
}
.flight-telemetry-shell{
  width:min(750px,calc(100vw - 24px));
  position:relative;
  overflow:hidden;
  padding:3px 6px 6px;
  background:
    linear-gradient(180deg,rgba(7,18,30,.97),rgba(3,10,18,.94)),
    repeating-linear-gradient(90deg,rgba(129,165,189,.08) 0,rgba(129,165,189,.08) 1px,transparent 1px,transparent 18px);
  border:1px solid rgba(132,173,198,.55);
  border-top:none;
  border-radius:0 0 18px 18px;
  box-shadow:0 18px 40px rgba(0,0,0,.42),inset 0 1px 0 rgba(217,235,248,.08);
  backdrop-filter:blur(12px);
}
.flight-telemetry-shell::before{
  content:"";
  position:absolute;
  top:0;
  left:18%;
  right:18%;
  height:1px;
  background:linear-gradient(90deg,transparent,rgba(238,248,255,.35),transparent);
}
.flight-telemetry-readout{
  display:grid;
  grid-template-columns:repeat(5,minmax(0,1fr));
  align-items:stretch;
  gap:8px;
}
.flight-telemetry-block{
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  text-align:center;
  gap:4px;
  min-height:78px;
  padding:5px 6px;
  border:1px solid rgba(105,152,184,.22);
  border-radius:14px;
  background:linear-gradient(180deg,rgba(13,30,46,.72),rgba(7,17,28,.86));
  box-shadow:inset 0 1px 0 rgba(217,235,248,.04);
}
.flight-telemetry-block-accent{
  box-shadow:inset 0 1px 0 rgba(217,235,248,.04);
}
.flight-telemetry-label{
  font-size:10px;
  line-height:1;
  letter-spacing:.22em;
  text-transform:uppercase;
  color:#7f97a8;
}
.flight-telemetry-value{
  font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
  font-size:18px;
  line-height:1.05;
  font-weight:700;
  color:#e9f4ff;
  white-space:nowrap;
}
.flight-telemetry-block-accent .flight-telemetry-value{
  color:var(--flight-accent-strong);
}
.flight-telemetry-note{
  font-size:10px;
  line-height:1.15;
  color:#84a9c2;
  letter-spacing:.08em;
  text-transform:uppercase;
}
.flight-telemetry-vsi{
  position:relative;
  width:100%;
  height:18px;
  margin-top:1px;
}
.flight-telemetry-vsi::before{
  content:"";
  position:absolute;
  left:4px;
  right:4px;
  top:50%;
  height:6px;
  transform:translateY(-50%);
  border:1px solid rgba(110,147,171,.22);
  border-radius:999px;
  background:linear-gradient(90deg,rgba(235,136,94,.25),rgba(118,154,182,.34) 50%,rgba(73,211,175,.25));
}
.flight-telemetry-vsi-mark{
  position:absolute;
  top:3px;
  bottom:3px;
  width:1px;
  background:rgba(207,226,239,.45);
}
.flight-telemetry-vsi-mark-left{left:18%}
.flight-telemetry-vsi-mark-center{left:50%}
.flight-telemetry-vsi-mark-right{left:82%}
.flight-telemetry-vsi-needle{
  position:absolute;
  top:1px;
  bottom:1px;
  width:2px;
  left:calc(var(--flight-vsi-pos) - 1px);
  border-radius:999px;
  background:var(--flight-accent);
  transition:left .12s linear,background-color .12s linear,box-shadow .12s linear;
}
.flight-telemetry-gmeter{
  position:relative;
  width:100%;
  height:18px;
  margin-top:1px;
}
.flight-telemetry-gmeter::before{
  content:"";
  position:absolute;
  left:4px;
  right:4px;
  top:50%;
  height:6px;
  transform:translateY(-50%);
  border:1px solid rgba(110,147,171,.22);
  border-radius:999px;
  background:linear-gradient(90deg,rgba(86,170,214,.28),rgba(102,218,162,.28) 38%,rgba(224,198,94,.28) 70%,rgba(232,116,116,.3));
}
.flight-telemetry-gmeter-mark{
  position:absolute;
  top:3px;
  bottom:3px;
  width:1px;
  background:rgba(207,226,239,.45);
}
.flight-telemetry-gmeter-mark-left{left:18%}
.flight-telemetry-gmeter-mark-center{left:50%}
.flight-telemetry-gmeter-mark-right{left:82%}
.flight-telemetry-gmeter-needle{
  position:absolute;
  top:1px;
  bottom:1px;
  width:2px;
  left:calc(var(--flight-g-pos) - 1px);
  border-radius:999px;
  background:#ffe792;
  transition:left .12s linear,background-color .12s linear,box-shadow .12s linear;
}
.flight-telemetry-pressure{
  position:relative;
  width:100%;
  height:18px;
  margin-top:1px;
}
.flight-telemetry-pressure::before{
  content:"";
  position:absolute;
  left:4px;
  right:4px;
  top:50%;
  height:6px;
  transform:translateY(-50%);
  border:1px solid rgba(110,147,171,.22);
  border-radius:999px;
  background:linear-gradient(90deg,rgba(120,140,160,.18),rgba(100,180,220,.30) 50%,rgba(80,200,240,.38));
}
.flight-telemetry-pressure-mark{
  position:absolute;
  top:3px;
  bottom:3px;
  width:1px;
  background:rgba(207,226,239,.45);
}
.flight-telemetry-pressure-mark-left{left:18%}
.flight-telemetry-pressure-mark-center{left:50%}
.flight-telemetry-pressure-mark-right{left:82%}
.flight-telemetry-pressure-needle{
  position:absolute;
  top:1px;
  bottom:1px;
  width:2px;
  left:calc(var(--flight-pressure-pos) - 1px);
  border-radius:999px;
  background:#8fd4ff;
  transition:left .12s linear,background-color .12s linear,box-shadow .12s linear;
}
.sim-controls{position:absolute;top:12px;right:12px;display:flex;gap:6px;z-index:15}
.sim-controls button{width:34px;height:34px;padding:0;border-color:#2d6a93;background:rgba(12,43,68,.86);color:#bce7ff;display:inline-flex;align-items:center;justify-content:center}
.sim-controls button:hover:enabled{border-color:#5da9da;background:rgba(25,71,105,.92)}
.sim-controls button.active{border-color:#87cbff;background:rgba(33,82,120,.95);color:#e6f8ff}
.sim-action-icon{width:18px;height:18px;flex-shrink:0;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.spawn-craft-controls{position:absolute;bottom:12px;left:50%;transform:translateX(-50%);z-index:10;display:flex;gap:8px}
.sim-text-btn{height:34px;padding:0 12px;border-color:#2d6a93;background:rgba(12,43,68,.86);color:#bce7ff;font-size:13px}
.sim-text-btn:hover:enabled{border-color:#5da9da;background:rgba(25,71,105,.92)}
.control-craft-btn{position:absolute;bottom:12px;right:12px;z-index:10}
.control-help{position:absolute;top:12px;left:12px;z-index:10;font-size:12px;background:rgba(0,0,0,.7);color:#fff;padding:6px 8px;border-radius:4px;border:1px solid #444;pointer-events:none}
.navball-container{
  position:absolute;
  bottom:16px;
  left:50%;
  transform:translateX(-50%);
  z-index:11;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
  pointer-events:none;
}
.navball-frame{
  width:180px;
  height:180px;
  border-radius:50%;
  overflow:hidden;
  position:relative;
  border:2px solid rgba(132,173,198,.55);
  box-shadow:0 6px 20px rgba(0,0,0,.5),inset 0 0 16px rgba(0,0,0,.25);
}
.navball-frame::after{
  content:"";
  position:absolute;
  inset:0;
  border-radius:50%;
  background:radial-gradient(circle,transparent 50%,rgba(0,0,0,.25) 72%,rgba(0,0,0,.55) 100%);
  pointer-events:none;
}
.navball-canvas{position:absolute;top:0;left:0;width:100%;height:100%;display:block}
.navball-reticle{position:absolute;inset:0;pointer-events:none;z-index:1}
.navball-toggle{
  pointer-events:auto;
  padding:3px 14px;
  font-size:10px;
  letter-spacing:.12em;
  text-transform:uppercase;
}
.sim-layout.editor-mode #viewport{background:radial-gradient(circle at 30% 20%,rgba(38,99,163,.28),rgba(3,12,25,.95) 55%,rgba(2,7,15,1));}
.sim-layout.editor-mode .world-debug-only{display:none !important;}
.sim-layout.editor-mode .world-setting-row{display:none}
.sim-layout.editor-mode .sim-controls{display:none}
.sim-layout:not(.editor-mode) .editor-setting-row{display:none}

label{font-size:12px;color:#aaa}
.home-controls{flex:1 1 auto;display:flex;align-items:center;justify-content:center}
.home-controls-inner{max-width:400px;width:100%;padding:24px;border-radius:12px;background:#111;border:1px solid #2a2a2a;display:flex;flex-direction:column;gap:16px}
.field{display:flex;flex-direction:column;gap:4px}
.home-buttons{display:flex;gap:12px;align-items:center;justify-content:center}
.auth-container{flex:1 1 auto;display:flex;flex-direction:column;align-items:center;justify-content:center;padding:24px}
.auth-form{width:100%;max-width:320px;display:flex;flex-direction:column;gap:12px}
.auth-actions{margin-top:16px;display:flex;flex-direction:column;gap:8px;align-items:center}
.auth-actions form{margin:0}
.auth-actions a{color:#8ab4ff;text-decoration:none}
.auth-actions a:hover{text-decoration:underline}
h1{margin:0 0 16px;font-size:20px;font-weight:600;text-align:center}

/* debug sidebar and frame chart UI */
#charts-stack{flex:0 0 360px;display:none;flex-direction:column;align-items:stretch;gap:8px;padding:12px;padding-left:16px;border-left:1px solid #2a2a2a;background:#050505;overflow-y:auto;height:100%;position:relative}
.sim-layout.debug-open #charts-stack{display:flex}
#debug-resize-handle{position:absolute;left:0;top:0;bottom:0;width:6px;cursor:ew-resize;background:transparent;z-index:10}
#debug-resize-handle:hover,#debug-resize-handle.dragging{background:rgba(138,180,255,.3)}

/* Chart panels container in debug sidebar */
.chart-panels-container{display:flex;flex-wrap:wrap;gap:8px;flex:1 1 auto;min-height:0;overflow-y:auto;align-content:start}
.chart-panels-container .chart-card{width:160px;height:180px;min-width:140px;min-height:150px;resize:both}
.chart-buttons-row{display:flex;gap:8px;margin-top:8px;align-items:center}
.chart-buttons-row .add-chart-btn,.chart-buttons-row .reset-layout-btn{flex:1 1 0}
.chart-buttons-row .auto-reset-label{display:flex;align-items:center;gap:4px;font-size:11px;color:#aaa;cursor:pointer;white-space:nowrap}
.chart-buttons-row .auto-reset-label input{margin:0;cursor:pointer}
.debug-camera-value{font-size:12px;color:#e6e6e6;font-family:monospace;line-height:1.2}

/* toggle grid for binary options */
.toggle-grid{display:grid;grid-template-columns:1fr 1fr;gap:4px 12px}
.toggle-item{display:flex;align-items:center;gap:4px;font-size:11px;color:#aaa;cursor:pointer}
.toggle-item input[type=checkbox]{margin:0;width:14px;height:14px;cursor:pointer}
.toggle-item span{white-space:nowrap}

/* settings panel */
.settings-panel{position:absolute;top:52px;right:12px;z-index:20;background:#111;border:1px solid #2a2a2a;border-radius:8px;padding:16px;min-width:240px;box-shadow:0 4px 16px rgba(0,0,0,.5)}
.settings-header{display:flex;justify-content:space-between;align-items:center;margin-bottom:12px;font-size:14px;font-weight:600;color:#e6e6e6}
.settings-close-btn{padding:2px 8px;font-size:16px;background:transparent;border:none;color:#888;cursor:pointer}
.settings-close-btn:hover{color:#e6e6e6}
.settings-body{display:flex;flex-direction:column;gap:12px}
.settings-row{display:flex;flex-direction:column;gap:6px}
.settings-slider-row{display:flex;align-items:center;gap:8px}
.settings-slider-row input[type=range]{flex:1;accent-color:#8ab4ff}
.settings-slider-value{min-width:36px;text-align:right;font-family:monospace;font-size:12px;color:#e6e6e6}

.editor-overlay{
  --editor-gap: 10px;
  --editor-left-width: 250px;
  --editor-right-width: 370px;
  --editor-top-height: 54px;
  --editor-icon-size: 16px;
  --editor-button-size: 34px;
  position:absolute;
  inset:0;
  z-index:16;
  pointer-events:none;
  font-family:"Trebuchet MS","Segoe UI",sans-serif;
}
.editor-workspace-hitbox{
  position:absolute;
  left:calc(var(--editor-left-width) + var(--editor-gap));
  right:calc(var(--editor-right-width) + var(--editor-gap));
  top:calc(var(--editor-top-height) + var(--editor-gap));
  bottom:var(--editor-gap);
  pointer-events:none;
}
.editor-left-panel{
  position:absolute;
  top:0;
  bottom:0;
  left:0;
  width:var(--editor-left-width);
  border-right:1px solid #1f4f70;
  background:
    linear-gradient(180deg,rgba(5,26,44,.96),rgba(3,16,30,.96)),
    repeating-linear-gradient(0deg,rgba(74,132,173,.07) 0,rgba(74,132,173,.07) 1px,transparent 1px,transparent 20px);
  display:flex;
  pointer-events:auto;
}
.editor-category-list{
  width:40px;
  border-right:1px solid #1d4a68;
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:8px;
  padding:10px 4px;
}
.editor-category-btn{
  width:var(--editor-button-size);
  height:var(--editor-button-size);
  border-radius:4px;
  border:1px solid #2f6f99;
  background:rgba(11,40,66,.85);
  color:#9ad9ff;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0;
}
.editor-category-icon{
  width:var(--editor-icon-size);
  height:var(--editor-icon-size);
  display:block;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.editor-category-btn.active{
  border-color:#87cbff;
  background:rgba(33,82,120,.95);
  color:#e6f8ff;
}
.editor-part-list-shell{
  flex:1 1 auto;
  min-width:0;
  min-height:0;
  display:flex;
  flex-direction:column;
  gap:8px;
  padding:10px 8px 10px 10px;
}
.editor-panel-title{
  font-size:11px;
  letter-spacing:.08em;
  text-transform:uppercase;
  color:#92c9ef;
}
.editor-parts-list{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  display:flex;
  flex-direction:column;
  gap:5px;
  padding-right:2px;
}
.editor-template-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:8px;
  text-align:left;
  border:1px solid #265a80;
  border-radius:5px;
  background:linear-gradient(180deg,rgba(16,54,84,.82),rgba(9,35,57,.9));
  color:#d8f1ff;
  padding:6px 8px;
  font-size:12px;
}
.editor-template-row:hover{border-color:#4e95c7;background:linear-gradient(180deg,rgba(22,70,106,.85),rgba(11,44,72,.95))}
.editor-template-stat{color:#98c8e8;font-size:10px;font-family:monospace}
.editor-template-row.dragging{border-color:#8ee2ff;background:linear-gradient(180deg,rgba(45,112,155,.95),rgba(18,62,92,.95))}
.editor-left-resize-handle{
  position:absolute;
  top:0;
  bottom:0;
  width:8px;
  left:calc(var(--editor-left-width) - 4px);
  cursor:ew-resize;
  pointer-events:auto;
  z-index:2;
}
.editor-left-resize-handle:hover,.editor-left-resize-handle.dragging{background:rgba(106,191,235,.34)}
.editor-right-resize-handle{
  position:absolute;
  top:0;
  bottom:0;
  width:8px;
  right:calc(var(--editor-right-width) - 4px);
  cursor:ew-resize;
  pointer-events:auto;
  z-index:2;
}
.editor-right-resize-handle:hover,.editor-right-resize-handle.dragging{background:rgba(106,191,235,.34)}
.editor-top-bar{
  position:absolute;
  left:calc(var(--editor-left-width) + var(--editor-gap));
  right:calc(var(--editor-right-width) + var(--editor-gap));
  top:var(--editor-gap);
  height:var(--editor-top-height);
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border:1px solid #2a6992;
  border-radius:7px;
  background:
    linear-gradient(180deg,rgba(11,39,63,.92),rgba(6,25,43,.96)),
    repeating-linear-gradient(90deg,rgba(97,175,224,.08) 0,rgba(97,175,224,.08) 1px,transparent 1px,transparent 16px);
  pointer-events:auto;
}
.editor-craft-name-display{
  flex:1 1 auto;
  min-width:0;
  text-align:left;
  border-color:#2f6f99;
  background:rgba(13,44,70,.86);
  color:#d8f2ff;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.editor-craft-name-display:hover{border-color:#5da8d8}
.editor-craft-name-input{
  flex:1 1 auto;
  min-width:0;
  border-color:#54a5d7 !important;
}
.editor-top-actions{display:flex;gap:6px}
.editor-icon-btn{
  width:var(--editor-button-size);
  height:var(--editor-button-size);
  padding:0;
  border-color:#2d6a93;
  background:rgba(12,43,68,.86);
  color:#bce7ff;
  font-weight:700;
}
.editor-icon-svg{
  width:var(--editor-icon-size);
  height:var(--editor-icon-size);
  display:block;
  margin:auto;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.editor-icon-btn:hover:enabled{border-color:#5da9da;background:rgba(25,71,105,.92)}
.editor-mode-bar{
  position:absolute;
  left:calc(var(--editor-left-width) + var(--editor-gap));
  top:calc(var(--editor-top-height) + var(--editor-gap) + var(--editor-gap));
  display:flex;
  gap:4px;
  pointer-events:auto;
  z-index:1;
}
.editor-mode-btn{
  width:var(--editor-button-size);
  height:var(--editor-button-size);
  padding:0;
  border-color:#2d6a93;
  background:rgba(12,43,68,.86);
  color:#8cc3e8;
}
.editor-mode-btn:hover:enabled{border-color:#5da9da;background:rgba(25,71,105,.92);color:#bce7ff}
.editor-mode-btn.active{border-color:#87cbff;background:rgba(33,82,120,.95);color:#e6f8ff}
.editor-mode-icon{
  width:var(--editor-icon-size);
  height:var(--editor-icon-size);
  display:block;
  margin:auto;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.editor-info-bar{
  position:absolute;
  top:0;
  bottom:0;
  right:0;
  width:var(--editor-right-width);
  border-left:1px solid #1f4f70;
  background:
    linear-gradient(180deg,rgba(5,26,44,.98),rgba(3,16,30,.97)),
    repeating-linear-gradient(0deg,rgba(74,132,173,.06) 0,rgba(74,132,173,.06) 1px,transparent 1px,transparent 20px);
  display:flex;
  flex-direction:column;
  pointer-events:auto;
}
.editor-info-actions{
  display:flex;
  gap:6px;
  padding:10px;
  border-bottom:1px solid #1f4f70;
  width:100%;
}
.editor-info-actions button{
  flex:1 1 0;
  width:0;
  border-color:#2f6e98;
  background:rgba(13,43,68,.86);
  color:#caeeff;
  height:var(--editor-button-size);
  padding:0;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}
.editor-action-icon{
  width:var(--editor-icon-size);
  height:var(--editor-icon-size);
  flex-shrink:0;
  fill:none;
  stroke:currentColor;
  stroke-width:1.8;
  stroke-linecap:round;
  stroke-linejoin:round;
}
.editor-info-actions button:hover:enabled{
  border-color:#66b3de;
  background:rgba(24,68,101,.92);
}
.editor-info-actions button.active{
  border-color:#87cbff;
  background:rgba(33,82,120,.95);
  color:#e6f8ff;
}
.editor-info-meta{
  display:flex;
  flex-direction:column;
  gap:6px;
  padding:10px;
  border-bottom:1px solid #1f4f70;
}
.editor-info-meta-row{
  display:grid;
  grid-template-columns:58px 1fr;
  gap:8px;
  align-items:start;
  font-size:12px;
  color:#d2ecff;
}
.editor-tag{font-size:10px;text-transform:uppercase;letter-spacing:.08em;color:#81b8dd}
.editor-info-content{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  padding:10px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.editor-info-section{
  border:1px solid #25597f;
  background:rgba(10,37,60,.72);
  border-radius:6px;
  padding:8px;
  display:flex;
  flex-direction:column;
  gap:8px;
}
.editor-info-section-title{
  font-size:10px;
  text-transform:uppercase;
  letter-spacing:.08em;
  color:#90c6eb;
}
.editor-info-grid{
  display:grid;
  grid-template-columns:88px 1fr;
  gap:6px 8px;
  align-items:center;
  font-size:12px;
}
.editor-info-grid .value{font-family:monospace;color:#cce9ff}
.editor-info-grid label{font-size:11px;color:#90c0df}
.editor-info-grid input[type=text],.editor-info-grid input[type=number]{height:32px;padding:6px}
.editor-info-grid input[type=range]{width:100%}
.editor-info-grid select{width:100%;padding:5px 6px;border:1px solid #3a78b7;border-radius:4px;background:#071d34;color:#d9f0ff;font-family:inherit;font-size:11px}
.editor-info-note{font-size:11px;color:#9bc4e1}
.editor-template-drag-label{
  position:absolute;
  z-index:24;
  transform:translate(12px,12px);
  padding:6px 8px;
  border:1px solid #5ab0df;
  border-radius:5px;
  background:rgba(13,48,74,.95);
  color:#d8f4ff;
  font-size:11px;
  pointer-events:none;
}

.editor-craft-dialog{position:absolute;inset:0;z-index:18;display:flex;align-items:center;justify-content:center;background:rgba(2,8,15,.72);pointer-events:auto}
.editor-craft-dialog-card{width:min(560px,calc(100% - 28px));max-height:calc(100% - 28px);overflow:hidden;display:flex;flex-direction:column;gap:10px;padding:14px;background:rgba(7,20,37,.96);border:1px solid #3f75a3;border-radius:10px}
.editor-craft-dialog-header{font-size:14px;font-weight:600;color:#d7edff}
.editor-craft-dialog-list{display:flex;flex-direction:column;gap:8px;overflow-y:auto;max-height:320px}
.editor-craft-row{display:flex;align-items:center;gap:8px;padding:8px;border:1px solid #2f5f87;border-radius:6px;background:rgba(16,43,70,.7)}
.editor-craft-row-name{flex:1 1 auto;min-width:0;font-size:12px;color:#d3ebff;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.editor-craft-row-btns{display:flex;gap:4px;flex-shrink:0}
.editor-craft-row-btn{padding:6px 10px}
.editor-craft-row-btn-secondary{border-color:#2f5f87;background:rgba(16,43,70,.7);color:#89adce}
.editor-craft-row-btn-secondary:hover:enabled{border-color:#4a8ab8;background:rgba(25,60,95,.8);color:#b8dcf5}
.editor-craft-row-btn-danger{border-color:#873030;background:rgba(70,20,20,.7);color:#f0a0a0}
.editor-craft-row-btn-danger:hover:enabled{border-color:#b84a4a;background:rgba(95,30,30,.8);color:#ffc8c8}
.editor-craft-row-name-input{flex:1 1 auto;min-width:0;padding:4px 6px;font-size:12px;border:1px solid #54a5d7;border-radius:4px;background:rgba(8,28,48,.9);color:#d3ebff;font-family:inherit}
.editor-craft-empty{font-size:12px;color:#89adce;padding:8px 4px}
.editor-craft-dialog-actions{display:flex;justify-content:flex-end;gap:8px}

@media (max-width: 1150px){
  .editor-overlay{
    --editor-left-width:250px;
    --editor-right-width:320px;
  }
}
@media (max-width: 900px){
  .editor-overlay{
    --editor-left-width:220px;
    --editor-right-width:300px;
  }
  .editor-info-grid{grid-template-columns:74px 1fr}
}
@media (max-width: 760px){
  .editor-overlay{
    --editor-left-width:220px;
    --editor-right-width:260px;
  }
  .editor-info-actions{grid-template-columns:1fr}
}
@media (max-width: 760px){
  .flight-telemetry-shell{
    width:min(620px,calc(100vw - 18px));
    padding:3px 4px 4px;
  }
  .flight-telemetry-readout{
    grid-template-columns:repeat(2,minmax(0,1fr));
    gap:10px;
  }
  .flight-telemetry-block{
    min-height:74px;
  }
}
@media (max-width: 480px){
  .flight-telemetry{
    top:0;
  }
  .flight-telemetry-shell{
    width:min(360px,calc(100vw - 12px));
    padding:2px 3px 3px;
  }
  .flight-telemetry-readout{
    grid-template-columns:1fr;
  }
  .flight-telemetry-value{
    font-size:17px;
  }
}

.hidden{display:none}
#viewport canvas{width:100%;height:100%;display:block}

/* terrain stats */
.terrain-stats{background:rgba(0,0,0,.7);border-radius:5px;font-size:11px}
.terrain-stats-header{font-weight:600;margin-bottom:8px;color:#aaa}
.terrain-stats-grid{display:grid;grid-template-columns:auto 1fr;gap:4px 8px}
.terrain-stats-grid span:nth-child(odd){color:#888}
.terrain-stats-grid span:nth-child(even){color:#e6e6e6;font-family:monospace}
.mini-chart-container{height:40px;margin-top:6px}
.mini-chart-canvas{display:block;width:100%;height:100%}

/* Metric popover (tree-in-dropdown for debug panel) */
.metric-popover-wrapper{position:relative;display:inline-block}
.metric-popover-trigger{padding:4px 8px;font-size:10px;max-width:150px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.metric-popover-panel{position:absolute;top:100%;left:0;z-index:100;margin-top:4px;background:#1a1a1a;border:1px solid #3a3a3a;border-radius:6px;box-shadow:0 4px 12px rgba(0,0,0,.5);min-width:200px;max-width:300px;max-height:300px;overflow-y:auto}
.metric-popover-tree{padding:8px}

/*
 * Metric selector styles
 * The MetricSelector is a standalone UI component for selecting metrics.
 * It outputs a metric name to an abstract consumer - it knows nothing about
 * what consumes the selection (could be a chart, export, etc).
 */
.metric-tree-selector{font-size:11px}
.tree-empty{color:#666;text-align:center;padding:8px}
.tree-list{list-style:none;margin:0;padding:0 0 0 12px}
.metric-tree-selector>.tree-list{padding-left:0}
.tree-item{margin:2px 0}
.tree-toggle{display:inline-block;width:14px;cursor:pointer;color:#888;font-size:9px;user-select:none}
.tree-toggle:hover{color:#fff}
.tree-branch-label{color:#aaa;font-weight:500}
.tree-leaf{background:transparent;border:1px solid transparent;border-radius:4px;padding:2px 6px;color:#8ab4ff;cursor:pointer;font-size:11px;text-align:left;width:auto}
.tree-leaf:hover{background:#1a1a2e;border-color:#3a3a5a}
.tree-leaf.selected{background:#1a2a3a;border-color:#3a5a7a;color:#fff}

/*
 * ChartWidget - a generic, abstract data visualization component.
 * ALL graphs are IDENTICAL and completely abstract data sinks.
 * Any graph can receive data from ANY source - the graph has no knowledge
 * of where its data originates. Data producers (selectors, APIs, etc.)
 * know nothing about the graph - they just output data to an abstract consumer.
 */
.chart-widget{
  --cw-ylabels-width: 32px;
  --cw-xlabels-height: 14px;
  display: grid;
  grid-template-rows: auto 1fr;
  font-size: 11px;
  height: 100%;
}
.cw-legend{display:flex;gap:12px;align-items:center;flex-wrap:wrap;justify-content:center;padding:4px 0}
.cw-legend-item{display:inline-flex;gap:4px;align-items:center;font-size:10px}
.cw-legend-color{width:12px;height:3px;display:inline-block}
.cw-legend-value{color:#fff}
.cw-chart-area{
  display: grid;
  grid-template-columns: var(--cw-ylabels-width) 1fr;
  grid-template-rows: 1fr var(--cw-xlabels-height);
  min-height: 0;
}
.cw-ylabels{
  grid-row: 1;
  grid-column: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 9px;
  color: #888;
  padding-right: 4px;
  text-align: right;
}
.cw-ylabels .y-tick{line-height: 1}
.cw-canvas-wrap{
  grid-row: 1;
  grid-column: 2;
  position: relative;
  min-height: 0;
  min-width: 0;
}
.cw-canvas{display:block;width:100%;height:100%}
.cw-xlabels{
  grid-row: 2;
  grid-column: 2;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 9px;
  color: #888;
}
.cw-tooltip{position:absolute;display:none;background:rgba(20,20,20,.95);color:#fff;padding:6px 8px;border-radius:4px;font-size:10px;pointer-events:none;border:1px solid #444;white-space:nowrap;z-index:10}
.cw-tooltip .tt-time{color:#888;font-size:9px;margin-bottom:4px}
.cw-tooltip .tt-row{display:flex;gap:6px;align-items:center}
.cw-tooltip .dot{width:8px;height:8px;border-radius:50%}
.cw-tooltip .tt-label{color:#aaa}
.cw-tooltip .tt-val{color:#fff;font-weight:500}

/* Telemetry page layout */
.metrics-page{display:flex;flex-direction:column;height:100vh}
.metrics-header-bar{display:flex;align-items:center;justify-content:space-between;padding:12px 24px;background:#111;border-bottom:1px solid #2a2a2a;flex-shrink:0}
.metrics-header-bar h1{margin:0;font-size:18px;font-weight:600}
.header-controls{display:flex;gap:12px;align-items:center}
.back-link{color:#8ab4ff;text-decoration:none;font-size:13px}
.back-link:hover{text-decoration:underline}
.metrics-main{flex:1 1 auto;padding:24px;overflow-y:auto}
.charts-container{display:flex;flex-wrap:wrap;gap:16px;align-items:start;align-content:start}
.chart-card{background:#111;border:1px solid #2a2a2a;border-radius:8px;padding:12px;display:flex;flex-direction:column;gap:8px;resize:both;overflow:hidden;width:350px;height:250px;min-width:280px;min-height:200px}
.chart-card-header{display:flex;justify-content:flex-end;flex-shrink:0}
.remove-chart-btn{padding:4px 10px;font-size:12px;background:#2a1a1a;border-color:#4a2a2a;color:#ff6666}
.remove-chart-btn:hover:enabled{background:#3a2020;border-color:#6a3030}
/* Chart card internal layout */
.chart-title{flex:1;font-size:12px;font-weight:500;color:#e6e6e6;cursor:pointer}
.chart-title:hover{color:#8ab4ff}
.chart-selector-container{flex:1 1 auto;min-height:0;overflow-y:auto}
.chart-selector-container.hidden{display:none}
.chart-graph-container{flex:1 1 auto;min-height:0}
.chart-graph-container.hidden{display:none}
