@import url("https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap");

:root,
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f3f2ee;
  --surface: #ffffff;
  --surface-raised: #faf9f6;
  --surface-muted: #eeede8;
  --line: #dfded8;
  --line-strong: #cac9c2;
  --text: #1c211f;
  --text-soft: #434a46;
  --muted: #626b65;
  --accent: #176a57;
  --accent-hover: #105443;
  --accent-soft: #e0eee9;
  --accent-text: #105443;
  --chord: #a63e28;
  --danger: #d44545;
  --font: "Vazirmatn", "Vazir", "IRANSansX", Tahoma, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111413;
  --surface: #191d1b;
  --surface-raised: #1e2421;
  --surface-muted: #242a27;
  --line: #303733;
  --line-strong: #454e49;
  --text: #f1f3ef;
  --text-soft: #cbd1cd;
  --muted: #98a19b;
  --accent: #68b9a2;
  --accent-hover: #83cbb7;
  --accent-soft: #1d3931;
  --accent-text: #91d5c2;
  --chord: #ff9a77;
  --danger: #ef6666;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  font-size: 16px;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  transition: background-color 180ms ease, color 180ms ease;
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
}

:is(button, a, input, select, .source-sheet-scroll):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

.shell {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding-bottom: 48px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  margin-inline: -20px;
  padding: 12px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
  transition: background-color 180ms ease, border-color 180ms ease;
}

.brand {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  border-radius: 12px;
}

.brand-mark svg {
  width: 23px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.brand-copy {
  display: grid;
  line-height: 1.2;
}

.brand-copy strong {
  font-size: 1rem;
  font-weight: 800;
}

.brand-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 500;
}

.header-actions {
  display: flex;
  flex: 1;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.searchbox {
  position: relative;
  display: flex;
  width: min(100%, 430px);
  height: 44px;
  align-items: center;
  color: var(--muted);
}

.searchbox input {
  width: 100%;
  height: 100%;
  padding: 0 42px 0 68px;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: 0;
  background: var(--surface);
  color: var(--text);
  appearance: none;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 180ms ease;
}

.searchbox input::-webkit-search-cancel-button {
  display: none;
}

.searchbox input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.searchbox input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 14%, transparent);
}

.search-icon {
  position: absolute;
  z-index: 1;
  right: 14px;
  width: 19px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
  pointer-events: none;
}

.search-clear {
  position: absolute;
  left: 39px;
  display: grid;
  width: 28px;
  height: 28px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.search-clear:hover {
  background: var(--surface-muted);
  color: var(--text);
}

.search-clear svg {
  width: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 2;
}

.search-shortcut {
  position: absolute;
  left: 11px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface-raised);
  color: var(--muted);
  font-family: inherit;
  font-size: 0.76rem;
  line-height: 1;
}

.icon-button {
  display: inline-grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  padding: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background-color 150ms ease, transform 150ms ease;
}

.icon-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-raised);
  color: var(--accent);
}

.icon-button:active:not(:disabled) {
  transform: scale(0.96);
}

.icon-button:disabled {
  opacity: 0.38;
  cursor: default;
}

.theme-icon {
  width: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

:root[data-theme="light"] .theme-icon-sun,
:root[data-theme="dark"] .theme-icon-moon {
  display: none;
}

.app-shell {
  display: grid;
  gap: 26px;
  min-width: 0;
  padding-top: 26px;
}

.surface {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  transition: background-color 180ms ease, border-color 180ms ease;
}

.page-intro {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px 20px;
  padding-block: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.page-intro h1,
.artist-hero h1,
.song-heading h1 {
  margin: 0;
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.collection-count {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
  white-space: nowrap;
}

.collection-section {
  display: grid;
  gap: 12px;
  min-width: 0;
}

.pagination {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 0.86rem;
}

.page-button {
  min-height: 44px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  cursor: pointer;
}

.page-button:hover:not(:disabled) {
  border-color: var(--line-strong);
  color: var(--accent);
}

.page-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-header h2,
.lyrics-header h2,
.transpose-main h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.section-header > span {
  color: var(--muted);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.artist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(245px, 1fr));
  gap: 10px;
}

.artist-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 18px;
  gap: 11px;
  align-items: center;
  min-width: 0;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color 150ms ease, background-color 150ms ease;
}

.artist-card:hover {
  border-color: var(--line-strong);
  background: var(--surface-raised);
}

.artist-avatar {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 1rem;
  font-weight: 800;
}

.artist-card-copy {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.artist-card-copy strong {
  overflow: hidden;
  font-size: 0.91rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.artist-card-copy small,
.song-artist {
  color: var(--muted);
  font-size: 0.76rem;
}

.ui-icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.card-chevron {
  color: var(--muted);
  transition: color 150ms ease, transform 150ms ease;
}

.artist-card:hover .card-chevron,
.song-card:hover .card-chevron {
  color: var(--accent);
  transform: translateX(-2px);
}

.song-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.song-card {
  display: grid;
  align-content: start;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  transition: border-color 150ms ease, background-color 150ms ease;
}

.song-card:hover {
  border-color: var(--line-strong);
  background: var(--surface-raised);
}

.song-card-heading,
.song-card-footer {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.song-card-heading > span:first-child {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.song-title {
  overflow: hidden;
  font-size: 0.98rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.verified-mark {
  display: inline-grid;
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--surface);
}

.verified-mark .ui-icon {
  width: 12px;
  height: 12px;
  stroke-width: 2.6;
}

.song-preview {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--text-soft);
  font-family: var(--font);
  font-size: 0.82rem;
  line-height: 1.6;
  direction: rtl;
  text-align: right;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.song-card-footer {
  grid-row: 3;
  align-self: end;
  align-items: center;
}

.song-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 2px 8px;
  border-radius: 7px;
  background: var(--surface-muted);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
}

.key-tag {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.back-link {
  display: inline-flex;
  width: fit-content;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.81rem;
  font-weight: 600;
  transition: color 150ms ease;
}

.back-link:hover {
  color: var(--accent);
}

.back-link .ui-icon {
  width: 15px;
}

.artist-view,
.song-page {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.artist-hero {
  display: flex;
  min-height: 130px;
  align-items: center;
  gap: 20px;
  padding: 20px;
}

.artist-avatar-large {
  width: 72px;
  height: 72px;
  flex: 0 0 auto;
  border-radius: 16px;
  font-size: 2rem;
}

.artist-hero .collection-count {
  margin-top: 8px;
}

.song-page {
  width: min(100%, 1040px);
  justify-self: center;
  gap: 16px;
}

.song-heading {
  display: grid;
  justify-items: start;
  gap: 6px;
  min-width: 0;
}

.song-heading-title,
.song-heading-details {
  display: flex;
  width: 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
}

.song-heading-details {
  gap: 6px 20px;
}

.verified-label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
}

.verified-label .verified-mark {
  width: 16px;
  height: 16px;
}

.verified-label .verified-mark .ui-icon {
  width: 10px;
}

.song-facts,
.song-facts > div {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.song-facts {
  flex-wrap: wrap;
  gap: 5px 16px;
  margin: 0;
  font-size: 0.84rem;
}

.song-facts:not(:has(dt)) {
  display: none;
}

.song-facts dt {
  color: var(--muted);
}

.song-facts dd {
  margin: 0;
  font-weight: 700;
}

.song-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 284px;
  align-items: start;
  gap: 16px;
  min-width: 0;
}

.transpose-card {
  position: sticky;
  top: 88px;
  grid-column: 2;
  grid-row: 1;
  padding: 16px;
  background: var(--surface-raised);
}

.transpose-main {
  display: grid;
  align-items: center;
  gap: 12px;
}

.transpose-controls {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  gap: 4px;
  align-items: center;
}

.transpose-button {
  position: relative;
  isolation: isolate;
  border: 0;
  background: transparent;
  color: var(--accent-text);
  font-size: 1.15rem;
  font-weight: 600;
}

.transpose-button::before {
  position: absolute;
  z-index: -1;
  inset: 5px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  content: "";
}

.transpose-button:hover:not(:disabled) {
  background: transparent;
  color: var(--accent-text);
}

.transpose-button:hover:not(:disabled)::before {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.transpose-display {
  display: grid;
  min-width: 0;
  justify-items: center;
  gap: 3px;
  text-align: center;
  line-height: 1.35;
}

.transpose-display strong {
  max-width: 100%;
  color: var(--accent-text);
  font-size: 1.3rem;
  overflow-wrap: anywhere;
}

.transpose-display span {
  color: var(--muted);
  font-size: 0.75rem;
  font-variant-numeric: tabular-nums;
}

.transpose-options {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 8px;
  margin-top: 8px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}

.accidental-control,
.transpose-reset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.79rem;
  font-weight: 600;
}

.accidental-switch {
  position: relative;
  display: flex;
}

.accidental-switch::before {
  position: absolute;
  inset: 3px 0;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  content: "";
}

.accidental-switch label {
  position: relative;
  display: grid;
  width: 34px;
  height: 36px;
  place-items: center;
}

.accidental-switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.accidental-switch span {
  display: grid;
  width: 28px;
  height: 24px;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 5px;
  font-size: 1rem;
  line-height: 1;
}

.accidental-switch input:hover + span {
  background: var(--surface-muted);
}

.accidental-switch input:checked + span {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
}

.accidental-switch input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (max-width: 760px), (any-pointer: coarse) {
  .accidental-switch::before {
    inset: 7px 5px;
  }

  .accidental-switch label {
    width: 44px;
    height: 44px;
  }
}

.transpose-reset {
  min-height: 44px;
  padding-inline: 6px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
}

.transpose-reset:disabled {
  opacity: 0.52;
  cursor: default;
}

.transpose-reset:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--accent-text);
}

.transpose-reset .ui-icon,
.source-link .ui-icon {
  width: 15px;
  height: 15px;
}

.source-link {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.79rem;
  font-weight: 600;
}

.source-link:hover {
  color: var(--accent-text);
}

.lyrics-panel {
  grid-column: 1;
  grid-row: 1;
  min-width: 0;
}

.lyrics-header {
  display: flex;
  min-height: 54px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  padding: 10px 20px;
  border-bottom: 1px solid var(--line);
}

.chord-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.chord-palette bdi {
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--surface-raised);
  color: var(--chord);
  font-size: 0.8rem;
  font-weight: 700;
}

.source-sheet-scroll {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 22px 20px 28px;
  overflow-x: auto;
  direction: rtl;
  scrollbar-color: var(--line-strong) transparent;
  scrollbar-width: thin;
}

.source-sheet-scroll:focus-visible {
  outline-offset: -3px;
}

.source-song-sheet {
  display: block;
  width: max-content;
  min-width: 100%;
  margin: 0;
  padding: 0;
  overflow: visible;
  border: 0;
  background: transparent;
  color: var(--text);
  font-family: var(--font);
  font-size: 1.03rem;
  font-weight: 400;
  line-height: 1.95;
  direction: ltr;
  tab-size: 4;
  text-align: right;
  white-space: pre;
}

.source-chord-token {
  color: var(--chord);
  font-weight: 700;
}

.source-mizan::after {
  content: "";
  border-right: 1px solid var(--danger);
}

.source-sheet-scroll ::selection {
  background: var(--accent-soft);
  color: var(--text);
}

.empty-state {
  display: grid;
  min-height: 130px;
  place-items: center;
  padding: 24px;
  border: 1px dashed var(--line-strong);
  border-radius: 15px;
  color: var(--muted);
  font-size: 0.85rem;
  text-align: center;
}

.missing-view {
  min-height: 300px;
  align-content: center;
  gap: 12px;
  border-style: solid;
}

.missing-view p {
  margin: 0;
}

.empty-icon {
  width: 30px;
  height: 30px;
  color: var(--accent);
}

.loading-panel {
  display: grid;
  min-height: 220px;
  margin: 0;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  font-size: 0.85rem;
}

@media (max-width: 760px) {
  .song-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .transpose-card,
  .lyrics-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .transpose-card {
    position: static;
    padding: 12px;
  }

  .transpose-main {
    grid-template-columns: auto minmax(0, 200px);
    justify-content: space-between;
    gap: 8px;
  }

  .transpose-options {
    margin-top: 8px;
    padding-top: 6px;
  }
}

@media (max-width: 700px) {
  .shell {
    width: min(100% - 24px, 1240px);
    padding-bottom: 28px;
  }

  .topbar {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 44px;
    gap: 10px;
    min-height: auto;
    margin-inline: -12px;
    padding: 10px 12px 12px;
  }

  .brand {
    justify-self: start;
  }

  .brand-mark {
    width: 38px;
    height: 38px;
  }

  .header-actions {
    display: contents;
  }

  .theme-toggle {
    grid-column: 2;
    grid-row: 1;
  }

  .searchbox {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
  }

  .app-shell {
    gap: 28px;
    padding-top: 24px;
  }

  .page-intro h1,
  .artist-hero h1,
  .song-heading h1 {
    font-size: 1.75rem;
  }

  .shell:has(.song-page) .topbar {
    position: static;
  }

  .app-shell:has(.song-page) {
    padding-top: 12px;
  }

  .song-page {
    gap: 12px;
  }

  .song-heading-details {
    justify-content: space-between;
  }

  .song-grid {
    grid-template-columns: 1fr;
  }

  .artist-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .artist-hero {
    min-height: 132px;
    padding: 20px;
  }

  .artist-avatar-large {
    width: 68px;
    height: 68px;
    border-radius: 19px;
    font-size: 1.6rem;
  }

  .source-sheet-scroll {
    padding: 18px 14px 24px;
  }

  .source-song-sheet {
    font-size: 0.96rem;
    line-height: 1.95;
  }
}

@media (max-width: 430px) {
  .brand-copy small,
  .search-shortcut {
    display: none;
  }

  .searchbox input {
    padding-left: 42px;
  }

  .search-clear {
    left: 8px;
  }

  .page-intro {
    display: grid;
    gap: 7px;
  }

  .artist-grid {
    gap: 8px;
  }

  .artist-card {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 7px;
    padding: 8px;
  }

  .artist-card .artist-avatar {
    width: 32px;
    height: 32px;
    border-radius: 8px;
  }

  .artist-card .card-chevron {
    display: none;
  }

  .artist-card-copy strong {
    overflow-wrap: anywhere;
    white-space: normal;
  }

  .artist-hero {
    gap: 14px;
    padding: 16px;
  }

  .lyrics-header {
    padding-inline: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
