:root {
  --bg: #0b0c10;
  --card: #14161c;
  --text: #e9eef7;
  --muted: #a9b2c3;
  --border: rgba(255,255,255,.1);
  --radius: 18px;

  --chord-size: 18px;
  --chord-line-height: 1.55;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(1200px 800px at 20% 0%, #14162b 0%, var(--bg) 55%);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}

.wrap {
  max-width: 980px;
  margin: 0 auto;
  padding: 16px 14px 40px;
}

/* IMPORTANT: give header a baseline padding so we can shrink it later */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 10px 0 12px;

  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  background: linear-gradient(to bottom, rgba(11,12,16,.92), rgba(11,12,16,.55), rgba(11,12,16,0));
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

h1 {
  margin: 0;
  font-size: clamp(20px, 3.5vw, 34px);
  line-height: 1.15;
}

.subtitle {
  color: var(--muted);
  font-size: 13px;
  margin-top: 4px;
}

.controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.btn {
  background: rgba(255,255,255,.06);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
}

.meta {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.pill {
  border: 1px solid var(--border);
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 12px;
}

.parts {
  margin-top: 14px;
  display: grid;
  gap: 12px;
}

.partTitle {
  font-weight: 700;
  margin-bottom: 8px;
}

.sheet {
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: var(--chord-size);
  line-height: var(--chord-line-height);

  /* key mobile fixes */
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;

  /* prevent clipping at right/bottom edges */
  padding: 14px 16px;
  margin: 0;

  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.18);

  /* wrapping behavior: best for mobile */
  white-space: pre-wrap;
  overflow-x: hidden;
  overflow-y: visible;

  /* long tokens shouldn't force overflow */
  overflow-wrap: anywhere;
  word-break: break-word;

  -webkit-overflow-scrolling: touch;
}

.status {
  color: var(--muted);
}

.error {
  margin-top: 12px;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255,120,120,.1);
  border: 1px solid rgba(255,120,120,.35);
  color: #ffb4b4;
}

/* Compact sticky header on mobile */
@media (max-width: 520px) {
  .wrap { padding: 12px 10px 30px; }

  header {
    padding: 4px 0 6px; /* shrink */
  }

  .topbar {
    gap: 6px;
  }

  h1 {
    font-size: 18px;
    line-height: 1.15;
  }

  .subtitle {
    font-size: 11px;
    margin-top: 2px;
  }

  .meta {
    margin-top: 4px;
    gap: 6px;
  }

  #meta .pill {
    font-size: 10px;
    padding: 4px 8px;
  }

  .controls {
    gap: 6px;
  }

  .btn {
    padding: 6px 9px;
    font-size: 12px;
  }

  .sheet {
    padding: 12px 14px;
  }
}

/* Extra-compact header for landscape / low-height screens */
@media (orientation: landscape) and (max-height: 430px) {
  .wrap { padding-top: 8px; }

  header {
    padding: 2px 0 4px;
  }

  h1 {
    font-size: 16px;
    line-height: 1.1;
  }

  .subtitle {
    display: none;
  }

  #meta {
    display: none !important;
  }

  .controls {
    gap: 5px;
  }

  .btn {
    padding: 5px 8px;
    font-size: 11px;
  }

  .sheet {
    padding: 10px 12px;
  }
}
