:root {
    --primary-red: #8b0000;
    --primary-red-hover: #a50000;
    --bg-grey: #e0e0e0;
    --card-bg: #ffffff;
    --text-dark: #333;
    --text-light: #666;
    --radius: 12px;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-grey);
    color: var(--text-dark);
    margin: 0;
    padding: 20px;
    display: flex;
    justify-content: center;
}

.app-container {
    max-width: 600px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Header & Clear Button */
.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#clearBtn {
    background-color: transparent;
    border: 1px solid var(--primary-red);
    color: var(--primary-red);
    padding: 5px 15px;
    font-size: 0.8rem;
    border-radius: 50px;
    cursor: pointer;
}

#clearBtn:hover {
    background-color: var(--primary-red);
    color: white;
}

header { margin-bottom: 10px; }
h1 { margin: 0; font-size: 1.6rem; color: var(--primary-red); }
p { margin: 5px 0 0; color: var(--text-light); }
h2 { margin-top: 0; font-size: 1.2rem; }
h3 { font-size: 1rem; color: var(--text-light); margin-bottom: 10px; }

.card, .resistance-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.resistance-card {
    margin-bottom: 15px;
    border-left: 5px solid var(--primary-red);
    position: relative;
    overflow: hidden; 
}

/* --- Layout Fixes --- */
.input-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
    width: 100%;
}

.row {
    display: flex;
    flex-wrap: wrap; /* Allows stacking */
    gap: 15px;
}

.row .input-group {
    flex: 1 1 200px; /* Flexible width with min-breakpoint */
    min-width: 0; 
}

input, select {
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
    background: #f9f9f9;
    width: 100%; 
    box-sizing: border-box; 
    min-width: 0;
}

input:focus, select:focus {
    outline: none;
    border-color: var(--primary-red);
}

/* Buttons */
button {
    background-color: var(--primary-red);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 50px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s;
}

button:hover { background-color: var(--primary-red-hover); }

.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.remove-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: transparent;
    color: #999;
    padding: 5px;
    font-size: 1.2rem;
    width: auto;
    line-height: 1;
}

.remove-btn:hover { color: var(--primary-red); background: transparent; }

#solveBtn {
    width: 100%;
    font-size: 1.1rem;
    margin-top: 10px;
    box-shadow: 0 4px 10px rgba(139, 0, 0, 0.3);
}

.hidden { display: none; }

.result-card {
    display: flex;
    justify-content: space-between;
    padding: 15px;
    background: #fff0f0;
    border-radius: 8px;
    margin-bottom: 10px;
}

.result-card .value { font-weight: bold; color: var(--primary-red); font-size: 1.1rem; }

.node-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
    font-size: 0.9rem;
}
.node-temp { font-weight: bold; }

/* --- Footer & Modal --- */
.footer-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    margin-bottom: 40px;
    justify-content: center;
}

.secondary-btn {
    background-color: #666; 
    color: white;
}

.secondary-btn:hover { background-color: #444; }


/* ... [All previous CSS remains the same] ... */

/* --- Modal Styles (Updated) --- */
.modal {
    position: fixed;
    z-index: 100;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    /* Default is visible/flex, but .hidden will override it below */
    display: flex; 
    align-items: center;
    justify-content: center;
}

/* CRITICAL FIX: This specific selector ensures it hides on load */
.modal.hidden {
    display: none !important;
}

.modal-content {
    background-color: #fefefe;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    position: relative;
    max-height: 80vh;
    overflow-y: auto;
    /* Animation for smooth entry */
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.close-modal {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close-modal:hover { color: var(--primary-red); }

.eq-block {
    margin-bottom: 20px;
    background: #f9f9f9;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #666;
}

.eq-block h3 { color: var(--primary-red); margin-top: 0; }
.eq-block p { font-family: 'Courier New', monospace; font-size: 0.95rem; margin: 5px 0; }
.note { font-size: 0.8rem !important; color: #888; font-family: sans-serif !important; }

