:root {
  --bg: #0a0c12;
  --panel: #11151f;
  --panel2: #161b28;
  --line: #232a3a;
  --text: #e6e9f0;
  --muted: #8b93a7;
  --accent: #59d0ff;
  --rh: #4bd07a;
  --lh: #f0a03c;
  --warn: #f0a03c;
  --danger: #e0575a;
  --radius: 9px;
}

* { box-sizing: border-box; }

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

/* ------------------------------------------------------------------ topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.title { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.title h1 { font-size: 17px; margin: 0; letter-spacing: .3px; }
.title .sub { color: var(--muted); font-size: 12.5px; white-space: nowrap; }
.topbar-right { display: flex; gap: 8px; align-items: center; }

.badge {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--panel2);
  white-space: nowrap;
}
.badge.warn { color: #0e1117; background: var(--warn); border-color: transparent; font-weight: 600; }
.badge.ok { color: #0e1117; background: var(--rh); border-color: transparent; font-weight: 600; }

/* -------------------------------------------------------------------- layout */

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 9px 16px;
  background: #3a2a10;
  border-bottom: 1px solid #6b4c17;
  color: #ffd9a3;
  font-size: 12.5px;
}
.banner strong { color: #ffb84d; }
.banner span { flex: 1; min-width: 220px; }
.banner button { background: var(--warn); color: #2a1c06; border-color: transparent; font-weight: 650; }
.banner.hidden { display: none; }

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 372px;
  flex: 1 1 auto;
  min-height: 0;
}

.stage { display: flex; flex-direction: column; min-width: 0; }
#roll { flex: 1 1 auto; width: 100%; min-height: 0; display: block; cursor: pointer; }

/* ----------------------------------------------------------------- transport */

.transport {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 14px;
  border-top: 1px solid var(--line);
  background: var(--panel);
}

button {
  font: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 7px 13px;
  cursor: pointer;
}
button:hover { border-color: #38445c; }
button.primary { background: var(--accent); color: #08202b; border-color: transparent; font-weight: 650; }
button.primary:hover { filter: brightness(1.08); }
button.small { padding: 5px 10px; font-size: 12.5px; }
button.danger { color: var(--danger); }

.ctl { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); min-width: 150px; }
.ctl b { color: var(--text); font-variant-numeric: tabular-nums; }
.ctl.narrow { min-width: auto; }
.pair { display: flex; gap: 4px; }

input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=number], select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px 7px;
}
input[type=number] { width: 62px; }
input.tiny { width: 52px; }

.seg { display: flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 7px 12px; background: var(--panel2); font-size: 13px; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--accent); color: #08202b; font-weight: 650; }

.chk { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.chk input { accent-color: var(--accent); }

.pos {
  font: 12px ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--muted);
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------- panel */

.panel {
  border-left: 1px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.tabs { display: flex; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
}
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }

.tabpane { display: none; padding: 14px; overflow-y: auto; }
.tabpane.on { display: block; }

.panel h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); margin: 18px 0 8px; }
.panel h2:first-child { margin-top: 0; }
.muted { color: var(--muted); font-size: 12.5px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; font-size: 12.5px; color: var(--muted); }
ul.tight, ol.tight { padding-left: 20px; margin: 6px 0; }
ul.tight li, ol.tight li { margin: 4px 0; }
code { font: 11.5px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--panel2); padding: 1px 5px; border-radius: 4px; }
kbd {
  font: 11px ui-monospace, monospace; background: var(--panel2);
  border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px;
}

/* --------------------------------------------------------------------- plan */

.drills { list-style: none; margin: 8px 0; padding: 0; }
.drills li {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 9px; margin-bottom: 5px;
  background: var(--panel2); border: 1px solid var(--line); border-radius: 7px;
}
.drills li.done { opacity: .5; }
.drills li.current { border-color: var(--accent); }
.drills .name { flex: 1; font-size: 13px; }
.drills .name small { color: var(--muted); display: block; font-size: 11px; }
.drills input { accent-color: var(--rh); }

/* ---------------------------------------------------------------------- map */

.mapgrid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; margin: 8px 0 14px; }
.mapgrid button {
  padding: 7px 0; font-size: 11.5px; border-radius: 6px;
  font-variant-numeric: tabular-nums; color: #0d1017; font-weight: 600; border: 1px solid transparent;
}
.mapgrid button.playing { outline: 2px solid var(--accent); outline-offset: 1px; }

.groups .group { border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; margin-bottom: 6px; background: var(--panel2); }
.groups .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 7px; vertical-align: -1px; }
.groups .bars { font-size: 12px; color: var(--muted); }
.groups pre { margin: 6px 0 0; font: 11px ui-monospace, monospace; color: var(--text); white-space: pre-wrap; word-break: break-word; }
.groups button { margin-top: 6px; }

/* -------------------------------------------------------------------- notes */

#notesArea {
  width: 100%; height: 300px; resize: vertical;
  font: 12px/1.65 ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre; overflow-wrap: normal; overflow-x: auto; tab-size: 2;
}
.status { font-size: 12px; margin: 8px 0; min-height: 18px; color: var(--muted); }
.status.err { color: var(--danger); }
.status.ok { color: var(--rh); }

/* ------------------------------------------------------------------- import */

.drop {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  height: 120px;
  border: 1.5px dashed var(--line); border-radius: var(--radius);
  color: var(--muted); font-size: 12.5px; text-align: center;
}
.drop.over { border-color: var(--accent); background: rgba(89, 208, 255, .06); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

pre.keys {
  font: 12px/1.5 ui-monospace, monospace; background: var(--panel2);
  border: 1px solid var(--line); border-radius: 7px; padding: 9px; color: var(--text); margin: 6px 0;
}

@media (max-width: 900px) {
  main { grid-template-columns: 1fr; grid-template-rows: minmax(240px, 1fr) minmax(0, 46%); }
  .panel { border-left: 0; border-top: 1px solid var(--line); }
}
