@font-face { font-family: "Inter"; font-weight: 400; font-display: swap; src: url(vendor/fonts/inter-400.woff2) format("woff2"); }
@font-face { font-family: "Inter"; font-weight: 500; font-display: swap; src: url(vendor/fonts/inter-500.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 400; font-display: swap; src: url(vendor/fonts/jbmono-400.woff2) format("woff2"); }
@font-face { font-family: "JetBrains Mono"; font-weight: 500; font-display: swap; src: url(vendor/fonts/jbmono-500.woff2) format("woff2"); }

:root {
  /* graphite ramp */
  --deep: #0f0f10;
  --bg: #141415;
  --card: #19191b;
  --raised: #232325;
  --hover: #2a2a2d;
  --line: rgba(237, 237, 237, 0.08);
  --line-strong: rgba(237, 237, 237, 0.14);
  --text: #ededed;
  --text-2: #a1a1a6;
  --muted: #85858b;
  /* one accent: selection and focus */
  --accent: #2563eb;
  --accent-ink: #6ea0ff;
  --negative: #e5484d;
  --positive: #4cc38a;

  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --sans: "Inter", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 400 13px/20px var(--sans);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.icon { width: 16px; height: 16px; flex: none; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* controls */
button, input, select {
  font: inherit;
  color: var(--text);
  background: var(--raised);
  border: 1px solid var(--line);
  border-radius: 8px;
}
button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 32px; padding: 0 12px;
  cursor: pointer; white-space: nowrap;
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease), transform 120ms var(--ease);
}
button .icon { color: var(--text-2); transition: color 140ms var(--ease); }
button:hover { background: var(--hover); border-color: var(--line-strong); }
button:hover .icon { color: var(--text); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.4; cursor: default; pointer-events: none; }
button.icon-btn { width: 32px; padding: 0; }
button.primary { background: var(--text); border-color: var(--text); color: var(--bg); font-weight: 500; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12); }
button.primary .icon { color: var(--bg); }
button.primary:hover { background: #ffffff; }
button.danger:hover { color: var(--negative); }
button.danger:hover .icon { color: var(--negative); }
input, select { height: 32px; padding: 0 8px; }
input[type=number] { width: 100%; font-family: var(--mono); font-variant-numeric: tabular-nums; }
input::placeholder { color: var(--muted); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* toolbar */
.toolbar {
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 16px;
  background: var(--deep); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 500; font-size: 15px; white-space: nowrap; }
.mark { width: 16px; height: 16px; }
.name { width: 192px; }
.group { display: flex; gap: 4px; align-items: center; }
.spacer { flex: 1; }

.seg { display: flex; padding: 2px; gap: 2px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.seg button { height: 28px; padding: 0 12px; border-radius: 8px; border-color: transparent; background: transparent; color: var(--text-2); }
.seg button:hover { background: var(--raised); color: var(--text); }
.seg button.on, .seg button[aria-selected=true] { background: var(--raised); border-color: var(--line-strong); color: var(--text); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06); }

button.toggle { background: transparent; border-color: transparent; color: var(--muted); }
button.toggle:hover { background: var(--raised); }
button.toggle[aria-pressed=true] { background: var(--raised); border-color: var(--line); color: var(--text); }
button.toggle[aria-pressed=true] .icon { color: var(--text); }

.menu-wrap { position: relative; }
.menu {
  position: absolute; right: 0; top: calc(100% + 8px); z-index: 20;
  width: 272px; padding: 4px;
  background: var(--card); border: 1px solid var(--line-strong); border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  opacity: 0; transform: translateY(-4px);
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
}
.menu.open { opacity: 1; transform: none; }
.menu button {
  width: 100%; height: auto; padding: 8px; justify-content: flex-start; align-items: flex-start; gap: 12px;
  background: transparent; border-color: transparent; text-align: left;
}
.menu button:hover { background: var(--raised); }
.menu button .icon { margin-top: 2px; }
.menu small { display: block; color: var(--muted); font-size: 12px; line-height: 16px; }

/* layout */
.layout { display: grid; grid-template-columns: 240px 1fr 280px; min-height: 0; }
.palette, .side { background: var(--deep); overflow-y: auto; min-height: 0; }
.palette { border-right: 1px solid var(--line); padding: 16px; }
.side { border-left: 1px solid var(--line); }

.tabs { margin-bottom: 16px; }
.tabs button { flex: 1; padding: 0 8px; }
.items { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.item {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  height: 104px; padding: 8px 4px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  cursor: grab; user-select: none; text-align: center; font-size: 12px; line-height: 16px; color: var(--text-2);
  transition: background-color 140ms var(--ease), border-color 140ms var(--ease), color 140ms var(--ease);
}
.item:hover { background: var(--raised); border-color: var(--line-strong); color: var(--text); }
.item:active { cursor: grabbing; }
.item canvas { width: 64px; height: 48px; }
.items-head { grid-column: 1 / -1; margin: 16px 0 4px; font-size: 13px; line-height: 20px; font-weight: 500; }
.items-head small { display: block; font-size: 12px; line-height: 16px; font-weight: 400; color: var(--muted); }
.field-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.field-label { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; line-height: 16px; }
.seg.levels button { padding: 0 8px; }
.hint { color: var(--muted); font-size: 12px; line-height: 16px; margin: 16px 0 0; }

/* views */
.views { display: grid; min-width: 0; min-height: 0; }
.views.view-split { grid-template-columns: 1fr 1fr; }
.views.view-top #pane3d, .views.view-3d #paneTop { display: none; }
.pane { position: relative; min-width: 0; min-height: 0; overflow: hidden; background: var(--bg); }
#pane3d { border-left: 1px solid var(--line); }
.views.view-3d #pane3d { border-left: 0; }
#topCanvas { display: block; outline: none; touch-action: none; }
#pane3d canvas { display: block; }
.pane-btn {
  position: absolute; top: 12px; right: 12px; z-index: 2;
  height: 28px; padding: 0 8px; gap: 4px; font-size: 12px;
  background: rgba(20, 20, 21, 0.85); border-color: var(--line-strong);
}

/* side panels */
.panel { padding: 16px; border-bottom: 1px solid var(--line); }
.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.panel h3 { margin: 0; font-size: 13px; font-weight: 500; }
.panel h3 .muted { font-weight: 400; }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 8px; }
.form label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 12px; line-height: 16px; }
.form input[type=text] { width: 100%; }
.actions-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 4px; margin-top: 12px; }
.actions-row button { padding: 0; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; align-items: center; }
.swatch {
  width: 20px; height: 20px; padding: 0; border-radius: 50%;
  border: 0; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}
.swatch:hover { background-color: inherit; }
.swatch.on { box-shadow: 0 0 0 2px var(--deep), 0 0 0 4px var(--text); }
.swatches input[type=color] { width: 28px; height: 20px; padding: 0 2px; border-radius: 4px; cursor: pointer; }
.empty { color: var(--muted); margin: 0; }

.bom-set { color: var(--muted); font-size: 12px; line-height: 16px; margin: 12px 0 4px; }
.bom-set:first-child { margin-top: 0; }
.bom-row {
  display: grid; grid-template-columns: 40px 1fr auto; gap: 12px; align-items: center;
  min-height: 44px; padding: 4px 8px 4px 4px; margin: 0 -8px 0 -4px; border-radius: 8px; cursor: pointer;
  transition: background-color 140ms var(--ease);
}
.bom-row:hover { background: var(--card); }
.bom-row canvas { width: 40px; height: 32px; }
.bom-row .count { font-family: var(--mono); font-variant-numeric: tabular-nums; font-weight: 500; font-size: 15px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 4px; font-family: var(--mono); font-size: 12px; line-height: 16px; color: var(--muted); }
.chip i { width: 8px; height: 8px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2); }

/* status */
.status {
  display: flex; align-items: center; gap: 16px; height: 28px; padding: 0 16px;
  background: var(--deep); border-top: 1px solid var(--line);
  font-size: 12px; line-height: 16px; white-space: nowrap; overflow: hidden; color: var(--text-2);
}
#stCursor { min-width: 160px; color: var(--muted); }
#stMsg.err { color: var(--negative); }
#stMsg.ok { color: var(--positive); }
.keys { display: flex; gap: 16px; margin-left: auto; overflow: hidden; color: var(--muted); }
.keys > span { display: inline-flex; align-items: center; gap: 4px; }
kbd {
  display: inline-block; min-width: 20px; padding: 0 4px;
  font: 500 11px/16px var(--mono); text-align: center; color: var(--text-2);
  background: var(--raised); border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 4px;
}

/* dialogs */
dialog {
  width: 400px; padding: 24px;
  background: var(--card); color: var(--text);
  border: 1px solid var(--line-strong); border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.5); }
dialog h3 { margin: 0 0 4px; font-size: 16px; font-weight: 500; }
dialog p { margin: 0; }
.choices { display: grid; gap: 8px; margin-top: 16px; }
.choices button { height: auto; padding: 12px; flex-direction: column; align-items: flex-start; gap: 0; text-align: left; border-radius: 10px; }
.choices button .num { font-size: 12px; color: var(--muted); }
.actions { display: flex; align-items: center; gap: 8px; margin-top: 24px; }
.actions .spacer { flex: 1; }
.actions button:last-child { margin-left: auto; }
.tracklist { list-style: none; padding: 0; margin: 12px 0 0; max-height: 50vh; overflow-y: auto; }
.tracklist li { display: flex; gap: 8px; align-items: center; min-height: 44px; border-bottom: 1px solid var(--line); }
.tracklist li .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tracklist li .when { font-size: 12px; color: var(--muted); }
.tracklist li.muted { color: var(--muted); }

@media (max-width: 1200px) {
  .keys > span:nth-child(n+4) { display: none; }
  .name { width: 144px; }
}
@media (max-width: 1000px) {
  .layout { grid-template-columns: 184px 1fr 240px; }
  .views.view-split { grid-template-columns: 1fr; grid-template-rows: 1fr 1fr; }
  #pane3d { border-left: 0; border-top: 1px solid var(--line); }
  .toolbar { gap: 8px; }
  .toolbar .group button:not(.icon-btn) { width: 32px; padding: 0; font-size: 0; gap: 0; }
  .brand { font-size: 0; gap: 0; }
}
