:root {
  --bg: #14110f;
  --panel: #1d1916;
  --panel-2: #262019;
  --ink: #f2ebe2;
  --muted: #a89c8c;
  --accent: #e0a44a;
  --accent-ink: #1a1410;
  --chord: #ffd27a;
  --line: #3a3128;
  --radius: 12px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap { max-width: 860px; margin: 0 auto; padding: 18px 16px 80px; }

header.site {
  position: sticky; top: 0; z-index: 5;
  background: rgba(20,17,15,.92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
header.site .bar {
  max-width: 860px; margin: 0 auto; padding: 12px 16px;
  display: flex; align-items: center; gap: 14px;
}
header.site .brand { font-weight: 700; letter-spacing: .2px; color: var(--ink); }
header.site .brand span { color: var(--accent); }
header.site nav { margin-left: auto; display: flex; gap: 16px; }

h1 { font-size: 1.5rem; margin: .2em 0 .1em; }
h2 { font-size: 1.15rem; }
.sub { color: var(--muted); margin: 0 0 18px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: 8px; padding: 9px 14px;
  font-weight: 600; cursor: pointer; font-size: .95rem;
}
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn:hover { filter: brightness(1.06); }
.btn:disabled { opacity: .5; cursor: default; }

/* Library */
.song-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.song-list a {
  display: block; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; color: var(--ink);
}
.song-list a:hover { border-color: var(--accent); text-decoration: none; }
.song-list .t { font-weight: 600; }
.song-list .a { color: var(--muted); font-size: .9rem; }
.tag { font-size: .72rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; }

/* Toolbar (viewer) */
.toolbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 10px 12px; margin: 14px 0 18px;
  position: sticky; top: 56px; z-index: 4;
}
.toolbar .grp { display: inline-flex; align-items: center; gap: 6px; }
.toolbar label { color: var(--muted); font-size: .85rem; }
.toolbar .keyval { font-variant-numeric: tabular-nums; min-width: 2.4em; text-align: center; }
.iconbtn {
  width: 32px; height: 32px; border-radius: 7px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--ink); font-size: 1.05rem; cursor: pointer;
}
.iconbtn:hover { border-color: var(--accent); }

/* Chord panel */
.chord-panel {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin-bottom: 18px;
}
.chord-panel h3 { margin: 0 0 8px; font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.chord-grid { display: flex; flex-wrap: wrap; gap: 10px; }
.chord-cell { background: var(--panel-2); border-radius: 10px; padding: 4px; }

/* Sheet */
.sheet { font-family: var(--mono); font-size: 15px; }
.sheet .row { display: flex; flex-wrap: wrap; align-items: flex-end; min-height: 1em; }
.sheet .row.chordsonly { gap: 10px; padding: 2px 0; }
.sheet .sp { height: 12px; }
.sheet .section {
  margin: 16px 0 4px; font-family: system-ui, sans-serif; font-weight: 700;
  color: var(--accent); font-size: .95rem;
}
.seg { display: inline-flex; flex-direction: column; align-items: flex-start; }
.chordslot { height: 1.25em; line-height: 1; }
.lyric { white-space: pre; }

button.chord {
  font-family: var(--mono); font-size: .92em; font-weight: 700;
  color: var(--chord); background: transparent; border: 0; padding: 0 1px;
  cursor: pointer; line-height: 1; white-space: nowrap;
  border-bottom: 1px dotted transparent;
}
button.chord:hover { border-bottom-color: var(--chord); }
.chordsonly button.chord { font-size: 1rem; }

/* Diagram popover + svg */
.chord-pop {
  position: absolute; z-index: 50; background: var(--panel);
  border: 1px solid var(--accent); border-radius: 10px; padding: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5);
}
svg.chord-dia { display: block; }
.dia-title { fill: var(--chord); font: 700 13px system-ui, sans-serif; }
.dia-base { fill: var(--muted); font: 10px system-ui, sans-serif; }
.dia-unknown { fill: var(--muted); font: 700 14px system-ui, sans-serif; }
.dia-nut { fill: var(--ink); }
.dia-fret { stroke: #5e5448; stroke-width: 1; }
.dia-string { stroke: #5e5448; stroke-width: 1; }
.dia-dot { fill: var(--accent); }
.dia-barre { fill: var(--accent); }
.dia-open { fill: none; stroke: var(--ink); stroke-width: 1.4; }
.dia-mute { fill: var(--muted); font: 11px system-ui, sans-serif; }

/* Studio */
.studio-grid { display: grid; gap: 18px; }
@media (min-width: 820px) { .studio-grid { grid-template-columns: 1fr 1fr; } }
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field label { color: var(--muted); font-size: .85rem; }
.field input, .field textarea {
  width: 100%; background: var(--panel-2); color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 9px 10px; font-size: .95rem;
}
.field textarea { font-family: var(--mono); min-height: 360px; resize: vertical; line-height: 1.45; }
.preview-box { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; min-height: 200px; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0; }
.hint { color: var(--muted); font-size: .85rem; }
.export {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px; font-family: var(--mono); font-size: .82rem; white-space: pre-wrap;
  max-height: 220px; overflow: auto;
}
.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--accent); color: var(--accent-ink); padding: 10px 16px;
  border-radius: 8px; font-weight: 600; opacity: 0; transition: opacity .2s; pointer-events: none;
}
.toast.show { opacity: 1; }
.empty { color: var(--muted); text-align: center; padding: 40px 0; }
