/* ============================================
   DopeChorus - Design System
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Backgrounds */
  --bg-primary: #08080e;
  --bg-secondary: #0e0e18;
  --bg-surface: rgba(255, 255, 255, 0.03);
  --bg-surface-hover: rgba(255, 255, 255, 0.06);
  --bg-surface-active: rgba(255, 255, 255, 0.09);
  --bg-glass: rgba(16, 16, 28, 0.85);

  /* Borders */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-default: rgba(255, 255, 255, 0.1);
  --border-hover: rgba(255, 255, 255, 0.15);

  /* Text */
  --text-primary: #e4e4e7;
  --text-secondary: #a1a1aa;
  --text-muted: #52525b;
  --text-accent: #c4b5fd;

  /* Accents */
  --accent-purple: #a78bfa;
  --accent-indigo: #818cf8;
  --accent-gradient: linear-gradient(135deg, #a78bfa, #818cf8);
  --accent-glow: rgba(167, 139, 250, 0.15);

  /* Rhyme group colors */
  --rhyme-a: #a78bfa;
  --rhyme-b: #60a5fa;
  --rhyme-c: #34d399;
  --rhyme-d: #fbbf24;
  --rhyme-e: #f472b6;
  --rhyme-f: #fb923c;
  --rhyme-g: #e879f9;
  --rhyme-h: #22d3ee;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 20px var(--accent-glow);

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);

  /* Font */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

  /* Editor sizing */
  --editor-font: 0.9rem;
  --editor-lh: 24px;
}

/* ============================================
   Reset & Base
   ============================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: hidden;
}

::selection {
  background: rgba(167, 139, 250, 0.3);
  color: #fff;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ============================================
   App Layout
   ============================================ */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: radial-gradient(ellipse at 20% 0%, rgba(99, 102, 241, 0.08) 0%, transparent 60%),
              radial-gradient(ellipse at 80% 100%, rgba(167, 139, 250, 0.06) 0%, transparent 60%),
              var(--bg-primary);
}

/* ============================================
   Header
   ============================================ */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-xl);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(20px);
  background: rgba(8, 8, 14, 0.8);
  z-index: 10;
  flex-shrink: 0;
}

.logo {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.logo h1 {
  font-size: 1.3rem;
  font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.logo-icon {
  font-size: 1.4rem;
}

.header-actions {
  display: flex;
  gap: var(--space-sm);
}

.btn {
  font-family: var(--font-ui);
  font-size: 0.8rem;
  font-weight: 500;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn:hover {
  background: var(--bg-surface-hover);
  border-color: var(--border-hover);
  color: var(--text-primary);
}

.btn-accent {
  background: rgba(167, 139, 250, 0.1);
  border-color: rgba(167, 139, 250, 0.3);
  color: var(--accent-purple);
}

.btn-accent:hover {
  background: rgba(167, 139, 250, 0.2);
  border-color: rgba(167, 139, 250, 0.5);
}

/* ============================================
   Main Layout
   ============================================ */
main {
  display: flex;
  flex: 1;
  overflow: hidden;
  gap: 1px;
  background: var(--border-subtle);
}

/* ============================================
   Editor
   ============================================ */
.editor-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  min-width: 0;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.editor-toolbar .label {
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.editor-nav {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: 8px var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
  background: var(--bg-surface);
}

.editor-nav.hidden { display: none; }

.nav-node {
  font-family: var(--font-ui);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  background: rgba(167, 139, 250, 0.1);
  color: var(--accent-purple);
  border: 1px solid rgba(167, 139, 250, 0.2);
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.nav-node:hover {
  background: rgba(167, 139, 250, 0.2);
  border-color: rgba(167, 139, 250, 0.4);
}

.toolbar-sep {
  color: var(--text-muted);
  opacity: 0.4;
}

.char-count {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-accent);
  font-weight: 500;
}

.char-count.warning { color: #fbbf24; }
.char-count.danger { color: #ef4444; }

.editor-container {
  flex: 1;
  display: flex;
  position: relative;
  overflow: hidden;
}

.line-numbers {
  width: 48px;
  padding: var(--space-md) 0;
  padding-right: var(--space-sm);
  text-align: right;
  font-family: var(--font-mono);
  font-size: var(--editor-font);
  line-height: var(--editor-lh);
  color: var(--text-muted);
  user-select: none;
  overflow: hidden;
  border-right: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.line-numbers .ln {
  display: block;
  cursor: pointer;
  padding-right: 4px;
  border-radius: 3px 0 0 3px;
  transition: all var(--transition-fast);
  height: var(--editor-lh);
  line-height: var(--editor-lh);
}

.line-numbers .ln:hover {
  color: var(--text-secondary);
  background: rgba(167, 139, 250, 0.06);
}

.line-numbers .ln.selected {
  color: var(--accent-purple);
  background: rgba(167, 139, 250, 0.15);
  font-weight: 600;
  box-shadow: inset -2px 0 0 var(--accent-purple);
}

#editor {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: var(--editor-font);
  line-height: var(--editor-lh);
  padding: var(--space-md);
  tab-size: 2;
  white-space: pre;
  overflow-x: auto;
  overflow-y: auto;
}

#editor::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

#editor:focus {
  box-shadow: inset 0 0 0 1px rgba(167, 139, 250, 0.1);
}

/* Editor wrapper for overlay system */
.editor-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.editor-wrapper textarea {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  background: transparent;
  caret-color: var(--accent-purple);
  color: var(--text-primary);
}

/* Highlight layer (behind textarea) */
.highlight-layer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  pointer-events: none;
  font-family: var(--font-mono);
  font-size: var(--editor-font);
  line-height: var(--editor-lh);
  padding: var(--space-md);
  white-space: pre;
  overflow: hidden;
  color: transparent;
}

.hl-line {
  display: block;
  height: var(--editor-lh);
  line-height: var(--editor-lh);
  overflow: hidden;
}

.hl-line.hl-selected {
  background: rgba(167, 139, 250, 0.08);
  border-left: 2px solid var(--accent-purple);
  margin-left: -2px;
  padding-left: 2px;
}

/* Section header styling — visible background behind textarea text */
.hl-section {
  background: rgba(167, 139, 250, 0.2);
  box-shadow: inset 0 -2px 0 var(--accent-purple), 0 0 10px rgba(167, 139, 250, 0.3);
  border-radius: 3px;
  color: transparent;
}

/* Phonetic/pronunciation spelling styling — highlight layer only */
.hl-phonetic {
  background: rgba(34, 211, 238, 0.12);
  border-bottom: 1px dotted rgba(34, 211, 238, 0.5);
  border-radius: 2px;
}

/* Rhyme group color coding — colored underline on end-words */
.hl-rhyme {
  border-bottom-width: 2px;
  border-bottom-style: solid;
  /* border-bottom-color set inline per rhyme group */
  border-radius: 2px;
  /* box-shadow set inline for glow effect */
}

/* Parenthetical text */
.hl-paren {
  color: var(--text-secondary);
  font-style: italic;
}

/* ============================================
   Inspector Panel
   ============================================ */
.inspector-section {
  width: 360px;
  display: flex;
  flex-direction: column;
  background: var(--bg-secondary);
  overflow-y: auto;
  flex-shrink: 0;
}

.inspector-header {
  padding: var(--space-md);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.inspector-panel {
  border-bottom: 1px solid var(--border-subtle);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md);
  cursor: pointer;
  user-select: none;
  transition: background var(--transition-fast);
}

.panel-header:hover {
  background: var(--bg-surface-hover);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 0.85rem;
  font-weight: 600;
}

.panel-title .icon { font-size: 1rem; }

.panel-chevron {
  color: var(--text-muted);
  transition: transform var(--transition-fast);
  font-size: 0.75rem;
}

.panel-header[aria-expanded="true"] .panel-chevron {
  transform: rotate(90deg);
}

.panel-body {
  padding: 0 var(--space-md) var(--space-md);
  overflow: hidden;
}

.panel-body.collapsed {
  display: none;
}

/* Rhyme Scheme Display */
.rhyme-scheme-display {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  margin-bottom: var(--space-md);
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.1em;
}

.rhyme-letter {
  padding: 2px 6px;
  border-radius: 3px;
  min-width: 24px;
  text-align: center;
}

/* Line Ending Cards */
.line-ending {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.82rem;
}

.line-ending:last-child { border-bottom: none; }

.line-num-badge {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--text-muted);
  min-width: 28px;
  padding-top: 2px;
}

.ending-word {
  font-family: var(--font-mono);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  flex-shrink: 0;
}

.ending-rhymes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
}

.rhyme-chip {
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-surface);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.rhyme-chip:hover {
  background: var(--bg-surface-active);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* Syllable Counter */
.syllable-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--border-subtle);
}

.syllable-line:last-child { border-bottom: none; }

.syllable-text {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}

.syllable-count {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-surface);
  color: var(--text-accent);
  min-width: 28px;
  text-align: center;
}

/* ============================================
   Context Menu
   ============================================ */
.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 280px;
  max-width: 360px;
  max-height: 480px;
  overflow-y: auto;
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg), 0 0 0 1px rgba(255,255,255,0.03) inset;
  padding: var(--space-sm);
  animation: menuIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes menuIn {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.context-menu.hidden { display: none; }

.context-menu-header {
  padding: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-xs);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.selected-word-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.selected-word-text {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--accent-purple);
  padding: 2px 8px;
  background: rgba(167, 139, 250, 0.1);
  border-radius: var(--radius-sm);
}

.menu-category {
  border-radius: var(--radius-md);
  overflow: hidden;
  margin-bottom: 2px;
}

.category-header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  cursor: pointer;
  transition: background var(--transition-fast);
  border-radius: var(--radius-sm);
}

.category-header:hover {
  background: var(--bg-surface-hover);
}

.category-icon { font-size: 0.9rem; }

.category-label {
  flex: 1;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.category-count {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  background: var(--bg-surface);
  padding: 1px 6px;
  border-radius: 8px;
}

.category-chevron {
  color: var(--text-muted);
  font-size: 0.65rem;
  transition: transform var(--transition-fast);
}

.category-header.expanded .category-chevron {
  transform: rotate(90deg);
}

.category-items {
  display: none;
  padding: 2px var(--space-sm) var(--space-sm);
  flex-direction: column;
  gap: 4px;
}

.category-items.expanded {
  display: flex;
}

.suggestion-def {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  color: var(--text-muted);
  white-space: normal;
  text-align: left;
  line-height: 1.2;
  margin-top: 4px;
  max-width: 100%;
}

.suggestion-word {
  font-weight: 600;
  color: var(--accent-purple);
}

.suggestion-item {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  text-align: left;
}

.suggestion-item:hover {
  background: rgba(167, 139, 250, 0.15);
  border-color: rgba(167, 139, 250, 0.3);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(167, 139, 250, 0.1);
}

.category-loading {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-default);
  border-top-color: var(--accent-purple);
  border-radius: 50%;
  animation: spin 600ms linear infinite;
}

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

.category-empty {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ============================================
   Autocomplete
   ============================================ */
.autocomplete {
  position: fixed;
  z-index: 999;
  min-width: 250px;
  max-width: 350px;
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  padding: var(--space-xs);
  animation: acIn 150ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes acIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.autocomplete.hidden { display: none; }

.autocomplete-header {
  padding: 4px var(--space-sm);
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-xs);
}

.ac-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 8px var(--space-sm);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast);
  border-bottom: 1px solid var(--border-subtle);
}

.ac-item:last-child {
  border-bottom: none;
}

.ac-item:hover, .ac-item.selected {
  background: rgba(167, 139, 250, 0.12);
}

.ac-item .ac-hint {
  font-size: 0.65rem;
  color: var(--text-muted);
  font-family: var(--font-ui);
}

.ac-item .ac-def {
  font-family: var(--font-ui);
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 4px;
  white-space: normal;
  line-height: 1.2;
}

/* ============================================
   Toast Notifications
   ============================================ */
.toast-container {
  position: fixed;
  bottom: var(--space-lg);
  right: var(--space-lg);
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.toast {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-glass);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  font-size: 0.82rem;
  color: var(--text-primary);
  animation: toastIn 300ms cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.toast.out { animation: toastOut 200ms ease-in forwards; }

@keyframes toastIn {
  from { opacity: 0; transform: translateY(10px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes toastOut {
  to { opacity: 0; transform: translateY(10px) scale(0.95); }
}

/* ============================================
   Empty States
   ============================================ */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-xl);
  text-align: center;
  color: var(--text-muted);
  gap: var(--space-sm);
}

.empty-state .icon { font-size: 1.5rem; opacity: 0.5; }
.empty-state p { font-size: 0.8rem; }

/* ============================================
   Save/Load Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1500;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 200ms ease;
}

.modal-overlay.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  min-width: 400px;
  max-width: 500px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 300ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: var(--space-md);
}

.modal input[type="text"] {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  outline: none;
  margin-bottom: var(--space-md);
}

.modal input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.modal-actions {
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

.saved-list {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: var(--space-md);
}

.saved-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition-fast);
  font-size: 0.85rem;
}

.saved-item:hover { background: var(--bg-surface-hover); }

.saved-item .date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.saved-item .delete-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all var(--transition-fast);
}

.saved-item .delete-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 900px) {
  main { flex-direction: column; }
  .editor-section { height: 60vh; flex: none; }
  .inspector-section {
    width: 100%;
    height: 40vh;
    max-height: 40vh;
  }
  .autocomplete {
    max-width: 90vw;
  }
}

/* ============================================
   Rhyme Pairing Panel
   ============================================ */
.rhyme-pair-panel {
  background: linear-gradient(135deg, rgba(167,139,250,0.08), rgba(96,165,250,0.08));
  border: 1px solid rgba(167,139,250,0.2);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  margin: var(--space-md);
  animation: menuIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
}

.rhyme-pair-header {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--accent-purple);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.rhyme-pair-words {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}

.pair-word {
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 0.85rem;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: rgba(167,139,250,0.15);
  color: var(--accent-purple);
}

.pair-arrow {
  color: var(--text-muted);
  font-size: 0.8rem;
}

.pair-section {
  margin-bottom: var(--space-sm);
}

.pair-section-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.pair-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pair-chip {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pair-chip:hover {
  background: rgba(167,139,250,0.15);
  border-color: rgba(167,139,250,0.3);
  color: #fff;
  transform: translateY(-1px);
}

.pair-chip[data-target] {
  cursor: pointer;
}

.pair-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.8rem;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
  transition: all var(--transition-fast);
}

.pair-close:hover {
  color: var(--text-primary);
  background: var(--bg-surface-hover);
}

/* ============================================
   Utility
   ============================================ */
.hidden { display: none !important; }

/* ============================================
   Auth UI
   ============================================ */
.auth-controls {
  display: flex;
  align-items: center;
}

.btn-google {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  gap: 8px;
}

.btn-google:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-google svg {
  flex-shrink: 0;
}

.user-menu {
  position: relative;
}

.user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px 4px 4px;
  border-radius: 20px;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border-default);
  object-fit: cover;
}

.user-name {
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pro-badge {
  font-size: 0.6rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 8px;
  background: linear-gradient(135deg, #a78bfa, #818cf8);
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.free-badge {
  font-size: 0.6rem;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--bg-surface);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 240px;
  background: var(--bg-glass);
  backdrop-filter: blur(24px) saturate(1.5);
  -webkit-backdrop-filter: blur(24px) saturate(1.5);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: var(--space-xs);
  animation: menuIn 200ms cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 100;
}

.dropdown-header {
  padding: var(--space-sm) var(--space-md);
  font-size: 0.75rem;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-xs);
}

.dropdown-item {
  display: block;
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-ui);
  font-size: 0.82rem;
  text-align: left;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.dropdown-item:hover {
  background: var(--bg-surface-hover);
  color: var(--text-primary);
}

.dropdown-item.upgrade-item {
  color: var(--accent-purple);
  font-weight: 600;
}

.dropdown-item.upgrade-item:hover {
  background: rgba(167, 139, 250, 0.12);
}

/* ============================================
   Sync Status
   ============================================ */
.sync-status {
  font-size: 0.7rem;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 8px;
  transition: all var(--transition-normal);
}

.sync-cloud {
  color: #60a5fa;
  background: rgba(96, 165, 250, 0.1);
}

.sync-saved {
  color: #34d399;
  background: rgba(52, 211, 153, 0.1);
}

.sync-local {
  color: var(--text-muted);
  background: var(--bg-surface);
}

/* ============================================
   Hit Potential Dashboard
   ============================================ */
.hit-dashboard {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-xs);
}

.hit-metric {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  background: var(--bg-surface);
  padding: var(--space-sm);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
}

.hit-ring {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  color: var(--text-primary);
  background: conic-gradient(var(--accent-primary) 0%, var(--bg-surface) 0%);
}

.hit-ring::before {
  content: '';
  position: absolute;
  top: 4px; left: 4px; right: 4px; bottom: 4px;
  background: var(--bg-surface);
  border-radius: 50%;
  z-index: 1;
}

.hit-ring span {
  position: relative;
  z-index: 2;
}

.hit-info {
  flex: 1;
}

.hit-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.hit-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.3;
}

.hit-warnings {
  margin-top: var(--space-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hit-warning-item {
  display: block;
  width: 100%;
  text-align: left;
  font-size: 0.7rem;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.2);
  font-family: inherit;
}

.hit-warning-item.actionable {
  cursor: pointer;
  transition: all var(--transition-fast);
}

.hit-warning-item.actionable:hover {
  filter: brightness(1.2);
  transform: translateY(-1px);
}
