.app-window {
    position: absolute;
    left: clamp(72px, 8vw, 120px);
    top: 48px;
    width: fit-content;
    max-width: calc(100vw - 140px);
    max-height: calc(100vh - 66px);
    z-index: 105;
    display: grid;
    grid-template-rows: auto auto auto auto;
    gap: 10px;
    padding: 14px;
    overflow: auto;
    background: var(--panel-bg);
    border-radius: 8px;
}

.app-window:has(.graph-board-frame:hover) {
    max-width: calc(100vw - 24px);
}

.app-window[hidden] {
    display: none;
}

.app-window-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    cursor: move;
    user-select: none;
}

.app-window-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.graph-status {
    border: 1px solid #f59e0b;
    border-radius: 8px;
    background: #fffbeb;
    color: #92400e;
    padding: 10px 12px;
    font: 600 13px Inter, sans-serif;
    line-height: 1.35;
}

.icon-btn.mini {
    width: 32px;
    height: 32px;
    font-size: 13px;
}

.graph-mode-panel {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
    align-items: stretch;
    height: auto;
    gap: 10px;
    overflow: visible;
}

.graph-mode-panel[hidden] {
    display: none;
}

.graph-sidebar {
    min-height: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-right: 2px;
}

.graph-field {
    display: grid;
    gap: 6px;
    color: var(--text-muted);
    font: 700 12px Inter, sans-serif;
}

.graph-label-row {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    width: max-content;
    max-width: 100%;
}

.graph-info-wrap {
    position: relative;
    display: inline-flex;
}

.graph-info-button {
    width: 18px;
    height: 18px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--text-muted);
    cursor: help;
    display: inline-grid;
    place-items: center;
    padding: 0;
    font: italic 800 14px Inter, sans-serif;
    line-height: 1;
}

.graph-info-button i {
    display: block;
    font-size: 15px;
    line-height: 1;
}

.graph-info-button:hover,
.graph-info-button:focus-visible {
    color: var(--primary);
    outline: none;
}

.graph-info-tooltip {
    position: absolute;
    left: 0;
    top: calc(100% + 8px);
    z-index: 80;
    width: min(440px, calc(100vw - 72px));
    max-width: calc(100vw - 72px);
    padding: 10px 12px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--panel-bg);
    color: var(--text-main);
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.18);
    display: grid;
    gap: 6px;
    font: 500 12px/1.4 Inter, sans-serif;
    text-transform: none;
    opacity: 0;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.graph-info-tooltip code {
    color: #dc2626;
    background: transparent;
    font: 800 12px/1.4 Inter, sans-serif;
}

.graph-info-wrap:hover .graph-info-tooltip,
.graph-info-wrap:focus-within .graph-info-tooltip {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.graph-field textarea,
.graph-field input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    padding: 8px 10px;
    background: var(--input-bg);
    color: var(--text-main);
    font: 600 13px Inter, sans-serif;
}

.graph-field.compact {
    gap: 8px;
}

.graph-field.compact input {
    height: auto;
    padding: 0;
}

.graph-params {
    display: grid;
    gap: 10px;
}

.graph-param-card {
    display: grid;
    gap: 8px;
    padding: 9px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--input-bg);
}

.graph-param-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-main);
    font: 700 12px Inter, sans-serif;
}

.graph-param-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.graph-param-range label {
    display: grid;
    gap: 4px;
    color: var(--text-muted);
    font: 700 11px Inter, sans-serif;
}

.graph-param-range input {
    width: 100%;
    min-width: 0;
    height: 28px;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    background: var(--panel-bg);
    color: var(--text-main);
    padding: 0 6px;
    font: 600 12px Inter, sans-serif;
}

.graph-field textarea {
    min-height: 112px;
    resize: vertical;
    line-height: 1.4;
}

.graph-series-options {
    display: grid;
    gap: 8px;
}

.graph-series-row {
    display: grid;
    grid-template-columns: 26px minmax(0, 1fr) 82px;
    align-items: center;
    gap: 6px;
    color: var(--text-muted);
    font: 700 11px Inter, sans-serif;
}

.graph-series-row input[type="color"] {
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    background: transparent;
}

.graph-series-row select {
    height: 28px;
    width: 54px;
    border: 1px solid var(--panel-border);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-main);
    font: 800 17px Inter, sans-serif;
    text-align: center;
}

.graph-tool-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.graph-board-frame {
    width: 760px;
    height: 480px;
    min-width: 360px;
    min-height: 260px;
    max-width: 100%;
    max-height: calc(100vh - 220px);
    resize: both;
    overflow: auto;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--panel-bg);
}

.graph-board {
    width: 100%;
    height: 100%;
    min-width: 360px;
    min-height: 260px;
    border-radius: 8px;
    background: #ffffff;
    overflow: hidden;
    touch-action: none;
}

.graph-board svg {
    display: block;
    width: 100%;
    height: 100%;
}

.graph-board .graph-implicit-path {
    fill: none;
    pointer-events: none;
}

.graph-board .graph-axis-arrow {
    pointer-events: none;
}

.graph-board .graph-axis-ticks {
    pointer-events: none;
}

.graph-check {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main);
    font: 700 12px Inter, sans-serif;
}

.graph-bottom-bar {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: end;
    gap: 16px;
}

.graph-bottom-options {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.graph-chip-btn {
    height: 34px;
    border: 1px solid var(--panel-border);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-main);
    cursor: pointer;
    font: 700 12px Inter, sans-serif;
    padding: 0 12px;
}

.graph-chip-btn:hover {
    background: var(--hover-bg);
}

.graph-export-button {
    min-width: 148px;
    height: 52px;
    border: none;
    border-radius: 10px;
    background: var(--primary);
    color: #ffffff;
    cursor: pointer;
    font: 800 18px Inter, sans-serif;
    box-shadow: 0 8px 18px rgba(92, 92, 255, 0.22);
    transition: filter 0.16s ease, transform 0.16s ease, box-shadow 0.16s ease;
}

.graph-export-button:hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: 0 12px 26px rgba(92, 92, 255, 0.28);
}

@media (max-width: 700px) {
    .app-window {
        left: 15px;
        right: 15px;
        top: 58px;
        bottom: 16px;
        width: auto;
        min-height: 0;
    }

    .graph-mode-panel {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
    }

    .graph-board {
        min-height: 300px;
    }

    .graph-bottom-bar {
        grid-template-columns: 1fr;
    }
}
