:root {
  --app-teal: #0f766e;
  --app-teal-dark: #0b4f4a;
  --app-ink: #14213d;
  --app-muted: #64748b;
  --app-bg: #f5f7fb;
  --app-border: #d9e2ec;
  --app-focus: #f59e0b;
  --bottom-nav-height: 72px;
}

* {
  letter-spacing: 0;
}

body {
  min-height: 100vh;
  background: var(--app-bg);
  color: #111827;
  padding-bottom: var(--bottom-nav-height);
}

a {
  color: var(--app-teal);
}

a:hover {
  color: var(--app-teal-dark);
}

.bg-app {
  background: var(--app-teal-dark);
}

.brand-mark {
  display: inline-grid;
  width: 2rem;
  height: 2rem;
  place-items: center;
  border-radius: 50%;
  background: #f59e0b;
  color: #111827;
}

.btn {
  border-radius: 8px;
  font-weight: 600;
}

.btn-primary {
  --bs-btn-bg: var(--app-teal);
  --bs-btn-border-color: var(--app-teal);
  --bs-btn-hover-bg: var(--app-teal-dark);
  --bs-btn-hover-border-color: var(--app-teal-dark);
  --bs-btn-active-bg: var(--app-teal-dark);
  --bs-btn-active-border-color: var(--app-teal-dark);
}

.btn-outline-primary {
  --bs-btn-color: var(--app-teal);
  --bs-btn-border-color: var(--app-teal);
  --bs-btn-hover-bg: var(--app-teal);
  --bs-btn-hover-border-color: var(--app-teal);
}

.btn-touch {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.page-shell {
  padding-top: 1.5rem;
  padding-bottom: 2rem;
}

.narrow-shell {
  max-width: 820px;
}

.page-header,
.section-heading {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-header h1,
.dashboard-hero h1 {
  margin: 0;
  color: var(--app-ink);
  font-weight: 800;
}

.section-kicker {
  margin: 0 0 .25rem;
  text-transform: uppercase;
  font-size: .76rem;
  font-weight: 800;
  color: var(--app-teal);
}

.header-actions,
.form-actions,
.resource-actions,
.setlist-controls {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  align-items: center;
}

.flash-stack {
  display: grid;
  gap: .75rem;
  margin-bottom: 1rem;
}

.auth-shell {
  min-height: calc(100vh - 4rem);
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.auth-panel {
  width: min(100%, 460px);
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 1.25rem;
  box-shadow: 0 1rem 2.5rem rgb(15 23 42 / 8%);
}

.auth-icon {
  display: inline-grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: .75rem;
  border-radius: 50%;
  background: #ccfbf1;
  color: var(--app-teal-dark);
  font-size: 1.4rem;
}

.dashboard-hero {
  display: grid;
  gap: 1rem;
  padding: 1.25rem;
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
}

.dashboard-search .input-group {
  box-shadow: 0 .75rem 1.75rem rgb(15 23 42 / 7%);
}

.quick-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: .75rem;
  margin: 1rem 0;
}

.stats-grid,
.detail-grid,
.resource-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.stat-tile,
.detail-section,
.resource-card,
.song-card,
.setlist-item,
.danger-zone {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
}

.stat-tile {
  padding: 1rem;
  display: grid;
  gap: .2rem;
}

.stat-label {
  color: var(--app-muted);
  font-weight: 700;
}

.stat-tile strong {
  font-size: 2rem;
  line-height: 1.1;
}

.stat-title {
  font-size: 1.2rem;
}

.section-block {
  margin-top: 1.5rem;
}

.song-list {
  display: grid;
  gap: .75rem;
}

.compact-list {
  gap: .5rem;
}

.song-card {
  display: grid;
  gap: 1rem;
  padding: 1rem;
}

.song-card h2,
.song-card h3 {
  overflow-wrap: anywhere;
}

.song-card-main {
  min-width: 0;
}

.song-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.song-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem .75rem;
  color: var(--app-muted);
  font-size: .95rem;
}

.register-badges {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}

.empty-state {
  background: #fff;
  border: 1px dashed #b7c4d5;
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  color: var(--app-muted);
}

.empty-state i {
  display: block;
  font-size: 2rem;
  margin-bottom: .5rem;
  color: var(--app-teal);
}

.empty-state.compact {
  padding: 1rem;
  text-align: left;
}

.empty-state.compact i {
  display: inline-block;
  margin-right: .4rem;
  margin-bottom: 0;
  font-size: 1.1rem;
}

.toolbar-search,
.history-filters {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: .75rem;
}

.history-filters {
  display: grid;
  gap: .75rem;
}

.filter-actions {
  display: flex;
  gap: .5rem;
  align-items: end;
}

.stacked-form {
  display: grid;
  gap: 1rem;
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 1rem;
}

.form-section {
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 1rem;
  background: #f8fafc;
}

.form-section-heading {
  margin-bottom: 1rem;
}

.form-section-heading h2 {
  margin: 0 0 .25rem;
  font-size: 1.05rem;
  color: var(--app-ink);
}

.form-section-heading p {
  margin: 0;
  color: var(--app-muted);
}

.lyrics-editor {
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
}

.detail-section,
.danger-zone {
  padding: 1rem;
}

.detail-section h2,
.danger-zone h2 {
  font-size: 1.1rem;
  margin-bottom: .75rem;
  color: var(--app-ink);
}

.register-list {
  display: grid;
  gap: .75rem;
}

.register-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: .75rem;
  border: 1px solid var(--app-border);
  border-radius: 8px;
}

.memory-pill {
  flex: 0 0 auto;
  display: inline-grid;
  width: 2.75rem;
  height: 2.75rem;
  place-items: center;
  border-radius: 50%;
  background: var(--app-ink);
  color: #fff;
  font-weight: 800;
}

.prewrap,
.lyrics-preview,
.lyrics-text {
  white-space: pre-wrap;
}

.lyrics-preview {
  max-height: 26rem;
  overflow: auto;
  line-height: 1.7;
  background: #f8fafc;
  border-radius: 8px;
  padding: 1rem;
}

.lyrics-shell {
  min-height: calc(100vh - var(--bottom-nav-height));
  background: #071817;
  color: #f8fafc;
  padding: 1rem;
}

.lyrics-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
  justify-content: space-between;
  max-width: 980px;
  margin: 0 auto 1rem;
}

.lyrics-reader {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem 0 3rem;
}

.lyrics-reader h1 {
  font-size: 2rem;
  line-height: 1.1;
  margin-bottom: .5rem;
}

.lyrics-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  color: #b5f4ea;
  margin-bottom: 1.5rem;
}

.lyrics-text {
  font-size: var(--lyrics-font-size, 1.45rem);
  line-height: 1.65;
  color: #fff;
}

body.reader-mode .navbar,
body.reader-mode .app-footer,
body.reader-mode .mobile-nav {
  display: none;
}

body.reader-mode {
  padding-bottom: 0;
}

body.reader-mode .lyrics-shell {
  min-height: 100vh;
}

.keyboard-panel {
  background: #1f2937;
  border: 1px solid #0f172a;
  border-radius: 8px;
  padding: .75rem;
  color: #f8fafc;
  box-shadow: inset 0 0 0 2px rgb(255 255 255 / 5%);
}

.keyboard-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: .75rem;
  padding: .6rem .75rem;
  margin-bottom: .75rem;
  background: #111827;
  border-radius: 8px;
  color: #d1d5db;
  text-transform: uppercase;
  font-size: .82rem;
}

.memory-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: .75rem;
}

.memory-slot {
  display: grid;
  grid-template-columns: 3.25rem 1fr;
  gap: .75rem;
  align-items: start;
  background: #f8fafc;
  color: #111827;
  border: 1px solid #374151;
  border-radius: 8px;
  padding: .75rem;
}

.memory-slot.filled {
  border-color: #f59e0b;
}

.memory-button {
  display: grid;
  place-items: center;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 50%;
  color: #f8fafc;
  background: radial-gradient(circle at 35% 25%, #4b5563, #111827 70%);
  border: 3px solid #9ca3af;
  box-shadow: 0 .35rem .75rem rgb(0 0 0 / 30%);
  font-weight: 900;
  font-size: 1.25rem;
}

.memory-slot.filled .memory-button {
  border-color: #f59e0b;
  color: #fef3c7;
}

.memory-content {
  min-width: 0;
}

.memory-form {
  display: grid;
}

.setlist-song-list {
  display: grid;
  gap: .75rem;
}

.setlist-item {
  display: grid;
  grid-template-columns: 3rem 1fr;
  gap: .75rem;
  padding: .75rem;
}

.setlist-position {
  display: grid;
  width: 2.5rem;
  height: 2.5rem;
  place-items: center;
  background: #e0f2f1;
  color: var(--app-teal-dark);
  border-radius: 8px;
  font-weight: 800;
}

.setlist-item-heading {
  display: grid;
  gap: .75rem;
}

.setlist-item h3 {
  margin: 0;
  font-size: 1.05rem;
  overflow-wrap: anywhere;
}

.error-page {
  background: #fff;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 2rem 1rem;
  text-align: center;
}

.error-page i {
  display: block;
  font-size: 2.5rem;
  color: var(--app-teal);
  margin-bottom: 1rem;
}

.mobile-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1030;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  height: var(--bottom-nav-height);
  background: #fff;
  border-top: 1px solid var(--app-border);
  box-shadow: 0 -.75rem 1.75rem rgb(15 23 42 / 8%);
}

.mobile-nav a {
  display: grid;
  place-items: center;
  align-content: center;
  gap: .15rem;
  min-width: 0;
  color: #475569;
  text-decoration: none;
  font-size: .72rem;
  font-weight: 700;
}

.mobile-nav i {
  font-size: 1.25rem;
}

.mobile-nav a.active {
  color: var(--app-teal);
}

.app-footer {
  padding: 1rem 0 calc(var(--bottom-nav-height) + 1rem);
}

@media (min-width: 576px) {
  .quick-actions {
    grid-template-columns: repeat(2, 1fr);
  }

  .setlist-item-heading {
    grid-template-columns: 1fr auto;
    align-items: start;
  }
}

@media (min-width: 768px) {
  body {
    padding-bottom: 0;
  }

  .page-shell {
    padding-top: 2rem;
  }

  .page-header,
  .section-heading {
    flex-direction: row;
    justify-content: space-between;
    align-items: end;
  }

  .dashboard-hero {
    grid-template-columns: minmax(0, 1fr) minmax(360px, 1.4fr);
    align-items: end;
    padding: 1.5rem;
  }

  .quick-actions {
    grid-template-columns: repeat(4, 1fr);
  }

  .stats-grid,
  .detail-grid {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .song-card {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
  }

  .history-filters {
    grid-template-columns: minmax(0, 1fr) 220px auto;
    align-items: end;
  }

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

  .lyrics-reader h1 {
    font-size: 2.6rem;
  }

  .app-footer {
    padding-bottom: 1rem;
  }
}

@media (min-width: 1200px) {
  .memory-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
