:root {
  color-scheme: light;
  --ink: #263b34;
  --muted: #65736c;
  --line: #e5e9e3;
  --line-strong: #cdd5cc;
  --paper: #ffffff;
  --surface: #f7f8f4;
  --surface-strong: #edf2e9;
  --accent: #42654d;
  --accent-strong: #304f39;
  --accent-soft: #e6eedf;
  --danger: #be123c;
  --warning: #b45309;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow: 0 10px 30px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 20px 45px rgba(15, 23, 42, 0.12);
  --radius: 18px;
  --radius-lg: 24px;

  /* spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-strong);
  font-weight: 600;
  text-decoration: none;
  transition: color 150ms ease;
}

a:hover {
  color: var(--accent);
}

/* ----- Headings (scoped to content/auth, not global) ----- */
.content h2,
.auth-panel h2 {
  color: var(--ink);
  font-size: clamp(1.5rem, 3vw, 2rem);
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0;
}

/* Section headings that follow content get top spacing */
.content > h2:not(:first-child),
.content > h3 {
  margin-top: var(--space-7);
  margin-bottom: var(--space-4);
}

.content h3,
.card h3,
.auth-panel h3 {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
  margin: 0;
}

.content p,
.card p,
.auth-panel p {
  line-height: 1.6;
  margin: 0;
}

/* ----- Layout shell ----- */
.shell {
  min-height: 100vh;
}

/* Mobile-first: sidebar hidden, top bar + bottom tabs drive nav. */
.sidebar {
  display: none;
}

.icon {
  flex: 0 0 auto;
  height: 1.4rem;
  width: 1.4rem;
}

/* ----- Mobile top bar ----- */
.mobile-bar {
  align-items: center;
  background: var(--paper);
  color: #f7f8f4;
  display: flex;
  gap: var(--space-3);
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  position: sticky;
  top: 0;
  z-index: 20;
}

.mobile-bar .brand-mark {
  height: 2.1rem;
  width: 2.1rem;
}

.mobile-bar h1 {
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 650;
  margin: 0;
}

.mobile-bar .button_to button {
  background: rgba(255, 255, 255, 0.10);
  font-size: 0.82rem;
  min-height: 2.25rem;
  padding: 0.45rem 0.8rem;
}

.mobile-bar .button_to button:hover {
  background: rgba(255, 255, 255, 0.18);
}

/* ----- Mobile bottom tab bar ----- */
.tab-bar {
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--line);
  bottom: 0;
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
  display: flex;
  left: 0;
  padding: var(--space-1) var(--space-1) max(var(--space-1), env(safe-area-inset-bottom));
  position: fixed;
  right: 0;
  z-index: 20;
}

.tab-link {
  align-items: center;
  border-radius: 10px;
  color: var(--muted);
  display: flex;
  flex: 1 1 0;
  flex-direction: column;
  font-weight: 600;
  gap: 0.2rem;
  min-height: 3.25rem;
  justify-content: center;
  padding: var(--space-2) var(--space-1);
  text-decoration: none;
}

.tab-link .icon {
  height: 1.5rem;
  width: 1.5rem;
}

.tab-label {
  font-size: 0.68rem;
  letter-spacing: 0.01em;
}

.tab-link-active {
  color: var(--accent);
}

.tab-link:active {
  background: rgba(15, 118, 110, 0.06);
}

.brand-block {
  align-items: center;
  display: flex;
  gap: var(--space-3);
  min-width: 0;
}

.brand-mark {
  align-items: center;
  background: var(--accent-soft);
  border-radius: 10px;
  box-shadow: none;
  color: var(--accent-strong);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.95rem;
  font-weight: 650;
  height: 2.65rem;
  justify-content: center;
  width: 2.65rem;
}

.brand-block h1 {
  color: var(--ink);
  font-size: 1.02rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  line-height: 1.15;
  margin: 0;
}

.brand-block p {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.25;
  margin: 0.15rem 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-section {
  display: flex;
  gap: var(--space-2);
  margin: 0 calc(-1 * var(--space-4));
  overflow-x: auto;
  padding: 0 var(--space-4) var(--space-1);
  scrollbar-width: none;
}

.nav-section::-webkit-scrollbar {
  display: none;
}

.nav-link {
  align-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  color: var(--muted);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.9rem;
  font-weight: 600;
  min-height: 2.65rem;
  padding: 0.6rem 0.9rem;
  text-decoration: none;
  transition: background-color 150ms ease, color 150ms ease;
}

.nav-link:hover {
  background: var(--surface);
  color: var(--ink);
}

.nav-link-active {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent-strong);
}

.nav-divider {
  background: var(--line);
  display: none;
  height: 1px;
  margin: var(--space-1) 0;
  width: 100%;
}

.content {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: 0 auto;
  max-width: 1180px;
  /* extra bottom space so fixed tab bar never covers content */
  padding: var(--space-5) var(--space-4) calc(4.5rem + env(safe-area-inset-bottom));
  width: 100%;
}

/* sidebar nav icon spacing */
.nav-link .icon {
  height: 1.2rem;
  width: 1.2rem;
  margin-right: var(--space-1);
}

/* ----- Auth ----- */
.auth-shell {
  align-items: center;
  display: grid;
  min-height: 100vh;
  padding: var(--space-5);
}

.auth-panel {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: 0 auto;
  max-width: 26rem;
  padding: var(--space-6);
  width: 100%;
}

.auth-brand {
  margin-bottom: var(--space-2);
}

.auth-brand h1 {
  color: var(--ink);
}

.auth-brand p {
  color: var(--muted);
}

/* ----- Toolbar (page header row) ----- */
.toolbar {
  align-items: flex-start;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  justify-content: space-between;
}

.toolbar > div {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

/* ----- Card grid ----- */
.grid {
  display: grid;
  gap: var(--space-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 18rem), 1fr));
}

.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-5);
  transition: box-shadow 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.card:hover {
  border-color: var(--line-strong);


}

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

/* ----- Tables ----- */
table {
  background: var(--paper);
  border: 1px solid var(--line);
  border-collapse: separate;
  border-radius: var(--radius);
  border-spacing: 0;
  box-shadow: none;
  display: block;
  max-width: 100%;
  overflow-x: auto;
  width: 100%;
}

thead,
tbody,
tr {
  width: 100%;
}

th,
td {
  border-bottom: 1px solid var(--line);
  min-width: 8rem;
  padding: 0.85rem 1rem;
  text-align: left;
  vertical-align: middle;
}

th {
  background: var(--surface);
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

tbody tr {
  transition: background-color 120ms ease;
}

tbody tr:hover {
  background: rgba(15, 118, 110, 0.035);
}

tr:last-child td {
  border-bottom: 0;
}

/* ----- Forms ----- */
form:not(.button_to) {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  display: grid;
  gap: var(--space-4);
  max-width: 52rem;
  padding: var(--space-5);
}

/* Forms inside cards / auth panels are bare */
.card form:not(.button_to),
.auth-panel form:not(.button_to) {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
}

label,
legend {
  color: #334155;
  display: grid;
  font-size: 0.88rem;
  font-weight: 600;
  gap: var(--space-2);
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  display: grid;
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-4);
}

fieldset .card {
  box-shadow: none;
}

input,
textarea,
select {
  background: #ffffff;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--ink);
  font: inherit;
  min-height: 2.75rem;
  padding: 0.65rem 0.85rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
  width: 100%;
}

input::placeholder,
textarea::placeholder {
  color: #94a3b8;
}

textarea {
  line-height: 1.55;
  min-height: 7.5rem;
  resize: vertical;
}

input[type="checkbox"],
input[type="radio"] {
  accent-color: var(--accent);
  min-height: auto;
  width: auto;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(20, 184, 166, 0.16);
  outline: none;
}

/* ----- Buttons ----- */
button,
input[type="submit"],
.button {
  align-items: center;
  background: var(--accent);
  border: 1px solid transparent;
  border-radius: 10px;
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  font: inherit;
  font-weight: 600;
  gap: var(--space-2);
  justify-content: center;
  line-height: 1.1;
  min-height: 2.75rem;
  padding: 0.7rem 1.1rem;
  text-decoration: none;
  transition: background-color 150ms ease, box-shadow 150ms ease, transform 120ms ease;
  white-space: nowrap;
  width: fit-content;
}

button:hover,
input[type="submit"]:hover,
.button:hover {
  background: var(--accent-strong);
  box-shadow: none;
  color: #ffffff;

}

button:active,
input[type="submit"]:active,
.button:active {
  transform: translateY(0);
}

button:focus-visible,
input[type="submit"]:focus-visible,
.button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.button.secondary,
button.secondary,
input.secondary {
  background: var(--paper);
  border-color: var(--line-strong);
  color: var(--ink);
}

.button.secondary:hover,
button.secondary:hover,
input.secondary:hover {
  background: var(--surface-strong);
  color: var(--ink);
  box-shadow: none;
}

.button_to {
  display: inline-block;
  margin: 0;
}

/* ----- Notices ----- */
.notice {
  background: #ecfdf5;
  border: 1px solid #99f6e4;
  border-radius: var(--radius);
  color: #304f39;
  font-weight: 600;
  padding: 0.85rem 1.1rem;
}

.alert {
  background: #fff7ed;
  border-color: #fed7aa;
  color: var(--warning);
}

audio {
  display: block;
  max-width: 100%;
  width: 100%;
}

.song-number {
  background: var(--accent-soft);
  border-radius: 999px;
  color: var(--accent-strong);
  display: inline-flex;
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: 0.04em;
  padding: 0.2rem 0.55rem;
  width: fit-content;
}

.repertoire-card {
  position: relative;
}

.card-link::after {
  content: "";
  inset: 0;
  position: absolute;
}

.search-form {
  max-width: none !important;
}

.search-controls,
.section-heading {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.search-controls input[type="search"] {
  flex: 1 1 18rem;
}

.audio-groups {
  display: grid;
  gap: var(--space-4);
  margin-top: var(--space-4);
}

.audio-group {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  display: grid;
  gap: var(--space-4);
  padding: var(--space-5);
}

.audio-group h4 {
  font-size: 1rem;
  margin: 0;
}

.audio-track {
  border-top: 1px solid var(--line);
  display: grid;
  gap: var(--space-3);
  padding-top: var(--space-4);
}

.audio-track > div {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.section-heading {
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.pdf-viewer {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  height: min(72vh, 56rem);
  min-height: 32rem;
  width: 100%;
}

.empty-state {
  background: var(--paper);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  color: var(--muted);
  padding: var(--space-6);
  text-align: center;
}

.setlist-picker {
  max-height: 34rem;
  overflow-y: auto;
}

.setlist-row {
  align-items: center;
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: var(--space-3);
  grid-template-columns: minmax(0, 1fr) 6rem;
  padding: var(--space-2) 0;
}

.setlist-row:last-child {
  border-bottom: 0;
}

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

.setlist-song > span {
  align-items: center;
  display: flex;
  gap: var(--space-2);
}

.setlist-position {
  font-size: 0.72rem;
}

.setlist-position input {
  min-height: 2.25rem;
  padding: 0.4rem;
}

.inline-check {
  align-items: center;
  display: flex;
  flex-direction: row;
}

.compact-list {
  margin-bottom: 0;
  padding-left: 1.4rem;
}

/* ----- Responsive ----- */
@media (min-width: 640px) {
  .toolbar {
    align-items: center;
    flex-direction: row;
  }

  .content {
    padding: var(--space-6) var(--space-6) calc(4.5rem + env(safe-area-inset-bottom));
  }
}

@media (min-width: 1024px) {
  /* Desktop: real sidebar, hide mobile chrome. */
  .mobile-bar,
  .tab-bar {
    display: none;
  }

  .sidebar {
    align-content: start;
    background: var(--paper);
    border-right: 1px solid var(--line);
    color: #f7f8f4;
    display: grid;
    gap: var(--space-5);
    height: 100dvh;
    overflow-y: auto;
    padding: var(--space-5);
    position: sticky;
    top: 0;
  }

  .brand-block {
    margin-bottom: var(--space-1);
  }

  .nav-section {
    display: grid;
    gap: var(--space-2);
    margin: 0;
    overflow: visible;
    padding: 0;
  }

  .nav-link {
    width: 100%;
  }

  .nav-divider {
    display: block;
  }

  .nav-footer {
    align-self: stretch;
    margin-top: auto;
  }

  .nav-footer .button_to,
  .nav-footer button {
    width: 100%;
  }

  .content {
    padding: var(--space-7) var(--space-6);
  }
}

/* Shared member UI */
body { font-size: 15px; }
.shell, .content, .card, .toolbar > div, fieldset { min-width: 0; }
.content { gap: 1.5rem; }
.content h2, .auth-panel h2 { font-weight: 600; letter-spacing: -0.045em; line-height: 1.2; }
.content h3 { line-height: 1.4; }
.content p, .content a, .audio-track strong { overflow-wrap: anywhere; }
.mobile-bar { border-bottom: 1px solid var(--line); padding-top: max(.75rem, env(safe-area-inset-top)); padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
.mobile-bar .button_to button { background: var(--surface); color: var(--muted); min-height: 44px; }
.mobile-bar .button_to button:hover { background: var(--accent-soft); }
.tab-link-active { background: var(--accent-soft); color: var(--accent-strong); }
.tab-bar { gap: .25rem; box-shadow: none; }
.tab-label { font-size: .7rem; }
.nav-link { gap: .5rem; min-height: 44px; }
.nav-caption, .eyebrow { color: var(--muted); font-size: .7rem; font-weight: 600; letter-spacing: .13em; text-transform: uppercase; }
.nav-caption { margin: .5rem .9rem; }
.member-profile { display: flex; align-items: center; gap: .75rem; padding: 1rem 0; border-top: 1px solid var(--line); color: var(--ink); }
.member-profile small { display: block; color: var(--muted); margin-top: .25rem; }
.avatar { background: var(--surface-strong); border-radius: 50%; width: 40px; height: 40px; display: grid; place-items: center; flex-shrink: 0; font-weight: 600; }
.page-heading { display: flex; flex-direction: column; align-items: flex-start !important; gap: .4rem !important; }
.welcome-panel { background: #eaf0e3; border: 1px solid #dce5d3; border-radius: 24px; padding: clamp(1.5rem, 4vw, 2.75rem); display: grid; gap: .75rem; }
.welcome-panel .eyebrow { color: var(--accent-strong); }
.event-heading { display: flex; align-items: center; gap: 1rem; }
.date-tile { display: flex; flex-direction: column; align-items: center; justify-content: center; background: var(--surface-strong); border-radius: 14px; width: 58px; min-height: 64px; flex-shrink: 0; color: var(--accent-strong); }
.date-tile span { font-size: .65rem; text-transform: uppercase; letter-spacing: .08em; }
.date-tile strong { font-size: 1.5rem; font-weight: 600; }
.status-badge { display: inline-flex; width: fit-content; border-radius: 99px; padding: .35rem .7rem; background: var(--surface-strong); color: var(--accent-strong); font-size: .78rem; font-weight: 600; }
.card { gap: 1rem; }
.card:focus-within { border-color: var(--accent); }
.card .button_to, .card .button_to button { width: 100%; }
.card details { border-top: 1px solid var(--line); padding-top: .5rem; }
summary { cursor: pointer; color: var(--muted); min-height: 44px; padding: .75rem 0; font-weight: 600; }
details form { margin-top: .5rem; }
.compact-list li { padding: .35rem 0; }
.repertoire-card { gap: .75rem; }
.repertoire-card .card-link { margin-top: auto; padding-top: .5rem; font-size: .85rem; }
.repertoire-card h3 a { color: var(--ink); }
.repertoire-card .song-number { border-radius: 10px; padding: .5rem .7rem; }
.search-form label { gap: .75rem; }
.search-controls { flex-wrap: nowrap; }
.search-controls input[type="search"] { min-width: 0; flex: 1; }
.search-controls .button { flex-shrink: 0; }
.auth-panel { padding: 2rem; box-shadow: 0 20px 80px #263b3408; }
.auth-panel input[type="submit"] { width: 100%; }
.auth-shell { min-height: 100dvh; }
input, textarea, select { min-width: 0; font-size: 16px; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; flex-shrink: 0; }
label:has(input[type="checkbox"]), label:has(input[type="radio"]) { min-height: 44px; }
.skip-link { position: fixed; top: -100px; left: 1rem; z-index: 50; padding: 1rem; background: var(--paper); }
.skip-link:focus { top: 1rem; }
.admin-shortcuts { display: flex; flex-wrap: wrap; gap: .5rem; }
.admin-shortcuts a { background: var(--paper); border: 1px solid var(--line); border-radius: 99px; padding: .75rem 1rem; font-size: .85rem; }
@media (max-width: 639px) {
  .content { padding-left: max(1rem, env(safe-area-inset-left)); padding-right: max(1rem, env(safe-area-inset-right)); }
  .card { padding: 1.25rem; }
  .toolbar > .button { align-self: flex-start; }
  .search-controls { flex-wrap: wrap; }
  .search-controls input[type="search"] { flex-basis: 100%; }
  .pdf-viewer { min-height: 20rem; height: 60dvh; }
  .setlist-row { grid-template-columns: minmax(0, 1fr) 4rem; }
  .auth-shell { padding: 1rem; }
}
@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: 250px minmax(0, 1fr); }
  .sidebar { display: flex; flex-direction: column; height: 100dvh; overflow-y: auto; }
  .content { padding: 3rem clamp(2rem, 4vw, 4rem); }
  .nav-footer { margin-top: auto; }
  .admin-shortcuts { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
