/* ============================================
   comps. - STYLES
   ============================================
   Design System based on Claude.ai aesthetics
   - Warm beige backgrounds
   - Terracotta accent colors  
   - Clean, minimal typography
   ============================================ */

/* ============================================
   DESIGN SYSTEM - Claude-Inspired Colors
   ============================================ */
:root {
    /* Background colors - warm beige palette */
    --primary-bg: #f4f0ec;
    --secondary-bg: #ffffff;
    --tertiary-bg: #faf8f5;
    
    /* Accent colors - terracotta/rust tones */
    --accent-primary: #d4875f;
    --accent-secondary: #b87048;
    --accent-tertiary: #8b5a3c;
    
    /* Text colors */
    --text-primary: #2d2d2d;
    --text-secondary: #6b6b6b;
    --text-tertiary: #9b9b9b;
    
    /* Status colors */
    --success: #4a9b7f;
    --warning: #e8a75d;
    --error: #d47d7d;
    
    /* Border colors */
    --border-light: #e8e4df;
    --border-medium: #d4cfc7;
    --border-dark: #b8b3ab;
    
    /* Shadow system */
    --shadow-subtle: 0 1px 3px rgba(45, 45, 45, 0.06);
    --shadow-medium: 0 2px 8px rgba(45, 45, 45, 0.10);
    --shadow-large: 0 4px 16px rgba(45, 45, 45, 0.12);
    
    /* Typography */
    --font-primary: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Helvetica Neue', sans-serif;
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    
    /* Spacing scale (4px base) */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
}

/* ============================================
   GLOBAL STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    /* Prevent horizontal scroll / drift on mobile.
       Content should never exceed viewport width. */
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

/* Also lock the React root to prevent any child
   from pushing the page wider than the viewport */
#root {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

body {
    font-family: var(--font-primary);
    background: var(--primary-bg);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    /* Prevent iOS Safari pull-to-refresh on main page
       when we want to handle it ourselves in sheets */
    overscroll-behavior-x: none;
}

/* ============================================
   LOGIN/AUTH STYLES
   ============================================ */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-bg) 0%, #e8e4df 100%);
}

.auth-card {
    background: var(--secondary-bg);
    border-radius: 20px;
    padding: var(--space-10);
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-large);
    text-align: center;
}

.auth-logo {
    font-size: var(--text-3xl);
    font-weight: 400;
    color: var(--accent-primary);
    margin-bottom: var(--space-2);
    letter-spacing: 1.5px;
    font-style: italic;
}

.auth-tagline {
    font-size: var(--text-base);
    color: var(--text-secondary);
    margin-bottom: var(--space-8);
}

.auth-divider {
    display: flex;
    align-items: center;
    margin: var(--space-6) 0;
    color: var(--text-tertiary);
    font-size: var(--text-sm);
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border-light);
}

.auth-divider span {
    padding: 0 var(--space-4);
}

.btn-google {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-4);
    border-radius: 12px;
    border: 2px solid var(--border-medium);
    background: var(--secondary-bg);
    color: var(--text-primary);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-google:hover {
    border-color: var(--accent-primary);
    background: var(--tertiary-bg);
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.btn-google:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.google-icon {
    width: 20px;
    height: 20px;
}

.auth-footer {
    margin-top: var(--space-8);
    font-size: var(--text-sm);
    color: var(--text-tertiary);
}

.auth-error {
    background: rgba(212, 125, 125, 0.1);
    border: 1px solid var(--error);
    color: var(--error);
    padding: var(--space-3) var(--space-4);
    border-radius: 8px;
    margin-bottom: var(--space-4);
    font-size: var(--text-sm);
}

/* ============================================
   USER MENU STYLES
   ============================================ */
.user-menu {
    position: relative;
    /* Prevent flex child from overflowing parent */
    min-width: 0;
    flex-shrink: 1;
}

.user-menu-button {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: 8px;
    border: 1px solid var(--border-light);
    background: var(--secondary-bg);
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-menu-button:hover {
    background: var(--tertiary-bg);
    border-color: var(--border-medium);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 600;
    overflow: hidden;
}

.user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

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

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--secondary-bg);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: var(--shadow-large);
    min-width: 200px;
    z-index: 1000;
    display: none;
}

.user-dropdown.open {
    display: block;
}

.user-dropdown-header {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-light);
}

.user-dropdown-name {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
}

.user-dropdown-email {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-top: var(--space-1);
}

.user-dropdown-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: none;
    background: none;
    text-align: left;
    color: var(--text-primary);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background 0.15s ease;
}

.user-dropdown-item:hover {
    background: var(--tertiary-bg);
}

.user-dropdown-item.danger {
    color: var(--error);
}

.user-dropdown-item.danger:hover {
    background: rgba(212, 125, 125, 0.1);
}

/* ============================================
   DASHBOARD STYLES
   ============================================ */
.dashboard-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* Prevent horizontal drift on mobile */
    overflow-x: hidden;
}

/* Dashboard header replaced by .app-accent-bar (shared with editor).
   The old .dashboard-header class is no longer used.
   Additional dashboard-specific overrides below. */

.dashboard-accent-bar {
    padding: 10px 20px;
}

/* UserMenu in accent bar — avatar-only circle button */
.dashboard-accent-bar .user-menu-button {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
}
.dashboard-accent-bar .user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255,255,255,0.25);
    transition: border-color 0.15s;
}
.dashboard-accent-bar .user-avatar:hover {
    border-color: rgba(255,255,255,0.5);
}
.dashboard-accent-bar .user-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
/* Ensure dropdown appears below the dark bar */
.dashboard-accent-bar .user-dropdown {
    top: 100%;
    right: 0;
    margin-top: 4px;
}

.dashboard-main {
    flex: 1;
    padding: var(--space-8);
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    /* Prevent content from causing horizontal overflow */
    overflow-x: hidden;
}

/* Welcome text and title removed from dashboard —
   accent bar provides identity; space saved. */

.dashboard-controls {
    display: flex;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
    align-items: center;
    flex-wrap: wrap;
}

.dashboard-actions {
    display: flex;
    gap: var(--space-4);
}

/* Search and filter controls */
.search-filter-group {
    display: flex;
    gap: var(--space-3);
    flex: 1;
    max-width: 600px;
}

.search-container {
    position: relative;
    flex: 1;
}

.search-input {
    width: 100%;
    padding: var(--space-3) var(--space-10) var(--space-3) var(--space-4);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    font-family: var(--font-primary);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--secondary-bg);
    transition: all 0.2s ease;
}

.search-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(212, 135, 95, 0.1);
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

.search-icon {
    position: absolute;
    right: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

.clear-search {
    position: absolute;
    right: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: var(--space-1);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.clear-search:hover {
    background: var(--tertiary-bg);
    color: var(--text-primary);
}

/* Claude.ai-style dropdown */
.sort-dropdown {
    position: relative;
    display: inline-block;
}

.sort-dropdown-button {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    /* Match the height of adjacent buttons (btn-primary, btn-secondary) */
    padding: var(--space-3) var(--space-4);
    background: var(--secondary-bg);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: var(--text-base);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 150px;
    justify-content: space-between;
}

.sort-dropdown-button:hover {
    background: var(--tertiary-bg);
    border-color: var(--border-medium);
}

.sort-dropdown-button.open {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(212, 135, 95, 0.1);
}

.sort-dropdown-menu {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--secondary-bg);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    box-shadow: var(--shadow-medium);
    z-index: 100;
    display: none;
}

.sort-dropdown-menu.open {
    display: block;
}

.sort-dropdown-menu button {
    display: block;
    width: 100%;
    padding: var(--space-2) var(--space-4);
    border: none;
    background: none;
    text-align: left;
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    cursor: pointer;
    transition: background 0.15s ease;
}

.sort-dropdown-menu button:first-child {
    border-radius: 8px 8px 0 0;
}

.sort-dropdown-menu button:last-child {
    border-radius: 0 0 8px 8px;
}

.sort-dropdown-menu button:hover {
    background: var(--tertiary-bg);
}

.sort-dropdown-menu button.selected {
    background: rgba(212, 135, 95, 0.1);
    color: var(--accent-primary);
    font-weight: 600;
}

/* ============================================
   BUTTON STYLES
   ============================================ */
.btn-primary {
    background: var(--accent-primary);
    color: white;
    padding: var(--space-3) var(--space-6);
    border-radius: 8px;
    border: none;
    font-family: var(--font-primary);
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-subtle);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.btn-primary:hover:not(:disabled) {
    background: var(--accent-secondary);
    box-shadow: var(--shadow-medium);
    transform: translateY(-1px);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-secondary {
    background: var(--secondary-bg);
    color: var(--text-primary);
    padding: var(--space-2) var(--space-4);
    border-radius: 8px;
    border: 1px solid var(--border-medium);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: var(--tertiary-bg);
    border-color: var(--border-dark);
    box-shadow: var(--shadow-subtle);
}

.btn-icon {
    background: var(--secondary-bg);
    color: var(--text-primary);
    padding: var(--space-2) var(--space-3);
    border-radius: 8px;
    border: 1px solid var(--border-medium);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.btn-icon:hover:not(:disabled) {
    background: var(--tertiary-bg);
    border-color: var(--border-dark);
}

.btn-icon:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Version Control Buttons */
.btn-save-version {
    background: var(--success);
    color: white;
    padding: var(--space-2) var(--space-4);
    border-radius: 8px;
    border: none;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.btn-save-version:hover {
    background: #3d7f66;
    transform: translateY(-1px);
}

.btn-versions {
    background: var(--accent-primary);
    color: white;
    padding: var(--space-2) var(--space-4);
    border-radius: 8px;
    border: none;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.btn-versions:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}

/* ============================================
   SONG GRID STYLES
   ============================================ */
.songs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-6);
}

.song-card {
    background: var(--secondary-bg);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: var(--space-4) var(--space-5);
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-subtle);
}

.song-card:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-large);
    transform: translateY(-2px);
}

.song-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: var(--space-2);
}

.song-card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0;
}

/* song-card-id removed from cards — not useful to writers */

.song-card-meta {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

/* ============================================
   SHARED SONG BADGE STYLES
   ============================================ */
.song-card-badges {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.shared-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    background: rgba(74, 155, 127, 0.12);
    color: var(--success);
    padding: var(--space-1) var(--space-2);
    border-radius: 4px;
    font-size: var(--text-xs);
    font-weight: 600;
}

.song-card-owner {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-top: var(--space-1);
}

.collaborator-count {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    background: var(--tertiary-bg);
    color: var(--text-secondary);
    padding: var(--space-1) var(--space-2);
    border-radius: 4px;
    font-size: var(--text-xs);
    font-weight: 500;
}

/* ============================================
   SHARE MODAL STYLES
   ============================================ */
.share-input-group {
    display: flex;
    gap: var(--space-2);
    margin-bottom: var(--space-4);
}

.share-input-group input {
    flex: 1;
}

.collaborators-list {
    border: 1px solid var(--border-light);
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.collaborator-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-light);
}

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

.collaborator-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.collaborator-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--text-sm);
    font-weight: 600;
}

.collaborator-email {
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.collaborator-role {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.btn-remove-collaborator {
    padding: var(--space-1) var(--space-2);
    border-radius: 4px;
    border: 1px solid var(--border-light);
    background: var(--secondary-bg);
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-remove-collaborator:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.share-link-section {
    margin-top: var(--space-6);
    padding-top: var(--space-4);
    border-top: 1px solid var(--border-light);
}

.share-link-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.share-link-input-group {
    display: flex;
    gap: var(--space-2);
}

.share-link-input {
    flex: 1;
    padding: var(--space-3);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-family: 'Menlo', monospace;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    background: var(--tertiary-bg);
}

.empty-collaborators {
    padding: var(--space-6);
    text-align: center;
    color: var(--text-tertiary);
}

.owner-badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    background: rgba(212, 135, 95, 0.12);
    color: var(--accent-primary);
    padding: var(--space-1) var(--space-2);
    border-radius: 4px;
    font-size: var(--text-xs);
    font-weight: 600;
}

.empty-state {
    text-align: center;
    padding: var(--space-12) var(--space-6);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--space-4);
    opacity: 0.3;
}

.empty-state-title {
    font-size: var(--text-2xl);
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.empty-state-text {
    font-size: var(--text-lg);
    color: var(--text-tertiary);
    margin-bottom: var(--space-6);
}

/* ============================================
   MODAL STYLES
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(45, 45, 45, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: var(--space-4);
}

.modal {
    background: var(--secondary-bg);
    border-radius: 16px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-large);
}

.modal-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-light);
}

.modal-title {
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.modal-subtitle {
    font-size: var(--text-base);
    color: var(--text-secondary);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

.form-group {
    margin-bottom: var(--space-6);
}

.form-label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.form-input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-family: var(--font-primary);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--secondary-bg);
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(212, 135, 95, 0.1);
}

.form-textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-family: var(--font-primary);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--secondary-bg);
    transition: all 0.2s ease;
    resize: vertical;
    min-height: 80px;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(212, 135, 95, 0.1);
}

/* ============================================
   TEMPLATE SELECTION STYLES
   ============================================ */
.template-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-3);
}

.template-option {
    background: var(--tertiary-bg);
    border: 2px solid var(--border-light);
    border-radius: 8px;
    padding: var(--space-4);
    cursor: pointer;
    transition: all 0.2s ease;
}

.template-option:hover {
    border-color: var(--accent-primary);
    background: var(--secondary-bg);
}

.template-option.selected {
    border-color: var(--accent-primary);
    background: rgba(212, 135, 95, 0.05);
}

.template-name {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.template-structure {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    font-family: 'Menlo', monospace;
}

/* ============================================
   LOADING STATE
   ============================================ */
.loading-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    font-size: var(--text-lg);
    color: var(--text-secondary);
    flex-direction: column;
    gap: var(--space-4);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-light);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ============================================
   EDITOR STYLES
   ============================================ */
.editor-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

.editor-toolbar {
    background: var(--tertiary-bg);
    border-bottom: 1px solid var(--border-medium);
    padding: var(--space-2) var(--space-4);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-subtle);
}

.toolbar-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.back-button {
    background: var(--secondary-bg);
    border: 1px solid var(--border-medium);
    color: var(--text-primary);
    padding: var(--space-2) var(--space-4);
    border-radius: 8px;
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.back-button:hover {
    background: var(--tertiary-bg);
    box-shadow: var(--shadow-subtle);
}

.song-title-input {
    font-size: var(--text-lg);
    font-weight: 600;
    border: none;
    background: transparent;
    color: var(--text-primary);
    padding: var(--space-1) var(--space-3);
    border-radius: 6px;
    transition: all 0.2s ease;
    min-width: 300px;
}

.song-title-input:hover {
    background: var(--secondary-bg);
}

.song-title-input:focus {
    outline: none;
    background: var(--secondary-bg);
    box-shadow: 0 0 0 2px var(--accent-primary);
}

/* Version Badge */
.version-badge {
    background: rgba(74, 155, 127, 0.12);
    color: var(--success);
    padding: var(--space-1) var(--space-3);
    border-radius: 6px;
    font-size: var(--text-xs);
    font-weight: 600;
    border: 1px solid var(--success);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.version-dot {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.toolbar-right {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

.toolbar-divider {
    width: 1px;
    height: 24px;
    background: var(--border-medium);
}

.btn-share {
    background: var(--accent-primary);
    color: white;
    padding: var(--space-2) var(--space-4);
    border-radius: 8px;
    border: none;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.btn-share:hover {
    background: var(--accent-secondary);
    transform: translateY(-1px);
}

/* Collaborators button - success green theme */
.btn-collaborators {
    background: var(--success);
    color: white;
    padding: var(--space-2) var(--space-4);
    border-radius: 8px;
    border: none;
    font-size: var(--text-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.btn-collaborators:hover {
    background: #3d7f66;
    transform: translateY(-1px);
}

/* Badge showing collaborator count on button */
.collab-count-badge {
    background: white;
    color: var(--success);
    font-size: 0.65rem;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: var(--space-1);
}

.btn-export {
    background: var(--secondary-bg);
    color: var(--text-primary);
    padding: var(--space-2) var(--space-4);
    border-radius: 8px;
    border: 1px solid var(--border-medium);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.btn-export:hover {
    background: var(--tertiary-bg);
    border-color: var(--border-dark);
}

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

.preview-panel {
    width: 35%;
    background: var(--secondary-bg);
    border-right: 1px solid var(--border-light);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.font-controls {
    display: flex;
    gap: var(--space-2);
    align-items: center;
}

.font-control-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 1px solid var(--border-light);
    background: var(--secondary-bg);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.font-control-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.font-size-display {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    font-family: 'Menlo', monospace;
    min-width: 32px;
    text-align: center;
}

.preview-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #e0dbd5;
}

.preview-text {
    font-family: 'Menlo', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.35;
    color: var(--text-primary);
    font-weight: 600;
    white-space: normal;
    width: 100%;
    transition: font-size 0.2s ease;
    background: var(--secondary-bg);
    border: 2px solid var(--accent-primary);
    border-radius: 10px;
    padding: 0;
    box-shadow: var(--shadow-medium);
    display: flex;
    flex-direction: column;
}

.preview-island-header {
    padding: var(--space-2) var(--space-3);
    border-bottom: 1px solid var(--border-light);
    background: var(--tertiary-bg);
    border-radius: 8px 8px 0 0;
}

.preview-island-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-1);
}

.preview-island-title {
    font-family: var(--font-primary);
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.preview-island-subtitle {
    font-family: var(--font-primary);
    font-size: var(--text-xs);
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 0;
}

.preview-island-body {
    padding: var(--space-3);
    flex: 1;
    overflow: visible;
}

.preview-section {
    margin-bottom: var(--space-4);
}

/* Section labels inherit from .preview-text so they
   scale when the user changes preview font size. */
.preview-section-label {
    font-size: 0.85em;
    font-weight: 600;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0;
    margin-top: 0;
}

.preview-line {
    margin-bottom: 0;
    position: relative;
    white-space: pre-wrap;
    word-wrap: break-word;
    cursor: pointer;
    padding: 0 0 0 2px;
    border-radius: 4px;
    transition: background 0.2s ease, padding 0.15s ease;
}

.preview-line:hover {
    background: var(--tertiary-bg);
    padding-left: var(--space-2);
    padding-right: var(--space-2);
}

.preview-line.empty {
    color: var(--text-tertiary);
    font-style: italic;
}

.editor-panel {
    flex: 1;
    background: var(--primary-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.editor-header {
    padding: var(--space-2) var(--space-6);
    background: var(--tertiary-bg);
    border-bottom: 1px solid var(--border-light);
    border-radius: 0 12px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.editor-header-left {
    display: flex;
    flex-direction: column;
}

.editor-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
}

.editor-subtitle {
    font-size: var(--text-xs);
    color: var(--text-secondary);
}

.editor-spreadsheet {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
}

.section-block {
    background: var(--secondary-bg);
    border-radius: 12px;
    /* Minimal vertical padding — rows sit tight against header and bottom */
    padding: 0 var(--space-6) var(--space-1);
    margin-bottom: var(--space-6);
    box-shadow: var(--shadow-subtle);
    border: 1px solid var(--border-light);
    transition: all 0.2s ease;
}

.section-block.dragging {
    opacity: 0.4;
}

.section-block.drag-over {
    border-top: 3px solid var(--accent-primary);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Small top pad so label doesn't touch card edge,
       zero bottom margin so first row is flush */
    padding: var(--space-2) 0 var(--space-1) 0;
    margin-bottom: 0;
    border-bottom: 1px solid var(--border-light);
}

.section-header-left {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.section-drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    cursor: grab;
    padding: var(--space-1);
    user-select: none;
}

.section-drag-handle:active {
    cursor: grabbing;
}

.delete-section-btn {
    padding: var(--space-1) var(--space-2);
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: 6px;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-xs);
}

.delete-section-btn:hover {
    background: var(--error);
    border-color: var(--error);
    color: white;
}

.section-label-input {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--accent-primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    background: transparent;
    padding: var(--space-1) var(--space-2);
    border-radius: 4px;
    transition: all 0.2s ease;
    min-width: 100px;
}

.section-label-input:hover {
    background: rgba(212, 135, 95, 0.05);
}

.section-label-input:focus {
    outline: none;
    background: var(--secondary-bg);
    box-shadow: 0 0 0 2px var(--accent-primary);
}

.lyric-row {
    display: flex;
    gap: 0;
    margin-bottom: 0;
    align-items: stretch;
    padding: 0;
    border-radius: 0;
    transition: all 0.2s ease;
    overflow-x: auto;
    overflow-y: visible;
    border-bottom: 1px solid var(--border-light);
}

.lyric-row::-webkit-scrollbar {
    display: none;
}

.lyric-row {
    scrollbar-width: none;
}

.lyric-row:hover {
    background: var(--tertiary-bg);
}

.lyric-row.dragging {
    opacity: 0.4;
    background: var(--tertiary-bg);
}

.lyric-row.drag-over {
    border-top: 3px solid var(--accent-primary);
    padding-top: calc(var(--space-2) - 3px);
}

.row-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    cursor: grab;
    padding: var(--space-1);
    user-select: none;
    flex-shrink: 0;
    width: 24px;
}

.row-handle:active {
    cursor: grabbing;
}

.variation-textarea {
    width: 180px;
    min-width: 180px;
    flex-shrink: 0;
    min-height: 36px;
    padding: var(--space-2) var(--space-3);
    border: none;
    background: transparent;
    font-family: var(--font-primary);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    transition: all 0.2s ease;
    resize: none;
    overflow: hidden;
    line-height: 1.4;
    cursor: pointer;
}

.variation-textarea:hover {
    background: rgba(212, 135, 95, 0.05);
}

/* Read-only (default): pointer cursor, no text editing */
.variation-textarea:not(.editing) {
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

/* Focus ring when selected but not editing */
.variation-textarea:focus:not(.editing) {
    outline: 2px solid rgba(212, 135, 95, 0.4);
    outline-offset: -2px;
    background: rgba(212, 135, 95, 0.06);
}

/* Editing state: cursor changes, editable look */
.variation-textarea.editing {
    cursor: text;
    user-select: text;
    -webkit-user-select: text;
    background: var(--secondary-bg);
    color: var(--text-primary);
    outline: 2px solid var(--accent);
    outline-offset: -2px;
}

/* Generic focus (for editing state) */
.variation-textarea:focus {
    outline: none;
}
.variation-textarea.editing:focus {
    outline: 2px solid var(--accent);
    outline-offset: -2px;
    background: var(--secondary-bg);
    color: var(--text-primary);
}

/* Another user is editing this cell */
.variation-textarea.occupied {
    cursor: not-allowed;
}

.variation-textarea.active {
    background: rgba(74, 155, 127, 0.12);
    color: var(--text-primary);
    font-weight: 600;
    border-left: 3px solid var(--success);
    padding-left: calc(var(--space-3) - 2px);
}

.row-controls {
    display: flex;
    gap: var(--space-2);
    opacity: 0;
    transition: opacity 0.2s ease;
    padding: 0 var(--space-2);
    flex-shrink: 0;
    align-items: center;
}

.lyric-row:hover .row-controls {
    opacity: 1;
}

.mini-btn {
    padding: var(--space-1);
    background: var(--secondary-bg);
    border: 1px solid var(--border-light);
    border-radius: 4px;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.2s ease;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.mini-btn:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.mini-btn.delete:hover {
    background: var(--error);
    border-color: var(--error);
}


.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #666;
}

.status-dot.connected {
    background: var(--success);
    animation: pulse 2s infinite;
}

/* ============================================
   VERSION CONTROL SIDEBAR
   ============================================ */
.version-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: 350px;
    height: 100%;
    background: var(--secondary-bg);
    border-left: 1px solid var(--border-light);
    box-shadow: var(--shadow-large);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 100;
    display: flex;
    flex-direction: column;
}

.version-sidebar.open {
    transform: translateX(0);
}

.version-sidebar-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-light);
    background: var(--tertiary-bg);
}

.version-sidebar-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.close-sidebar {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    font-size: 1.5rem;
    padding: var(--space-1);
    transition: color 0.2s ease;
}

.close-sidebar:hover {
    color: var(--text-primary);
}

.version-sidebar-subtitle {
    font-size: var(--text-sm);
    color: var(--text-secondary);
}

.version-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
}

.version-list-empty {
    text-align: center;
    padding: var(--space-8);
    color: var(--text-tertiary);
}

.version-list-empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-4);
    opacity: 0.3;
}

.version-item {
    background: var(--tertiary-bg);
    border: 1px solid var(--border-light);
    border-radius: 8px;
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    cursor: pointer;
    transition: all 0.2s ease;
}

.version-item:hover {
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-medium);
}

.version-item.active {
    border-color: var(--success);
    background: rgba(74, 155, 127, 0.05);
}

.version-item-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: var(--space-2);
}

.version-name {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.version-badge-small {
    background: var(--success);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
}

.version-meta {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    display: flex;
    gap: var(--space-2);
}

.version-notes {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-style: italic;
    margin-top: var(--space-2);
    padding: var(--space-2);
    background: rgba(212, 135, 95, 0.05);
    border-radius: 4px;
}

.version-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-light);
}

.btn-small {
    padding: var(--space-1) var(--space-3);
    border-radius: 6px;
    border: 1px solid var(--border-medium);
    background: var(--secondary-bg);
    color: var(--text-secondary);
    font-size: var(--text-xs);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-small:hover {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
    color: white;
}

.btn-small.danger:hover {
    background: var(--error);
    border-color: var(--error);
}

/* ============================================
   VERSION TOAST
   ============================================ */
.version-toast {
    position: fixed;
    bottom: var(--space-8);
    right: var(--space-8);
    background: var(--success);
    color: white;
    padding: var(--space-4) var(--space-6);
    border-radius: 8px;
    box-shadow: var(--shadow-large);
    display: none;
    align-items: center;
    gap: var(--space-3);
    z-index: 2000;
    font-size: var(--text-sm);
    font-weight: 500;
}

.version-toast.show {
    display: flex;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ============================================
   MOBILE EDITOR STYLES
   v2.9.0 - Complete mobile UI
   ============================================ */

/* ============================================
   MOBILE LOADING STATE
   ============================================ */
.mobile-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: var(--primary-bg);
    color: var(--text-secondary);
    padding: var(--space-6);
    text-align: center;
}

.mobile-btn-primary {
    background: var(--accent-primary);
    color: white;
    padding: var(--space-3) var(--space-6);
    border-radius: 8px;
    border: none;
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
}

/* ============================================
   MOBILE EDITOR CONTAINER
   ============================================ */
.mobile-editor-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    background: var(--primary-bg);
    position: relative;
    /* Lock to viewport — no horizontal or vertical overflow */
    overflow: hidden;
    width: 100%;
    max-width: 100vw;
}

/* ============================================
   MOBILE HEADER
   ============================================ */
.mobile-header {
    display: flex;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: var(--secondary-bg);
    border-bottom: 1px solid var(--border-light);
    gap: var(--space-3);
    flex-shrink: 0;
    min-height: 56px;
}

.mobile-back-btn {
    background: none;
    border: none;
    padding: var(--space-2);
    color: var(--accent-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}

.mobile-back-btn:active {
    background: var(--tertiary-bg);
}

.mobile-song-title {
    flex: 1;
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.mobile-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    transition: background 0.3s;
}

.mobile-status-dot.connected {
    background: var(--success);
    animation: mobilePulse 2s infinite;
}

@keyframes mobilePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.mobile-menu-btn {
    background: none;
    border: none;
    padding: var(--space-2);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.mobile-menu-btn:active {
    background: var(--tertiary-bg);
}

/* Mobile undo/redo buttons — v2.15.21 */
.mobile-undo-btn,
.mobile-redo-btn {
    background: none;
    border: none;
    padding: 6px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: opacity 0.15s;
}
.mobile-undo-btn:active,
.mobile-redo-btn:active {
    background: var(--tertiary-bg);
}
.mobile-undo-btn.disabled,
.mobile-redo-btn.disabled {
    opacity: 0.25;
    pointer-events: none;
}

/* ============================================
   MOBILE MENU OVERLAY & SETTINGS
   ============================================ */
.mobile-menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 100;
}

.mobile-menu-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.mobile-settings-menu {
    position: fixed;
    top: 0;
    right: 0;
    width: 85%;
    max-width: 320px;
    height: 100%;
    background: var(--secondary-bg);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 101;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.mobile-settings-menu.visible {
    transform: translateX(0);
}

.mobile-menu-header {
    padding: var(--space-6) var(--space-5);
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border-light);
}

.mobile-menu-section {
    padding: var(--space-4) var(--space-5);
}

.mobile-menu-section-title {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: var(--space-3);
}

.mobile-menu-divider {
    height: 1px;
    background: var(--border-light);
    margin: 0 var(--space-5);
}

/* ============================================
   MOBILE MODE OPTIONS (Radio Buttons)
   ============================================ */
.mobile-mode-option {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: 10px;
    margin-bottom: var(--space-2);
    cursor: pointer;
    transition: background 0.2s;
    border: 2px solid transparent;
}

.mobile-mode-option:active {
    background: var(--tertiary-bg);
}

.mobile-mode-option.selected {
    background: rgba(212, 135, 95, 0.08);
    border-color: var(--accent-primary);
}

.mobile-mode-radio {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border-medium);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.mobile-mode-option.selected .mobile-mode-radio {
    border-color: var(--accent-primary);
}

.mobile-mode-radio-inner {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: transparent;
    transition: background 0.2s;
}

.mobile-mode-option.selected .mobile-mode-radio-inner {
    background: var(--accent-primary);
}

.mobile-mode-content {
    flex: 1;
}

.mobile-mode-name {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.mobile-mode-desc {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.4;
}

/* ============================================
   MOBILE MENU ITEMS
   ============================================ */
.mobile-menu-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    cursor: pointer;
    transition: background 0.2s;
}

.mobile-menu-item:active {
    background: var(--tertiary-bg);
}

.mobile-menu-item-icon {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.mobile-menu-item-text {
    flex: 1;
    font-size: var(--text-base);
    color: var(--text-primary);
}

.mobile-menu-item-badge {
    background: var(--accent-primary);
    color: white;
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

/* ============================================
   MOBILE MAIN CONTENT
   ============================================ */
.mobile-main-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* ============================================
   MOBILE TAB MODE
   ============================================ */
.mobile-tabs-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.mobile-tab-content {
    flex: 1;
    overflow: hidden;
}

.mobile-tab-bar {
    display: flex;
    background: var(--secondary-bg);
    border-top: 1px solid var(--border-light);
    padding: var(--space-2) var(--space-4);
    gap: var(--space-2);
    flex-shrink: 0;
}

.mobile-tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-2) var(--space-3);
    background: none;
    border: none;
    border-radius: 10px;
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-tab-btn.active {
    background: rgba(212, 135, 95, 0.12);
    color: var(--accent-primary);
}

.mobile-tab-btn:active {
    background: var(--tertiary-bg);
}

/* ============================================
   MOBILE PREVIEW PANEL
   ============================================ */
.mobile-preview-panel,
.mobile-contextual-preview {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-preview-area {
    padding: var(--space-4);
    min-height: 100%;
    background: #e0dbd5;
}

.mobile-preview-container {
    background: var(--secondary-bg);
    border: 2px solid var(--accent-primary);
    border-radius: 12px;
    overflow: hidden;
}

.mobile-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-3) var(--space-4);
    background: var(--tertiary-bg);
    border-bottom: 1px solid var(--border-light);
}

.mobile-preview-title {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--text-primary);
}

.mobile-preview-badge {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    background: var(--primary-bg);
    padding: 2px 8px;
    border-radius: 4px;
}

.mobile-preview-hint {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    text-align: center;
    padding: var(--space-2);
    background: rgba(212, 135, 95, 0.05);
    border-bottom: 1px solid var(--border-light);
}

.mobile-preview-body {
    padding: var(--space-4);
}

.mobile-preview-section {
    margin-bottom: var(--space-2);
}

.mobile-preview-section:last-child {
    margin-bottom: 0;
}

.mobile-section-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 2px;
}

.mobile-lyric-line {
    font-family: 'Menlo', monospace;
    font-size: 13px;
    line-height: 1.15;
    color: var(--text-primary);
    padding: 1px 0;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-2);
}

.mobile-lyric-line.empty {
    color: var(--text-tertiary);
    font-style: italic;
}

.mobile-lyric-line.tappable {
    padding: 3px var(--space-2);
    margin: 0 calc(-1 * var(--space-2));
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.mobile-lyric-line.tappable:active {
    background: rgba(212, 135, 95, 0.15);
}

.mobile-var-count {
    font-size: var(--text-xs);
    color: var(--accent-primary);
    background: rgba(212, 135, 95, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
}

/* ============================================
   MOBILE EDITOR PANEL (Tab Mode)
   ============================================ */
.mobile-editor-panel {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-editor-wrapper {
    padding: var(--space-4);
}

.mobile-section-card {
    background: var(--secondary-bg);
    border-radius: 12px;
    margin-bottom: var(--space-4);
    overflow: hidden;
    border: 1px solid var(--border-light);
}

.mobile-section-header {
    padding: var(--space-3) var(--space-4);
    background: var(--tertiary-bg);
    border-bottom: 1px solid var(--border-light);
}

.mobile-section-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--accent-primary);
    text-transform: uppercase;
}

.mobile-lyric-row {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--border-light);
}

.mobile-lyric-row:last-child {
    border-bottom: none;
}

.mobile-row-label {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-bottom: var(--space-2);
}

.mobile-variation-scroll {
    display: flex;
    gap: var(--space-2);
    overflow-x: auto;
    padding-bottom: var(--space-2);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    /* Snap scroll: cards align to the left edge
       of the scroll container when swiping */
    scroll-snap-type: x mandatory;
    /* Small inset so the first card isn't flush
       against the container edge after snapping */
    scroll-padding-left: 0;
}

.mobile-variation-scroll::-webkit-scrollbar {
    display: none;
}

.mobile-variation-card {
    flex-shrink: 0;
    width: 200px;
    background: var(--tertiary-bg);
    border: 2px solid var(--border-light);
    border-radius: 8px;
    transition: all 0.2s;
}

.mobile-variation-card.active {
    background: rgba(74, 155, 127, 0.1);
    border-color: var(--success);
}

.mobile-variation-input {
    width: 100%;
    padding: var(--space-3);
    border: none;
    background: transparent;
    font-size: var(--text-sm);
    color: var(--text-primary);
}

.mobile-variation-input:focus {
    outline: none;
}

.mobile-variation-input::placeholder {
    color: var(--text-tertiary);
}

.mobile-add-card {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    background: var(--tertiary-bg);
    border: 2px dashed var(--border-medium);
    border-radius: 8px;
    color: var(--text-tertiary);
    font-size: var(--text-xl);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.mobile-add-card:active {
    background: rgba(212, 135, 95, 0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* ============================================
   MOBILE CONTEXTUAL MODE
   ============================================ */
.mobile-contextual-container {
    height: 100%;
    position: relative;
}

.mobile-contextual-preview {
    padding: var(--space-4);
    background: #e0dbd5;
}

/* ============================================
   MOBILE BOTTOM SHEET
   ============================================ */
.mobile-sheet-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 200;
}

.mobile-sheet-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.mobile-bottom-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--secondary-bg);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 201;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    /* CRITICAL: Prevent swipe-down on the sheet from
       triggering the browser's pull-to-refresh gesture.
       This contains the overscroll within the sheet. */
    overscroll-behavior: contain;
}

.mobile-bottom-sheet.open {
    transform: translateY(0);
}

.mobile-sheet-handle {
    display: flex;
    justify-content: center;
    padding: var(--space-3);
}

.mobile-sheet-handle-bar {
    width: 36px;
    height: 4px;
    background: var(--border-medium);
    border-radius: 2px;
}

.mobile-sheet-header {
    padding: 0 var(--space-5) var(--space-3);
    border-bottom: 1px solid var(--border-light);
    /* The header acts as part of the drag zone —
       prevent browser taking over the swipe gesture */
    touch-action: none;
}

.mobile-sheet-context {
    font-size: var(--text-xs);
    color: var(--accent-primary);
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: var(--space-1);
}

.mobile-sheet-title {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text-primary);
}

.mobile-sheet-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4) var(--space-5);
    -webkit-overflow-scrolling: touch;
    /* Contain scroll so pull-to-refresh doesn't fire
       when the user scrolls to the top of the sheet body */
    overscroll-behavior: contain;
}

.mobile-variation-option {
    background: var(--tertiary-bg);
    border: 2px solid var(--border-light);
    border-radius: 10px;
    padding: var(--space-3);
    margin-bottom: var(--space-3);
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-variation-option.active {
    background: rgba(74, 155, 127, 0.1);
    border-color: var(--success);
}

.mobile-variation-option:active {
    background: var(--primary-bg);
}

.mobile-var-label {
    display: block;
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    margin-bottom: var(--space-2);
}

.mobile-sheet-input {
    width: 100%;
    padding: var(--space-2);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--secondary-bg);
}

.mobile-sheet-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.mobile-add-variation-btn {
    width: 100%;
    padding: var(--space-3);
    background: none;
    border: 2px dashed var(--border-medium);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: var(--text-sm);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-add-variation-btn:active {
    background: rgba(212, 135, 95, 0.1);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.mobile-sheet-footer {
    display: flex;
    gap: var(--space-3);
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--border-light);
}

.mobile-sheet-btn {
    flex: 1;
    padding: var(--space-3);
    border-radius: 10px;
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-sheet-btn.cancel {
    background: var(--tertiary-bg);
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
}

.mobile-sheet-btn.confirm {
    background: var(--accent-primary);
    border: none;
    color: white;
}

.mobile-sheet-btn:active {
    opacity: 0.8;
}

/* ============================================
   MOBILE VERSION HISTORY PANEL
   ============================================ */
.mobile-versions-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 300;
}

.mobile-versions-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.mobile-versions-panel {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--secondary-bg);
    border-radius: 20px 20px 0 0;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 301;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.mobile-versions-panel.open {
    transform: translateY(0);
}

.mobile-versions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-5);
    border-bottom: 1px solid var(--border-light);
}

.mobile-versions-title {
    font-size: var(--text-xl);
    font-weight: 700;
    color: var(--text-primary);
}

.mobile-versions-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: var(--space-1);
}

.mobile-versions-subtitle {
    padding: var(--space-2) var(--space-5);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    background: var(--tertiary-bg);
}

.mobile-versions-list {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-4);
    -webkit-overflow-scrolling: touch;
}

.mobile-versions-empty {
    text-align: center;
    padding: var(--space-8);
    color: var(--text-tertiary);
}

.mobile-versions-empty-icon {
    font-size: 3rem;
    margin-bottom: var(--space-3);
    opacity: 0.4;
}

.mobile-versions-empty-hint {
    font-size: var(--text-sm);
    margin-top: var(--space-2);
}

.mobile-version-item {
    background: var(--tertiary-bg);
    border: 1px solid var(--border-light);
    border-radius: 10px;
    padding: var(--space-4);
    margin-bottom: var(--space-3);
    cursor: pointer;
    transition: all 0.2s;
}

.mobile-version-item:active {
    background: var(--primary-bg);
    border-color: var(--accent-primary);
}

.mobile-version-name {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.mobile-version-meta {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
}

.mobile-version-notes {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    font-style: italic;
    margin-top: var(--space-2);
    padding: var(--space-2);
    background: rgba(212, 135, 95, 0.05);
    border-radius: 4px;
}

/* ============================================
   MOBILE TOAST
   ============================================ */
/* ============================================
   MOBILE COLLABORATORS PANEL — v2.15.20
   Reuses .mobile-versions-panel for the slide-up
   shell; these styles handle the inner content.
   ============================================ */

/* Share link row: readonly URL + copy button */
.mobile-collab-share-row {
    display: flex;
    gap: 8px;
    padding: 0 16px;
    margin-bottom: 4px;
}
.mobile-collab-share-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    background: var(--tertiary-bg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mobile-collab-copy-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: var(--accent-primary);
    color: white;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}
.mobile-collab-share-note {
    padding: 0 16px;
    font-size: 11px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
}

/* Add collaborator row: email input + add button */
.mobile-collab-add-row {
    display: flex;
    gap: 8px;
    padding: 0 16px;
    margin-bottom: 4px;
}
.mobile-collab-add-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border-light);
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--secondary-bg);
}
.mobile-collab-add-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}
.mobile-collab-add-btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    background: var(--accent-primary);
    color: white;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}
.mobile-collab-error {
    padding: 4px 16px;
    font-size: 12px;
    color: var(--error);
}

/* People list header */
.mobile-collab-list-label {
    padding: 12px 16px 8px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Person row */
.mobile-collab-list {
    padding: 0 16px 16px;
}
.mobile-collab-person {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-light);
}
.mobile-collab-person:last-child {
    border-bottom: none;
}

/* Avatar circle */
.mobile-collab-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--tertiary-bg);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}
.mobile-collab-avatar.owner-avatar {
    background: var(--accent-primary);
    color: white;
}

/* Info block */
.mobile-collab-info {
    flex: 1;
    min-width: 0;
}
.mobile-collab-email {
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.mobile-collab-role {
    font-size: 12px;
    color: var(--text-tertiary);
    display: flex;
    align-items: center;
    gap: 6px;
}
.mobile-collab-owner-badge {
    background: rgba(212, 135, 95, 0.15);
    color: var(--accent-primary);
    padding: 1px 6px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 11px;
}
.mobile-collab-name {
    color: var(--text-secondary);
}

/* Remove button — only visible for owner */
.mobile-collab-remove {
    background: none;
    border: none;
    color: var(--text-tertiary);
    padding: 8px;
    border-radius: 6px;
    flex-shrink: 0;
}
.mobile-collab-remove:active {
    background: rgba(212, 125, 125, 0.1);
    color: var(--error);
}

/* Empty state */
.mobile-collab-empty {
    padding: 16px 0;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 14px;
}

.mobile-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--success);
    color: white;
    padding: var(--space-3) var(--space-5);
    border-radius: 25px;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 500;
    box-shadow: var(--shadow-large);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 400;
}

.mobile-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ============================================
   MOBILE TOGGLE SWITCH - v2.9.1
   For Show Variation Counts setting
   ============================================ */
.mobile-toggle-option {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.mobile-toggle-option:active {
    background: var(--tertiary-bg);
}

.mobile-toggle-content {
    flex: 1;
}

.mobile-toggle-name {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-1);
}

.mobile-toggle-desc {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    line-height: 1.4;
}

.mobile-toggle-switch {
    width: 50px;
    height: 30px;
    background: var(--border-medium);
    border-radius: 15px;
    padding: 3px;
    transition: background 0.3s ease;
    flex-shrink: 0;
}

.mobile-toggle-switch.on {
    background: var(--success);
}

.mobile-toggle-knob {
    width: 24px;
    height: 24px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: transform 0.3s ease;
}

.mobile-toggle-switch.on .mobile-toggle-knob {
    transform: translateX(20px);
}

/* ============================================
   ACTIVE BADGE IN BOTTOM SHEET
   ============================================ */

.mobile-active-badge {
    display: inline-block;
    background: var(--success);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: var(--space-2);
    text-transform: uppercase;
}

/* ============================================
   FIX: TEXTAREA STYLES FOR TEXT WRAPPING
   ============================================ */
.mobile-variation-input {
    width: 100%;
    padding: var(--space-3);
    border: none;
    background: transparent;
    font-size: var(--text-sm);
    color: var(--text-primary);
    resize: none;
    min-height: 60px;
    line-height: 1.4;
    font-family: var(--font-primary);
}

.mobile-variation-input:focus {
    outline: none;
}

.mobile-variation-input::placeholder {
    color: var(--text-tertiary);
}

/* Bottom sheet textarea */
.mobile-sheet-input {
    width: 100%;
    padding: var(--space-2);
    border: 1px solid var(--border-light);
    border-radius: 6px;
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--secondary-bg);
    resize: none;
    min-height: 60px;
    line-height: 1.4;
    font-family: var(--font-primary);
}

.mobile-sheet-input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

/* ============================================
   FIX: BETTER TAB BUTTON TOUCH TARGETS
   ============================================ */
.mobile-tab-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-3) var(--space-3);
    background: none;
    border: none;
    border-radius: 10px;
    color: var(--text-tertiary);
    font-size: var(--text-xs);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    /* Better touch handling */
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    min-height: 60px;
}

.mobile-tab-btn.active {
    background: rgba(212, 135, 95, 0.12);
    color: var(--accent-primary);
}

.mobile-tab-btn:active {
    background: var(--tertiary-bg);
    transform: scale(0.98);
}

/* ============================================
   FIX: BOTTOM SHEET HANDLE TOUCH AREA
   Larger touch target for pull-down gesture
   ============================================ */
.mobile-sheet-handle {
    display: flex;
    justify-content: center;
    padding: var(--space-4) var(--space-4) var(--space-2);
    cursor: grab;
    /* Prevent browser scroll when dragging */
    touch-action: none;
}

.mobile-sheet-handle:active {
    cursor: grabbing;
}

.mobile-sheet-handle-bar {
    width: 40px;
    height: 5px;
    background: var(--border-medium);
    border-radius: 3px;
}

/* ============================================
   FIX: SHEET BUTTON TOUCH IMPROVEMENTS
   ============================================ */
.mobile-sheet-btn {
    flex: 1;
    padding: var(--space-4);
    border-radius: 10px;
    font-size: var(--text-base);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
}

.mobile-sheet-btn.cancel {
    background: var(--tertiary-bg);
    border: 1px solid var(--border-medium);
    color: var(--text-secondary);
}

.mobile-sheet-btn.confirm {
    background: var(--accent-primary);
    border: none;
    color: white;
}

.mobile-sheet-btn:active {
    opacity: 0.7;
    transform: scale(0.98);
}

/* ============================================
   FIX: VARIATION CARD WIDTH FOR LONGER TEXT
   + SNAP SCROLL ALIGNMENT (v2.11.0)
   ============================================ */
.mobile-variation-card {
    flex-shrink: 0;
    width: 220px;
    min-width: 220px;
    background: var(--tertiary-bg);
    border: 2px solid var(--border-light);
    border-radius: 8px;
    transition: all 0.2s;
    /* Each card snaps to the start (left edge)
       of the scroll container when swiping */
    scroll-snap-align: start;
}

.mobile-variation-card.active {
    background: rgba(74, 155, 127, 0.1);
    border-color: var(--success);
}

/* The + button at the end should also snap */
.mobile-add-card {
    scroll-snap-align: start;
}

/* ============================================
   v2.14.0 — PHASE 2 STYLES
   Preview panel section management + Duplicate
   ============================================ */

/* Preview section — draggable + hover controls */
.preview-section {
    position: relative;
    border-radius: 4px;
    transition: all 0.2s ease;
    margin-bottom: var(--space-3);
}

.preview-section:hover {
    background: rgba(212, 135, 95, 0.04);
}

.preview-section:hover .preview-section-controls {
    opacity: 1;
    pointer-events: auto;
}

.preview-section.dragging {
    opacity: 0.4;
}

.preview-section.drag-over {
    border-top: 3px solid var(--accent-primary);
    padding-top: 4px;
}

/* Section label row: flush left to align with lyric lines below */
.preview-section-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1px;
    margin-top: var(--space-3);
    padding: 0;
}

.preview-section:first-child .preview-section-label-row {
    margin-top: 0;
}

/* Draggable label with grab cursor */
.preview-section-label {
    cursor: grab;
    user-select: none;
}

.preview-section-label:active {
    cursor: grabbing;
}

/* Drag handle grip dots */
.preview-drag-icon {
    display: flex;
    flex-direction: column;
    gap: 2px;
    opacity: 0.4;
    transition: opacity 0.15s;
}

.preview-section:hover .preview-drag-icon {
    opacity: 0.8;
}

.preview-drag-icon span {
    display: flex;
    gap: 2px;
}

.preview-drag-icon span::before,
.preview-drag-icon span::after {
    content: '';
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: var(--accent-primary);
}

/* Hover-to-reveal action buttons */
.preview-section-controls {
    display: flex;
    gap: 2px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
}

.preview-section-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.preview-section-btn:hover {
    background: rgba(212, 135, 95, 0.12);
    color: var(--accent-primary);
}

.preview-section-btn.danger:hover {
    background: rgba(212, 125, 125, 0.12);
    color: var(--error);
}

/* Duplicate section button in editor header */
.btn-duplicate-section {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: var(--space-1) var(--space-2);
    border: 1px solid var(--border-light);
    background: transparent;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 6px;
    font-size: var(--text-xs);
}

.btn-duplicate-section:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    background: rgba(212, 135, 95, 0.08);
}

/* ============================================
   v2.14.0 — Icon-only section action buttons
   Replaces the old text-label buttons with
   subtle icon buttons, hidden until hover.
   ============================================ */

/* Container for duplicate + delete icons, pushed right */
.section-header-actions {
    display: flex;
    gap: 2px;
    margin-left: auto;
    opacity: 0;
    transition: opacity 0.15s ease;
}

/* Show on section hover */
.section-header:hover .section-header-actions {
    opacity: 1;
}

/* Individual icon button */
.section-action-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.section-action-btn:hover {
    background: rgba(212, 135, 95, 0.1);
    color: var(--accent-primary);
}

.section-action-btn.danger:hover {
    background: rgba(212, 125, 125, 0.1);
    color: var(--error);
}

/* ============================================
   v2.14.0 — CLICHÉ DETECTION STYLES
   ============================================ */

/* Toolbar button — warm gold accent */
.btn-cliche {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: var(--space-1) var(--space-3);
    border: 1.5px solid #e8b84b;
    background: linear-gradient(135deg, #fef9e7, #fdf2d5);
    color: #8a6d2b;
    font-size: var(--text-sm);
    font-weight: 600;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-cliche:hover {
    background: linear-gradient(135deg, #fdf2d5, #fce9b8);
    border-color: #d4a532;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(234, 184, 75, 0.25);
}

/* Modal */
.cliche-modal { max-width: 560px; }

.cliche-result {
    padding: var(--space-3);
    border-radius: 8px;
    margin-bottom: var(--space-3);
    border: 1px solid var(--border-light);
    background: var(--tertiary-bg);
}

.cliche-result-header {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    margin-bottom: var(--space-2);
}

.cliche-severity {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 8px;
    border-radius: 10px;
}

.cliche-severity-high {
    background: rgba(212, 125, 125, 0.15);
    color: var(--error);
}

.cliche-severity-medium {
    background: rgba(232, 167, 93, 0.15);
    color: #c17b1e;
}

.cliche-severity-low {
    background: rgba(74, 155, 127, 0.15);
    color: var(--success);
}

.cliche-section {
    font-size: var(--text-xs);
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.cliche-line {
    font-size: var(--text-sm);
    color: var(--text-primary);
    cursor: pointer;
    padding: var(--space-1) 0;
    transition: color 0.15s;
}

.cliche-line:hover { color: var(--accent-primary); }

.cliche-matched {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-top: var(--space-1);
}

.cliche-matched strong { color: var(--error); }

.cliche-suggestion {
    font-size: var(--text-xs);
    color: var(--text-secondary);
    margin-top: var(--space-2);
    padding-top: var(--space-2);
    border-top: 1px solid var(--border-light);
    line-height: 1.4;
}

/* ============================================
   v2.14.2 — INLINE CLICHÉ HIGHLIGHTS
   Replaces the modal with preview-panel highlights.
   ============================================ */

/* Wrapper for each preview line + possible feedback */
.preview-line-wrapper {
    position: relative;
}

/* Highlighted lines — colored left border + subtle background.
   Uses flex layout so lightbulb sits at end of first line. */
.preview-line.cliche-flagged {
    border-left: 3px solid transparent;
    padding-left: 6px;
    border-radius: 3px;
    position: relative;
    z-index: 2;
    display: flex;
    align-items: first baseline;
    gap: 6px;
}

.preview-line.cliche-high {
    border-left-color: var(--error);
    background: rgba(212, 125, 125, 0.08);
}

.preview-line.cliche-medium {
    border-left-color: #e0a84b;
    background: rgba(232, 167, 93, 0.08);
}

.preview-line.cliche-low {
    border-left-color: var(--success);
    background: rgba(74, 155, 127, 0.06);
}

/* The lightbulb indicator — flex child pushed to end of line.
   Uses em so it scales with preview font size.
   margin-left:auto pushes it right without absolute positioning,
   so hover padding changes don't affect it. */
.cliche-indicator {
    cursor: pointer;
    font-size: 1em;
    flex-shrink: 0;
    margin-left: auto;
    opacity: 0.7;
    transition: opacity 0.15s;
    z-index: 3;
    line-height: 1;
}

.cliche-indicator:hover {
    opacity: 1;
}

/* Active state button */
.btn-cliche.active {
    background: linear-gradient(135deg, #e8b84b, #d4a532);
    color: white;
    border-color: #c99a2e;
}

.btn-cliche.active:hover {
    background: linear-gradient(135deg, #d4a532, #c08f28);
}

/* Count badge on button */
.cliche-badge {
    background: rgba(255,255,255,0.9);
    color: #8a6d2b;
    font-size: 10px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    margin-left: 4px;
}

.btn-cliche.active .cliche-badge {
    background: rgba(255,255,255,0.3);
    color: white;
}

/* Inline feedback panel — appears below the flagged line */
.cliche-inline-feedback {
    padding: 8px 8px 8px 12px;
    margin: 2px 0 6px 0;
    background: var(--tertiary-bg);
    border-radius: 6px;
    border: 1px solid var(--border-light);
    font-size: 11px;
}

.cliche-inline-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 4px 0;
}

.cliche-inline-item + .cliche-inline-item {
    border-top: 1px solid var(--border-light);
    margin-top: 4px;
    padding-top: 8px;
}

/* Severity dot */
.cliche-severity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-top: 3px;
}

.cliche-dot-high { background: var(--error); }
.cliche-dot-medium { background: #e0a84b; }
.cliche-dot-low { background: var(--success); }

.cliche-inline-matched {
    display: block;
    font-style: italic;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.cliche-inline-suggestion {
    display: block;
    color: var(--text-primary);
    line-height: 1.4;
}

/* ============================================
   v2.14.4 — Toolbar uniformity fixes
   All toolbar buttons: single-line, compact
   ============================================ */

/* Force all toolbar buttons to single-line */
.editor-toolbar button {
    white-space: nowrap;
}

/* Consistent compact height for labeled buttons */
.btn-save, .btn-versions, .btn-share, .btn-collaborators, .btn-export, .btn-cliche {
    padding: var(--space-1) var(--space-2) !important;
    font-size: var(--text-xs) !important;
    height: 32px;
    display: inline-flex !important;
    align-items: center;
}

/* Working Draft badge compact */
.btn-draft {
    white-space: nowrap;
    height: 32px;
    padding: var(--space-1) var(--space-2) !important;
    font-size: var(--text-xs) !important;
}

/* ============================================
   v2.14.5 — Review indicator fixes
   Flat icon, no scale jump, bigger click target
   ============================================ */

/* Override: remove scale transform, bigger click area */
.cliche-indicator {
    width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: inherit;
    transition: opacity 0.15s, background 0.15s;
    transform: none !important;
}

.cliche-indicator:hover {
    transform: none !important;
    opacity: 1;
    background: rgba(0, 0, 0, 0.06);
}

.cliche-indicator svg {
    flex-shrink: 0;
}

/* Re-scan button — small icon button next to Review */
.btn-rescan {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--border-light);
    background: var(--secondary-bg);
    border-radius: 50%;
    cursor: pointer;
    padding: 0;
    margin-left: -4px;
    color: var(--text-secondary);
    transition: all 0.15s ease;
}

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

.btn-rescan:disabled {
    opacity: 0.4;
    cursor: default;
}

/* ============================================
   v2.14.6 — Preview line hover fix + flat lightbulb
   Remove padding shift on hover (caused icon jump)
   ============================================ */

/* Preview line hover: subtle indent cue restored.
   Original padding-left on hover from base styles applies. */

/* ============================================
   v2.14.12 — Vertical cell borders + top accent bar
   Matching prototype styling
   ============================================ */

/* Vertical cell separators removed per v2.15.1 — 
   matching the Jan 28 production style.
   Cells separated by row background/gap only. */

/* Top accent bar — warm separation from browser chrome */
.top-accent-bar {
    height: 4px;
    background: linear-gradient(135deg, var(--accent-primary), #d4a532);
    flex-shrink: 0;
}

/* ============================================
   v2.14.12 — Top accent bar + cell borders
   ============================================ */

/* Top accent bar — warm dark strip for visual separation */
.app-accent-bar {
    background: linear-gradient(135deg, #2d2926, #4a3f3a);
    color: rgba(255, 255, 255, 0.85);
    padding: 8px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 11px;
    z-index: 100;
    letter-spacing: 0.3px;
}

.app-accent-bar .accent-version {
    background: var(--accent-primary);
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 12px;
    letter-spacing: 0.5px;
}

/* Build version label next to comps. logo */
.app-accent-bar .accent-build {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.3px;
}

.app-accent-bar .accent-info {
    display: flex;
    gap: 8px;
    align-items: center;
}

.app-accent-bar .accent-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #7ecf8a;
    display: inline-block;
    margin-right: 4px;
}

/* ============================================
   v2.15.0 — Accent bar improvements
   Version badge moved to accent bar,
   green connected dot, cleaner toolbar
   ============================================ */

/* Version badge in accent bar — lighter styling for dark background */
.accent-version-badge {
    background: rgba(255, 255, 255, 0.12) !important;
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    color: rgba(255, 255, 255, 0.9) !important;
    padding: 2px 10px !important;
    font-size: 11px !important;
    border-radius: 20px !important;
    display: inline-flex !important;
    align-items: center !important;
    gap: 6px !important;
}

.accent-version-badge .version-dot {
    width: 6px !important;
    height: 6px !important;
    border-radius: 50% !important;
    background: #4a9b7f !important;
}

/* Connection indicator */
.accent-connection {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    opacity: 0.6;
    color: rgba(255, 255, 255, 0.8);
}

.accent-connection.connected {
    opacity: 0.9;
}

.connection-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    display: inline-block;
}

.accent-connection.connected .connection-dot {
    background: #4ade80;
    box-shadow: 0 0 4px rgba(74, 222, 128, 0.5);
}

/* v2.15.1 — Accent bar right-side grouping */
.accent-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ============================================
   v2.15.1 — Row overflow indicators
   Subtle gradient fade when more variations
   exist beyond the visible edge
   ============================================ */

/* Wrapper for overflow fade indicators.
   The wrapper is position:relative so the fade overlays
   sit on top of the scrollable lyric-row inside it. */
.lyric-row-wrapper {
    position: relative;
}

/* Overflow scroll arrows — real clickable buttons positioned
   outside the row so they don't overlap cell content.
   Hidden by default, shown when wrapper has overflow class. */
.overflow-arrow {
    display: none;
    position: absolute;
    top: 0;
    bottom: 0;
    width: 22px;
    border: none;
    background: none;
    color: var(--text-muted);
    font-size: 18px;
    font-family: system-ui, sans-serif;
    cursor: pointer;
    z-index: 3;
    padding: 0;
    align-items: center;
    justify-content: center;
    transition: color 0.15s;
}
.overflow-arrow:hover {
    color: var(--accent-primary);
}

/* Right arrow: sits just outside the row area */
.overflow-arrow-right {
    right: -24px;
    border-radius: 0 6px 6px 0;
}

/* Left arrow: sits at the left edge */
.overflow-arrow-left {
    left: -24px;
    border-radius: 6px 0 0 6px;
}

/* Show arrows only when overflow is detected */
.lyric-row-wrapper.has-overflow-right .overflow-arrow-right {
    display: flex;
}
.lyric-row-wrapper.has-overflow-left .overflow-arrow-left {
    display: flex;
}

/* White fade gradient on the row edge to hint at more content */
.lyric-row-wrapper.has-overflow-right::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(to left,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
    z-index: 2;
}

.lyric-row-wrapper.has-overflow-left::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 16px;
    background: linear-gradient(to right,
        rgba(255, 255, 255, 0.9) 0%,
        rgba(255, 255, 255, 0) 100%);
    pointer-events: none;
    z-index: 2;
}

/* ============================================
   v2.15.6 — UI polish
   ============================================ */

/* Last row in a section: no bottom border, no gap.
   Lets the section end flush with the section block. */
.lyric-row-wrapper:last-child .lyric-row {
    border-bottom: none;
}

/* Close the ~2-4px gap at the bottom of section blocks */
.section-block {
    padding-bottom: 0 !important;
}

/* ---- OVERFLOW: WHITE FADE + CLICKABLE ARROWS ---- */
