.graph-page {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;

    animation: pageEnter 500ms ease both;
}

.graph-header {
    display: flex;
    align-items: center;
    gap: 18px;

    margin-bottom: 24px;
}

.graph-header .logo {
    color: var(--blue);

    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.6px;

    text-decoration: none;
}

.graph-header > div {
    border-left: 1px solid var(--border);
    padding-left: 18px;
}

.graph-header h1 {
    font-size: 20px;
    font-weight: 600;
    line-height: 1.2;
}

.graph-header p {
    margin-top: 4px;

    color: var(--text-secondary);

    font-size: 13px;
}

.graph-layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    gap: 14px;

    min-height: 650px;
}

.expression-panel {
    min-width: 0;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);

    overflow: hidden;

    box-shadow: var(--shadow);
}

.panel-header {
    height: 58px;

    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 0 14px;

    border-bottom: 1px solid var(--border);
}

.panel-header h2 {
    font-size: 14px;
    font-weight: 600;
}

.add-expression {
    border: 0;
    border-radius: 7px;

    padding: 7px 10px;

    background: var(--blue-soft);
    color: var(--blue);

    font-family: inherit;
    font-size: 12px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background-color var(--transition),
        color var(--transition);
}

.add-expression:hover {
    background: var(--blue);
    color: white;
}

.expressions {
    padding: 10px;
}

.expression-row {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr) 28px;
    align-items: center;
    gap: 6px;

    min-height: 48px;

    padding: 5px 6px;

    border: 1px solid transparent;
    border-radius: 8px;

    transition:
        background-color var(--transition),
        border-color var(--transition);
}

.expression-row:focus-within {
    background: var(--background);
    border-color: var(--border);
}

.expression-number {
    color: var(--text-muted);

    font-size: 12px;
    text-align: center;
}

.expression-input {
    width: 100%;
    height: 34px;

    border: 1px solid transparent;
    border-radius: 6px;

    padding: 0 8px;

    background: transparent;
    color: var(--text);

    font-family: inherit;
    font-size: 14px;

    outline: none;

    transition:
        background-color var(--transition),
        border-color var(--transition);
}

.expression-input::placeholder {
    color: var(--text-muted);
}

.expression-input:focus {
    background: var(--surface);
    border-color: var(--blue);
}

.remove-expression {
    width: 28px;
    height: 28px;

    border: 0;
    border-radius: 6px;

    background: transparent;
    color: var(--text-muted);

    font-family: inherit;
    font-size: 18px;
    line-height: 1;

    cursor: pointer;

    transition:
        background-color var(--transition),
        color var(--transition);
}

.remove-expression:hover {
    background: var(--blue-soft);
    color: var(--blue);
}

.graph-container {
    position: relative;

    min-width: 0;
    min-height: 0;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);

    overflow: hidden;

    box-shadow: var(--shadow);
}

#graphCanvas {
    display: block;

    width: 100%;
    height: 100%;

    cursor: crosshair;
}

.graph-controls {
    position: absolute;

    right: 14px;
    bottom: 14px;

    display: flex;
    align-items: center;
    gap: 4px;

    padding: 4px;

    background: color-mix(
        in srgb,
        var(--surface) 92%,
        transparent
    );

    border: 1px solid var(--border);
    border-radius: 8px;

    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);

    backdrop-filter: blur(8px);
}

.graph-controls button {
    min-width: 34px;
    height: 32px;

    border: 0;
    border-radius: 6px;

    background: transparent;
    color: var(--text-secondary);

    font-family: inherit;
    font-size: 13px;
    font-weight: 500;

    cursor: pointer;

    transition:
        background-color var(--transition),
        color var(--transition);
}

.graph-controls button:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.graph-controls button:first-child,
.graph-controls button:last-child {
    font-size: 20px;
}

.graph-controls button:nth-child(2) {
    padding: 0 8px;
}

.tools a.tool {
    display: flex;
    align-items: center;
    justify-content: center;

    text-decoration: none;
}

@media (max-width: 800px) {
    .graph-layout {
        grid-template-columns: 1fr;
        grid-template-rows: auto minmax(500px, 1fr);
    }

    .expression-panel {
        max-height: 260px;
    }

    .expressions {
        max-height: 200px;
        overflow-y: auto;
    }
}

@media (max-width: 520px) {
    body {
        padding: 24px 12px;
    }

    .graph-header {
        gap: 12px;
    }

    .graph-header .logo {
        font-size: 21px;
    }

    .graph-header > div {
        padding-left: 12px;
    }

    .graph-header h1 {
        font-size: 18px;
    }

    .graph-layout {
        grid-template-rows: auto 450px;
    }

    .expression-panel {
        max-height: 220px;
    }

    .graph-controls {
        right: 10px;
        bottom: 10px;
    }
}

.variable-panel {
    margin-top: 10px;

    padding: 12px;

    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
}

.variable-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 12px;
}

.variable-panel-header h2 {
    font-size: 13px;
    font-weight: 600;
}

.variable-panel-header span {
    color: var(--text-muted);

    font-size: 11px;
}

.variable-row {
    padding: 10px 0;

    border-top: 1px solid var(--border);
}

.variable-row:first-of-type {
    border-top: 0;
}

.variable-top {
    display: flex;
    align-items: center;
    justify-content: space-between;

    gap: 10px;

    margin-bottom: 8px;
}

.variable-name {
    color: var(--blue);

    font-size: 14px;
    font-weight: 600;
}

.variable-value {
    width: 72px;
    height: 30px;

    border: 1px solid var(--border);
    border-radius: 6px;

    padding: 0 7px;

    background: var(--background);
    color: var(--text);

    font-family: inherit;
    font-size: 12px;

    text-align: right;
    outline: none;
}

.variable-value:focus {
    border-color: var(--blue);
}

.variable-slider {
    width: 100%;

    height: 18px;

    accent-color: var(--blue);

    cursor: pointer;
}

.variable-range {
    display: flex;
    justify-content: space-between;

    color: var(--text-muted);

    font-size: 10px;
}

.variable-settings {
    margin-top: 10px;

    padding: 10px;

    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.variable-settings[hidden] {
    display: none;
}

.variable-settings-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.variable-setting {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.variable-setting label {
    color: var(--text-muted);

    font-size: 10px;
}

.variable-setting input {
    width: 100%;
    height: 30px;

    border: 1px solid var(--border);
    border-radius: 6px;

    padding: 0 7px;

    background: var(--surface);
    color: var(--text);

    font-family: inherit;
    font-size: 12px;

    outline: none;
}

.variable-setting input:focus {
    border-color: var(--blue);
}

.variable-settings-actions {
    display: flex;
    justify-content: flex-end;

    margin-top: 9px;
}

.variable-settings-apply {
    border: 0;
    border-radius: 6px;

    padding: 6px 10px;

    background: var(--blue);
    color: white;

    font-family: inherit;
    font-size: 11px;
    font-weight: 600;

    cursor: pointer;

    transition:
        background-color var(--transition);
}

.variable-settings-apply:hover {
    background: var(--blue-hover);
}

.variable-settings-button {
    width: 28px;
    height: 28px;

    border: 0;
    border-radius: 6px;

    background: transparent;
    color: var(--text-muted);

    font-family: inherit;
    font-size: 14px;

    cursor: pointer;

    transition:
        background-color var(--transition),
        color var(--transition);
}

.variable-settings-button:hover {
    background: var(--surface-hover);
    color: var(--text);
}

@media (max-width: 520px) {
    .variable-settings-grid {
        grid-template-columns: 1fr;
    }
}
