:root {
  --ink: #0a0a09;
  --bone: #eae4d8;
  --red: #ff2b18;
  --smoke: #7a756c;
  --panel: #121210;
  --line: #2a2926;
  --head-bg: #161512;
  --ok: #3d8f6a;
  --font-display: "Anton", Impact, sans-serif;
  --font-body: "Space Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: clip;
  max-width: 100%;
}

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--bone);
  background: var(--ink);
  min-height: 100vh;
  overflow-x: clip;
  max-width: 100%;
  width: 100%;
  -webkit-font-smoothing: antialiased;
}

.grain {
  position: fixed;
  inset: -100px;
  z-index: 50;
  pointer-events: none;
  opacity: 0.09;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='300' height='300'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='300' height='300' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain 0.6s steps(4) infinite;
}

@keyframes grain {
  0% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(-30px, 20px);
  }
  50% {
    transform: translate(20px, -30px);
  }
  75% {
    transform: translate(-20px, -20px);
  }
  100% {
    transform: translate(0, 0);
  }
}

#app {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: min(1100px, 100%);
  margin: 0 auto;
  padding: 16px 14px 48px;
  min-width: 0;
}

.top {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  margin-bottom: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

.top-brand-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.top-aside {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  flex-shrink: 0;
  padding-top: 4px;
}

.top-nav {
  display: flex;
  gap: 14px;
  align-items: center;
}

/* Bare REC-style text links — never a red slab. */
.text-link {
  appearance: none;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  font-family: var(--font-body);
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--smoke);
  cursor: pointer;
  line-height: 1.2;
}

a.text-link {
  color: var(--smoke);
}

.text-link:hover,
a.text-link:hover {
  color: var(--bone);
}

.text-link:focus-visible,
a.text-link:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 3px;
  color: var(--bone);
}

.add-song-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.add-song {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--bone);
  cursor: pointer;
  font-family: var(--font-body);
}

.add-song:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.add-song__plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  background: #000;
  border: 2px solid #000;
  box-shadow: inset 0 0 0 1px var(--line);
  color: var(--bone);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1;
}

.add-song__label {
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bone);
}

.add-song:hover .add-song__label,
.add-song:focus-visible .add-song__label {
  color: var(--red);
}

.add-song:focus-visible {
  outline: none;
}

.add-song:focus-visible .add-song__plus {
  outline: 2px solid var(--red);
  outline-offset: 3px;
}

a.brand-block {
  display: block;
  text-decoration: none;
  color: inherit;
}

a.brand-block:hover .brand .zilla,
a.brand-block:focus-visible .brand .zilla {
  color: color-mix(in srgb, var(--red) 82%, var(--bone));
}

a.brand-block:focus-visible {
  outline: 1px solid var(--red);
  outline-offset: 4px;
}

.brand {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 9vw, 4rem);
  letter-spacing: 0.02em;
  line-height: 0.9;
  text-transform: uppercase;
  color: var(--bone);
}

.brand .zilla {
  color: var(--red);
}

h1 {
  margin: 6px 0 0;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--red);
}

h2 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.35rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 400;
}

.muted,
.status {
  color: var(--smoke);
  font-size: 0.78rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.session-slot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: var(--smoke);
}

.session-slot strong {
  color: var(--bone);
  font-weight: 700;
}

.board-shell {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

/* ——— Song list (replaces spreadsheet) ——— */

.song-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--line);
  background: var(--panel);
}

.song-row {
  border-bottom: 1px solid var(--line);
}

.song-row:last-child {
  border-bottom: none;
}

.song-row__bar {
  display: grid;
  grid-template-columns: 1.75rem 3.5rem minmax(0, 1fr) auto auto;
  gap: 8px 10px;
  align-items: start;
  padding: 10px 10px;
  min-width: 0;
}

.song-num {
  font-family: var(--font-display);
  font-size: 1.35rem;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--smoke);
  padding-top: 4px;
  text-align: center;
}

.song-art {
  display: flex;
  flex-direction: column;
  gap: 4px;
  align-items: stretch;
}

.cover {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 0;
  background: #222;
  display: block;
  filter: contrast(1.05) saturate(0.92);
}

.song-art .cover {
  width: 100%;
  aspect-ratio: 1;
  height: auto;
  max-width: 56px;
}

.move-stack {
  display: flex;
  gap: 3px;
}

.song-info {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding-top: 2px;
}

.song-title {
  font-weight: 700;
  color: var(--bone);
  font-size: 0.88rem;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.song-artist {
  color: var(--smoke);
  font-size: 0.72rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.stream-links {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
}

.stream-links a {
  color: var(--red);
  font-size: 0.68rem;
  letter-spacing: 0.02em;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.stream-links a:hover {
  color: var(--bone);
}

.song-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
  padding-top: 2px;
}

.vote-stack {
  display: flex;
  gap: 4px;
}

.vote-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 36px;
  min-height: 40px;
  padding: 4px 6px;
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--bone);
  border-radius: 0;
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
}

.vote-btn .vote-count {
  font-size: 0.62rem;
  color: var(--smoke);
  margin-top: 2px;
}

.vote-btn.on-knarly {
  background: color-mix(in srgb, var(--ok) 35%, var(--ink));
  border-color: var(--ok);
}

.vote-btn.on-lame {
  background: color-mix(in srgb, var(--red) 28%, var(--ink));
  border-color: var(--red);
}

.vote-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.key-control {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  margin: 0;
  font-size: 0.65rem;
  letter-spacing: 0;
  text-transform: none;
  color: var(--smoke);
}

.key-control select {
  padding: 2px 4px;
  font-size: 0.68rem;
  max-width: 72px;
}

.chevron {
  align-self: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  background: var(--ink);
  color: var(--bone);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.15s ease, color 0.15s ease;
}

.chevron:hover,
.chevron:focus-visible {
  border-color: var(--red);
  color: var(--red);
  outline: none;
}

.song-row.is-open .chevron {
  transform: rotate(180deg);
  border-color: var(--red);
  color: var(--red);
}

.song-roster {
  display: none;
  padding: 8px 12px 12px;
  border-top: 1px dashed var(--line);
  background: color-mix(in srgb, var(--ink) 55%, var(--panel));
}

.song-row.is-open .song-roster {
  display: block;
  animation: roster-in 0.2s ease;
}

@keyframes roster-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.roster-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.roster-row {
  margin: 0;
  padding: 4px 2px;
  border: none;
  background: transparent;
}

.roster-row.is-self .roster-line strong {
  color: var(--red);
}

.roster-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  font-size: 0.8rem;
  line-height: 1.35;
  padding-bottom: 4px;
  border-bottom: 1px dotted color-mix(in srgb, var(--line) 80%, transparent);
}

.roster-line strong {
  font-size: 0.8rem;
  font-weight: 700;
  flex: 0 1 auto;
  min-width: 0;
}

.roster-instruments {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 4px;
  margin-left: auto;
  min-width: 0;
}

.role-pills {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  justify-content: flex-end;
}

.role-pill {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 9rem;
  padding: 1px 2px 1px 7px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 70%, var(--ink));
  color: var(--bone);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.role-pill__label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.role-pill__x {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--smoke);
  cursor: pointer;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0 4px;
}

.role-pill__x:hover,
.role-pill__x:focus-visible {
  color: var(--red);
  outline: none;
}

.instrument-slot {
  position: relative;
  flex: 0 0 auto;
}

.instrument-caret {
  appearance: none;
  width: 1.55rem;
  height: 1.55rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--smoke);
  font-size: 0.55rem;
  line-height: 1;
  cursor: pointer;
}

.instrument-caret:hover,
.instrument-caret:focus-visible,
.instrument-caret[aria-expanded="true"] {
  color: var(--bone);
  border-color: var(--red);
  outline: none;
}

.instrument-caret:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.instrument-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  z-index: 20;
  min-width: 10.5rem;
  max-height: 14rem;
  overflow: auto;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.instrument-option,
.instrument-option-row {
  display: flex;
  width: 100%;
  align-items: center;
  gap: 2px;
}

.instrument-option {
  appearance: none;
  flex: 1 1 auto;
  margin: 0;
  padding: 6px 8px;
  border: 0;
  background: transparent;
  color: var(--bone);
  font-size: 0.78rem;
  text-align: left;
  cursor: pointer;
}

.instrument-option:hover,
.instrument-option:focus-visible {
  background: color-mix(in srgb, var(--red) 18%, transparent);
  outline: none;
}

.instrument-option:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.instrument-option.is-empty {
  color: var(--smoke);
}

.instrument-option.is-custom {
  color: var(--red);
  font-style: italic;
}

.instrument-forget {
  appearance: none;
  flex: 0 0 auto;
  width: 1.5rem;
  height: 1.5rem;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--smoke);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
}

.instrument-forget:hover,
.instrument-forget:focus-visible {
  color: var(--red);
  outline: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--panel);
  color: var(--bone);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 14px;
  margin-bottom: 14px;
}

.hidden {
  display: none !important;
}

.login-landing {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 24px) 18px
    calc(env(safe-area-inset-bottom, 0px) + 24px);
}

.login-shell {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: inset 4px 0 0 var(--red);
  padding: 28px 22px 24px;
}

.login-shell .brand {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: clamp(2.6rem, 10vw, 3.4rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--bone);
  line-height: 0.95;
}

.login-shell h1 {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.login-lede {
  margin: 0 0 18px;
  max-width: 34ch;
}

.login-form {
  display: grid;
  gap: 12px;
}

.login-submit {
  width: 100%;
  min-height: 48px;
  margin-top: 4px;
  font-size: 1rem;
}

.login-error {
  margin: 0;
  color: var(--red);
  font-size: 0.78rem;
  font-weight: 700;
}

label {
  display: grid;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--smoke);
}

input,
select,
textarea,
button {
  font: inherit;
}

input,
select,
textarea {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--ink);
  color: var(--bone);
}

.btn {
  border: none;
  border-radius: 0;
  padding: 8px 14px;
  background: var(--red);
  color: var(--bone);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.ghost {
  background: transparent;
  color: var(--bone);
  border: 1px solid var(--line);
}

.btn.icon {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn.tiny {
  padding: 2px 6px;
  font-size: 0.7rem;
}

.btn.tiny.danger {
  color: var(--bone);
  background: color-mix(in srgb, var(--red) 72%, #1a0a0a);
  border: 1px solid color-mix(in srgb, var(--bone) 28%, var(--red));
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1;
}

.btn.tiny.danger:hover,
.btn.tiny.danger:focus-visible {
  background: var(--red);
  outline: none;
}

.move-stack .btn.tiny {
  flex: 1;
  min-height: 28px;
  min-width: 0;
  padding: 2px 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.desk {
  display: grid;
  grid-template-columns: 2.75rem minmax(0, 1fr);
  gap: 0;
  align-items: start;
}

.tabs {
  position: relative;
  z-index: 5;
  align-self: start;
}

.tabs-rail {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

.tab {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 2.75rem;
  min-height: 8.5rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--line);
  border-right: none;
  border-radius: 6px 0 0 6px;
  background: color-mix(in srgb, var(--panel) 88%, var(--ink));
}

.tab.is-main {
  box-shadow: inset -3px 0 0 transparent;
}

.tab.active {
  border-color: var(--red);
  background: var(--panel);
  z-index: 1;
}

.tab.active.is-main {
  box-shadow: inset 3px 0 0 var(--red);
}

.tab-main {
  appearance: none;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin: 0;
  padding: 14px 0 10px;
  border: none;
  background: transparent;
  color: var(--smoke);
  cursor: pointer;
  font: inherit;
}

.tab.active .tab-main {
  color: var(--bone);
}

.tab-name {
  display: block;
  /* File-spine tabs: upright page text, rotated −90° */
  transform: rotate(-90deg);
  white-space: nowrap;
  font-family: var(--font-display);
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  line-height: 1;
}

.tab-x {
  appearance: none;
  position: absolute;
  top: 2px;
  right: 2px;
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--smoke);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
}

.tab-x:hover,
.tab-x:focus-visible {
  color: var(--red);
  outline: none;
}

@media (max-width: 859px) {
  .desk {
    grid-template-columns: 2.75rem minmax(0, 1fr);
    gap: 0;
  }

  .tabs {
    position: sticky;
    top: 8px;
  }

  .tab {
    min-height: 6.5rem;
  }

  .tab-name {
    font-size: 0.82rem;
  }
}

@media (min-width: 860px) {
  .desk {
    grid-template-columns: 2.75rem minmax(0, 1fr);
    gap: 0;
  }

  .tabs {
    position: sticky;
    top: 12px;
  }

  .board-shell {
    border-left: 1px solid var(--line);
    padding-left: 14px;
  }
}

.comments {
  margin-top: 18px;
}

.comments textarea {
  width: 100%;
  margin-bottom: 8px;
}

.comment {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.comment strong {
  display: block;
  font-size: 0.85rem;
}

.comment time {
  color: var(--smoke);
  font-size: 0.72rem;
}

dialog {
  border: 1px solid var(--line);
  border-radius: 0;
  padding: 0;
  max-width: 440px;
  width: calc(100% - 24px);
  background: var(--panel);
  color: var(--bone);
}

dialog::backdrop {
  background: rgb(10 10 9 / 72%);
}

.help-card,
.search-card {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.custom-instrument-label {
  display: grid;
  gap: 6px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--smoke);
}

.custom-instrument-label input {
  font: inherit;
  text-transform: none;
  letter-spacing: 0;
  color: var(--bone);
  background: var(--ink);
  border: 1px solid var(--line);
  padding: 10px;
}

.legend-inline {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.row {
  display: flex;
  gap: 8px;
}

.row input {
  flex: 1;
}

.search-hit {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.search-hit img,
.search-hit .cover {
  width: 44px;
  height: 44px;
  border-radius: 0;
  object-fit: cover;
  flex-shrink: 0;
}

.search-hit button {
  margin-left: auto;
}

code {
  color: var(--red);
}

@media (max-width: 640px) {
  .brand {
    font-size: 2.5rem;
  }

  .login-shell {
    padding: 24px 16px 20px;
  }

  .song-row__bar {
    grid-template-columns: 1.4rem 2.75rem minmax(0, 1fr) auto auto;
    gap: 6px 8px;
    padding: 10px 8px;
  }

  .song-num {
    font-size: 1.1rem;
  }

  .song-art .cover {
    max-width: 44px;
  }

  .song-title {
    font-size: 0.78rem;
  }

  .song-artist {
    font-size: 0.66rem;
  }

  .vote-btn {
    min-width: 32px;
    min-height: 36px;
    padding: 3px 4px;
  }

  .key-control select {
    max-width: 64px;
  }

  .chevron {
    width: 32px;
    height: 32px;
  }
}

@media (min-width: 720px) {
  .song-row__bar {
    grid-template-columns: 2rem 3.75rem minmax(0, 1fr) auto auto;
    gap: 10px 14px;
    padding: 12px 14px;
  }

  .song-tools {
    flex-direction: row;
    align-items: center;
  }

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

@media (prefers-reduced-motion: reduce) {
  .grain {
    animation: none;
  }

  .song-row.is-open .song-roster {
    animation: none;
  }

  .chevron {
    transition: none;
  }
}
