* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

#canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* Panel Styles */
.panel {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 320px;
    background: rgba(24, 24, 28, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    font-family: 'Source Serif 4', Georgia, serif;
    color: #e8e6e3;
    backdrop-filter: blur(12px);
    z-index: 1000;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.panel:hover {
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 18px;
    background: rgba(255, 255, 255, 0.03);
    cursor: pointer;
    user-select: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    transition: background 0.15s ease;
}

.panel-header:hover {
    background: rgba(255, 255, 255, 0.06);
}

.panel-title {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: #f0eeeb;
}

.panel-arrow {
    font-size: 10px;
    color: #888;
    transition: transform 0.25s ease;
}

.panel.collapsed .panel-arrow {
    transform: rotate(-90deg);
}

.panel-content {
    padding: 16px 18px;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
    opacity: 1;
}

.panel.collapsed .panel-content {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    opacity: 0;
}

/* Function Input */
.function-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.function-input-wrapper label {
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    font-size: 15px;
    color: #c4bfb6;
    white-space: nowrap;
}

#function-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 10px 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    color: #e8e6e3;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#function-input:focus {
    border-color: rgba(130, 170, 255, 0.4);
    box-shadow: 0 0 0 3px rgba(130, 170, 255, 0.1);
}

#function-input.error {
    border-color: rgba(255, 100, 100, 0.5);
}

.error-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff4d4d;
    box-shadow: 0 0 8px rgba(255, 77, 77, 0.6);
    opacity: 0;
    transition: opacity 0.2s ease;
    flex-shrink: 0;
}

.error-dot.visible {
    opacity: 1;
}

/* Coefficient Section */
.coef-section {
    border-top: 1px solid rgba(255, 255, 255, 0.06);
    padding-top: 16px;
}

.coef-header {
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #888;
    margin-bottom: 12px;
}

.coef-list {
    max-height: 280px;
    overflow-y: auto;
    padding-right: 8px;
}

.coef-list::-webkit-scrollbar {
    width: 4px;
}

.coef-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 2px;
}

.coef-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.coef-list::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.25);
}

.coef-row {
    display: flex;
    gap: 16px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
    font-size: 13px;
}

.coef-row:last-child {
    border-bottom: none;
}

.coef-item {
    flex: 1;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.coef-label {
    font-family: 'Source Serif 4', Georgia, serif;
    font-style: italic;
    color: #a09a90;
    min-width: 28px;
}

.coef-label sub {
    font-size: 10px;
}

.coef-value {
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    color: #d0ccc4;
}

.coef-value.positive {
    color: #7dcea0;
}

.coef-value.negative {
    color: #f1948a;
}

.coef-value.zero {
    color: #666;
}

/* A0 special row */
.coef-row.a0-row {
    margin-bottom: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
