/* Scientific Calculator — scoped to page-calculator--math */

.page-calculator--math .sci-section {
    padding: 0 0 3rem;
}

.page-calculator--math .sci-layout {
    display: grid;
    grid-template-columns: minmax(0, 520px) minmax(0, 320px);
    gap: 1.5rem;
    align-items: start;
    justify-content: center;
    max-width: 900px;
    margin: 0 auto;
}

.page-calculator--math .scientific-calculator {
    background: var(--pg-surface);
    border: 1px solid var(--pg-border);
    border-radius: 20px;
    padding: 1.25rem;
    box-shadow: var(--pg-shadow);
}

.page-calculator--math .sci-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.55rem 0.75rem;
    background: var(--pg-primary-soft);
    border-radius: 12px;
    font-size: 0.82rem;
}

.page-calculator--math .sci-toolbar-left,
.page-calculator--math .sci-toolbar-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.page-calculator--math .sci-mode-label {
    color: var(--pg-muted);
    font-weight: 500;
}

.page-calculator--math .sci-mode-value {
    font-weight: 700;
    color: var(--pg-accent);
}

.page-calculator--math .sci-memory-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    padding: 0 0.35rem;
    border-radius: 6px;
    background: var(--pg-accent);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
}

.page-calculator--math .sci-memory-badge[hidden] {
    display: none !important;
}

.page-calculator--math .sci-btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: 1px solid var(--pg-border);
    border-radius: 8px;
    background: white;
    color: var(--pg-accent);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.page-calculator--math .sci-btn-icon:hover {
    background: white;
    border-color: var(--pg-accent);
}

.page-calculator--math .sci-display-wrap {
    margin-bottom: 1rem;
}

.page-calculator--math .sci-error {
    min-height: 1.25rem;
    margin-bottom: 0.35rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #dc2626;
}

.page-calculator--math .sci-error[hidden] {
    display: none !important;
}

.page-calculator--math .calculator-display {
    background: linear-gradient(145deg, #1e293b, #334155);
    border-radius: 14px;
    padding: 1.25rem 1rem;
}

.page-calculator--math .display-screen {
    text-align: right;
    color: white;
    font-variant-numeric: tabular-nums;
}

.page-calculator--math .sci-expression-label {
    display: block;
    margin-bottom: 0.25rem;
    color: #94a3b8 !important;
    font-size: 0.7rem;
    font-weight: 600;
    text-align: left;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.page-calculator--math .sci-expression-input {
    width: 100%;
    min-height: 2.4rem;
    padding: 0.2rem 0;
    border: 0 !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2) !important;
    border-radius: 0 !important;
    outline: none;
    background: transparent !important;
    color: #fff !important;
    font: 500 1.08rem/1.5 'Plus Jakarta Sans', sans-serif;
    text-align: right;
    caret-color: #67e8f9;
}

.page-calculator--math .sci-expression-input:focus {
    border-bottom-color: #67e8f9 !important;
    box-shadow: none !important;
}

.page-calculator--math .sci-expression-input::placeholder {
    color: #94a3b8;
    opacity: 0.75;
}

.page-calculator--math .previous-operand {
    font-size: 0.95rem;
    opacity: 0.65;
    min-height: 1.35rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-calculator--math .current-operand {
    font-size: clamp(1.75rem, 5vw, 2.35rem);
    font-weight: 600;
    line-height: 1.15;
    word-break: break-all;
}

.page-calculator--math .sci-cursor-tools {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.page-calculator--math .sci-cursor-tools .btn {
    height: 38px;
    border: 1px solid #c4b5fd;
    border-radius: 9px;
    background: #f5f3ff;
    color: #6d28d9;
    font: 700 0.82rem/1 'Plus Jakarta Sans', sans-serif;
    cursor: pointer;
}

.page-calculator--math .sci-cursor-tools .btn:hover {
    background: #ede9fe;
}

.page-calculator--math .calculator-buttons {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.5rem;
}

.page-calculator--math .calculator-buttons .btn {
    border: none;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 600;
    height: 46px;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
    font-family: inherit;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.page-calculator--math .calculator-buttons .btn:hover {
    transform: translateY(-1px);
}

.page-calculator--math .calculator-buttons .btn:active {
    transform: translateY(0);
}

.page-calculator--math .btn-number {
    background: #f8fafc;
    color: var(--pg-text);
    border: 1px solid var(--pg-border);
}

.page-calculator--math .btn-number:hover {
    background: #f1f5f9;
}

.page-calculator--math .btn-operator {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: white;
}

.page-calculator--math .btn-function {
    background: #64748b;
    color: white;
    font-size: 0.75rem;
}

.page-calculator--math .btn-function:hover {
    background: #475569;
}

.page-calculator--math .btn-scientific {
    background: #0891b2;
    color: white;
    font-size: 0.72rem;
}

.page-calculator--math .btn-scientific:hover {
    background: #0e7490;
}

.page-calculator--math .btn-equals {
    background: linear-gradient(135deg, #059669, #10b981);
    color: white;
}

html[data-theme="dark"] .page-calculator--math .sci-cursor-tools .btn {
    border-color: #4c3b7a;
    background: #211a38;
    color: #c4b5fd;
}

.page-calculator--math .btn-wide {
    grid-column: span 2;
}

.page-calculator--math .sci-hint {
    margin-top: 0.85rem;
    text-align: center;
    font-size: 0.72rem;
    color: var(--pg-muted);
}

/* History panel — desktop sidebar */
.page-calculator--math .sci-history-panel {
    background: var(--pg-surface);
    border: 1px solid var(--pg-border);
    border-radius: 20px;
    box-shadow: var(--pg-shadow);
    overflow: hidden;
}

.page-calculator--math .sci-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.1rem;
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: white;
}

.page-calculator--math .sci-history-header h2 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.page-calculator--math .sci-history-clear {
    border: none;
    background: rgba(255, 255, 255, 0.18);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
}

.page-calculator--math .sci-history-clear:hover {
    background: rgba(255, 255, 255, 0.28);
}

.page-calculator--math .sci-history-list {
    max-height: 520px;
    overflow-y: auto;
    padding: 0.5rem;
}

.page-calculator--math .sci-history-empty {
    text-align: center;
    color: var(--pg-muted);
    font-size: 0.875rem;
    padding: 2rem 1rem;
    margin: 0;
}

.page-calculator--math .sci-history-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.15rem;
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 0.35rem;
    border: 1px solid var(--pg-border);
    border-radius: 10px;
    background: #fafafa;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: border-color 0.15s, background 0.15s;
}

.page-calculator--math .sci-history-item:hover {
    border-color: var(--pg-accent);
    background: var(--pg-primary-soft);
}

.page-calculator--math .sci-history-expr {
    font-size: 0.82rem;
    color: var(--pg-text);
    font-weight: 600;
}

.page-calculator--math .sci-history-eq {
    font-size: 1rem;
    color: var(--pg-accent);
    font-weight: 700;
}

.page-calculator--math .sci-history-time {
    font-size: 0.7rem;
    color: var(--pg-muted);
}

/* Mobile history modal */
.page-calculator--math .sci-history-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
}

.page-calculator--math .sci-history-modal[hidden] {
    display: none !important;
}

.page-calculator--math .sci-history-modal-inner {
    width: 100%;
    max-width: 520px;
    max-height: 70vh;
    background: var(--pg-surface);
    border-radius: 20px 20px 0 0;
    overflow: hidden;
    animation: sciSlideUp 0.25s ease;
}

@keyframes sciSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

body.sci-modal-open {
    overflow: hidden;
}

.page-calculator--math .sci-features {
    max-width: 720px;
    margin: 2rem auto 0;
    padding: 0 0.5rem;
}

.page-calculator--math .sci-features h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
}

.page-calculator--math .sci-features ul {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem 1.5rem;
    list-style: none;
    padding: 0;
    margin: 0;
    color: var(--pg-muted);
    font-size: 0.875rem;
}

.page-calculator--math .sci-features li {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.page-calculator--math .sci-features li i {
    color: var(--pg-accent);
    font-size: 0.75rem;
}

@media (max-width: 860px) {
    .page-calculator--math .sci-layout {
        grid-template-columns: 1fr;
        max-width: 520px;
    }

    .page-calculator--math .sci-history-panel--desktop {
        display: none;
    }

    .page-calculator--math .sci-btn-icon--history {
        display: inline-flex;
    }
}

@media (min-width: 861px) {
    .page-calculator--math .page-hero {
        padding: 0.65rem 0 0.55rem;
    }

    .page-calculator--math .page-hero .breadcrumb {
        display: none;
    }

    .page-calculator--math .page-hero h1 {
        font-size: 1.6rem;
        margin-bottom: 0.2rem;
    }

    .page-calculator--math .page-hero p {
        font-size: 0.85rem;
        line-height: 1.35;
    }

    .page-calculator--math .sci-section {
        padding-bottom: 1.5rem;
    }

    .page-calculator--math .scientific-calculator {
        padding: 0.75rem;
    }

    .page-calculator--math .sci-toolbar {
        min-height: 30px;
        margin-bottom: 0.45rem;
        padding: 0.25rem 0.6rem;
    }

    .page-calculator--math .sci-btn-icon {
        width: 28px;
        height: 28px;
    }

    .page-calculator--math .sci-display-wrap {
        margin-bottom: 0.45rem;
    }

    .page-calculator--math .calculator-display {
        padding: 0.55rem 0.75rem;
    }

    .page-calculator--math .sci-expression-input {
        min-height: 1.85rem;
        font-size: 0.95rem;
        line-height: 1.3;
    }

    .page-calculator--math .previous-operand {
        min-height: 1rem;
        font-size: 0.72rem;
    }

    .page-calculator--math .current-operand {
        font-size: 1.45rem;
        line-height: 1.05;
    }

    .page-calculator--math .sci-cursor-tools {
        gap: 0.35rem;
        margin-bottom: 0.35rem;
    }

    .page-calculator--math .sci-cursor-tools .btn {
        min-height: 0;
        height: 28px;
    }

    .page-calculator--math .calculator-buttons {
        grid-template-rows: none;
        grid-auto-rows: 30px;
        gap: 0.25rem;
        aspect-ratio: auto;
    }

    .page-calculator--math .calculator-buttons .btn {
        min-height: 0;
        height: 30px;
        border-radius: 8px;
        font-size: 0.74rem;
    }

    .page-calculator--math .sci-hint {
        margin-top: 0.45rem;
        font-size: 0.67rem;
        line-height: 1.3;
    }

    .page-calculator--math .sci-history-modal {
        display: none !important;
    }

    .page-calculator--math .sci-btn-icon--history {
        display: none;
    }
}

@media (min-width: 861px) and (max-height: 800px) {
    .page-calculator--math .page-hero {
        display: none;
    }

    .page-calculator--math .sci-layout {
        padding-top: 0.5rem;
    }

    .page-calculator--math .calculator-buttons {
        grid-auto-rows: 28px;
    }

    .page-calculator--math .calculator-buttons .btn {
        height: 28px;
    }

    .page-calculator--math .sci-hint {
        display: none;
    }
}

@media (max-width: 480px) {
    .page-calculator--math .scientific-calculator {
        padding: 1rem;
    }

    .page-calculator--math .calculator-buttons .btn {
        min-height: 42px;
        height: 42px;
        font-size: 0.75rem;
    }

    .page-calculator--math .sci-features ul {
        grid-template-columns: 1fr;
    }
}
