/* Learn by lyrics — light theme.
   Teal = the interface (focus, learning). Coral = energy and motivation (Check, progress, score).
   Green = success (right answers, Share). */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;

  --accent: #0d9488; /* teal: main colour */
  --accent-strong: #0f766e;
  --accent-text: #ffffff;
  --accent-soft: #f0fdfa;
  --accent-tint: #ccfbf1;

  --energy: #f97316; /* coral: Check, progress, motivation */
  --energy-strong: #ea580c;
  --energy-soft: #fff7ed;

  --good: #10b981; /* success */
  --good-text: #047857;
  --good-bg: #ecfdf5;
  --bad: #dc2626;
  --bad-bg: #fef2f2;
  --close: #b45309;
  --close-bg: #fffbeb;
  --gap-bg: #f0fdfa;

  --radius-sm: 10px;
  --radius: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 1px 2px rgb(15 23 42 / 0.04), 0 1px 3px rgb(15 23 42 / 0.05);
  --shadow: 0 1px 3px rgb(15 23 42 / 0.05), 0 8px 24px rgb(15 23 42 / 0.06);
  --shadow-pop: 0 12px 32px rgb(15 23 42 / 0.12);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Plus Jakarta Sans", "Inter", system-ui, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

h1, h2 { font-family: var(--font-display); line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
[hidden] { display: none !important; }
::selection { background: var(--accent-tint); color: var(--text); }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  /* Three columns: logo | search (always centred) | buttons. The side columns share the rest equally. */
  display: grid;
  /* The search box is at most 560px and always leaves ~400px on each side for the logo and the buttons
     (sign in, sign up, stats, language). Medium screens show icon-only buttons and leave less (below). */
  grid-template-columns: minmax(0, 1fr) minmax(0, min(560px, calc(100% - 860px))) minmax(0, 1fr);
  align-items: center;
  gap: 8px 24px;
  padding: 14px 32px;
  background: rgb(255 255 255 / 0.85);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
/* A thin teal → coral line: the "rhythm" of the page */
.site-header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) 55%, var(--energy) 100%);
  opacity: 0.85;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.brand img { width: 36px; height: 36px; margin: -4px 0; } /* headphones logo, transparent background */
.brand span { white-space: nowrap; }
.brand:hover span { color: var(--accent); }
.brand:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; }
.lang-picker { display: flex; align-items: center; gap: 6px; }
.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.header-btn:hover { border-color: var(--accent); color: var(--accent-strong); }
@media (max-width: 800px) {
  .header-btn span:last-child { display: none; } /* just the icons on phones */
  .header-btn { padding: 7px 10px; }
}
.header-actions { justify-self: end; display: flex; align-items: center; gap: 10px; }
/* Under 1600px the right-hand group must fit in its third of the header: "My stats" becomes its icon
   and a signed-in email is shortened. */
@media (max-width: 1599px) {
  #stats-btn span:last-child { display: none; }
  #stats-btn { padding: 7px 10px; }
  .account-btn.signed-in #account-label { max-width: 110px; }
}
.brand { justify-self: start; }

/* Account: "Sign in" button, avatar and menu */
.account-menu { position: relative; }
.account-btn .account-avatar {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 0.8rem;
  line-height: 1;
}
.account-btn.signed-in .account-avatar { background: var(--accent); color: #fff; font-weight: 700; position: relative; }
/* a little dot on the avatar: green synced, coral syncing/offline, red error */
.account-btn.signed-in .account-avatar::after {
  content: "";
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  background: var(--good);
}
.account-btn[data-sync="syncing"] .account-avatar::after,
.account-btn[data-sync="offline"] .account-avatar::after { background: var(--energy); }
.account-btn[data-sync="error"] .account-avatar::after { background: var(--bad); }
.account-btn.signed-in #account-label { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-list { left: auto; right: 0; min-width: 260px; }
.account-email { margin: 4px 10px 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.sync-status { margin: 0 10px 6px; color: var(--muted); }
@media (max-width: 800px) {
  .account-btn #account-label { display: none; }
}

/* Sign-in window */
.auth-dialog { width: min(440px, calc(100vw - 32px)); }
.auth-dialog > p { margin: 0 0 16px; }
.google-btn { width: 100%; gap: 10px; padding: 11px 16px; }
.auth-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.auth-divider::before,
.auth-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.auth-tabs { margin-bottom: 14px; }
.auth-note { margin: -4px 0 0; }
.auth-switch { margin: 16px 0 0; text-align: center; color: var(--muted); }
.auth-switch .link-btn { font-weight: 700; }
/* "Sign up" stands out next to "Sign in" */
.signup-btn { background: var(--accent); border-color: var(--accent); color: #fff; }
.signup-btn:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
.account-menu { display: flex; align-items: center; gap: 8px; }
.auth-form { display: grid; gap: 12px; }
.auth-form input { width: 100%; }
.auth-form .btn-primary { width: 100%; margin-top: 4px; }
.auth-message { margin: 0; font-weight: 600; }
.auth-message.ok { color: var(--good-text); }
.auth-message.fail { color: var(--bad); }

/* My stats */
.stats-dialog { width: min(720px, calc(100vw - 32px)); }
.stats-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 20px; }
.stats-tile {
  display: grid;
  gap: 2px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid var(--accent-tint);
}
.stats-tile strong { font-family: var(--font-display); font-size: 1.6rem; color: var(--accent-strong); line-height: 1.1; }
.stats-tile span { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.stats-tile.energy { background: var(--energy-soft); border-color: #fed7aa; }
.stats-tile.energy strong { color: var(--energy-strong); }
.stats-dialog h3 { font-family: var(--font-display); font-size: 1rem; margin: 0 0 10px; }
.stats-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; margin-bottom: 8px; }
.stats-table th {
  text-align: left;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border);
}
.stats-table td { padding: 7px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.stats-table td:nth-child(2) { color: var(--bad); font-weight: 600; }
.stats-table td:nth-child(3) { color: var(--close); font-weight: 600; }
.stats-table td:nth-child(4) { color: var(--good-text); font-weight: 600; }
.stats-table td:last-child { color: var(--muted); font-size: 0.8rem; }
.stats-table td:first-child { width: 34%; }
.stats-word { display: block; font-weight: 700; }
.stats-bar { display: block; height: 4px; margin-top: 4px; border-radius: 999px; background: var(--energy); opacity: 0.7; }
@media (max-width: 600px) { .stats-tiles { grid-template-columns: 1fr; } .stats-table td:last-child, .stats-table th:last-child { display: none; } }

/* Footer: links to the privacy policy and the terms of service */
.site-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 20px;
  padding: 8px 16px 32px;
  color: var(--muted);
  font-size: 0.85rem;
}
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--accent-strong); }

/* Offline notice */
.offline-banner {
  margin: 0;
  padding: 8px 16px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 600;
  background: var(--energy-soft);
  color: #9a3412;
  border-bottom: 1px solid #fed7aa;
}
.lang-picker select { border-radius: 999px; padding: 7px 12px; background: var(--surface); }

/* Search box in the middle of the header */
.header-search {
  width: 100%;
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--bg);
  overflow: hidden;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.header-search:hover { border-color: #cbd5e1; }
.header-search:focus-within {
  background: var(--surface);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgb(13 148 136 / 0.12);
}
.header-search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 11px 20px;
  outline: none;
  font-size: 0.95rem;
}
.header-search input::placeholder { color: var(--muted); }
.header-search-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  margin: 4px;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.95rem;
  display: grid;
  place-items: center;
  transition: background 0.15s;
}
.header-search-btn:hover { background: var(--accent-strong); }
.lang-icon { font-size: 1.1rem; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
@media (max-width: 800px) {
  /* On phones: logo and buttons on the first row, the search box on its own full-width row below. */
  .site-header { padding: 12px 16px; grid-template-columns: auto minmax(0, 1fr); }
  .header-search { grid-column: 1 / -1; grid-row: 2; }
  .header-actions { gap: 6px; }
  .brand span { white-space: nowrap; }
}
@media (max-width: 480px) {
  /* Very narrow: the logo icon alone, and the language list without its globe, so the buttons fit. */
  .brand span,
  .lang-icon { display: none; }
}
@media (min-width: 801px) and (max-width: 1100px) {
  /* Medium screens: the buttons show just their icons so the search box keeps its room. */
  .header-btn span:last-child { display: none; }
  .header-btn { padding: 7px 10px; }
  .site-header { grid-template-columns: minmax(0, 1fr) minmax(0, min(560px, calc(100% - 620px))) minmax(0, 1fr); }
}
@media (max-width: 1599px) {
  .lang-icon { display: none; } /* the language list alone, to save room */
}

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 28px;
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px;
}
@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; padding: 16px; gap: 16px; }
}
/* Wide screens: a third column on the right (ideas & bugs box, or my notes), 520px wide.
   On narrower screens that box goes under the lyrics, full width. */
@media (min-width: 1500px) {
  .layout { grid-template-columns: 280px 1fr 520px; max-width: 1840px; }
}

/* ---------- Right column: ideas & bugs box (home) and my notes (inside a song) ---------- */
.side-panel {
  grid-column: 1 / -1; /* under the lyrics on narrower screens */
  align-self: start;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
@media (min-width: 1500px) { .side-panel { grid-column: auto; position: sticky; top: 96px; } }
/* A soft coral corner: it's an invitation to take part */
.side-panel::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--energy));
}
.side-panel h2 { font-size: 1.05rem; line-height: 1.3; margin-bottom: 4px; }
.feedback-panel > p { margin: 0 0 12px; }
.feedback-form { display: grid; gap: 10px; }
.feedback-form textarea { width: 100%; resize: vertical; min-height: 110px; }
.feedback-form input { width: 100%; font-size: 0.9rem; }
.feedback-status { margin: 0; font-weight: 600; }
.feedback-status.ok { color: var(--good-text); }
.feedback-status.fail { color: var(--bad); }

/* My notes: two tabs (all songs / this song) over one writing area */
.notes-panel h2 { margin-bottom: 12px; }
.notes-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
}
.notes-tabs button {
  border: none;
  border-radius: 9px;
  padding: 7px 8px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.notes-tabs button:hover { color: var(--accent-strong); }
.notes-tabs button[aria-selected="true"] { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow-sm); }
.notes-caption { margin: 0 0 8px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.notes-panel textarea {
  width: 100%;
  min-height: 520px;
  resize: vertical;
  line-height: 1.6;
  background: #fffef8; /* a hint of paper */
}
.notes-status { margin: 6px 0 0; min-height: 1.2em; color: var(--good-text); font-weight: 600; }

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px 16px;
  align-self: start;
  position: sticky;
  top: 96px;
}
@media (max-width: 800px) { .sidebar { position: static; } }
.sidebar-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 0 4px 14px; }
.sidebar-head h2 { font-size: 1.15rem; }
.song-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.song-item { position: relative; }
.song-list .song-pick { padding-right: 38px; }
.song-menu { position: absolute; top: 8px; right: 8px; }
.song-list .song-menu-toggle {
  width: 28px;
  height: 28px;
  padding: 0;
  text-align: center;
  font-size: 1.1rem;
  line-height: 1;
  border-radius: 8px;
  color: var(--muted);
  opacity: 0;
}
.song-item:hover .song-menu-toggle,
.song-menu.open .song-menu-toggle,
.song-list .song-menu-toggle:focus-visible { opacity: 1; }
.song-list .song-menu-toggle:hover { background: var(--border); color: var(--text); }
@media (hover: none) { .song-list .song-menu-toggle { opacity: 1; } }
.song-menu-list {
  position: absolute;
  right: 0;
  top: 32px;
  z-index: 10;
  min-width: 140px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}
.song-list .song-menu-list button { color: var(--bad); padding: 8px 10px; border-left: none; }
.song-list .song-menu-list button:hover { background: var(--bad-bg); }
.song-list .song-menu-list .fav-item { color: var(--text); white-space: nowrap; }
.song-list .song-menu-list .fav-item:hover { background: var(--energy-soft); color: var(--energy-strong); }
.song-list .link-btn { color: var(--accent); font-size: 0.85rem; padding: 8px 10px; }
.song-list .link-btn:hover { background: none; text-decoration: underline; }
.song-list button {
  width: 100%;
  text-align: left;
  background: none;
  border: 1px solid transparent;
  border-left: 4px solid transparent;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.song-list button:hover { background: var(--bg); }
/* The open song: soft teal background and a thick teal bar on the left */
.song-list button[aria-current="true"] {
  background: var(--accent-soft);
  border-left-color: var(--accent);
}
.song-list button[aria-current="true"] .title { color: var(--accent-strong); }
.song-list .title { display: block; font-weight: 600; font-size: 0.95rem; line-height: 1.35; }
.song-list .meta { display: block; font-size: 0.8rem; color: var(--muted); margin-top: 2px; }
.song-list .section-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  padding: 12px 12px 6px;
}
.song-section ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
/* "Recommended songs" title with the country flag (opens the country list) and ↻ (four other songs) */
.recommended-head { display: flex; align-items: center; gap: 6px; }
.recommended-head > span { flex: 1; }
.country-picker { position: relative; text-transform: none; letter-spacing: 0; }
.song-list .flag-btn,
.song-list .shuffle-btn {
  width: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: 0.8rem;
  color: var(--muted);
}
.song-list .flag-btn:hover,
.song-list .shuffle-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--surface); }
.song-list .shuffle-btn { font-size: 0.95rem; line-height: 1; }
.flag { width: 20px; height: 15px; border-radius: 3px; object-fit: cover; box-shadow: 0 0 0 1px rgb(15 23 42 / 0.08); }
.country-list {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  z-index: 15;
  min-width: 200px;
  padding: 6px;
  display: grid;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-pop);
}
.song-list .country-list button {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  font-size: 0.9rem;
  color: var(--text);
  border-left: none;
}
.song-list .country-list button[aria-checked="true"] { background: var(--accent-soft); color: var(--accent-strong); font-weight: 600; }
.song-list button.song-pick[aria-busy="true"] { opacity: 0.6; cursor: progress; }
/* "Your song history" stands out with its own soft teal background; recommended songs come after it. */
.song-section.history {
  background: linear-gradient(180deg, var(--accent-soft), #f5fffd);
  border: 1px solid var(--accent-tint);
  border-radius: var(--radius);
  padding: 4px 6px 8px;
  margin-bottom: 12px;
}
.song-section.history .section-label { color: var(--accent-strong); }
/* Two tabs at the top of the history: "Your song history" / "★ Your favorites" */
.history-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 6px 2px 8px; }
.song-list .history-tabs button {
  width: auto;
  text-align: center;
  padding: 6px 4px;
  border-left: none;
  border-radius: 9px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}
.song-list .history-tabs button:hover { background: var(--surface); color: var(--accent-strong); }
.song-list .history-tabs button[aria-selected="true"] { background: var(--surface); color: var(--accent-strong); box-shadow: var(--shadow-sm); }
.history-empty { padding: 8px 12px 10px; list-style: none; }
.fav-star { color: var(--energy); }
.song-section.history button.song-pick:hover { background: var(--surface); }
.song-section.history button.song-pick[aria-current="true"] { background: var(--surface); box-shadow: var(--shadow-sm); }

/* ---------- Main ---------- */
.practice {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: 36px 40px;
  min-width: 0;
}
@media (max-width: 800px) { .practice { padding: 20px; } }
/* Home: a calm welcome with a hint of music */
.empty-state {
  position: relative;
  padding: 12px 0 8px;
}
.empty-state::before {
  content: "♪";
  position: absolute;
  right: 4px;
  top: -10px;
  font-size: 5rem;
  line-height: 1;
  color: var(--accent-tint);
  pointer-events: none;
}
.empty-state h1 { font-size: 2rem; margin-bottom: 12px; max-width: 18ch; }
.empty-state p { color: var(--muted); max-width: 56ch; font-size: 1.02rem; }
.empty-state p strong { color: var(--energy-strong); }
.empty-state .tip {
  color: var(--text);
  background: var(--accent-soft);
  border: 1px solid var(--accent-tint);
  border-radius: var(--radius);
  padding: 14px 18px;
  max-width: 62ch;
  margin-top: 20px;
}
.empty-state .tip strong { color: var(--accent-strong); }
/* Big search box on the home screen */
.home-search {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 640px;
  margin-top: 24px;
  padding: 8px 8px 8px 20px;
  background: var(--surface);
  border: 2px solid var(--accent-tint);
  border-radius: 999px;
  box-shadow: 0 8px 24px rgb(13 148 136 / 0.1);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.home-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 5px rgb(13 148 136 / 0.12), 0 8px 24px rgb(13 148 136 / 0.12); }
.home-search-icon { font-size: 1.4rem; color: var(--accent); }
.home-search input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 12px 4px;
  font-size: 1.1rem;
  outline: none;
  box-shadow: none;
}
.home-search input:focus { box-shadow: none; }
.home-search .btn { border-radius: 999px; padding: 12px 26px; font-size: 1rem; }
.song-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 24px; }
.song-head h1 { font-size: 2.1rem; }
.song-head p { margin: 6px 0 0; }
#song-artist { font-size: 1.05rem; font-weight: 500; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 18px;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.05s;
}
.btn:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-small { padding: 6px 12px; font-size: 0.85rem; border-radius: 10px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); box-shadow: 0 2px 8px rgb(13 148 136 / 0.25); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }
/* Check: the key action, in coral */
.btn-energy { background: var(--energy); border-color: var(--energy); color: #fff; box-shadow: 0 2px 10px rgb(249 115 22 / 0.3); }
.btn-energy:hover { background: var(--energy-strong); border-color: var(--energy-strong); color: #fff; }
.btn-ghost { background: transparent; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Player ---------- */
.player-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--bg), var(--surface));
  padding: 20px;
  margin-bottom: 28px;
  display: grid;
  gap: 14px;
}
.player-wrap { position: relative; width: 100%; max-width: 600px; aspect-ratio: 16 / 9; margin: 0 auto; }
.player-wrap iframe, .player-wrap #player {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.no-video {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 18px; border-radius: var(--radius); background: var(--accent-soft);
}
.no-video p { margin: 0; color: var(--muted); }
.video-form { max-width: 600px; width: 100%; margin: 0 auto; }
.video-form label { display: block; font-size: 0.8rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }
.player-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; max-width: 600px; width: 100%; margin: 0 auto; }

/* Follow the lyrics */
.follow-btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: #fff; }
.follow-btn[aria-pressed="true"]:hover { background: var(--accent-strong); color: #fff; }
.follow-adjust { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: auto; }
.follow-offset { min-width: 5ch; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; color: var(--accent-strong); }
.follow-status { margin: 0 auto; max-width: 600px; width: 100%; }
.lyrics.following .line {
  margin: 0 -14px;
  padding: 0 14px;
  border-radius: 12px;
  transition: background 0.3s, box-shadow 0.3s;
}
/* The line being sung */
.lyrics .line.now { background: var(--accent-soft); box-shadow: inset 4px 0 0 var(--accent); }

input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgb(13 148 136 / 0.12); outline: none; }
.error { color: var(--bad); margin: 6px 0 0; font-size: 0.875rem; }

/* ---------- Toolbar ---------- */
/* First line: difficulty + options on the left, full lyrics / answers on the right.
   Second line: Check on the left, Share on the far right. */
.toolbar,
.action-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.toolbar { margin-bottom: 12px; }
.action-bar {
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.toolbar .spacer,
.action-bar .spacer { flex: 1; }
#check-btn { min-width: 140px; }
.level { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 0.85rem; font-weight: 600; }
.level select { font-weight: 600; border-radius: 12px; padding: 9px 12px; }
/* Score: progress and motivation, in coral */
.score {
  margin: 0 0 20px;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--energy-soft);
  border-left: 4px solid var(--energy);
  color: #9a3412;
  font-weight: 600;
}

/* ---------- Lyrics ---------- */
/* The lyrics scroll inside their own box; the wheel there doesn't move the page (overscroll: contain). */
/* As tall as the screen below the sticky header: scrolling the page down, the lyrics fill the screen. */
.lyrics-box {
  /* screen minus the sticky header (~70px) and the spacing under the box (~70px) */
  height: calc(100vh - 152px);
  height: calc(100dvh - 152px);
  min-height: 320px;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 12px 28px 40px;
  margin: 0 -8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, var(--surface) 0%, #fcfdfe 100%);
  scrollbar-width: thin;
  scrollbar-color: var(--accent-tint) transparent;
}
.lyrics-box::-webkit-scrollbar { width: 10px; }
.lyrics-box::-webkit-scrollbar-thumb { background: var(--accent-tint); border-radius: 999px; border: 3px solid var(--surface); }
@media (max-width: 800px) { .lyrics-box { height: calc(100dvh - 150px); padding: 8px 16px 32px; margin: 0; } }
.lyrics { font-size: 1.2rem; line-height: 2.4; overflow-wrap: anywhere; color: #1e293b; }
.lyrics .line { min-height: 1em; }

/* Options menu (own gaps, more/fewer, shuffle, vocabulary only) and Share menu (link, print) */
.options-menu,
.share-menu { position: relative; }
.options-list {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  z-index: 15;
  min-width: 270px;
  padding: 8px;
  display: grid;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--accent-tint);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgb(13 148 136 / 0.14), 0 2px 6px rgb(15 23 42 / 0.06);
}
.share-list { left: auto; right: 0; min-width: 240px; }
.options-list button {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: none;
  border: none;
  border-radius: 12px;
  padding: 8px 10px;
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.options-list button:hover { background: var(--accent-soft); color: var(--accent-strong); }
/* Every item starts with the same rounded icon badge, so all the texts line up */
.menu-icon {
  flex: none;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
}
.options-list button:hover .menu-icon { background: var(--accent); color: #fff; }
/* More / fewer gaps: a green "+" and a coral "−" so they read at a glance */
[data-action="more"] .menu-icon { background: var(--good-bg); color: var(--good-text); font-size: 1.3rem; }
[data-action="fewer"] .menu-icon { background: var(--energy-soft); color: var(--energy-strong); font-size: 1.3rem; }
[data-action="more"]:hover .menu-icon { background: var(--good); color: #fff; }
[data-action="fewer"]:hover .menu-icon { background: var(--energy); color: #fff; }
[data-action="vocab"] .menu-icon { font-size: 0.8rem; }
.menu-separator { height: 1px; background: var(--border); margin: 6px 4px; }
/* "Vocabulary only": an on/off switch on the right instead of a tick */
.options-list .switch {
  margin-left: auto;
  flex: none;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  transition: background 0.2s;
}
.options-list .switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgb(15 23 42 / 0.2);
  transition: transform 0.2s;
}
.options-list [aria-checked="true"] .switch { background: var(--accent); }
.options-list [aria-checked="true"] .switch::after { transform: translateX(16px); }
.share-list .menu-icon { background: var(--good-bg); }
.share-list button:hover { background: var(--good-bg); color: var(--good-text); }
.share-list button:hover .menu-icon { background: var(--good); color: #fff; }

/* Create your own gaps */
.edit-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  margin-bottom: 20px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  border: 1px solid var(--accent-tint);
  color: var(--accent-strong);
  font-weight: 600;
}
.edit-bar .spacer { flex: 1; }
.lyrics.editing .word.editable { cursor: pointer; padding: 0 3px; border-radius: 6px; }
.lyrics.editing .word.editable:hover { background: var(--accent-soft); outline: 1px dashed var(--accent); }
.lyrics.editing .word.picked { background: var(--accent); color: var(--accent-text); }
.gap-info { margin: 0 0 14px; }
.share-box {
  display: grid;
  gap: 8px;
  margin-bottom: 20px;
  padding: 14px 16px;
  border-radius: var(--radius);
  background: var(--good-bg);
  border: 1px solid #a7f3d0;
  color: var(--good-text);
}
.share-box p { margin: 0; font-weight: 500; }
.share-box input { width: 100%; font-size: 0.85rem; }
.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
  text-decoration: underline;
}
.lyrics .stanza-break { height: 1em; }

/* The blanks: soft teal with a teal underline; green when right */
.gap {
  display: inline-block;
  font: inherit;
  font-size: 1.08rem;
  font-weight: 500;
  line-height: 1.4;
  padding: 2px 8px;
  margin: 0 2px;
  border: none;
  border-bottom: 2px solid var(--accent);
  border-radius: 8px 8px 2px 2px;
  background: var(--gap-bg);
  color: var(--accent-strong);
  text-align: center;
  max-width: 100%;
  transition: background 0.15s, box-shadow 0.15s;
}
.gap:focus { outline: none; background: var(--accent-tint); box-shadow: 0 3px 0 -1px var(--accent); }
.gap.correct { background: var(--good-bg); border-bottom-color: var(--good); color: var(--good-text); font-weight: 600; }
.gap.wrong { background: var(--bad-bg); border-bottom-color: var(--bad); color: var(--bad); font-weight: 600; }
.gap.close { background: var(--close-bg); border-bottom-color: #f59e0b; color: var(--close); font-weight: 600; }
.word { border-radius: 5px; transition: background 0.12s; }
.word:hover { background: var(--accent-soft); }
.word-tip {
  position: absolute;
  z-index: 40;
  max-width: 280px;
  padding: 6px 12px;
  border-radius: 10px;
  background: var(--text);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  pointer-events: none;
  box-shadow: var(--shadow-pop);
}
.answer { font-size: 0.85rem; color: var(--good-text); font-weight: 700; margin: 0 4px 0 2px; }

/* ---------- Dialog ---------- */
.dialog {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  width: min(600px, calc(100vw - 32px));
  padding: 24px;
  box-shadow: var(--shadow-pop);
}
.dialog::backdrop { background: rgb(15 23 42 / 0.45); backdrop-filter: blur(3px); }
.dialog form { display: grid; gap: 14px; }
.dialog p { margin: 0; }
.dialog label { display: grid; gap: 6px; font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.dialog textarea { resize: vertical; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.dialog-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.dialog-head h2 { font-size: 1.3rem; }
.dialog-step { display: grid; gap: 14px; }
.dialog a { color: var(--accent); }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; max-height: 45vh; overflow-y: auto; }
.results button {
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.results button:hover { border-color: var(--accent); background: var(--accent-soft); box-shadow: var(--shadow-sm); }
.results .title { display: block; font-weight: 600; }
.results .meta { display: block; font-size: 0.8rem; color: var(--muted); }
.results button { display: grid; grid-template-columns: 1fr auto; gap: 0 10px; align-items: center; }
.results .source {
  grid-row: span 2;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent-strong);
  background: var(--accent-tint);
  border-radius: 999px;
  padding: 3px 10px;
  white-space: nowrap;
}
.results button[aria-busy="true"] { opacity: 0.6; cursor: progress; }
/* YouTube search results: thumbnail on the left, title and channel on the right. */
.video-results button { grid-template-columns: 128px 1fr; gap: 0 14px; }
.video-results img { grid-row: span 2; width: 128px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius-sm); background: var(--bg); }
.video-results .title { align-self: end; }
.video-results .meta { align-self: start; }
.web-links { display: grid; gap: 8px; }
.web-links p { margin: 0; }
.link-row { display: flex; flex-wrap: wrap; gap: 8px; }
#song-source a { color: var(--accent); font-weight: 600; }

/* ---------- Spotify ---------- */
.spotify-wrap { display: grid; gap: 8px; width: 100%; max-width: 600px; margin: 0 auto; }
.spotify-wrap iframe { width: 100%; border: 0; border-radius: var(--radius); }
.spotify-wrap p { margin: 0; }

/* Share: same shape as Check, success green */
.btn-share { background: var(--good); border-color: var(--good); color: #fff; box-shadow: 0 2px 8px rgb(16 185 129 / 0.25); }
.btn-share:hover { background: #059669; border-color: #059669; color: #fff; }

/* ---------- Print: only the sheet with the lyrics and blank lines is printed ---------- */
.print-sheet { display: none; }
@media print {
  body > *:not(.print-sheet) { display: none !important; }
  body { background: #fff; color: #000; }
  .print-sheet { display: block; font: 13pt/2 Georgia, "Times New Roman", serif; color: #000; }
  .print-sheet h1 { font-size: 20pt; margin: 0 0 2pt; }
  .print-artist { margin: 0 0 14pt; color: #444; }
  .print-break { height: 10pt; }
  .print-gap { display: inline-block; border-bottom: 1px solid #000; margin: 0 2pt; height: 1em; vertical-align: baseline; }
  .print-footer { margin-top: 18pt; font-size: 9pt; color: #666; font-family: system-ui, sans-serif; }
}
