:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-glow: rgba(99, 102, 241, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    /* Standard scrollbar styling for Firefox */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}
body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-x: hidden;
    padding: 20px;
}

.glass-container {
    /* Removed glass effect */
    background: transparent;
    border: none;
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    
    /* Layout */
    width: 100%;
    max-width: 700px; /* Slightly wider as requested implicitly by "narrow" comment before? Or just standard */
    padding: 20px 0; /* Vertical padding, remove horizontal constraint visually */
    margin: 0 auto;
    position: relative;
    z-index: 10;
}

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

#main-title {
    font-family: 'Outfit', sans-serif;
    font-size: 2.5rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ultra {
    background: linear-gradient(135deg, #818cf8 0%, #c084fc 100%);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1rem;
}

.number-cards {
    display: flex;
    gap: 40px; /* Wider spacing */
    justify-content: center;
    margin-bottom: 24px;
    margin-top: 10px;
}

.card {
    /* "Normal" display: Remove card aesthetics */
    background: transparent;
    border: none;
    box-shadow: none;
    width: auto;
    height: auto;
    
    /* Typography focus */
    font-family: 'mb', 'Outfit', sans-serif; /* Fallback */
    font-size: 4rem;
    font-weight: 800;
    color: #fff;
    line-height: 1;
    
    /* Center text */
    display: flex;
    align-items: center;
    justify-content: center;
    
    /* Subtle glow instead of card shadow */
    text-shadow: 0 0 30px rgba(99, 102, 241, 0.5);
    
    cursor: default;
    transition: all 0.3s ease;
}

.card.used {
    color: var(--text-muted);
    opacity: 0.2;
    transform: scale(0.9);
    text-shadow: none;
    text-decoration: line-through; /* Optional: adds clarity */
}

.expression-area {
    margin-bottom: 24px;
}

.input-wrapper {
    position: relative;
    margin-bottom: 16px;
}

#expression-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 16px 20px;
    color: #fff;
    font-size: 1.25rem;
    outline: none;
    transition: all 0.3s ease;
}

#expression-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--accent-glow);
}

/* Old .live-result removed */

.controls {
    display: flex;
    gap: 12px;
}

.primary-btn, .secondary-btn {
    flex: 1;
    padding: 14px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.primary-btn {
    background: var(--primary);
    color: white;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.15);
}

.operator-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
    margin-bottom: 32px;
}

.op-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 12px;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.op-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
}

.help-section {
    border-top: 1px solid var(--glass-border);
    padding-top: 24px;
}

.help-section h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.help-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.hint {
    margin-top: 16px;
    font-size: 0.8rem;
    color: #f43f5e;
}

.message-area {
    height: 24px;
    margin-top: 16px;
    text-align: center;
    font-weight: 600;
}

.status-error { color: #f43f5e; }
.status-success { color: #10b981; }

/* Background Blobs */
.bg-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    z-index: 1;
}

.blob {
    position: absolute;
    width: 400px;
    height: 400px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.2) 0%, rgba(192, 132, 252, 0.2) 100%);
    filter: blur(80px);
    border-radius: 50%;
    animation: move 25s infinite alternate ease-in-out;
}

.blob-1 { top: -10%; left: -10%; }
.blob-2 { bottom: -10%; right: -10%; animation-delay: -5s; }
.blob-3 { top: 40%; left: 30%; width: 300px; height: 300px; animation-duration: 15s; }

@keyframes move {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 100px) scale(1.2); }
}

@media (max-width: 480px) {
    .glass-container { padding: 24px 16px; }
    .operator-grid { grid-template-columns: repeat(4, 1fr); }
    .card { width: 60px; height: 80px; font-size: 2rem; }
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #0f172a;
    border: 1px solid var(--glass-border);
    margin: 5vh auto; /* Vertical centering adjustment */
    padding: 30px;
    width: 90%;
    max-width: 1200px; /* Much wider */
    min-height: 80vh; /* Taller */
    border-radius: 20px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.close-modal {
    color: #94a3b8;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    top: 15px;
    right: 20px;
    transition: color 0.2s;
    z-index: 10;
}

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

/* Old answer list styles removed */

.modal h2 {
    font-family: 'Outfit', sans-serif;
    margin-bottom: 20px;
    color: var(--primary);
    text-align: center;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5); 
    border-radius: 5px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2); 
    border-radius: 5px;
    border: 2px solid rgba(15, 23, 42, 0.5); /* Creates padding effect */
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3); 
}

/* Updated Answer List for Wide Layout */
.answer-list {
    margin-top: 20px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 16px;
}

.answer-item {
    background: rgba(255, 255, 255, 0.05);
    /* Padding adjustments: less right padding as button is part of flow now */
    padding: 12px; 
    border-radius: 12px;
    font-family: monospace;
    font-size: 1.1rem;
    color: var(--text-main);
    border: 1px solid var(--glass-border);
    
    display: flex; /* Align items */
    align-items: center;
    gap: 12px;
    min-height: 60px;
}

.math-scroll-area {
    flex: 1;
    overflow-x: auto;
    overflow-y: hidden; /* Hide vertical */
    white-space: nowrap;
    
    /* Ensure scrollbar is visible/styled here too if needed */
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.math-scroll-area::-webkit-scrollbar {
    height: 6px; /* thinner horizontal scrollbar */
}

.copy-btn {
    /* No absolute position */
    flex-shrink: 0; 
    
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.copy-btn svg {
    width: 18px;
    height: 18px;
    fill: none; /* Icon uses stroke based on my JS svg */
    stroke: currentColor;
}

/* Latex Preview Area */
.latex-preview {
    min-height: 2rem;
    margin-bottom: 16px;
    padding: 10px;
    color: var(--text-main);
    text-align: center;
    font-size: 1.2rem;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0.9;
    
    /* Also allow scrolling for long input previews */
    overflow-x: auto;
    white-space: nowrap;
}

/* Error Overlay */
.error-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    z-index: 200; /* Higher than normal modal */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.error-content {
    max-width: 400px;
    text-align: center;
    padding: 40px;
}

.error-content h2 {
    color: #f43f5e;
    font-size: 2rem;
    margin-bottom: 16px;
    font-family: 'Outfit', sans-serif;
}

.error-content p {
    color: var(--text-main);
    margin-bottom: 30px;
    font-size: 1.1rem;
    line-height: 1.6;
}

#error-retry-btn {
    width: 100%;
    padding: 16px;
    font-size: 1.2rem;
}

/* Settings Modal Styles */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
    text-align: left;
}

.settings-grid label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-main);
    font-size: 1.1rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
    padding: 12px;
    border-radius: 8px;
    transition: background 0.3s;
}

.settings-grid label:hover {
    background: rgba(255, 255, 255, 0.1);
}

.settings-grid input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
}

.settings-actions {
    display: flex;
    gap: 16px;
    justify-content: center;
}
