:root {
    --app-bg: #fdfbf7;
    --text-primary: #2d3436;
    --text-secondary: #636e72;
    --origin-red: #d63031;
    --process-blue: #0984e3;
    --result-green: #00b894;
    --link-gold: #fdcb6e;
    --shadow-sm: 0 4px 6px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 10px 20px rgba(0, 0, 0, 0.08);
    --font-family: "Noto Serif SC", "Outfit", serif;
    --font-mono: "JetBrains Mono", monospace;
    --font-title: "Ma Shan Zheng", cursive;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 95vw;
    height: 90vh;
    max-width: 1600px;
    background: rgba(255, 252, 245, 0.98);
    backdrop-filter: blur(20px);
    border-radius: 24px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.main-header {
    padding: 1.2rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    background: rgba(255, 255, 255, 0.6);
}

.header-content h1 {
    font-family: var(--font-title);
    font-size: 2rem;
    color: var(--origin-red);
}

.highlight {
    color: var(--result-green);
}

.subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: -5px;
}

.header-controls {
    display: flex;
    gap: 16px;
    align-items: center;
}

.mode-nav {
    display: flex;
    background: #fff;
    padding: 4px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.nav-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    font-family: var(--font-family);
    font-weight: 600;
    color: var(--text-secondary);
}

.nav-btn.active {
    background: var(--process-blue);
    color: white;
    box-shadow: 0 4px 12px rgba(9, 132, 227, 0.3);
}

.nav-btn[data-mode="inverse"].active {
    background: var(--origin-red);
    box-shadow: 0 4px 12px rgba(214, 48, 49, 0.3);
}

.apple-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
    background: #fff;
    cursor: pointer;
    font-size: 1.2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
}

.apple-btn:hover {
    transform: scale(1.1);
}

.main-stage {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 350px;
    gap: 2px;
    background: rgba(0, 0, 0, 0.02);
    overflow: hidden;
}

.operation-view {
    display: none;
    flex-direction: column;
    padding: 40px;
    background: rgba(255, 255, 255, 0.5);
    align-items: center;
    justify-content: center;
    gap: 40px;
}

.operation-view.active {
    display: flex;
}

.pipeline-container {
    display: flex;
    align-items: center;
    gap: 24px;
    width: 100%;
    max-width: 1000px;
}

.stage-node {
    width: 240px;
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: all 0.3s;
}

.stage-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
}

.input-stage .stage-header {
    background: linear-gradient(135deg, rgba(214, 48, 49, 0.1) 0%, transparent 100%);
}

.intermediate-stage .stage-header {
    background: linear-gradient(135deg, rgba(9, 132, 227, 0.1) 0%, transparent 100%);
}

.output-stage .stage-header {
    background: linear-gradient(135deg, rgba(0, 184, 148, 0.1) 0%, transparent 100%);
}

.stage-icon {
    font-size: 1.2rem;
}

.stage-header h4 {
    flex: 1;
    font-size: 1rem;
}

.math-var {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-secondary);
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 8px;
    border-radius: 4px;
}

.selection-list {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 280px;
    overflow-y: auto;
}

.list-item {
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.9rem;
    border: 2px solid transparent;
}

.list-item:hover {
    background: #fff;
    transform: translateX(2px);
    box-shadow: var(--shadow-sm);
}

.list-item.selected {
    background: rgba(9, 132, 227, 0.1);
    border-color: var(--process-blue);
    color: var(--process-blue);
    font-weight: 600;
}

.output-stage .list-item.selected {
    background: rgba(214, 48, 49, 0.1);
    border-color: var(--origin-red);
    color: var(--origin-red);
}

.result-display {
    padding: 24px;
    min-height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.6;
}

.loading-dots {
    display: flex;
    gap: 8px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ddd;
}

.flow-connector {
    flex: 1;
    min-width: 80px;
    max-width: 120px;
    position: relative;
}

.connector-svg {
    width: 100%;
    height: 60px;
}

.connector-flow {
    stroke-dasharray: 200;
    stroke-dashoffset: 200;
    transition: stroke-dashoffset 0.8s ease;
}

.flow-connector.active .connector-flow {
    stroke-dashoffset: 0;
}

.func-label {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: #fff;
    padding: 4px 12px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.label-text {
    font-size: 0.7rem;
    color: var(--text-secondary);
    font-family: var(--font-family);
}

.formula-box {
    background: #fff;
    padding: 20px 32px;
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
}

.formula {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    color: var(--text-primary);
}

.insight-panel {
    background: rgba(255, 255, 255, 0.9);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    border-left: 1px solid rgba(0, 0, 0, 0.08);
    overflow-y: auto;
}

.concept-card,
.insight-card,
.progress-indicator {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    box-shadow: var(--shadow-sm);
}

.concept-card {
    border-left: 4px solid var(--process-blue);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.card-icon {
    font-size: 1.4rem;
}

.card-header h4 {
    font-size: 1.1rem;
}

.math-def {
    font-family: var(--font-mono);
    background: rgba(0, 0, 0, 0.04);
    padding: 10px;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

#conceptDesc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.insight-card {
    background: linear-gradient(135deg, #fff5f5 0%, #fff 100%);
}

.insight-card h4 {
    color: var(--origin-red);
    margin-bottom: 10px;
}

.insight-card p {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.progress-indicator {
    display: flex;
    justify-content: space-between;
    padding: 16px;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.step-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e0e0e0;
    transition: all 0.3s;
}

.progress-step.active .step-dot {
    background: var(--process-blue);
    box-shadow: 0 0 0 4px rgba(9, 132, 227, 0.2);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 0.3;
    }

    50% {
        opacity: 1;
    }
}

.loading-dots span:nth-child(1) {
    animation: pulse 1.4s infinite 0s;
}

.loading-dots span:nth-child(2) {
    animation: pulse 1.4s infinite 0.2s;
}

.loading-dots span:nth-child(3) {
    animation: pulse 1.4s infinite 0.4s;
}