:root {
  --paper: #f5f0e5;
  --paper-light: #fffdf8;
  --ink: #172523;
  --muted: #66706d;
  --brand: #174b47;
  --brand-soft: #dceae5;
  --accent: #d88a49;
  --border: #d8d0c0;
  --danger: #9a3f35;
  --song-font-size: 1.2rem;
  color-scheme: light;
  font-family: Arial, "Noto Sans Hebrew", sans-serif;
  background: var(--paper);
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 0%, rgb(255 255 255 / 65%), transparent 28rem),
    var(--paper);
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  min-height: 44px;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 70%, white);
  outline-offset: 2px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 3vw, 3rem);
  background: var(--brand);
  color: white;
}

.site-header h1,
.site-header p {
  margin: 0;
}

.site-header h1 {
  font-family: Georgia, "Noto Serif Hebrew", serif;
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  letter-spacing: -0.035em;
}

.eyebrow {
  margin: 0 0 0.25rem;
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.site-header .eyebrow {
  color: #f4c397;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.icon-button,
.install-button,
.wake-toggle {
  border: 1px solid rgb(255 255 255 / 30%);
  border-radius: 999px;
  background: rgb(255 255 255 / 10%);
  color: white;
}

.icon-button {
  width: 46px;
}

.install-button {
  padding-inline: 0.85rem;
}

.wake-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
}

.wake-toggle input {
  min-height: auto;
  accent-color: var(--accent);
}

.sample-notice {
  padding: 0.55rem 1rem;
  border-bottom: 1px solid #e2bc97;
  background: #fff0dc;
  color: #6c3b16;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 700;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(280px, 360px) minmax(0, 1fr);
  min-height: calc(100vh - 125px);
}

.sidebar {
  padding: 1.15rem;
  border-left: 1px solid var(--border);
  background: rgb(255 253 248 / 72%);
}

.search-box {
  display: grid;
  gap: 0.45rem;
  margin-bottom: 1rem;
  font-weight: 800;
}

.search-box input,
.compact-filter select {
  width: 100%;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: white;
  color: var(--ink);
}

.filter-card {
  display: block;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--paper-light);
  box-shadow: 0 8px 28px rgb(40 54 48 / 6%);
}

.section-heading,
.results-heading,
.song-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
}

.section-heading h2,
.section-heading h3,
.results-heading h2 {
  margin: 0;
}

.section-heading h2 {
  font-size: 1.05rem;
}

.helper {
  margin: 0.65rem 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.text-button {
  min-height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--brand);
  font-size: 0.85rem;
  font-weight: 800;
}

.chord-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  direction: ltr;
}

.chord-choice {
  min-width: 48px;
  min-height: 40px;
  padding: 0.35rem 0.65rem;
  border: 1px solid #bcc8c3;
  border-radius: 10px;
  background: white;
  color: var(--brand);
  font-weight: 800;
}

.chord-choice[aria-pressed="true"] {
  border-color: var(--brand);
  background: var(--brand);
  color: white;
}

.compact-filter {
  display: grid;
  gap: 0.65rem;
}

.compact-filter span {
  display: grid;
  gap: 0.15rem;
}

.compact-filter small {
  color: var(--muted);
}

.results-heading {
  align-items: baseline;
  padding: 0 0.25rem 0.5rem;
}

.results-heading h2 {
  font-size: 1.1rem;
}

#resultCount {
  color: var(--muted);
  font-size: 0.85rem;
}

.song-list {
  display: grid;
  gap: 0.55rem;
  max-height: 48vh;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.song-list button {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--paper-light);
  color: var(--ink);
  text-align: right;
}

.song-list button:hover,
.song-list button.active {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.result-title {
  display: block;
  font-weight: 850;
}

.result-meta,
.result-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.3rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.badge {
  padding: 0.15rem 0.42rem;
  border-radius: 999px;
  background: #ece7dc;
}

.badge.good {
  background: var(--brand-soft);
  color: var(--brand);
}

.badge.new {
  background: #ffead7;
  color: #7d4315;
}

.empty-results {
  padding: 1.2rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.5;
}

.reader {
  min-width: 0;
  padding: clamp(1rem, 3vw, 3rem);
}

.welcome-card {
  max-width: 760px;
  margin: clamp(1rem, 8vh, 6rem) auto;
  padding: clamp(1.5rem, 5vw, 4rem);
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--paper-light);
  box-shadow: 0 24px 70px rgb(45 53 46 / 10%);
}

.welcome-card h2 {
  margin: 0.15rem 0 0.75rem;
  font-family: Georgia, "Noto Serif Hebrew", serif;
  font-size: clamp(2rem, 5vw, 3.7rem);
  line-height: 1.05;
}

.welcome-card > p:not(.eyebrow) {
  max-width: 58ch;
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1.65;
}

.welcome-steps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin-top: 2rem;
}

.welcome-steps span {
  display: grid;
  gap: 0.5rem;
  padding: 1rem;
  border-radius: 16px;
  background: var(--brand-soft);
  font-weight: 800;
}

.welcome-steps b {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: var(--brand);
  color: white;
}

.song-view {
  max-width: 980px;
  margin: 0 auto;
}

.song-toolbar {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.song-toolbar button,
.source-link {
  min-height: 44px;
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--paper-light);
  color: var(--brand);
  font-weight: 800;
  text-decoration: none;
}

.song-toolbar button:disabled {
  cursor: default;
  opacity: 0.45;
}

.song-header {
  padding: clamp(1.2rem, 3vw, 2rem);
  border-radius: 22px 22px 0 0;
  background: var(--brand);
  color: white;
}

.song-header h2 {
  margin: 0.2rem 0;
  font-family: Georgia, "Noto Serif Hebrew", serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  line-height: 1.08;
}

.artist,
.credits {
  margin: 0.25rem 0 0;
}

.credits {
  color: #cfe1dc;
  font-size: 0.9rem;
}

.difficulty {
  display: inline-block;
  margin: 0;
  padding: 0.25rem 0.55rem;
  border-radius: 999px;
  background: #f3bd88;
  color: #402713;
  font-size: 0.8rem;
  font-weight: 900;
}

.source-link {
  flex: 0 0 auto;
  background: transparent;
  color: white;
}

.song-header-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.wake-status {
  min-height: 1.3rem;
  margin: 0;
  padding: 0.4rem 1rem;
  background: #e8f2ef;
  color: var(--brand);
  font-size: 0.82rem;
  text-align: center;
}

.diagram-section {
  padding: 1.25rem;
  border: 1px solid var(--border);
  border-top: 0;
  background: var(--paper-light);
}

.diagram-section h3 {
  font-size: 1.3rem;
}

.missing-summary {
  max-width: 34ch;
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.diagram-strip {
  display: flex;
  gap: 0.75rem;
  padding-top: 1rem;
  overflow-x: auto;
  direction: ltr;
}

.chord-card {
  flex: 0 0 138px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: white;
  color: var(--ink);
  text-align: center;
}

button.chord-card:hover {
  border-color: var(--brand);
  transform: translateY(-1px);
}

.chord-card.advanced {
  display: grid;
  min-height: 180px;
  place-content: center;
  background: #f4eee4;
}

.chord-name {
  margin-bottom: 0.45rem;
  color: var(--brand);
  font-size: 1.15rem;
  font-weight: 900;
}

.chord-note {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.4;
}

.chord-diagram {
  position: relative;
  width: 96px;
  height: 118px;
  margin: 0 auto;
  direction: ltr;
}

.string-line,
.fret-line,
.finger-dot,
.string-state {
  position: absolute;
}

.string-line {
  top: 18px;
  bottom: 4px;
  width: 1px;
  background: #6f7774;
}

.fret-line {
  right: 8px;
  left: 8px;
  height: 1px;
  background: #6f7774;
}

.fret-line.nut {
  height: 3px;
  background: var(--ink);
}

.finger-dot {
  width: 14px;
  height: 14px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: var(--brand);
}

.string-state {
  top: -2px;
  width: 18px;
  transform: translateX(-50%);
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  text-align: center;
}

.song-content {
  padding: clamp(1.2rem, 4vw, 3rem);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 22px 22px;
  background: var(--paper-light);
  font-family: Arial, "Noto Sans Hebrew", sans-serif;
  font-size: var(--song-font-size);
  line-height: 1.75;
}

.lyric-line {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  margin: 0.55rem 0;
  direction: rtl;
}

.lyric-line > span:not(.chord-segment) {
  white-space: pre-wrap;
}

.chord-segment {
  display: inline-grid;
  grid-template-rows: auto auto;
  align-items: end;
  white-space: pre-wrap;
}

.chord-segment > span:empty::before {
  content: "\00a0";
  visibility: hidden;
}

.inline-chord {
  width: max-content;
  min-height: auto;
  margin: 0 0 0.08rem 0.25rem;
  padding: 0.05rem 0.24rem;
  border: 0;
  border-radius: 5px;
  background: #fff0dc;
  color: #984d13;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.78em;
  font-weight: 900;
  line-height: 1.25;
  direction: ltr;
}

.plain-lyric {
  margin: 0.2rem 0;
}

.progression {
  width: fit-content;
  max-width: 100%;
  margin: 0.75rem 0;
  padding: 0.55rem 0.75rem;
  overflow-wrap: anywhere;
  border-right: 4px solid var(--accent);
  border-radius: 8px;
  background: #fff7eb;
  color: #7b4218;
  font-family: ui-monospace, Consolas, monospace;
  font-weight: 800;
  direction: ltr;
}

.song-space {
  height: 0.75rem;
}

.chord-dialog {
  width: min(92vw, 360px);
  padding: 1.5rem;
  border: 0;
  border-radius: 20px;
  background: var(--paper-light);
  box-shadow: 0 26px 80px rgb(0 0 0 / 30%);
}

.chord-dialog::backdrop {
  background: rgb(9 28 26 / 70%);
}

.dialog-close {
  position: absolute;
  top: 0.5rem;
  left: 0.5rem;
  width: 44px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 2rem;
}

.chord-dialog .chord-card {
  width: 180px;
  margin: 1rem auto 0;
  border: 0;
}

.empty-results {
  color: var(--muted);
}

@media (max-width: 900px) {
  .app-shell {
    display: block;
  }

  .sidebar {
    border-left: 0;
    border-bottom: 1px solid var(--border);
  }

  .song-list {
    max-height: 34vh;
  }

  .reader {
    padding: 1rem;
  }
}

@media (max-width: 620px) {
  .site-header {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .site-header .eyebrow,
  .wake-toggle span {
    display: none;
  }

  .header-actions {
    gap: 0.25rem;
  }

  .welcome-steps {
    grid-template-columns: 1fr;
  }

  .song-header,
  .section-heading {
    display: grid;
  }

  .source-link,
  .song-header-actions {
    width: fit-content;
  }

  .song-toolbar {
    position: sticky;
    top: 0.4rem;
    z-index: 5;
  }

  .song-toolbar button {
    flex: 1;
    padding-inline: 0.45rem;
    background: rgb(255 253 248 / 96%);
    font-size: 0.82rem;
  }
}

@media print {
  .site-header,
  .sample-notice,
  .sidebar,
  .song-toolbar,
  .wake-status,
  .source-link {
    display: none !important;
  }

  .app-shell {
    display: block;
  }

  .reader,
  .song-content {
    padding: 0;
    border: 0;
  }
}
