/* LEO Lab — compact dark theme, no framework (leo-web pattern). */
:root {
  --bg: #0d1117; --panel: #161b22; --line: #30363d;
  --text: #e6edf3; --dim: #8b949e;
  --ok: #2dbe60; --bad: #f85149; --warn: #d29922; --accent: #2f81f7;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  min-height: 100vh; display: flex; flex-direction: column;
}
#topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
  background: var(--panel); position: sticky; top: 0;
}
.brand { font-size: 1.05em; letter-spacing: 0.02em; }
.spacer { flex: 1; }
main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 16px; }
footer { padding: 10px 16px; border-top: 1px solid var(--line); font-size: 0.8em; }

.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 8px; padding: 16px 18px; margin-bottom: 18px;
}
.card.narrow { max-width: 420px; margin: 48px auto; }
.row { display: flex; align-items: center; gap: 10px; }
h2 { margin: 0 0 12px; font-size: 1.15em; }
.muted { color: var(--dim); }
.err { color: var(--bad); min-height: 1em; margin: 6px 0; }
.ok { color: var(--ok); } .bad { color: var(--bad); } .warn { color: var(--warn); }

label { display: block; margin: 10px 0; font-size: 0.92em; color: var(--dim); }
input, select, textarea {
  display: block; width: 100%; margin-top: 4px; padding: 7px 9px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--line); border-radius: 6px; font: inherit;
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.86em; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 14px; }

fieldset { border: 1px solid var(--line); border-radius: 6px; margin: 12px 0; padding: 8px 12px; }
legend { color: var(--dim); font-size: 0.85em; padding: 0 6px; }
.ds-row { display: flex; gap: 8px; align-items: baseline; margin: 6px 0; color: var(--text); }
.ds-row input { width: auto; display: inline; margin: 0; }
.ds-row.blocked { opacity: 0.6; }
.pill {
  display: inline-block; padding: 0 7px; border-radius: 10px;
  background: var(--line); color: var(--dim); font-size: 0.75em; margin-left: 4px;
}
.pill.live { background: var(--ok); color: #04260f; font-weight: 600; }

button {
  background: var(--accent); color: #fff; border: 0; border-radius: 6px;
  padding: 8px 16px; font: inherit; cursor: pointer;
}
button.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
button:disabled { opacity: 0.55; cursor: default; }

table { width: 100%; border-collapse: collapse; font-size: 0.86em; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--dim); font-weight: 500; }
td.params { max-width: 220px; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
td.params .full { display: none; }
td.params.expanded { max-width: none; overflow: visible; white-space: normal; }
td.params.expanded .short { display: none; }
td.params.expanded .full {
  display: block; margin: 2px 0; padding: 6px 8px;
  white-space: pre-wrap; word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em;
  background: rgba(127, 127, 127, 0.08); border-radius: 6px;
}
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.92em; }

.algo { margin: 8px 0 14px; }
.algo > strong { display: block; margin-bottom: 4px; }
.algo table { max-width: 760px; }

.param-docs { margin: 10px 0; }
.param-docs summary { cursor: pointer; color: var(--dim); font-size: 0.9em; }
.param-docs table { margin-top: 8px; }
.param-docs td.note { white-space: normal; max-width: 360px; color: var(--dim); }
tr.param-inactive { opacity: 0.45; }
.subform { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; margin: 8px 0 14px; }
button.sm { padding: 3px 9px; font-size: 0.82em; }

/* ============ v0.28.0 overhaul: tabs, param editor, scoreboard v2 ============ */

#tabs {
  max-width: 1080px; margin: 0 auto; padding: 8px 16px 0;
  display: flex; gap: 18px; border-bottom: 1px solid var(--line);
}
#tabs a { color: var(--dim); text-decoration: none; padding: 6px 2px; }
#tabs a.active { color: var(--text); border-bottom: 2px solid var(--accent); }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 8px 0; }
.row.spread { justify-content: space-between; }
button.sm { font-size: 0.8em; padding: 2px 8px; }
button.ghost { background: transparent; border: 1px solid var(--line); color: var(--text); }

.filterbar { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin: 8px 0 12px; }
.chip {
  border: 1px solid var(--line); background: transparent; color: var(--text);
  border-radius: 999px; padding: 2px 10px; font-size: 0.8em; cursor: pointer;
}
.chip.active { background: var(--accent); border-color: transparent; color: #fff; }

/* param editor */
.pe-table { width: 100%; }
.pe-table .note { white-space: normal; max-width: 320px; font-size: 0.85em; }
.pe-row.changed td:first-child { border-left: 3px solid var(--accent); }
.pe-row .pe-reset { visibility: hidden; }
.pe-row.changed .pe-reset { visibility: visible; }
.pe-row.param-inactive { opacity: 0.4; }
.pe-val input, .pe-val select { width: 110px; }
.pe-meta { font-size: 0.82em; }
.pe-raw { margin-top: 8px; }
.pe-raw textarea { width: 100%; font-family: ui-monospace, monospace; font-size: 0.85em; }
.pe-extra-row input { width: 110px; }

/* scoreboard v2 */
.sb .sb-row { cursor: pointer; }
.sb .sb-row:hover td { background: rgba(127, 127, 127, 0.06); }
.sb-detail { display: none; }
.sb-row.open + .sb-detail { display: table-row; }
.sb-detail > td { background: rgba(127, 127, 127, 0.04); }
.sb-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px; padding: 8px 0;
}
.sb-grid h4 { margin: 0 0 6px; }
.sb-grid table { font-size: 0.82em; }
.sb-err pre, .pre {
  white-space: pre-wrap; word-break: break-word; background: var(--panel);
  padding: 8px; border-radius: 6px; font-size: 0.8em; max-height: 220px; overflow-y: auto;
}
.gt { list-style: none; padding: 0; margin: 0; font-size: 0.85em; }
.gt li { margin-bottom: 4px; }
.delta-pos { color: var(--ok); }
.delta-neg { color: var(--bad); }
.count-chip {
  display: inline-block; min-width: 16px; text-align: center;
  background: var(--accent); color: #fff; border-radius: 999px;
  font-size: 0.75em; padding: 0 4px;
}

/* diff table */
.diff { font-size: 0.85em; margin: 8px 0; }
.diff .diff-add td { color: var(--ok); }
.diff .diff-del td { color: var(--bad); text-decoration: line-through; }
.diff .diff-chg td:first-child { color: var(--warn); }

/* modal */
dialog#lab-modal {
  background: var(--panel); color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; padding: 18px 20px; max-width: min(680px, 92vw);
  max-height: 85vh; overflow-y: auto;
}
dialog#lab-modal::backdrop { background: rgba(0, 0, 0, 0.55); }

/* datasets */
.ds-form label { display: block; margin: 6px 0; }
.ds-form textarea { width: 100%; font-family: ui-monospace, monospace; font-size: 0.85em; }
.ds-per-row label { display: inline-flex; gap: 4px; align-items: center; font-size: 0.85em; }
