* {
    box-sizing: border-box;
}

@font-face {
    font-family: "Computer Modern";
    src: url("./cmunrm.otf") format("opentype");
    font-weight: normal;
    font-style: normal;
}

.katex-display > .katex {
    font-size: 1em !important;
}

.katex {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* base mobile styles */
.instruction-label {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 15px;
    font-weight: 500;
    color: #555555;
    margin: 0 0 16px 0;
    letter-spacing: 0.2px;
}

#signToggle {
    background: transparent;
    border-radius: 3px;
    font-family: "Computer Modern", serif;
    font-size: 22px;
    width: 32px;
    height: 32px;
    cursor: pointer;
    border: 1px solid #767676;
    padding-bottom: 4px;
    line-height: 0;
    font-weight: bold;
}

#signToggle:hover {
    border-color: #2196F3;
    background-color: rgba(33, 150, 243, 0.05);
}

.buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    width: 100%;
}

.buttons button {
    padding: 12px 14px;
    font-size: 16px;
    border-radius: 6px;
    border: none;
    color: #fff;
    background: #2196F3;
    cursor: pointer;
    width: 100%;
}

.lowerButtons {
    display: flex;
    gap: 8px;
    width: 100%;
}

.buttons button.active-focus:not(:disabled) {
    background: #4CAF50;
}

.buttons button:disabled {
    background: #d3d3d3;
    color: #888888;
    border: 1px solid #cccccc;
    cursor: not-allowed;
}

.exerciseContainer {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 16px;
    justify-content: center;
}

.exercise-text {
    font-size: 30px;
    margin: 0;
}

.solutionInput {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    width: 3.5em;
    gap: 4px;
}

.solutionInput input {
    width: 100%;
    text-align: center;
    font-size: 30px;
    padding: 0;
    font-family: "Computer Modern";
    border: 1px solid #767676;
    border-radius: 3px;
    outline: none;
}

.solutionInput input:hover {
    border: 1px solid #2196F3;
    background-color: rgba(33, 150, 243, 0.05);
}

.solutionInput hr {
    width: 100%;
    margin: 0;
    border: none;
    border-top: 1px solid #000;
}

.feedback-text {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.4;
    margin: 0;
}

/* little arrow buttons removal */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
    appearance: textfield;
}

/* desktop styles */
@media (min-width: 768px) {
    .exercise-card {
        max-width: 600px;
        margin: 40px auto;
        padding: 32px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        border-radius: 12px;
    }

    .exercise-workspace {
        display: flex;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 24px;
        min-height: 200px;
    }

    .exerciseContainer {
        flex: 2;
        justify-content: end;
    }

    .feedback-text {
        flex: 1;
    }

    .buttons {
        flex-direction: row;
        justify-content: flex-end;
        gap: 10px;
        padding: 0;
        margin-top: 20px;
    }

    .lowerButtons {
        display: contents;
    }

    .buttons button{
        flex: 0 0 auto !important;
        width: auto !important;
        min-width: 110px;
        padding: 10px 16px;
        font-size: 15px;
    }

    .exercise-text,
    .solutionInput input {
        font-size: 36px;
    }
}

/* Equation Layout */
.exercise-workspace.equation-workspace {
    display: flex !important;
    flex-direction: column !important;
    align-items: center;
    justify-content: center;
    gap: 20px;
    min-height: 200px;
}

.equation-workspace #equationText {
    width: 100%;
    text-align: center;
    font-size: 28px;
}

.equation-bottom-row {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
}

.equation-input-row {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.equation-input-row .exercise-text {
    font-family: KaTeX_Math, KaTeX_Main, serif;
}

.equation-input {
    width: 2.2em;
    height: 1.4em;
    text-align: center;
    font-size: 32px;
    font-family: "Computer Modern", serif;
    border: 1px solid #767676;
    border-radius: 4px;
    outline: none;
    padding: 0;
}

.equation-input:hover {
    border-color: #2196F3;
    background-color: rgba(33, 150, 243, 0.05);
}

.equation-bottom-row .feedback-text {
    text-align: center;
    min-height: 24px;
    margin: 0;
}

#amount {
    width: 2em;
}

#unitLeftText, #unitRightText {
    font-size: 28px;
}

@media (min-width: 768px) {
    .equation-bottom-row {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 24px;
    }

    .equation-bottom-row .equation-input-row {
        flex: 2;
        justify-content: flex-end;
    }

    .equation-bottom-row .feedback-text {
        flex: 1;
        text-align: left;
    }
}