* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    font-family: Arial, sans-serif;
    color: #263445;
}

body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f4f6f9;
}

button {
    font: inherit;
    cursor: pointer;
}

.app-header {
    height: 54px;
    min-height: 54px;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 24px;
    background: #263445;
    color: white;
}

.app-header h1 {
    margin: 0;
    font-size: 19px;
    font-weight: 600;
}

.header-subtitle {
    font-size: 13px;
    color: #b9c5d1;
}

main {
    flex: 1;
    min-height: 0;
}

.view {
    width: 100%;
    height: 100%;
}

.hidden {
    display: none !important;
}

#config-view {
    overflow-y: auto;
    padding: 32px;
}

.page-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
}

h2 {
    margin: 0 0 8px;
    font-size: 25px;
}

.page-heading p {
    margin: 0;
    color: #697586;
    font-size: 14px;
}

.primary-button {
    border: 0;
    border-radius: 6px;
    background: #2563a6;
    color: white;
    padding: 12px 20px;
    font-weight: 600;
}

.primary-button:hover {
    background: #194e87;
}

.count-section {
    margin-bottom: 28px;
}

.count-section h3 {
    font-size: 15px;
    margin-bottom: 12px;
}

.count-selector {
    display: flex;
    gap: 8px;
}

.count-selector button {
    width: 42px;
    height: 38px;
    border: 1px solid #ccd3dc;
    border-radius: 5px;
    background: white;
    color: #263445;
}

.count-selector button.selected {
    background: #263445;
    color: white;
    border-color: #263445;
}

.functions-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 1000px;
}

.function-card {
    background: white;
    border: 1px solid #dce1e8;
    border-radius: 8px;
    overflow: hidden;
}

.function-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #edf1f5;
    border-bottom: 1px solid #dce1e8;
}

.function-card-header h3 {
    margin: 0;
    font-size: 16px;
}

.function-card-body {
    padding: 20px;
}

.field-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 600;
}

.expression-input {
    width: 100%;
    padding: 12px;
    border: 1px solid #cbd3dd;
    border-radius: 5px;
    font-size: 16px;
}

.expression-input:focus {
    outline: 2px solid #8bb9e8;
    border-color: #2563a6;
}

.analysis-section {
    margin-top: 22px;
}

.analysis-section h4 {
    margin: 0 0 12px;
    font-size: 14px;
}

.analysis-options {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 24px;
}

.analysis-options label {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: #4b5563;
}

.graph-toolbar {
    height: 54px;
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 0 16px;
    background: #edf1f5;
    border-bottom: 1px solid #dce1e8;
}

.graph-toolbar h2 {
    margin: 0;
    font-size: 16px;
}

.secondary-button {
    border: 1px solid #cbd3dd;
    background: white;
    border-radius: 5px;
    padding: 8px 12px;
}

.geogebra-container {
    width: 100%;
    height: calc(100% - 54px);
    min-height: 400px;
}

@media (max-width: 650px) {
    #config-view {
        padding: 20px 14px;
    }

    .page-heading {
        align-items: flex-start;
        flex-direction: column;
    }
}


.function-type {
    width: 100%;
    max-width: 320px;
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid #cbd3dd;
    border-radius: 5px;
    background: white;
    font-size: 14px;
}

.pieces-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 8px 0 14px;
}

.pieces-heading h4 {
    margin: 0;
    font-size: 14px;
}

.pieces-heading span {
    color: #697586;
    font-size: 12px;
}

.pieces-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.piece-card {
    padding: 16px;
    border: 1px solid #dce1e8;
    border-radius: 6px;
    background: #fafbfd;
}

.piece-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    font-size: 14px;
}

.remove-piece-button {
    border: 0;
    background: transparent;
    color: #b43b3b;
    font-size: 12px;
}

.interval-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 16px;
}

.interval-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd3dd;
    border-radius: 5px;
    font-size: 14px;
}

.endpoint-option {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 8px;
    font-size: 12px;
    color: #697586;
}

.add-piece-button {
    margin-top: 14px;
    padding: 9px 14px;
    border: 1px solid #2563a6;
    border-radius: 5px;
    background: white;
    color: #2563a6;
    font-size: 13px;
}

.add-piece-button:hover:not(:disabled) {
    background: #edf5fc;
}

.add-piece-button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

@media (max-width: 550px) {
    .interval-fields {
        grid-template-columns: 1fr;
    }
}


.help-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 19px;
    height: 19px;
    margin-left: 5px;
    border: 1px solid #2563a6;
    border-radius: 50%;
    background: white;
    color: #2563a6;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
}

.help-dialog {
    width: min(560px, calc(100% - 32px));
    max-height: 85vh;
    padding: 0;
    border: 0;
    border-radius: 9px;
    box-shadow: 0 10px 40px #0003;
}

.help-dialog::backdrop {
    background: #0007;
}

.help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 22px;
    background: #263445;
    color: white;
}

.help-header h2 {
    margin: 0;
    font-size: 17px;
}

.help-header button {
    border: 0;
    background: transparent;
    color: white;
    font-size: 18px;
}

.help-content {
    padding: 20px 24px;
    overflow-y: auto;
}

.help-content h3 {
    margin-top: 18px;
    font-size: 14px;
}

.help-content li {
    margin: 7px 0;
    font-size: 13px;
}

.help-content code {
    padding: 2px 5px;
    border-radius: 3px;
    background: #edf1f5;
}

.help-note {
    margin-top: 24px;
    padding: 12px;
    background: #edf5fc;
    border-radius: 5px;
    font-size: 12px;
    line-height: 1.5;
}

.infinity-controls {
    display: flex;
    gap: 5px;
}

.infinity-controls .interval-input {
    min-width: 0;
    flex: 1;
}

.infinity-button {
    padding: 0 9px;
    border: 1px solid #cbd3dd;
    border-radius: 5px;
    background: white;
    color: #2563a6;
    font-size: 13px;
}