@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap');

:root {
  color-scheme: dark;
  --bg: #090c11;
  --panel: #11161e;
  --panel-2: #151b24;
  --line: #252d39;
  --line-hot: #394557;
  --text: #e9edf3;
  --muted: #8994a5;
  --muted-2: #5e6979;
  --accent: #ff8a3d;
  --accent-hot: #ffb15f;
  --cyan: #60d8ee;
  --green: #67e0a3;
  --danger: #ff6474;
  --radius: 10px;
  font-family: "DM Sans", system-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: inherit; }

.app-header {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(13, 17, 23, .96);
  position: relative;
  z-index: 5;
}
.brand { color: inherit; text-decoration: none; display: flex; align-items: center; gap: 11px; }
.brand-mark {
  display: grid; place-items: center; width: 35px; height: 35px;
  background: linear-gradient(145deg, var(--accent), #cf4b1c);
  border-radius: 9px; color: #1a0a03; font: 800 13px/1 "Space Grotesk", sans-serif;
  box-shadow: 0 0 24px rgba(255, 119, 40, .2);
}
.brand strong { font: 600 16px/1.05 "Space Grotesk", sans-serif; display: block; letter-spacing: -.02em; }
.brand small { color: var(--muted); font-size: 11px; display: block; margin-top: 3px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.asset-picker { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; margin-right: 4px; }
select, input[type="number"], input[type="search"] {
  background: #0c1118; border: 1px solid var(--line); border-radius: 6px; color: var(--text); outline: none;
}
select:focus, input:focus { border-color: var(--cyan); box-shadow: 0 0 0 2px rgba(96, 216, 238, .1); }
.asset-picker select { min-width: 220px; padding: 8px 30px 8px 10px; }
.btn, .small-btn, .icon-btn, .tool-btn, .play-btn, .socket-actions button {
  border: 1px solid var(--line-hot); border-radius: 7px; background: #171e28; cursor: pointer;
  transition: border-color .14s, background .14s, color .14s, transform .1s;
}
.btn:hover, .small-btn:hover, .icon-btn:hover, .tool-btn:hover, .play-btn:hover, .socket-actions button:hover { border-color: #59677a; background: #1d2632; }
.btn:active, .small-btn:active, .tool-btn:active { transform: translateY(1px); }
.btn { padding: 9px 14px; font-weight: 650; font-size: 12px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #211006; }
.btn.primary:hover { background: var(--accent-hot); border-color: var(--accent-hot); }
.btn.secondary { background: #19212c; }
.btn.apply { color: var(--green); border-color: rgba(103, 224, 163, .4); background: rgba(38, 112, 78, .16); }
.btn.apply:hover { border-color: var(--green); background: rgba(38, 112, 78, .28); }
.btn:disabled { opacity: .38; cursor: not-allowed; transform: none; }
.btn.compact { padding: 7px 10px; }

.workspace { height: calc(100vh - 90px); display: grid; grid-template-columns: 270px minmax(320px, 1fr) 330px; }
.sidebar { min-height: 0; overflow-y: auto; background: var(--panel); scrollbar-color: #303a47 transparent; scrollbar-width: thin; }
.left-sidebar { border-right: 1px solid var(--line); }
.right-sidebar { border-left: 1px solid var(--line); }
.panel { padding: 16px; border-bottom: 1px solid var(--line); }
.panel h1, .panel h2 { font-family: "Space Grotesk", sans-serif; margin: 0; }
.panel h1 { font-size: 17px; margin-top: 5px; word-break: break-word; }
.panel h2 { font-size: 14px; margin-top: 3px; }
.eyebrow { font-size: 9px; letter-spacing: .13em; color: var(--muted); font-weight: 700; }
#asset-stats { font-size: 11px; color: var(--muted); margin: 5px 0 13px; }
.drop-zone {
  border: 1px dashed #3b4656; border-radius: 8px; padding: 14px 10px; text-align: center;
  background: rgba(255,255,255,.015); color: var(--muted); cursor: pointer;
}
.drop-zone strong { color: #bbc3cf; display: block; font-size: 11px; }
.drop-zone span { font-size: 10px; }
.drop-zone.dragging { border-color: var(--accent); background: rgba(255,138,61,.08); }
.panel-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; margin-bottom: 11px; }
.icon-btn { width: 27px; height: 27px; padding: 0; color: var(--muted); }
.search-wrap { height: 32px; position: relative; display: block; margin-bottom: 9px; }
.search-wrap span { position: absolute; left: 9px; top: 5px; color: var(--muted); z-index: 1; }
.search-wrap input { width: 100%; height: 100%; padding: 0 9px 0 28px; font-size: 11px; }
.tree-panel { padding-left: 10px; padding-right: 10px; }
.tree-panel .panel-heading, .tree-panel .search-wrap { margin-left: 6px; margin-right: 6px; }
.node-tree { height: calc(100vh - 300px); min-height: 180px; overflow: auto; padding-bottom: 14px; }
.tree-row {
  height: 27px; display: flex; align-items: center; gap: 6px; padding-right: 7px; border-radius: 5px;
  color: #aeb7c4; font-size: 11px; cursor: pointer; white-space: nowrap; user-select: none;
}
.tree-row:hover { background: #18202a; color: var(--text); }
.tree-row.selected { background: rgba(255, 138, 61, .12); color: #ffd1aa; }
.tree-row.socket-node { color: var(--cyan); }
.tree-indent { flex: 0 0 auto; }
.tree-caret { width: 11px; border: 0; background: none; color: var(--muted-2); padding: 0; cursor: pointer; font-size: 9px; }
.tree-icon { width: 14px; text-align: center; color: var(--muted-2); font-size: 9px; }
.tree-label { overflow: hidden; text-overflow: ellipsis; }

.viewport { min-width: 0; position: relative; overflow: hidden; background: radial-gradient(circle at 50% 42%, #222a33, #0c1016 72%); }
.viewport canvas { display: block; width: 100%; height: 100%; outline: none; }
.viewport-toolbar { position: absolute; z-index: 2; top: 12px; left: 12px; right: 12px; display: flex; justify-content: space-between; pointer-events: none; }
.tool-group { display: flex; padding: 3px; background: rgba(11,15,21,.82); border: 1px solid rgba(68,79,93,.72); border-radius: 8px; backdrop-filter: blur(9px); pointer-events: auto; }
.tool-btn { font-size: 10px; padding: 6px 9px; border-color: transparent; background: transparent; color: var(--muted); }
.tool-btn.active { color: #211006; background: var(--accent); border-color: var(--accent); }
.viewport-note { position: absolute; z-index: 2; left: 50%; bottom: 12px; transform: translateX(-50%); padding: 6px 10px; border-radius: 6px; background: rgba(7,10,14,.65); color: var(--muted); font-size: 9px; pointer-events: none; white-space: nowrap; }
kbd { font: inherit; color: #d8dee8; }
.loading-card, .empty-state { position: absolute; z-index: 3; left: 50%; top: 50%; transform: translate(-50%,-50%); display: flex; align-items: center; gap: 10px; color: #d8dee7; font-size: 12px; }
.empty-state { flex-direction: column; text-align: center; max-width: 290px; color: var(--muted); }
.empty-state strong { font: 600 18px "Space Grotesk", sans-serif; color: var(--text); }
.spinner { width: 17px; height: 17px; border: 2px solid #485463; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

.type-chip { color: var(--muted); background: #0c1117; border: 1px solid var(--line); border-radius: 999px; padding: 3px 7px; font-size: 9px; }
.transform-fields.disabled { opacity: .38; pointer-events: none; }
.field-row { display: grid; grid-template-columns: 55px 1fr; align-items: center; gap: 7px; margin: 8px 0; }
.field-row > label { font-size: 10px; color: var(--muted); }
.axis-fields { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.axis-fields label { position: relative; }
.axis-fields b { position: absolute; left: 6px; top: 7px; font-size: 8px; z-index: 1; }
.axis-x { color: #ff6b6b; } .axis-y { color: #69dc91; } .axis-z { color: #62a8ff; }
.axis-fields input { width: 100%; height: 28px; padding: 0 4px 0 17px; font-size: 9px; }
input[type="number"] { appearance: textfield; }
input::-webkit-inner-spin-button { appearance: none; }
.inspector-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 11px; }
.small-btn { font-size: 10px; padding: 6px 8px; color: #b8c1cd; }
.small-btn.danger { color: #ff9aa5; border-color: rgba(255, 100, 116, .35); }
.small-btn.danger:hover { color: #ffd6da; border-color: var(--danger); background: rgba(121, 31, 44, .28); }
.small-btn:disabled { opacity: .35; cursor: not-allowed; }
.toggle-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 10px; cursor: pointer; white-space: nowrap; }
.toggle-label input { position: absolute; opacity: 0; }
.toggle-label span { width: 24px; height: 13px; background: #29313d; border-radius: 999px; position: relative; }
.toggle-label span::after { content: ''; position: absolute; width: 9px; height: 9px; left: 2px; top: 2px; background: #7f8a99; border-radius: 50%; transition: .15s; }
.toggle-label input:checked + span { background: rgba(96,216,238,.25); }
.toggle-label input:checked + span::after { left: 13px; background: var(--cyan); }
.help-dot { display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--line-hot); color: var(--muted); border-radius: 50%; font-size: 10px; cursor: help; }
.panel-copy { color: var(--muted); font-size: 10px; line-height: 1.45; margin: -3px 0 10px; }
.socket-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.socket-actions button { min-height: 40px; padding: 5px 3px; font-size: 9px; color: #abb5c2; }
.socket-dot { width: 6px; height: 6px; display: inline-block; border-radius: 50%; margin-right: 3px; box-shadow: 0 0 7px currentColor; }
.socket-dot.orange { color: var(--accent); background: var(--accent); }
.socket-dot.cyan { color: var(--cyan); background: var(--cyan); }
.socket-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 9px; }
.socket-chip { border: 1px solid #31404d; border-radius: 999px; padding: 3px 7px; color: #8bdced; font-size: 9px; cursor: pointer; background: #101a21; }
.muted { color: var(--muted-2); font-size: 9px; }
.clip-row { display: grid; grid-template-columns: 1fr 32px; gap: 6px; }
.clip-row select { width: 100%; padding: 7px 9px; font-size: 10px; }
.play-btn { padding: 0; color: var(--accent); }
.time-readout { display: flex; justify-content: flex-end; gap: 3px; margin-top: 8px; font: 9px/1 "Space Grotesk", monospace; }
#time-current { color: var(--text); } #time-duration { color: var(--muted); }
.timeline { width: 100%; height: 15px; margin: 0; accent-color: var(--accent); }
.animation-options { display: grid; grid-template-columns: 1fr 1fr auto; gap: 6px; align-items: end; margin-top: 7px; }
.animation-options > label:not(.toggle-label) { color: var(--muted); font-size: 9px; }
.animation-options input[type="number"] { display: block; width: 100%; height: 27px; padding: 0 6px; margin-top: 3px; font-size: 10px; }
.animation-options .toggle-label { margin-bottom: 7px; }
.key-actions { display: flex; gap: 6px; margin-top: 10px; }
#key-hint { margin-top: 7px; }
.walk-generator { border-top: 1px solid var(--line); margin: 12px -16px -16px; padding: 13px 16px 16px; background: rgba(255,255,255,.012); }
.walk-generator > div:first-child { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.walk-generator strong { font: 600 11px "Space Grotesk", sans-serif; }
.walk-generator > div:first-child span { color: var(--muted); font-size: 8px; }
.walk-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 9px 0; }
.walk-fields label { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 9px; }
.walk-fields input { width: 40px; padding: 4px; text-align: right; font-size: 9px; }
.walk-generator .btn { width: 100%; }

.status-bar { height: 26px; display: flex; justify-content: space-between; align-items: center; padding: 0 12px; background: #0b0f14; border-top: 1px solid var(--line); color: var(--muted-2); font-size: 9px; }
.status-dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 7px var(--green); margin-right: 6px; }
.status-dot.busy { background: var(--accent); box-shadow: 0 0 7px var(--accent); }
.status-dot.error { background: var(--danger); box-shadow: 0 0 7px var(--danger); }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 42px; transform: translate(-50%, 15px); padding: 9px 13px; background: #202a36; border: 1px solid #445164; border-radius: 7px; color: #eef2f7; font-size: 11px; opacity: 0; pointer-events: none; transition: .2s; box-shadow: 0 8px 30px rgba(0,0,0,.35); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--danger); }

@media (max-width: 1050px) {
  .workspace { grid-template-columns: 220px minmax(300px, 1fr) 300px; }
  .asset-picker span { display: none; }
  .asset-picker select { min-width: 180px; }
}
@media (max-width: 800px) {
  html, body { overflow: auto; }
  .app-header { height: auto; min-height: 62px; flex-wrap: wrap; gap: 8px; padding: 10px; }
  .brand small { display: none; }
  .header-actions { flex: 1; justify-content: flex-end; }
  .asset-picker { display: none; }
  #apply-game { display: none; }
  .workspace { height: auto; min-height: calc(100vh - 90px); display: grid; grid-template-columns: 1fr; grid-template-rows: 58vh auto auto; }
  .viewport { grid-row: 1; }
  .left-sidebar { grid-row: 2; border: 0; overflow: visible; }
  .right-sidebar { grid-row: 3; border: 0; overflow: visible; }
  .node-tree { height: 280px; }
  .status-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 8; }
  .status-bar > span:last-child { display: none; }
}
