/* ============================================
   CringeKill
   Kill Boring. Get Read.
   ============================================ */

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

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Dark Theme Colors */
    --bg-primary: #0f0f13;
    --bg-secondary: #18181f;
    --bg-tertiary: #1f1f27;
    --bg-card: #1a1a22;
    --bg-input: #1e1e28;
    --bg-hover: #2a2a35;
    --bg-sidebar: #141419;

    /* Text */
    --text-primary: #ffffff;
    --text-secondary: rgba(255,255,255,0.7);
    --text-tertiary: rgba(255,255,255,0.5);
    --text-muted: rgba(255,255,255,0.35);

    /* Accents - Blood Red for "Kill" theme */
    --accent: #dc2626;
    --accent-hover: #ef4444;
    --accent-glow: rgba(220,38,38,0.25);
    --accent-secondary: #991b1b;

    /* Borders */
    --border-color: rgba(255,255,255,0.08);
    --border-light: rgba(255,255,255,0.05);

    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-serif: 'Cormorant Garamond', Georgia, serif;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

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

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    font-size: 14px;
    height: 100vh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

/* ============================================
   App Layout
   ============================================ */

.app-layout {
    display: none; /* Hidden by default, shown after Clerk auth check */
    height: 100vh;
}

/* ============================================
   Sidebar
   ============================================ */

.sidebar {
    width: 240px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: var(--space-5) var(--space-5);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.sidebar-logo {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Search box */
.sidebar-search {
    padding: 0 var(--space-4) var(--space-4);
}

.sidebar-search input {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    padding-left: 36px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='rgba(255,255,255,0.4)' viewBox='0 0 24 24'%3E%3Cpath d='M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z' stroke='rgba(255,255,255,0.4)' stroke-width='2' fill='none'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 12px center;
}

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

.sidebar-search input:focus {
    outline: none;
    border-color: var(--accent);
}

.sidebar-nav {
    padding: var(--space-2) var(--space-3);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    text-align: left;
    width: 100%;
}

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

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

.sidebar-item svg {
    flex-shrink: 0;
    opacity: 0.6;
    width: 18px;
    height: 18px;
}

.sidebar-item:hover svg,
.sidebar-item.active svg {
    opacity: 1;
}

/* Chat History in Sidebar */
.sidebar-history {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-3);
    border-top: 1px solid var(--border-color);
    margin-top: var(--space-2);
    display: flex;
    flex-direction: column;
}

.new-chat-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    width: 100%;
    padding: var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: var(--space-3);
    transition: all var(--transition-fast);
}

.new-chat-btn:hover {
    background: var(--bg-hover);
    border-color: var(--text-tertiary);
}

#chat-history-list {
    flex: 1;
    overflow-y: auto;
}

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

.sidebar-history-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: var(--space-2) var(--space-2);
}

.sidebar-history-item {
    display: block;
    padding: var(--space-2) var(--space-2);
    color: var(--text-tertiary);
    font-size: 13px;
    text-decoration: none;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

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

.empty-history {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: var(--space-4);
}

/* User Profile at bottom */
.sidebar-user {
    padding: var(--space-4);
    border-top: 1px solid var(--border-color);
}

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

.user-avatar {
    flex-shrink: 0;
}

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

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

.user-plan {
    font-size: 12px;
    color: var(--text-muted);
}

/* ============================================
   Main Content
   ============================================ */

.main-content {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    position: relative;
}

.panel {
    display: none;
    height: 100%;
    overflow-y: auto;
    padding: var(--space-8);
    position: relative;
}

.panel.active {
    display: flex;
    flex-direction: column;
}

.panel-header {
    margin-bottom: var(--space-6);
}

.panel-header h2 {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
}

/* ============================================
   Chat Panel
   ============================================ */

#chat-panel {
    padding: 0;
    background: var(--bg-primary);
}

#chat-panel.active {
    display: flex;
}

.chat-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    position: relative;
    justify-content: center;
    background: transparent;
}

/* Top header with AI Assistant dropdown */
.chat-header {
    display: flex;
    align-items: center;
    padding: var(--space-4) var(--space-6);
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
}

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

.chat-header span {
    display: none;
}

#chat-style-select {
    padding: var(--space-3) var(--space-5);
    padding-right: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all var(--transition-fast);
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='white' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
}

#chat-style-select:hover {
    border-color: var(--text-tertiary);
}

#chat-style-select:focus {
    outline: none;
    border-color: var(--accent);
}

.chat-header .btn-secondary {
    display: none;
}

/* Chat messages area */
.chat-messages {
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--space-4);
    padding-bottom: 0;
    background: transparent;
}

/* Welcome State - Centered */
.chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 0;
    max-width: 700px;
    overflow: visible;
}

/* Blood Red Orb - Kill Theme */
.chat-orb {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    margin-bottom: var(--space-6);
    background:
        radial-gradient(circle at 30% 30%, rgba(255,255,255,0.3) 0%, transparent 50%),
        radial-gradient(circle at 70% 80%, rgba(220,38,38,0.8) 0%, transparent 40%),
        radial-gradient(circle at 20% 70%, rgba(153,27,27,0.7) 0%, transparent 40%),
        radial-gradient(circle at 80% 30%, rgba(248,113,113,0.6) 0%, transparent 40%),
        linear-gradient(135deg, #7f1d1d 0%, #dc2626 30%, #ef4444 50%, #991b1b 70%, #450a0a 100%);
    box-shadow:
        0 0 80px rgba(220,38,38,0.4),
        0 0 120px rgba(153,27,27,0.3),
        inset 0 -30px 60px rgba(0,0,0,0.4),
        inset 0 10px 30px rgba(255,255,255,0.15);
    animation: float 6s ease-in-out infinite, pulse 3s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { box-shadow: 0 0 80px rgba(220,38,38,0.4), 0 0 120px rgba(153,27,27,0.3), inset 0 -30px 60px rgba(0,0,0,0.4), inset 0 10px 30px rgba(255,255,255,0.15); }
    50% { box-shadow: 0 0 100px rgba(220,38,38,0.6), 0 0 150px rgba(153,27,27,0.4), inset 0 -30px 60px rgba(0,0,0,0.4), inset 0 10px 30px rgba(255,255,255,0.15); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.chat-welcome-text {
    font-family: var(--font-serif);
    font-size: 32px;
    font-weight: 500;
    line-height: 1.2;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.chat-welcome-text span {
    display: block;
}

/* Conversation Mode - Messages */
.chat-messages.has-messages {
    flex: 1;
    overflow-y: auto;
    justify-content: flex-start;
    padding-top: var(--space-4);
    gap: var(--space-4);
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
}

.chat-messages.has-messages .chat-welcome {
    display: none;
}

.chat-message {
    max-width: 85%;
    padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-lg);
    line-height: 1.6;
    font-size: 14px;
}

.chat-message.user {
    align-self: flex-end;
    background: var(--accent);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.chat-message.assistant {
    align-self: flex-start;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border-bottom-left-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.message-content {
    white-space: pre-wrap;
}

.message-content strong {
    font-weight: 600;
}

.chat-message-actions {
    display: flex;
    gap: var(--space-2);
    margin-top: var(--space-2);
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.chat-message:hover .chat-message-actions {
    opacity: 1;
}

.btn-regenerate, .btn-edit, .btn-copy-chat {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-1);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.btn-regenerate:hover, .btn-copy-chat:hover {
    color: var(--text-primary);
}

.btn-edit:hover, .chat-message.user .btn-copy-chat:hover {
    color: rgba(255,255,255,0.8);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: var(--space-3) var(--space-4);
    align-self: flex-start;
    background: var(--bg-tertiary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ============================================
   Chat Input - Large Box Style
   ============================================ */

.chat-input-container {
    padding: var(--space-2) var(--space-8);
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
}

.chat-input-box {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: var(--space-4);
    min-height: 100px;
    display: flex;
    flex-direction: column;
    transition: all var(--transition-fast);
}

.chat-input-box:focus-within {
    border-color: var(--text-tertiary);
}

.chat-input-container textarea {
    width: 100%;
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    outline: none;
    line-height: 1.5;
}

.chat-input-container textarea::placeholder {
    color: var(--text-muted);
}

.chat-input-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: var(--space-4);
    padding-top: var(--space-3);
}

.chat-input-left-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.chat-input-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.chat-input-btn svg {
    width: 16px;
    height: 16px;
    opacity: 0.7;
}

.chat-input-btn.icon-only {
    padding: var(--space-2);
    width: 36px;
    height: 36px;
    justify-content: center;
}

.chat-input-right-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

/* Attached file indicator */
.attached-file {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--bg-tertiary);
    border: 1px solid var(--accent);
    border-radius: var(--radius-full);
    font-size: 12px;
    color: var(--text-primary);
    margin-left: var(--space-2);
}

.attached-file-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attached-file-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attached-file-remove:hover {
    color: var(--text-primary);
}

.chat-input-container .btn-primary {
    padding: var(--space-3) var(--space-5);
    background: var(--accent);
    border: none;
    border-radius: var(--radius-full);
    color: white;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chat-input-container .btn-primary:hover {
    background: var(--accent-hover);
}

/* ============================================
   Feature Cards
   ============================================ */

.feature-cards {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-3);
    max-width: 900px;
    margin: 0 auto;
    padding: 0 var(--space-8) var(--space-6);
}

.feature-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.feature-card:hover {
    border-color: var(--text-tertiary);
    background: var(--bg-tertiary);
}

.feature-card-title {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.feature-card-title svg {
    color: var(--accent);
    flex-shrink: 0;
    width: 14px;
    height: 14px;
}

.feature-card-desc {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: var(--space-1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.feature-card.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.feature-card.disabled:hover {
    border-color: var(--border-color);
    background: var(--bg-secondary);
}

/* Edit Textarea */
.edit-textarea {
    width: 100%;
    min-height: 150px;
    padding: var(--space-4);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--radius-md);
    background: rgba(255,255,255,0.1);
    color: white;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    margin-bottom: var(--space-3);
    line-height: 1.5;
}

.edit-textarea:focus {
    outline: none;
    border-color: rgba(255,255,255,0.4);
}

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

/* ============================================
   Buttons
   ============================================ */

.btn-primary {
    padding: var(--space-3) var(--space-5);
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    padding: var(--space-2) var(--space-4);
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

.btn-icon {
    padding: var(--space-2);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-tertiary);
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

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

.btn-text {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 13px;
    cursor: pointer;
    padding: var(--space-1) 0;
}

.btn-text:hover {
    text-decoration: underline;
}

/* ============================================
   Form Elements
   ============================================ */

.input-section {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-6);
    margin-bottom: var(--space-6);
    max-width: 800px;
    border: 1px solid var(--border-color);
}

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

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--space-2);
    color: var(--text-secondary);
    font-size: 13px;
}

select, textarea, input[type="text"] {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    transition: all var(--transition-fast);
    background: var(--bg-input);
    color: var(--text-primary);
}

select:focus, textarea:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--accent);
}

textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

textarea::placeholder {
    color: var(--text-muted);
}

.form-row {
    display: flex;
    gap: var(--space-4);
    margin-bottom: var(--space-5);
}

.form-row .form-group {
    flex: 1;
    margin-bottom: 0;
}

/* ============================================
   Results & Content Sections
   ============================================ */

.results-section {
    margin-bottom: var(--space-6);
    max-width: 800px;
}

.results-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: var(--space-4);
    color: var(--text-primary);
}

.outline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.outline-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    border: 1px solid var(--border-color);
}

.outline-content h2 {
    font-size: 16px;
    color: var(--accent);
    margin-top: var(--space-5);
    margin-bottom: var(--space-3);
    padding-bottom: var(--space-2);
    border-bottom: 1px solid var(--border-color);
}

.outline-content h2:first-child {
    margin-top: 0;
}

.outline-content ul, .outline-content ol {
    margin: 0;
    padding-left: var(--space-5);
}

.outline-content li {
    margin-bottom: var(--space-2);
    line-height: 1.6;
    color: var(--text-secondary);
}

/* Suggested Content */
.suggested-content-section {
    margin-top: var(--space-6);
}

.suggested-content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.suggested-content-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
    margin: 0;
}

.suggested-content-box {
    background: linear-gradient(135deg, rgba(220,38,38,0.08) 0%, rgba(153,27,27,0.04) 100%);
    border: 1px solid rgba(220,38,38,0.15);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
}

.suggested-content-box ul {
    margin: 0;
    padding-left: var(--space-5);
}

.suggested-content-box li {
    margin-bottom: var(--space-2);
    line-height: 1.6;
}

.refine-content-section {
    display: flex;
    gap: var(--space-3);
    margin-bottom: var(--space-4);
    align-items: flex-start;
}

.feedback-textarea {
    flex: 1;
    min-height: 70px;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    background: var(--bg-input);
    color: var(--text-primary);
}

.feedback-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

/* Content Version History */
.content-version {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-2);
}

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

.version-label {
    background: var(--bg-hover);
    color: var(--text-secondary);
    padding: var(--space-1) var(--space-2);
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-weight: 600;
}

.version-feedback {
    color: var(--text-tertiary);
    font-size: 12px;
    font-style: italic;
}

/* ============================================
   Post Cards
   ============================================ */

.post-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    margin-bottom: var(--space-4);
    border: 1px solid var(--border-color);
    transition: all var(--transition-base);
}

.post-card:hover {
    border-color: var(--text-tertiary);
}

.post-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.post-number {
    font-weight: 600;
    color: var(--accent);
    font-size: 13px;
}

.post-actions {
    display: flex;
    gap: var(--space-1);
}

.post-content {
    background: var(--bg-tertiary);
    padding: var(--space-4);
    border-radius: var(--radius-md);
    white-space: pre-wrap;
    font-size: 14px;
    line-height: 1.7;
    margin-bottom: var(--space-4);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
}

.refine-section {
    display: flex;
    gap: var(--space-3);
}

.refine-input {
    flex: 1;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 13px;
    background: var(--bg-input);
    color: var(--text-primary);
}

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

/* ============================================
   History Section
   ============================================ */

.history-container-panel {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    max-width: 800px;
    border: 1px solid var(--border-color);
}

.history-item {
    padding: var(--space-4) 0;
    border-bottom: 1px solid var(--border-color);
}

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

.history-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.history-style {
    background: linear-gradient(135deg, rgba(220,38,38,0.15) 0%, rgba(153,27,27,0.08) 100%);
    color: var(--accent);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
}

.history-date {
    color: var(--text-muted);
    font-size: 12px;
}

.history-preview {
    color: var(--text-tertiary);
    font-size: 13px;
    margin-bottom: var(--space-2);
    line-height: 1.5;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: var(--space-8);
    font-size: 14px;
}

/* ============================================
   Loading & Toast
   ============================================ */

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 19, 0.95);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: var(--space-4);
}

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

.loading-overlay p {
    color: var(--text-secondary);
    font-size: 13px;
}

.toast {
    position: fixed;
    bottom: var(--space-6);
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1001;
    font-size: 13px;
    font-weight: 500;
}

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

/* ============================================
   Auth Overlay (Clerk)
   ============================================ */

.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.auth-container {
    text-align: center;
    max-width: 400px;
    width: 100%;
    padding: var(--space-6);
}

.auth-header {
    margin-bottom: var(--space-8);
}

.auth-header h1 {
    font-size: 32px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-2);
}

.auth-header p {
    color: var(--text-tertiary);
    font-size: 15px;
}

/* Clerk component styling overrides */
#user-button-container {
    display: flex;
    align-items: center;
}

/* ============================================
   Utility Classes
   ============================================ */

.hidden {
    display: none !important;
}

/* ============================================
   Responsive Design
   ============================================ */

@media (max-width: 1024px) {
    .sidebar {
        width: 220px;
    }

    .feature-cards {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
    }

    .sidebar-header {
        display: none;
    }

    .sidebar-search,
    .sidebar-history,
    .sidebar-user {
        display: none;
    }

    .sidebar-nav {
        flex-direction: row;
        overflow-x: auto;
        padding: var(--space-2) var(--space-4);
        gap: var(--space-2);
    }

    .sidebar-item {
        padding: var(--space-3) var(--space-4);
        white-space: nowrap;
        flex-shrink: 0;
    }

    .sidebar-item svg {
        display: none;
    }

    .main-content {
        height: calc(100vh - 50px);
    }

    .panel {
        padding: var(--space-4);
    }

    .chat-welcome-text {
        font-size: 28px;
    }

    .chat-orb {
        width: 80px;
        height: 80px;
    }

    .chat-input-container {
        padding: var(--space-4);
    }

    .chat-input-box {
        min-height: 100px;
    }

    .feature-cards {
        grid-template-columns: 1fr;
        padding: 0 var(--space-4) var(--space-4);
    }

    .form-row {
        flex-direction: column;
    }

    .refine-section {
        flex-direction: column;
    }

    .input-section {
        padding: var(--space-4);
    }
}
