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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.capillary-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    text-align: center;
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
    max-width: 800px;
    margin: 0 auto;
}

main {
    padding: 40px;
}

/* Mode Selection */
.mode-selector {
    margin-bottom: 30px;
}

.mode-selector h3 {
    font-size: 1.3em;
    color: #333;
    margin-bottom: 15px;
}

.mode-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.mode-btn {
    padding: 12px 24px;
    background: #f0f0f0;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.3s ease;
    font-weight: 500;
}

.mode-btn:hover {
    background: #e0e0e0;
    transform: translateY(-2px);
}

.mode-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

/* Canvas Wrapper */
.canvas-wrapper {
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 30px;
    margin-bottom: 30px;
}

.canvas-container {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

#capillaryCanvas {
    width: 100%;
    height: 600px;
    display: block;
}

/* Stats Panel */
.stats-panel {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 15px;
    padding: 25px;
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.stats-panel h4 {
    font-size: 1.2em;
    margin-bottom: 20px;
    font-weight: 600;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 25px;
}

.stat-item {
    background: rgba(255, 255, 255, 0.2);
    padding: 15px;
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.stat-label {
    font-size: 0.85em;
    opacity: 0.9;
}

.stat-value {
    font-size: 1.4em;
    font-weight: 700;
}

.stat-unit {
    font-size: 0.9em;
    opacity: 0.8;
}

/* Formula Display */
.formula-display {
    background: rgba(255, 255, 255, 0.2);
    padding: 20px;
    border-radius: 10px;
}

.formula-main {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.formula-text {
    font-size: 1.1em;
    font-weight: 600;
}

.formula-fraction {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.numerator {
    border-bottom: 2px solid white;
    padding: 5px 10px;
    font-weight: 600;
}

.denominator {
    padding: 5px 10px;
    font-weight: 600;
}

.formula-calculation {
    font-size: 0.9em;
    opacity: 0.9;
    line-height: 1.4;
    word-wrap: break-word;
}

/* Liquid Panel */
.liquid-panel {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.liquid-panel h3 {
    font-size: 1.3em;
    color: #333;
    margin-bottom: 20px;
}

.properties-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
}

.property-item {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.property-label {
    font-size: 0.9em;
    color: #666;
    font-weight: 500;
}

.property-value {
    font-size: 1.2em;
    color: #333;
    font-weight: 600;
}

/* Controls Panel */
.controls-panel {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.controls-panel h3 {
    font-size: 1.3em;
    color: #333;
    margin-bottom: 25px;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin-bottom: 25px;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.control-group label {
    font-size: 0.95em;
    color: #333;
    font-weight: 500;
}

.control-group input[type="range"] {
    width: 100%;
    height: 6px;
    border-radius: 5px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.control-group select {
    padding: 10px;
    border: 2px solid #ddd;
    border-radius: 8px;
    font-size: 1em;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s;
}

.control-group select:focus {
    outline: none;
    border-color: #667eea;
}

.range-info {
    font-size: 0.85em;
    color: #666;
    font-style: italic;
}

.info-text {
    color: #666;
}

/* Buttons */
.button-group {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.control-button {
    padding: 12px 30px;
    border: none;
    border-radius: 10px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.control-button.reset {
    background: linear-gradient(135deg, #f44336 0%, #d32f2f 100%);
    color: white;
}

.control-button.toggle {
    background: #e0e0e0;
    color: #333;
}

.control-button.toggle.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.control-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0, 0, 0, 0.15);
}

.control-button:active {
    transform: translateY(0);
}

/* Comparison Options */
.comparison-options {
    background: #e8eaf6;
    border-radius: 10px;
    padding: 20px;
    margin-top: 20px;
}

.comparison-options h4 {
    font-size: 1.1em;
    color: #333;
    margin-bottom: 15px;
}

.comparison-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.comparison-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 0.95em;
}

.comparison-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Derivation Panel */
.derivation-panel {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.derivation-panel h3 {
    font-size: 1.5em;
    color: #333;
    margin-bottom: 30px;
}

.derivation-steps {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.step {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}

.step-number {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.2em;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-content h4 {
    font-size: 1.2em;
    color: #667eea;
    margin-bottom: 10px;
}

.step-content p {
    color: #666;
    line-height: 1.6;
    margin-bottom: 10px;
}

.formula-box {
    background: white;
    padding: 15px;
    border-radius: 8px;
    font-size: 1.1em;
    font-weight: 600;
    color: #333;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.fraction {
    display: inline-block;
    text-align: center;
    vertical-align: middle;
}

.fraction .numerator {
    display: block;
    border-bottom: 2px solid #333;
    padding: 5px 10px;
}

.fraction .denominator {
    display: block;
    padding: 5px 10px;
}

/* Applications Panel */
.applications-panel {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.applications-panel h3 {
    font-size: 1.5em;
    color: #333;
    margin-bottom: 30px;
}

.applications-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 25px;
}

.application-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.application-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.application-icon {
    font-size: 2.5em;
    margin-bottom: 15px;
}

.application-card h4 {
    font-size: 1.2em;
    color: #333;
    margin-bottom: 10px;
}

.application-card p {
    color: #666;
    line-height: 1.6;
    font-size: 0.95em;
}

/* Explanation Section */
.explanation {
    background: #f8f9fa;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.explanation h2 {
    font-size: 2em;
    color: #333;
    margin-bottom: 20px;
}

.explanation h3 {
    font-size: 1.5em;
    color: #667eea;
    margin-top: 30px;
    margin-bottom: 15px;
}

.explanation p {
    font-size: 1.05em;
    line-height: 1.8;
    color: #555;
    margin-bottom: 15px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .canvas-wrapper {
        grid-template-columns: 1fr;
    }

    .controls-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    header {
        padding: 30px 20px;
    }

    header h1 {
        font-size: 1.8em;
    }

    main {
        padding: 20px;
    }

    .mode-options {
        flex-direction: column;
    }

    .mode-btn {
        width: 100%;
    }

    .button-group {
        flex-direction: column;
    }

    .control-button {
        width: 100%;
    }

    #capillaryCanvas {
        height: 400px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .applications-grid {
        grid-template-columns: 1fr;
    }

    .step {
        flex-direction: column;
    }

    .step-number {
        width: 35px;
        height: 35px;
        font-size: 1em;
    }
}

@media (max-width: 480px) {
    header h1 {
        font-size: 1.5em;
    }

    .subtitle {
        font-size: 0.9em;
    }

    .properties-grid {
        grid-template-columns: 1fr;
    }

    .formula-main {
        flex-direction: column;
        align-items: flex-start;
    }

    .comparison-grid {
        grid-template-columns: 1fr;
    }
}
