/* song2score — mobile-first UI */

:root {
  --bg: #0d1017;
  --bg-soft: #141924;
  --card: #1a2030;
  --card-2: #222a3d;
  --line: #2c3549;
  --text: #e8edf7;
  --muted: #93a0bb;
  --accent: #57c7a3;
  --accent-2: #4a9dea;
  --warn: #f0b74a;
  --danger: #ef6b6b;
  --radius: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, .32);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -200px, #1b2436 0%, var(--bg) 60%);
  color: var(--text);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  padding-bottom: calc(24px + var(--safe-b));
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ── header ─────────────────────────────────────────────── */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(12px);
  background: rgba(13, 16, 23, .82);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
}
.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: .3px;
}
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0b1016;
  font-size: 15px;
  font-weight: 800;
}
.tagline { color: var(--muted); font-size: 12.5px; }

/* ── layout ─────────────────────────────────────────────── */
.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

/* ── drop zone ──────────────────────────────────────────── */
.drop {
  border: 2px dashed #3a465f;
  border-radius: var(--radius);
  padding: 28px 16px;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s, background .18s, transform .18s;
}
.drop:hover, .drop:focus-visible { border-color: var(--accent); background: rgba(87, 199, 163, .06); outline: none; }
.drop.dragover { border-color: var(--accent-2); background: rgba(74, 157, 234, .12); transform: scale(1.01); }
.drop-icon { font-size: 34px; color: var(--accent); line-height: 1; }
.drop-title { margin-top: 10px; font-weight: 600; font-size: 16px; }
.drop-hint { margin-top: 6px; color: var(--muted); font-size: 12.5px; }

.file-info {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13.5px;
}
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { color: var(--muted); font-size: 12.5px; margin-left: auto; white-space: nowrap; }

button { font: inherit; cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }

.ghost {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 8px;
}
.ghost:hover { color: var(--text); background: rgba(255, 255, 255, .06); }

/* ── options ────────────────────────────────────────────── */
.options { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 12px; }
.options summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 13.5px;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}
.options summary::-webkit-details-marker { display: none; }
.options summary::before { content: "▸"; transition: transform .18s; }
.options[open] summary::before { transform: rotate(90deg); }

.options-grid {
  margin-top: 12px;
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr;
}
@media (min-width: 620px) { .options-grid { grid-template-columns: 1fr 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field input, .field select {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 10px 12px;
  font: inherit;
  width: 100%;
}
.field input:focus, .field select:focus { outline: none; border-color: var(--accent-2); }

.checks {
  margin-top: 12px;
  display: grid;
  gap: 8px 14px;
  grid-template-columns: 1fr 1fr;
}
@media (min-width: 620px) { .checks { grid-template-columns: repeat(3, 1fr); } }
.check { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--text); }
.check input { width: 17px; height: 17px; accent-color: var(--accent); }

/* ── buttons ────────────────────────────────────────────── */
.primary {
  margin-top: 16px;
  width: 100%;
  padding: 14px 18px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--accent), #3fa9d8);
  color: #08120f;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .5px;
  transition: filter .18s, transform .12s;
}
.primary:not(:disabled):hover { filter: brightness(1.08); }
.primary:not(:disabled):active { transform: scale(.99); }

.fineprint { margin: 12px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ── progress ───────────────────────────────────────────── */
.progress-head {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 10px;
}
#progressPct { color: var(--accent); font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: var(--bg-soft); border-radius: 99px; overflow: hidden; }
.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .35s ease;
}
.progress-hint { margin-top: 10px; color: var(--muted); font-size: 12.5px; }

.error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(239, 107, 107, .12);
  border: 1px solid rgba(239, 107, 107, .4);
  color: #ffc9c9;
  font-size: 13.5px;
  white-space: pre-wrap;
}

/* ── summary ────────────────────────────────────────────── */
.summary h2 {
  margin: 0 0 4px;
  font-size: 19px;
  line-height: 1.35;
  word-break: break-word;
}
.summary .sub { color: var(--muted); font-size: 12.5px; margin-bottom: 12px; }
.facts { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
@media (min-width: 620px) { .facts { grid-template-columns: repeat(4, 1fr); } }
.fact {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 11px;
}
.fact .k { color: var(--muted); font-size: 11.5px; }
.fact .v { font-size: 15.5px; font-weight: 700; margin-top: 2px; word-break: break-word; }

/* ── audio ──────────────────────────────────────────────── */
.audio-card { padding: 12px 14px; }
.audio-card audio { width: 100%; height: 38px; display: block; }
.audio-hint { color: var(--muted); font-size: 12px; margin-top: 8px; }

/* ── warnings ───────────────────────────────────────────── */
.warn { border-color: rgba(240, 183, 74, .38); background: rgba(240, 183, 74, .07); }
.warn h3 { margin: 0 0 8px; font-size: 13.5px; color: var(--warn); }
.warn ul { margin: 0; padding-left: 18px; color: #f2ddb4; font-size: 13px; }

/* ── tabs ───────────────────────────────────────────────── */
.tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 4px;
  position: sticky;
  top: 52px;
  z-index: 10;
  backdrop-filter: blur(10px);
}
.tab {
  flex: 1;
  padding: 10px 6px;
  border: none;
  border-radius: 9px;
  background: none;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  transition: background .16s, color .16s;
}
.tab.active { background: var(--card-2); color: var(--text); box-shadow: 0 1px 6px rgba(0, 0, 0, .3); }

.panel { min-height: 80px; }

/* ── toolbar ────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: flex-end;
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.control { display: flex; flex-direction: column; gap: 5px; }
.control.grow { flex: 1; min-width: 140px; }
.control > label { color: var(--muted); font-size: 11.5px; }
.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.stepper button {
  width: 38px;
  height: 34px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 17px;
}
.stepper button:hover { background: var(--card-2); }
.stepper span {
  min-width: 46px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.capo { font-size: 13.5px; padding: 8px 0; }
#zoom { accent-color: var(--accent); width: 100%; }

/* ── notation ───────────────────────────────────────────── */
.notation-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
#notation svg { max-width: 100%; height: auto; display: block; }
#notation .measure-hit { cursor: pointer; }
.legend { margin-top: 10px; color: var(--muted); font-size: 12px; }

/* ── chord chart ────────────────────────────────────────── */
.bars {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 560px) { .bars { grid-template-columns: repeat(4, 1fr); } }
.bar-cell {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  text-align: center;
}
.bar-cell .num { color: var(--muted); font-size: 11px; }
.bar-cell .chord { font-size: 17px; font-weight: 700; margin-top: 2px; word-break: break-word; }
.bar-cell .roman { color: var(--accent); font-size: 12px; margin-top: 2px; }
.bar-cell.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }

h3.section {
  margin: 20px 0 10px;
  font-size: 14px;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: .4px;
  text-transform: none;
}
h3.section:first-child { margin-top: 0; }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th, .table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.table td.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 1px; }
.table tr:last-child td { border-bottom: none; }

.strum { display: flex; flex-direction: column; gap: 8px; }
.strum-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
}
.strum-name { color: var(--muted); font-size: 12px; min-width: 68px; }
.strum-glyphs { font-size: 17px; letter-spacing: 3px; color: var(--accent); }

/* ── fretboards ─────────────────────────────────────────── */
.frets {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, 1fr);
}
@media (min-width: 560px) { .frets { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 860px) { .frets { grid-template-columns: repeat(4, 1fr); } }
.fret-card {
  background: var(--card-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 6px 6px;
  text-align: center;
}
.fret-card .label { font-size: 15px; font-weight: 700; margin-bottom: 6px; }
.fret-card .source { color: var(--muted); font-size: 11px; margin-top: 4px; }
.fret-card svg { width: 100%; max-width: 150px; height: auto; }

/* ── downloads ──────────────────────────────────────────── */
.downloads { display: grid; gap: 10px; grid-template-columns: 1fr; }
@media (min-width: 560px) { .downloads { grid-template-columns: 1fr 1fr; } }
.dl {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 14px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--card-2);
  color: var(--text);
  text-decoration: none;
  transition: border-color .16s, transform .12s;
}
.dl:hover { border-color: var(--accent); }
.dl:active { transform: scale(.99); }
.dl-icon { font-size: 19px; }
.dl-body { display: flex; flex-direction: column; }
.dl-title { font-weight: 600; font-size: 14px; }
.dl-sub { color: var(--muted); font-size: 11.5px; }

.tuning { color: var(--muted); font-size: 12.5px; margin-top: 12px; }

/* ── footer ─────────────────────────────────────────────── */
.foot {
  max-width: 980px;
  margin: 8px auto 0;
  padding: 16px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}
