:root {
  color-scheme: dark;
  --bg: #121414;
  --panel: #1d2020;
  --panel-2: #252929;
  --panel-3: #303535;
  --text: #f3f0e9;
  --muted: #aaa59a;
  --line: #3b403f;
  --accent: #e4b657;
  --accent-2: #7ec4cf;
  --danger: #e17067;
  --ok: #8ac17d;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  overscroll-behavior: none;
  background:
    linear-gradient(135deg, rgba(228, 182, 87, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(126, 196, 207, 0.08), transparent 30%),
    var(--bg);
  color: var(--text);
}

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

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  border-right: 1px solid var(--line);
  background: rgba(22, 24, 24, 0.88);
  padding: 24px;
}

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

.brand-mark {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 1px solid rgba(228, 182, 87, 0.5);
  border-radius: 12px;
  background: #251f16;
  color: var(--accent);
  font-size: 24px;
  font-weight: 800;
}

.brand h1,
.brand p,
.view-header h2,
.view-header p,
.empty-state h3,
.empty-state p {
  margin: 0;
}

.brand h1 {
  font-size: 22px;
}

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

.nav-tabs {
  display: grid;
  gap: 8px;
}

.nav-tab,
.ghost-button,
.primary-button,
.secondary-button,
.danger-button,
.icon-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  padding: 10px 12px;
  text-align: left;
}

.nav-tab span {
  color: var(--accent);
  font-size: 18px;
}

.nav-tab.active,
.nav-tab:hover,
.ghost-button:hover,
.secondary-button:hover {
  border-color: var(--line);
  background: var(--panel-2);
}

.storage-panel {
  margin-top: auto;
  padding: 14px;
}

.storage-panel p {
  margin: 0 0 4px;
}

.storage-actions {
  display: flex;
  gap: 8px;
  margin-top: 14px;
}

.file-button {
  display: grid;
  place-items: center;
}

.file-button input {
  display: none;
}

.logout-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px;
  border: none;
  border-radius: 8px;
  background: rgba(225, 112, 103, 0.1);
  color: var(--danger);
  font-size: 14px;
  font-weight: 700;
  transition: all 0.2s ease;
  cursor: pointer;
}

.logout-button:hover {
  background: rgba(225, 112, 103, 0.2);
}

.workspace {
  min-width: 0;
  padding: 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.view {
  display: none;
}

.view.active {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
  flex-shrink: 0;
}

.header-actions,
.input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.input-row input {
  min-width: 0;
}

.input-row .secondary-button {
  flex: 0 0 auto;
}

.view-header h2 {
  font-size: 30px;
  letter-spacing: 0;
}

.eyebrow {
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.primary-button {
  background: var(--accent);
  color: #20170a;
  font-weight: 800;
  padding: 0 16px;
}

.secondary-button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 0 14px;
}

.ghost-button,
.icon-button {
  background: transparent;
  padding: 0 14px;
}

.danger-button {
  background: transparent;
  border-color: rgba(225, 112, 103, 0.35);
  color: var(--danger);
  padding: 0 14px;
}

.icon-button {
  width: 42px;
  padding: 0;
  font-size: 26px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 180px;
  gap: 12px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

label,
.search-field,
.select-field,
.source-url-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151717;
  color: var(--text);
  outline: none;
  padding: 11px 12px;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px rgba(126, 196, 207, 0.14);
}

textarea {
  min-height: 180px;
  resize: vertical;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  line-height: 1.45;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 1fr);
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.song-list-panel,
.reader-panel,
.setlist-sidebar,
.setlist-detail,
.live-stage {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(29, 32, 32, 0.82);
  box-shadow: var(--shadow);
}

.song-list-panel,
.setlist-sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.song-list,
.setlist-list {
  display: grid;
  align-content: start;
  gap: 6px;
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 10px;
}

.song-card,
.setlist-card,
.setlist-song-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.song-card,
.setlist-card {
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 10px 12px;
  color: var(--text);
  text-align: left;
}

.song-card.active,
.setlist-card.active {
  border-color: rgba(228, 182, 87, 0.75);
  background: #282313;
}

.song-card strong,
.setlist-card strong {
  font-size: 15px;
}

.meta-line {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 6px;
  flex-wrap: wrap;
}


.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  color: var(--muted);
  font-size: 12px;
}

a.pill {
  text-decoration: none;
  transition: border-color 0.15s ease, color 0.15s ease;
}

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

.reader-panel {
  min-width: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.reader-top > div:first-child {
  min-width: 0;
  flex: 1;
}

.reader-top {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
  flex-shrink: 0;
}

.reader-top h3 {
  margin: 0 0 4px;
  font-size: 20px;
}

.reader-actions,
.transpose-controls,
.live-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.source-link {
  color: var(--accent-2);
  text-decoration: none;
}

.source-link:hover {
  text-decoration: underline;
}

.transpose-controls strong {
  min-width: 64px;
  color: var(--accent);
  text-align: center;
}

.chart {
  overflow: auto;
  flex: 1;
  min-height: 0;
  padding: 16px 18px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 17px;
  line-height: 1.8;
}

.chart-line {
  min-height: 1.85em;
  white-space: pre-wrap;
}

.chord-line {
  color: var(--accent);
  font-weight: 800;
}

.lyric-chunk {
  position: relative;
  display: inline-block;
  min-width: 1.4ch;
  padding-top: 1.25em;
}

.lyric-chunk .chord {
  position: absolute;
  top: 0;
  left: 0;
  color: var(--accent);
  font-size: 0.78em;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.song-notes,
.setlist-notes {
  border-top: 1px solid var(--line);
  color: var(--muted);
  padding: 12px 16px;
  flex-shrink: 0;
}

.empty-state {
  display: grid;
  align-content: center;
  flex: 1;
  min-height: 0;
  padding: 24px;
  color: var(--muted);
  text-align: center;
}

.empty-state h3 {
  color: var(--text);
  font-size: 20px;
}

.setlist-layout {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.setlist-detail {
  overflow: auto;
  min-height: 0;
}

.setlist-header > div:first-child {
  min-width: 0;
  flex: 1;
}

.setlist-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding: 18px;
}

.setlist-song-picker {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  border-bottom: 1px solid var(--line);
  padding: 14px 18px;
}

.setlist-song-list {
  display: grid;
  gap: 10px;
  padding: 18px;
}

.setlist-song-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px;
}

.song-index {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 8px;
  background: var(--panel-3);
  color: var(--accent);
  font-weight: 800;
}

.row-actions {
  display: flex;
  gap: 6px;
}

.row-actions .ghost-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
}

.live-header {
  position: sticky;
  top: 0;
  z-index: 3;
  background: var(--c-bg);
  padding-bottom: 10px;
}

.live-stage {
  min-height: calc(100vh - 116px);
  overflow: hidden;
}

.live-song {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  height: calc(100vh - 116px);
}

.live-song .reader-top {
  background: #151717;
}

.live-song .chart {
  max-height: none;
  font-size: 24px;
  line-height: 2.05;
}

.live-progress {
  color: var(--accent-2);
  font-weight: 800;
}

.modal {
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 0;
  margin: auto;
  max-width: 100vw;
  max-height: 100vh;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.62);
}

.modal-card {
  width: min(940px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  display: grid;
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 20px;
}

.modal-card.small {
  width: min(520px, calc(100vw - 24px));
}

.modal-header,
.modal-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.modal-header h2 {
  margin: 0;
}

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

.wide {
  grid-column: 1 / -1;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #202424;
  color: var(--text);
  padding: 12px 14px;
  transition: 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.mobile-topbar {
  display: none;
  align-items: center;
  gap: 16px;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 10;
}

.mobile-brand-title {
  font-weight: 800;
  font-size: 1.2rem;
  color: var(--accent);
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  z-index: 99;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.sidebar-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 1200px) {
  .app-shell {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
  }

  .mobile-topbar {
    display: flex;
    flex-shrink: 0;
  }

  .sidebar-backdrop {
    display: block;
    pointer-events: none;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--bg);
    border-right: 1px solid var(--line);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .workspace {
    padding: 14px;
  }

  .chart {
    font-size: 16px;
    padding: 14px;
  }
}

@media (max-width: 800px) {
  .content-grid,
  .setlist-layout,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .content-grid,
  .setlist-layout {
    flex: none;
    overflow: visible;
  }

  .song-list-panel,
  .setlist-sidebar {
    max-height: 300px;
  }

  .reader-panel {
    max-height: none;
  }

  .setlist-detail {
    max-height: none;
    overflow: visible;
  }

  .live-song,
  .live-stage {
    height: auto;
    min-height: calc(100vh - 150px);
  }

  .live-song .chart {
    font-size: 20px;
  }
}

@media (max-width: 620px) {
  .view-header,
  .reader-top,
  .setlist-header,
  .modal-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .header-actions,
  .input-row {
    width: 100%;
  }

  .header-actions button,
  .input-row button {
    flex: 1 1 0;
  }

  .reader-actions,
  .transpose-controls,
  .live-controls {
    flex-wrap: wrap;
  }

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

  .setlist-song-row {
    grid-template-columns: 36px minmax(0, 1fr);
  }

  .row-actions {
    grid-column: 1 / -1;
  }
}

.import-url-row {
  display: grid;
  gap: 7px;
}

.import-url-label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.import-status {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 14px 18px;
  color: var(--accent-2);
  font-weight: 700;
}

.import-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid var(--line);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.import-error {
  border: 1px solid rgba(225, 112, 103, 0.35);
  border-radius: 8px;
  background: rgba(225, 112, 103, 0.08);
  padding: 14px 18px;
  color: var(--danger);
  font-weight: 600;
}

.import-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  padding: 18px;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.import-preview textarea {
  min-height: 220px;
}

.login-overlay {
  position: fixed;
  inset: 0;
  background: rgba(18, 14, 10, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.login-box {
  background: var(--panel);
  border: 1px solid var(--line);
  padding: 3rem 2.5rem;
  border-radius: 24px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.6);
}
.modern-input {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--fg);
  font-size: 15px;
  transition: all 0.2s ease;
}
.modern-input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255,255,255,0.06);
}

/* LIVE MODAL */
.live-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: var(--bg);
  flex-direction: column;
}

.live-modal.show {
  display: flex;
}

.live-unified-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  gap: 24px;
}

.live-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}

.live-header-controls {
  display: flex;
  align-items: center;
  gap: 40px; /* Space between nav and transpose controls */
  flex-shrink: 0;
}

.live-header-center,
.live-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.live-header-left h3 {
  margin: 0;
  font-size: 20px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.live-progress {
  font-weight: 800;
  color: var(--accent-2);
  font-size: 16px;
  min-width: 48px;
  text-align: center;
}

.live-modal .chart {
  flex: 1;
  overflow: auto;
  font-size: 22px; /* Reduced from 28px as requested */
  padding: 24px;
  line-height: 2.05;
}

.accent-pill {
  color: #20170a !important;
  background: var(--accent);
  border-color: var(--accent);
  font-weight: 800;
}

@media (max-width: 620px) {
  .live-unified-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    padding: 12px 16px;
  }
  .live-header-controls {
    gap: 16px;
    justify-content: space-between;
  }
  .live-header-left {
    justify-content: space-between;
  }
}
