* { box-sizing: border-box; }
:root {
  --bg: #070b14;
  --bg-2: #0d1420;
  --panel: rgba(17, 24, 39, 0.82);
  --panel-2: rgba(12, 18, 31, 0.9);
  --border: rgba(148, 163, 184, 0.18);
  --border-strong: rgba(148, 163, 184, 0.28);
  --text: #eef2ff;
  --muted: #9aa5bd;
  --accent: #7cffa3;
  --accent-2: #7aa2ff;
  --danger: #ff7373;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}
html, body {
  margin: 0;
  height: 100%;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(122,162,255,.16), transparent 30%),
    radial-gradient(circle at 80% 0%, rgba(124,255,163,.12), transparent 26%),
    linear-gradient(180deg, var(--bg), var(--bg-2));
  color: var(--text);
  font-family: Inter, Arial, sans-serif;
}
body { padding: 12px; overflow: hidden; }
#app {
  height: calc(100dvh - 24px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  overflow: hidden;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, textarea, select { font: inherit; }
button {
  border: 1px solid var(--border);
  background: rgba(28, 38, 58, 0.86);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  transition: transform .12s ease, border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
button:hover { transform: translateY(-1px); border-color: var(--border-strong); }
button.primary {
  background: linear-gradient(135deg, var(--accent), #bbffd0);
  color: #06110a;
  font-weight: 800;
  border-color: transparent;
}
button.primary.active,
button.active {
  background: linear-gradient(135deg, #4cff8f, #98ffc0);
  color: #06110a;
  border-color: transparent;
  box-shadow: 0 0 0 3px rgba(124,255,163,.18);
}
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
button.icon-button {
  width: 46px;
  min-width: 46px;
  padding: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  line-height: 1;
}
.visually-hidden-file {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
input, textarea, select {
  width: 100%;
  background: rgba(7, 11, 20, 0.86);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: rgba(124,255,163,.45); box-shadow: 0 0 0 4px rgba(124,255,163,.08); }
textarea { resize: none; min-height: 120px; overflow: hidden; }
textarea.readonly-view {
  color: #d7def4;
  background: rgba(10, 16, 30, 0.94);
  border-color: rgba(124,255,163,.28);
}
[hidden] { display: none !important; }
.shell-glow {
  position: fixed;
  inset: -20vmax;
  pointer-events: none;
  background:
    radial-gradient(circle at center, rgba(124,255,163,.06), transparent 28%),
    radial-gradient(circle at 30% 20%, rgba(122,162,255,.07), transparent 22%);
  filter: blur(30px);
}
.panel {
  position: relative;
  background: linear-gradient(180deg, var(--panel), var(--panel-2));
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.glassy::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255,255,255,.05);
  pointer-events: none;
}
.topbar {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 0;
  overflow: hidden;
  padding: 6px 18px;
}
.top-actions {
  position: relative;
  z-index: 1;
  justify-content: flex-end;
}

.brand-lockup {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}
.brand-banner-shell {
  position: relative;
  display: flex;
  align-items: center;
  width: clamp(420px, 42vw, 680px);
  height: clamp(90px, 11vw, 120px);
  padding: 0;
  border-radius: 0;
  overflow: visible;
  background: transparent;
  border: none;
  box-shadow: none;
}
.brand-banner {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  max-width: none;
  object-fit: contain;
  object-position: left center;
  display: block;
  filter: none;
}
.brand-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  object-fit: cover;
  flex: 0 0 auto;
  border: 1px solid rgba(148, 163, 184, 0.18);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.24);
  background: rgba(9, 13, 24, 0.95);
}
.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .12em;
  font-size: 12px;
  font-weight: 700;
}
.eyebrow.small { margin-bottom: 4px; font-size: 11px; }
.hero h1, .topbar h1, .panel-header h2 { margin: 0; }
.hero h1, .topbar h1 { font-size: clamp(18px, 3vw, 24px); letter-spacing: -0.03em; }
.hero p, .topbar p { margin: 2px 0 0; color: var(--muted); max-width: 760px; font-size: 12px; }
.top-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.layout { --left-sidebar-width: 260px; display: grid; grid-template-columns: var(--left-sidebar-width) minmax(0, 1fr); gap: 10px; min-height: 0; height: 100%; overflow: hidden; }
.layout.library-collapsed { --left-sidebar-width: 76px; }
.workspace { display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 10px; min-height: 0; height: 100%; overflow: hidden; }

.sidebar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px;
  gap: 8px;
  align-items: stretch;
  min-height: 0;
}
.sidebar-content {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.sidebar.collapsed {
  grid-template-columns: 56px;
  padding: 10px;
}
.sidebar.collapsed .sidebar-content {
  display: none;
}
.drawer-handle-left .drawer-label {
  writing-mode: vertical-rl;
  transform: none;
}
.panel-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 10px; }
.panel-header.tight { margin-bottom: 8px; }
.panel-title-with-badge { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.panel-title-with-badge h2 { margin: 0; }
.compact { padding-bottom: 10px; }
.meta-grid {
  display: grid;
  /* Titel | Artist | BPM | Key | Beat-Upload | Beat-Status */
  grid-template-columns: 1.5fr 1.3fr .4fr .35fr 1.2fr .7fr;
  gap: 8px;
  align-items: end;
  padding: 10px 12px;
}
.meta-grid label,
.toolbar-slider,
.settings-grid label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}
.meta-upload {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.file-picker {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}
.file-name {
  min-height: 46px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(7, 11, 20, 0.86);
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.beat-status-box {
  display: grid;
  gap: 6px;
  align-self: stretch;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(7, 11, 20, 0.45);
}
.beat-status {
  color: var(--text);
  font-size: 14px;
  word-break: break-word;
}
.editor-shell {
  --right-sidebar-width: 380px;
  --lyrics-line-height: 1.55;
  --lyrics-line-height-px: 27px;
  --line-stats-width: 80px;
  --editor-shell-height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--right-sidebar-width);
  gap: 10px;
  align-items: stretch;
  height: min(100%, var(--editor-shell-height));
  max-height: min(100%, var(--editor-shell-height));
  min-height: 0;
  overflow: hidden;
}

.editor-shell.sidebar-collapsed {
  grid-template-columns: minmax(0, 1fr) 82px;
}
.editor-panel,
.right-sidebar {
  min-width: 0;
  align-self: stretch;
  height: 100%;
}
.editor-panel { display: grid; grid-template-rows: auto minmax(0, 1fr); min-height: 0; overflow: hidden; }
.lyrics-header { align-items: center; margin-bottom: 6px; }
.lyrics-toolbar {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  font-size: 13px;
}
.toolbar-check {
  display: inline-flex !important;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(7, 11, 20, 0.7);
  color: var(--text) !important;
  font-size: 13px;
}
.toolbar-check input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  margin: 0;
}
.toolbar-slider input[type="range"] {
  min-width: 120px;
  accent-color: var(--accent);
}
.toolbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(7, 11, 20, 0.7);
  color: var(--text);
}
.ai-credit-pill {
  max-width: 240px;
  justify-content: space-between;
  cursor: pointer;
  min-height: 40px;
}
.ai-credit-pill .credit-label {
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
  font-size: 12px;
}
.ai-credit-pill #aiCreditsValue {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-credit-pill.is-loading { border-color: rgba(148, 163, 184, 0.4); }
.ai-credit-pill.is-available { border-color: rgba(124,255,163,.4); box-shadow: 0 0 0 1px rgba(124,255,163,.14) inset; }
.ai-credit-pill.is-warning { border-color: rgba(245, 158, 11, .45); }
.ai-credit-pill.is-error { border-color: rgba(248, 113, 113, .45); }
.lyrics-viewport {
  height: 100%;
  max-height: 100%;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding-right: 4px;
  border-radius: 14px;
  position: relative;
}

/* ── Block Editor ──────────────────────────────────────────────────── */
.editor-root {
  min-height: 320px;
  padding: 10px 0;
}
.editor-root:empty::before {
  content: 'Schreibe hier deinen Songtext...';
  color: var(--muted);
  opacity: .5;
  padding: 14px 16px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  display: block;
}
.block-row {
  display: grid;
  grid-template-columns: var(--line-stats-width) 1fr;
  gap: 0;
  align-items: stretch;
  position: relative;
}
.block-row.active {
  background: rgba(124,255,163,.04);
}
.block-row.selected {
  background: rgba(122,162,255,.06);
}
.block-gutter {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  padding: 0 8px;
  min-height: var(--lyrics-line-height-px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  user-select: none;
}
.block-gutter .gutter-bar {
  opacity: .72;
  min-width: 52px;
  text-align: right;
  letter-spacing: .03em;
}
.block-gutter .gutter-divider {
  opacity: .28;
}
.block-gutter .gutter-syl {
  color: var(--accent);
  opacity: .95;
  min-width: 18px;
  text-align: right;
}
.block-gutter .gutter-density-point {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 12px;
  color: rgba(148,163,184,.62);
  opacity: .88;
  cursor: help;
}
.block-gutter .gutter-density-point.is-green {
  color: rgba(124,255,163,.95);
}
.block-gutter .gutter-density-point.is-yellow {
  color: rgba(250,204,21,.92);
}
.block-gutter .gutter-density-point.is-red {
  color: rgba(248,113,113,.84);
}
.block-section-gutter {
  opacity: .4;
}
.block-empty-gutter {
  opacity: .2;
}
.block-bar-content {
  padding: 0 16px 0 8px;
  min-height: var(--lyrics-line-height-px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: var(--lyrics-line-height);
  white-space: pre-wrap;
  overflow-wrap: break-word;
  word-break: normal;
  outline: none;
  border-left: 2px solid transparent;
  transition: border-color .12s ease;
}
.block-bar-content:focus {
  border-left-color: var(--accent);
}
.block-bar-content.readonly-view {
  color: var(--accent-2);
  cursor: default;
}
.block-section-content {
  padding: 0 16px 0 8px;
  min-height: var(--lyrics-line-height-px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: var(--lyrics-line-height);
  color: var(--accent-2);
  font-weight: 600;
  opacity: .7;
  outline: none;
  white-space: pre-wrap;
}
.block-empty-content {
  padding: 0 16px 0 8px;
  min-height: var(--lyrics-line-height-px);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: var(--lyrics-line-height);
  outline: none;
}

/* ── Context Menu ──────────────────────────────────────────────────── */
.editor-context-menu {
  position: fixed;
  z-index: 100;
  min-width: 200px;
  max-width: 320px;
  background: var(--panel-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 6px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}
.editor-context-menu[hidden] { display: none; }

.selection-action-toolbar {
  position: fixed;
  z-index: 110;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid rgba(124,255,163,.24);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(16, 23, 39, .98), rgba(9, 14, 26, .98));
  box-shadow: 0 12px 28px rgba(0,0,0,.34), 0 0 0 1px rgba(124,255,163,.10) inset;
  transform: translate(-50%, -118%);
  backdrop-filter: blur(18px);
}

.selection-toolbar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid rgba(124,255,163,.16);
  border-radius: 10px;
  background: rgba(255,255,255,.02);
  color: var(--text);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, transform .12s ease;
}

.selection-toolbar-btn:hover {
  background: rgba(124,255,163,.10);
  border-color: rgba(124,255,163,.34);
  transform: translateY(-1px);
}

.selection-toolbar-btn:focus-visible {
  outline: 2px solid rgba(122,162,255,.78);
  outline-offset: 2px;
}

.selection-toolbar-icon {
  font-size: 14px;
  line-height: 1;
}

.selection-toolbar-label {
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.selection-toolbar-more .selection-toolbar-icon {
  font-size: 18px;
  margin-top: -1px;
}

.ctx-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
  text-align: left;
  transition: background .1s;
}
.ctx-menu-item:hover {
  background: rgba(124,255,163,.10);
}
.ctx-menu-item .ctx-icon {
  font-size: 14px;
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}
.ctx-menu-sep {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

/* ── Inline Suggestions ────────────────────────────────────────────── */
.inline-suggestion-panel {
  margin: 4px 0 4px var(--line-stats-width);
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(124,255,163,.04);
  border: 1px solid rgba(124,255,163,.16);
  display: grid;
  gap: 6px;
}
.inline-suggestion-panel .suggestion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
}
.inline-suggestion-card {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(124,255,163,.06);
  border: 1px solid rgba(124,255,163,.12);
  display: grid;
  gap: 6px;
}
.inline-suggestion-card .suggestion-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
  opacity: .7;
}
.inline-suggestion-card .suggestion-text {
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.5;
}
.inline-suggestion-actions {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.inline-suggestion-actions button {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(124,255,163,.08);
  border: 1px solid rgba(124,255,163,.18);
  color: var(--text);
  cursor: pointer;
  transition: background .1s;
}
.inline-suggestion-actions button:hover {
  background: rgba(124,255,163,.18);
  transform: none;
}
.inline-suggestion-actions .suggestion-dismiss {
  background: rgba(255,255,255,.05);
  border-color: var(--border);
  color: var(--muted);
}

/* Legacy hidden textarea for data compatibility */
#lyricsInput { position: absolute; left: -99999px; top: -99999px; width: 0; height: 0; overflow: hidden; }
.right-sidebar {
  position: relative;
  display: grid;
  grid-template-columns: 42px 6px minmax(0, 1fr);
  gap: 8px;
  align-items: stretch;
  overflow: hidden;
  padding: 12px;
  height: 100%;
  min-height: 0;
}
.right-sidebar.collapsed {
  grid-template-columns: 56px;
  padding: 10px;
}
.drawer-handle {
  position: static;
  top: auto;
  width: 100%;
  min-width: 42px;
  min-height: 100%;
  height: 100%;
  padding: 10px 4px;
  border-radius: 14px;
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: start;
  justify-items: center;
  gap: 8px;
  align-self: stretch;
  z-index: 4;
  background: rgba(15, 23, 42, 0.96);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 6px 18px rgba(0,0,0,0.22);
}
.drawer-arrow {
  font-size: 16px;
  line-height: 1;
}
.drawer-label {
  display: inline-block;
  align-self: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--muted);
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.right-sidebar.collapsed .drawer-handle,
.sidebar.collapsed .drawer-handle {
  width: 100%;
  min-width: 48px;
  min-height: 100%;
  height: 100%;
  align-self: stretch;
  border-radius: 14px;
  padding: 12px 4px;
  justify-items: center;
  align-items: stretch;
}

.sidebar-resize-handle {
  align-self: stretch;
  width: 6px;
  border-radius: 999px;
  cursor: ew-resize;
  background: linear-gradient(180deg, rgba(124,255,163,.04), rgba(124,255,163,.20), rgba(124,255,163,.04));
  opacity: .7;
}
.sidebar-resize-handle:hover,
.sidebar-resize-handle.resizing {
  background: linear-gradient(180deg, rgba(124,255,163,.18), rgba(124,255,163,.52), rgba(124,255,163,.18));
}
.drawer-content {
  display: grid;
  gap: 16px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  max-height: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  align-content: start;
  grid-auto-rows: max-content;
  padding-right: 4px;
}
.right-sidebar.collapsed .drawer-content,
.right-sidebar.collapsed .sidebar-resize-handle {
  display: none;
}
.subpanel {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(148, 163, 184, 0.10);
  border-radius: 14px;
  padding: 12px;
  background: rgba(7, 11, 20, 0.28);
}
.subpanel-toggle {
  width: 32px;
  min-width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
}
.subpanel-body { display: grid; gap: 8px; }
.subpanel.collapsed .subpanel-body { display: none; }
.song-list { display: flex; flex-direction: column; gap: 8px; min-height: 0; flex: 1 1 auto; overflow-y: auto; overflow-x: hidden; padding-right: 6px; align-items: stretch; }
.song-card {
  background: rgba(255,255,255,.03);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  flex: 0 0 auto;
  min-height: 0;
}
.song-card.active { border-color: rgba(124,255,163,.48); box-shadow: 0 0 0 1px rgba(124,255,163,.25) inset; }
.song-card h3 { margin: 0; font-size: 14px; line-height: 1.25; }
.song-card .meta { color: var(--muted); font-size: 12px; line-height: 1.35; }
.song-card .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.song-card .actions button { padding: 7px 10px; border-radius: 10px; font-size: 12px; }
.rhyme-provider-row { display: grid; grid-template-columns: minmax(0, 1fr); gap: 10px; }
.provider-field { display: grid; gap: 6px; color: var(--muted); }
.rhyme-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: end; }
.muted { color: var(--muted); font-size: 14px; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  background: rgba(124,255,163,.1);
  color: var(--text);
  border: 1px solid rgba(124,255,163,.25);
  border-radius: 999px;
  padding: 7px 12px;
}
.rhyme-group { display: grid; gap: 8px; margin-bottom: 12px; }
.rhyme-group-title {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.ai-chat-log {
  min-height: 100px;
  max-height: 360px;
  overflow: auto;
  display: grid;
  gap: 8px;
  margin-bottom: 6px;
  align-content: end;
}
.ai-bubble { border-radius: 14px; padding: 10px 12px; white-space: pre-wrap; font-size: 14px; line-height: 1.5; }
.ai-bubble.user { background: rgba(6, 11, 20, 0.95); border: 1px solid var(--border); font-size: 12px; color: var(--muted); padding: 6px 10px; }
.ai-bubble.assistant { background: rgba(124,255,163,.06); border: 1px solid rgba(124,255,163,.20); position: relative; }
.ai-result-group { display: grid; gap: 6px; }
.ai-result-card {
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(124,255,163,.05);
  border: 1px solid rgba(124,255,163,.16);
  white-space: pre-wrap;
  font-size: 14px;
  line-height: 1.5;
}
.ai-result-card .ai-card-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--accent);
  margin-bottom: 4px;
  opacity: .7;
}
.ai-result-card .ai-card-text {
  white-space: pre-wrap;
  line-height: 1.5;
}
.ai-input-row { display: flex; gap: 10px; align-items: stretch; }
.ai-input-row.stacked { flex-direction: column; }
.notes-subpanel textarea,
#aiUserInput { min-height: 80px; }
#notesInput { min-height: 100px; }
.readonly-badge {
  background: rgba(255,255,255,.1);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 13px;
}
.hidden-storage {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}
.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
}
.settings-overlay[hidden] { display: none !important; }
.settings-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 14, 0.72);
  backdrop-filter: blur(10px);
}
.settings-dialog {
  position: relative;
  z-index: 1;
  width: min(760px, calc(100vw - 48px));
}
.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.settings-span-2 { grid-column: span 2; }
.settings-hint {
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(7, 11, 20, 0.55);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}
.settings-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

/* ── Shared alert / confirm dialog ──────────────────────────────── */
.app-dialog {
  position: relative;
  z-index: 1;
  width: min(460px, calc(100vw - 48px));
  padding: 24px;
}
.app-dialog-message {
  margin: 0 0 20px;
  font-size: 15px;
  line-height: 1.55;
  white-space: pre-line;
  color: var(--text);
}
.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}
@media (max-width: 1450px) {
  .meta-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 1250px) {
  .editor-shell,
  .editor-shell.sidebar-collapsed { grid-template-columns: 1fr; height: auto; max-height: none; }
  .right-sidebar,
  .right-sidebar.collapsed {
    position: relative;
    top: 0;
    grid-template-columns: 42px 6px minmax(0, 1fr);
    padding: 12px;
    min-height: 0;
  }
  .right-sidebar.collapsed .drawer-content,
  .right-sidebar.collapsed .sidebar-resize-handle { display: none; }
  .drawer-label { display: none !important; }
}
@media (max-width: 1100px) {
  body { overflow: auto; }
  #app { height: auto; overflow: visible; }
  .layout { grid-template-columns: 1fr; overflow: visible; }
  .workspace { overflow: visible; }
  .sidebar { order: 2; }
}
@media (max-width: 860px) {
  .meta-grid,
  .rhyme-controls,
  .meta-upload,
  .settings-grid { grid-template-columns: 1fr; }
  .settings-span-2 { grid-column: auto; }
  .lyrics-wrap { grid-template-columns: minmax(76px, var(--line-stats-width)) 1fr; }
  .lyrics-toolbar { justify-content: flex-start; }
  .lyrics-viewport { max-height: 68vh; }
}
@media (max-width: 760px) {
  body { padding: 8px; }
  #app { height: calc(100dvh - 16px); }
  .topbar { align-items: flex-start; }
}

/* Auth: user badge & role badge */
.user-badge { font-size: .8rem; color: var(--muted); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.role-badge { display: inline-block; font-size: .65rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; background: var(--accent); color: #fff; border-radius: 6px; padding: 1px 6px; margin-left: 5px; vertical-align: middle; }


.settings-actions-split {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0.85rem;
}
.settings-debug-panel {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.9rem;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background: rgba(255,255,255,0.03);
}
.settings-debug-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}
.settings-debug-output {
  margin: 0;
  min-height: 120px;
  max-height: 260px;
  overflow: auto;
  padding: 0.8rem;
  border-radius: 12px;
  background: rgba(7,10,18,0.82);
  color: #d9e4ff;
  font-size: 0.82rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 900px) {
  .topbar {
    grid-template-columns: minmax(0, 1fr);
  }
  .top-actions {
    justify-content: flex-start;
  }
  .brand-lockup {
    width: 100%;
  }
  .brand-banner-shell {
    width: min(100%, 560px);
    height: 90px;
  }
  .brand-banner {
    width: 100%;
    height: 100%;
  }
}
@media (max-width: 680px) {
  .topbar {
    align-items: flex-start;
  }
  .brand-lockup {
    width: 100%;
  }
  .brand-banner-shell {
    width: 100%;
    height: 80px;
    border-radius: 0;
  }
  .brand-banner {
    width: 100%;
    height: 100%;
    object-position: left center;
  }
}

/* ── Syllable toggle improved ──────────────────────────────────────── */
#toggleLineStatsBtn {
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 10px;
  transition: background .15s, border-color .15s, color .15s;
}
#toggleLineStatsBtn.active {
  background: rgba(124,255,163,.15);
  border-color: rgba(124,255,163,.4);
  color: var(--accent);
}

/* ── Library empty state ───────────────────────────────────────────── */
.library-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 14px;
  text-align: center;
  color: var(--muted);
  min-height: 120px;
}
.library-empty-icon {
  font-size: 28px;
  opacity: .35;
  line-height: 1;
}
.library-empty h3 {
  margin: 0;
  font-size: 14px;
  color: var(--text);
  font-weight: 600;
}
.library-empty p {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
  max-width: 200px;
}
.library-empty .library-cta {
  margin-top: 4px;
  font-size: 13px;
  padding: 8px 16px;
}

/* ── AI context bar ────────────────────────────────────────────────── */
.ai-context-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(122,162,255,.08);
  border: 1px solid rgba(122,162,255,.18);
  font-size: 12px;
  color: var(--muted);
  flex-wrap: wrap;
}
.ai-context-bar strong {
  color: var(--accent-2);
  font-weight: 600;
}
.ai-context-bar .ai-ctx-selection {
  color: var(--text);
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: italic;
}

/* ── AI quick actions ──────────────────────────────────────────────── */
.ai-quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ai-quick-actions button {
  font-size: 12px;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(122,162,255,.08);
  border: 1px solid rgba(122,162,255,.18);
  color: var(--text);
  white-space: nowrap;
  transition: background .12s, border-color .12s;
}
.ai-quick-actions button:hover {
  background: rgba(122,162,255,.16);
  border-color: rgba(122,162,255,.32);
}

/* ── Notes cleaner ─────────────────────────────────────────────────── */
.notes-subpanel textarea {
  min-height: 80px;
  font-size: 14px;
  line-height: 1.5;
  border-radius: 10px;
}

/* ── Subpanel header tweaks ────────────────────────────────────────── */
.subpanel > .panel-header h2 {
  font-size: 14px;
}

/* ── Rhyme search compact ──────────────────────────────────────────── */
.rhyme-controls input {
  padding: 8px 10px;
  font-size: 13px;
}
.rhyme-controls button {
  padding: 8px 12px;
  font-size: 13px;
}
.chip {
  padding: 4px 9px;
  font-size: 12px;
}

/* ── Compact panel adjustments ─────────────────────────────────────── */
.compact { padding: 8px 12px; }
.ai-bubble-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.ai-bubble-actions button {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(124,255,163,.08);
  border: 1px solid rgba(124,255,163,.18);
  color: var(--muted);
  cursor: pointer;
  transition: background .1s, color .1s;
}
.ai-bubble-actions button:hover {
  background: rgba(124,255,163,.18);
  color: var(--text);
  transform: none;
}


/* Phase 2 – brand polish for header and editor */
.topbar.brand-app-header {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  padding: 12px 22px;
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(19, 28, 46, 0.9), rgba(10, 16, 29, 0.92)),
    radial-gradient(circle at top left, rgba(122,162,255,.12), transparent 28%);
  border-color: rgba(148,163,184,.16);
  box-shadow: 0 26px 60px rgba(0,0,0,.28);
}

.topbar.brand-app-header::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255,255,255,.04), transparent 22%, transparent 78%, rgba(255,255,255,.02));
  pointer-events: none;
}

.brand-header-lockup {
  align-self: stretch;
}

.brand-banner-shell {
  width: clamp(420px, 42vw, 680px);
  height: clamp(90px, 11vw, 120px);
  padding: 0;
  border-radius: 0;
  align-items: center;
  background: transparent;
  border: none;
  box-shadow: none;
  overflow: visible;
}

.brand-banner {
  object-fit: contain;
  object-position: left center;
  filter: none;
}

.top-actions.brand-header-actions {
  gap: 8px;
  padding: 8px;
  border-radius: 18px;
  background: rgba(7, 11, 20, 0.38);
  border: 1px solid rgba(148,163,184,.12);
  justify-content: flex-end;
}

.top-actions.brand-header-actions > button,
.top-actions.brand-header-actions > a {
  min-height: 42px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.04);
  border: 1px solid rgba(148,163,184,.12);
  color: #d6def6;
  max-width: 220px;
}

.layout {
  gap: 14px;
}

.workspace.brand-editor-workspace {
  gap: 14px;
}

.brand-meta-panel {
  padding: 12px 14px;
  background: linear-gradient(180deg, rgba(15, 22, 37, 0.78), rgba(10, 15, 27, 0.82));
  border-color: rgba(148,163,184,.14);
  box-shadow: 0 14px 30px rgba(0,0,0,.16);
}

.meta-grid label {
  gap: 6px;
  font-size: 12px;
  letter-spacing: .02em;
}

.file-name,
.beat-status-box {
  background: rgba(5, 10, 20, 0.58);
}

.editor-shell {
  --right-sidebar-width: 350px;
  gap: 14px;
}

.brand-editor-primary {
  padding: 16px;
  border-radius: 24px;
  border-color: rgba(124,255,163,.12);
  box-shadow: 0 30px 70px rgba(0,0,0,.28);
}

.brand-editor-header {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(148,163,184,.12);
}

.brand-editor-header h2 {
  font-size: 1.1rem;
  letter-spacing: -.02em;
}

.lyrics-toolbar {
  gap: 8px;
}

.toolbar-check,
.toolbar-badge,
#toggleLineStatsBtn {
  background: rgba(7, 11, 20, 0.76);
  border-color: rgba(148,163,184,.16);
}

.brand-lyrics-focus {
  padding: 10px 10px 10px 6px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(6, 11, 20, 0.5), rgba(10, 16, 28, 0.72)),
    radial-gradient(circle at top left, rgba(124,255,163,.05), transparent 25%);
  border: 1px solid rgba(124,255,163,.12);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}

.editor-root {
  min-height: 440px;
  padding: 14px 0;
}

.editor-root:empty::before {
  padding: 18px 18px;
  font-size: 15px;
}

.block-row {
  border-radius: 10px;
}

.block-row.active {
  background: rgba(124,255,163,.06);
}

.block-row.selected {
  background: rgba(122,162,255,.08);
}

.block-gutter {
  padding: 2px 10px 2px 6px;
  opacity: .82;
}

.block-bar-content,
.block-section-content,
.block-empty-content {
  padding: 2px 20px 2px 12px;
  font-size: 16px;
}

.block-bar-content {
  border-left-width: 3px;
}

.brand-editor-secondary {
  padding: 14px;
  border-radius: 22px;
  border-color: rgba(148,163,184,.12);
  background: linear-gradient(180deg, rgba(13, 19, 33, 0.84), rgba(8, 12, 23, 0.92));
}

.right-sidebar {
  grid-template-columns: 46px 6px minmax(0, 1fr);
}

.drawer-handle {
  border-radius: 16px;
  background: rgba(14, 22, 38, 0.92);
}

.drawer-content {
  gap: 12px;
}

.subpanel {
  gap: 10px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(5, 10, 20, 0.4);
  border-color: rgba(148,163,184,.12);
}

.subpanel > .panel-header h2 {
  font-size: 13px;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: #d8e0fb;
}

.ai-chat-log,
.notes-subpanel textarea,
#aiUserInput {
  background: rgba(3, 8, 18, 0.26);
  border-radius: 14px;
  padding: 10px;
}

.song-card,
.ai-result-card,
.inline-suggestion-card {
  background: rgba(255,255,255,.025);
}

@media (max-width: 900px) {
  .topbar.brand-app-header {
    gap: 14px;
  }

  .top-actions.brand-header-actions {
    justify-content: flex-start;
  }

  .brand-banner-shell {
    width: min(100%, 520px);
    height: 90px;
  }
}

@media (max-width: 680px) {
  .brand-banner-shell {
    height: 76px;
    padding-inline: 0;
  }

  .top-actions.brand-header-actions {
    width: 100%;
  }
}

/* ── Plaintext editor mode (single-host textarea) ─────────────────── */
.editor-root-plaintext {
  min-height: 440px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.lyrics-editor-plain {
  display: grid;
  grid-template-columns: var(--line-stats-width) minmax(0, 1fr);
  align-items: stretch;
  min-height: 440px;
  border-radius: 14px;
  background: rgba(8, 12, 23, 0.34);
}

.lyrics-gutter-pane {
  overflow: hidden;
  padding: 14px 0;
  border-right: 1px solid rgba(148,163,184,.08);
}

.lyrics-gutter-line {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
  min-height: var(--lyrics-line-height-px);
  padding: 2px 10px 2px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  opacity: .82;
  user-select: none;
}

.lyrics-gutter-line .gutter-bar {
  opacity: .72;
  min-width: 52px;
  text-align: right;
  letter-spacing: .03em;
}

.lyrics-gutter-line .gutter-divider {
  opacity: .28;
}

.lyrics-gutter-line .gutter-syl {
  color: var(--accent);
  opacity: .95;
  min-width: 18px;
  text-align: right;
}

.lyrics-gutter-line .gutter-density-point {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 12px;
  color: rgba(148,163,184,.62);
  opacity: .88;
  cursor: help;
}

.lyrics-gutter-line .gutter-density-point.is-green {
  color: rgba(124,255,163,.95);
}

.lyrics-gutter-line .gutter-density-point.is-yellow {
  color: rgba(250,204,21,.92);
}

.lyrics-gutter-line .gutter-density-point.is-red {
  color: rgba(248,113,113,.84);
}

.lyrics-gutter-line.active {
  background: rgba(124,255,163,.06);
}

.lyrics-gutter-line.selected {
  background: rgba(122,162,255,.08);
}

.lyrics-textarea {
  width: 100%;
  min-height: 440px;
  border: none;
  outline: none;
  resize: none;
  margin: 0;
  padding: 16px 20px 16px 12px;
  background: transparent;
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  line-height: var(--lyrics-line-height);
  white-space: pre;
  overflow: auto;
  tab-size: 2;
  caret-color: var(--accent);
}

.lyrics-textarea::selection {
  background: rgba(122,162,255,.28);
}

.lyrics-textarea::placeholder {
  color: var(--muted);
  opacity: .5;
}


.floating-suggestion-popover {
  position: fixed;
  z-index: 120;
  width: min(520px, calc(100vw - 40px));
  max-height: min(58vh, 560px);
  overflow: auto;
  padding: 10px 12px;
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(11, 18, 33, .98), rgba(8, 12, 24, .98));
  border: 1px solid rgba(124,255,163,.20);
  box-shadow: 0 22px 44px rgba(0,0,0,.42), 0 0 0 1px rgba(124,255,163,.08) inset;
  backdrop-filter: blur(18px);
  transform: translate(-12%, 0);
}

.floating-suggestion-popover .suggestion-header.floating {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 12px;
  color: var(--muted);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.floating-suggestion-popover .suggestion-dismiss {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 7px;
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  color: var(--muted);
  cursor: pointer;
}

.floating-suggestion-list {
  display: grid;
  gap: 10px;
}

.floating-suggestion-popover .floating-card {
  background: rgba(124,255,163,.05);
  border-color: rgba(124,255,163,.16);
}

.inline-suggestion-actions .suggestion-subtle {
  background: rgba(255,255,255,.04);
  border-color: rgba(255,255,255,.10);
  color: var(--muted);
}

.floating-density-tooltip {
  position: fixed;
  z-index: 1250;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(124,255,163,.16);
  background: rgba(7, 12, 22, 0.94);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.36);
  color: var(--text);
  pointer-events: none;
  backdrop-filter: blur(12px);
}

.floating-density-tooltip-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.floating-density-tooltip-rows {
  display: grid;
  gap: 4px;
}

.floating-density-tooltip-row {
  font-size: 12px;
  line-height: 1.35;
  color: var(--muted);
}

.floating-density-tooltip-current {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(148,163,184,.14);
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.meta-source-hint {
  color: var(--muted);
  font-size: 11px;
}
.meta-upload-stack {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}
.meta-upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}
.beat-analysis-card {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(7, 11, 20, 0.72);
}
.beat-analysis-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.beat-analysis-status {
  font-size: 12px;
  color: var(--muted);
}
.beat-analysis-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}
.beat-analysis-grid > div,
.beat-analysis-alt-row,
.beat-analysis-meta {
  display: grid;
  gap: 2px;
}
.beat-analysis-label {
  color: var(--muted);
  font-size: 11px;
}
.beat-analysis-alt-list,
.beat-analysis-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.beat-analysis-pill {
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.08);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 10px;
  cursor: pointer;
}
.beat-analysis-meta {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  color: var(--muted);
  font-size: 12px;
}
.beat-analysis-actions button.secondary {
  background: rgba(148, 163, 184, 0.08);
}
.beat-analysis-actions button.ghost {
  background: transparent;
  border: 1px dashed var(--border);
}
.beat-analysis-error {
  color: #fca5a5;
  font-size: 13px;
}
.audio-analysis-panel {
  grid-column: 1 / -1;
}
.analysis-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.analysis-auto-apply {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.analysis-btn {
  border: 1px solid var(--border);
  background: rgba(148, 163, 184, 0.08);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 10px;
}
.analysis-results {
  display: grid;
  gap: 8px;
}
.analysis-error {
  color: #fca5a5;
  font-size: 13px;
}

.beat-length-summary {
  grid-column: 1 / -1;
}

.beat-length-grid strong {
  font-variant-numeric: tabular-nums;
}
