:root {
  --bg0: #0f1410;
  --bg1: #171e18;
  --bg2: #1f2921;
  --line: #2d3a30;
  --text: #e8efe6;
  --muted: #8fa093;
  --accent: #3d9a5f;
  --accent-2: #c4a35a;
  --danger: #c45c4a;
  --ok: #4caf70;
  --radius: 10px;
  --font: "DM Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, #1a3324 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #2a2416 0%, transparent 50%),
    var(--bg0);
}

.page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

.header {
  display: flex;
  justify-content: space-between;
  gap: 1.5rem;
  align-items: flex-start;
  margin-bottom: 1.75rem;
}

.brand {
  margin: 0;
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-2);
  font-weight: 600;
}

h1 {
  margin: 0.2rem 0 0.4rem;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 700;
}

.sub {
  margin: 0;
  color: var(--muted);
  max-width: 40rem;
  line-height: 1.45;
}

.header-meta {
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--muted);
  padding: 0.45rem 0.7rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg1);
  white-space: nowrap;
}

.panel {
  background: color-mix(in srgb, var(--bg1) 92%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.15rem 1.25rem 1.35rem;
  margin-bottom: 1rem;
  backdrop-filter: blur(8px);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

h2 {
  margin: 0 0 0.9rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.panel-head h2 { margin: 0; }

.muted { color: var(--muted); font-size: 0.85rem; }

.row {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
}

.grow { flex: 1; }

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.field.check {
  flex-direction: row;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  padding-top: 1.4rem;
}

input[type="number"],
input[type="url"],
input[type="datetime-local"],
select {
  font: inherit;
  color: var(--text);
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.55rem 0.7rem;
  outline: none;
}

input:focus, select:focus {
  border-color: var(--accent);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.85rem 0.75rem;
}

.form-grid .grow { grid-column: 1 / -1; }
.form-grid .check { grid-column: 1 / 3; }
.estimate { grid-column: 3 / -1; align-self: end; font-family: var(--mono); font-size: 0.8rem; color: var(--accent-2); }
.actions { grid-column: 1 / -1; display: flex; gap: 0.6rem; margin-top: 0.25rem; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  margin-top: 1rem;
}

.stats-grid.live {
  grid-template-columns: repeat(3, 1fr);
  margin-top: 0.85rem;
}

.stat {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
}

.stat-label {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 500;
}

.btn {
  font: inherit;
  font-weight: 600;
  border-radius: 8px;
  border: 1px solid var(--line);
  padding: 0.55rem 1rem;
  cursor: pointer;
  background: var(--bg2);
  color: var(--text);
}

.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: #2f7a4a; color: #04140a; }
.btn.danger { background: transparent; border-color: var(--danger); color: #f0b0a4; }
.btn.ghost { height: 2.5rem; }

.schema-wrap {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg0);
}

.tree-layout {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 0.75rem;
}

.picker-col,
.paths-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg0);
  max-height: 560px;
  overflow: auto;
  padding: 0.75rem 0.85rem;
}

.picker-col h3,
.paths-wrap h3,
.live-tree-box h3 {
  margin: 0 0 0.45rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.tiny { font-size: 0.72rem; margin: 0 0 0.5rem; }

.live-tree-box {
  margin-top: 0.75rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--line);
}

.tree-wrap {
  max-height: 220px;
  overflow: auto;
  padding: 0.35rem 0;
}

.paths-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.draft-path-card,
.saved-path-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg2);
  padding: 0.65rem 0.75rem;
}

.saved-path-card {
  cursor: default;
  transition: border-color 0.15s ease;
}

.saved-path-card:hover {
  border-color: #4a5c4e;
}

.saved-path-card.active {
  border-color: var(--line);
  box-shadow: none;
}

.path-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.path-card-head strong {
  font-size: 0.88rem;
}

.btn-xs {
  height: auto;
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
}

.save-row {
  display: flex;
  gap: 0.45rem;
  margin-top: 0.55rem;
  align-items: center;
}

.save-row input {
  flex: 1;
  font: inherit;
  color: var(--text);
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.5rem 0.65rem;
}

.saved-paths {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.tree-node {
  margin: 0.15rem 0;
  font-size: 0.85rem;
}

.tree-node > .node-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0;
}

.tree-children {
  margin-left: 1rem;
  padding-left: 0.65rem;
  border-left: 1px solid var(--line);
}

.node-event {
  font-family: var(--mono);
  font-size: 0.78rem;
}

.node-event.present {
  color: #cfe6c8;
}

.path-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.path-item {
  font-family: var(--mono);
  font-size: 0.68rem;
  line-height: 1.4;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg0);
  color: #b8c7b6;
}

.path-item.custom {
  border-color: #3d5a45;
  color: #cfe6c8;
}

.path-item.half {
  border-color: #5a4d2a;
  color: #d9c27a;
}

.path-tag {
  display: inline-block;
  font-size: 0.62rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 0.35rem;
  opacity: 0.85;
}

.seed-mix-note {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg2);
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.55rem;
}

.mode-opt {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg2);
  cursor: pointer;
  color: var(--text);
}

.mode-opt input { margin-right: 0.35rem; }
.mode-opt span { font-weight: 600; font-size: 0.9rem; }
.mode-opt small { color: var(--muted); font-size: 0.72rem; }
.mode-opt:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.tree-mode-field { grid-column: 1 / -1; }

.tree-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.35rem;
}

.event-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  max-height: 180px;
  overflow: auto;
  margin: 0.35rem 0 0.55rem;
}

.event-pick {
  font-family: var(--mono);
  font-size: 0.68rem;
  padding: 0.25rem 0.45rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--bg2);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}

.event-pick.on {
  color: #cfe6c8;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--bg0));
}

.event-pick .ord {
  color: var(--accent-2);
  margin-right: 0.25rem;
}

#activeTreeHint {
  grid-column: 1 / -1;
  margin: 0;
}

.badge {
  font-family: var(--mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg2);
}

.badge.running { color: var(--accent-2); border-color: #6a5a2e; }
.badge.completed { color: var(--ok); border-color: #2f5a3d; }
.badge.failed, .badge.stopped { color: #f0b0a4; border-color: var(--danger); }

.progress-bar {
  height: 8px;
  background: var(--bg0);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #7bc98f);
  transition: width 0.25s ease;
}

.log {
  margin: 0.9rem 0 0;
  max-height: 240px;
  overflow: auto;
  padding: 0.75rem;
  background: var(--bg0);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre-wrap;
  color: #b8c7b6;
}

.dry-panel {
  margin-top: 1rem;
  padding-top: 0.25rem;
}

.dry-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) 1.4fr;
  gap: 0.75rem;
  min-height: 260px;
}

.dry-events,
.dry-props {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg0);
  max-height: 360px;
  overflow: auto;
}

.dry-props {
  padding: 0.85rem;
}

.dry-event {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  padding: 0.7rem 0.85rem;
  cursor: pointer;
}

.dry-event:last-child { border-bottom: 0; }
.dry-event:hover { background: var(--bg2); }
.dry-event.active {
  background: color-mix(in srgb, var(--accent) 18%, var(--bg2));
  box-shadow: inset 3px 0 0 var(--accent);
}

.dry-event .ev-name {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
}

.dry-event .ev-meta {
  display: block;
  margin-top: 0.2rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  color: var(--muted);
}

.prop-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.prop-table th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 0 0 0.55rem;
}

.prop-table td {
  padding: 0.4rem 0.5rem 0.4rem 0;
  border-top: 1px solid var(--line);
  vertical-align: top;
  word-break: break-word;
}

.prop-table td.key {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--accent-2);
  width: 38%;
}

.prop-table td.val {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: #c9d6c7;
}

.dry-props h3 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.dry-props .ev-ts {
  margin: 0 0 0.85rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
}

.hidden { display: none; }

@media (max-width: 860px) {
  .form-grid { grid-template-columns: 1fr 1fr; }
  .stats-grid, .stats-grid.live { grid-template-columns: 1fr 1fr; }
  .form-grid .check, .estimate { grid-column: 1 / -1; }
  .header { flex-direction: column; }
  .dry-layout { grid-template-columns: 1fr; }
  .tree-layout { grid-template-columns: 1fr; }
  .mode-toggle { grid-template-columns: 1fr; }
}
