:root {
    --bg-color: #f8fafc;
    --text-color: #334155;
    --primary-color: #0f172a;
    --accent-color: #2563eb;
    --border-color: #e2e8f0;
    --panel-bg: #ffffff;
    --grid-color: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    background-image:
        linear-gradient(var(--grid-color) 1px, transparent 1px),
        linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
    background-size: 40px 40px;
    color: var(--text-color);
    min-height: 100vh;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

/* Header */
.main-header {
    background: var(--panel-bg);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
}

nav {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary-color);
    letter-spacing: -0.02em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-links {
    list-style: none;
    display: flex;
    gap: 2rem;
}

.nav-links a {
    color: #64748b;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: var(--accent-color);
}

/* Main Container */
.container {
    max-width: 800px;
    margin: 3rem auto;
    padding: 0 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Panels */
.panel {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Calculator Section */
.calculator-section {
    text-align: center;
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
    letter-spacing: -0.03em;
}

.subtitle {
    color: #64748b;
    font-size: 0.95rem;
    margin-bottom: 2rem;
}

/* Band Selector */
.band-selector {
    display: inline-flex;
    background: #f1f5f9;
    padding: 0.25rem;
    border-radius: 6px;
    margin-bottom: 2.5rem;
    border: 1px solid var(--border-color);
}

.band-btn {
    background: transparent;
    border: none;
    color: #64748b;
    padding: 0.5rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.band-btn.active {
    background: white;
    color: var(--primary-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

/* Resistor Visual */
.resistor-visual {
    height: 120px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 2.5rem;
    position: relative;
    background-image: radial-gradient(#cbd5e1 1px, transparent 1px);
    background-size: 10px 10px;
    border: 1px dashed var(--border-color);
    border-radius: 4px;
}

.resistor-body {
    width: 300px;
    height: 70px;
    background: #f1f5f9;
    border: 2px solid #94a3b8;
    border-radius: 35px;
    position: relative;
    display: flex;
    justify-content: space-evenly;
    align-items: center;
    z-index: 2;
}

.wire {
    position: absolute;
    height: 4px;
    width: 60px;
    background: #94a3b8;
    z-index: 1;
}

.left-wire {
    right: 100%;
}

.right-wire {
    left: 100%;
}

.stripe {
    width: 12px;
    height: 100%;
    background-color: transparent;
    transition: background-color 0.2s;
}

.stripe.hidden {
    display: none;
}

/* Controls Grid */
.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    text-align: left;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.control-group label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    font-weight: 600;
}

select {
    appearance: none;
    background-color: white;
    border: 1px solid var(--border-color);
    color: var(--primary-color);
    padding: 0.6rem;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 1rem;
    padding-right: 2rem;
}

select:focus {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* Result Display */
.result-display {
    display: flex;
    justify-content: center;
    gap: 3rem;
    flex-wrap: wrap;
    background: #f8fafc;
    padding: 2rem;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.result-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.result-item.hidden {
    display: none;
}

.result-item .label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #64748b;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.result-item .value {
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
}

/* Info Section */
.info-section h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.info-section h3 {
    font-size: 1.1rem;
    margin-top: 2rem;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
}

.info-section p {
    color: #475569;
    margin-bottom: 1rem;
}

/* Footer */
.main-footer {
    border-top: 1px solid var(--border-color);
    padding: 2rem;
    text-align: center;
    color: #94a3b8;
    font-size: 0.85rem;
    background: var(--panel-bg);
    margin-top: auto;
}

/* Responsive */
@media (max-width: 600px) {
    h1 {
        font-size: 1.75rem;
    }

    .resistor-body {
        width: 100%;
    }

    .nav-links {
        display: none;
    }

    .result-display {
        flex-direction: column;
        gap: 1.5rem;
    }

    .container {
        margin: 1.5rem auto;
    }
}

/* Tools Grid */
.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.tool-card {
    background: var(--panel-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1.5rem;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    border-color: var(--accent-color);
}

.tool-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.tool-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.tool-desc {
    font-size: 0.9rem;
    color: #64748b;
    line-height: 1.5;
}

/* MOBILE FIX: Stack columns vertically on phones */
@media (max-width: 768px) {

    /* 1. Reset the Main Layout to a single column */
    body {
        display: block;
        /* Stops the side-by-side flex/grid */
    }

    /* 2. Fix the Container */
    .container {
        display: flex;
        flex-direction: column;
        /* Stacks Calculator on top, Sidebar on bottom */
        width: 100%;
        padding: 10px;
    }

    /* 3. Make columns full width */
    .main-content,
    .sidebar {
        width: 100%;
        max-width: 100%;
        margin: 0;
    }

    /* 4. Fix Input Fields for Fat Thumbs */
    input,
    select,
    button {
        min-height: 48px;
        /* Google requires 48px touch target */
        font-size: 16px;
        /* Prevents iPhone from zooming in automatically */
    }
}