/* Calculator Page Styles */
.calculator-container {
    max-width: 480px;
    margin: 1.25rem auto;
    background-color: #f0f2f5;
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.13);
    overflow: hidden;
    padding: 1rem 1rem 1.25rem;
}

.calculator-tabs {
    display: flex;
    border-bottom: 2px solid var(--light-gray);
    margin-bottom: 0.75rem;
}

.tab-btn {
    padding: 0.6rem 1rem;
    background: none;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab-btn:hover {
    color: var(--primary-color);
    background-color: var(--bg-hover);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Basic & Scientific Calculator */
.calc-display {
    width: 100%;
    padding: 1.25rem 1rem;
    font-size: 1.5rem;
    min-height: 4.5rem;
    text-align: right;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 0.4rem;
    background-color: var(--light-color);
    font-family: 'Courier New', monospace;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

#scientific-tab .scientific-display-wrapper {
    margin-bottom: 0.4rem;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
}

.scientific-grid {
    grid-template-columns: repeat(5, 1fr);
}

.scientific-display-wrapper {
    margin-bottom: 0.75rem;
}

.angle-mode-toggle {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.angle-mode-toggle label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    cursor: pointer;
}

.angle-mode-toggle input[type="radio"] {
    accent-color: var(--primary-color);
}

.sci-mode-toggle {
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

.sci-mode-btn {
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-light);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.sci-mode-btn.active {
    background-color: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

.sci-mode-panel {
    display: none;
}

.sci-mode-panel.active {
    display: grid;
}

.calc-btn {
    padding: 1rem;
    font-size: 1.25rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.calc-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--primary-color);
}

.calc-btn.operator {
    background-color: var(--light-gray);
    color: var(--primary-color);
    font-weight: 600;
}

.calc-btn.equals {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.calc-btn.equals:hover {
    background-color: var(--primary-hover);
}

.calc-btn.clear {
    background-color: #ffe3e3;
    color: #e03131;
    border-color: #ffc9c9;
}

/* ── Compact Scientific Keypad ────────────────────────────── */
.sci-keypad {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 5px;
    background: #555e6b;
    border-radius: 10px;
    padding: 6px;
}

.sci-btn {
    padding: 0.32rem 0.15rem;
    font-size: 0.83rem;
    font-weight: 500;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    transition: filter 0.12s, transform 0.1s;
    background: #f5f6f8;
    color: #1a1a2e;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 2px 0 #3a424e, 0 2px 4px rgba(0,0,0,0.18);
}

.sci-btn:hover  { filter: brightness(0.93); }
.sci-btn:active { transform: translateY(1px); box-shadow: 0 1px 0 #3a424e, 0 1px 2px rgba(0,0,0,0.15); filter: brightness(0.88); }

/* Angle mode buttons */
.sci-mode-rad,
.sci-mode-deg {
    background: #f5f6f8;
    color: #00897b;
    font-weight: 700;
    font-size: 0.82rem;
}
.sci-mode-rad.active,
.sci-mode-deg.active {
    background: #00897b;
    color: #ffffff;
    box-shadow: 0 2px 0 #005a50, 0 2px 4px rgba(0,0,0,0.18);
}

/* Inverse trig */
.sci-inv {
    color: #00897b;
    font-size: 0.75rem;
    font-weight: 600;
    background: #f5f6f8;
}

/* Regular trig */
.sci-trig {
    color: #00897b;
    font-weight: 600;
    background: #f5f6f8;
}

/* Math function keys (√, ln, log, n!, %, x^) */
.sci-fn {
    background: #f5f6f8;
    color: #2c2c2c;
}

/* Parentheses */
.sci-paren {
    background: #f5f6f8;
    color: #444;
    font-size: 1.05rem;
}

/* Clear */
.sci-clear {
    background: #f5f6f8;
    color: #555;
    font-size: 0.78rem;
}
.sci-clear:hover {
    background: #ffe3e3;
    color: #e03131;
    filter: none;
}

/* Constants π and e */
.sci-const {
    color: #00897b;
    font-style: italic;
    font-size: 1rem;
    font-weight: 600;
    background: #f5f6f8;
}

/* Operators ÷ × − + */
.sci-op {
    background: #f5f6f8;
    color: #1a1a2e;
    font-size: 1rem;
}

/* Number buttons */
.sci-num {
    background: #ffffff;
    font-size: 1rem;
    font-weight: 500;
    color: #1a1a2e;
}

/* Equals */
.sci-equals {
    background: #00897b;
    color: #ffffff;
    font-size: 1.25rem;
    font-weight: 700;
    border-radius: 7px;
    box-shadow: 0 2px 0 #005a50, 0 2px 4px rgba(0,0,0,0.18);
}
.sci-equals:hover { filter: brightness(0.88); }
.sci-equals:active { transform: translateY(1px); box-shadow: 0 1px 0 #005a50; }

/* ── Embed mode (graphing panel, ?embed=1) ── */
html.embed-mode body { overflow: hidden; height: 100vh; }
html.embed-mode .navbar,
html.embed-mode .footer,
html.embed-mode .calculator-tabs { display: none !important; }
html.embed-mode .main-content { padding: 0 !important; }

/* ── Calculator panel mode (scientific only, ?calc=1) ── */
html.calc-panel-mode body { overflow: hidden; }
html.calc-panel-mode .navbar,
html.calc-panel-mode .footer,
html.calc-panel-mode .calculator-tabs { display: none !important; }
html.calc-panel-mode .main-content { padding: 0 !important; }
html.calc-panel-mode .calculator-container {
    margin: 0;
    max-width: 100%;
    border-radius: 0;
    box-shadow: none;
    padding: 0.75rem;
}

/* ═══════════════════════════════════════════════════════════
   GRAPHING CALCULATOR — full-screen Desmos-style layout
   ═══════════════════════════════════════════════════════════ */

/* 1. Body override when graphing tab is open */
body.graph-fullscreen {
    overflow: hidden;
    height: 100vh;
}
body.graph-fullscreen .footer { display: none; }
body.graph-fullscreen .main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
}
body.graph-fullscreen .calculator-container {
    flex: 1;
    max-width: 100%;
    width: 100%;
    margin: 0;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}
body.graph-fullscreen .calculator-tabs {
    flex-shrink: 0;
    padding: 0 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: white;
}

/* 2. The graphing tab itself fills the remaining space */
#graphing-tab.active {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    /* top is set dynamically by fitGraphingTab() in JS */
    display: flex !important;
    flex-direction: row;
    align-items: stretch;   /* children fill the full height */
    overflow: hidden;
    background: white;
    z-index: 100;
}

/* 3. Left sidebar — expression / points panel */
.graph-sidebar {
    width: 280px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e5e7eb;
    background: #ffffff;
    overflow: hidden;
    transition: width 0.25s ease;
    /* height filled by align-items: stretch on parent */
}
.graph-sidebar.collapsed {
    width: 0;
    min-width: 0;
    border-right: none;
}
.graph-sidebar.collapsed .graph-panel,
.graph-sidebar.collapsed .graph-sidebar-footer,
.graph-sidebar.collapsed .graph-sidebar-modes {
    display: none;
}

/* 4. Mode tabs inside the sidebar */
.graph-sidebar-modes {
    display: flex;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}

/* Sidebar collapse grip strip */
.sidebar-toggle-btn {
    flex-shrink: 0;
    width: 14px;
    border: none;
    border-left: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    background: #f8fafc;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0;
    transition: background 0.15s, border-color 0.15s, width 0.15s;
    position: relative;
}
.sidebar-toggle-btn:hover {
    background: #e8f0fe;
    border-color: var(--primary-color);
    width: 18px;
}
.sidebar-grip {
    display: block;
    width: 3px;
    height: 20px;
    background: #cbd5e1;
    border-radius: 3px;
    transition: background 0.15s;
}
.sidebar-toggle-btn:hover .sidebar-grip {
    background: var(--primary-color);
}
.sidebar-chevron {
    font-size: 0.55rem;
    color: #94a3b8;
    transition: color 0.15s, transform 0.25s;
}
.sidebar-toggle-btn:hover .sidebar-chevron {
    color: var(--primary-color);
}
.graph-sidebar.collapsed ~ .sidebar-toggle-btn .sidebar-chevron {
    transform: rotate(180deg);
}
.graph-mode-btn {
    flex: 1;
    padding: 0.7rem 0.5rem;
    border: none;
    background: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: #6b7280;
    letter-spacing: 0.02em;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s;
}
.graph-mode-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
    background: #f5f7ff;
}
.graph-mode-btn:hover:not(.active) {
    color: #374151;
    background: #f9fafb;
}

/* 5. Panels inside the sidebar */
.graph-panel {
    display: none;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}
.graph-panel.active { display: flex; }

/* 6. Function expression input row */
.graph-expr-input {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.6rem 0.65rem;
    border-bottom: 1px solid #e5e7eb;
    flex-shrink: 0;
}
.function-input {
    flex: 1;
    min-width: 0;
    padding: 0.45rem 0.65rem;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: 'Courier New', monospace;
    background: #f9fafb;
    transition: border-color 0.15s, background 0.15s;
}
.function-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: #fff;
}

/* MathQuill live-render overrides for the function input */
.function-input.mq-editable-field {
    display: inline-flex;
    align-items: center;
    position: relative;
    cursor: text;
    overflow: hidden;
    min-height: 2.1rem;
    box-sizing: border-box;
}
.function-input.mq-editable-field .mq-root-block {
    flex: 1;
    white-space: nowrap;
    padding: 0;
}
.function-input.mq-focused {
    border-color: var(--primary-color) !important;
    background: #fff !important;
    outline: none !important;
}
/* Placeholder shown when field is empty */
.function-input.mq-empty::before {
    content: attr(data-placeholder);
    position: absolute;
    color: #9ca3af;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    font-style: italic;
    pointer-events: none;
    left: 0.65rem;
}

/* Small icon buttons beside the input */
.gsi-btn {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    color: #374151;
    transition: all 0.15s;
}
.gsi-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f0f4ff;
}
.gsi-plot {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}
.gsi-plot:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: white;
}

/* 7. Expression list */
.fn-list {
    flex: 1;
    overflow-y: auto;
    padding: 0.35rem 0.5rem;
}
.fn-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.55rem;
    border-radius: 6px;
    font-size: 0.82rem;
    font-family: 'Courier New', monospace;
    transition: background 0.1s;
    border: 1px solid transparent;
}
.fn-item:hover {
    background: #f9fafb;
    border-color: #e5e7eb;
}
.fn-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}
.fn-latex {
    flex: 1;
    word-break: break-all;
    color: #1f2937;
}
.fn-remove-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #d1d5db;
    font-size: 0.7rem;
    padding: 0.15rem 0.3rem;
    border-radius: 3px;
    transition: all 0.1s;
    flex-shrink: 0;
}
.fn-remove-btn:hover { color: #ef4444; background: #fee2e2; }

/* 8. Points panel — scrollable table + fixed controls */
.points-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.points-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.points-table th {
    padding: 0.35rem 0.4rem;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    font-weight: 600;
    color: #6b7280;
    text-align: center;
    position: sticky;
    top: 0;
    z-index: 1;
}
.points-table td {
    padding: 0;
    border: 1px solid #e5e7eb;
}
.point-x, .point-y {
    width: 100%;
    padding: 0.35rem 0.4rem;
    border: none;
    text-align: center;
    font-size: 0.875rem;
    background: transparent;
}
.point-x:focus, .point-y:focus {
    outline: none;
    background: #f0f4ff;
}
.remove-point-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #d1d5db;
    font-size: 0.75rem;
    padding: 0.3rem 0.55rem;
    width: 100%;
    transition: all 0.1s;
}
.remove-point-btn:hover { color: #ef4444; }

.btn-add-point {
    display: block;
    width: calc(100% - 1rem);
    margin: 0.4rem 0.5rem;
    padding: 0.3rem;
    background: none;
    border: 1px dashed #d1d5db;
    border-radius: 5px;
    font-size: 0.8rem;
    color: #6b7280;
    cursor: pointer;
    text-align: center;
    transition: all 0.15s;
    flex-shrink: 0;
}
.btn-add-point:hover { border-color: var(--primary-color); color: var(--primary-color); }

/* 9. Bestfit buttons section */
.graph-bestfit-section {
    flex-shrink: 0;
    padding: 0.6rem 0.65rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}
.gbf-btn {
    padding: 0.52rem 0.75rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    transition: opacity 0.15s;
    text-align: center;
}
.gbf-btn:hover { opacity: 0.85; }
.gbf-plot  { background: var(--primary-color); color: white; }
.gbf-line  { background: #4dabf7; color: white; }
.gbf-curve { background: #f783ac; color: white; }

.gbf-curve-row {
    display: flex;
    flex-direction: row;
    gap: 0.3rem;
    align-items: stretch;
}
.gbf-curve-select {
    flex: 1;
    min-width: 0;
    padding: 0.42rem 0.6rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.8rem;
    background: #fff;
    color: #374151;
    cursor: pointer;
    outline: none;
}
.gbf-curve-select:focus { border-color: #f783ac; box-shadow: 0 0 0 2px rgba(247,131,172,0.2); }

.bestfit-result {
    padding: 0.55rem 0.7rem;
    background: #f0f4ff;
    border: 1px solid #c7d2fe;
    border-radius: 6px;
    font-size: 0.82rem;
    font-family: 'Courier New', monospace;
    color: #3730a3;
    display: none;
    line-height: 1.5;
    word-break: break-word;
}
.bestfit-result:not(:empty) { display: block; }

/* 10. Sidebar footer */
.graph-sidebar-footer {
    flex-shrink: 0;
    padding: 0.55rem 0.65rem;
    border-top: 1px solid #e5e7eb;
    background: #fafafa;
    display: flex;
    gap: 0.4rem;
    align-items: center;
}
.graph-btn-clear {
    flex: 1;
    padding: 0.45rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    color: #6b7280;
    transition: all 0.15s;
}
.graph-btn-clear:hover { border-color: #ef4444; color: #ef4444; background: #fff5f5; }

/* 11. Desmos canvas fills the rest */
#desmos-calculator .dcg-graphpaper-branding,
#desmos-calculator .dcg-expressions-branding {
    display: none !important;
}

/* Wrapper that holds both the toolbar overlay and the Desmos canvas */
.graph-canvas-wrap {
    flex: 1;
    min-width: 0;
    position: relative;
    /* height filled by align-items: stretch on the parent flex row */
}

.desmos-canvas {
    position: absolute;
    inset: 0;
}

/* ── Graph canvas toolbar (fullscreen + save buttons) ─────── */
.graph-canvas-toolbar {
    position: absolute;
    bottom: 10px;
    right: 10px;
    z-index: 10;
    display: flex;
    gap: 6px;
}

.graph-tool-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.92);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    color: #374151;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.18);
    transition: background 0.15s, box-shadow 0.15s, transform 0.1s;
}
.graph-tool-btn:hover {
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22);
    transform: scale(1.06);
}
.graph-tool-btn:active {
    transform: scale(0.97);
}

/* ── Fullscreen state for the graphing tab ────────────────── */
#graphing-tab:fullscreen {
    top: 0 !important;
    width: 100vw;
    height: 100vh;
}
#graphing-tab:-webkit-full-screen {
    top: 0 !important;
    width: 100vw;
    height: 100vh;
}

/* Shared plot/action button (used by matrix "Set Dimensions") */
.btn-plot {
    padding: 0.6rem 1.25rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}
.btn-plot:hover { background-color: var(--primary-hover); }

/* Matrix Calculator */
.matrix-controls {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: var(--light-color);
    border-radius: 8px;
}

.dimension-inputs {
    display: flex;
    gap: 2rem;
    margin-bottom: 1rem;
}

.dim-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dim-group input {
    width: 60px;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.matrix-workspace {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 2rem;
    align-items: start;
}

.matrix-box h3 {
    margin-bottom: 1rem;
    color: var(--text-secondary);
    text-align: center;
}

.matrix-grid {
    display: grid;
    gap: 0.5rem;
    padding: 1rem;
    background-color: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.matrix-row {
    display: flex;
    gap: 0.5rem;
}

.matrix-cell {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.matrix-cell input {
    width: 100%;
    padding: 0.5rem;
    text-align: center;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.matrix-operations {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding-top: 2rem;
}

.op-btn {
    padding: 0.75rem;
    background-color: white;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.op-btn:hover {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.matrix-result {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

/* Virtual Keyboard */
.virtual-keyboard {
    position: fixed;
    bottom: 0.5rem;
    left: 50%;
    transform: translateX(-50%);
    max-width: 560px;
    width: calc(100% - 2rem);
    background-color: var(--bg-light);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    z-index: 2000;
    padding: 0.75rem 0.5rem;
    border-top: 1px solid var(--border-color);
    transition: transform 0.3s ease-in-out;
}

.virtual-keyboard.hidden {
    transform: translate(-50%, 100%);
}

.keyboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.keyboard-header span {
    font-weight: 600;
    color: var(--primary-color);
}

.close-keyboard-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.keyboard-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0.4rem;
    max-width: 520px;
    margin: 0 auto;
}

.k-btn {
    padding: 0.55rem 0.4rem;
    font-size: 0.95rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: white;
    cursor: pointer;
    transition: all 0.2s;
}

.k-btn:hover {
    background-color: var(--bg-hover);
    border-color: var(--primary-color);
}

.k-btn:active {
    transform: scale(0.95);
}

.show-keyboard-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: white;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    cursor: pointer;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.show-keyboard-btn.hidden {
    display: none;
}

.show-keyboard-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: #f5f7ff;
}

/* ── Responsive: Mobile & Tablet ──────────────────────────── */
@media (max-width: 576px) {
    .calculator-container {
        margin: 0.75rem;
        padding: 0.75rem 0.75rem 1rem;
        border-radius: 10px;
    }

    .calc-btn {
        padding: 0.75rem 0.4rem;
        font-size: 1rem;
    }

    .calc-grid {
        gap: 0.5rem;
    }

    .sci-keypad {
        gap: 3px;
        padding: 4px;
    }

    .sci-btn {
        padding: 0.28rem 0.1rem;
        font-size: 0.75rem;
    }
}

@media (max-width: 768px) {
    .matrix-workspace {
        grid-template-columns: 1fr;
    }

    .matrix-operations {
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        padding-top: 0;
        margin-bottom: 1rem;
    }

    .dimension-inputs {
        flex-wrap: wrap;
        gap: 1rem;
    }
}
