:root {
  color-scheme: dark;
  --bg: #0b0d12;
  --panel: #111624;
  --panel-border: #1f2a45;
  --panel-soft: rgba(255, 255, 255, 0.02);
  --text: #e7e7e7;
  --muted: #cfd6e6;
  --muted2: #b8c3dd;
  --input: #0c1220;
  --input-border: #263354;
  --btn: #1a2a52;
  --btn-border: #2a3c6e;
  --btn-hover: #22366b;
  --accent: #9bc5ff;
  --warn: #ffca73;
  --ok: #39d67b;
  --bad: #ef5a5a;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

.wrap {
  display: grid;
  grid-template-columns: 440px 1fr;
  gap: 10px;
  height: 100vh;
  padding: 10px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0));
}

.crumbs {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.crumb {
  color: var(--accent);
  text-decoration: none;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.crumb:hover {
  text-decoration: underline;
}

.crumbDim {
  color: var(--muted2);
  font-weight: 600;
}

.sep {
  color: rgba(255, 255, 255, 0.35);
}

.here {
  color: #dbe3f7;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-transform: uppercase;
}

.panelScroll {
  overflow: auto;
  min-height: 0;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section {
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 10px;
  background: var(--panel-soft);
}

.section h2 {
  margin: 0 0 8px 0;
  font-size: 14px;
  letter-spacing: 0.2px;
  color: #dbe3f7;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

label {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.1;
}

input[type="number"],
input[type="text"],
select,
textarea {
  width: 100%;
  box-sizing: border-box;
  background: var(--input);
  color: var(--text);
  border: 1px solid var(--input-border);
  border-radius: 10px;
  padding: 7px 9px;
  outline: none;
  font-size: 12px;
  resize: vertical;
}

textarea {
  min-height: 58px;
}

.btnRow {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

button,
.fileBtn {
  background: var(--btn);
  color: var(--text);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  padding: 8px 10px;
  cursor: pointer;
  font-size: 12px;
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

button:hover,
.fileBtn:hover {
  background: var(--btn-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.fileBtn input {
  display: none;
}

.hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: rgba(231, 231, 231, 0.78);
  line-height: 1.35;
}

.dropZone {
  border: 1px dashed rgba(155, 197, 255, 0.55);
  border-radius: 10px;
  padding: 12px;
  background: rgba(12, 18, 32, 0.6);
  outline: none;
}

.dropZone:focus-visible {
  box-shadow: 0 0 0 3px rgba(155, 197, 255, 0.25);
}

.dropZone.dragOver {
  border-color: rgba(57, 214, 123, 0.7);
  background: rgba(12, 18, 32, 0.86);
}

.dropTitle {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: #dbe3f7;
}

.dropSub {
  margin-top: 4px;
  font-size: 12px;
  color: rgba(231, 231, 231, 0.72);
}

.canvasWrap {
  background: var(--bg);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  overflow: hidden;
  min-width: 0;
  position: relative;
}

#view {
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  pointer-events: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.35;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: pre-wrap;
}

.toast {
  position: absolute;
  left: 10px;
  bottom: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(17, 22, 36, 0.88);
  border: 1px solid rgba(31, 42, 69, 0.9);
  color: rgba(231, 231, 231, 0.92);
  font-size: 12px;
  line-height: 1.35;
  max-width: min(560px, calc(100% - 20px));
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 140ms ease, transform 140ms ease;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.kv {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
  color: var(--muted2);
}

.kvRow {
  display: flex;
  gap: 10px;
  align-items: baseline;
}

.k {
  min-width: 86px;
  color: rgba(231, 231, 231, 0.8);
}

.v {
  color: var(--muted2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.libraryList {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 8px;
}

.libraryItem {
  text-align: left;
  background: rgba(12, 18, 32, 0.7);
  border: 1px solid rgba(38, 51, 84, 0.9);
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease;
}

.libraryItem:hover {
  border-color: rgba(155, 197, 255, 0.6);
  transform: translateY(-1px);
}

.libraryItemTitle {
  font-size: 12px;
  font-weight: 800;
  color: #dbe3f7;
  letter-spacing: 0.2px;
}

.libraryItemMeta {
  margin-top: 3px;
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: rgba(184, 195, 221, 0.95);
}

@media (max-width: 980px) {
  body {
    overflow: auto;
  }
  .wrap {
    grid-template-columns: 1fr;
    height: auto;
  }
  .canvasWrap {
    height: 58vh;
  }
}

