:root {
  color-scheme: dark;
  --bg: #0b1120;
  --bg-alt: #111827;
  --panel: rgba(15, 23, 42, 0.9);
  --panel-soft: rgba(30, 41, 59, 0.9);
  --line: rgba(148, 163, 184, 0.22);
  --text: #e5e7eb;
  --muted: #a5b4cf;
  --accent: #34d399;
  --accent-strong: #22c55e;
  --accent-soft: rgba(52, 211, 153, 0.18);
  --warning: #fbbf24;
  --danger: #f87171;
  --shadow: 0 18px 45px rgba(2, 6, 23, 0.32);
  --slot-rest: rgba(148, 163, 184, 0.04);
  --slot-down: rgba(57, 217, 138, 0.17);
  --slot-up: rgba(96, 165, 250, 0.16);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Arial, sans-serif;
  background: radial-gradient(circle at top, #111827, var(--bg) 38%, #020817 100%);
  color: var(--text);
}

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

.app-shell {
  max-width: 1500px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px 22px;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 0.7rem;
}

h1 {
  margin: 6px 0 0;
  font-size: clamp(1.8rem, 2vw, 2.4rem);
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.ghost-button,
.primary-button,
.secondary-button,
.metric-button {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.72rem 1rem;
  background: rgba(148, 163, 184, 0.08);
  color: var(--text);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  border-color: rgba(52, 211, 153, 0.5);
  color: #02130d;
  font-weight: 700;
}

.secondary-button {
  background: rgba(59, 130, 246, 0.14);
  border-color: rgba(96, 165, 250, 0.35);
}

.toolbar button.metric-button:hover,
.ghost-button:hover,
.primary-button:hover,
.secondary-button:hover,
.metric-button:hover,
.timeline-slot:hover {
  transform: translateY(-1px);
}

.layout {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1.15fr) minmax(260px, 330px);
  gap: 18px;
  margin-top: 20px;
}

.panel {
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel h2 {
  margin: 0 0 16px;
  font-size: 1.08rem;
}

.field-group {
  display: grid;
  gap: 12px;
}

.field {
  display: grid;
  gap: 6px;
}

label {
  color: var(--muted);
  font-size: 0.8rem;
}

input, select, textarea {
  width: 100%;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.72rem 0.8rem;
  color: var(--text);
}

textarea {
  min-height: 90px;
  resize: vertical;
}

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

.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.metric-button {
  padding: 0.52rem 0.75rem;
  background: rgba(148, 163, 184, 0.08);
}

.metric-button.active {
  background: var(--accent-soft);
  border-color: rgba(52, 211, 153, 0.52);
}

.editor-timeline {
  display: grid;
  gap: 14px;
  margin-top: 8px;
}

/* Timeline layout mirrors the playback view (css/strummer.css): absolute width per slot, guides and chord row above the measures. */
.editor-viewport {
  position: relative;
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 290px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 14px;
  background: rgba(2, 6, 23, 0.48);
  scrollbar-width: thin;
  scrollbar-color: rgba(96, 165, 250, 0.7) rgba(15, 23, 42, 0.6);
}

.timeline-inner {
  position: relative;
  min-height: 250px;
  padding-top: 18px;
}

.timeline-guides {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.timeline-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  background: rgba(148, 163, 184, 0.18);
}

.timeline-guide.beat-guide {
  background: rgba(148, 163, 184, 0.22);
}

.timeline-guide.bar-guide {
  width: 2px;
  background: rgba(96, 165, 250, 0.56);
}

.timeline-chords {
  position: relative;
  z-index: 2;
  height: 28px;
  margin-bottom: 8px;
}

.chord-badge {
  position: absolute;
  top: 0;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
  background: rgba(96, 165, 250, 0.18);
  border: 1px solid rgba(96, 165, 250, 0.42);
  color: var(--text);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.measure-row {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-start;
}

.measure {
  position: relative;
  flex: 0 0 auto;
  border-left: 1px solid rgba(148, 163, 184, 0.12);
}

.measure:first-child {
  border-left: none;
}

.measure-header {
  position: relative;
  height: 30px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.12);
}

.beat-label {
  position: absolute;
  top: 0;
  bottom: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  border-left: 1px solid rgba(148, 163, 184, 0.1);
}

.measure-body {
  display: flex;
  min-height: 160px;
}

.timeline-slot {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 110px;
  flex: 0 0 auto;
  padding: 0;
  background: var(--slot-rest);
  border: none;
  border-left: 1px solid rgba(148, 163, 184, 0.1);
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  color: var(--text);
  cursor: pointer;
  user-select: none;
  transition: background 0.12s ease, box-shadow 0.12s ease;
}

.measure-lyrics {
  display: flex;
  min-height: 2.2rem;
  border-top: 1px dashed rgba(148, 163, 184, 0.12);
}

.lyric-cell {
  min-height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: text;
}

.lyric-cell.has-text {
  color: var(--text);
  background: rgba(96, 165, 250, 0.12);
}

.lyric-input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 2px 4px;
  font: inherit;
  color: var(--text);
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(96, 165, 250, 0.8);
  border-radius: 4px;
}

.timeline-slot.selected {
  box-shadow: inset 0 0 0 2px rgba(251, 191, 36, 0.9);
  background: rgba(251, 191, 36, 0.16);
}

.timeline-slot.down {
  background: var(--slot-down);
}

.timeline-slot.up {
  background: var(--slot-up);
}

.timeline-slot.rest {
  color: var(--muted);
}

.timeline-slot.accent {
  box-shadow: inset 0 0 0 1px rgba(251, 191, 36, 0.7);
}

.timeline-slot .slot-chord {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.58rem;
}

.slot-info {
  margin-left: auto;
  color: var(--muted);
  font-size: 0.8rem;
}

.timeline-hint {
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.slot-symbol {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
}

.slot-chord {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text);
}

.metric-button[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: rgba(52, 211, 153, 0.52);
}

.current-slot-card {
  margin-top: 16px;
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.65);
}

.empty-state {
  font-size: 0.85rem;
  color: var(--muted);
}

.section-list {
  display: grid;
  gap: 4px;
  min-width: 0;
  margin: 0 0 14px;
  padding: 0;
  list-style: none;
}

.section-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.5);
}

.section-item-fields {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 6px;
  min-width: 0;
}

.section-item select {
  width: 0;
  min-width: 100%;
  padding: 4px 6px;
  font-size: 0.85rem;
}

.section-item.active {
  border-color: rgba(52, 211, 153, 0.52);
  background: var(--accent-soft);
}

.section-item-range {
  color: var(--muted);
  font-size: 0.75rem;
  white-space: nowrap;
}

.section-item-actions {
  display: flex;
  gap: 2px;
}

.section-item-actions .metric-button {
  padding: 2px 7px;
  line-height: 1.3;
}


.section-add-row {
  align-items: flex-end;
}

.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin-top: 14px;
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.08);
  border: 1px solid var(--line);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.28rem 0.7rem;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.15);
  color: #baf7d9;
  font-size: 0.76rem;
  font-weight: 700;
}

@media (max-width: 1100px) {
  .layout {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 12px;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .measure-body {
    grid-template-columns: repeat(8, minmax(28px, 1fr));
  }
}
