:root {
  --bg: #060a18;
  --panel: #0d1428;
  --panel-2: #111a33;
  --border: #233150;
  --text: #dfe6f3;
  --dim: #8ea0c0;
  --accent: #4f8cff;
  --gold: #f5c518;
}

* { box-sizing: border-box; }

body {
  height: 100vh;
  margin: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  overflow: hidden;
}

body.dropping::after {
  content: "Drop .ktsp file to load";
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(79, 140, 255, 0.16);
  border: 3px dashed var(--accent);
  font-size: 22px;
  font-weight: 600;
  color: #cfe0ff;
  pointer-events: none;
  z-index: 50;
}

#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

#topbar h1 {
  font-size: 16px;
  margin: 0;
  letter-spacing: 0.4px;
  white-space: nowrap;
}

.upload-area {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.btn {
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent); background: #16224a; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #3f7bef; }

#play-btn { min-width: 92px; }
#play-btn.active { background: #2f5cbf; border-color: #5f8ff5; color: #fff; }

.status { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status.idle { color: var(--dim); }
.status.ok { color: #7ddc9a; }
.status.error { color: #ff8484; }

#workspace {
  display: flex;
  flex: 1;
  min-height: 0;
}

#side {
  width: 270px;
  min-width: 230px;
  padding: 10px;
  overflow-y: auto;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel {
  background: var(--panel-2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 12px;
}
.panel h2 {
  margin: 0 0 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--dim);
}

.frow {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: baseline;
  padding: 3px 0;
}
.frow > span:first-child { color: var(--dim); white-space: nowrap; }
.frow > span:last-child { text-align: right; }
.frow.labels { gap: 6px; align-items: center; }

.fcomments {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  color: var(--dim);
  font-size: 12px;
}

.hint { color: var(--dim); font-size: 12px; padding-top: 6px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.small { font-size: 11px; }

.hops { margin-top: 6px; display: flex; flex-direction: column; gap: 2px; }
.hop {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  padding: 3px 7px;
  border-radius: 5px;
  font-size: 12px;
  background: rgba(35, 49, 80, 0.35);
}
.hop.active { background: var(--accent); color: #fff; }
.hop.active .dim { color: #d8e4ff; }
.hop .dim { color: var(--dim); }
.s.problems {
  margin-top: 6px;
  color: #ffb46b;
  font-size: 12px;
  line-height: 1.5;
}

.chk {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 3px 0;
  cursor: pointer;
}
.chk input { accent-color: var(--accent); }

#size-slider {
  width: 100%;
  accent-color: var(--accent);
  margin: 2px 0 8px;
  cursor: pointer;
}

select {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 6px;
  font: inherit;
}

#canvas-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  background:
    radial-gradient(ellipse 60% 55% at 62% 40%, #0d1530 0%, #060a18 72%);
}

#view { display: block; cursor: grab; touch-action: none; }
#view:active { cursor: grabbing; }

.tooltip {
  position: absolute;
  left: 0; top: 0;
  background: rgba(10, 16, 36, 0.92);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 12px;
  line-height: 1.5;
  pointer-events: none;
  z-index: 20;
  white-space: nowrap;
}
.tooltip .dim { color: var(--dim); }

.btn.small { padding: 5px 12px; font-size: 12px; margin-top: 8px; }

#controls {
  position: relative;
  padding: 8px 14px 10px;
  background: linear-gradient(180deg, rgba(9,14,30,0), var(--panel) 30%);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timebar {
  display: flex;
  align-items: center;
  gap: 10px;
}

#time-label {
  margin-left: auto;
  font-size: 13px;
  color: #b9c8e8;
  letter-spacing: 0.3px;
}

.sliderbar {
  display: flex;
  align-items: center;
  gap: 10px;
}

#time-slider {
  flex: 1;
  accent-color: var(--accent);
  cursor: pointer;
}

@media (max-width: 720px) {
  #side { width: 200px; min-width: 170px; }
  #time-label { font-size: 11px; }
}
