/* ==========================================================================
   Paddy Prompt Studio — Sheet music maker
   Layers on /blog/style.css (same dark indigo/cyan palette and type scale).
   The score itself sits on white "paper" so it reads (and prints) like
   real sheet music.
   ========================================================================== */

.sm {
  background: linear-gradient(180deg, var(--card), var(--card-2));
  border: 1px solid var(--border); border-radius: 22px;
  padding: 1.1rem 1.25rem 1.25rem; margin: 0.5rem 0 1rem;
  box-shadow: 0 30px 70px -40px rgba(99, 102, 241, 0.6);
}
.sm button:focus-visible, .sm select:focus-visible, .sm input:focus-visible, .sm textarea:focus-visible { outline: 2px solid #22d3ee; outline-offset: 2px; }

/* ------------------------------------------------------------ Header form */
.sm-meta { display: grid; grid-template-columns: 2fr 1.4fr repeat(4, minmax(0, 1fr)); gap: 0.6rem; }
.sm-ctl { display: flex; flex-direction: column; gap: 0.3rem; font-size: 0.74rem; font-weight: 700; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; min-width: 0; }
.sm-ctl input[type="text"], .sm-ctl select, .sm-abc {
  font: inherit; font-size: 0.92rem; font-weight: 600; text-transform: none; letter-spacing: 0; color: var(--text);
  background: #0b0d14; border: 1px solid var(--border); border-radius: 10px; padding: 0.55rem 0.65rem; min-height: 44px; width: 100%;
}
.sm-ctl input[type="range"] { accent-color: #818cf8; min-height: 44px; width: 100%; }
.sm-ctl output { color: #fff; text-transform: none; }

/* ------------------------------------------------------------ Paper */
.sm-paper-wrap { position: relative; margin-top: 1rem; }
.sm-paper {
  background: #fdfcf8; color: #111; border-radius: 14px; padding: 0.6rem 0.9rem; min-height: 180px;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08), 0 18px 40px -26px rgba(0,0,0,0.8);
  overflow: hidden; cursor: default;
}
.sm-paper svg { display: block; }
.sm-paper .abcjs-note, .sm-paper .abcjs-rest { cursor: pointer; }
.sm-paper .sm-now, .sm-paper .sm-now path { fill: #4f46e5 !important; stroke: none; }
.sm-paper-tip {
  position: absolute; left: 50%; bottom: 1.4rem; transform: translateX(-50%); margin: 0;
  font-size: 0.88rem; font-weight: 600; color: #6b7280; pointer-events: none; text-align: center; width: 90%;
}
.sm:not(.is-empty) .sm-paper-tip { display: none; }

/* ------------------------------------------------------------ Transport */
.sm-transport { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem 0.7rem; margin-top: 0.85rem; }
.sm-play {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; cursor: pointer;
  padding: 0.7rem 1.4rem; min-height: 50px; min-width: 8.5rem; border: 0; border-radius: 14px;
  font: inherit; font-size: 1.02rem; font-weight: 800;
  background: linear-gradient(135deg, #818cf8, #22d3ee); color: #0b0620;
}
.sm-play:hover { filter: brightness(1.08); }
.sm-play[data-state="playing"] { background: rgba(52, 211, 153, 0.14); color: #6ee7b7; box-shadow: inset 0 0 0 1px rgba(52, 211, 153, 0.5); }
.sm-play[data-state="loading"] { opacity: 0.75; cursor: progress; }
.sm-play .ico::before { content: "▶"; }
.sm-play[data-state="playing"] .ico::before { content: "■"; }
.sm-status { margin: 0.7rem 0 0; font-size: 0.9rem; color: var(--text-muted); min-height: 1.35em; }
.sm-status.err { color: #fcd34d; font-weight: 600; }

/* ------------------------------------------------------------ Palette */
.sm-palette { margin-top: 1rem; padding-top: 0.9rem; border-top: 1px solid var(--border-soft); }
.sm-row { display: flex; flex-wrap: wrap; align-items: center; gap: 0.45rem; }
.sm-row + .sm-row { margin-top: 0.6rem; }
.sm-durs { display: inline-flex; flex-wrap: wrap; gap: 0.3rem; background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: 12px; padding: 0.22rem; }
.sm-dur {
  display: inline-flex; align-items: center; gap: 0.35rem; cursor: pointer;
  border: 0; border-radius: 9px; padding: 0.4rem 0.6rem; min-height: 42px;
  background: transparent; color: var(--text-muted); font: inherit; font-size: 0.85rem; font-weight: 700;
}
.sm-dur .sym { display: inline-flex; line-height: 0; }
.note-ico { display: inline-block; vertical-align: middle; color: var(--indigo); }
.sm-dur kbd, .sm-btn kbd { font-family: "JetBrains Mono", monospace; font-size: 0.68rem; opacity: 0.6; border: 1px solid var(--border); border-radius: 4px; padding: 0 0.3em; }
.sm-dur[aria-pressed="true"] { background: rgba(99, 102, 241, 0.26); color: #fff; }
.sm-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; cursor: pointer;
  min-height: 42px; padding: 0.45rem 0.85rem; border-radius: 11px; font: inherit; font-size: 0.88rem; font-weight: 700;
  background: rgba(255, 255, 255, 0.04); color: var(--text); border: 1px solid var(--border); text-decoration: none;
}
.sm-btn:hover { background: rgba(129, 140, 248, 0.16); }
.sm-btn[aria-pressed="true"] { border-color: rgba(34, 211, 238, 0.6); color: #a5f3fc; background: rgba(34, 211, 238, 0.1); }
.sm-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.sm-btn.ghost { background: transparent; }
.sm-btn-sm { min-height: 36px; padding: 0.3rem 0.65rem; font-size: 0.82rem; }
.sm-chord { width: 7.5rem; font: inherit; font-size: 0.88rem; font-weight: 600; color: var(--text); background: #0b0d14; border: 1px solid var(--border); border-radius: 10px; padding: 0.5rem 0.6rem; min-height: 42px; }
.sm-check { display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.86rem; font-weight: 600; color: var(--text-muted); min-height: 42px; cursor: pointer; }
.sm-check input { width: 1.05rem; height: 1.05rem; accent-color: #818cf8; margin: 0; }
.sm-bar-info { margin-left: auto; font-size: 0.82rem; font-weight: 700; color: var(--text-dim); font-family: "JetBrains Mono", monospace; }
.sm-bar-info.over { color: #fcd34d; }

/* ------------------------------------------------------------ Piano */
.sm-octave { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; margin-top: 0.8rem; }
.sm-octave span { font-family: "JetBrains Mono", monospace; font-size: 0.85rem; font-weight: 700; color: var(--indigo); }
.sm-piano { position: relative; height: 150px; margin-top: 0.5rem; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.sm-key { position: absolute; top: 0; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; font: inherit; }
.sm-key.white {
  height: 100%; background: linear-gradient(180deg, #f8fafc, #e2e8f0); border: 1px solid #94a3b8; border-radius: 0 0 9px 9px;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 0.4rem; z-index: 1; color: #334155;
}
.sm-key.black {
  height: 62%; background: linear-gradient(180deg, #1e293b, #0b0d14); border-radius: 0 0 7px 7px; z-index: 2;
  box-shadow: 0 3px 0 #000; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; padding-bottom: 0.3rem; color: #cbd5e1;
}
.sm-key .n { font-size: 0.72rem; font-weight: 700; }
.sm-key .k { font-family: "JetBrains Mono", monospace; font-size: 0.62rem; opacity: 0.55; }
.sm-key.white.down, .sm-key.white:active { background: linear-gradient(180deg, #c7d2fe, #a5b4fc); }
.sm-key.black.down, .sm-key.black:active { background: linear-gradient(180deg, #6366f1, #4338ca); }

/* ------------------------------------------------------------ Lower panels */
.sm-panels { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; margin-top: 1rem; }
.sm-panel { background: rgba(255,255,255,0.025); border: 1px solid var(--border-soft); border-radius: 14px; padding: 0.85rem; min-width: 0; }
.sm-panel h3 { margin: 0 0 0.55rem; font-size: 0.95rem; color: #fff; }
.sm-abc { min-height: 120px; resize: vertical; font-family: "JetBrains Mono", monospace; font-size: 0.85rem; line-height: 1.5; font-weight: 400; }
.sm-small { font-size: 0.8rem; color: var(--text-dim); margin: 0.45rem 0 0; }
.sm-actions { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.sm-library { list-style: none; margin: 0.6rem 0 0; padding: 0; max-height: 220px; overflow-y: auto; }
.sm-library li { display: grid; grid-template-columns: 1fr auto auto; grid-template-rows: auto auto; gap: 0 0.4rem; align-items: center; padding: 0.4rem 0; border-bottom: 1px dashed var(--border-soft); }
.sm-library .sm-lib-name { font-weight: 700; font-size: 0.9rem; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sm-library .sm-lib-meta { grid-row: 2; font-size: 0.75rem; color: var(--text-dim); }
.sm-library .sm-btn { grid-row: 1 / span 2; }
.sm-library .sm-lib-empty { display: block; font-size: 0.85rem; color: var(--text-dim); border: 0; }
.sm-hint { margin: 0.85rem 0 0; text-align: center; font-size: 0.8rem; color: var(--text-dim); }
.sm-hint kbd, .article-body kbd {
  font-family: "JetBrains Mono", monospace; font-size: 0.78em; font-weight: 700;
  background: rgba(255,255,255,0.06); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 6px; padding: 0.05em 0.4em; color: #e0e7ff;
}

/* ------------------------------------------------------------ Prose tables */
.table-wrap { overflow-x: auto; margin: 0 0 1.5rem; border: 1px solid var(--border); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
table.data caption { text-align: left; padding: 0.85rem 1rem 0.2rem; color: var(--text-dim); font-size: 0.82rem; }
table.data th, table.data td { padding: 0.6rem 1rem; text-align: left; border-bottom: 1px solid var(--border-soft); vertical-align: top; }
table.data th { color: var(--indigo); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }
table.data tr:last-child td { border-bottom: 0; }
table.data code { font-size: 0.88em; }

/* ------------------------------------------------------------ Selected note */
.sm-paper .sm-sel, .sm-paper .sm-sel path { fill: #6366f1 !important; }
.sm-paper .sm-anchor, .sm-paper .sm-anchor path { fill: #0891b2 !important; }
.sm-selbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem; margin-top: 0.6rem;
  padding: 0.45rem 0.6rem; border-radius: 12px; background: rgba(99, 102, 241, 0.12); border: 1px solid rgba(129, 140, 248, 0.45);
}
.sm-selbar[hidden] { display: none; }
.sm-sel-label { font-size: 0.9rem; color: #fff; margin-right: 0.3rem; min-width: 7.5rem; }
.sm-sel-keys { margin-left: auto; font-size: 0.75rem; color: var(--text-dim); }
.sm-sel-keys kbd { font-family: "JetBrains Mono", monospace; font-size: 0.7rem; border: 1px solid var(--border); border-radius: 4px; padding: 0 0.25em; margin-right: 0.1em; }

/* ------------------------------------------------------------ Lyrics */
.sm-lyrics { margin-top: 0.9rem; background: rgba(255,255,255,0.025); border: 1px solid var(--border-soft); border-radius: 14px; padding: 0.55rem 0.85rem; }
.sm-lyrics summary { cursor: pointer; font-weight: 700; font-size: 0.95rem; color: #fff; min-height: 32px; display: flex; align-items: center; }
.sm-lyrics[open] summary { margin-bottom: 0.5rem; }
.sm-lyrics-box { width: 100%; min-height: 70px; font-family: inherit; font-size: 0.95rem; }
.sm-lyric-info.over { color: #fcd34d; font-weight: 600; }
.sm-linkbtn {
  display: block; margin: 0.55rem auto 0; padding: 0.35rem 0.6rem; min-height: 36px; background: none; border: 0;
  font: inherit; font-size: 0.98rem; font-weight: 700; color: var(--indigo); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.sm-linkbtn:hover { color: #a5b4fc; }
.sm-linkbtn[hidden] { display: none; }

/* ------------------------------------------------------------ Small screens */
@media (max-width: 860px) {
  .sm-meta { grid-template-columns: 1fr 1fr; }
  .sm-panels { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .sm { padding: 0.85rem; }
  .sm-paper { padding: 0.4rem; }
  .sm-dur span:not(.sym) { display: none; }
  .sm-dur kbd { display: none; }
  .sm-piano { height: 120px; }
  .sm-key .k { display: none; }
  .sm-bar-info { margin-left: 0; width: 100%; }
  .sm-sel-keys { display: none; }
  .sm-sel-label { width: 100%; }
}

/* ------------------------------------------------------------ Print: just the score */
@media print {
  body * { visibility: hidden !important; }
  .sm-paper-wrap { position: static !important; }
  .sm-paper, .sm-paper * { visibility: visible !important; }
  .sm-paper { position: absolute; left: 0; top: 0; width: 100%; box-shadow: none; padding: 0; background: #fff; }
  .sm-paper-tip { display: none; }
  .sm-paper .sm-sel, .sm-paper .sm-sel path, .sm-paper .sm-anchor, .sm-paper .sm-anchor path { fill: #000 !important; }
  body { background: #fff !important; }
}
