/**
 * Expression Cards: 100% Exact Desmos Visual Typography (Image 2 Replica)
 */
.expression-card {
    background: #ffffff;
    border: 1px solid #d9dee3;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.expression-card:hover {
    border-color: #bac2cb;
}

.expression-card.focused {
    border-color: #2d70b3;
    box-shadow: 0 0 0 1px #2d70b3;
}

.expression-row-main {
    display: flex;
    align-items: stretch;
    min-height: 44px;
}

/* Desmos Authentic Left Colored Badge (Image 2) */
.desmos-left-badge {
    width: 34px;
    background: #2d70b3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    cursor: pointer;
    flex-shrink: 0;
    transition: opacity 0.15s;
}

.desmos-left-badge:hover {
    opacity: 0.9;
}

.badge-index {
    position: absolute;
    top: 3px;
    left: 4px;
    font-size: 10px;
    font-weight: 700;
    color: #ffffff;
    font-family: var(--font-mono);
}

.color-badge-container {
    display: flex;
    align-items: center;
    justify-content: center;
}

.color-disc {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.1s;
}

.color-disc:hover {
    transform: scale(1.1);
}

.color-disc.hidden-curve {
    opacity: 0.35;
    background: transparent;
    border: 1px dashed #ffffff;
}

/* Math Input & WYSIWYG Typography (Images 2 & 7) */
.math-input-wrapper {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 4px 10px;
    min-height: 44px;
}

.desmos-math-field-wrapper {
    position: relative;
    width: 100%;
    min-height: 36px;
    display: flex;
    align-items: center;
    cursor: text;
}

.desmos-math-display {
    font-family: "Times New Roman", Times, "Cambria Math", serif;
    font-size: 18px;
    color: #111418;
    line-height: 1.25;
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    white-space: pre-wrap;
    pointer-events: none;
    user-select: none;
}

.desmos-placeholder {
    color: #98a2b3;
    font-family: var(--font-sans);
    font-size: 13px;
    font-style: normal;
}

/* Authentic Desmos Blinking Typing Cursor */
.desmos-math-cursor {
    display: inline-block;
    width: 2px;
    height: 1.2em;
    background-color: #2d70b3;
    margin: 0 1px;
    vertical-align: -0.15em;
    animation: desmos-caret-blink 1s ease-in-out infinite;
}

@keyframes desmos-caret-blink {
    0%, 45% { opacity: 1; }
    50%, 95% { opacity: 0; }
    100% { opacity: 1; }
}

.desmos-math-raw-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: text;
    border: none;
    outline: none;
    background: transparent;
}

/* Authentic Desmos Fraction (Image 7 Replica) */
.desmos-fraction {
    display: inline-flex;
    flex-direction: column;
    vertical-align: middle;
    text-align: center;
    padding: 0 4px;
    margin: 0 2px;
}

.desmos-num {
    display: block;
    font-size: 0.9em;
    line-height: 1.15;
    padding-bottom: 2px;
    margin-bottom: 1px;
}

.desmos-frac-bar {
    display: block;
    height: 1.5px;
    background-color: currentColor;
    width: 100%;
}

.desmos-den {
    display: block;
    font-size: 0.9em;
    line-height: 1.15;
    padding-top: 2px;
    margin-top: 1px;
}

.desmos-var {
    font-style: italic;
    font-family: "Times New Roman", Times, "Cambria Math", serif;
    padding: 0 1px;
}

.desmos-prime {
    font-style: normal;
    font-family: "Times New Roman", Times, "Cambria Math", serif;
    padding-left: 1.5px;
    padding-right: 1px;
}

.desmos-fn {
    font-style: normal;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    padding: 0 2px;
    font-size: 0.92em;
}

.desmos-op {
    padding: 0 4px;
    font-weight: 400;
}

.desmos-paren {
    font-family: "Times New Roman", Times, serif;
    font-size: 1.05em;
}

.desmos-comma {
    margin-right: 4px;
}

.desmos-sup {
    font-size: 0.72em;
    vertical-align: 0.55em;
    margin-left: 1px;
    font-family: "Times New Roman", Times, serif;
}

.desmos-sub {
    font-size: 0.72em;
    vertical-align: -0.3em;
    margin-left: 1px;
    font-family: "Times New Roman", Times, serif;
}

.desmos-sqrt {
    display: inline-flex;
    align-items: stretch;
    margin: 0 2px;
}

.desmos-sqrt-symbol {
    font-size: 1.15em;
    line-height: 1;
    margin-right: 1px;
}

.desmos-radicand {
    border-top: 1.5px solid currentColor;
    padding-top: 1px;
    padding-left: 2px;
    padding-right: 2px;
}

/* Actions */
.expr-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    padding-right: 8px;
}

.btn-show-steps {
    background: rgba(45, 112, 179, 0.1);
    border: 1px solid rgba(45, 112, 179, 0.25);
    color: #2d70b3;
    font-size: 10.5px;
    font-weight: 700;
    padding: 3px 7px;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 3px;
    transition: all 0.15s;
}

.btn-show-steps:hover {
    background: rgba(45, 112, 179, 0.2);
}

.btn-delete-expr {
    background: transparent;
    border: none;
    color: #98a2b3;
    font-size: 16px;
    cursor: pointer;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.15s;
}

.btn-delete-expr:hover {
    color: #d92d20;
    background: #f2f4f7;
}

/* Slider Controls */
.slider-container {
    background: #f8fafc;
    border-top: 1px solid #eaecf0;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.slider-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: #475467;
}

.slider-val-badge {
    font-family: var(--font-mono);
    color: #1d2939;
    font-weight: 700;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-play-loop {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid #d0d5dd;
    color: #344054;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    transition: all 0.15s;
}

.btn-play-loop:hover {
    background: #2d70b3;
    color: #ffffff;
    border-color: #2d70b3;
}

.range-input {
    flex: 1;
    -webkit-appearance: none;
    height: 4px;
    border-radius: 2px;
    background: #d0d5dd;
    outline: none;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #2d70b3;
    cursor: pointer;
    border: 2px solid #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.slider-bounds {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: #98a2b3;
    font-family: var(--font-mono);
}

/* Add Item Button */
.btn-add-item {
    background: transparent;
    border: 1px dashed #d0d5dd;
    border-radius: 4px;
    padding: 9px;
    color: #475467;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 0.15s;
}

.btn-add-item:hover {
    border-color: #2d70b3;
    color: #2d70b3;
    background: rgba(45, 112, 179, 0.04);
}

@media (max-width: 768px) {
    .sidebar-content {
        padding: 4px 6px !important;
        gap: 6px !important;
    }

    .expression-card {
        border-radius: 4px !important;
    }

    .expression-row-main {
        min-height: 38px !important;
    }

    .desmos-left-badge {
        width: 28px !important;
    }

    .badge-index {
        font-size: 9px !important;
        top: 2px !important;
        left: 3px !important;
    }

    .desmos-math-field-wrapper {
        padding: 4px 6px !important;
    }

    .desmos-math-display {
        font-size: 14px !important;
    }

    .expr-actions {
        gap: 2px !important;
        padding-right: 4px !important;
    }

    .btn-show-steps {
        padding: 2px 5px !important;
        font-size: 10.5px !important;
        height: 24px !important;
    }

    .btn-delete-expr {
        width: 22px !important;
        height: 22px !important;
        font-size: 12px !important;
    }
}

/* Table of Values & Regression Cards */
.card-table {
    border-left: 4px solid #2d70b3;
    padding: 0;
}

.table-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.table-title {
    font-size: 12px;
    font-weight: 700;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 6px;
}

.table-grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    font-family: var(--font-mono);
}

.table-grid th {
    background: #f1f5f9;
    padding: 4px 8px;
    font-weight: 600;
    color: #475569;
    border-bottom: 1px solid #e2e8f0;
    text-align: center;
    font-size: 12px;
}

.table-grid td {
    padding: 2px 4px;
    border-bottom: 1px solid #f1f5f9;
    text-align: center;
}

.table-cell-input {
    width: 100%;
    border: 1px solid transparent;
    border-radius: 3px;
    padding: 4px 6px;
    text-align: center;
    font-family: inherit;
    font-size: 13px;
    background: transparent;
    color: #1e293b;
    outline: none;
    transition: all 0.15s;
}

.table-cell-input:focus {
    background: #ffffff;
    border-color: #2d70b3;
    box-shadow: 0 0 0 1px #2d70b3;
}

.table-row-del-btn {
    opacity: 0;
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 11px;
    padding: 2px 4px;
    border-radius: 2px;
    transition: all 0.15s;
}

.table-grid tr:hover .table-row-del-btn {
    opacity: 1;
}

.table-row-del-btn:hover {
    color: #ef4444;
}

.table-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.btn-table-add-row {
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-table-add-row:hover {
    border-color: #2d70b3;
    color: #2d70b3;
}

.table-regression-section {
    padding: 8px 10px;
    background: #fafafa;
    border-top: 1px solid #eef2f6;
    font-size: 12px;
}

.table-regression-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.regression-select {
    padding: 3px 6px;
    font-size: 11px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    background: #ffffff;
    color: #334155;
    outline: none;
}

.table-stats-badge {
    margin-top: 6px;
    padding: 4px 8px;
    background: #f1f5f9;
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: #1e293b;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.stats-formula {
    font-weight: 700;
    color: #2d70b3;
}

.stats-metrics {
    color: #64748b;
    font-size: 10px;
}
