
:root {
  --bg: #0d1117;
  --panel: #151b24;
  --panel-2: #1b2330;
  --border: #273244;
  --text: #edf4ff;
  --muted: #8fa0b7;
  --primary: #2f9cff;
  --danger: #ff5d73;
  --success: #37d39a;
  --shadow: 0 12px 40px rgba(0,0,0,.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }

button { cursor: pointer; }

#app {
  display: grid;
  grid-template-columns: 260px 1fr 310px;
  grid-template-rows: 64px 1fr;
  width: 100vw;
  height: 100vh;
}

.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  background: rgba(15, 20, 28, .96);
  backdrop-filter: blur(12px);
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand .logo {
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  background: linear-gradient(135deg, #2f9cff, #7a5cff);
  font-weight: 900;
}
.brand strong { display: block; }
.brand span { display: block; color: var(--muted); font-size: 12px; margin-top: 2px; }

.top-actions { display: flex; gap: 8px; align-items: center; }

.btn, .mini-btn, .wide-btn, .tool-card, .view-btn, .transform-mode {
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 9px;
  transition: .18s ease;
}

.btn { padding: 9px 13px; }
.btn:hover, .mini-btn:hover, .wide-btn:hover, .tool-card:hover, .view-btn:hover, .transform-mode:hover {
  border-color: #3b9cff;
  transform: translateY(-1px);
}
.btn.primary, .wide-btn.primary { background: var(--primary); border-color: var(--primary); color: white; }
.icon-btn { width: 38px; }

.panel {
  background: var(--panel);
  overflow-y: auto;
  border-color: var(--border);
  z-index: 10;
}
.left-panel { border-right: 1px solid var(--border); }
.right-panel { border-left: 1px solid var(--border); }

.panel-section { padding: 15px; border-bottom: 1px solid var(--border); }
.panel-section h3 { margin: 0 0 12px; font-size: 13px; text-transform: uppercase; letter-spacing: .08em; color: #c7d5e8; }

.grid-2, .grid-3 { display: grid; gap: 8px; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.compact { gap: 6px; }

.tool-card, .view-btn { padding: 11px 8px; }
.segmented { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.transform-mode { padding: 9px 5px; }
.transform-mode.active, .mini-btn.active { background: #173c61; border-color: var(--primary); }

.shortcut-note, .muted { color: var(--muted); font-size: 12px; line-height: 1.5; }
.shortcut-note { margin-top: 8px; }

.wide-btn { width: 100%; padding: 10px 12px; margin-top: 7px; text-align: left; }
.wide-btn.danger { color: #ffd9df; border-color: #613240; background: #321b22; }

.viewport-wrap { position: relative; min-width: 0; min-height: 0; background: #10161f; }
#viewport { position: absolute; inset: 0; }
#viewport canvas { display: block; width: 100%; height: 100%; }

.viewport-toolbar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; padding: 6px;
  border: 1px solid var(--border); background: rgba(18, 24, 33, .85);
  border-radius: 12px; backdrop-filter: blur(10px);
}
.mini-btn { padding: 7px 10px; font-size: 12px; }

.statusbar {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-between; gap: 10px;
  padding: 7px 12px;
  border-top: 1px solid var(--border);
  background: rgba(13,17,23,.88); color: var(--muted);
  font-size: 12px;
}

.drop-overlay {
  position: absolute; inset: 0; display: none; place-items: center;
  background: rgba(20, 100, 170, .25); border: 3px dashed var(--primary);
  z-index: 15; pointer-events: none;
}
.drop-overlay.visible { display: grid; }
.drop-overlay div { padding: 30px 40px; border-radius: 16px; background: rgba(12,16,23,.9); text-align: center; }
.drop-overlay strong, .drop-overlay span { display: block; }
.drop-overlay span { color: var(--muted); margin-top: 6px; }

.tabs { display: grid; grid-template-columns: repeat(3, 1fr); padding: 8px; gap: 6px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 2; }
.tab-btn { padding: 9px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); }
.tab-btn.active { color: white; background: var(--panel-2); }
.tab-content { display: none; }
.tab-content.active { display: block; }

label { display: block; color: #c8d4e5; font-size: 12px; margin-bottom: 10px; }
input[type="text"], input[type="number"], select {
  width: 100%; margin-top: 5px; padding: 9px 10px;
  border: 1px solid var(--border); border-radius: 8px;
  background: #101722; color: var(--text);
}
input[type="color"] { width: 100%; height: 38px; margin-top: 5px; border: 0; background: transparent; }
input[type="range"] { width: 100%; margin-top: 7px; }
.vector-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; }
.check { display: flex; align-items: center; gap: 7px; margin-top: 8px; }

.stats-box, .analysis-box {
  background: #101722; border: 1px solid var(--border); border-radius: 9px;
  padding: 10px; color: var(--muted); font-size: 12px; line-height: 1.55;
}
.analysis-box.good { border-color: #256d55; color: #bff7df; }
.analysis-box.warn { border-color: #7b5b26; color: #ffe2ad; }

.scene-list { display: grid; gap: 6px; }
.scene-item {
  display: flex; align-items: center; justify-content: space-between;
  gap: 8px; padding: 8px 9px; border: 1px solid var(--border);
  background: #101722; border-radius: 8px; font-size: 12px;
}
.scene-item.active { border-color: var(--primary); background: #142a40; }
.scene-item span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scene-item button { border: 0; color: var(--muted); background: transparent; }

.toast-container { position: fixed; right: 18px; bottom: 40px; display: grid; gap: 8px; z-index: 50; }
.toast {
  min-width: 260px; max-width: 360px;
  padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: #151d28; box-shadow: var(--shadow); font-size: 13px;
}
.toast.success { border-color: #256d55; }
.toast.error { border-color: #7b2835; }

@media (max-width: 1000px) {
  #app { grid-template-columns: 220px 1fr; }
  .right-panel {
    position: fixed; right: 0; top: 64px; bottom: 0; width: 310px;
    transform: translateX(100%); transition: .2s;
  }
  .right-panel.open { transform: translateX(0); }
}

@media (max-width: 720px) {
  #app { grid-template-columns: 1fr; }
  .left-panel { position: fixed; left: 0; top: 64px; bottom: 0; width: 250px; transform: translateX(-100%); }
  .brand span { display: none; }
  .top-actions .btn:not(.primary):not(.icon-btn) { display: none; }
}
