/* Custom styles for calculator using the stylesheet's variables */
        .card {
            background-color: var(--color-white);
            border-radius: 8px;
            border: 1px solid var(--secondary-color-color);
            box-shadow: 0 3px 10px var(--secondary-color);
            padding: 2rem;
            margin-bottom: 2rem;
        }
        
        .grid-container {
            display: grid;
            grid-template-columns: 1fr;
            gap: 1.5rem;
        }
        @media (min-width: 768px) {
            .grid-container {
                grid-template-columns: repeat(2, 1fr);
            }
            .grid-span-2 {
                grid-column: span 2 / span 2;
            }
        }

        label {
            display: block;
            font-size: 0.875rem;
            font-weight: bold;
            color: #4a5568;
            margin-bottom: 0.25rem;
        }
        input[type="number"], input[type="date"] {
            width: 100%;
            padding: 0.5rem 0.75rem;
            border: 1px solid #cbd5e0;
            border-radius: 0.375rem;
            box-shadow: inset 0 1px 2px 0 rgba(0,0,0,0.05);
            font-size: 1rem;
            font-family: Arial, Helvetica, sans-serif;
        }
        input:focus {
            outline: none;
            border-color: var(--main-color);
            box-shadow: 0 0 0 3px rgba(26, 72, 238, 0.4);
        }
        .button-container {
            display: flex;
            justify-content: center;
            margin-top: 1rem;
        }
        #calculate-savings, #calculate-investment, #calculate-loan {
            width: 100%;
            background-color: var(--main-color);
            color: var(--color-white);
            font-weight: bold;
            padding: 0.75rem 2rem;
            border: none;
            border-radius: 0.5rem;
            box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
            transition: background-color 0.3s;
            cursor: pointer;
            font-size: 1rem;
        }
        @media (min-width: 768px) {
           #calculate-savings, #calculate-investment, #calculate-loan { width: auto; }
        }
        #calculate-savings:hover, #calculate-investment:hover, #calculate-loan:hover {
            background-color: var(--secondary-color);
        }
        
        /* Results Section Styling */
        #results-container {
            margin-top: 2rem;
            padding-top: 1.5rem;
            border-top: 1px solid #e2e8f0;
        }
        .results-grid {
            display: grid;
            grid-template-columns: 1fr;
            gap: 1rem;
            text-align: center;
        }
        @media (min-width: 768px) {
            .results-grid { grid-template-columns: repeat(3, 1fr); }
        }
        .results-grid h3 {
            font-size: 1.125rem;
            font-weight: normal;
        }
        .results-grid .amount-primary, .amount-primary {
            font-size: 2.25rem;
            font-weight: bold;
            color: var(--main-color);
        }
        .results-grid .amount-secondary, .amount-secondary {
            font-size: 1.5rem;
            font-weight: bold;
        }
         .error-message {
            text-align: center;
            color: #c53030;
            font-weight: bold;
        }
        #math-explanation {
            margin-top: 2rem;
            padding: 1.5rem;
            background-color: var(--secondary-background);
            border: 1px solid #e2e8f0;
            border-radius: 0.5rem;
        }
        .formula-container {
            display: flex;
            justify-content: center;
            padding: 0.5rem 0;
            overflow-x: auto;
        }
        math {
            font-size: 1.2em;
        }
         /* Styles for the radio button toggle */
        .calc-mode-fieldset {
            border: none;
            padding: 0;
            margin: 0 0 1.5rem 0;
        }
        .calc-mode-legend {
            font-weight: bold;
            font-size: 0.875rem;
            color: #4a5568;
            margin-bottom: 0.5rem;
            width: 100%;
            text-align: center;
        }
        .radio-group {
            display: flex;
            justify-content: center;
            gap: 1rem;
            flex-wrap: wrap;
        }
        .radio-group label {
            cursor: pointer;
        }
        /* Amortization Table Styles */
        .amortization-section {
            margin-top: 2rem;
        }
        .amortization-table-container {
            max-height: 400px;
            overflow-y: auto;
            border: 1px solid #e2e8f0;
            border-radius: 0.5rem;
        }
        .amortization-table {
            width: 100%;
            border-collapse: collapse;
            text-align: left;
        }
        .amortization-table th, .amortization-table td {
            padding: 0.75rem;
            border-bottom: 1px solid #e2e8f0;
        }
        .amortization-table thead {
            background-color: var(--secondary-background);
            position: sticky;
            top: 0;
        }
        #impact-grid{
            display: block;
            justify-content: space-around;
            margin-top: 1rem;
            flex-wrap: wrap;
        }
        @media screen and (min-width: 768px){
            #impact-grid{ 
                display: flex;
            }
        }
        /* Calculator Specific Styles */
        /* Main content layout inside the card */
        .calculator-layout {
            display: flex;
            flex-direction: column;
        }

        /* Calculator Specific Styles */
        .calculator-grid {
            display: grid;
            grid-template-columns: repeat(4, 1fr);
            gap: 10px;
        }
        #calculator-display {
            grid-column: 1 / -1;
            background-color: var(--secondary-background);
            border: 1px solid #ccc;
            border-radius: 4px;
            padding: 1rem;
            font-size: 2rem;
            text-align: right;
            width: 100%;
            margin-bottom: 10px;
            font-family: monospace;
        }
        .calculator-grid button {
            padding: 20px;
            font-size: 1.5rem;
            border-radius: 4px;
            border: 1px solid #ccc;
            background-color: #f9f9f9;
            cursor: pointer;
            transition: background-color 0.2s;
        }
        .calculator-grid button:hover {
            background-color: #e0e0e0;
        }
        .calculator-grid>.operator {
            background-color: var(--secondary-color);
            color: var(--color-white);
        }
        .calculator-grid>.operator:hover {
            background-color: var(--main-color); /* Darker shade for hover */
        }
        .calculator-grid>.equals {
            grid-column: 4 / 5;
            grid-row: 4 / 6;
            background-color: var(--secondary-color);
            color: var(--color-white);
        }
        .calculator-grid>.equals:hover {
             background-color: var(--main-color);
        }
        .calculator-grid>.clear {
            background-color: var(--secondary-color);
            color: white;
        }
        .calculator-grid>.clear:hover {
             background-color: var(--main-color);
        }
        
        /* History Section */
        #history-container {
            padding-top: 15px;
            margin-top: 15px;
            border-top: 1px solid #ccc;
            width: 100%;
        }
        #history-container h3 {
            text-align: center;
            margin-top: 0;
        }
        #history-log {
            background-color: var(--secondary-background);
            border: 1px solid #ccc;
            border-radius: 4px;
            padding: 1rem;
            min-height: 100px;
            max-height: 200px; /* Added max-height to prevent card from getting too tall */
            overflow-y: auto; /* Add scroll for overflow */
            font-family: monospace;
            font-size: 1.2rem;
            line-height: 1.8;
        }
        /* Larger screen layout */
        @media (min-width: 992px) {
            .articlecontainer {
                max-width: 1100px; /* Wider container for side-by-side layout */
            }
            .calculator-layout {
                flex-direction: row;
                gap: 20px;
            }
            .calculator-main, #history-container {
                flex: 1; /* Make both sections take up equal space */
                min-width: 300px; 
            }
            #history-container {
                margin-top: 0;
                padding-top: 0;
                border-top: none;
                border-left: 1px solid #ccc;
                padding-left: 20px;
            }
            #history-log {
                height: 100%;
                max-height: 430px; /* Adjust height for side-by-side view */
            }
        }
        /* Fraction Calculator Styles */
        .calculator-layout {
            display: flex;
            align-items: center;
            justify-content: center;
            flex-wrap: wrap;
            gap: 1rem;
        }
        .fraction-input, .operator-group {
            display: flex;
            flex-direction: column;
            align-items: center;
            gap: 0.25rem;
        }
        .fraction-input input {
            width: 60px;
            text-align: center;
            font-size: 1.5rem;
            padding: 0.5rem;
            border: 1px solid #ccc;
            border-radius: 4px;
        }
        .fraction-input .bar {
            width: 60px;
            height: 2px;
            background-color: #333;
        }
        .operator-group label {
            font-weight: bold;
            font-size: 0.875rem;
            color: #4a5568;
        }
        #operator-select {
            font-size: 1.5rem;
            padding: 0.5rem;
            border-radius: 4px;
            border: 1px solid #ccc;
            background-color: var(--main-color);
            color: var(--color-white);
        }
        .equals-sign {
            font-size: 2.5rem;
            font-weight: bold;
        }
        .result-display {
            display: flex;
            flex-direction: row; /* Changed for mixed numbers */
            align-items: center; /* Changed for mixed numbers */
            gap: 0.5rem; /* Gap between whole and fraction */
            font-size: 2.5rem;
            min-width: 80px;
            text-align: center;
        }
        .result-display .bar {
            width: 100%;
            height: 3px;
            background-color: #333;
        }
        .result-display .whole-number {
             margin-right: 0.25rem;
        }
        .result-fraction {
            display: inline-flex;
            flex-direction: column;
            align-items: center;
            vertical-align: middle;
            font-size: 2.5rem; /* Ensure fraction part has same base size */
        }
        .result-fraction .bar {
            width: 100%;
        }

        .controls {
            width: 100%;
            text-align: center;
            margin-top: 1.5rem;
            display: flex;
            justify-content: center;
            gap: 1rem;
        }
        .controls button {
            border: none;
            padding: 0.75rem 1.5rem;
            font-size: 1rem;
            font-weight: bold;
            border-radius: 4px;
            cursor: pointer;
            transition: background-color 0.2s;
        }
        #calculate-btn {
            background-color: var(--main-color);
            color: var(--color-white);
        }
        #calculate-btn:hover {
            background-color: var(--secondary-color);
        }
        #clear-btn {
            background-color: #c53030;
            color: white;
        }
        #clear-btn:hover {
            background-color: #d32f2f;
        }
        /* Explanation Section */
        #explanation-container {
            margin-top: 1.5rem;
            padding: 1rem;
            background-color: var(--secondary-background);
            border-radius: 4px;
        }
        #explanation-container h3 {
            text-align: center;
            margin-top: 0;
        }
        #explanation-steps p {
            font-size: 1.1rem;
            line-height: 1.6;
            margin-bottom: 0.5rem;
        }
        .unit-label {
            margin-top: 0.5rem;
        }