:root {
  --bg: #07131d;
  --bg2: #0b1c2a;
  --panel: #102334;
  --panel-2: #142c40;
  --line: #24475f;
  --text: #d8ebf0;
  --muted: #8eb0bf;
  --accent: #45d3ff;
  --accent2: #f6c349;
  --danger: #ff4f5f;
  --ok: #2fc876;
  --mono: "JetBrains Mono", "Fira Code", Consolas, Menlo, monospace;
  --ui: "Sora", "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at 10% 10%, #18344a 0%, transparent 40%),
    radial-gradient(circle at 90% 15%, #3a2b1a 0%, transparent 35%),
    linear-gradient(160deg, var(--bg) 0%, #050d14 100%);
  font-family: var(--ui);
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(to right, rgb(255 255 255 / 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgb(255 255 255 / 0.03) 1px, transparent 1px);
  background-size: 30px 30px;
}

.app-shell {
  position: relative;
  max-width: 1500px;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 12px;
}

.kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

h1 {
  margin: 4px 0 0;
  font-size: clamp(1.2rem, 1.8vw, 1.9rem);
}

.run-status {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.github-link {
  color: #9ed9ee;
  font-size: 0.82rem;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
}

.github-link:hover {
  color: #d6f5ff;
  border-color: var(--accent);
}

.workspace {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 12px;
}

.sidebar,
.main-area {
  min-width: 0;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel {
  background: linear-gradient(180deg, rgb(255 255 255 / 0.03) 0%, rgb(255 255 255 / 0.01) 100%);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 16px 28px rgb(0 0 0 / 0.24);
  padding: 10px;
}

h2 {
  margin: 0 0 8px;
  font-size: 0.98rem;
}

.field {
  display: block;
  margin-bottom: 10px;
}

.field span {
  display: block;
  margin-bottom: 5px;
  font-size: 0.84rem;
  color: var(--muted);
}

.field select,
.field input[type="text"],
.field input[type="range"] {
  width: 100%;
}

select,
input[type="text"] {
  background: #0d2434;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-family: var(--mono);
  font-size: 0.82rem;
}

small {
  color: var(--muted);
  font-size: 0.78rem;
}

.action-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0d2434;
  color: var(--text);
  padding: 7px 10px;
  cursor: pointer;
  font-size: 0.8rem;
}

.btn:hover {
  border-color: var(--accent);
}

.btn.primary {
  border-color: #1e7ea1;
}

.btn.accent {
  border-color: var(--accent2);
}

.btn.danger {
  border-color: #a84852;
}

.watch-add {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px;
  margin-bottom: 8px;
}

.watch-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.watch-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  background: #0b202f;
}

.watch-name {
  color: var(--accent);
}

.watch-val {
  color: #b9dbe7;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.vars-box {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  min-height: 120px;
  background: #081b28;
  font-family: var(--mono);
  font-size: 0.76rem;
  overflow: auto;
}

.tp-vars-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.tp-var-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) 1.5fr;
  gap: 8px;
  align-items: center;
}

.tp-var-key {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 0.76rem;
}

.tp-var-input {
  background: #0d2434;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  font-family: var(--mono);
  font-size: 0.76rem;
}

.tp-var-actions {
  margin-top: 9px;
  display: flex;
  gap: 8px;
}

.top-panels {
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mono {
  font-family: var(--mono);
  font-size: 0.78rem;
  color: var(--muted);
}

.editor-wrapper {
  height: min(58vh, 680px);
  display: grid;
  grid-template-columns: 66px 1fr;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-2) 100%);
}

.gutter {
  border-right: 1px solid var(--line);
  overflow: auto;
  background: #0a1c29;
}

.line-btn {
  width: 100%;
  height: 24px;
  border: none;
  background: transparent;
  border-bottom: 1px solid rgb(255 255 255 / 0.03);
  color: var(--muted);
  font: 500 0.76rem/24px var(--mono);
  text-align: right;
  padding-right: 10px;
  position: relative;
  cursor: pointer;
}

.line-btn:hover {
  background: rgb(255 255 255 / 0.05);
  color: var(--text);
}

.line-btn.tp-explicit::before {
  content: "";
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.line-btn.tp-explicit::before {
  left: 7px;
  background: var(--danger);
  box-shadow: 0 0 0 2px rgb(255 79 95 / 0.35);
}

.line-btn.current {
  background: rgb(69 211 255 / 0.12);
  color: #dff8ff;
}

#editor {
  width: 100%;
  border: none;
  resize: none;
  margin: 0;
  padding: 0 12px;
  background: transparent;
  color: var(--text);
  font: 500 0.9rem/24px var(--mono);
  outline: none;
  white-space: pre;
  tab-size: 2;
  overflow: auto;
}

.muted {
  color: var(--muted);
  margin: 6px 0 0;
}

.tiny {
  font-size: 0.76rem;
}

.output-box {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #06131d;
  min-height: min(58vh, 680px);
  max-height: min(58vh, 680px);
  overflow: auto;
  padding: 8px;
  font-family: var(--mono);
  font-size: 0.78rem;
}

.output-line {
  border-bottom: 1px solid rgb(255 255 255 / 0.05);
  padding: 4px 2px;
}

.output-line .ts {
  color: var(--muted);
  margin-right: 8px;
}

.output-line.error {
  color: #ff9ca4;
}

.timeline-panel {
  min-height: 240px;
}

.timeline {
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #06131d;
  padding: 12px;
  overflow: auto;
  min-height: 180px;
}

.timeline-track {
  position: relative;
  min-width: max-content;
  padding: 24px 18px 10px;
  display: flex;
  align-items: center;
  gap: 26px;
}

.timeline-row {
  margin-bottom: 18px;
}

.timeline-row.active .timeline-title {
  color: var(--accent);
}

.timeline-title {
  margin-bottom: 7px;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
}

.timeline-track::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 36px;
  height: 4px;
  border-radius: 999px;
  background: #1c3f53;
}

.timeline-node {
  position: relative;
  z-index: 2;
  border: 2px solid #6f8793;
  background: #d5dde1;
  color: #071520;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--mono);
  font-size: 0.7rem;
  cursor: pointer;
}

.timeline-node.explicit {
  background: #ffd25e;
  border-color: #b0892c;
}

.timeline-node.selected {
  outline: 3px solid rgb(69 211 255 / 0.45);
}

.timeline-time {
  position: absolute;
  top: -18px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 0.7rem;
  color: var(--muted);
}

.timeline-label {
  position: absolute;
  top: 38px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--mono);
  font-size: 0.67rem;
  color: #c1d8e1;
  white-space: nowrap;
}

.empty {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.8rem;
}

@media (max-width: 1200px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .top-panels {
    grid-template-columns: 1fr;
  }

  .editor-wrapper,
  .output-box {
    min-height: 48vh;
    max-height: 48vh;
  }
}
