:root {
  --bg: #0c1117;
  --panel: #141b24;
  --panel-2: #1a2330;
  --text: #e8eef5;
  --muted: #8b9aab;
  --line: #273344;
  --accent: #6eb0ff;
  --ok: #3d9a6a;
  --busy: #d4a017;
  --danger: #d46b6b;
  --warn: #c98a3c;
  --mono: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
  --list-w: 340px;
  --dock-h: 148px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select {
  font: inherit;
  color: var(--text);
}
button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 0.35rem 0.65rem;
  cursor: pointer;
}
button:hover { border-color: var(--accent); }
button:disabled { opacity: 0.4; cursor: default; }
button.danger { border-color: #5a3030; color: #f0b0b0; }
button.danger:hover { border-color: var(--danger); }
button.primary { border-color: #3a5f8a; color: var(--accent); }
button.active { border-color: var(--busy); color: var(--busy); }
input[type=number], input[type=text], select {
  background: #0b1016;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.3rem 0.45rem;
}
input[type=range] { accent-color: var(--accent); }
label.toggle {
  display: inline-flex; align-items: center; gap: 0.4rem;
  cursor: pointer; user-select: none; font-size: 0.85rem;
}
.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.8rem; }

/* Top bar */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
}
.topbar h1 {
  margin: 0; font-size: 1.05rem; font-weight: 600;
  letter-spacing: -0.02em; white-space: nowrap;
}
.topbar .stats { color: var(--muted); font-size: 0.85rem; flex: 1; }
.global-sim {
  display: flex; flex-wrap: wrap; gap: 0.55rem 0.85rem; align-items: center;
  font-size: 0.85rem;
}
.global-sim input[type=number] { width: 4.5rem; }

/* Shell */
.shell {
  display: grid;
  grid-template-columns: var(--list-w) 1fr;
  flex: 1;
  min-height: 0;
  padding-bottom: var(--dock-h);
}

/* Session list */
.list-pane {
  border-right: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.list-tools {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 0.5rem;
}
.list-tools input[type=search] {
  width: 100%;
  background: #0b1016;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
}
.filters { display: flex; gap: 0.35rem; }
.filters button { flex: 1; font-size: 0.78rem; padding: 0.3rem; }
.session-list {
  list-style: none; margin: 0; padding: 0;
  overflow: auto; flex: 1;
}
.session-list li {
  padding: 0.7rem 0.85rem;
  border-bottom: 1px solid var(--line);
  cursor: pointer;
}
.session-list li:hover { background: #182230; }
.session-list li.selected { background: #1e2d40; box-shadow: inset 3px 0 0 var(--accent); }
.session-list .name {
  font-size: 0.88rem; font-weight: 550;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.session-list .row2 {
  display: flex; justify-content: space-between; gap: 0.5rem;
  margin-top: 0.25rem; font-size: 0.75rem; color: var(--muted);
}
.pill {
  display: inline-block; font-size: 0.68rem; padding: 0.08rem 0.4rem;
  border-radius: 999px; font-weight: 650; color: #0b120e;
}
.pill.ok { background: var(--ok); }
.pill.busy { background: var(--busy); }
.pill.fault { background: var(--danger); color: #1a0808; }
.empty-list { padding: 1.5rem; color: var(--muted); font-size: 0.9rem; }

/* Detail */
.detail-pane {
  overflow: auto;
  background: radial-gradient(900px 400px at 80% -10%, #182333, var(--bg));
  padding: 1.1rem 1.25rem 1.5rem;
}
.detail-empty {
  color: var(--muted); margin-top: 3rem; text-align: center;
}
.detail-head {
  display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: flex-start;
  justify-content: space-between; margin-bottom: 1rem;
}
.detail-head h2 {
  margin: 0 0 0.25rem; font-size: 1.15rem; word-break: break-all;
}
.detail-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .list-pane { max-height: 38vh; border-right: 0; border-bottom: 1px solid var(--line); }
  .grid-2 { grid-template-columns: 1fr; }
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.85rem 1rem;
}
.card h3 {
  margin: 0 0 0.55rem; font-size: 0.78rem; text-transform: uppercase;
  letter-spacing: 0.04em; color: var(--muted); font-weight: 600;
}
.kv { display: grid; grid-template-columns: 7.5rem 1fr; gap: 0.25rem 0.5rem; font-size: 0.86rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

.progress {
  height: 8px; background: #0b1016; border-radius: 999px; overflow: hidden;
  margin: 0.55rem 0 0.25rem;
}
.progress > span {
  display: block; height: 100%; background: linear-gradient(90deg, #3a7cc2, var(--accent));
  border-radius: 999px; width: 0%;
}
.files { list-style: none; margin: 0; padding: 0; }
.files li {
  display: flex; gap: 0.45rem; align-items: center; flex-wrap: wrap;
  padding: 0.35rem 0; font-size: 0.88rem; border-bottom: 1px solid #1f2a36;
}
.files li:last-child { border-bottom: 0; }

.sim-form {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 0.65rem 0.75rem;
  align-items: end;
}
.sim-form .field { display: flex; flex-direction: column; gap: 0.25rem; }
.sim-form .field span { font-size: 0.75rem; color: var(--muted); }
.sim-form .field input, .sim-form .field select { width: 100%; }
.sim-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.75rem; }
.hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.55rem; line-height: 1.4; }

.log-box {
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.45;
  background: #0b1016;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.65rem 0.75rem;
  max-height: 280px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Dock player */
.dock {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: var(--dock-h);
  background: #10171fee;
  border-top: 1px solid var(--line);
  backdrop-filter: blur(10px);
  padding: 0.55rem 1rem 0.7rem;
  z-index: 30;
}
.dock-row {
  display: flex; gap: 0.75rem; align-items: center;
  max-width: 1400px; margin: 0 auto 0.35rem;
}
.wave-wrap {
  max-width: 1400px; margin: 0 auto; position: relative;
  height: 72px; cursor: pointer; touch-action: none;
}
.wave-wrap.disabled { cursor: default; opacity: 0.45; pointer-events: none; }
#wave { width: 100%; height: 72px; display: block; border-radius: 8px; background: #070b10; }
.dock .title { font-size: 0.85rem; min-width: 0; flex: 1; }
.dock .title strong {
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.time {
  font-variant-numeric: tabular-nums; font-size: 0.8rem;
  color: var(--muted); min-width: 6.5rem; text-align: right;
}
#vol { width: 90px; }
.err { color: #e08a8a; font-size: 0.78rem; margin: 0.15rem auto 0; max-width: 1400px; min-height: 1em; }
