:root {
  --bg: #1c1c1e; --fg: #f5f5f7; --dim: #8a8a8e;
  --ok: #4cd964; --warn: #ff9f0a; --bad: #ff453a;
  --acc: #0a84ff; --chal: #bf5af2; --gold: #ffd60a;
  --row: #2c2c2e;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
}
#app { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; }

/* top bar */
.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 12px 8px;
  background: #111113; position: sticky; top: 0; z-index: 10;
}
.spacer { flex: 1; }
.chip {
  border: 0; border-radius: 10px; padding: 9px 12px; min-height: 40px;
  background: #2a2a2c; color: var(--fg); font-weight: 600; font-size: 14px;
  cursor: pointer;
}
.chip.go { background: var(--ok); color: #0a2a12; }
.chip.on { background: var(--acc); }
.chip:active { filter: brightness(1.2); }
.timer { font-weight: 700; font-size: 15px; min-width: 60px; text-align: right; }

/* screen */
.screen {
  flex: 1; width: 100%; max-width: 560px; margin: 0 auto;
  padding: 14px 16px calc(env(safe-area-inset-bottom) + 24px);
  display: flex; flex-direction: column; align-items: center;
}
.title { font-size: clamp(28px, 8vw, 40px); font-weight: 800; margin: 6px 0 4px; text-align: center; }
.accent { color: var(--acc); }
.muted { color: var(--dim); }
.center { text-align: center; }
.small { font-size: 12px; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
.tip { max-width: 460px; line-height: 1.4; }
.foot { margin-top: 22px; }

.section { color: var(--dim); font-weight: 700; font-size: 12px; letter-spacing: .05em; margin: 26px 0 8px; align-self: flex-start; }
.section.chal { color: var(--chal); }

/* menu rows */
.row {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 12px;
  border: 0; border-radius: 12px; background: var(--row); color: var(--fg);
  padding: 14px 16px; margin: 4px 0; min-height: 52px; cursor: pointer; text-align: left;
}
.row:active { filter: brightness(1.3); }
.row b { font-size: 15px; }
.row .names, .row .mono { color: var(--dim); font-size: 12px; text-align: right; }
.chalrow { background: #3a2a4e; }
.libbtn { background: #24303a; }

/* chord library grid */
.libgrid {
  width: 100%; display: grid; gap: 8px; margin: 4px 0 8px;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
}
.libcell {
  border: 0; border-radius: 10px; background: var(--row); color: var(--fg);
  padding: 8px 4px 6px; display: flex; flex-direction: column; align-items: center;
  gap: 2px; cursor: pointer;
}
.libcell:active { filter: brightness(1.3); }
.libname { font-size: 13px; font-weight: 600; }
.libnum { font-size: 12px; font-weight: 700; color: var(--gold); }
.installrow { background: #2a3a2c; }

/* library controls */
.libholder { width: 100%; }
.libctl { width: 100%; display: flex; gap: 10px; align-items: center; margin: 8px 0 4px; flex-wrap: wrap; }
.keywrap { display: inline-flex; align-items: center; gap: 4px; }
.search {
  flex: 1; min-width: 140px; border: 0; border-radius: 10px; padding: 10px 12px;
  background: var(--row); color: var(--fg); font-size: 15px; min-height: 42px;
}
.search::placeholder { color: var(--dim); }
.keysel {
  border: 0; border-radius: 8px; padding: 8px 10px; background: var(--row);
  color: var(--fg); font-size: 15px; font-weight: 600;
}

/* number system block on the chord card */
.numbers {
  width: 100%; max-width: 460px; background: #17171a; border: 1px solid #2a2a2c;
  border-radius: 14px; padding: 12px 14px; margin: 6px 0 4px; text-align: center;
}
.numhead { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.bignum { font-size: 40px; font-weight: 800; color: var(--gold); line-height: 1.1; }
.acrossline { margin-top: 6px; opacity: .85; }

/* iOS install sheet */
.overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(0,0,0,.6);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.sheet {
  background: #232326; border-radius: 16px; padding: 20px; max-width: 340px;
  display: flex; flex-direction: column; gap: 10px; text-align: center;
}
.sheet h2 { margin: 0; }
.sheet .go { align-self: center; }

/* hero / start */
.hero { display: flex; flex-direction: column; align-items: center; gap: 14px; margin-top: 12vh; }
.bigbtn {
  border: 0; border-radius: 16px; padding: 20px 28px; font-size: 20px; font-weight: 700;
  background: var(--acc); color: #fff; cursor: pointer; margin-top: 10px;
}
.bigbtn:disabled { opacity: .6; }

/* readouts */
.heard { font-size: 17px; margin: 10px 0 6px; min-height: 24px; }
.board { color: var(--gold); font-weight: 700; font-size: 15px; margin: 8px 0; text-align: center; }

/* bars */
.bar { width: 100%; max-width: 380px; background: var(--row); border-radius: 8px; overflow: hidden; margin: 8px 0; }
.bar.wide { height: 14px; }
.bar.thin { height: 5px; }
.bar.timer { height: 18px; }
.fill { height: 100%; width: 0; background: var(--ok); transition: width 45ms linear; }

.diagramwrap, .gridwrap { margin: 8px 0; }
.controls { display: flex; gap: 10px; margin: 14px 0 4px; flex-wrap: wrap; justify-content: center; }

/* debug / chroma panel */
.debug {
  position: sticky; bottom: 0; z-index: 9;
  background: #0d0d0f; border-top: 1px solid #2a2a2c;
  padding: 10px 12px calc(env(safe-area-inset-bottom) + 10px);
}
.chroma { display: flex; align-items: flex-end; gap: 4px; height: 84px; }
.ccol { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; height: 100%; }
.cfill { width: 70%; background: var(--acc); border-radius: 3px 3px 0 0; height: 0; transition: height 60ms linear; }
.clab { font-size: 10px; color: var(--dim); margin-top: 3px; }
.debug p { margin: 6px 0 0; color: var(--dim); }

@media (min-width: 480px) {
  .cfill { width: 60%; }
}
