:root {
  /* Green and gold, Irish without the shamrocks: dark grounds with a hint of
     green, a deep green for what you press and what is playing, and the gold
     of the bodhrán's rim for names. (Amber and goatskin brown until 1.8.0.) */
  --bg:         #0f1411;
  --panel:      #161d18;
  --panel-2:    #1d2620;
  --line:       #2c3b31;
  --text:       #eef0e8;
  --muted:      #9aa89c;
  --accent:     #3daa6d;
  --accent-dim: #2a6b47;
  --on-accent:  #06150c;
  --skin:       #d1b36a;
  --bass:       #3daa6d;
  --treble:     #d1b36a;
  --ghost:      #56625a;
  --radius:    14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 ui-sans-serif, -apple-system, "SF Pro Text", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

.app {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 16px calc(104px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* One row, left-aligned so it lines up with the panels below: icon, title
   and version with the tagline under them, About on the right. */
.head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 2px 2px 6px;
}
.logo {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
}
.brand { flex: 1 1 auto; min-width: 0; }
.head h1 {
  margin: 0;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 9px;
  font-size: 26px;
  line-height: 1.15;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--skin);
}
.version {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.6;
  color: var(--muted);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0 7px;
  font-variant-numeric: tabular-nums;
}
.version:empty { display: none; }
.sub { margin: 3px 0 0; color: var(--muted); font-size: 13.5px; line-height: 1.4; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.panel h2 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.tag {
  font-size: 11px;
  letter-spacing: 0;
  text-transform: none;
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 1px 7px;
  border-radius: 20px;
}
.tag.muted { opacity: 0.75; }

/* No Web MIDI in this browser (Safari, so every iPhone): one short line. */
.panel.unavailable { padding-top: 12px; padding-bottom: 12px; }
.panel.unavailable h2 { margin-bottom: 4px; }
.panel.unavailable .blurb { margin: 0; }

/* ---------- transport ---------- */
.transport {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.play {
  flex: 0 0 auto;
  width: 108px; height: 108px;
  border-radius: 50%;
  border: 2px solid var(--accent-dim);
  background: radial-gradient(circle at 34% 28%, #22302a 0%, #111813 80%);
  color: var(--text);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: border-color .15s, transform .06s, box-shadow .15s;
}
.play:hover { border-color: var(--accent); }
.play:active { transform: scale(0.97); }
.play.hit { box-shadow: 0 0 0 6px rgba(61,170,109,0.18); }
.play.playing { border-color: var(--accent); }

.play-icon {
  width: 0; height: 0;
  border-left: 19px solid var(--accent);
  border-top: 12px solid transparent;
  border-bottom: 12px solid transparent;
  margin-left: 5px;
}
.play.playing .play-icon {
  border: 0;
  width: 17px; height: 19px;
  margin-left: 0;
  background: var(--accent);
  -webkit-mask: linear-gradient(#000 0 0) 0/5px 100% no-repeat,
                linear-gradient(#000 0 0) 100%/5px 100% no-repeat;
          mask: linear-gradient(#000 0 0) 0/5px 100% no-repeat,
                linear-gradient(#000 0 0) 100%/5px 100% no-repeat;
}
.play-label { font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }

.play-col { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.finish { min-width: 5.4em; }
.finish:disabled { opacity: 0.38; cursor: default; }
.finish[aria-pressed="true"] { border-color: var(--accent); color: var(--accent); }

.tempo { flex: 1 1 240px; min-width: 220px; }
.tempo-readout { display: flex; align-items: baseline; gap: 10px; }
#bpm-num {
  width: 3.4em;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  font: 600 40px/1 ui-sans-serif, -apple-system, sans-serif;
  font-variant-numeric: tabular-nums;
  padding: 0 0 2px;
}
#bpm-num:focus { outline: none; border-bottom-color: var(--accent); }
#bpm-num::-webkit-outer-spin-button,
#bpm-num::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#bpm-num { -moz-appearance: textfield; }

.tempo-unit { display: flex; flex-direction: column; color: var(--muted); }
.tempo-unit span { font-size: 14px; }
.tempo-unit small { font-size: 11px; opacity: 0.8; }
/* A tempo you asked for was outside the tune's range: say what it can be. */
.tempo-unit small.warn { color: var(--accent); opacity: 1; }

.tempo-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

.ghost-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
.ghost-btn:hover { border-color: var(--accent-dim); }
.ghost-btn:active { background: #24302a; }

/* ---------- range inputs ---------- */
input[type=range] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 22px;
  background: transparent;
  cursor: pointer;
  margin: 6px 0 0;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 5px; border-radius: 3px; background: var(--panel-2);
  border: 1px solid var(--line);
}
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent);
  border: 0;
  margin-top: -7px;
}
input[type=range]::-moz-range-track {
  height: 5px; border-radius: 3px; background: var(--panel-2);
  border: 1px solid var(--line);
}
input[type=range]::-moz-range-thumb {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--accent); border: 0;
}

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 20px;
  padding: 7px 14px;
  font-size: 14px;
  cursor: pointer;
}
.chip:hover { border-color: var(--accent-dim); }
.chip[aria-checked="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.chip .meter { opacity: 0.6; font-size: 12px; margin-left: 5px; }
.chip[aria-checked="true"] .meter { opacity: 0.7; }

.blurb { margin: 12px 0 0; color: var(--muted); font-size: 13px; }
/* One line under the transport while playing: is the page making sound? */
/* The foot of the app and of Session Buddies: switch between the two. */
.foot .apps { margin: 0 0 8px; font-size: 14px; }
.foot .apps a { color: var(--accent); }
.foot .apps b { color: var(--text); font-weight: 600; background: none; border: 0; padding: 0; }   /* not a key */
.sound-check { margin: -6px 4px 10px; min-height: 1.3em; color: var(--muted); font-size: 12.5px; }
.sound-check:empty { min-height: 0; margin: 0; }

/* ---------- bar grid ---------- */
.grid {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  justify-content: center;
  min-height: 62px;
  padding: 4px 0;
}
.cell {
  flex: 1 1 0;
  min-width: 6px;
  max-width: 56px;   /* a 4-slot polka bar should not look like giant slabs */
  border-radius: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  transition: background .09s, transform .09s, box-shadow .09s;
}
.cell.beat { border-color: #3b4b40; }
.cell.rest  { height: 12px; }
.cell.ghost { height: 18px; background: var(--ghost); }
.cell.t     { height: 28px; background: #6a5f3a; }
.cell.T     { height: 38px; background: var(--treble); }
.cell.d     { height: 36px; background: #2c6145; }
.cell.D     { height: 52px; background: var(--bass); }
.cell.C, .cell.c { height: 24px; background: #3a463f; }
.cell.on {
  transform: translateY(-3px);
  box-shadow: 0 0 0 2px rgba(238,240,232,0.35);
  filter: brightness(1.5);
}

.legend {
  display: flex; flex-wrap: wrap; gap: 14px;
  margin-top: 10px; font-size: 12px; color: var(--muted);
}
.legend span { display: flex; align-items: center; gap: 6px; }
.sw { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.sw.bass { background: var(--bass); }
.sw.treble { background: var(--treble); }
.sw.ghost { background: var(--ghost); }

/* ---------- sliders / rows ---------- */
.sliders {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px 22px;
}
.sliders.one { grid-template-columns: 1fr; }
.sliders label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  position: relative;
}
.sliders output {
  display: block;
  font-size: 12px;
  color: var(--text);
  opacity: 0.8;
  font-variant-numeric: tabular-nums;
}

.row {
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  align-items: center; margin-top: 12px;
}
.row:first-child { margin-top: 0; }
label.inline {
  display: inline-flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--muted);
}
select, input.num {
  background: var(--panel-2);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 5px 8px;
  font: inherit;
  font-size: 13px;
}
input.num { width: 4.5em; font-variant-numeric: tabular-nums; }
input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }

.hidden { display: none; }

.how { margin-top: 14px; font-size: 13px; color: var(--muted); }
.how summary { cursor: pointer; color: var(--skin); }
.how ol { margin: 10px 0 0; padding-left: 20px; }
.how li { margin-bottom: 5px; }
.how b { color: var(--text); font-weight: 600; }
.note { font-size: 12px; opacity: 0.85; }

.foot { text-align: center; color: var(--muted); font-size: 12px; }
.foot b {
  color: var(--text); font-weight: 500;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px;
}

/* Phones: Play and the tempo share one row instead of Play sitting alone
   above it, which pushed everything else down the page. */
@media (max-width: 420px) {
  .transport { flex-wrap: nowrap; gap: 14px; }
  .play { width: 78px; height: 78px; }
  .finish { padding: 5px 8px; font-size: 12.5px; min-width: 78px; }
  .tempo { flex: 1 1 0; min-width: 0; }
  #bpm-num { font-size: 32px; width: 2.3em; }
}

/* ---------- about ---------- */
.about-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
}
.info-icon { width: 15px; height: 15px; }
.about-version { margin-top: 18px; }
.about-body a { color: var(--accent); }

@media (max-width: 420px) {
  .head { gap: 11px; }
  .logo { width: 38px; height: 38px; border-radius: 10px; }
  .head h1 { font-size: 22px; }
}

dialog.about {
  width: min(640px, calc(100vw - 32px));
  max-height: min(84vh, 760px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  overflow: hidden;
}
dialog.about::backdrop {
  background: rgba(4, 8, 6, 0.72);
  backdrop-filter: blur(3px);
}

.about-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
  position: sticky;
  top: 0;
}
.about-head h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
  color: var(--skin);
}

.icon-btn {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover { color: var(--text); border-color: var(--accent-dim); }

.about-body {
  padding: 4px 18px 22px;
  overflow-y: auto;
  max-height: calc(min(84vh, 760px) - 65px);
  -webkit-overflow-scrolling: touch;
}
.about-body h3 {
  margin: 22px 0 8px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--accent);
}
.about-body p, .about-body li { font-size: 14px; color: #dfe3da; }
.about-body p { margin: 0 0 10px; }
.about-body ul, .about-body ol { margin: 0 0 10px; padding-left: 20px; }
.about-body li { margin-bottom: 6px; }
.about-body b { color: var(--text); font-weight: 600; }

.about-body .lede {
  margin-top: 18px;
  font-size: 15px;
  color: var(--text);
  line-height: 1.55;
}
.about-body .hint { font-size: 12.5px; color: var(--muted); }
.about-body .keys b {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  font-weight: 500;
}

.tune-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 10px;
}
.tune-row {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 12px;
  align-items: baseline;
  padding: 9px 12px;
  background: var(--panel);
}
.tune-row .n { font-size: 14px; font-weight: 600; color: var(--text); }
.tune-row .m {
  font-size: 12px; color: var(--muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
}
.tune-row .b { grid-column: 1 / -1; font-size: 12.5px; color: var(--muted); }

@media (max-width: 460px) {
  .tune-row { grid-template-columns: 1fr; }
  .tune-row .m { text-align: left; }
  .about-body { padding: 4px 14px 20px; }
  .about-head { padding: 14px; }
}

/* ---------- rhythm mode ---------- */
.modes {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.mode {
  flex: 1 1 0;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.mode:hover { color: var(--text); }
.mode[aria-checked="true"] {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 600;
}
.mode-desc { margin: 10px 0 0; min-height: 2.6em; }

/* a control that simple mode has taken over */
/* ---------- Basic / Advanced ---------- */
.view-bar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: -4px 0 -2px; }
.view-switch {
  display: inline-flex; gap: 3px; padding: 3px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 9px;
}
.view-switch button {
  padding: 5px 14px; border: 0; border-radius: 6px; background: transparent;
  color: var(--muted); font: inherit; font-size: 13px; cursor: pointer;
}
.view-switch button:hover { color: var(--text); }
.view-switch button[aria-checked="true"] { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.view-note { font-size: 12.5px; color: var(--muted); flex: 1 1 12em; }

.app.basic .adv { display: none; }
.app.basic #midi-panel.unavailable { display: none; }   /* nothing to offer here */
.adv-hint { display: none; }
.app.basic .adv-hint {
  display: block; width: 100%; margin-top: 12px; padding: 8px 10px;
  background: transparent; border: 1px dashed var(--line); border-radius: 8px;
  color: var(--muted); font: inherit; font-size: 12.5px; text-align: left; cursor: pointer;
}
.app.basic .adv-hint:hover { border-color: var(--accent-dim); color: var(--text); }
.adv-hint b { color: var(--accent); font-weight: 600; }
.adv-hint .changed { color: var(--accent); }
.app.basic #midi-panel h2 { margin-bottom: 0; }

.sliders label.is-off { opacity: 0.38; }
.sliders label.is-off input[type=range] { cursor: not-allowed; }

.inline-hint { font-size: 12px; color: var(--muted); }

/* ---------- pinned bar ---------- */
.mini {
  position: fixed;
  left: 50%;
  bottom: 0;
  width: min(720px, 100%);
  transform: translate(-50%, 110%);
  visibility: hidden;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: rgba(22, 29, 24, 0.96);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
  z-index: 10;
  transition: transform 0.2s ease, visibility 0.2s;
}
.mini.show { transform: translate(-50%, 0); visibility: visible; }
.mini-play {
  flex: 0 0 auto;
  width: 48px; height: 48px;
  border-radius: 50%;
  border: 2px solid var(--accent-dim);
  background: #121914;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.mini-play.playing { border-color: var(--accent); }
.mini-play.hit { box-shadow: 0 0 0 5px rgba(61,170,109,0.18); }
.mini-play .play-icon {
  width: 0; height: 0;
  border-left: 14px solid var(--accent);
  border-top: 9px solid transparent;
  border-bottom: 9px solid transparent;
  margin-left: 4px;
}
.mini-play.playing .play-icon {
  border: 0; margin-left: 0;
  width: 13px; height: 15px;
  background: var(--accent);
  -webkit-mask: linear-gradient(#000 0 0) 0/4px 100% no-repeat,
                linear-gradient(#000 0 0) 100%/4px 100% no-repeat;
          mask: linear-gradient(#000 0 0) 0/4px 100% no-repeat,
                linear-gradient(#000 0 0) 100%/4px 100% no-repeat;
}
.mini-info {
  flex: 1 1 auto; min-width: 0;
  display: flex; flex-direction: column; line-height: 1.25;
}
.mini-tune { font-size: 12px; color: var(--muted); }
.mini-tempo { font-size: 14px; color: var(--muted); }
.mini-tempo b { font-size: 18px; color: var(--text); font-variant-numeric: tabular-nums; }
