body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #e0e0e0; /* Light gray background for page */
    font-family: 'Open Sans', sans-serif;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
}

.calculator {
    width: 330px;
    background-color: #333740;
    background-image: linear-gradient(45deg, rgba(255,255,255,0.02) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.02) 75%, rgba(255,255,255,0.02)),
                      linear-gradient(45deg, rgba(255,255,255,0.02) 25%, transparent 25%, transparent 75%, rgba(255,255,255,0.02) 75%, rgba(255,255,255,0.02));
    background-size: 12px 12px;
    background-position: 0 0, 6px 6px;
    border-radius: 12px;
    padding: 18px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3), 0 0 0 3px #2a2e35;
    color: white;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    padding: 0 5px;
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

.casio-logo {
    font-size: 1.6em;
    font-weight: bold;
    color: #d8d8d8;
    font-family: 'Arial Black', Gadget, sans-serif;
    letter-spacing: -1px;
}

.model-name {
    font-size: 0.7em;
    color: #a0a0a0;
    margin-top: -3px;
    font-family: 'Open Sans', sans-serif;
}

.classwiz-logo {
    font-size: 0.9em;
    color: #e85a70;
    font-weight: bold;
    letter-spacing: 0.5px;
    margin-top: 1px;
    font-family: 'Open Sans', sans-serif;
    font-style: italic;
}

.solar-panel {
    width: 90px;
    height: 22px;
    background: #2c2c3a;
    border: 1px solid #404048;
    border-radius: 3px;
    margin-top: 5px;
    box-shadow: inset 0 0 4px rgba(0,0,0,0.6);
}

.display-area {
    background: linear-gradient(to bottom, #d0e0d0, #b8c8b8);
    border: 1px solid #333;
    border-top-color: #555;
    border-left-color: #555;
    border-radius: 6px;
    padding: 6px 8px;
    margin-bottom: 18px;
    box-shadow: inset 1px 1px 4px rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.05);
}

.secondary-display {
    height: 20px;
    font-family: 'Roboto Mono', monospace;
    font-size: 0.75em;
    color: #3a4a3a;
    letter-spacing: 0.5px;
    padding: 2px 5px;
    overflow: hidden;
    white-space: nowrap;
    border-bottom: 1px solid rgba(50,70,50,0.2);
    margin-bottom: 3px;
    line-height: 18px;
}

.main-display {
    height: 85px;
    font-family: 'Roboto Mono', monospace;
    font-size: 1.3em;
    color: #1a2a1a;
    line-height: 1.35;
    padding: 5px;
    overflow-y: auto;
    text-align: right;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}
.main-display div {
    min-height: 17px;
}

.top-controls {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 6px;
    margin-bottom: 12px;
    align-items: center;
}

.top-controls .btn, .top-controls .btn-main {
    height: 38px;
    background-color: #303030;
    color: #e0e0e0;
    border: 1px solid #252525;
    box-shadow: 0 2px 0 #1a1a1a, inset 0 1px 0 rgba(255,255,255,0.05);
    font-size: 0.8em;
    font-weight: 600;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.1s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}
.top-controls .btn:active, .top-controls .btn-main:active {
    transform: translateY(1px);
    box-shadow: 0 1px 0 #1a1a1a, inset 0 1px 1px rgba(0,0,0,0.2);
}

.shift-btn-main { grid-column: 1 / 2; color: #ffd700; }
.alpha-btn-main { grid-column: 2 / 3; color: #ff69b4; }
.menu-btn { grid-column: 5 / 6; flex-direction: column; line-height: 1.1; padding-top: 2px; }
.on-btn-main { grid-column: 6 / 7; color: #fff; }

.menu-btn .shift-text-label { /* This is for the MENU button's SETUP label */
    position: static; /* Overrides absolute from general .btn */
    font-size: 0.75em;
    color: #ffd700;
    font-weight: normal;
}
.menu-btn .main-content {
    margin-top: 1px;
    font-size: 0.9em;
}

.nav-pad {
    grid-column: 3 / 5;
    display: grid;
    grid-template-areas:
        ". up ."
        "left center right"
        ". down .";
    grid-template-rows: 1fr auto 1fr;
    grid-template-columns: 1fr auto 1fr;
    gap: 1px;
    width: 75px;
    height: 75px;
    padding: 4px;
    background-color: #3a3a3a;
    border-radius: 50%;
    place-self: center;
    margin-top: -8px;
    border: 1px solid #282828;
    box-shadow: 0 2px 1px rgba(0,0,0,0.3);
}

.nav-pad button {
    background-color: #585858;
    border: 1px solid #404040;
    color: #d0d0d0;
    border-radius: 4px;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.1s ease;
    min-width: 20px;
    min-height: 20px;
}
.nav-pad button:active { background-color: #686868; transform: scale(0.97); }

.nav-up { grid-area: up; clip-path: polygon(50% 0%, 100% 100%, 0% 100%); }
.nav-down { grid-area: down; clip-path: polygon(0% 0%, 100% 0%, 50% 100%); }
.nav-left { grid-area: left; clip-path: polygon(0% 50%, 100% 0%, 100% 100%); }
.nav-right { grid-area: right; clip-path: polygon(0% 0%, 100% 50%, 0% 100%); }
.nav-center { grid-area: center; background-color: #656565; border-radius: 50%; }

.nav-up::after { content: ""; width:0; height:0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-bottom: 7px solid #ccc;}
.nav-down::after { content: ""; width:0; height:0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 7px solid #ccc;}
.nav-left::after { content: ""; width:0; height:0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-right: 7px solid #ccc;}
.nav-right::after { content: ""; width:0; height:0; border-top: 5px solid transparent; border-bottom: 5px solid transparent; border-left: 7px solid #ccc;}

.function-row {
    display: grid;
    gap: 8px;
    margin-top: 10px;
}
.function-row-cols-4 {
    grid-template-columns: repeat(4, 1fr);
}
.function-row-cols-6 {
    grid-template-columns: repeat(6, 1fr);
}

.function-row .btn {
    padding: 5px; /* Less padding as content is managed more internally */
    font-size: 0.9em;
    font-weight: 600;
    border: 1px solid #282828;
    border-radius: 6px;
    background-color: #4a4a52;
    color: white;
    cursor: pointer;
    box-shadow: 0 3px 0 #303030, 0 4px 4px rgba(0,0,0,0.2);
    transition: all 0.1s ease;
    position: relative;
    display: flex; /* This might be overridden by .row4-buttons .btn if needed, but good default */
    flex-direction: column; /* Default assumption for label flow */
    align-items: center;
    justify-content: center;
    min-height: 48px;
    text-align: center;
    line-height: 1.2;
}

.function-row .btn:active {
    transform: translateY(2px);
    box-shadow: 0 1px 0 #303030, 0 2px 2px rgba(0,0,0,0.2), inset 0 1px 1px rgba(0,0,0,0.1);
}

/* --- General Label Styling for MOST buttons (SHIFT top-left, ALPHA/BASE-N top-right) --- */
.btn .shift-text-label,
.btn .alpha-text-label, /* Default alpha label styling */
.btn .base-n-text-label {
    font-size: 0.65em; /* Unified size */
    font-weight: normal;
    position: absolute;
    top: 3px;
    text-transform: uppercase;
    line-height: 1;
    padding: 1px 2px; /* Added small padding */
}

.btn .shift-text-label {
    left: 4px;
    color: #ffd700; /* Gold */
}
.btn .alpha-text-label { /* Default for buttons like CALC, ∫ */
    right: 4px;
    color: #ff69b4; /* Hot Pink / Magenta */
}
.btn .base-n-text-label { /* For DEC, HEX, BIN, OCT */
    right: 4px;
    color: #4FC3F7; /* Light Blue */
}

.btn .main-content {
    font-size: 1em;
    display: block; /* or inline-block, or flex item */
    margin-top: 0; /* Base */
    font-family: 'Arial', sans-serif;
}

/* Push main content down IF top labels are present (default behavior) */
/* This applies when labels are positioned as per the general rule above */
.function-row:not(.row4-buttons):not(.row6-buttons):not(.number-pad-row) .btn .shift-text-label ~ .main-content,
.function-row:not(.row4-buttons):not(.row6-buttons):not(.number-pad-row) .btn .alpha-text-label ~ .main-content,
.function-row:not(.row4-buttons):not(.row6-buttons):not(.number-pad-row) .btn .base-n-text-label ~ .main-content {
    margin-top: 14px;
}


/* --- Specific Label Styling for ROW 4 BUTTONS (SHIFT top-center, ALPHA bottom-center) --- */
.function-row.row4-buttons .btn .shift-text-label {
    /* top: 3px; (inherited) */
    left: 50%;
    transform: translateX(-50%);
    /* color: #ffd700; (inherited) */
    /* font-size, text-transform, etc. inherited */
}

.function-row.row4-buttons .btn .alpha-text-label {
    top: auto; /* CRITICAL: Unset top positioning */
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    color: #ff69b4; /* Ensure red/pink as per prompt */
    /* font-size, text-transform, etc. inherited */
}

.function-row.row4-buttons .btn .main-content {
    margin-top: 0; /* Override any inherited margin */
    padding: 0;    /* Override any inherited padding that might affect layout */
    height: 100%;  /* Allow vertical centering */
    width: 100%;   /* Allow horizontal centering */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2em; /* Make main text more prominent for this row */
    font-weight: bold; /* As seen in image for sin, cos, tan */
}
/* Special styling for specific symbols in row 4 for better appearance */
.function-row.row4-buttons .btn .main-content.neg-symbol {
    font-size: 1.5em; /* Make (–) larger */
}
.function-row.row4-buttons .btn .main-content.dms-symbol {
    font-size: 1em; /* ° ′ ″ might need slightly smaller or adjusted spacing */
    letter-spacing: -0.5px; /* Tighten up DMS symbols if needed */
}


/* --- Symbol styling (from previous steps, ensure they are still fine) --- */
.optn-btn .main-content { font-size: 0.95em; }
.calc-btn .main-content { font-size: 0.95em; }

.integration-btn-user .main-content { font-size: 1.5em; line-height: 1; font-family: 'Times New Roman', serif;}
.integration-btn-user .shift-text-label { font-style: italic; font-size: 0.7em; }
.integration-btn-user .alpha-text-label { font-size: 0.8em; font-weight: bold; }

.log-base-sum-btn .main-content { font-size: 0.9em; display: inline-flex; align-items: baseline;}
.log-base-sum-btn .shift-text-label {font-size: 1.1em;}

.sym-box-sub { display: inline-block; width: 0.5em; height: 0.5em; border: 1px solid currentColor; vertical-align: sub; margin: 0 0.1em; }
.sym-box-main { display: inline-block; width: 0.6em; height: 0.6em; border: 1px solid currentColor; margin-left: 0.1em; }

.sym-fraction { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 0.6; transform: scale(0.85); }
.sym-fraction.inline { transform: scale(0.8); margin-left: 1px; }
.sym-fraction .sym-box, .sym-mixed-fraction .sym-box { width: 0.65em; height: 0.65em; border: 1.5px solid currentColor; display: inline-block; box-sizing: border-box; }
.sym-fraction .sym-line { width: 0.9em; height: 1.5px; background-color: currentColor; margin: 0.05em 0; }
.sym-mixed-fraction { display: inline-flex; align-items: center; justify-content: center; transform: scale(0.85); }
.sym-mixed-fraction .sym-box.whole { width: 0.7em; height: 0.7em; margin-right: 0.15em; }

.sym-box-inline, sup .sym-box-inline-sup { display: inline-block; width: 0.55em; height: 0.55em; border: 1px solid currentColor; box-sizing: border-box; font-size: 0.9em; line-height: 0.55em; vertical-align: baseline; }
sup .sym-box-inline-sup { vertical-align: super; }
sup > .sym-box-inline, .main-content sup > .sym-box-inline { transform: translateY(-0.1em) scale(0.9); }
.shift-text-label sup > .sym-box-inline { transform: translateY(-0.2em) scale(0.8); }

.btn .shift-text-label .sym-mixed-fraction, .btn .shift-text-label sup, .btn .shift-text-label .sym-box-inline { font-size: 0.9em; }
.btn .main-content log, .btn .main-content ln { font-size: 1.1em; } /* For log/ln text in other buttons */
.btn sup, .btn sub { font-size: 0.75em; line-height: 0; } /* Ensure sup/sub don't mess up line height too much */
.function-row .btn i { font-style: italic; }
/* --- Styling for 5th Row (STO, ENG, etc.) --- */
/* Row 5 mostly uses existing .btn, .shift-text-label, .alpha-text-label */
/* Need to ensure the general margin-top rule for main-content applies if labels are present */
.row5-buttons .btn .shift-text-label ~ .main-content,
.row5-buttons .btn .alpha-text-label ~ .main-content {
    margin-top: 14px; /* Same as other function rows with top-corner labels */
}

.complex-i {
    color: #c774a8; /* A purplish-pink, adjust as needed */
    font-style: italic;
    font-weight: 500; /* slightly less bold than main text maybe */
    margin-left: 3px;
    font-size: 0.9em;
}

.paren-symbol {
    font-size: 1.4em; /* Make parentheses larger */
    font-weight: normal;
}
.s-d-symbol {
    font-size: 1.1em; /* S<->D slightly larger */
    font-weight: bold;
}
.s-d-shift-label {
    font-size: 0.55em !important; /* Override general to make it very small */
    letter-spacing: -0.5px;
    white-space: nowrap; /* Try to keep on one line */
    left: 50% !important; /* Center it for better fit */
    transform: translateX(-50%) !important;
    top: 2px !important; /* Adjust top position */
    padding: 0 !important;
}
.s-d-shift-label sup, .s-d-shift-label sub {
    line-height: 0;
    font-size: 0.9em; /* relative to its parent (0.55em) */
}


/* --- Styling for 6th Row (Numbers, DEL, AC) --- */
.row6-buttons {
    /* 3 standard buttons, 2 wider control buttons */
    grid-template-columns: 1fr 1fr 1fr 1.5fr 1.5fr;
}

.row6-buttons .btn,
.number-pad-row .btn { /* Apply common structure to all numpad rows */
    /* Buttons in this row have labels above main content */
    padding-top: 3px; /* Give a bit of space for labels inside */
    padding-bottom: 3px;
    justify-content: flex-start; /* Align content (labels, main text) to the top */
}

.row6-buttons .btn .labels-above,
.number-pad-row .btn .labels-above { /* Apply common structure */
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    min-height: 14px; /* Ensure space for up to two labels */
    margin-bottom: 2px; /* Space between labels and main content */
}

.row6-buttons .btn .labels-above .shift-text-label,
.row6-buttons .btn .labels-above .alpha-text-label,
.number-pad-row .btn .labels-above .shift-text-label,
.number-pad-row .btn .labels-above .alpha-text-label { /* Apply common structure */
    position: static; /* Override absolute positioning */
    transform: none; /* Reset transform */
    font-size: 0.65em; /* Consistent small label size */
    line-height: 1.1; /* Allow labels to stack closely */
    padding: 0;
    text-align: center;
    width: auto; /* Don't force full width, let text centering work */
}

.row6-buttons .btn .labels-above .shift-text-label,
.number-pad-row .btn .labels-above .shift-text-label { /* Common color */
    color: #ffd700; /* Gold */
}
.row6-buttons .btn .labels-above .alpha-text-label,
.number-pad-row .btn .labels-above .alpha-text-label { /* Common color */
    color: #ff69b4; /* Pink */
}

.row6-buttons .btn .main-content,
.number-pad-row .btn .main-content { /* Common structure */
    margin-top: 0; /* Reset any margin from general rules */
    font-size: 1.3em; /* Default for this row */
    width: 100%; /* Ensure it takes width for centering */
    text-align: center; /* Center the main content text */
    line-height: 1.2; /* Adjust for main content */
}

.btn-numeric {
    background-color: #d4d4d2; /* Light gray */
    color: #222222; /* Dark gray/black text */
    font-weight: 500; /* Slightly less bold than control keys maybe */
}
.btn-numeric .main-content {
    font-size: 1.5em; /* Larger for numbers */
    font-family: 'Open Sans', sans-serif; /* Standard font for numbers */
}
.btn-numeric:active {
    background-color: #bfbfba;
}

.btn-control-del,
.btn-control-ac {
    background-color: #007bff; /* A common blue, can be adjusted to match image */
    color: white;
    font-weight: bold;
}
.btn-control-del .main-content,
.btn-control-ac .main-content {
    font-size: 1.25em; /* Slightly smaller than numbers, but bold */
    font-family: 'Open Sans', sans-serif;
}
.btn-control-del:active {
    background-color: #0069d9;
}
.btn-control-ac:active {
    background-color: #0069d9;
}

/* Override for row 5 buttons that don't have alpha label for centering main content better */
.row5-buttons .btn:not(:has(.alpha-text-label)) .shift-text-label ~ .main-content {
     /* If only shift label, the margin-top: 14px still applies which is fine */
}
.row5-buttons .btn:not(:has(.shift-text-label)):not(:has(.alpha-text-label)) .main-content {
    margin-top: 0 !important; /* If NO labels, center fully */
}


/* --- Styling for 7th, 8th, 9th Rows (Number Pad and Operators) --- */
.number-pad-row {
    /* All these rows have 5 buttons of equal width */
    grid-template-columns: repeat(5, 1fr);
}

/* Numeric buttons in these rows (0-9, ., Ans, x10^x) will use .btn-numeric style for color */
/* .btn-numeric styles are already defined from row 6, they will apply here */

/* Operator buttons (×, ÷, +, −, =) */
.btn-operator {
    background-color: #d4d4d2; /* Light gray, same as numeric for this model */
    color: #222222; /* Dark gray/black text */
    font-weight: normal; /* Operators are typically not as bold as numbers on some calculators */
}
.btn-operator .main-content.op-symbol {
    font-size: 1.5em; /* Make operator symbols prominent */
    font-family: 'Arial', sans-serif; /* Good for symbols */
}
.btn-operator .main-content.op-minus {
    font-size: 1.8em; /* Minus might need to be a bit larger/thicker */
    position: relative;
    top: -0.05em; /* slight vertical adjustment if needed */
}
.btn-operator:active {
    background-color: #bfbfba;
}

.btn-equals { /* Specific for equals if slightly different styling is needed, e.g., more prominent */
    font-weight: bold; /* Make equals sign bold */
}
.btn-equals .main-content.op-symbol {
    font-size: 1.6em;
}


/* Specific styling for some main content elements in numpad rows */
.decimal-point {
    font-size: 1.8em; /* Larger decimal point */
    font-weight: bold;
    line-height: 0.8; /* Adjust line height to center it better */
}
.sci-notation-symbol {
    font-size: 1.0em; /* Adjust as needed for x10x */
    font-weight: 500;
    letter-spacing: -0.5px; /* Tighten spacing */
}
.sci-notation-symbol sup {
    font-size: 0.8em; /* Smaller superscript for 'x' */
    vertical-align: super;
    line-height: 0;
}
.number-pad-row .btn .labels-above .alpha-text-label i { /* for italic 'e' */
    font-style: italic;
    text-transform: lowercase; /* Ensure 'e' is lowercase */
}

/* Ensure the labels-above div doesn't exist or is empty for buttons without top labels (like 4,5,6) */
.number-pad-row .btn:not(:has(.labels-above:not(:empty))) .main-content {
    /* If no labels-above or it's empty, ensure main content is centered vertically */
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%; /* Take full button height */
    padding-top: 0; /* Reset padding that might have been for labels */
    padding-bottom: 0;
}
/* For buttons 4, 5, 6 that have no labels at all */
.number-pad-row .btn.btn-numeric:not(:has(.labels-above)) .main-content {
    font-size: 1.6em; /* Make numbers 4,5,6 slightly larger as they fill the button */
}