@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=Space+Mono:wght@400;700&display=swap');

:root {
    --primary-gradient: linear-gradient(135deg, #f59e0b 0%, #ef4444 100%);
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #f59e0b;
    --accent-2: #ef4444;
    --border: rgba(255, 255, 255, 0.1);
    --shadow-premium: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.15);
    --panel-bg: rgba(255, 255, 255, 0.03);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 2rem;
}

/* ── Background Blobs ── */
.bg-blobs {
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    overflow: hidden;
}

.blob {
    position: absolute;
    width: 700px;
    height: 700px;
    background: var(--primary-gradient);
    filter: blur(150px);
    opacity: 0.1;
    border-radius: 50%;
    top: -200px;
    left: -200px;
    animation: blobFloat 14s ease-in-out infinite alternate;
}

.blob-2 {
    bottom: -200px;
    right: -200px;
    top: auto;
    left: auto;
    background: linear-gradient(135deg, #a855f7 0%, #3b82f6 100%);
    animation-delay: -7s;
}

@keyframes blobFloat {
    from {
        transform: translate(0, 0) scale(1);
    }

    to {
        transform: translate(40px, 25px) scale(1.06);
    }
}

/* ── Container ── */
.tool-container {
    width: 100%;
    max-width: 1100px;
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border);
    border-radius: 28px;
    padding: 3rem;
    box-shadow: var(--shadow-premium);
    margin: 1rem auto;
}

/* ── Header ── */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

.header-icon {
    font-size: 2.2rem;
    font-weight: 800;
    font-family: 'Space Mono', monospace;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    display: block;
    margin-bottom: 0.6rem;
    letter-spacing: -0.05em;
}

.header h1 {
    font-size: 2.4rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 0.5rem;
}

.header p {
    color: var(--text-secondary);
    font-size: 1.05rem;
}

/* ── Mode Toggle ── */
.mode-toggle {
    display: flex;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 6px;
    margin: 0 auto 1.5rem;
    width: fit-content;
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.6rem 1.5rem;
    border-radius: 11px;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    transition: all 0.25s ease;
}

.mode-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.mode-btn.active {
    background: var(--primary-gradient);
    color: #fff;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

/* ── Stats Bar ── */
.stats-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.025);
    border: 1px solid var(--border);
    border-radius: 16px;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}

.stat-val {
    font-size: 1.1rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    font-family: 'Space Mono', monospace;
    color: var(--text-secondary);
    transition: all 0.3s;
}

.stat-item.saving .stat-val {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.stat-lbl {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-secondary);
}

.stat-divider {
    width: 1px;
    height: 36px;
    background: var(--border);
    flex-shrink: 0;
}

.stats-bar.active .stat-val {
    color: var(--text-primary);
}

/* ── Editor Layout ── */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 1rem;
    align-items: start;
}

/* ── Editor Panels ── */
.editor-panel {
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 1.25rem 1.5rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.editor-panel:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.08);
}

.output-panel {
    border-color: rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.03);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.panel-header label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-secondary);
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

textarea {
    width: 100%;
    height: 380px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: 'Space Mono', monospace;
    font-size: 0.85rem;
    resize: vertical;
    outline: none;
    line-height: 1.65;
    min-height: 200px;
}

textarea::placeholder {
    color: rgba(148, 163, 184, 0.4);
}

/* ── Process Bar (center) ── */
.process-bar {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding-top: 3.5rem;
    gap: 0.75rem;
}

.process-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--primary-gradient);
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.35);
    transition: all 0.25s ease;
    flex-shrink: 0;
}

.process-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.45);
}

.process-btn:active {
    transform: scale(0.96);
}

.btn-icon {
    flex-shrink: 0;
}

/* ── Action Buttons ── */
.action-link {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.2s;
}

.action-link:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.07);
}

.action-link.danger:hover {
    color: #f87171;
    background: rgba(248, 113, 113, 0.08);
}

.copy-btn,
.download-btn {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border);
    color: var(--text-primary);
    padding: 0.38rem 0.85rem;
    border-radius: 9px;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s;
}

.copy-btn:hover {
    background: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.3);
}

.download-btn:hover {
    background: rgba(59, 130, 246, 0.8);
    border-color: rgba(59, 130, 246, 0.8);
}

.copy-btn.copied {
    background: #10b981;
    border-color: #10b981;
}

/* ── Error Box ── */
.error-box {
    margin-top: 1rem;
    padding: 1rem 1.25rem;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    border-radius: 12px;
    color: #fca5a5;
    font-size: 0.9rem;
    font-family: 'Space Mono', monospace;
}

/* ── Info Section ── */
.info-section {
    margin-top: 2rem;
    padding: 1.5rem 2rem;
    background: rgba(245, 158, 11, 0.05);
    border-radius: 18px;
    border: 1px solid rgba(245, 158, 11, 0.15);
}

.info-section h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 0.6rem;
    color: #fcd34d;
}

.info-section p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.7;
}

/* ── Responsive ── */
@media (max-width: 900px) {
    .editor-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto auto auto;
    }

    .process-bar {
        flex-direction: row;
        padding-top: 0;
        justify-content: center;
    }

    .process-btn {
        width: auto;
        height: auto;
        border-radius: 14px;
        padding: 0.8rem 2.5rem;
        flex-direction: row;
        font-size: 0.95rem;
        gap: 0.5rem;
    }
}

@media (max-width: 640px) {
    body {
        padding: 1rem;
    }

    .tool-container {
        padding: 1.5rem 1.25rem;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .mode-toggle {
        width: 100%;
    }

    .mode-btn {
        flex: 1;
        justify-content: center;
    }

    .stats-bar {
        gap: 0.75rem;
    }

    .stat-divider {
        display: none;
    }

    textarea {
        height: 250px;
    }
}