:root {
  --bg: #14121c; --panel: #1e1b28; --panel-2: #262232; --line: #352f45;
  --ink: #ecebf4; --dim: #9d98b2; --accent: #8b6cff; --accent-2: #38d6bf;
  --danger: #ff5c7a; --radius: 14px;
}
@media (prefers-color-scheme: light) {
  :root { --bg: #f6f5fb; --panel: #fff; --panel-2: #f0eef8; --line: #e2ddef;
    --ink: #1b1926; --dim: #6d6884; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; padding-bottom: env(safe-area-inset-bottom); }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  justify-content: space-between; gap: 12px; padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -.4px; }
.topbar h1 span { color: var(--accent); }
.provider { font-size: 12px; color: var(--dim); font-family: ui-monospace, monospace; }

main { max-width: 900px; margin: 0 auto; padding: 16px; padding-bottom: 96px; }

.head-right { display: flex; align-items: center; gap: 10px; }
button.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.row.wrap { flex-wrap: wrap; }
.field.grow { flex: 1 1 auto; }

.panel { background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }

.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.field > span { font-size: 12.5px; color: var(--dim); font-weight: 600; }
.field em { color: var(--dim); font-style: normal; opacity: .8; font-weight: 400; }

textarea, input[type="text"], input[type="number"], input:not([type]) {
  width: 100%; background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px;
  font: inherit; font-size: 16px; }
textarea { resize: vertical; min-height: 60px; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.seed-row { display: flex; gap: 10px; align-items: center; }
.seed-preview { margin-top: 8px; font-family: ui-monospace, monospace; font-size: 12px;
  color: var(--accent-2); background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 8px; padding: 8px 10px; max-height: 90px; overflow: auto; word-break: break-word; }

.row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.opts .mini { display: flex; flex-direction: column; gap: 5px; flex: 0 0 auto; }
.opts .mini span { font-size: 11px; color: var(--dim); font-weight: 600; }
.opts .mini input { width: 72px; }
.opts #compose { margin-left: auto; }

button { font: inherit; cursor: pointer; min-height: 44px; border-radius: 10px;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button.primary { background: var(--accent); color: #fff; border: 0; font-weight: 700; padding: 0 22px; }
button.ghost { background: var(--panel-2); color: var(--ink); border: 1px solid var(--line);
  font-weight: 600; padding: 0 14px; }
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; pointer-events: none; }

.hint { color: var(--dim); font-size: 13px; margin: 10px 2px 0; min-height: 18px; }

.transport { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.transport .grow { flex: 1; }
.transport .title { font-weight: 700; font-size: 14px; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }

.score-panel { position: sticky; top: 60px; z-index: 10; }

/* ── chat ─────────────────────────────────────────────────────────────────── */
.chat { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.msg { max-width: 88%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.45; }
.msg.you { align-self: flex-end; background: var(--accent); color: #fff; border-bottom-right-radius: 5px; }
.msg.cat { align-self: flex-start; background: var(--panel); border: 1px solid var(--line);
  border-bottom-left-radius: 5px; }
.msg.err { align-self: flex-start; background: color-mix(in srgb, var(--danger) 16%, var(--panel));
  border: 1px solid var(--danger); color: var(--ink); }
.msg.pending { color: var(--dim); font-style: italic; }
.msg.pending::before { content: '♪ '; font-style: normal; }

/* ── sticky composer ─────────────────────────────────────────────────────── */
.composer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; gap: 8px; align-items: flex-end;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); }
.composer textarea { flex: 1; resize: none; min-height: 44px; max-height: 140px;
  border-radius: 12px; padding: 11px 14px; }
.composer button { flex: 0 0 auto; }

.score { background: #fff; border-radius: 10px; padding: 10px; overflow-x: auto; }
.score svg { max-width: 100%; height: auto; }

.abc { background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  padding: 12px; font-family: ui-monospace, monospace; font-size: 12px; color: var(--ink);
  white-space: pre-wrap; word-break: break-word; margin: 12px 0 0; max-height: 320px; overflow: auto; }

.toast { position: fixed; left: 50%; top: calc(60px + env(safe-area-inset-top));
  transform: translate(-50%, -12px); background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s;
  z-index: 100; max-width: 90vw; box-shadow: 0 6px 24px rgba(0,0,0,.28); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* abcjs highlights the playing note */
.abcjs-cursor { stroke: var(--accent); stroke-width: 2; }
