* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #121212;
  --surface: #1e1e2f;
  --surface-light: #2a2a40;
  --primary: #7c3aed;
  --primary-light: #a78bfa;
  --accent: #06b6d4;
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --danger: #ef4444;
  --success: #22c55e;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,0.4);
}

[data-theme="light"] {
  --bg: #f3f4f8;
  --surface: #ffffff;
  --surface-light: #e2e4ea;
  --primary: #7c3aed;
  --primary-light: #5b21b6;
  --accent: #0891b2;
  --text: #1e1e2f;
  --text-muted: #6b7280;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

html {
  font-size: 17px;
}
html, body {
  width: 100%;
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* Views */
.view {
  display: none;
  width: 100%;
  height: 100%;
  flex-direction: column;
  animation: fadeIn 0.25s ease;
}
.view.active { display: flex; }

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

/* Login */
.login-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  gap: 20px;
}
.login-container h1 {
  font-size: 2.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.login-container .logo {
  font-size: 4rem;
}
.input {
  width: 100%;
  max-width: 320px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--surface-light);
  background: var(--surface);
  color: var(--text);
  font-size: 1.05rem;
  outline: none;
  transition: border-color 0.2s;
}
.input:focus {
  border-color: var(--primary-light);
}
.btn {
  padding: 14px 24px;
  border-radius: var(--radius);
  border: none;
  background: var(--primary);
  color: white;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  transition: filter 0.2s, transform 0.1s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.btn:active { transform: scale(0.97); }
.btn:hover { filter: brightness(1.1); }
.btn-secondary {
  background: var(--surface-light);
  color: var(--text);
}
.btn-danger { background: var(--danger); }
.btn-success { background: var(--success); }
.btn-accent { background: var(--accent); color: #fff; }
[data-theme="light"] .btn-accent { color: #fff; }
.btn-full { width: 100%; max-width: 320px; }

/* App Layout */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--surface-light);
  z-index: 10;
}
.app-header h2 { font-size: 1.5rem; font-weight: 700; }
.app-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
}
.app-nav {
  display: flex;
  justify-content: space-around;
  padding: 10px 0;
  background: var(--surface);
  border-top: 1px solid var(--surface-light);
  z-index: 10;
}
.nav-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  padding: 4px 12px;
  transition: color 0.2s;
}
.nav-btn.active { color: var(--primary-light); }
.nav-btn span { font-size: 1.4rem; }

/* Theme toggle */
.theme-toggle {
  background: var(--surface-light);
  border: 1px solid var(--surface-light);
  color: var(--text);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: transform 0.2s, background 0.2s;
}
.theme-toggle:active { transform: scale(0.92); }

/* Search */
.search-bar {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.search-bar .input { flex: 1; max-width: none; }

/* Cards */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  border: 1px solid var(--surface-light);
  box-shadow: var(--shadow);
  transition: transform 0.15s, border-color 0.2s;
  cursor: pointer;
  position: relative;
}
.card:active { transform: scale(0.99); }
.card:hover { border-color: var(--primary); }
.card-title { font-weight: 700; font-size: 1.15rem; margin-bottom: 4px; }
.card-meta { color: var(--text-muted); font-size: 0.95rem; }
.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}
.card-actions .btn {
  padding: 8px 14px;
  font-size: 0.95rem;
  flex: 1;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  backdrop-filter: blur(4px);
}
[data-theme="light"] .modal-overlay {
  background: rgba(0,0,0,0.4);
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
}
.modal h3 { font-size: 1.3rem; font-weight: 700; margin-bottom: 16px; }
.modal .input { max-width: none; margin-bottom: 12px; }
.modal .btn-full { max-width: none; margin-top: 8px; }
.modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

/* Variation tag */
.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--surface-light);
  font-size: 0.9rem;
  margin-right: 6px;
  margin-top: 6px;
}
.tag.primary {
  background: var(--primary);
  color: white;
}

/* PDF Viewer */
.pdf-viewer {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 50;
  display: none;
  flex-direction: column;
}
.pdf-viewer.active { display: flex; }
.pdf-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--surface-light);
  gap: 10px;
  flex-wrap: wrap;
  position: relative;
  z-index: 3;
}
.pdf-toolbar .btn {
  padding: 8px 14px;
  font-size: 0.95rem;
}
.pdf-title {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  text-align: center;
}
.pdf-container {
  flex: 1;
  overflow: auto;
  position: relative;
  background: var(--bg);
}
.pdf-container iframe, .pdf-container embed {
  width: 100%;
  height: 100%;
  border: none;
}
.pdf-swipe-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  touch-action: pan-y;
  pointer-events: none;
}
.pdf-container {
  will-change: auto;
}
.pdf-container.animating {
  will-change: transform, opacity;
}
.pdf-controls {
  display: flex;
  gap: 8px;
  align-items: center;
}
.scroll-speed {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
}
.scroll-speed input[type="range"] {
  width: 80px;
}

/* Empty state */
.empty {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 20px;
}
.empty-icon { font-size: 3rem; margin-bottom: 12px; }

/* Set list builder */
.setlist-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  border: 1px solid var(--surface-light);
  box-shadow: var(--shadow);
}
.setlist-item .handle {
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: grab;
}
.setlist-item .info { flex: 1; }
.setlist-item .remove {
  background: none;
  border: none;
  color: var(--danger);
  font-size: 1.2rem;
  cursor: pointer;
}

/* Selection list for adding to setlist */
.select-list {
  max-height: 50vh;
  overflow-y: auto;
}
.select-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius);
  cursor: pointer;
}
.select-item:hover { background: var(--surface-light); }
.select-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
}

/* Responsive */
@media (max-width: 400px) {
  .app-header h2 { font-size: 1.25rem; }
  .btn { padding: 12px 18px; }
}

/* Form group */
.form-group {
  margin-bottom: 12px;
}
.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.95rem;
  color: var(--text-muted);
}

/* Chord Chart Viewer */
.chart-viewer {
  padding: 16px;
  max-width: 720px;
  margin: 0 auto;
}
@media (max-width: 400px) {
  .chart-viewer { padding: 12px; }
  .chart-chord { font-size: 1.15rem; }
  .chart-lyric-row { font-size: 1.15rem; line-height: 1.55; }
  .chart-section-name { font-size: 1.1rem; }
}
.chart-section {
  margin-bottom: 20px;
}
.chart-section-name {
  font-weight: 700;
  font-size: 1.25rem;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  margin-bottom: 14px;
  color: var(--text);
}
.chart-pair {
  margin-bottom: 14px;
}
.chart-chord-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
  min-height: 24px;
}
.chart-chord {
  font-weight: 700;
  color: var(--primary-light);
  font-size: 1.35rem;
  white-space: nowrap;
}
.chart-lyric-row {
  font-size: 1.3rem;
  line-height: 1.6;
  color: var(--text);
  word-break: normal;
  overflow-wrap: break-word;
}
.chart-meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  margin-bottom: 16px;
  border: 1px solid var(--surface-light);
}
.chart-meta-bar .key-badge {
  background: var(--primary);
  color: white;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.95rem;
  font-weight: 700;
}

/* Key selector */
.key-select {
  padding: 8px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--surface-light);
  background: var(--surface);
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
}

/* Confirm Modal */
.confirm-modal {
  text-align: center;
  padding: 28px 24px;
}
.confirm-modal h3 {
  margin-bottom: 8px;
}
.confirm-modal p {
  color: var(--text-muted);
  margin-bottom: 20px;
}
.confirm-actions {
  display: flex;
  gap: 10px;
}
.confirm-actions .btn {
  flex: 1;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--surface-light);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 1rem;
  opacity: 0;
  transition: all 0.3s ease;
  z-index: 200;
  pointer-events: none;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Password show/hide toggle */
.pass-wrap { position: relative; display: flex; width: 100%; max-width: 320px; }
.pass-wrap .input { padding-right: 40px; width: 100%; max-width: none; }
.pass-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  padding: 4px;
  opacity: 0.6;
  transition: opacity 0.2s;
}
.pass-toggle:hover { opacity: 1; }



/* Slide animations for setlist viewer */
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideInLeft {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(-100%); opacity: 0; }
}
@keyframes slideOutLeft {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

.slide-in-right { animation: slideInRight 0.3s ease-out forwards; }
.slide-in-left  { animation: slideInLeft  0.3s ease-out forwards; }
.slide-out-right { animation: slideOutRight 0.3s ease-out forwards; }
.slide-out-left  { animation: slideOutLeft  0.3s ease-out forwards; }

/* Chat */
.chat-messages { flex: 1; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 10px; }
.chat-bubble { max-width: 80%; padding: 10px 14px; border-radius: var(--radius); background: var(--surface-light); font-size: 1.05rem; line-height: 1.4; word-break: break-word; }
.chat-bubble.own { align-self: flex-end; background: var(--primary); color: white; }
.chat-bubble.own .chat-meta { color: rgba(255,255,255,0.75); }
.chat-meta { font-size: 0.85rem; color: var(--text-muted); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
.chat-meta .actions { margin-left: auto; display: flex; gap: 6px; }
.chat-meta .actions button { background: none; border: none; cursor: pointer; font-size: 0.9rem; color: inherit; opacity: 0.6; padding: 0; }
.chat-meta .actions button:hover { opacity: 1; }
.chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-light);
  flex-shrink: 0;
}
.chat-avatar-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.chat-bubble-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.chat-mention { background: var(--primary-light); color: white; padding: 1px 5px; border-radius: 4px; font-weight: 600; }
.chat-input-bar { display: flex; gap: 10px; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--surface-light); align-items: center; }
.chat-input-bar .input { margin-bottom: 0; }
.mention-dropdown { position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--surface-light); border-radius: var(--radius); max-height: 160px; overflow-y: auto; display: none; z-index: 10; box-shadow: var(--shadow); }
.mention-dropdown.active { display: block; }
.mention-dropdown div { padding: 8px 12px; cursor: pointer; font-size: 0.95rem; }
.mention-dropdown div:hover { background: var(--surface-light); }

.home-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 16px; max-width: 520px; margin: 0 auto; }
.home-tile {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px 12px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
  white-space: nowrap;
  box-shadow: 0 4px 24px rgba(0,0,0,0.25);
}
.home-tile:hover {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  transform: translateY(-2px);
}
.home-tile:active { transform: scale(0.97); }
[data-theme="light"] .home-tile {
  background: rgba(255,255,255,0.55);
  border-color: rgba(0,0,0,0.06);
  color: var(--text);
  box-shadow: 0 4px 24px rgba(0,0,0,0.06);
}
[data-theme="light"] .home-tile:hover {
  background: rgba(255,255,255,0.85);
  border-color: rgba(0,0,0,0.1);
}

.nns-scale { display: flex; flex-direction: column; gap: 6px; font-size: 1rem; }
.nns-scale div { padding: 6px 10px; border-radius: 8px; background: var(--surface-light); }
.nns-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; text-align: center; font-size: 1rem; }
.nns-grid > div { padding: 10px 4px; border-radius: 8px; background: var(--surface-light); display: flex; flex-direction: column; align-items: center; gap: 6px; }
.nns-grid > div.header { background: var(--primary); color: white; font-weight: 600; }
.nns-grid .nns-num { font-size: 1.1rem; font-weight: 700; }
.nns-grid .nns-chord { font-size: 1rem; opacity: 0.9; }

/* Swipe hint arrows */
.swipe-hint {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 3rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
  z-index: 3;
}
.swipe-hint.show { opacity: 0.4; }
.swipe-hint-left  { left: 20px; }
.swipe-hint-right { right: 20px; }

