:root {
  --bg: #f1f5ec;
  --panel: #fbfcf8;
  --ink: #22302a;
  --muted: #6b7a72;
  --line: #c9d3c6;
  --S: #7a4fc0;
  --K: #1d8a6c;
  --I: #c48600;
  --gold: #e0a42a;
  --flow: #2a7fd4;
  --result: #8a6bd1;
  --skip: #a7b1ab;
  --rules: #d48a2a;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  height: 100vh;
  display: grid;
  grid-template-columns: 300px 1fr;
  grid-template-rows: auto 1fr auto;
  font: 14px/1.45 system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
header {
  grid-column: 1 / 3;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
header .sub, .help { color: var(--muted); }
.help { margin-left: auto; font-size: 13px; }
kbd { font: 12px ui-monospace, monospace; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; background: #fff; }
nav button, .bar button, .seg button, #suggest button {
  font: inherit;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 6px;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
}
nav button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
aside {
  padding: 0.8rem 1rem;
  border-right: 1px solid var(--line);
  background: var(--panel);
  overflow: auto;
}
aside h3 { margin: 0.8rem 0 0.3rem; font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
aside p { margin: 0.2rem 0 0.6rem; color: var(--muted); font-size: 13px; }
.def { padding: 0.45rem 0.5rem; border-radius: 8px; margin: 0 -0.5rem 0.2rem; }
.def.hot { background: #eef3e6; }
.def code { font: 12.5px ui-monospace, monospace; display: block; }
.def .why { font-size: 12px; color: var(--muted); }
.def .why b { font-weight: 600; color: var(--ink); }
.seg { display: inline-flex; margin-top: 0.25rem; }
.seg button { border-radius: 0; padding: 0.05rem 0.45rem; font-size: 12px; margin-left: -1px; }
.seg button:first-child { border-radius: 6px 0 0 6px; }
.seg button:last-child { border-radius: 0 6px 6px 0; }
.seg button.on { color: #fff; }
.seg button.on.l0 { background: var(--skip); border-color: var(--skip); }
.seg button.on.l1 { background: var(--result); border-color: var(--result); }
.seg button.on.l2 { background: var(--flow); border-color: var(--flow); }
.seg button.on.l3 { background: var(--rules); border-color: var(--rules); }
.seg button.ghost { box-shadow: inset 0 0 0 2px var(--gold); }
main { position: relative; overflow: hidden; }
#stage { width: 100%; height: 100%; display: block; }
#stage .node { cursor: pointer; }
#ring {
  position: absolute;
  pointer-events: none;
}
#ring svg path { pointer-events: stroke; }
#ring {
  transform: translate(-50%, -50%);
}
#ring .tip {
  position: absolute;
  left: calc(100% + 2px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  background: var(--ink);
  color: #fff;
  font-size: 12.5px;
  padding: 0.3rem 0.55rem;
  border-radius: 6px;
}
#ring .tip i { color: #c8d4cc; font-style: normal; }
#suggest {
  position: absolute;
  right: 1rem;
  top: 1rem;
  background: #fff;
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 0.5rem 0.7rem;
  box-shadow: 0 4px 16px #0001;
  font-size: 13px;
  max-width: 300px;
}
footer {
  grid-column: 1 / 3;
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 0.5rem 1rem 0.7rem;
}
#caption { min-height: 2.9em; font-size: 15px; }
#caption code { font: 13.5px ui-monospace, monospace; background: #eef3e6; padding: 0 3px; border-radius: 3px; }
#caption .lvl { font-size: 12px; color: #fff; border-radius: 4px; padding: 0 5px; margin-right: 0.4rem; }
.bar { display: flex; gap: 0.4rem; align-items: center; }
#beats { flex: 1; display: flex; gap: 2px; align-items: stretch; height: 22px; }
#beats div {
  border-radius: 4px;
  min-width: 10px;
  cursor: pointer;
  opacity: 0.45;
  position: relative;
}
#beats div.done, #beats div.cur { opacity: 1; }
#beats div.cur { outline: 2px solid var(--ink); outline-offset: 1px; }
#beats div .ticks { position: absolute; inset: 0; display: flex; justify-content: space-evenly; align-items: center; }
#beats div .ticks span { width: 2px; height: 8px; background: #fff8; border-radius: 1px; }
#count { color: var(--muted); font-size: 13px; min-width: 15em; text-align: right; }
.l0bg { background: var(--skip); }
.l1bg { background: var(--result); }
.l2bg { background: var(--flow); }
.l3bg { background: var(--rules); }
#beats .playhead { position: absolute; top: -3px; bottom: -3px; width: 2px; background: var(--ink); border-radius: 1px; }
