/* Fonts: Be Vietnam Pro (SIL OFL) for text, Dimbo (CC BY-SA 3.0, Jayvee D. Enaguas) for headings */
@font-face { font-family: "Be Vietnam Pro"; src: url("../fonts/BeVietnamPro-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Be Vietnam Pro"; src: url("../fonts/BeVietnamPro-Medium.ttf") format("truetype"); font-weight: 500; font-style: normal; font-display: swap; }
@font-face { font-family: "Be Vietnam Pro"; src: url("../fonts/BeVietnamPro-SemiBold.ttf") format("truetype"); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: "Be Vietnam Pro"; src: url("../fonts/BeVietnamPro-Bold.ttf") format("truetype"); font-weight: 700; font-style: normal; font-display: swap; }
@font-face { font-family: "Be Vietnam Pro"; src: url("../fonts/BeVietnamPro-ExtraBold.ttf") format("truetype"); font-weight: 800; font-style: normal; font-display: swap; }
@font-face { font-family: "Dimbo"; src: url("../fonts/Dimbo-Regular.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }

:root {
  --bg: #f3f5f2;
  --surface: #ffffff;
  --surface-2: #eef1ed;
  --surface-3: #e3e8e2;
  --text: #1c2a33;
  --muted: #66737c;
  --line: #dfe4de;
  --accent: #9dd49f;
  --accent-strong: #86c789;
  --accent-ink: #2c7a4b;
  --accent-soft: #e2f3e2;
  --on-accent: #173322;
  --on-cell: #ffffff;
  --navy: #263a48;
  --c-hh: #c99418;
  --c-hh-soft: #fbf0d4;
  --c-sn: #9dd49f;
  --c-sn-soft: #e2f3e2;
  --c-sn-ink: #3f8a49;
  --c-bd: #2f6ea8;
  --c-bd-soft: #dceaf7;
  --c-tom: #8a5cc2;
  --c-tom-soft: #ece3f7;
  --c-stk: #66737c;
  --c-stk-soft: #e8ecef;
  --playhead: rgba(157, 212, 159, 0.3);
  --shadow: 0 1px 2px rgba(20, 35, 30, 0.06), 0 4px 16px rgba(20, 35, 30, 0.06);
  --radius: 16px;
  --radius-sm: 10px;
  --transport-h: 132px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101518;
    --surface: #182026;
    --surface-2: #1f2930;
    --surface-3: #29353e;
    --text: #e6ecef;
    --muted: #93a1aa;
    --line: #2a353d;
    --accent: #9dd49f;
    --accent-strong: #b5e0b6;
    --accent-ink: #9dd49f;
    --accent-soft: #233a28;
    --on-accent: #173322;
    --on-cell: #0d1a12;
    --navy: #0c1216;
    --c-hh: #e2b13c;
    --c-hh-soft: #3a3220;
    --c-sn: #9dd49f;
    --c-sn-soft: #233a28;
    --c-sn-ink: #9dd49f;
    --c-bd: #5d9be0;
    --c-bd-soft: #1d2f43;
    --c-tom: #ae86e3;
    --c-tom-soft: #2f2640;
    --c-stk: #93a1aa;
    --c-stk-soft: #26313a;
    --playhead: rgba(157, 212, 159, 0.22);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #101518;
  --surface: #182026;
  --surface-2: #1f2930;
  --surface-3: #29353e;
  --text: #e6ecef;
  --muted: #93a1aa;
  --line: #2a353d;
  --accent: #9dd49f;
  --accent-strong: #b5e0b6;
  --accent-ink: #9dd49f;
  --accent-soft: #233a28;
  --on-accent: #173322;
  --on-cell: #0d1a12;
  --navy: #0c1216;
  --c-hh: #e2b13c;
  --c-hh-soft: #3a3220;
  --c-sn: #9dd49f;
  --c-sn-soft: #233a28;
  --c-sn-ink: #9dd49f;
  --c-bd: #5d9be0;
  --c-bd-soft: #1d2f43;
  --c-tom: #ae86e3;
  --c-tom-soft: #2f2640;
  --c-stk: #93a1aa;
  --c-stk-soft: #26313a;
  --playhead: rgba(157, 212, 159, 0.22);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent-ink); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; text-decoration: none; color: inherit; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; flex: none; display: block; }
.brand-name { font-family: "Dimbo", "Be Vietnam Pro", sans-serif; font-weight: 400; font-size: 19px; line-height: 1.1; white-space: nowrap; }
.brand-name small { display: block; font-family: "Be Vietnam Pro", system-ui, sans-serif; font-weight: 500; font-size: 11px; color: var(--muted); margin-top: 0; }
.topbar .spacer { flex: 1; }
.top-actions { display: flex; gap: 6px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text);
  font-weight: 600; font-size: 14px; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-strong); }
.btn.icon { width: 40px; padding: 0; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn[disabled] { opacity: .4; pointer-events: none; }
.btn svg { width: 18px; height: 18px; flex: none; }
.btn.sm { min-height: 32px; padding: 0 10px; font-size: 13px; }
.btn.sm.icon { width: 32px; }
@media (max-width: 560px) {
  .btn .lbl-wide { display: none; }
  .top-actions .btn:not(.icon) { width: 40px; padding: 0; }
  .brand-name small { display: none; }
}

/* ---------- layout ---------- */
main {
  max-width: 1120px; margin: 0 auto;
  padding: 16px max(16px, env(safe-area-inset-right)) calc(var(--transport-h) + 28px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: grid; gap: 16px;
}
/* studio: video and details side by side at the top */
.top-cards { display: grid; gap: 16px; align-items: start; min-width: 0; }
.top-cards > * { min-width: 0; }
@media (min-width: 900px) { .top-cards { grid-template-columns: 1fr 1fr; } }
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
  min-width: 0;
}
.card-pad { padding: 16px; }
@media (min-width: 700px) { .card-pad { padding: 20px 24px; } }

.groove-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.groove-title { font-family: "Dimbo", "Be Vietnam Pro", sans-serif; font-size: 24px; font-weight: 400; line-height: 1.15; margin: 0; overflow-wrap: anywhere; }
.groove-title.placeholder { color: var(--muted); }
.groove-meta { color: var(--muted); font-size: 13px; }
.groove-head .grid-toggle { margin-left: auto; align-self: center; min-height: 32px; }
.groove-head .grid-toggle + .grid-toggle { margin-left: 0; }
.groove-head .seg.voices { align-self: center; }
.groove-comment { color: var(--muted); font-size: 14px; margin: 6px 0 0; white-space: pre-wrap; }
.notation { color: var(--text); margin-top: 8px; display: grid; gap: 6px; position: relative; }
.notation.scrolling { overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.notation .playhead { fill: var(--playhead); }

/* ---------- editor toolbar ---------- */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
@media (min-width: 700px) { .toolbar { padding: 14px 24px; } }
.field { display: flex; align-items: center; gap: 8px; }
.field > .label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.select {
  appearance: none; -webkit-appearance: none;
  min-height: 36px; padding: 0 30px 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2366737c' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  font-weight: 600; font-size: 14px;
}
.seg { display: inline-flex; background: var(--surface-2); border-radius: 999px; padding: 3px; border: 1px solid var(--line); overflow-x: auto; max-width: 100%; scrollbar-width: none; }
.seg::-webkit-scrollbar { display: none; }
.seg button {
  border: 0; background: transparent; border-radius: 999px;
  min-height: 30px; padding: 0 11px; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.seg .lbl-short { display: none; }
@media (max-width: 560px) { .seg .lbl-wide { display: none; } .seg .lbl-short { display: inline; } .seg button { padding: 0 9px; } }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.stepper { display: inline-flex; align-items: center; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; }
.stepper button { border: 0; background: transparent; width: 34px; height: 34px; border-radius: 999px; display: grid; place-items: center; }
.stepper button:hover { background: var(--surface-3); }
.stepper svg { width: 16px; height: 16px; }
.stepper output { min-width: 22px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.toggle {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2);
  font-weight: 600; font-size: 13px; color: var(--muted);
}
.toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent-ink); }
.toolbar .grow { flex: 1; }
.toolbar-group { display: flex; gap: 6px; align-items: center; }

/* ---------- grid ---------- */
.grid { padding: 8px 16px 16px; display: grid; gap: 18px; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
@media (min-width: 700px) { .grid { padding: 10px 24px 20px; } }
.mode-note { margin: 0 0 10px; font-size: 13px; color: var(--muted); }
.mode-note button { border: 0; background: none; padding: 0; color: var(--accent-ink); font-weight: 700; text-decoration: underline; }
.measure { scroll-margin-top: 76px; border-radius: 12px; }
.measure.flash { animation: bar-flash 1.6s ease-out; }
@keyframes bar-flash { 0%, 40% { box-shadow: 0 0 0 3px var(--accent); background: var(--accent-soft); } 100% { box-shadow: 0 0 0 3px transparent; } }
#notation.jump svg { cursor: pointer; }
.measure-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.measure-head h3 { font-size: 13px; margin: 0; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.measure-head .spacer { flex: 1; }
.bar-tag { font-size: 12px; font-weight: 700; color: var(--text); border: 1px solid var(--line); background: var(--surface-2); border-radius: 6px; padding: 1px 7px; white-space: nowrap; }
.bar-tag.mark { border: 1.5px solid var(--text); background: none; font-weight: 800; }
.bar-tag.text { font-style: italic; font-weight: 600; max-width: 14em; overflow: hidden; text-overflow: ellipsis; }
.measure { display: grid; gap: 10px; }
.block { display: grid; gap: 5px; }
.g-row { display: flex; align-items: center; gap: 8px; }
.g-row .lbl {
  width: 34px; flex: none; font-size: 11px; font-weight: 800; letter-spacing: .03em;
  color: var(--muted); text-align: left;
}
/* row names with a pattern menu (right click / tap) */
.g-row .lbl.has-menu { cursor: pointer; border-radius: 6px; padding: 4px 2px; margin-left: -2px; user-select: none; -webkit-user-select: none; }
.g-row .lbl.has-menu:hover, .g-row .lbl.has-menu:focus-visible { color: var(--accent-ink); background: var(--surface-2); outline: none; }
.g-beats { flex: 1; display: flex; gap: 6px; min-width: 0; }
.g-beat { display: grid; gap: 3px; min-width: 0; }
.g-row.count .g-beat span { font-size: 11px; text-align: center; color: var(--muted); font-weight: 600; height: 14px; line-height: 14px; }
.g-row.count .g-beat span.on-beat { color: var(--text); font-weight: 800; }

.cell {
  --c: var(--accent); --c-soft: var(--accent-soft);
  /* --c-ink: lines and text on light ground, --c-on: icon on a filled cell */
  --c-ink: var(--c); --c-on: var(--on-cell);
  position: relative;
  aspect-ratio: 1 / 1.08;
  min-width: 0; min-height: 30px; max-height: 52px;
  padding: 0; border: 0; border-radius: 9px;
  background: var(--surface-2);
  display: grid; place-items: center;
  font-weight: 800; font-size: clamp(12px, 2.4vw, 17px); line-height: 1;
  color: var(--c-ink);
  touch-action: manipulation;
  transition: background .1s, transform .06s, box-shadow .1s;
}
.cell:hover { background: var(--surface-3); }
.cell:active { transform: scale(.92); }
.cell.beat-start { box-shadow: inset 0 0 0 1px var(--line); }
.cell[data-track="H"] { --c: var(--c-hh); --c-soft: var(--c-hh-soft); }
.cell[data-track="S"] { --c: var(--c-sn); --c-soft: var(--c-sn-soft); --c-ink: var(--c-sn-ink); --c-on: var(--on-accent); }
.cell[data-track="K"] { --c: var(--c-bd); --c-soft: var(--c-bd-soft); }
.cell[data-track^="T"] { --c: var(--c-tom); --c-soft: var(--c-tom-soft); }
.cell[data-track="ST"], .cell[data-track="TE"], .cell[data-track="C"] { --c: var(--c-stk); --c-soft: var(--c-stk-soft); }
.cell.on { background: var(--c); color: var(--c-on); }
.cell.on.soft { background: var(--c-soft); color: var(--c-ink); box-shadow: inset 0 0 0 2px var(--c-ink); }
.cell.on.ghost { background: transparent; color: var(--c-ink); box-shadow: inset 0 0 0 2px var(--c-ink); font-size: .8em; }
.cell.on.acc::after {
  content: ""; position: absolute; top: 3px; right: 3px; width: 6px; height: 6px; border-radius: 50%;
  background: var(--c-on); opacity: .9;
}
.cell.now { outline: 2px solid var(--text); outline-offset: 1px; }
.cell.now:not(.on) { background: var(--surface-3); }
.cell[data-track="ST"], .cell[data-track="TE"] { aspect-ratio: auto; height: 28px; min-height: 28px; font-size: 12px; }
.cell[data-track="TE"] { font-size: 16px; font-weight: 800; }

.hint { margin: 0; padding: 0 16px 16px; color: var(--muted); font-size: 13px; }
@media (max-width: 699px) {
  .grid { padding: 6px 12px 14px; }
  .g-row { gap: 6px; }
  .g-row .lbl { width: 28px; font-size: 10px; }
  .g-beats { gap: 5px; }
  .toolbar { padding: 12px; gap: 10px; }
  .hint { padding: 0 12px 14px; }
}
@media (min-width: 700px) { .hint { padding: 0 24px 20px; } }
.hint kbd { font: inherit; font-weight: 700; color: var(--text); }

/* ---------- details ---------- */
details.card > summary {
  list-style: none; cursor: pointer; padding: 16px; font-weight: 700;
  display: flex; align-items: center; gap: 8px;
}
@media (min-width: 700px) { details.card > summary { padding: 18px 24px; } }
details.card > summary::-webkit-details-marker { display: none; }
details.card > summary svg { width: 18px; height: 18px; transition: transform .2s; color: var(--muted); }
details.card[open] > summary svg { transform: rotate(90deg); }
.form { display: grid; gap: 14px; padding: 0 16px 18px; }
@media (min-width: 700px) { .form { padding: 0 24px 22px; grid-template-columns: 1fr 1fr; } .form .full { grid-column: 1 / -1; } }
.form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.input, textarea.input {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: var(--radius-sm);
  border: 1px solid var(--line); background: var(--surface-2); color: var(--text); font-size: 16px;
}
textarea.input { min-height: 70px; resize: vertical; }
.range-row { display: flex; align-items: center; gap: 12px; }
.range-row output { min-width: 44px; text-align: right; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }

input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 28px; background: transparent; }
input[type="range"]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(to right, var(--accent) var(--fill, 50%), var(--surface-3) var(--fill, 50%)); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); margin-top: -8px; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
input[type="range"]::-moz-range-track { height: 6px; border-radius: 3px; background: var(--surface-3); }
input[type="range"]::-moz-range-progress { height: 6px; border-radius: 3px; background: var(--accent); }
input[type="range"]::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--surface); border: 2px solid var(--accent); }

/* ---------- transport ---------- */
.transport {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 10px max(16px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.4) blur(14px);
  -webkit-backdrop-filter: saturate(1.4) blur(14px);
  border-top: 1px solid var(--line);
  box-shadow: 0 -6px 24px rgba(0,0,0,.06);
}
.transport-inner { max-width: 1120px; margin: 0 auto; display: grid; grid-template-columns: auto 1fr auto; grid-template-areas: "play tempo tools" "play slider slider"; gap: 6px 14px; align-items: center; }
.play {
  grid-area: play; width: 64px; height: 64px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 40%, transparent);
  transition: transform .08s, background .15s;
}
.play:hover { background: var(--accent-strong); }
.play:active { transform: scale(.94); }
.play svg { width: 28px; height: 28px; }
.tempo { grid-area: tempo; display: flex; align-items: center; gap: 8px; min-width: 0; }
.tempo-val { display: flex; align-items: baseline; gap: 4px; min-width: 76px; justify-content: center; }
.tempo-val input {
  width: 3.2ch; border: 0; background: transparent; text-align: center;
  font-size: 26px; font-weight: 800; font-variant-numeric: tabular-nums; padding: 0; letter-spacing: -0.02em;
  -moz-appearance: textfield;
}
.tempo-val input::-webkit-inner-spin-button, .tempo-val input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.tempo-val span { font-size: 12px; font-weight: 700; color: var(--muted); }
.round { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; flex: none; }
.round:hover { background: var(--surface-3); }
.round svg { width: 16px; height: 16px; }
.tools { grid-area: tools; display: flex; gap: 6px; justify-content: flex-end; }
.tool {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); font-size: 13px; font-weight: 700; color: var(--muted); white-space: nowrap;
}
.tool svg { width: 17px; height: 17px; }
.tool[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-ink); border-color: transparent; }
.slider { grid-area: slider; display: flex; align-items: center; gap: 12px; }
.pos { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; font-weight: 600; }
@media (max-width: 520px) {
  .tool .lbl-wide { display: none; }
  .tool { padding: 0 10px; }
  .transport-inner { gap: 4px 10px; }
  .play { width: 58px; height: 58px; }
  .tempo { gap: 6px; }
  .tempo-val { min-width: 54px; flex-direction: column; align-items: center; gap: 0; line-height: 1; }
  .tempo-val span { font-size: 10px; margin-top: 1px; }
}

/* ---------- menus & dialogs ---------- */
/* mixer panel (editor and player) */
.mixer-panel {
  position: fixed; z-index: 60; width: 300px; max-width: calc(100vw - 16px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18); padding: 12px 14px; display: grid; gap: 6px;
  animation: pop .12s ease-out;
}
.mixer-panel.inline { position: static; width: auto; max-width: 420px; margin: 10px 0 2px auto; box-shadow: none; background: var(--surface-2); }
.mixer-panel h4 { margin: 0 0 2px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.mix-row { display: flex; align-items: center; gap: 10px; }
.mix-row label { flex: 1; display: grid; font-size: 13px; font-weight: 600; }
.mix-row input[type="range"] { height: 24px; }
.mix-row.muted label { color: var(--muted); }
.mix-row.muted input[type="range"] { opacity: .45; }
.mix-mute { flex: none; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); display: grid; place-items: center; color: var(--text); }
.mix-mute svg { width: 17px; height: 17px; }
.mix-mute[aria-pressed="true"] { background: var(--c-hh-soft); color: var(--text); border-color: transparent; }
.mix-solo { flex: none; width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); font-weight: 800; font-size: 14px; color: var(--muted); }
.mix-solo[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.mix-note { margin: 2px 0 0; font-size: 12px; color: var(--muted); }
/* metronome panel */
.mixer-panel .metro-lbl { margin: 4px 0 0; font-size: 12px; font-weight: 700; color: var(--muted); }
.mixer-panel .metro-seg { display: flex; width: 100%; }
.mixer-panel .metro-seg button { flex: 1 1 auto; padding: 0 8px; min-height: 32px; font-size: 13px; }
.mixer-panel .metro-seg button:disabled { opacity: .4; }
.mixer-panel .metro-accent { justify-self: start; margin-top: 4px; min-height: 32px; }
.mix-reset { margin-top: 4px; border: 0; background: none; color: var(--accent-ink); font-weight: 700; font-size: 13px; justify-self: start; padding: 4px 0; }
.menu {
  user-select: none; -webkit-user-select: none;
  position: fixed; z-index: 60; min-width: 220px; max-width: calc(100vw - 24px);
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18); padding: 6px;
  display: grid; gap: 2px; max-height: calc(100dvh - 24px); overflow-y: auto; overscroll-behavior: contain;
  animation: pop .12s ease-out;
}
.menu h4 { margin: 4px 10px 6px; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.menu button {
  display: flex; align-items: center; gap: 12px; text-align: left;
  border: 0; background: transparent; border-radius: 9px; padding: 10px 10px; font-size: 15px; min-height: 44px;
}
.menu button:hover, .menu button:focus-visible { background: var(--surface-2); }
.menu button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.menu .ico { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; font-weight: 800; font-size: 14px; background: var(--surface-2); flex: none; }
.menu svg { width: 18px; height: 18px; color: var(--muted); }
.menu hr { border: 0; border-top: 1px solid var(--line); margin: 4px 6px; }
@keyframes pop { from { opacity: 0; transform: scale(.96); } to { opacity: 1; transform: none; } }

dialog {
  border: 0; padding: 0; border-radius: 20px; background: var(--surface); color: var(--text);
  width: min(640px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  box-shadow: 0 24px 80px rgba(0,0,0,.3);
}
dialog::backdrop { background: rgba(10, 18, 22, .45); backdrop-filter: blur(3px); }
.dlg-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 6px; }
.dlg-head h2 { margin: 0; font-family: "Dimbo", "Be Vietnam Pro", sans-serif; font-size: 23px; font-weight: 400; flex: 1; }
.dlg-body { padding: 8px 20px 20px; display: grid; gap: 14px; overflow: auto; }
.dlg-body p { margin: 0; color: var(--muted); font-size: 14px; }
.copy-row { display: flex; gap: 8px; }
.copy-row .input { font-size: 13px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
textarea.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; min-height: 110px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.preview-frame { border: 1px dashed var(--line); border-radius: 14px; padding: 10px; background: var(--bg); }
.preview-frame iframe { width: 100%; border: 0; display: block; }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--transport-h) + 20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--navy); color: #fff; padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
  z-index: 80; box-shadow: 0 8px 30px rgba(0,0,0,.25); animation: pop .15s ease-out;
}

/* ---------- print ---------- */
/* Print layout (filled by printSheet): only the sheet is printed */
.print-sheet { display: none; }
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body > *:not(.print-sheet) { display: none !important; }
  html, body { background: #fff !important; }
  .print-sheet { display: block; color: #111; font-family: "Be Vietnam Pro", system-ui, sans-serif; }
  .print-sheet header { text-align: center; margin-bottom: 6mm; }
  .print-sheet h1 { font-family: Dimbo, "Be Vietnam Pro", sans-serif; font-weight: 400; font-size: 26pt; margin: 0 0 1.5mm; color: #111; }
  .print-sheet header p { margin: 0; font-size: 10pt; color: #444; }
  .print-sheet .notation-system { width: 100%; height: auto; margin-bottom: 3mm; break-inside: avoid; page-break-inside: avoid; color: #111; }
  .print-sheet .playhead { display: none; }
  .print-sheet .print-comment { font-size: 10pt; color: #333; margin-top: 4mm; white-space: pre-wrap; }
  .print-sheet footer { margin-top: 6mm; font-size: 8pt; color: #888; text-align: center; display: grid; justify-items: center; gap: 2.5mm; break-inside: avoid; }
  .print-sheet .print-link { display: inline-block; padding: 1.8mm 5mm; border-radius: 99px; background: #9dd49f; color: #14301a; font-size: 10pt; font-weight: 700; text-decoration: none; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* Video the notation follows (Bunny Stream iframe or video file) */
.video-box { position: relative; aspect-ratio: 16 / 9; background: #000; border-radius: 12px; overflow: hidden; }
.video-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #000; }
.notation.seekable svg { cursor: pointer; }

/* editor: video panel */
.sum-badge { margin-left: auto; font-size: 12px; font-weight: 700; color: var(--accent-ink); background: var(--accent-soft); border-radius: 999px; padding: 2px 9px; }
.sum-badge:empty { display: none; }
.video-panel { display: grid; gap: 12px; padding: 0 16px 18px; }
.video-panel .video-box { width: 100%; max-width: 720px; margin: 0 auto; }
/* grid folded away: only video and notation, to check both together */
.grid-hidden #video-card .video-link, .grid-hidden #video-tools { display: none !important; }
.grid-hidden #video-card .video-panel { padding-bottom: 14px; }
.check-hint { display: none; margin: 0; text-align: center; font-size: 13px; color: var(--muted); }
.grid-hidden .check-hint { display: block; }
@media (min-width: 700px) { .video-panel { padding: 0 24px 22px; } }
.video-link { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.video-tools { display: grid; gap: 10px; outline: none; }
.tap-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.btn.tap { min-height: 46px; padding: 0 22px; font-size: 15px; touch-action: manipulation; }
.btn.tap.hit { transform: scale(.95); }
.tap-from { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.tap-from input { width: 64px; min-height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; }
.video-clock { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.video-clock b { color: var(--text); font-size: 15px; }
.video-hint { margin: 0; font-size: 13px; color: var(--muted); }
.video-hint kbd { font: inherit; font-weight: 700; color: var(--text); }
.sync-list { display: grid; gap: 8px; }
.sync-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; padding: 10px 12px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.sync-row.now { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.sync-row .num { font-weight: 800; min-width: 18px; }
.sync-row label { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.sync-row input { width: 74px; min-height: 32px; padding: 0 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--text); font: inherit; font-size: 14px; font-variant-numeric: tabular-nums; }
.sync-row input.tempo { width: 58px; }
.sync-row .mini { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; min-width: 32px; min-height: 32px; padding: 0 7px; font-size: 12px; font-weight: 700; color: var(--muted); display: inline-grid; place-items: center; }
.sync-row .mini svg { width: 15px; height: 15px; }
.sync-row .mini:hover { color: var(--text); }
.align-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* studio: songs on the server */
.btn.dirty { position: relative; }
.btn.dirty::after { content: ""; position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--c-hh); }
.dlg-note { margin: 0; padding: 10px 12px; border-radius: 10px; background: var(--c-hh-soft); color: var(--text); font-size: 13px; }
.song-list { display: grid; gap: 6px; max-height: 55vh; overflow: auto; }
.song-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.song-row.current { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.song-row .song-open { flex: 1; min-width: 0; border: 0; background: none; text-align: left; padding: 2px 0; font-weight: 700; }
.song-row .song-open small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.song-row .song-open span { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-row .mini { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; width: 34px; height: 34px; display: grid; place-items: center; color: var(--muted); }
.song-row .mini svg { width: 16px; height: 16px; }
.song-empty { color: var(--muted); font-size: 14px; margin: 0; }
.song-tools { display: flex; gap: 8px; flex-wrap: wrap; }
/* studio: transcription tasks */
.task-set { display: grid; gap: 6px; }
.task-set-lbl { font-size: 13px; font-weight: 600; color: var(--muted); }
.task-set .toggle[disabled] { opacity: 1; cursor: default; }
#task-embed { display: grid; gap: 14px; }
#task-embed[hidden] { display: none; }
.task-list-head { margin: 6px 0 0; font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.song-tools .input { flex: 1 1 200px; min-width: 0; }
.song-folder > summary {
  list-style: none; display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none;
  padding: 6px 4px; font-weight: 800; font-size: 14px;
}
.song-folder > summary::-webkit-details-marker { display: none; }
.song-folder > summary svg { width: 16px; height: 16px; color: var(--muted); transition: transform .2s; }
.song-folder[open] > summary > span[data-icon] svg { transform: rotate(90deg); }
.song-folder .folder-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-folder > summary small { color: var(--muted); font-weight: 600; font-size: 12px; background: var(--surface-2); border-radius: 999px; padding: 1px 8px; }
.song-folder > summary .mini { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; width: 30px; height: 30px; display: grid; place-items: center; color: var(--muted); }
.song-folder > summary .mini svg { width: 15px; height: 15px; transform: none; }
.folder-songs { display: grid; gap: 6px; padding: 2px 0 10px 22px; }
.import-notes { margin: 0; padding-left: 20px; display: grid; gap: 6px; font-size: 14px; }
.import-notes:empty { display: none; }
.sync-row .grp { display: inline-flex; align-items: center; gap: 4px; }
.sync-row .acts { margin-left: auto; }

/* The hidden attribute always wins over component display rules. */
[hidden] { display: none !important; }
