:root {
    --bg-app: #f8fafc;
    --bg-sidebar: #ffffff;
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --primary: #4338ca;
    /* Deep indigo/purple from image */
    --primary-light: #e0e7ff;
    --accent: #3b82f6;
    --success: #22c55e;
    --error: #ef4444;
    --border-color: #e2e8f0;
    --font-main: 'Outfit', sans-serif;
    --radius-lg: 24px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: var(--font-main);
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.app-container {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    transition: transform 0.3s ease;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2.5rem;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    color: white;
}

.sidebar h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-group {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    padding-left: 0.75rem;
    font-weight: 600;
}

.nav-item {
    background: none;
    border: none;
    color: var(--text-muted);
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--bg-app);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    background-color: #f3f4f6;
    /* Lighter background for main area */
}

.top-bar {
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.mobile-only {
    display: none;
}

#menu-toggle {
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 1.5rem;
    cursor: pointer;
}

#page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    display: none;
    /* Hidden based on the image design which has titles in cards */
}

.content-area {
    flex: 1;
    padding: 0 2rem 2rem;
    overflow-y: auto;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

/* --- CALCULATOR SPECIFIC STYLES --- */

/* The main grid layout for the calculator view */
.calc-grid-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

/* TOP CARD: Inputs */
.input-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
}

.card-header i {
    color: var(--primary);
}

.inputs-row {
    display: flex;
    align-items: flex-end;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.input-group {
    flex: 1;
    min-width: 200px;
}

.input-group label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.stylized-input {
    width: 100%;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.75rem 1rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    transition: border-color 0.2s;
    outline: none;
}

.stylized-input:focus {
    border-color: var(--primary);
}

/* Operation Selector */
.operation-selector {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: var(--radius-md);
    gap: 4px;
}

.op-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.op-btn:hover {
    color: var(--primary);
    background: rgba(255, 255, 255, 0.5);
}

.op-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
    font-weight: bold;
}

/* BOTTOM SECTION: Split view */
.bottom-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

/* Left: Graph Paper Calculation */
.paper-card {
    min-height: 500px;
}

.paper-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.step-instruction {
    font-size: 0.85rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
    align-items: baseline;
}

.step-number {
    background: var(--primary-light);
    color: var(--primary);
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
}

/* Graph Paper Effect */
.graph-paper {
    background-color: #f8fafc;
    background-image:
        linear-gradient(#e2e8f0 1px, transparent 1px),
        linear-gradient(90deg, #e2e8f0 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: -1px -1px;
    padding: 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'Fira Code', 'Courier New', monospace;
    font-size: 24px;
    line-height: 40px;
    /* Aligns with grid height (20px * 2) */
    color: #334155;
    position: relative;
    /* To ensure numbers align to grid */
    letter-spacing: 0.2em;
}

/* Right: Result & Guide */
.result-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.result-card {
    background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
    color: white;
    text-align: center;
    padding: 3rem 2rem;
    position: relative;
    overflow: hidden;
}

.result-label {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.result-value {
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 1rem;
    text-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    opacity: 0.9;
}

.big-check-icon {
    position: absolute;
    bottom: -20px;
    right: -20px;
    font-size: 10rem;
    opacity: 0.1;
    transform: rotate(-10deg);
}

.guide-card {
    background: #ffffff;
}

.guide-title {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #1e293b;
}

.guide-list {
    list-style: none;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.guide-list li {
    margin-bottom: 0.75rem;
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.guide-list li::before {
    content: "•";
    color: var(--primary);
    font-weight: bold;
}

/* --- OTHER SECTIONS (Kept minimal but compatible) --- */
.hero-card {
    background: white;
    padding: 3rem;
    text-align: center;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.feature-card {
    background: white;
    border: 1px solid var(--border-color);
    padding: 2rem;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s;
}

.feature-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary);
}

/* Responsiveness */
@media (max-width: 900px) {
    .bottom-section {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: absolute;
        height: 100%;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-only {
        display: block;
    }
}

/* Calc Specifics */
.calc-row {
    font-family: monospace;
    white-space: pre;
    display: block;
}

.carry-row {
    color: var(--error);
    /* Grey */
    font-size: 1em;
    /* Keep same size for perfect alignment */
    height: 20px;
    /* Match grid line height roughly or smaller */
    line-height: 20px;
    opacity: 0.8;
    font-weight: normal;
    /* No letter spacing modification so it matches monospaced grid perfectly */
}

/* Sidebar Navigation */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
}

.sidebar .logo-container {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
}

.sidebar h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
}

.nav-icon {
    font-size: 1.1rem;
}

.main-content {
    margin-left: 260px;
}

#page-title {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Mobile responsive */
@media (max-width: 900px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 1000;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-only {
        display: block !important;
    }
}

/* Pythagore Section */
.pythagore-content {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex-wrap: wrap;
}

.triangle-svg {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.formula {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
    background: var(--primary-light);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
}

.pythagore-inputs {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    flex: 1;
}

.pythagore-inputs .input-group {
    min-width: 150px;
}

.pythagore-steps {
    padding: 1.5rem;
    background: #f8fafc;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.step-line {
    padding: 0.25rem 0;
    font-size: 0.95rem;
    color: var(--text-main);
}

.step-line:empty {
    height: 0.75rem;
}

.pythagore-results {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: var(--radius-sm);
}

.result-label-small {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 600;
}

.result-value-small {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary);
}