:root {
    --primary: #4a90e2;
    --primary-hover: #357abd;
    --bg-color: #f8fafc;
    --surface: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --glass: rgba(255, 255, 255, 0.7);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --radius: 12px;
}

/* * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
} */

.app-container {
    font-family: 'Inter', sans-serif;
    display: flex;
    /* width: 90vw;
    height: 90vh; */
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
    min-height: 680px;
}

header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: baseline;
    gap: 1rem;
    background: var(--glass);
    backdrop-filter: blur(10px);
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
}

.logo span {
    color: var(--text-main);
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    font-weight: 300;
}

main {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.controls {
    width: 260px;
    padding: 1.0rem;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    background: #f2f2f4;
}

.header-with-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.header-with-action h3 {
    margin-bottom: 0 !important;
    margin-top: 0;
}

.compact-select {
    padding: 2px 6px;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
    background: white;
    outline: none;
    cursor: pointer;
    font-family: 'Outfit', sans-serif;
    color: --var(--text-main);
}

.compact-settings {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0.2rem; 
    padding: 0.6rem !important;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.compact-settings .setting-row {
    width: 100%;
    justify-content: space-between;
}

.setting-row {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    /* flex: 1; */
    flex-wrap: wrap;
}

.setting-row label {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
}

.small-input {
    width: 50px !important;
    padding: 4px 6px !important;
    font-size: 0.8rem !important;
}

.btn.small {
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
}

textarea {
    /* width: 100%; */
    height: 120px;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: Consolas, monospace;
    font-size: 0.85rem;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

textarea:focus {
    border-color: var(--primary);
}

.drop-zone {
    width: 98%;
    height: 32px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    /* padding: 1rem; */
    font-size: 0.75rem;
    color: var(--text-muted);
    background: #fcfcfd;
    transition: all 0.2s;
    cursor: pointer;
}

.drop-zone.dragover {
    border-color: var(--primary);
    background: #f0f7ff;
    color: var(--primary);
}

.stat-item {
    cursor: help;
}

.btn {
    padding: 0.5rem 0.5rem;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s;
    text-align: center;
    width: 100%;
}

.primary {
    background-color: var(--primary);
    color: white;
}

.primary:hover {
    background-color: var(--primary-hover);
}

.primary:disabled {
    background-color: #cbd5e1;
    cursor: not-allowed;
    opacity: 0.7;
}

.secondary {
    background-color: var(--bg-color);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.secondary:hover {
    background-color: #f1f5f9;
}

.secondary:disabled {
    background-color: #f8fafc;
    color: #94a3b8;
    cursor: not-allowed;
    opacity: 0.6;
}

.glass {
    background: var(--glass);
    backdrop-filter: blur(5px);
    border: 1px solid var(--border);
    color: var(--text-main);
}

.glass:hover {
    background: rgba(255, 255, 255, 0.9);
}

.glass:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: rgba(240, 240, 240, 0.5);
}

.setting-item {
    margin-bottom: 1rem;
}

.setting-item label {
    display: block;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

input[type="number"] {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
}

.toggle-group {
    display: flex;
    background: #f1f5f9;
    padding: 3px;
    border-radius: 8px;
}

.toggle-group input {
    display: none;
}

.toggle-group label {
    flex: 1;
    text-align: center;
    padding: 0.4rem;
    margin-bottom: 0;
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.8rem;
    transition: background 0.2s;
}

.toggle-group input:checked+label {
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    font-weight: 600;
}

.canvas-area {
    flex: 1;
    position: relative;
    background-color: #fcfcfd;
}

#main-canvas {
    width: 100%;
    height: 100%;
}

.results {
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    display: none;
}

.results.active {
    display: block;
}

.equation {
    font-family: 'Outfit', serif;
    font-size: 0.9rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
    word-break: break-all;
}

#stats-panel h3 { margin:0 0 0.25rem 0;}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f1f5f9;
    padding: 0.4rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
}

.stat-item span {
    color: var(--text-muted);
}

.stat-item strong {
    color: var(--primary);
    font-family: monospace;
}

.input-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.actions {
    margin-top: 1vw;
    display: flex;
    /* flex-direction: column; */
    gap: 0.5rem;
    flex-wrap: wrap;
}