:root {
    --bg-dark: #0b0d14;
    --bg-card: rgba(18, 22, 34, 0.75);
    --bg-card-border: rgba(168, 85, 247, 0.2);
    
    --accent-purple: #a855f7;
    --accent-cyan: #06b6d4;
    --accent-pink: #ec4899;
    --accent-green: #10b981;
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    
    --glow-purple: 0 0 20px rgba(168, 85, 247, 0.35);
    --glow-cyan: 0 0 20px rgba(6, 182, 212, 0.35);
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(168, 85, 247, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.08) 0%, transparent 40%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Layout */
.app-container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    gap: 1.5rem;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1fr solid var(--bg-card-border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.logo-glow {
    position: absolute;
    width: 32px;
    height: 32px;
    background: var(--accent-purple);
    border-radius: 50%;
    filter: blur(12px);
    opacity: 0.7;
}

.logo-text {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: #fff;
    position: relative;
}

.logo-text span {
    color: var(--accent-cyan);
    text-shadow: 0 0 10px rgba(6, 182, 212, 0.6);
}

.badge {
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    background: rgba(168, 85, 247, 0.15);
    border: 1px solid var(--accent-purple);
    color: var(--accent-purple);
    border-radius: 20px;
    text-transform: uppercase;
}

/* Main Workspace */
.workspace {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    flex: 1;
}

/* Cards & Glassmorphism */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    border: 1px solid var(--bg-card-border);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    transition: border-color var(--transition-fast);
}

.card:hover {
    border-color: rgba(168, 85, 247, 0.4);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.card-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
}

/* Dropzone & Textarea */
.dropzone {
    position: relative;
    flex: 1;
    display: flex;
}

textarea {
    width: 100%;
    height: 100%;
    min-height: 380px;
    background: transparent;
    border: none;
    padding: 1.5rem;
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    font-size: 1rem;
    line-height: 1.6;
    resize: none;
    outline: none;
}

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

.dropzone-overlay {
    position: absolute;
    inset: 0;
    background: rgba(11, 13, 20, 0.85);
    backdrop-filter: blur(8px);
    border: 2px dashed var(--accent-cyan);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    color: var(--accent-cyan);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
}

.dropzone.dragover .dropzone-overlay {
    opacity: 1;
}

/* Output Area */
.output-wrapper {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    min-height: 380px;
    max-height: 550px;
    font-size: 1rem;
    line-height: 1.6;
}

.output-content {
    white-space: pre-wrap;
    word-break: break-word;
}

.placeholder-text {
    color: var(--text-dim);
    font-style: italic;
}

/* Diff Styling */
.diff-removed {
    background: rgba(236, 72, 153, 0.25);
    color: #f472b6;
    text-decoration: line-through;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
}

.diff-added {
    background: rgba(16, 185, 129, 0.25);
    color: #34d399;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
}

/* Card Footers */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(10, 12, 18, 0.4);
}

.char-count {
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Buttons & UI Controls */
.btn-group {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 2.75rem; /* Strict mobile target >= 2.75rem */
    padding: 0 1.25rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
    color: #fff;
    box-shadow: var(--glow-purple);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 0 25px rgba(168, 85, 247, 0.6);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
    min-height: 2.5rem;
    padding: 0 0.875rem;
    font-size: 0.85rem;
}

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

/* Spinner */
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* View Toggle Tabs */
.view-toggle {
    display: flex;
    background: rgba(0, 0, 0, 0.3);
    padding: 0.25rem;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.toggle-tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.4rem 0.875rem;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toggle-tab.active {
    background: var(--accent-purple);
    color: #fff;
    box-shadow: 0 0 12px rgba(168, 85, 247, 0.4);
}

/* Stats Pills */
.stats-pills {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.pill {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.6rem;
    border-radius: 20px;
}

.pill-pink { background: rgba(236, 72, 153, 0.15); color: var(--accent-pink); border: 1px solid rgba(236, 72, 153, 0.3); }
.pill-cyan { background: rgba(6, 182, 212, 0.15); color: var(--accent-cyan); border: 1px solid rgba(6, 182, 212, 0.3); }
.pill-purple { background: rgba(168, 85, 247, 0.15); color: var(--accent-purple); border: 1px solid rgba(168, 85, 247, 0.3); }

/* History Drawer */
.history-drawer {
    position: fixed;
    top: 0;
    right: -380px;
    width: 360px;
    height: 100vh;
    background: #0f121d;
    border-left: 1px solid var(--bg-card-border);
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.6);
    z-index: 100;
    display: flex;
    flex-direction: column;
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.history-drawer.open {
    right: 0;
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.drawer-body {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.history-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    padding: 0.875rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.history-card:hover {
    border-color: var(--accent-purple);
    background: rgba(168, 85, 247, 0.08);
}

.history-card-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.history-card-preview {
    font-size: 0.875rem;
    color: var(--text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.drawer-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

/* Custom Neon Modal */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(5, 6, 10, 0.85);
    backdrop-filter: blur(12px);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-box {
    width: 90%;
    max-width: 440px;
    background: #121624;
    border: 1px solid var(--accent-purple);
    box-shadow: 0 0 30px rgba(168, 85, 247, 0.4);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transform: scale(0.9);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-backdrop.active .modal-box {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.modal-header h3 {
    font-size: 1.1rem;
    color: var(--accent-purple);
}

.modal-body {
    padding: 1.5rem 1.25rem;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-main);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    padding: 1rem 1.25rem;
    background: rgba(0, 0, 0, 0.3);
}

.btn-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}

.btn-close:hover {
    color: #fff;
}

/* Mobile Adaptivity (90-95% screen width constraint) */
@media (max-width: 900px) {
    .app-container {
        width: 94%; /* 94% width on mobile per user_global rule! */
        padding: 0.75rem 0;
    }
    
    .workspace {
        grid-template-columns: 1fr;
    }
    
    .history-drawer {
        width: 90vw;
        right: -95vw;
    }
}
