:root {
    --bg-color: #0f1115;
    --panel-bg: rgba(23, 25, 30, 0.6);
    --panel-border: rgba(255, 255, 255, 0.08);
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #1e293b;
    --input-bg: rgba(15, 17, 21, 0.7);
    --input-border: rgba(255, 255, 255, 0.1);
    --input-focus: rgba(99, 102, 241, 0.5);
    --error: #ef4444;
    
    --glow-1: rgba(99, 102, 241, 0.2);
    --glow-2: rgba(168, 85, 247, 0.2);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Background Animated Orbs */
.background-effects {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    animation: float 20s infinite ease-in-out alternate;
}

.blob-1 {
    width: 600px;
    height: 600px;
    background: var(--glow-1);
    top: -200px;
    left: -100px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: var(--glow-2);
    bottom: -100px;
    right: -100px;
    animation-delay: -10s;
}

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 30px) scale(1.1); }
}

/* Glassmorphism Classes */
.glass-panel {
    background: var(--panel-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Layout */
.container {
    width: 100%;
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Typography */
h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, #fff, #a5b4fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

p {
    color: var(--text-muted);
}

/* Login Screen */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 2rem;
    position: relative;
    z-index: 10;
}

.login-panel {
    width: 100%;
    max-width: 440px;
    padding: 3.5rem 3rem;
    text-align: center;
    background: rgba(30, 41, 59, 0.4);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: translateY(0);
    animation: fadeUpIn 0.8s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

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

.brand-header {
    margin-bottom: 2.5rem;
}

.logo-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    display: inline-block;
}

.error-message {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
}

/* Navigation */
.app-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    margin: 1.5rem 2rem 0;
    border-radius: 16px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
    font-size: 1.1rem;
}

.logo-icon.small {
    font-size: 1.25rem;
    margin-bottom: 0;
}

.logout-link {
    color: var(--text-muted);
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.logout-link:hover {
    color: var(--text-main);
}

/* Main App Layout */
.app-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    flex: 1;
    min-height: 0;
}

.input-panel, .result-panel {
    display: flex;
    flex-direction: column;
    padding: 2.5rem;
    height: calc(100vh - 140px);
}

.panel-header {
    margin-bottom: 2rem;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
    text-align: left;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

input, select, textarea {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 1rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--input-focus);
}

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

select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1em;
    cursor: pointer;
}

select option {
    background-color: var(--secondary);
    color: var(--text-main);
}

/* Buttons */
.primary-button {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1rem;
}

.primary-button:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 20px -10px rgba(99, 102, 241, 0.5);
}

.primary-button:active {
    transform: translateY(0);
}

.danger-button {
    width: 100%;
    background: rgba(239, 68, 68, 0.05);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 1rem 1.5rem;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 1rem;
}

.danger-button:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fff;
    border-color: rgba(239, 68, 68, 0.4);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px -8px rgba(239, 68, 68, 0.4);
}

.danger-button:active {
    transform: translateY(0);
    background: rgba(239, 68, 68, 0.25);
}

.arrow {
    transition: transform 0.2s;
}

.primary-button:hover .arrow {
    transform: translateX(4px);
}

.icon-button {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.icon-button:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
    background: rgba(255, 255, 255, 0.05);
}

/* Premium Header Action Buttons */
.action-button {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.action-button.danger {
    background: rgba(239, 68, 68, 0.05);
    color: #fca5a5;
    border-color: rgba(239, 68, 68, 0.2);
}

.action-button.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fff;
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 4px 12px -4px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.action-button.success {
    background: rgba(16, 185, 129, 0.05);
    color: #6ee7b7;
    border-color: rgba(16, 185, 129, 0.2);
}

.action-button.success:hover {
    background: rgba(16, 185, 129, 0.15);
    color: #fff;
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 4px 12px -4px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.hidden {
    display: none !important;
}

/* Loading State */
.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

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

/* Output Area (Markdown Styles) */
.output-content {
    flex: 1;
    overflow-y: auto;
    background: rgba(15, 17, 21, 0.4);
    border-radius: 12px;
    padding: 1.5rem;
    border: 1px solid var(--input-border);
}

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

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

.output-content::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

.empty-state {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-muted);
    text-align: center;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
     opacity: 0.5;
}

.markdown-body {
    color: var(--text-main);
}

.markdown-body h1, 
.markdown-body h2, 
.markdown-body h3, 
.markdown-body h4 {
    margin-top: 1.5em;
    margin-bottom: 0.5em;
    font-weight: 600;
    color: #fff;
}

.markdown-body h1 { font-size: 1.8em; }
.markdown-body h2 { font-size: 1.5em; border-bottom: 1px solid var(--input-border); padding-bottom: 0.3em;}
.markdown-body h3 { font-size: 1.25em; }

.markdown-body p, 
.markdown-body ul, 
.markdown-body ol {
    margin-bottom: 1em;
}

.markdown-body ul, .markdown-body ol {
    padding-left: 1.5em;
}

.markdown-body li {
    margin-bottom: 0.25em;
}

.markdown-body strong {
    color: #fff;
}

/* Responsive */
@media (max-width: 1024px) {
    .app-container {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .input-panel, .result-panel {
        height: auto;
        min-height: 500px;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 1rem;
    }
    
    .app-nav {
        margin: 1rem 1rem 0;
        flex-direction: column;
        gap: 1rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .input-panel, .result-panel {
        padding: 1.5rem;
    }
}

/* Modal Styles - Global Scope */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
    display: flex !important; /* Keep flex for transition, hide via opacity/pointer-events */
}

.modal-content {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 20px;
    padding: 2.5rem;
    width: 90%;
    max-width: 500px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.1) inset;
    transform: translateY(0) scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal-content {
    transform: translateY(20px) scale(0.95);
}
