/* ============================================
   COMPOXER — AI Music Composition Interface
   Professional Dark Theme Design
   ============================================ */

/* Screen-reader only utility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* --- CSS Custom Properties --- */
:root {
    /* Colors — clean professional dark */
    --bg-primary:   #0c0c0c;
    --bg-secondary: #111111;
    --bg-tertiary:  #181818;
    --bg-hover:     #1f1f1f;
    --bg-active:    #252525;

    --surface-1: #151515;
    --surface-2: #1a1a1a;
    --surface-3: #222222;

    --border-subtle:  rgba(255, 255, 255, 0.05);
    --border-default: rgba(255, 255, 255, 0.09);
    --border-strong:  rgba(255, 255, 255, 0.14);

    --text-primary:   #f2f2f2;
    --text-secondary: #8a8a8a;
    --text-tertiary:  #555555;
    --text-inverse:   #0c0c0c;

    --accent-purple:     #7c6af0;
    --accent-purple-dim: rgba(124, 106, 240, 0.12);
    --accent-purple-glow:rgba(124, 106, 240, 0.25);
    --accent-cyan:       #22d3ee;
    --accent-cyan-dim:   rgba(34, 211, 238, 0.12);
    --accent-amber:      #e8a020;
    --accent-amber-dim:  rgba(232, 160, 32, 0.12);
    --accent-emerald:    #22c55e;
    --accent-emerald-dim:rgba(34, 197, 94, 0.12);

    --gradient-brand:        linear-gradient(135deg, #7c6af0 0%, #22d3ee 100%);
    --gradient-brand-subtle: linear-gradient(135deg, rgba(124,106,240,0.15) 0%, rgba(34,211,238,0.15) 100%);

    /* Typography */
    --font-sans:  'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono:  'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    --font-brand: 'Helvetica Neue', 'Arial', Helvetica, sans-serif;

    /* Spacing */
    --sidebar-width: 280px;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
    --shadow-glow-purple: 0 0 20px rgba(139, 92, 246, 0.2);
    --shadow-glow-cyan: 0 0 20px rgba(6, 182, 212, 0.2);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
}

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

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    display: flex;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    line-height: 1.5;
    font-size: 14px;
    letter-spacing: 0.01em;
    font-weight: 400;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
    color: inherit;
    font-size: inherit;
}

textarea {
    font-family: inherit;
    color: inherit;
    border: none;
    outline: none;
    resize: none;
    background: none;
}

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

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

::-webkit-scrollbar-thumb {
    background: var(--border-default);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-strong);
}

/* Firefox scrollbar */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--border-default) transparent;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    transition: width 0.25s ease, min-width 0.25s ease, transform 0.25s ease, opacity 0.25s ease;
    z-index: 100;
    overflow: hidden;
}

/* Top strip of sidebar — same height, background and border as #brandHeader
   so together they form a seamless unified top bar across the full width */
.sidebar-top {
    height: 56px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    padding: 0 12px;
    background: rgba(12, 12, 12, 0.92);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

/* Desktop sidebar collapsed state */
body.sidebar-collapsed .sidebar {
    width: 0;
    min-width: 0;
    border-right-width: 0;
}

body.sidebar-collapsed .sidebar:not(.open) * {
    opacity: 0;
    pointer-events: none;
}

/* sidebar-header removed from HTML — rule kept for safety */
.sidebar-header { display: none; }

.sidebar-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

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

.sidebar-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

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

/* New Chat Button — lives inside .sidebar-top, full width of the strip */
.new-chat-btn {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    margin: 0;
    padding: 9px 12px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 0.85rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    transition: all 0.18s ease;
    background: rgba(255, 255, 255, 0.06);
    flex-shrink: 0;
    letter-spacing: 0.01em;
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.11);
    border-color: rgba(255, 255, 255, 0.18);
    color: #ffffff;
}

.new-chat-btn:active {
    transform: scale(0.97);
}

/* Conversations */
.sidebar-conversations {
    flex: 1;
    overflow-y: auto;
    padding: 8px 8px;
}

.conversations-section {
    margin-bottom: 8px;
}

.conversations-label {
    display: block;
    font-size: 0.62rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-tertiary);
    padding: 8px 12px 4px;
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    transition: background 0.12s ease, color 0.12s ease;
    cursor: pointer;
    width: 100%;
    text-align: left;
    overflow: hidden;
    position: relative;
}

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

.conversation-item.active {
    background: var(--bg-active);
    color: var(--text-primary);
}

/* Action buttons (rename/delete/more) — visible on hover */
.conversation-item-actions {
    display: flex;
    align-items: center;
    gap: 1px;
    margin-left: auto;
    flex-shrink: 0;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.12s ease;
}

.conversation-item:hover .conversation-item-actions,
.conversation-item.active .conversation-item-actions {
    opacity: 1;
    pointer-events: auto;
}

.conv-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border-radius: 4px;
    color: var(--text-tertiary);
    transition: background 0.1s, color 0.1s;
    flex-shrink: 0;
}

.conv-action-btn:hover {
    background: var(--surface-3);
    color: var(--text-primary);
}

.conv-action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.12);
    color: #ef4444;
}

.conversation-item-icon {
    flex-shrink: 0;
    opacity: 0.5;
}

.conversation-item-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-subtle);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh;
    min-width: 0;
    position: relative;
    padding-top: 56px;
}

/* ============================================
   DEV TESTER BAR — only visible in localhost
   ============================================ */
.dev-tester-bar {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 300;
    height: 32px;
    background: #1a1a2e;
    border-bottom: 1px solid rgba(124, 106, 240, 0.3);
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 12px;
    font-size: 0.68rem;
}

.dev-tester-bar.visible {
    display: flex;
}

.dev-tester-label {
    color: rgba(124, 106, 240, 0.7);
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    font-size: 0.6rem;
    margin-right: 4px;
    white-space: nowrap;
}

.dev-tester-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: transparent;
    color: rgba(255, 255, 255, 0.55);
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.dev-tester-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.85);
    border-color: rgba(255, 255, 255, 0.18);
}

.dev-tester-btn.active {
    background: rgba(124, 106, 240, 0.2);
    border-color: rgba(124, 106, 240, 0.5);
    color: #a89cf7;
}

.dev-tester-btn[data-tester="starter"].active {
    background: rgba(34, 211, 238, 0.15);
    border-color: rgba(34, 211, 238, 0.4);
    color: var(--accent-cyan);
}

.dev-tester-btn[data-tester="creator"].active {
    background: rgba(124, 106, 240, 0.15);
    border-color: rgba(124, 106, 240, 0.4);
    color: #a89cf7;
}

.dev-tester-btn[data-tester="pro"].active {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.4);
    color: #f59e0b;
}

.dev-tester-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.7;
    flex-shrink: 0;
}

.dev-tester-separator {
    width: 1px;
    height: 14px;
    background: rgba(255, 255, 255, 0.1);
    margin: 0 2px;
}

/* When dev bar is visible, push brand-header and main content down */
body.dev-mode .brand-header {
    top: 32px;
}

body.dev-mode .main {
    padding-top: calc(56px + 32px);
}

body.dev-mode .sidebar-top {
    margin-top: 32px;
}

/* ============================================
   ELEGANT BRAND HEADER — 3 columns
   Left: hamburger | Center: logo | Right: user
   Shifts right with the sidebar on desktop so
   the logo stays centered in the visible area.
   ============================================ */
.brand-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 200;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    height: 56px;
    padding: 0 16px;
    background: rgba(12, 12, 12, 0.92);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    /* Sidebar open on desktop: shift header right */
    transition: left 0.25s ease;
}

/* When sidebar is visible (desktop default), push header right */
body:not(.sidebar-collapsed) .brand-header {
    left: var(--sidebar-width);
}

body.sidebar-collapsed .brand-header {
    left: 0;
}

/* Left zone */
.brand-left {
    justify-self: start;
}

/* Center zone (layout only — hover/cursor handled in hamburger section) */
.brand-center {
    display: flex;
    align-items: center;
    justify-self: center;
    text-decoration: none;
}

/* Right zone */
.brand-right {
    justify-self: end;
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Public nav links (News / Pricing) — only shown when not logged in */
.brand-public-links {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-right: 6px;
}

.brand-public-link {
    font-size: 0.78rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.45);
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 6px;
    letter-spacing: 0.03em;
    transition: color 0.18s ease, background 0.18s ease;
    white-space: nowrap;
}

.brand-public-link:hover {
    color: rgba(255, 255, 255, 0.85);
    background: rgba(255, 255, 255, 0.06);
}

/* Hamburger button — always visible so user knows the option exists */
.hamburger-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.3);
    transition: color 0.2s ease, background 0.2s ease;
    flex-shrink: 0;
}

.hamburger-btn:hover {
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.7);
}

.hamburger-btn:active {
    transform: scale(0.93);
}

/* Icon swap: sidebar open → show close icon; collapsed → show open icon */
.hamburger-btn .icon-close-sidebar { display: block; }
.hamburger-btn .icon-open-sidebar  { display: none;  }

body.sidebar-collapsed .hamburger-btn .icon-close-sidebar { display: none;  }
body.sidebar-collapsed .hamburger-btn .icon-open-sidebar  { display: block; }

.hamburger-btn svg {
    transition: opacity 0.15s ease;
}

/* Brand center is clickable to open the sidebar */
.brand-center {
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.brand-center:hover {
    opacity: 0.8;
}

/* When sidebar is open on main page, logo is still a link (navigates to /) */
body:not(.sidebar-collapsed) .brand-center {
    opacity: 1;
}

/* Brand glow animation — subtle text-shadow shimmer only.
   letter-spacing is NOT animated to avoid rendering inconsistencies
   with inline spans on Android / Blink-based mobile browsers. */
@keyframes brandGlow {
    0%, 100% {
        text-shadow:
            0 0 12px rgba(255, 255, 255, 0.12),
            0 0 24px rgba(255, 255, 255, 0.04);
    }
    50% {
        text-shadow:
            0 0 18px rgba(255, 255, 255, 0.35),
            0 0 40px rgba(255, 255, 255, 0.12),
            0 0 80px rgba(255, 255, 255, 0.04);
    }
}

.brand-name {
    font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.55rem;
    font-weight: 600;
    letter-spacing: 0.18em;
    color: #ffffff;
    text-transform: uppercase;
    user-select: none;
    animation: brandGlow 4s ease-in-out infinite;
    text-rendering: geometricPrecision;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-kerning: none;
}

.brand-name em {
    font-style: italic;
    font-weight: 600;
    color: #ffffff;
}

.brand-name .brand-x {
    font-style: italic;
    font-weight: 600;
    letter-spacing: inherit;
    margin: 0;
    padding: 0;
}

/* News link in header — always visible for all users */
.brand-news-link {
    display: flex;
    align-items: center;
    padding: 7px 14px;
    margin-right: 8px;
    border-radius: 8px;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: all 0.2s ease;
}

.brand-news-link:hover {
    background: rgba(255, 255, 255, 0.07);
    color: rgba(255, 255, 255, 0.9);
}

/* Login button inside header */
.brand-login-btn {
    display: flex;
    align-items: center;
    padding: 7px 15px;
    border-radius: 980px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.13);
    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    transition: all 0.2s ease;
}

.brand-login-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

.brand-login-btn:active {
    transform: scale(0.96);
}

/* User avatar button inside header */
.brand-user-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.brand-user-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.brand-user-btn:active {
    transform: scale(0.93);
}

.brand-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    overflow: hidden;
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.4);
    transition: box-shadow 0.2s ease;
}

.brand-user-btn:hover .brand-user-avatar {
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.7);
}

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

/* ============================================
   COOKIE CONSENT BANNER
   ============================================ */
.cookie-banner {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    z-index: 190;
    background: rgba(15, 15, 15, 0.96);
    backdrop-filter: saturate(180%) blur(16px);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    transition: left var(--transition-base), transform var(--transition-slow), opacity var(--transition-slow);
}

body:not(.sidebar-collapsed) .cookie-banner {
    left: var(--sidebar-width);
}

body.sidebar-collapsed .cookie-banner {
    left: 0;
}

.cookie-banner.cookie-hidden {
    transform: translateY(-110%);
    opacity: 0;
    pointer-events: none;
}

.cookie-banner-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 9px 20px;
}

.cookie-banner-text {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    line-height: 1.5;
}

.cookie-banner-text svg {
    flex-shrink: 0;
    color: var(--accent-amber);
    opacity: 0.85;
}

.cookie-banner-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.cookie-btn {
    padding: 5px 15px;
    border-radius: var(--radius-full);
    font-size: 0.775rem;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    transition: all var(--transition-fast);
    border: 1px solid;
    white-space: nowrap;
    line-height: 1.6;
}

.cookie-btn-reject {
    background: transparent;
    border-color: rgba(255, 255, 255, 0.11);
    color: var(--text-secondary);
}

.cookie-btn-reject:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border-color: rgba(255, 255, 255, 0.2);
}

.cookie-btn-accept {
    background: var(--accent-purple);
    border-color: transparent;
    color: #fff;
}

.cookie-btn-accept:hover {
    background: #9d8df5;
    transform: scale(1.02);
}

.cookie-btn-accept:active,
.cookie-btn-reject:active {
    transform: scale(0.96);
}

/* sidebar-header: tiny top padding so new-chat-btn has breathing room */
.sidebar-header {
    height: 0;
    padding: 0;
    overflow: hidden;
    flex-shrink: 0;
}

/* Desktop: menu-btn only visible when sidebar is collapsed */
.menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.menu-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.9);
}

body.sidebar-collapsed .menu-btn {
    display: flex;
}

.sidebar-toggle-btn svg {
    transition: transform 0.2s ease;
}

.topbar-spacer {
    flex: 1;
}

/* ============================================
   WELCOME SCREEN
   ============================================ */
.welcome-screen {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 24px;
    overflow-y: auto;
    animation: fadeInUp 0.6s var(--transition-slow) both;
}

.welcome-content {
    max-width: 640px;
    width: 100%;
    text-align: center;
}

/* Waveform Animation */
.welcome-logo-anim {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.waveform-container {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 34px;
    padding: 5px 16px;
    border-radius: var(--radius-xl);
    background: var(--gradient-brand-subtle);
    border: 1px solid var(--border-subtle);
}

.waveform-bar {
    width: 3px;
    border-radius: var(--radius-full);
    background: var(--gradient-brand);
    animation: waveform 1.2s ease-in-out infinite;
}

.waveform-bar:nth-child(1) { height: 8px;  animation-delay: 0s; }
.waveform-bar:nth-child(2) { height: 13px; animation-delay: 0.1s; }
.waveform-bar:nth-child(3) { height: 20px; animation-delay: 0.2s; }
.waveform-bar:nth-child(4) { height: 15px; animation-delay: 0.3s; }
.waveform-bar:nth-child(5) { height: 22px; animation-delay: 0.4s; }
.waveform-bar:nth-child(6) { height: 13px; animation-delay: 0.5s; }
.waveform-bar:nth-child(7) { height: 9px;  animation-delay: 0.6s; }

@keyframes waveform {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.4); }
}

.welcome-title {
    font-size: 1.35rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    margin-bottom: 6px;
    color: var(--text-primary);
    line-height: 1.25;
}

.welcome-subtitle {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin-bottom: 22px;
    font-weight: 400;
    letter-spacing: 0.01em;
}

/* Feature Cards */
.feature-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.feature-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
    background: var(--surface-1);
    text-align: left;
    transition: all var(--transition-base);
    position: relative;
    overflow: hidden;
    cursor: pointer;
}

.feature-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity var(--transition-base);
    border-radius: inherit;
}

.feature-card[data-mode="generate"]::before {
    background: linear-gradient(135deg, rgba(139,92,246,0.08) 0%, transparent 60%);
}

.feature-card[data-mode="variation"]::before {
    background: linear-gradient(135deg, rgba(6,182,212,0.08) 0%, transparent 60%);
}

.feature-card[data-mode="copilot"]::before {
    background: linear-gradient(135deg, rgba(245,158,11,0.08) 0%, transparent 60%);
}

.feature-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.feature-card:hover::before {
    opacity: 1;
}

.feature-card:active {
    transform: translateY(0);
}

.feature-card-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all var(--transition-base);
}

.feature-card[data-mode="generate"] .feature-card-icon {
    background: var(--accent-purple-dim);
    color: var(--accent-purple);
}

.feature-card[data-mode="variation"] .feature-card-icon {
    background: var(--accent-cyan-dim);
    color: var(--accent-cyan);
}

.feature-card[data-mode="copilot"] .feature-card-icon {
    background: var(--accent-amber-dim);
    color: var(--accent-amber);
}

.feature-card:hover .feature-card-icon {
    transform: scale(1.05);
}

.feature-card-icon svg {
    width: 21px;
    height: 21px;
}

.feature-card-content {
    flex: 1;
    min-width: 0;
}

.feature-card-content h3 {
    font-size: 0.84rem;
    font-weight: 500;
    margin-bottom: 3px;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

.feature-card-content p {
    font-size: 0.76rem;
    color: var(--text-tertiary);
    line-height: 1.4;
}

.feature-card-arrow {
    color: var(--text-tertiary);
    transition: all var(--transition-base);
    flex-shrink: 0;
}

.feature-card:hover .feature-card-arrow {
    color: var(--text-secondary);
    transform: translateX(4px);
}

/* Premium Feature Cards (Image to Melody, Video to Melody) */
.feature-card-premium {
    position: relative;
    border: 1px solid rgba(124, 106, 240, 0.2);
}

.feature-card-premium::before {
    background: linear-gradient(135deg, rgba(124, 106, 240, 0.1) 0%, rgba(34, 211, 238, 0.08) 100%) !important;
}

.feature-card-premium:hover {
    border-color: rgba(124, 106, 240, 0.4);
    box-shadow: 0 4px 20px rgba(124, 106, 240, 0.15);
}

.feature-card-title-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    flex-wrap: wrap;
}

.feature-card-title-row h3 {
    margin-bottom: 0 !important;
}

.feature-card-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 0.58rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent-purple) 0%, var(--accent-cyan) 100%);
    color: white;
    box-shadow: 0 1px 6px rgba(124, 106, 240, 0.3);
    line-height: 1.5;
    flex-shrink: 0;
    white-space: nowrap;
}

.feature-card-pro .feature-card-badge,
.feature-card[data-mode="video"] .feature-card-badge {
    background: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    box-shadow: 0 1px 6px rgba(245, 158, 11, 0.3);
}

.feature-card[data-mode="image"] .feature-card-icon {
    background: linear-gradient(135deg, rgba(124, 106, 240, 0.15) 0%, rgba(34, 211, 238, 0.15) 100%);
    color: var(--accent-purple);
}

.feature-card[data-mode="image"]::before {
    background: linear-gradient(135deg, rgba(124, 106, 240, 0.08) 0%, rgba(34, 211, 238, 0.05) 60%);
}

.feature-card[data-mode="video"] .feature-card-icon {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.15) 0%, rgba(239, 68, 68, 0.15) 100%);
    color: #f59e0b;
}

.feature-card[data-mode="video"]::before {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.08) 0%, rgba(239, 68, 68, 0.05) 60%);
}

.feature-card-pro {
    border-color: rgba(245, 158, 11, 0.2);
}

.feature-card-pro:hover {
    border-color: rgba(245, 158, 11, 0.4);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.15);
}

/* Locked state for features not available in current plan */
.feature-card.feature-locked {
    opacity: 0.7;
    cursor: default;
    position: relative;
}

.feature-card.feature-locked .feature-card-arrow {
    display: none;
}

.feature-card.feature-locked:hover {
    opacity: 0.7;
    transform: none;
}

/* ============================================
   APPLE-STYLE CHAT CONTAINER
   "Design is not just what it looks like and 
   feels like. Design is how it works." - Steve Jobs
   ============================================ */
.chat-container {
    flex: 1;
    overflow-y: auto;
    display: none;
    scroll-behavior: smooth;
    background: var(--bg-primary);
}

.chat-container.active {
    display: block;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.chat-messages {
    max-width: 680px;
    margin: 0 auto;
    padding: 32px 24px 24px;
    width: 100%;
}

/* Apple-style Message Bubbles */
.message {
    display: flex;
    flex-direction: column;
    margin-bottom: 24px;
    animation: appleMessageIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    position: relative;
}

.message + .message {
    border-top: none;
}

/* User Messages - Right aligned, blue bubble */
.message.user {
    align-items: flex-end;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, #0a84ff 0%, #0066cc 100%);
    color: #ffffff;
    border-radius: 20px 20px 6px 20px;
    width: fit-content;
    min-width: 3em;
    max-width: 75%;
    padding: 14px 18px;
    box-shadow: 0 2px 12px rgba(10, 132, 255, 0.25);
}

/* Assistant Messages - Left aligned, subtle gray */
.message.assistant {
    align-items: flex-start;
}

.message.assistant .message-bubble {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.92);
    border-radius: 20px 20px 20px 6px;
    max-width: 85%;
    padding: 16px 20px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Hide old avatar system for cleaner Apple look */
.message-avatar {
    display: none;
}

/* Message sender label - Apple style */
.message-sender {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.7rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.02em;
    padding: 0 4px;
}

.message.user .message-sender {
    text-align: right;
}

.message-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.message.user .message-body {
    align-items: flex-end;
}

.message.assistant .message-body {
    align-items: flex-start;
}

/* Message text - Apple typography */
.message-text,
.message-bubble {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.94rem;
    line-height: 1.55;
    letter-spacing: -0.01em;
    /* overflow-wrap only on inner text, not here, to avoid min-content
       collapsing to 1 char wide when the flex parent uses align-items: flex-end */
}

.message-bubble p,
.message-text p {
    overflow-wrap: break-word;
    word-break: break-word;
}

.message-text p,
.message-bubble p {
    margin-bottom: 10px;
}

.message-text p:last-child,
.message-bubble p:last-child {
    margin-bottom: 0;
}

/* Apple-style message animation */
@keyframes appleMessageIn {
    0% {
        opacity: 0;
        transform: translateY(16px) scale(0.96);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Apple-style Mode Tag in Messages */
.message-mode-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 980px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 8px;
}

.message-mode-tag.generate {
    background: rgba(191, 90, 242, 0.15);
    color: #bf5af2;
}

.message-mode-tag.variation {
    background: rgba(100, 210, 255, 0.15);
    color: #64d2ff;
}

.message-mode-tag.copilot {
    background: rgba(255, 214, 10, 0.15);
    color: #ffd60a;
}

/* Apple-style Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 0;
}

.typing-status {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-right: 8px;
}

.typing-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.5);
    animation: appleTyping 1.4s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0s; }
.typing-dot:nth-child(3) { animation-delay: 0.16s; }
.typing-dot:nth-child(4) { animation-delay: 0.32s; }

@keyframes appleTyping {
    0%, 100% { 
        opacity: 0.4;
        transform: scale(1);
    }
    50% { 
        opacity: 1;
        transform: scale(1.15);
    }
}

/* Typing message — Windsurf/Claude Code style */
.message.typing-message .message-body {
    padding: 0;
}

.typing-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.typing-header-name {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.72rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.45);
    letter-spacing: 0.02em;
}

.typing-header-dots {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-header-dots .typing-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.35);
    animation: appleTyping 1.4s ease-in-out infinite;
}

.typing-header-dots .typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-header-dots .typing-dot:nth-child(2) { animation-delay: 0.16s; }
.typing-header-dots .typing-dot:nth-child(3) { animation-delay: 0.32s; }

.typing-status-line {
    margin-top: 4px;
    display: flex;
    align-items: center;
    min-height: 1.1em;
}

.typing-status-word {
    font-family: var(--font-mono);
    font-size: 0.72rem;
    color: var(--text-tertiary);
    letter-spacing: 0.03em;
}

.typing-cursor {
    display: inline-block;
    width: 1px;
    height: 0.9em;
    background: var(--text-tertiary);
    margin-left: 1px;
    vertical-align: middle;
    animation: cursorBlink 0.9s step-end infinite;
    opacity: 0.55;
}

@keyframes cursorBlink {
    0%, 100% { opacity: 0.55; }
    50%       { opacity: 0; }
}

/* Apple-style Music Player Card */
.music-player-card {
    margin-top: 16px;
    padding: 20px;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    max-width: 100%;
}

.music-player-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.12);
}

.music-player-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.music-player-title {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.95);
    letter-spacing: -0.01em;
}

.music-player-meta {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 500;
}

/* Apple-style Waveform Visualization */
.music-waveform {
    display: flex;
    align-items: center;
    gap: 2px;
    height: 44px;
    margin-bottom: 14px;
    padding: 0 2px;
}

.music-waveform-bar {
    flex: 1;
    border-radius: 3px;
    background: rgba(10, 132, 255, 0.35);
    transition: all 0.2s ease;
    min-width: 2px;
}

.music-waveform-bar.active {
    background: linear-gradient(180deg, #0a84ff 0%, #0066cc 100%);
}

.music-player-controls {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Apple-style Play Button */
.play-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a84ff 0%, #0066cc 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 14px rgba(10, 132, 255, 0.35);
}

.play-btn:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 20px rgba(10, 132, 255, 0.45);
}

.play-btn:active {
    transform: scale(0.94);
}

.music-player-time {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Mono', 'Menlo', monospace;
    font-size: 0.72rem;
    color: rgba(255, 255, 255, 0.45);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.music-player-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}

.music-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 980px;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.08);
    border: none;
    transition: all 0.2s ease;
}

.music-action-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.95);
}

/* ============================================
   APPLE-STYLE INPUT AREA
   ============================================ */
.input-area {
    padding: 12px 24px 28px;
    flex-shrink: 0;
    background: linear-gradient(to top, var(--bg-primary) 55%, transparent 100%);
    position: relative;
}

.input-wrapper {
    max-width: 680px;
    margin: 0 auto;
    width: 100%;
}

.active-mode-badge {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    margin-bottom: 12px;
    border-radius: 980px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    width: fit-content;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.75rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.7);
    animation: fadeInUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.active-mode-badge.visible {
    display: inline-flex;
}

.mode-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #0a84ff;
}

.active-mode-badge[data-mode="generate"] .mode-dot { background: #bf5af2; }
.active-mode-badge[data-mode="variation"] .mode-dot { background: #64d2ff; }
.active-mode-badge[data-mode="copilot"] .mode-dot { background: #ffd60a; }

.mode-clear {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.4);
    transition: all 0.2s ease;
}

.mode-clear:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

/* Input Box */
.input-box {
    display: flex;
    align-items: center;
    gap: 12px;
    /* Symmetric vertical padding so content sits visually centered */
    padding: 10px 16px;
    min-height: 50px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.055);
    border: 1.5px solid rgba(255, 255, 255, 0.09);
    transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

/* Focus: clean white border — no color */
.input-box:focus-within {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.55);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
    outline: none;
}

.input-box textarea {
    flex: 1;
    /* Remove ALL browser default textarea spacing */
    margin: 0;
    padding: 0;
    border: none;
    /* Explicit vertical alignment so textarea sits exactly at center */
    align-self: center;
    vertical-align: middle;
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.94rem;
    line-height: 1.5;
    max-height: 180px;
    background: transparent;
    color: rgba(255, 255, 255, 0.95);
    letter-spacing: -0.01em;
    outline: none;
    /* Prevent any resize handle */
    resize: none;
    /* Override browser baseline offset */
    display: block;
    position: relative;
    top: 0;
}

.input-box textarea::placeholder {
    color: rgba(255, 255, 255, 0.32);
}

/* ── Mode Picker ────────────────────────────────────────────────────── */
.mode-picker-wrap {
    position: relative;
    flex-shrink: 0;
    align-self: center;
}

.mode-picker-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.55);
    transition: background 0.18s ease, color 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
    cursor: pointer;
}

.mode-picker-btn:hover {
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.22);
}

.mode-picker-btn.open {
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.9);
    border-color: rgba(255, 255, 255, 0.28);
    transform: rotate(45deg);
}

/* Menu */
.mode-picker-menu {
    position: absolute;
    bottom: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    background: rgba(28, 28, 32, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 5px;
    min-width: 160px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.45), 0 2px 8px rgba(0, 0, 0, 0.3);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 100;
}

.mode-picker-menu.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.mode-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    border-radius: 9px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.82rem;
    font-weight: 500;
    letter-spacing: -0.01em;
    text-align: left;
    cursor: pointer;
    transition: background 0.14s ease, color 0.14s ease;
}

.mode-picker-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.95);
}

.mode-picker-item[data-mode="generate"] .mode-picker-icon { color: #bf5af2; }
.mode-picker-item[data-mode="variation"] .mode-picker-icon { color: #64d2ff; }
.mode-picker-item[data-mode="copilot"]   .mode-picker-icon { color: #ffd60a; }
.mode-picker-item[data-mode="image"]     .mode-picker-icon { color: #ff9f0a; }
.mode-picker-item[data-mode="video"]     .mode-picker-icon { color: #ff453a; }

.mode-picker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Animation stagger for items */
.mode-picker-menu.open .mode-picker-item {
    animation: modeItemIn 0.22s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.mode-picker-menu.open .mode-picker-item:nth-child(1) { animation-delay: 0.02s; }
.mode-picker-menu.open .mode-picker-item:nth-child(2) { animation-delay: 0.05s; }
.mode-picker-menu.open .mode-picker-item:nth-child(3) { animation-delay: 0.08s; }
.mode-picker-menu.open .mode-picker-item:nth-child(4) { animation-delay: 0.11s; }
.mode-picker-menu.open .mode-picker-item:nth-child(5) { animation-delay: 0.14s; }

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

/* Send Button */
.send-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0a84ff 0%, #0066cc 100%);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
    align-self: center;
    opacity: 0.3;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(10, 132, 255, 0.3);
}

.send-btn.active {
    opacity: 1;
    pointer-events: auto;
}

.send-btn.active:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(10, 132, 255, 0.4);
}

.send-btn.active:active {
    transform: scale(0.94);
}

.input-footer {
    text-align: center;
    padding-top: 12px;
}

.input-hint {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', sans-serif;
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.3);
    letter-spacing: 0.01em;
}

/* ============================================
   PARTICLES (Decorative Background)
   ============================================ */
.particles-container { display: none; }
.particle { display: none; }

@keyframes particleFloat {
    0% {
        opacity: 0;
        transform: translateY(100vh) rotate(0deg);
    }
    10% {
        opacity: 0.15;
    }
    90% {
        opacity: 0.15;
    }
    100% {
        opacity: 0;
        transform: translateY(-20px) rotate(360deg);
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

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

/* Skeleton loading for AI response */
.skeleton-line {
    height: 14px;
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    margin-bottom: 10px;
}

.skeleton-line:last-child {
    width: 60%;
}

/* ============================================
   RESPONSIVE DESIGN - Mobile
   ============================================ */
@media (max-width: 768px) {
    /* --- Sidebar mobile overlay --- */
    .sidebar {
        position: fixed;
        left: 0;
        top: 50px;
        height: calc(100vh - 50px);
        height: calc(100dvh - 50px);
        padding-top: 0;
        transform: translateX(-100%);
        box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
        z-index: 150;
    }

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

    .sidebar-top {
        height: 50px;
    }

    .sidebar-overlay {
        position: fixed;
        inset: 0;
        top: 50px;
        background: rgba(0, 0, 0, 0.55);
        z-index: 149;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition-base);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    body:not(.sidebar-collapsed) .brand-header,
    body.sidebar-collapsed .brand-header {
        left: 0;
    }

    /* Cookie banner: match header height and stay full-width on mobile */
    .cookie-banner,
    body:not(.sidebar-collapsed) .cookie-banner,
    body.sidebar-collapsed .cookie-banner {
        top: 50px;
        left: 0;
        right: 0;
    }

    .cookie-banner-content {
        padding: 7px 14px;
        gap: 12px;
    }

    .cookie-banner-text {
        font-size: 0.76rem;
    }

    .cookie-btn {
        padding: 5px 12px;
        font-size: 0.72rem;
    }

    .hamburger-btn {
        width: 44px;
        height: 44px;
    }

    /* On mobile always show the 3-line icon, never the X */
    .hamburger-btn .icon-close-sidebar { display: none;  }
    .hamburger-btn .icon-open-sidebar  { display: block; }

    .brand-center {
        cursor: pointer;
    }

    /* --- Brand Header Mobile --- */
    .brand-header {
        height: 50px;
        padding: 0 12px;
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .main {
        padding-top: 50px;
    }

    .brand-name {
        font-size: 1.05rem;
        letter-spacing: 0.14em;
    }

    .brand-login-btn {
        padding: 8px 14px;
        font-size: 0.78rem;
        min-height: 36px;
    }

    .brand-public-link {
        padding: 6px 8px;
        font-size: 0.75rem;
        min-height: 36px;
        display: inline-flex;
        align-items: center;
    }

    /* --- Touch-friendly sidebar items --- */
    .conversation-item {
        padding: 10px 12px;
        min-height: 44px;
    }

    .conv-action-btn {
        width: 36px;
        height: 36px;
    }

    .conversation-item-actions {
        opacity: 1;
        pointer-events: auto;
    }

    /* --- User menu dropdown --- */
    .user-menu-dropdown {
        top: auto;
        right: 8px;
        width: calc(100vw - 24px);
        max-width: 280px;
    }

    .user-menu-dropdown.from-header {
        top: 54px;
    }

    .user-menu-dropdown.from-sidebar {
        bottom: 62px;
        left: 8px;
    }

    .user-menu-item {
        padding: 12px 16px;
        min-height: 44px;
    }

    /* --- Welcome Screen --- */
    .welcome-screen {
        padding: 16px 16px 20px;
    }

    .welcome-title {
        font-size: 1.15rem;
    }

    .welcome-subtitle {
        font-size: 0.78rem;
        margin-bottom: 16px;
    }

    .feature-cards {
        gap: 8px;
    }

    .feature-card {
        padding: 12px 14px;
        min-height: 56px;
    }

    .feature-card-icon {
        width: 36px;
        height: 36px;
    }

    .feature-card-content p {
        font-size: 0.72rem;
        -webkit-line-clamp: 2;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* --- Chat Mobile --- */
    .chat-messages {
        padding: 16px 12px 32px;
    }

    .message {
        margin-bottom: 16px;
    }

    .message.user .message-bubble,
    .message.assistant .message-bubble {
        max-width: 90%;
        padding: 12px 16px;
    }

    .message-text,
    .message-bubble {
        font-size: 0.92rem;
    }

    /* --- Input Area Mobile --- */
    .input-area {
        padding: 0 12px 12px;
        padding-bottom: max(12px, env(safe-area-inset-bottom));
    }

    .input-wrapper {
        max-width: 100%;
        width: 100%;
    }

    .input-box {
        padding: 8px 12px;
        border-radius: 20px;
        min-height: 48px;
        gap: 8px;
        align-items: center;
        width: 100%;
    }

    .input-box textarea {
        font-size: 16px;
        padding: 0;
        line-height: 32px;
        min-height: 32px;
        flex: 1;
        width: 100%;
    }

    .input-footer {
        padding-top: 8px;
    }

    .input-hint {
        font-size: 0.65rem;
    }

    .send-btn {
        width: 36px;
        height: 36px;
    }

    .mode-picker-btn {
        width: 36px;
        height: 36px;
    }

    /* --- Music Player Mobile --- */
    .music-player-card {
        padding: 14px;
    }

    .music-player-controls {
        flex-wrap: wrap;
        gap: 10px;
    }

    .music-player-actions {
        width: 100%;
        margin-left: 0;
        gap: 6px;
    }

    .music-action-btn {
        flex: 1;
        justify-content: center;
        padding: 10px 12px;
        font-size: 0.74rem;
        min-height: 40px;
    }

    .play-btn {
        width: 44px;
        height: 44px;
    }

    /* --- Login modal — bottom sheet --- */
    .login-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .login-modal {
        max-width: 100%;
        padding: 28px 20px;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
        border-radius: 16px 16px 0 0;
    }

    /* --- Pricing modal — bottom sheet --- */
    .pricing-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .pricing-modal {
        max-width: 100%;
        max-height: 92vh;
        max-height: 92dvh;
        padding: 28px 16px 24px;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
        border-radius: 16px 16px 0 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .pricing-title {
        font-size: 1.3rem;
    }

    .pricing-subtitle {
        font-size: 0.8rem;
    }

    .pricing-cards {
        grid-template-columns: 1fr;
    }

    .pricing-card {
        padding: 20px 16px;
    }

    .pricing-cta {
        min-height: 44px;
    }

    /* --- Account modal — bottom sheet --- */
    .account-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .account-modal {
        max-width: 100%;
        max-height: 92vh;
        max-height: 92dvh;
        padding: 24px 16px;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
        border-radius: 16px 16px 0 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .account-header {
        flex-direction: column;
        text-align: center;
        gap: 12px;
    }

    .account-info {
        align-items: center;
    }

    .account-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    /* --- Blog modal — bottom sheet --- */
    .blog-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .blog-modal {
        max-width: 100%;
        max-height: 92vh;
        max-height: 92dvh;
        padding: 24px 16px;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
        border-radius: 16px 16px 0 0;
        -webkit-overflow-scrolling: touch;
    }

    .blog-post-actions {
        flex-direction: column;
    }

    .blog-action-btn {
        min-height: 44px;
    }

    /* --- Payment toast --- */
    .payment-toast {
        top: 58px;
        max-width: calc(100vw - 24px);
    }

    .payment-toast-content {
        font-size: 0.82rem;
        padding: 12px 18px;
        white-space: normal;
        text-align: center;
    }

    /* --- Mode picker menu --- */
    .mode-picker-menu {
        left: 0;
        transform: translateX(0) translateY(6px);
        min-width: 170px;
    }

    .mode-picker-menu.open {
        transform: translateX(0) translateY(0);
    }

    .mode-picker-item {
        padding: 10px 12px;
        min-height: 44px;
    }

    /* --- Prevent iOS Safari zoom on input focus --- */
    .input-box textarea,
    input[type="text"],
    input[type="email"],
    input[type="url"],
    input[type="search"],
    textarea {
        font-size: 16px;
    }
}

@media (max-width: 480px) {
    .brand-name {
        font-size: 0.95rem;
        letter-spacing: 0.12em;
    }

    .brand-public-links {
        display: none;
    }

    .welcome-screen {
        padding: 12px 12px 20px;
    }

    .welcome-title {
        font-size: 1rem;
    }

    .welcome-subtitle {
        font-size: 0.72rem;
        margin-bottom: 14px;
    }

    .feature-card-content p {
        font-size: 0.7rem;
        -webkit-line-clamp: 1;
    }

    .feature-card {
        padding: 10px 12px;
        gap: 10px;
        min-height: 48px;
    }

    .feature-card-icon {
        width: 32px;
        height: 32px;
    }

    .feature-card-icon svg {
        width: 16px;
        height: 16px;
    }

    .feature-card-content h3 {
        font-size: 0.8rem;
    }

    .chat-messages {
        padding: 12px 10px 24px;
    }

    .message.user .message-bubble,
    .message.assistant .message-bubble {
        max-width: 92%;
        padding: 10px 14px;
    }

    .input-area {
        padding: 0 8px 10px;
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .pricing-amount {
        font-size: 1.6rem;
    }

    .pricing-features li {
        font-size: 0.78rem;
    }

    .account-stat {
        padding: 10px;
    }

    .account-stat-value {
        font-size: 1rem;
    }

    .blog-modal {
        padding: 20px 14px;
        padding-bottom: max(20px, env(safe-area-inset-bottom));
    }

    .blog-modal-title {
        font-size: 1.1rem;
    }

    .form-group input,
    .form-group textarea {
        font-size: 16px;
    }

    .music-player-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .new-chat-btn {
        padding: 8px 10px;
        font-size: 0.82rem;
    }

    .sidebar-footer {
        padding: 10px;
    }

    .sidebar-login-btn {
        padding: 10px 12px;
        font-size: 0.82rem;
    }
}

@media (max-width: 360px) {
    .brand-name {
        font-size: 0.88rem;
        letter-spacing: 0.1em;
    }

    .brand-login-btn span {
        font-size: 0.72rem;
    }

    .welcome-title {
        font-size: 0.92rem;
    }

    .feature-card-content p {
        display: none;
    }

    .feature-card-badge {
        font-size: 0.52rem;
        padding: 2px 6px;
    }
}

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

/* ============================================
   TOPBAR LOGIN BUTTON
   ============================================ */
.topbar-login-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.topbar-login-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

/* Topbar User Button (when logged in) */
.topbar-user-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-full);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.topbar-user-btn:hover {
    background: var(--bg-hover);
}

.topbar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--gradient-brand);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    overflow: hidden;
}

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

/* ============================================
   SIDEBAR LOGIN BUTTON
   ============================================ */
.sidebar-login-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--gradient-brand);
    border: none;
    font-size: 0.875rem;
    font-weight: 500;
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar-login-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow-purple);
}

.sidebar-login-btn:active {
    transform: translateY(0);
}

/* User Profile in Sidebar (when logged in) */
.user-profile {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
    cursor: pointer;
    width: 100%;
}

.user-profile:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--surface-3);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: var(--text-secondary);
    overflow: hidden;
}

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

.user-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.user-menu-btn:hover {
    background: var(--bg-active);
    color: var(--text-primary);
}

/* User Menu Dropdown — base styles */
.user-menu-dropdown {
    position: fixed;
    width: 210px;
    padding: 4px;
    background: rgba(22, 22, 22, 0.97);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.7), 0 2px 8px rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    /* default hidden state */
    transform: scale(0.95);
    transition: opacity 0.18s ease, transform 0.18s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.18s;
}

/* From header avatar → top-right under brand header */
.user-menu-dropdown.from-header {
    top: 62px;
    right: 12px;
    bottom: auto;
    left: auto;
    transform-origin: top right;
}

/* From sidebar user profile → bottom-left above sidebar footer */
.user-menu-dropdown.from-sidebar {
    bottom: 68px;
    left: 12px;
    top: auto;
    right: auto;
    transform-origin: bottom left;
}

.user-menu-dropdown.visible {
    opacity: 1;
    visibility: visible;
    transform: scale(1);
}

.user-menu-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 10px;
}

.user-menu-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--surface-3);
    flex-shrink: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-menu-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.user-menu-name {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-email {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-menu-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 3px 0;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 10px;
    border-radius: 5px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: background 0.12s ease, color 0.12s ease;
    text-align: left;
    text-decoration: none;
}

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

.user-menu-item-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.user-menu-item svg {
    flex-shrink: 0;
    opacity: 0.7;
    width: 13px;
    height: 13px;
}

/* ============================================
   LOGIN MODAL
   ============================================ */
.login-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.login-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.login-modal {
    position: relative;
    width: 100%;
    max-width: 400px;
    padding: 32px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-base);
}

.login-modal-overlay.visible .login-modal {
    transform: scale(1) translateY(0);
}

.login-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

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

.login-modal-header {
    text-align: center;
    margin-bottom: 28px;
}

.login-modal-wordmark {
    font-family: 'Helvetica Neue', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 1.75rem;
    font-weight: 600;
    letter-spacing: 0.2em;
    color: #ffffff;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.login-modal-wordmark-x {
    font-style: italic;
}

.login-modal-subtitle {
    font-size: 0.92rem;
    color: rgba(255, 255, 255, 0.5);
    margin: 0;
    letter-spacing: 0.01em;
    line-height: 1.5;
}

/* Auth Error */
.auth-error {
    padding: 12px 16px;
    margin-bottom: 16px;
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    font-size: 0.85rem;
    text-align: center;
    animation: fadeIn 0.3s ease;
}

/* Auth Spinner */
.auth-spinner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 16px;
    margin-bottom: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

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

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

/* Login Modal Buttons */
.login-modal-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

/* Google Button Container */
.google-btn-container {
    display: flex;
    justify-content: center;
    min-height: 44px;
    width: 100%;
}

.google-btn-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 24px;
    color: var(--text-tertiary);
    font-size: 0.85rem;
}

.google-btn-placeholder .spinner {
    width: 16px;
    height: 16px;
}

.login-unavailable {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    color: #ef4444;
    font-size: 0.85rem;
}

.login-unavailable svg {
    flex-shrink: 0;
}

/* ============================================
   PRICING MODAL
   ============================================ */
.pricing-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.pricing-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.pricing-modal {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 20px;
    padding: 40px 32px 36px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(16px);
    transition: transform var(--transition-base);
}

.pricing-modal-overlay.active .pricing-modal {
    transform: translateY(0);
}

.pricing-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

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

.pricing-header {
    text-align: center;
    margin-bottom: 32px;
}

.pricing-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px;
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.pricing-subtitle {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    margin: 0;
    max-width: 520px;
    margin-inline: auto;
    line-height: 1.5;
}

/* Cards grid */
.pricing-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    align-items: start;
}

.pricing-card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: relative;
    transition: border-color var(--transition-base);
}

.pricing-card:hover {
    border-color: var(--border-default);
}

.pricing-card-featured {
    border-color: var(--accent-purple);
    background: linear-gradient(145deg, var(--bg-tertiary), rgba(139, 92, 246, 0.06));
}

.pricing-card-featured:hover {
    border-color: var(--accent-purple);
}

.pricing-card-badge {
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--gradient-brand);
    color: white;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 3px 12px;
    border-radius: 99px;
    white-space: nowrap;
}

.pricing-card-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.pricing-plan-name {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.pricing-price {
    display: flex;
    align-items: baseline;
    gap: 4px;
    margin: 4px 0 0;
}

.pricing-amount {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1;
}

.pricing-period {
    font-size: 0.85rem;
    color: var(--text-tertiary);
}

.pricing-model {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin: 6px 0 0;
    padding: 5px 8px;
    background: var(--surface-1);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

.pricing-features {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.pricing-features li {
    font-size: 0.82rem;
    color: var(--text-secondary);
    padding-left: 20px;
    position: relative;
    line-height: 1.4;
}

.pricing-features li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--accent-emerald);
    font-weight: 700;
    font-size: 0.78rem;
}

.pricing-best-for {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    font-style: italic;
    margin: 0;
    padding-top: 8px;
    border-top: 1px solid var(--border-subtle);
}

.pricing-cta {
    width: 100%;
    padding: 11px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    background: var(--surface-3);
    border: 1px solid var(--border-default);
    transition: all var(--transition-fast);
    cursor: pointer;
}

.pricing-cta:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

.pricing-cta-featured {
    background: var(--gradient-brand);
    border-color: transparent;
    color: white;
}

.pricing-cta-featured:hover {
    opacity: 0.9;
    background: var(--gradient-brand);
}

/* Responsive pricing — stacking handled in main 768px media query */

/* Usage limit modal emphasis */
.login-modal-title.limit-reached {
    color: var(--accent-purple);
}


/* Login Modal Links (News / Pricing) */
.login-modal-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 16px;
}

.login-modal-link {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    transition: color 0.2s ease;
}

.login-modal-link:hover {
    color: rgba(255, 255, 255, 0.9);
}

.login-modal-link-sep {
    color: rgba(255, 255, 255, 0.25);
    font-size: 0.8rem;
}

/* Login Modal Footer */
.login-modal-footer {
    text-align: center;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

.login-modal-footer p {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin: 0;
}

.login-modal-footer a {
    color: var(--accent-purple);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.login-modal-footer a:hover {
    color: var(--accent-cyan);
}

/* Responsive Modal */
@media (max-width: 480px) {
    .login-modal {
        padding: 24px;
    }

    .login-modal-title {
        font-size: 1.1rem;
    }

    .login-btn {
        padding: 12px 16px;
        font-size: 0.9rem;
    }
}

/* ============================================
   AUTH TABS (Sign In / Sign Up)
   ============================================ */
.auth-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
}

.auth-tab {
    flex: 1;
    padding: 10px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.auth-tab:hover {
    color: var(--text-primary);
}

.auth-tab.active {
    color: var(--text-primary);
    background: var(--bg-secondary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Terms Acceptance Checkbox */
.terms-acceptance {
    margin-top: 16px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
}

.terms-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--text-secondary);
}

.terms-checkbox {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.terms-checkbox-custom {
    flex-shrink: 0;
    width: 15px;
    height: 15px;
    border: 2px solid var(--border-strong);
    border-radius: 50%;
    background: transparent;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0;
}

.terms-checkbox-custom::after {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-secondary);
    opacity: 0;
    transform: scale(0);
    transition: all var(--transition-fast);
}

.terms-checkbox:checked + .terms-checkbox-custom {
    border-color: var(--border-strong);
}

.terms-checkbox:checked + .terms-checkbox-custom::after {
    opacity: 1;
    transform: scale(1);
}

.terms-checkbox:focus-visible + .terms-checkbox-custom {
    outline: 2px solid rgba(255, 255, 255, 0.2);
    outline-offset: 2px;
}

.terms-checkbox-text {
    flex: 1;
}

.terms-checkbox-text a {
    color: var(--text-secondary);
    text-decoration: underline;
    text-decoration-color: var(--border-strong);
    transition: color var(--transition-fast);
}

.terms-checkbox-text a:hover {
    color: var(--text-primary);
}

/* Login Modal Footer variants */
.login-footer-signin,
.login-footer-signup {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    margin: 0;
    transition: opacity var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.login-footer-signin a,
.login-footer-signup a {
    color: var(--text-tertiary);
    text-decoration: underline;
    text-decoration-color: var(--border-default);
}

.login-footer-signin a:hover,
.login-footer-signup a:hover {
    color: var(--text-secondary);
}

.login-footer-signin.hidden,
.login-footer-signup.hidden {
    display: none;
}

/* Terms link inline (in footer) */
.terms-link-inline,
.privacy-link-inline {
    color: var(--text-tertiary);
    text-decoration: underline;
    text-decoration-color: var(--border-default);
    cursor: pointer;
}

.terms-link-inline:hover,
.privacy-link-inline:hover {
    color: var(--text-secondary);
}

/* ============================================
   TERMS & PRIVACY MODAL
   ============================================ */
.terms-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-base);
}

.terms-modal-overlay.visible {
    opacity: 1;
    visibility: visible;
}

.terms-modal {
    position: relative;
    width: 100%;
    max-width: 720px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    transform: scale(0.95) translateY(20px);
    transition: transform var(--transition-base);
}

.terms-modal-overlay.visible .terms-modal {
    transform: scale(1) translateY(0);
}

.terms-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    color: var(--text-tertiary);
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
    z-index: 10;
}

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

.terms-modal-header {
    padding: 28px 32px 18px;
    border-bottom: 1px solid var(--border-subtle);
    flex-shrink: 0;
}

.terms-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.01em;
}

.terms-modal-subtitle {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin: 0;
}

.terms-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px 32px;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
}

.terms-modal-content::-webkit-scrollbar {
    width: 6px;
}

.terms-modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.terms-modal-content::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 3px;
}

/* Data Controller Box */
.terms-controller {
    padding: 14px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.terms-controller a {
    color: var(--text-secondary);
    text-decoration: none;
}

.terms-controller a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

/* Part Titles */
.terms-part-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 28px 0 18px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-subtle);
    letter-spacing: 0.02em;
    text-transform: uppercase;
}

.terms-part-title:first-of-type {
    margin-top: 0;
}

.terms-section {
    margin-bottom: 20px;
}

.terms-section:last-of-type {
    margin-bottom: 8px;
}

.terms-section h4 {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    letter-spacing: -0.01em;
}

.terms-section p {
    font-size: 0.82rem;
    line-height: 1.7;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.terms-section p:last-child {
    margin-bottom: 0;
}

.terms-section a {
    color: var(--text-secondary);
    text-decoration: underline;
    text-decoration-color: var(--border-strong);
}

.terms-section a:hover {
    color: var(--text-primary);
}

/* Terms Lists */
.terms-list {
    margin: 10px 0;
    padding-left: 20px;
    list-style: none;
}

.terms-list li {
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin-bottom: 6px;
    position: relative;
    padding-left: 12px;
}

.terms-list li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 4px;
    height: 4px;
    background: var(--border-strong);
    border-radius: 50%;
}

.terms-list li strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* Contact Box at bottom */
.terms-contact-box {
    margin-top: 24px;
    padding: 16px 18px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    text-align: center;
}

.terms-contact-box p {
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-secondary);
    margin: 0;
}

.terms-contact-box a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
}

.terms-contact-box a:hover {
    color: var(--text-primary);
    text-decoration: underline;
}

.terms-controller-name {
    display: block;
    margin-top: 6px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: 0.05em;
}

/* Responsive Terms Modal */
@media (max-width: 768px) {
    .terms-modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .terms-modal {
        max-width: 100%;
        max-height: 90vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }

    .terms-modal-header {
        padding: 22px 20px 14px;
    }

    .terms-modal-title {
        font-size: 1.1rem;
    }

    .terms-modal-content {
        padding: 20px;
    }

    .terms-part-title {
        font-size: 0.9rem;
    }

    .terms-section h4 {
        font-size: 0.84rem;
    }

    .terms-section p,
    .terms-list li {
        font-size: 0.78rem;
    }

    .terms-controller {
        font-size: 0.78rem;
    }

    .auth-tabs {
        margin-bottom: 16px;
    }

    .auth-tab {
        padding: 8px 12px;
        font-size: 0.82rem;
    }

    .terms-acceptance {
        padding: 10px 12px;
    }

    .terms-checkbox-label {
        font-size: 0.75rem;
    }
}

/* ============================================
   FOCUS STYLES
   ============================================ */
:focus-visible {
    outline: 2px solid rgba(124, 106, 240, 0.6);
    outline-offset: 2px;
}

button:focus:not(:focus-visible) {
    outline: none;
}

textarea:focus:not(:focus-visible) {
    outline: none;
}

.input-box textarea:focus-visible {
    outline: none;
}

/* ============================================
   NOTATION / CODE BLOCK IN MESSAGES
   ============================================ */
.message-text code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    color: var(--accent-cyan);
}

.message-text pre {
    margin: 12px 0;
    padding: 16px;
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    overflow-x: auto;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    line-height: 1.6;
}

/* ============================================
   SCROLLBAR FADE AT EDGES
   ============================================ */
.chat-container::before,
.chat-container::after {
    content: '';
    position: sticky;
    display: block;
    height: 32px;
    z-index: 5;
    pointer-events: none;
}

.chat-container::before {
    top: 0;
    background: linear-gradient(to bottom, var(--bg-primary) 0%, transparent 100%);
}

.chat-container::after {
    bottom: 0;
    background: linear-gradient(to top, var(--bg-primary) 0%, transparent 100%);
}

/* ============================================
   SPECIAL: Musical Staff Lines (decorative)
   ============================================ */
.staff-lines {
    position: relative;
    padding: 20px 0;
    margin: 12px 0;
}

.staff-lines::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        to bottom,
        transparent,
        transparent 9px,
        var(--border-subtle) 9px,
        var(--border-subtle) 10px
    );
    opacity: 0.5;
}

/* ============================================
   MIDI PLAYER CARD — Enhanced
   ============================================ */
.music-player-card {
    margin-top: 16px;
    padding: 16px;
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
}

.music-player-header {
    margin-bottom: 12px;
}

.music-player-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.music-player-meta {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.music-waveform {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 48px;
    gap: 2px;
    padding: 8px 0;
    margin-bottom: 12px;
}

.music-waveform-bar {
    flex: 1;
    background: var(--surface-3);
    border-radius: 2px;
    transition: background-color 0.15s ease, height 0.3s ease;
    min-width: 3px;
    max-width: 8px;
}

.music-waveform-bar.active {
    background: var(--accent-purple);
}

.music-player-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-purple);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: white;
    flex-shrink: 0;
}

.play-btn:hover {
    background: var(--accent-cyan);
    transform: scale(1.05);
}

.play-btn.playing {
    background: var(--accent-cyan);
}

.play-btn svg {
    width: 16px;
    height: 16px;
}

.music-player-time {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    min-width: 90px;
}

.music-player-actions {
    display: flex;
    gap: 8px;
    margin-left: auto;
}

.music-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--surface-3);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.music-action-btn.copied {
    background: var(--accent-emerald-dim);
    border-color: var(--accent-emerald);
    color: var(--accent-emerald);
}

.music-action-btn svg {
    flex-shrink: 0;
}

/* Message balance display */
.message-balance {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

.balance-label {
    color: var(--text-tertiary);
}

.balance-value {
    color: var(--accent-purple);
    font-weight: 600;
    font-family: var(--font-mono);
}

.balance-separator {
    color: var(--border-default);
}

/* Error message styling */
.message-error {
    background: rgba(239, 68, 68, 0.1) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

.message-error p {
    color: #f87171;
}

.error-hint {
    font-size: 0.8rem;
    color: var(--text-tertiary) !important;
    margin-top: 8px;
}

/* Moderation message styling - friendly redirection */
.message-moderation {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(59, 130, 246, 0.1)) !important;
    border-color: rgba(139, 92, 246, 0.3) !important;
    border-left: 3px solid var(--accent-primary);
}

.message-moderation p {
    color: var(--text-primary);
    line-height: 1.6;
}

/* ── Early Access Limit message styling ───────────────────── */
.message-early-access {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.08), rgba(245, 158, 11, 0.06)) !important;
    border-color: rgba(251, 191, 36, 0.3) !important;
    border-left: 3px solid #fbbf24;
    text-align: center;
    padding: 24px !important;
}

.early-access-icon {
    margin-bottom: 16px;
    color: #fbbf24;
}

.early-access-icon svg {
    width: 40px;
    height: 40px;
}

.early-access-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.early-access-text {
    font-size: 0.95rem;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 20px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.early-access-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

.btn-waitlist-join {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: #000;
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-waitlist-join:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(251, 191, 36, 0.3);
}

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

.btn-waitlist-decline {
    padding: 12px 20px;
    background: transparent;
    color: var(--text-tertiary);
    font-size: 0.9rem;
    border: 1px solid var(--border-default);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-waitlist-decline:hover {
    color: var(--text-secondary);
    border-color: var(--border-hover);
}

.btn-waitlist-decline:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.early-access-status {
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 8px;
    margin-top: 8px;
}

/* ── MIDI Guidance message styling ───────────────────────── */
.message-midi-guidance {
    background: linear-gradient(
        135deg,
        rgba(6, 182, 212, 0.08),
        rgba(16, 185, 129, 0.06)
    ) !important;
    border-color: rgba(6, 182, 212, 0.25) !important;
    border-left: 3px solid var(--accent-cyan, #06b6d4);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.midi-guidance-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.midi-guidance-body {
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.65;
    margin: 0;
}

.midi-guidance-body strong {
    color: var(--text-primary);
    font-weight: 600;
}

.midi-guidance-body em {
    color: var(--accent-cyan, #06b6d4);
    font-style: normal;
    font-weight: 500;
}

.midi-guidance-hint {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    line-height: 1.5;
    margin: 0;
    padding: 8px 12px;
    background: rgba(6, 182, 212, 0.06);
    border-radius: var(--radius-sm);
    border-left: 2px solid rgba(6, 182, 212, 0.3);
}

/* Responsive MIDI player — handled in 768px block above */

/* ============================================
   BLOG MANAGEMENT MODAL
   ============================================ */
.blog-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.blog-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.blog-modal {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 20px;
    padding: 32px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(16px);
    transition: transform var(--transition-base);
}

.blog-modal-overlay.active .blog-modal {
    transform: translateY(0);
}

.blog-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

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

.blog-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.blog-modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.blog-modal-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 8px 0 0;
    line-height: 1.5;
}

.blog-view-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--accent-purple);
    text-decoration: none;
    transition: color var(--transition-fast);
}

.blog-view-link:hover {
    color: var(--accent-cyan);
}

.blog-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    transition: color var(--transition-fast);
}

.blog-back-btn:hover {
    color: var(--text-primary);
}

/* Blog Setup Form */
.blog-setup-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

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

.form-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    font-size: 0.9rem;
    color: var(--text-primary);
    transition: all var(--transition-fast);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-purple);
    background: var(--surface-2);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-tertiary);
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.username-input-wrapper {
    display: flex;
    align-items: center;
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: all var(--transition-fast);
}

.username-input-wrapper:focus-within {
    border-color: var(--accent-purple);
    background: var(--surface-2);
}

.username-prefix {
    padding: 12px 0 12px 14px;
    font-size: 0.9rem;
    color: var(--text-tertiary);
    white-space: nowrap;
}

.username-input-wrapper input {
    flex: 1;
    padding: 12px 14px 12px 0;
    border: none;
    background: transparent;
}

.username-input-wrapper input:focus {
    outline: none;
    border: none;
    background: transparent;
}

.form-group-checkbox {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.checkbox-label input {
    display: none;
}

.checkbox-custom {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    border: 2px solid var(--border-strong);
    background: var(--surface-1);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.checkbox-label input:checked + .checkbox-custom {
    background: var(--accent-purple);
    border-color: var(--accent-purple);
}

.checkbox-label input:checked + .checkbox-custom::after {
    content: '✓';
    color: white;
    font-size: 12px;
    font-weight: 700;
}

.form-group-checkbox .form-hint {
    width: 100%;
    margin-top: 4px;
}

.blog-form-error {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
    font-size: 0.85rem;
}

.blog-submit-btn {
    width: 100%;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    background: var(--gradient-brand);
    border: none;
    font-size: 0.95rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.blog-submit-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.blog-submit-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Blog Dashboard */
.blog-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.blog-stat {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

.blog-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.blog-stat-label {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.blog-actions {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.blog-action-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.blog-action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

.blog-action-btn.blog-action-primary {
    background: var(--gradient-brand);
    border-color: transparent;
    color: white;
}

.blog-action-btn.blog-action-primary:hover {
    opacity: 0.9;
}

/* Blog Posts List */
.blog-posts-list {
    border-top: 1px solid var(--border-subtle);
    padding-top: 20px;
}

.blog-posts-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 16px;
}

.blog-posts-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 16px;
    text-align: center;
    color: var(--text-tertiary);
}

.blog-posts-empty svg {
    opacity: 0.4;
}

.blog-posts-empty p {
    font-size: 0.9rem;
    margin: 0;
}

.blog-posts-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.blog-post-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.blog-post-item:hover {
    background: var(--bg-hover);
    border-color: var(--border-default);
}

.blog-post-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.blog-post-item-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.blog-post-item-meta {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.blog-post-item-status {
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.blog-post-item-status.draft {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

.blog-post-item-status.published {
    background: var(--accent-emerald-dim);
    color: var(--accent-emerald);
}

/* Blog Post Form */
.blog-post-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.blog-post-actions {
    display: flex;
    gap: 12px;
    margin-top: 8px;
}

.blog-draft-btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--surface-2);
    border: 1px solid var(--border-default);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.blog-draft-btn:hover {
    background: var(--bg-hover);
}

.blog-publish-btn {
    flex: 1;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--gradient-brand);
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.blog-publish-btn:hover {
    opacity: 0.9;
}

/* Melody Selector */
.melody-selector {
    background: var(--surface-1);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 20px;
}

.melody-selector-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    color: var(--text-tertiary);
}

.melody-selector-empty svg {
    opacity: 0.4;
}

.melody-selector-empty p {
    font-size: 0.85rem;
    margin: 0;
}

.melody-select-btn {
    padding: 10px 20px;
    border-radius: var(--radius-md);
    background: var(--surface-3);
    border: 1px solid var(--border-default);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.melody-select-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-strong);
}

.melody-selected {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.melody-selected-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.melody-selected-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.melody-selected-meta {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.melody-remove-btn {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: var(--surface-3);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.melody-remove-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

/* Melody Picker */
.melody-picker-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 10;
}

.melody-picker {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    max-height: 400px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.melody-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.melody-picker-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.melody-picker-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background: none;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.melody-picker-list {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.melody-picker-hint {
    font-size: 0.85rem;
    color: var(--text-tertiary);
    text-align: center;
    padding: 24px;
    margin: 0;
}

.melody-picker-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.melody-picker-item:hover {
    background: var(--bg-hover);
}

.melody-picker-item-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-purple-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.melody-picker-item-icon svg {
    width: 16px;
    height: 16px;
    color: var(--accent-purple);
}

.melody-picker-item-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.melody-picker-item-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.melody-picker-item-date {
    font-size: 0.72rem;
    color: var(--text-tertiary);
}

/* ============================================
   ACCOUNT DASHBOARD MODAL
   ============================================ */
.account-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.account-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.account-modal {
    position: relative;
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: 20px;
    padding: 32px;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(16px);
    transition: transform var(--transition-base);
}

.account-modal-overlay.active .account-modal {
    transform: translateY(0);
}

.account-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: all var(--transition-fast);
}

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

/* Account Header */
.account-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.account-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.3);
}

.account-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.account-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.account-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-email {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.account-plan-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 980px;
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    width: fit-content;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.account-plan-badge.plan-starter {
    background: rgba(34, 197, 94, 0.12);
    color: #22c55e;
    border-color: rgba(34, 197, 94, 0.3);
}

.account-plan-badge.plan-creator {
    background: var(--accent-purple-dim);
    color: var(--accent-purple);
    border-color: rgba(124, 106, 240, 0.3);
}

.account-plan-badge.plan-pro {
    background: rgba(232, 160, 32, 0.12);
    color: var(--accent-amber);
    border-color: rgba(232, 160, 32, 0.3);
}

/* Account Sections */
.account-section {
    margin-bottom: 24px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.account-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.account-section h3 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin: 0 0 16px;
}

.account-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.account-section-header h3 {
    margin-bottom: 0;
}

.account-credits-count {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-purple);
}

/* Credits Bar */
.credits-bar-container {
    margin-bottom: 16px;
}

.credits-bar {
    height: 8px;
    background: var(--surface-3);
    border-radius: var(--radius-full);
    overflow: hidden;
    margin-bottom: 8px;
}

.credits-bar-fill {
    height: 100%;
    background: var(--gradient-brand);
    border-radius: var(--radius-full);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 2px;
}

.credits-sublabel {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin: 0;
}

/* Buy Credits Button */
.buy-credits-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    background: var(--gradient-brand);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.buy-credits-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(124, 106, 240, 0.3);
}

.buy-credits-btn:active {
    transform: translateY(0);
}

/* Account Stats Grid */
.account-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.account-stat {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.account-stat-value {
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.account-stat-label {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    letter-spacing: 0.02em;
}

/* Payments List */
.payments-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 16px;
    color: var(--text-tertiary);
    text-align: center;
}

.payments-empty p {
    font-size: 0.85rem;
    margin: 0;
}

.payment-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    margin-bottom: 8px;
    transition: background var(--transition-fast);
}

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

.payment-row:last-child {
    margin-bottom: 0;
}

.payment-row-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.payment-plan-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-primary);
    text-transform: capitalize;
}

.payment-date {
    font-size: 0.7rem;
    color: var(--text-tertiary);
}

.payment-row-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.payment-credits {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--accent-emerald);
}

.payment-amount {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

/* Payment Toast */
.payment-toast {
    position: fixed;
    top: 72px;
    left: 50%;
    transform: translateX(-50%) translateY(-20px);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.payment-toast.visible {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.payment-toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 24px;
    background: rgba(22, 22, 22, 0.97);
    border: 1px solid rgba(34, 197, 94, 0.4);
    border-radius: var(--radius-full);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #22c55e;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
}

.payment-toast.toast-error .payment-toast-content {
    border-color: rgba(239, 68, 68, 0.4);
    color: #f87171;
}

/* Responsive Account Modal — handled in 768px block */

/* ═══════════════════════════════════════════════════════════════════════════
   IMAGE UPLOAD AREA — Image to Melody Mode
   ═══════════════════════════════════════════════════════════════════════════ */

.image-upload-area {
    display: none;
    width: 100%;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease both;
}

.image-upload-area.visible {
    display: block;
}

.image-upload-dropzone {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    padding: 24px;
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.image-upload-dropzone:hover {
    border-color: var(--accent-purple);
    background: rgba(124, 106, 240, 0.05);
}

.image-upload-dropzone.dragover {
    border-color: var(--accent-purple);
    background: rgba(124, 106, 240, 0.1);
    transform: scale(1.01);
}

.image-upload-dropzone.hidden {
    display: none;
}

.image-upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    color: var(--text-secondary);
}

.image-upload-content svg {
    color: var(--text-tertiary);
    opacity: 0.7;
}

.image-upload-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.image-upload-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin: 0;
}

.image-upload-error {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    font-size: 0.8rem;
    border-radius: var(--radius-full);
    animation: fadeInUp 0.2s ease;
}

/* Image Preview */
.image-preview-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.image-preview-container.hidden {
    display: none;
}

.image-preview-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
}

.image-preview-wrapper img {
    display: block;
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.image-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
    backdrop-filter: blur(8px);
}

.image-remove-btn:hover {
    background: rgba(239, 68, 68, 0.9);
    transform: scale(1.1);
}

/* Ready hint */
.image-ready-hint {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════
   VIDEO UPLOAD AREA (Pro Studio feature)
   ═══════════════════════════════════════════════════════════ */

.video-upload-area {
    display: none;
    width: 100%;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease both;
}

.video-upload-area.visible {
    display: block;
}

.video-upload-dropzone {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 180px;
    padding: 24px;
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.video-upload-dropzone:hover {
    border-color: var(--accent-orange, #f97316);
    background: rgba(249, 115, 22, 0.05);
}

.video-upload-dropzone.dragover {
    border-color: var(--accent-orange, #f97316);
    background: rgba(249, 115, 22, 0.1);
    transform: scale(1.01);
}

.video-upload-dropzone.hidden {
    display: none;
}

.video-upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    color: var(--text-secondary);
}

.video-upload-content svg {
    color: var(--accent-orange, #f97316);
    opacity: 0.8;
}

.video-upload-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.video-upload-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin: 0;
}

.video-upload-error {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    font-size: 0.8rem;
    border-radius: var(--radius-full);
    animation: fadeInUp 0.2s ease;
}

/* Video Preview */
.video-preview-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.video-preview-container.hidden {
    display: none;
}

.video-preview-wrapper {
    position: relative;
    display: inline-block;
    max-width: 100%;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
}

.video-preview-wrapper video {
    display: block;
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: var(--radius-lg);
}

.video-duration-badge {
    position: absolute;
    bottom: 8px;
    left: 8px;
    padding: 4px 10px;
    background: rgba(0, 0, 0, 0.75);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: var(--font-mono, monospace);
    border-radius: var(--radius-full);
    backdrop-filter: blur(8px);
}

.video-remove-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    cursor: pointer;
    transition: all var(--transition-fast);
    backdrop-filter: blur(8px);
}

.video-remove-btn:hover {
    background: rgba(239, 68, 68, 0.9);
    transform: scale(1.1);
}

.video-ready-hint {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════
   MIDI UPLOAD AREA (Melody Variation feature)
   ═══════════════════════════════════════════════════════════ */

.midi-upload-area {
    display: none;
    width: 100%;
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease both;
}

.midi-upload-area.visible {
    display: block;
}

.midi-upload-dropzone {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 140px;
    padding: 24px;
    border: 2px dashed var(--border-subtle);
    border-radius: var(--radius-lg);
    background: var(--surface-1);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.midi-upload-dropzone:hover {
    border-color: var(--accent-cyan, #06b6d4);
    background: rgba(6, 182, 212, 0.05);
}

.midi-upload-dropzone.dragover {
    border-color: var(--accent-cyan, #06b6d4);
    background: rgba(6, 182, 212, 0.1);
    transform: scale(1.01);
}

.midi-upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
    color: var(--text-secondary);
}

.midi-upload-content svg {
    color: var(--accent-cyan, #06b6d4);
    opacity: 0.8;
}

.midi-upload-label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    margin: 0;
}

.midi-upload-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin: 0;
}

.midi-upload-error {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(239, 68, 68, 0.9);
    color: white;
    font-size: 0.8rem;
    border-radius: var(--radius-full);
    animation: fadeInUp 0.2s ease;
}

/* MIDI Preview */
.midi-preview-container {
    display: none;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.midi-preview-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.midi-preview-info svg {
    flex-shrink: 0;
    color: var(--accent-cyan, #06b6d4);
}

.midi-preview-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.midi-preview-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.midi-preview-meta {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.midi-preview-remove {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.midi-preview-remove:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.3);
    color: var(--accent-rose, #f43f5e);
}

.midi-ready-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    text-align: center;
    margin: 0;
}

/* Analysis Status (legacy, can be removed) */
.image-analysis-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    font-size: 0.8rem;
}

.analysis-pending,
.analysis-complete,
.analysis-error {
    display: flex;
    align-items: center;
    gap: 8px;
}

.analysis-pending.hidden,
.analysis-complete.hidden,
.analysis-error.hidden {
    display: none;
}

.analysis-pending {
    color: var(--text-secondary);
}

.analysis-complete {
    color: var(--accent-emerald);
}

.analysis-error {
    color: var(--accent-rose);
}

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

/* Image Analysis Card */
.image-analysis-card {
    background: var(--surface-1);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.analysis-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-hover);
    border-bottom: 1px solid var(--border-subtle);
}

.analysis-badge {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--accent-emerald);
    display: flex;
    align-items: center;
    gap: 5px;
}

.analysis-badge::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--accent-emerald);
}

.analysis-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.analysis-tokens,
.analysis-latency,
.analysis-conf {
    font-size: 0.68rem;
    font-family: var(--font-mono);
    color: var(--text-tertiary);
    background: var(--surface-2);
    padding: 2px 7px;
    border-radius: var(--radius-sm);
}

.analysis-conf {
    color: var(--accent-amber, #f59e0b);
}

.analysis-content {
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 7px;
}

.analysis-divider {
    height: 1px;
    background: var(--border-subtle);
    margin: 4px 0;
}

.analysis-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 0.77rem;
    line-height: 1.5;
}

.analysis-row--usr .analysis-label {
    color: var(--accent-cyan, #06b6d4);
}

.analysis-row--mus .analysis-label {
    color: var(--accent-purple);
}

.analysis-label {
    flex-shrink: 0;
    font-weight: 500;
    color: var(--text-tertiary);
    min-width: 76px;
    padding-top: 2px;
}

.analysis-value {
    color: var(--text-secondary);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
}

.analysis-tag {
    display: inline-block;
    padding: 1px 7px;
    background: var(--surface-2);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    font-size: 0.72rem;
    color: var(--text-primary);
    white-space: nowrap;
}

.analysis-tag--mus {
    border-color: rgba(124, 106, 240, 0.3);
    color: var(--accent-purple);
    background: rgba(124, 106, 240, 0.08);
}

.analysis-tag--archetype {
    border-color: rgba(240, 180, 106, 0.4);
    color: #f0b46a;
    background: rgba(240, 180, 106, 0.12);
    font-weight: 500;
    text-transform: capitalize;
}

.analysis-conf-small {
    font-size: 0.65rem;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    margin-left: 6px;
    opacity: 0.7;
}

.analysis-intensity {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
    padding-left: 2px;
}

/* ─── Mobile: Upload dropzones → compact "Attach" buttons ─── */
@media (max-width: 768px) {

    /* Shared compact button shape */
    .image-upload-dropzone,
    .video-upload-dropzone,
    .midi-upload-dropzone {
        min-height: 52px;
        height: 52px;
        padding: 0;
        border: 1px solid var(--border-default);
        border-radius: var(--radius-md);
        background: var(--surface-2);
        justify-content: flex-start;
        transition: background 0.15s ease, border-color 0.15s ease, transform 0.1s ease;
    }

    /* Tap feedback */
    .image-upload-dropzone:active,
    .video-upload-dropzone:active,
    .midi-upload-dropzone:active {
        transform: scale(0.97);
    }

    /* Hover accent per type */
    .image-upload-dropzone:hover {
        border-color: rgba(124, 106, 240, 0.45);
        background: rgba(124, 106, 240, 0.04);
    }
    .video-upload-dropzone:hover {
        border-color: rgba(249, 115, 22, 0.45);
        background: rgba(249, 115, 22, 0.04);
    }
    .midi-upload-dropzone:hover {
        border-color: rgba(6, 182, 212, 0.45);
        background: rgba(6, 182, 212, 0.04);
    }

    /* No drag-scale feedback on touch */
    .image-upload-dropzone.dragover,
    .video-upload-dropzone.dragover,
    .midi-upload-dropzone.dragover {
        transform: none;
    }

    /* Horizontal row */
    .image-upload-content,
    .video-upload-content,
    .midi-upload-content {
        flex-direction: row;
        align-items: center;
        gap: 12px;
        padding: 0 16px;
        width: 100%;
        height: 100%;
    }

    /* Existing icon: shrink, keep accent colour */
    .image-upload-content > svg,
    .video-upload-content > svg,
    .midi-upload-content > svg {
        width: 18px !important;
        height: 18px !important;
        flex-shrink: 0;
        opacity: 0.75;
    }

    /* Label: hide original long text, replace with short mobile text */
    .image-upload-label,
    .video-upload-label,
    .midi-upload-label {
        font-size: 0;   /* hide native text */
        flex: 1;
        text-align: left;
    }

    .image-upload-label::before {
        content: 'Attach image';
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--text-primary);
    }

    .video-upload-label::before {
        content: 'Attach video';
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--text-primary);
    }

    .midi-upload-label::before {
        content: 'Attach MIDI';
        font-size: 0.875rem;
        font-weight: 500;
        color: var(--text-primary);
    }

    /* Hide format hint (not relevant on mobile) */
    .image-upload-hint,
    .video-upload-hint,
    .midi-upload-hint {
        display: none;
    }

    /* Chevron → signals it's tappable */
    .image-upload-content::after,
    .video-upload-content::after,
    .midi-upload-content::after {
        content: '›';
        font-size: 1.5rem;
        font-weight: 300;
        line-height: 1;
        color: var(--text-tertiary);
        margin-left: auto;
    }

    /* Preview images/analysis stay compact */
    .image-preview-wrapper img {
        max-height: 200px;
    }

    .analysis-row {
        flex-direction: column;
        gap: 2px;
    }

    .analysis-label {
        min-width: auto;
    }
}

/* ============================================
   SITE FOOTER — shared across all pages
   ============================================ */

/* Base styles (blog / news / subscription) */
.site-footer {
    border-top: 1px solid var(--border-subtle, rgba(255,255,255,0.05));
    padding: 14px 20px;
    text-align: center;
    margin-top: auto;
    flex-shrink: 0;
}

/* Welcome-screen variant: sits inside .welcome-screen,
   no border, transparent, aligned to the bottom of the screen */
.site-footer--welcome {
    border-top: none;
    padding: 10px 20px 12px;
    margin-top: 0;
    width: 100%;
}

.site-footer-nav {
    display: flex;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 3px;
}

.site-footer-nav a {
    color: var(--text-tertiary, rgba(255,255,255,0.3));
    text-decoration: none;
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    transition: color 0.15s ease;
}

.site-footer-nav a:hover,
.site-footer-nav a[aria-current="page"] {
    color: var(--text-secondary, rgba(255,255,255,0.5));
}

.site-footer-copy {
    color: var(--text-tertiary, rgba(255,255,255,0.22));
    font-size: 0.62rem;
    margin: 0;
}

/* ============================================
   GLOBAL RESPONSIVE ENHANCEMENTS
   Overflow protection, touch, accessibility
   ============================================ */

/* Prevent horizontal overflow globally */
html {
    overflow-x: hidden;
}

/* Improve tap highlight on mobile */
@media (hover: none) and (pointer: coarse) {
    button, a, [role="button"] {
        -webkit-tap-highlight-color: rgba(124, 106, 240, 0.15);
    }

    .conversation-item-actions {
        opacity: 1;
        pointer-events: auto;
    }
}

/* Bottom sheet drag handle indicator for mobile modals */
@media (max-width: 768px) {
    .login-modal::before,
    .pricing-modal::before,
    .account-modal::before,
    .blog-modal::before,
    .composer-modal::before,
    .settings-modal::before,
    .melody-picker-modal::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: rgba(255, 255, 255, 0.2);
        border-radius: 2px;
        margin: 0 auto 16px;
        flex-shrink: 0;
    }
}

/* Prevent content overflow — avatars and contained images use their own sizing */
img:not([class]),
video:not([class]) {
    max-width: 100%;
}

/* Accessible reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    .brand-name {
        animation: none;
    }
}

/* Landscape phone optimization */
@media (max-height: 500px) and (orientation: landscape) {
    .welcome-logo-anim {
        display: none;
    }

    .welcome-screen {
        padding: 8px 16px;
    }

    .welcome-title {
        font-size: 1rem;
        margin-bottom: 4px;
    }

    .welcome-subtitle {
        margin-bottom: 8px;
    }

    .feature-card {
        padding: 8px 12px;
    }

    .brand-header {
        height: 44px;
    }

    .cookie-banner,
    body:not(.sidebar-collapsed) .cookie-banner,
    body.sidebar-collapsed .cookie-banner {
        top: 44px;
    }

    .main {
        padding-top: 44px;
    }

    .login-modal,
    .pricing-modal,
    .account-modal,
    .blog-modal {
        max-height: 100vh;
        max-height: 100dvh;
    }
}

/* Site footer responsive */
@media (max-width: 768px) {
    .site-footer {
        padding-left: max(16px, env(safe-area-inset-left));
        padding-right: max(16px, env(safe-area-inset-right));
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
}

