/* CRITICAL: Must be at the top */
        .hidden {
            display: none !important;
        }

        /* * Styles from main.css 
         * (Adapted and integrated)
        */
        :root{
          --main-color:#1A48EE;
          --secondary-color:#008AFF;
          --tertiary-color:#2c20E6;
          --secondary-background:#f9f9f9;
          --main-background:#e5f3ff;
          --tertiary-background:#e6e5ea;
          --color-white:#ffffff;
          --color-error-dark: #c53030;
          --color-green: #16a34a;
          --color-green-dark: #047857;
          --color-light-green: #D1FAE5;
          --color-contrast-green:#065F46;
          --border-color:#e2e8f0;
          --color-gray:#4a5568;
          --color-light-gray:#ccc;
          --color-very-light-gray:#e0e0e0;
        }
        * {
          box-sizing: border-box;  
        }
        h1, h2, h3 {
          margin-top: 0px;
          color: #1a202c;
          font-weight: 600;
        }
        p {
            margin-top: 0;
            margin-bottom: 1rem;
            line-height: 1.5;
        }
        ul, ol, dl{
          line-height: 1.5;
        }
        /* Accessible hiding class */
        .visually-hidden {
            border: 0;
            clip: rect(0 0 0 0);
            height: 1px;
            margin: -1px;
            overflow: hidden;
            padding: 0;
            position: absolute;
            width: 1px;
            white-space: nowrap; 
            word-wrap: normal;
        }

        /* * Custom Calculator Styles */

        .main-container {
            display: flex;
            flex-direction: column; 
            width: 100%;
            align-items: center; 
            gap: 1rem;
        }

        @media (min-width: 905px) {
            .main-container {
                flex-direction: row; 
                margin:auto;
                /* CHANGED: Stretch ensures both columns are equal height */
                align-items: stretch; 
                justify-content: center; 
                max-width: 900px; /* Increased width for more buttons */
            }
        }

        .history-card {
            width: 100%;
            max-width: 580px; /* Match calculator width */
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 5px 10px rgba(0, 0, 0, 0.05);
            border: 1px solid #e2e8f0;
            background-color: #e2e8f0; 
            border-radius: 0.5rem; 
            padding: 1rem; 
            display: flex;
            flex-direction: column;
        }
        
        @media (min-width: 905px) {
            .history-card {
                padding: 1.5rem; 
                max-width: 300px; 
                flex-shrink: 0;
                max-height: 55rem; /* Adjusted for taller calc */
                overflow: hidden; 
            }
        }

        /* Memory Monitor Styles */
        .memory-monitor {
            margin-bottom: 1rem;
            background: #f1f5f9;
            border: 1px solid #cbd5e1;
            border-radius: 0.375rem;
            padding: 0.75rem;
            max-height: 250px;
            overflow-y: auto;
            flex-shrink: 0; 
        }
        .monitor-section-title {
            font-size: 0.75rem;
            text-transform: uppercase;
            letter-spacing: 0.05em;
            color: #334155; /* Darker gray for accessibility */
            font-weight: 700;
            margin-bottom: 0.5rem;
            margin-top: 0.75rem;
            border-bottom: 1px solid #e2e8f0;
            padding-bottom: 0.25rem;
        }
        .monitor-section-title:first-child {
            margin-top: 0;
        }
        .variable-grid {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 0.5rem;
        }
        .variable-item {
            display: flex;
            justify-content: space-between;
            align-items: center;
            background: #ffffff;
            padding: 0.25rem 0.5rem;
            border-radius: 4px;
            border: 1px solid #e2e8f0;
            font-size: 0.8rem;
        }
        .var-name {
            font-weight: 600;
            color: #1d4ed8; /* Darker blue for contrast */
        }
        .var-value {
            font-family: 'Inter', sans-serif;
            font-variant-numeric: tabular-nums;
            color: #1e293b;
            font-weight: 600;

        }
        .var-empty {
            color: #475569; /* Darker gray for contrast */
            font-style: italic;
            font-size: 0.75rem;
        }
        
        .section-header {
            font-size: 0.9rem;
            font-weight: 600;
            color: #475569;
            margin: 0.5rem 0 0.5rem 0;
            flex-shrink: 0;
        }

        #history-display {
            width: 100%;
            height: 8rem;
            overflow-y: auto;
            background: #f1f5f9; 
            border: 2px solid #cbd5e1; 
            box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
            border-radius: 0.375rem; 
            padding: 0.75rem; 
             font-family: 'Inter', sans-serif;
            font-variant-numeric: tabular-nums;
            font-size: 0.875rem; 
            color: #4b5563; 
            text-align: right;
            display: flex;
            flex-direction: column; 
            justify-content: flex-start;
        }
        @media (min-width: 768px) {
             #history-display {
                height: auto;
                flex-grow: 1;
                min-height: 0;
             }
        }
        #history-display div {
            padding-top: 2px;
            padding-bottom: 2px;
            border-bottom: 1px dashed #e2e8f0;
            margin-bottom: 0.25rem;
        }

        .calculator-body {
            width: 100%;
            max-width: 580px; /* Increased for new keys */
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 5px 10px rgba(0, 0, 0, 0.05);
            border: 1px solid #e2e8f0;
            background-color: #e2e8f0; 
            border-radius: 0.5rem; 
            padding: 1rem; 
            flex-shrink: 0;
            min-width: 345px;
        }
        @media (min-width: 768px) {
            .calculator-body {
                padding: 1.5rem; 
                margin:auto;
            }
        }
        .calculator-header {
            text-align: center;
            margin-bottom: 1rem; 
        }
        .calculator-header h1 {
            font-size: 1.25rem; 
            font-weight: 700; 
            color: #1e293b; 
        }
        .calculator-header p {
            font-size: 0.75rem; 
            color: #334155; /* Darker gray for accessibility */
            margin-bottom: 0;
        }

        .display-screen {
            font-family: 'Inter', sans-serif;
            font-variant-numeric: tabular-nums;
            letter-spacing: 1px;
            background: #f1f5f9; 
            border: 2px solid #cbd5e1; 
            box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
            width: 100%;
            height: 5rem; 
            border-radius: 0.375rem; 
            padding: 0.75rem; 
            text-align: right;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            margin-bottom: 1rem; 
            overflow: hidden;
        }
        #indicators {
            font-size: 0.75rem; 
            color: #334155; /* Darker gray for accessibility */
            display: flex;
            justify-content: space-between;
        }
        #indicators span {
            font-weight: 700; 
            transition: opacity 0.2s ease;
        }
        #cpt-indicator { color: #15803d; /* Darker green */ }
        #sto-indicator, #rcl-indicator { color: #b45309; /* Darker amber */ }
        #angle-indicator { color: #4b5563; }
        #begin-indicator, #hyp-indicator, #inv-indicator, #k-indicator, #paren-indicator { color: #4b5563; margin-left: 5px;}
        
        .indicator-active {
            opacity: 1;
            visibility: visible;
        }
        .indicator-inactive {
            opacity: 0;
            visibility: hidden;
        }

        #display {
            font-size: 1.875rem; 
            font-weight: 600; 
            color: #1e293b; 
            word-wrap: break-word;
            overflow-x: auto;
        }

        .button-grid {
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            gap: 0.5rem; 
        }
        @media (min-width: 768px) {
            .button-grid {
                gap: 0.6rem; 
            }
        }

        .calc-button {
            transition: all 0.1s ease-in-out;
            border: 1px solid #a0aec0; 
            padding: 0.5rem 0;
            font-size: 0.8rem;
            border-radius: 0.375rem; 
            cursor: pointer;
            font-weight: 500;
        }
        .calc-button:focus-visible {
            transform: translateY(1px);
            filter: brightness(0.95);
            outline: 3px solid var(--main-color);
            outline-offset: 2px;
            z-index: 10;
        }
        .calc-button:active, .calc-button-active {
            transform: translateY(2px);
            filter: brightness(0.90);
            box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
        }
        
        .function-button { background-color: #f8fafc; color: #1e293b; } 
        .memory-button { background-color: #f59e0b; color: #1e293b; border-color: #d97706; font-weight: 600; }
        .number-button { background-color: #ffffff; color: #1e293b; font-weight: 600; font-size: 1.1rem; border-color: #a0aec0; }
        .compute-button { background-color: #3730a3; color: #ffffff; border-color: #312e81; }
        .action-button { background-color: #b91c1c; color: #ffffff; border-color: #991b1b; }
        .storage-button { background-color: #065f46; color: #ffffff; border-color: #064e3b; }
        .help-button { background-color: #0369a1; color: #ffffff; font-weight: 600; border-color: #075985; }

        .col-span-2 { grid-column: span 2 / span 2; }
        .row-span-2 { grid-row: span 2 / span 2; height: 100%; }

        /* Small Screen Adaptability */
        @media (max-width: 480px) {
            .calculator-body, .history-card {
                padding: 0.75rem;
            }
            .button-grid {
                gap: 0.25rem;
            }
            .calc-button {
                font-size: 0.75rem; /* Smaller font for small screens */
                padding: 0.6rem 0; /* Adjust touch target */
            }
            #display {
                font-size: 1.5rem;
            }
            .calculator-header h1 {
                font-size: 1.1rem;
            }
        }

        /* Worksheet Modal */
        .worksheet-overlay {
            background-color: rgba(0, 0, 0, 0.5);
            position: fixed;
            inset: 0;
            z-index: 50;
            display: flex;
            align-items: center;
            justify-content: center;
            padding: 1rem;
        }
        .worksheet-modal {
            max-height: 90vh;
            background-color: var(--color-white);
            border-radius: 0.5rem; 
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 5px 10px rgba(0, 0, 0, 0.05);
            width: 100%;
            max-width: 512px; 
            padding: 1.5rem; 
            display: flex;
            flex-direction: column;
        }
        .worksheet-header {
            display: flex;
            justify-content: space-between;
            align-items: center;
            margin-bottom: 1rem; 
            border-bottom: 1px solid var(--border-color);
            padding-bottom: 1rem;
        }
        #worksheet-title {
            font-size: 1.25rem; 
            font-weight: 700; 
            color: #1e293b; 
        }
        #close-worksheet {
            color: #334155; /* Darker gray for accessibility */
            font-size: 2.25rem; 
            line-height: 1;
            background: none;
            border: none;
            cursor: pointer;
            padding: 0;
        }
        #close-worksheet:hover {
            color: #1e293b; 
        }
        #close-worksheet:focus-visible {
            outline: 2px solid var(--main-color);
            border-radius: 2px;
            outline-offset: 2px;
        }

        #worksheet-content {
            overflow-y: auto;
            padding-right: 0.5rem; 
        }
        .ws-input-group {
            margin-bottom: 0.75rem;
        }
        .ws-input-group label, .ws-label {
            display: block;
            font-size: 0.875rem; 
            font-weight: 500; 
            color: #374151; 
            margin-bottom: 0.25rem; 
        }
        .ws-input, .ws-select {
            margin-top: 0.25rem; 
            display: block;
            width: 100%;
            padding: 0.5rem; 
            border: 1px solid var(--border-color);
            border-radius: 0.375rem; 
            box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); 
        }
        .ws-input:focus-visible, .ws-select:focus-visible {
            outline: 2px solid var(--main-color);
            outline-offset: 1px;
            border-color: var(--main-color);
        }
        .ws-button {
            width: 100%;
            padding: 0.5rem 1rem; 
            font-weight: 600; 
            border-radius: 0.375rem; 
            border: none;
            cursor: pointer;
            margin-top: 0.75rem;
            background-color: #1A48EE; /* Requested Color */
            color: var(--color-white);
        }
        .ws-button:hover {
            background-color: #153bc0; /* Darker shade for hover */
        }
        .ws-button:focus-visible {
            outline: 2px solid var(--main-color);
            outline-offset: 2px;
        }
        .ws-button.ws-button-red {
            background-color: #dc2626; 
        }
        .ws-button.ws-button-red:hover {
            background-color: #b91c1c; 
        }
        .ws-button.ws-button-gray {
            background-color: #4b5563; /* Darker gray for contrast */
            color: var(--color-white);
        }
        .ws-button.ws-button-gray:hover {
             background-color: #374151; 
        }

        .ws-grid-2 {
            display: grid;
            grid-template-columns: repeat(2, 1fr);
            gap: 1rem; 
        }
        .ws-grid-3-auto {
            display: grid;
            grid-template-columns: 1fr 1fr auto;
            gap: 0.5rem; 
            align-items: center;
        }
        .ws-grid-cf {
             display: grid;
            grid-template-columns: 1fr 1fr 2rem;
            gap: 0.5rem;
            align-items: center;
            margin-bottom: 0.5rem;
        }
        .ws-grid-cf .ws-label {
            margin-bottom: 0;
        }
        .ws-delete-button {
            background: none;
            border: none;
            color: #dc2626; 
            font-size: 1.5rem;
            font-weight: 700;
            cursor: pointer;
            padding: 0;
            line-height: 1;
        }
        .ws-delete-button:hover {
            color: #b91c1c; 
        }
         .ws-delete-button:focus-visible {
            outline: 2px solid var(--main-color);
            border-radius: 2px;
         }

        .ws-output-group {
            border-top: 1px solid var(--border-color);
            padding-top: 1rem; 
            margin-top: 1rem; 
        }
        .ws-output-row {
            display: flex;
            justify-content: space-between;
            padding: 0.5rem; 
            background-color: #f9fafb; 
            border-radius: 0.375rem; 
            margin-bottom: 0.5rem;
        }
        .ws-output-row span:last-child {
            font-family: 'Inter', sans-serif;
            font-variant-numeric: tabular-nums;
            font-weight: 600;
        }

        .ws-table-container {
            border-top: 1px solid var(--border-color);
            padding-top: 1rem;
            margin-top: 1rem;
            max-height: 40vh;
            overflow-y: auto;
        }
        .ws-table {
            width: 100%;
            font-size: 0.875rem; 
            text-align: left;
            border-collapse: collapse;
        }
        .ws-table th, .ws-table td {
            padding: 0.5rem 0.25rem; 
        }
        .ws-table thead tr {
            border-bottom: 1px solid var(--border-color);
        }
        .ws-table th {
            font-weight: 600; 
        }

        .flex-gap-2 {
            display: flex;
            gap: 0.5rem; 
            margin-top: 0.5rem; 
        }

        .fieldset-group {
            border: 1px solid var(--border-color);
            border-radius: 0.375rem;
            padding: 0.75rem;
            margin-top: 0.5rem;
            margin-bottom: 0.75rem;
        }
        .fieldset-group legend {
            padding: 0 0.25rem;
            font-size: 0.875rem;
            font-weight: 500;
            color: #374151;
        }
        .radio-group {
            display: flex;
            align-items: center;
            gap: 0.5rem;
            margin-top: 0.25rem;
        }
        .radio-group:first-of-type {
            margin-top: 0;
        }
        .radio-group label {
            margin-bottom: 0;
            font-weight: 400;
        }
        
        /* Help Worksheet Styles */
        .help-content {
            text-align: left;
            font-size: 0.875rem;
            color: #374151;
            max-height: 70vh;
            overflow-y: auto;
            padding-right: 0.5rem;
        }
        .help-content h3 {
            font-weight: 700;
            font-size: 1.125rem;
            color: #4f46e5;
            border-bottom: 1px solid #e0e0e0;
            padding-bottom: 0.25rem;
            margin-bottom: 0.5rem;
            margin-top: 1rem;
        }
         .help-content h3:first-child {
            margin-top: 0;
         }
        .help-content p {
            margin-bottom: 0.5rem;
        }
        .help-content .keystroke {
            background-color: #e2e8f0;
            padding: 2px 6px;
            border-radius: 4px;
            font-family: 'Courier New', Courier, monospace;
            font-weight: 600;
            border: 1px solid #cbd5e1;
            white-space: nowrap;
        }
        .help-content ul {
            list-style-type: disc;
            list-style-position: inside;
            padding-left: 0.5rem;
            margin-top: 0.5rem;
        }

        /* SEO Content Styles */
        .seo-content {
            margin:auto;
            max-width: 900px; /* Match main container max-width */
            width: 100%;
            margin-top: 2rem;
            padding: 1.5rem;
            background-color: #ffffff;
            border-radius: 0.5rem;
            box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1), 0 5px 10px rgba(0, 0, 0, 0.05);
            color: #4a5568;
            border: 1px solid #e2e8f0;
        }
        .seo-content h2 {
            font-size: 1.25rem;
            color: #1a202c;
            margin-bottom: 0.75rem;
        }
        .seo-content p {
            font-size: 0.95rem;
            margin-bottom: 1rem;
            line-height: 1.6;
        }
        .seo-content strong {
            color: #2d3748;
        }