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

:root {
  --bg: #0a0a0a;
  --bg-card: #161616;
  --bg-header: #1a1a1a;
  --accent: #f0c430;
  --text: #f2f2f2;
  --text-dim: #777;
  --chord: #f0c430;
  --border: #2a2a2a;
  --radius: 10px;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app {
  height: 100%;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.view.active {
  display: flex;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.app-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent);
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text);
  font-size: 24px;
  cursor: pointer;
  padding: 4px 10px;
  border-radius: var(--radius);
  transition: background 0.2s;
}

.icon-btn:active {
  background: rgba(255,255,255,0.1);
}

/* Search */
.search-bar {
  padding: 10px 16px;
  background: var(--bg);
  flex-shrink: 0;
}

.search-bar input {
  width: 100%;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.search-bar input:focus {
  border-color: var(--accent);
}

/* Song List */
.song-list {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px 100px;
}

.song-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  margin-bottom: 6px;
  background: var(--bg-card);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s;
}

.song-item:active {
  background: var(--bg-header);
}

.song-item-info h3 {
  font-size: 16px;
  font-weight: 500;
  margin-bottom: 2px;
}

.song-item-info span {
  font-size: 13px;
  color: var(--text-dim);
}

.song-item-key {
  font-size: 14px;
  color: var(--chord);
  font-weight: 600;
  padding: 4px 10px;
  background: rgba(240, 196, 48, 0.12);
  border-radius: 6px;
  white-space: nowrap;
}

/* Import */
.import-area {
  padding: 16px;
  text-align: center;
  flex-shrink: 0;
}

.import-label {
  display: inline-block;
  padding: 12px 24px;
  background: var(--bg-card);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-dim);
  cursor: pointer;
  font-size: 14px;
  transition: border-color 0.2s;
}

.import-label:active {
  border-color: var(--accent);
}

/* Song View */
.song-ui-bar {
  flex-shrink: 0;
}

.song-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg-header);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

/* Push action button to the right in any header that has a bare h2 */
.song-header h2 {
  flex: 1;
}

.song-title-area {
  flex: 1;
  min-width: 0;
}

.song-title-area h2 {
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.song-title-area span {
  font-size: 12px;
  color: var(--text-dim);
}

/* Controls — single compact row */
.song-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 5px 10px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: nowrap;
}

.control-group {
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.control-label {
  font-size: 10px;
  color: var(--text-dim);
  margin-right: 1px;
}

.ctrl-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.ctrl-btn:active {
  background: var(--accent);
  color: #000;
}

.key-display {
  font-size: 13px;
  font-weight: 700;
  color: var(--chord);
  min-width: 24px;
  text-align: center;
}

/* Floating auto-scroll button */
.fab-scroll {
  position: fixed;
  bottom: 28px;
  right: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: rgba(240, 196, 48, 0.25);
  color: var(--accent);
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: background 0.2s;
  box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

.fab-scroll:active {
  background: rgba(240, 196, 48, 0.4);
}

.fab-scroll.active {
  background: var(--accent);
  color: #000;
}

.fab-scroll svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Song Content */
.song-content-inner {
  transform-origin: top left;
  min-height: 100%;
}

.song-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 16px;
  padding-bottom: 80px;
  font-size: 13px;
  line-height: 1.35;
}

.chord-line {
  margin-bottom: 2px;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.chord-pair {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  padding-right: 0.2em;
}

.chord {
  color: var(--chord);
  font-weight: 700;
  font-size: 0.85em;
  line-height: 0.9;
  white-space: nowrap;
  min-height: 0.9em;
  margin-bottom: -1px;
}

.lyric {
  white-space: pre;
  line-height: 1.05;
}

.section-label {
  color: var(--accent);
  font-weight: 700;
  font-size: 11px;
  text-transform: uppercase;
  margin: 6px 0 2px;
  letter-spacing: 1px;
}

.empty-line {
  height: 22px;
}

.song-content .line-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  align-content: flex-start;
  row-gap: 0;
  margin-bottom: 2px;
}

/* Menu */
.menu-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.menu-section {
  margin-bottom: 24px;
}

.menu-section-title {
  font-size: 12px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}

.menu-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  margin-bottom: 4px;
  font-size: 15px;
}

.menu-value {
  color: var(--accent);
  font-weight: 600;
  font-size: 14px;
}

.menu-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s;
}

.menu-btn:active,
.menu-btn-label:active {
  background: var(--accent);
  color: #000;
}

.update-status {
  font-size: 13px;
  padding: 8px 0;
  min-height: 20px;
}

.update-status.ok {
  color: #4caf50;
}

.update-status.error {
  color: #f44336;
}

.update-status.info {
  color: var(--text-dim);
}

.update-progress {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
  display: none;
}

.update-progress.active {
  display: block;
}

.update-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease;
}

.changelog {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.changelog-entry {
  padding: 10px 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  display: flex;
  gap: 12px;
  align-items: baseline;
}

.changelog-version {
  color: var(--accent);
  font-weight: 700;
  font-size: 13px;
  white-space: nowrap;
}

.changelog-text {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
}

/* Editor */
.editor-fields {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.editor-input {
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 16px;
  outline: none;
}

.editor-input:focus {
  border-color: var(--accent);
}

.editor-input.small {
  width: 50%;
}

.editor-help {
  font-size: 13px;
  color: var(--text-dim);
  padding: 6px 0;
}

.editor-textarea {
  flex: 1;
  min-height: 300px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 15px;
  font-family: monospace;
  line-height: 1.6;
  resize: none;
  outline: none;
}

.editor-textarea:focus {
  border-color: var(--accent);
}

.editor-actions {
  padding: 16px;
  flex-shrink: 0;
}

.delete-btn {
  width: 100%;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 15px;
  cursor: pointer;
}

.delete-btn:active {
  background: rgba(240, 196, 48, 0.15);
}

/* Install banner */
.install-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 200;
  background: #1c1c1c;
  border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  padding: 20px 20px 28px;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.6);
  animation: slideUp 0.35s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.install-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 26px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}

.install-icon {
  text-align: center;
  margin-bottom: 12px;
}

.install-icon img {
  border-radius: 14px;
}

.install-text {
  text-align: center;
  margin-bottom: 18px;
}

.install-text h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 4px;
}

.install-text p {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.4;
}

.install-steps {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.install-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 15px;
  line-height: 1.4;
}

.install-step-num {
  flex-shrink: 0;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.install-step strong {
  color: var(--accent);
}

.install-share-icon {
  display: inline-block;
  width: 18px;
  height: 18px;
  vertical-align: -3px;
  color: var(--accent);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-dim);
}

.empty-state .emoji {
  font-size: 48px;
  margin-bottom: 16px;
}

.empty-state p {
  font-size: 15px;
  line-height: 1.6;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 2px;
}

@media (min-width: 600px) {
  .song-list {
    max-width: 600px;
    margin: 0 auto;
  }
  .song-content {
    max-width: 700px;
    margin: 0 auto;
    font-size: 17px;
  }
}
