:root {
  --action: #f97316;
  --error: #a00;
  --focus: #1b4fa8;
  --ground: #eef3f8;
  --gutter: max(1rem, calc((100% - 40rem) / 2));
  --header: #173a6a;
  --ink: #14253d;
  --line: #c5d3e3;
  --link: #1b4fa8;
  --muted: #3d5068;
  --on-action: #1a1206;
  --panel: #fff;
  --submit: #173a6a;
  --tab: #0b7575;
  --tab-text: #0b6f6f;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --error: #ff8a8a;
    --focus: #9cc2ff;
    --ground: #0f1826;
    --header: #14305a;
    --ink: #e8eef6;
    --line: #2c3d55;
    --link: #9cc2ff;
    --muted: #a9b8cb;
    --panel: #172335;
    --submit: #2f6bc9;
    --tab-text: #5fd0d0;
  }
}

body {
  background: var(--ground);
  color: var(--ink);
  font-family: system-ui, sans-serif;
  line-height: 1.5;
  margin: 0;
  overflow-wrap: anywhere;
}

a {
  color: var(--link);
}

/* The browser's own selection and caret take the palette too. */
::selection {
  background: var(--tab);
  color: #fff;
}

input,
textarea {
  caret-color: var(--submit);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

h1 {
  font-size: 1.5rem;
  margin: 1rem 0 0.5rem;
}

h1,
h2,
h3 {
  text-wrap: balance;
}

/* Text under 16px in a field makes a phone browser zoom the page when the field is tapped. */
button,
input,
textarea {
  font: inherit;
}

input,
textarea {
  background: var(--panel);
  border: 1.5px solid var(--muted);
  border-radius: 0.5rem;
  box-sizing: border-box;
  color: var(--ink);
}

input {
  min-height: 2.75rem;
  padding: 0 0.75rem;
}

textarea {
  padding: 0.5rem 0.75rem;
}

/* Safari draws its own search field unless it is told not to. */
input[type="search"] {
  -webkit-appearance: none;
  appearance: none;
}

input[type="file"] {
  background: none;
  border: 0;
  padding: 0;
}

/* One control system. A filled orange button is the main action on a song, a filled navy button
   submits a form, and an outlined button is anything else the owner can do. A link inside a
   sentence stays a plain link. */
button,
.button,
.play,
input[type="file"]::file-selector-button {
  align-items: center;
  background: var(--submit);
  border: 2px solid var(--submit);
  border-radius: 0.5rem;
  box-sizing: border-box;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 700;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0 1rem;
  text-decoration: none;
}

.button,
button.secondary,
input[type="file"]::file-selector-button {
  background: transparent;
  border-color: var(--muted);
  color: var(--ink);
}

input[type="file"]::file-selector-button {
  margin-right: 0.75rem;
}

.play {
  background: var(--action);
  border-color: var(--action);
  color: var(--on-action);
}

button:hover,
.button:hover,
.play:hover,
input[type="file"]::file-selector-button:hover {
  filter: brightness(0.9);
}

/* Off screen until a keyboard user tabs to it. */
.skip {
  background: var(--panel);
  border: 1px solid currentColor;
  left: 0.5rem;
  padding: 0.75rem 1rem;
  position: absolute;
  top: -5rem;
}

.skip:focus {
  top: 0.5rem;
}

header {
  background: var(--header);
  color: #fff;
  padding: 0.875rem var(--gutter) 0;
}

/* The header is dark in both colour schemes, so its focus ring is always white. */
header :focus-visible {
  outline-color: #fff;
}

.site-title {
  align-items: center;
  color: inherit;
  display: inline-flex;
  font-size: 1.3rem;
  font-weight: 800;
  min-height: 2.75rem;
  padding: 0.25rem 0;
  text-decoration: none;
}

/* The tabs stand on the bottom edge of the header, like dividers in a record-shop bin. */
nav {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  margin-top: 0.5rem;
  min-height: 3rem;
}

nav a:focus-visible {
  outline-offset: -3px;
}

nav a {
  align-items: center;
  background: var(--tab);
  border-radius: 0.625rem 0.625rem 0 0;
  color: #fff;
  display: inline-flex;
  font-size: 0.9rem;
  font-weight: 700;
  min-height: 2.75rem;
  padding: 0 0.875rem;
  text-decoration: none;
}

/* The current tab is taller and takes the page colour, so it joins the page below it. */
nav a[aria-current="page"] {
  background: var(--ground);
  color: var(--ink);
  min-height: 3rem;
  padding: 0 1rem;
}

main {
  padding: 0 var(--gutter) 2rem;
}

footer {
  align-items: center;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.9rem;
  gap: 0 1rem;
  padding: 0.5rem var(--gutter) 1rem;
}

footer form {
  margin: 0;
}

/* A form is a white card, like the panel of songs. */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0.5rem;
  margin: 1rem 0;
  padding: 0.25rem 1rem;
}

label {
  font-weight: 600;
}

label input,
label textarea {
  box-sizing: border-box;
  display: block;
  font-weight: 400;
  margin-top: 0.25rem;
  max-width: 100%;
  width: 100%;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.help {
  color: var(--muted);
  font-size: 0.9rem;
}

/* Messages stand out by a heavier outline and their text, not by colour alone. */
.error,
.notice {
  background: var(--panel);
  border: 2px solid var(--error);
  border-radius: 0.5rem;
  margin: 1rem 0;
  padding: 0.75rem 1rem;
}

.error {
  color: var(--error);
}

.notice {
  border-color: var(--tab);
}

ul.error {
  list-style: none;
}

.error li + li {
  margin-top: 0.25rem;
}

.notice p {
  margin: 0.25rem 0;
}

.search-head {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  justify-content: space-between;
}

.search-head a {
  font-size: 0.9rem;
}

.search-row {
  display: flex;
  gap: 0.5rem;
  margin: 0.25rem 0 0.5rem;
}

.search-row input {
  flex: 1;
  min-width: 0;
}

.songs {
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Each category is a divider tab standing on its own panel of songs. */
.group-head {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  gap: 0 1rem;
  justify-content: space-between;
  margin-top: 1.5rem;
}

.group h2 {
  background: var(--tab);
  border-radius: 0.625rem 0.625rem 0 0;
  color: #fff;
  font-size: 1.1rem;
  margin: 0;
  padding: 0.5rem 0.875rem;
}

.group-head .actions {
  margin: 0 0 0.25rem;
}

/* The song list sits in a white panel. The count tab above it joins its top left corner. */
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0 0.5rem 0.5rem 0.5rem;
  padding: 0 1rem;
}

/* Name, artist and categories on the left, the main action at the right edge. */
.song {
  border-bottom: 1px solid var(--line);
  column-gap: 0.75rem;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 0.75rem 0;
}

.song > * {
  grid-column: 1;
}

.song > .play {
  align-self: start;
  grid-column: 2;
  grid-row: 1 / span 3;
}

.song > .song-links {
  grid-column: 1 / -1;
}

.song:last-child {
  border-bottom: 0;
}

.song h2,
.song h3,
.song p {
  margin: 0;
}

.song h2,
.song h3 {
  font-size: 1.1rem;
}

/* Sorted by artist, the artist leads each song, so the line the list is ordered by is the one
   the eye runs down. */
.by-artist .artist {
  font-size: 1.1rem;
  font-weight: bold;
  order: -1;
}

.by-artist h2,
.by-artist h3 {
  font-size: 1rem;
  font-weight: normal;
}

.categories {
  color: var(--tab-text);
  font-size: 0.9rem;
  font-weight: 600;
}

.categories a {
  color: inherit;
  display: inline-block;
  padding: 0.5rem 0;
}

.category-index {
  display: flex;
  flex-wrap: wrap;
  font-size: 0.9rem;
  gap: 0.5rem;
  margin: 0 0 0.5rem;
}

.category-index a {
  align-items: center;
  background: var(--panel);
  border: 1.5px solid var(--muted);
  border-radius: 0.5rem;
  color: var(--ink);
  display: inline-flex;
  min-height: 2.75rem;
  padding: 0 0.875rem;
  text-decoration: none;
}

.comment {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: pre-wrap;
}

.count {
  background: var(--tab);
  border-radius: 0.625rem 0.625rem 0 0;
  color: #fff;
  font-weight: 700;
  margin: 0;
  padding: 0.5rem 0.875rem;
}

.song .song-links {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.actions {
  font-size: 0.9rem;
}

.song-links .actions {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.list-tools {
  align-items: flex-end;
  display: flex;
  flex-wrap: wrap;
  font-size: 0.9rem;
  gap: 0 1rem;
  justify-content: space-between;
}

.sort {
  font-size: 0.9rem;
  margin: 0 0 0 auto;
}

.sort a,
.sort strong {
  display: inline-block;
  padding: 0.75rem 0.25rem;
}
