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

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

.pn-container {
    max-width: 1400px;
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

header {
    background: linear-gradient(135deg, #1e3a8a 0%, #3b82f6 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

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

.subtitle {
    font-size: 1.1em;
    opacity: 0.9;
}

main {
    padding: 30px;
}

.visualization-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-bottom: 30px;
}

.panel-header {
    background: linear-gradient(135deg, #1e40af 0%, #3b82f6 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 8px 8px 0 0;
    margin-bottom: 0;
}

.panel-header h3 {
    font-size: 1.2em;
    margin: 0;
}

.structure-panel,
.band-panel {
    background: #f9fafb;
    border-radius: 8px;
    overflow: hidden;
}

canvas {
    width: 100%;
    height: 300px;
    background: white;
    border: 2px solid #e5e7eb;
    border-top: none;
}

.structure-legend,
.band-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    padding: 15px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
}

.legend-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

.p-type {
    background: rgba(239, 68, 68, 0.5);
}

.n-type {
    background: rgba(59, 130, 246, 0.5);
}

.depletion {
    background: rgba(156, 163, 175, 0.3);
}

.line-color {
    width: 30px;
    height: 3px;
}

.conduction-band {
    background: #EF4444;
}

.valence-band {
    background: #3B82F6;
}

.fermi-level {
    background: #10B981;
}

.junction-info,
.band-info {
    padding: 15px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}

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

.info-row span:first-child {
    font-weight: 600;
    color: #374151;
}

.info-row span:last-child {
    color: #1e40af;
    font-weight: 700;
}

.iv-curve-section,
.carrier-section {
    background: #f9fafb;
    border-radius: 8px;
    margin-bottom: 30px;
    overflow: hidden;
}

.iv-curve-container,
.carrier-container {
    padding: 0;
}

.iv-info {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    padding: 15px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.iv-parameter {
    text-align: center;
}

.iv-parameter span:first-child {
    display: block;
    font-weight: 600;
    color: #374151;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.iv-parameter span:last-child {
    display: block;
    color: #1e40af;
    font-weight: 700;
    font-size: 1.1em;
}

.controls-panel {
    background: #f9fafb;
    padding: 30px;
    border-radius: 8px;
    margin-top: 30px;
}

.controls-panel h3 {
    color: #1e40af;
    margin-bottom: 20px;
    font-size: 1.5em;
}

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

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

.control-group label {
    font-weight: 600;
    color: #374151;
    font-size: 0.9em;
}

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

.control-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.control-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #3b82f6;
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.control-group select {
    padding: 10px;
    border: 2px solid #e5e7eb;
    border-radius: 6px;
    font-size: 1em;
    background: white;
    cursor: pointer;
}

.control-group select:focus {
    outline: none;
    border-color: #3b82f6;
}

.checkbox-group {
    flex-direction: row;
    align-items: center;
    gap: 10px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

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

.button-group {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.control-button {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    flex: 1;
    min-width: 120px;
}

.control-button.reset {
    background: #6b7280;
    color: white;
}

.control-button.reset:hover {
    background: #4b5563;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(107, 114, 128, 0.3);
}

.control-button.forward {
    background: #10b981;
    color: white;
}

.control-button.forward:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(16, 185, 129, 0.3);
}

.control-button.reverse {
    background: #ef4444;
    color: white;
}

.control-button.reverse:hover {
    background: #dc2626;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(239, 68, 68, 0.3);
}

.formulas-section {
    background: white;
    padding: 25px;
    border-radius: 8px;
    border-left: 4px solid #10b981;
}

.formulas-section h3 {
    color: #1e40af;
    margin-bottom: 20px;
    font-size: 1.3em;
}

.formula-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

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

.formula-label {
    font-weight: 600;
    color: #374151;
}

.formula {
    font-family: 'Courier New', monospace;
    background: #f9fafb;
    padding: 10px;
    border-radius: 6px;
    color: #1e40af;
    font-size: 0.95em;
}

.constants-info {
    background: #f0fdf4;
    padding: 15px;
    border-radius: 6px;
    border-left: 4px solid #10b981;
    font-size: 0.9em;
    color: #374151;
}

.explanation {
    background: #fef3c7;
    padding: 30px;
    border-radius: 8px;
    margin-top: 30px;
}

.explanation h2 {
    color: #92400e;
    margin-bottom: 15px;
    font-size: 1.8em;
}

.explanation h3 {
    color: #92400e;
    margin-top: 25px;
    margin-bottom: 15px;
    font-size: 1.3em;
}

.explanation p {
    line-height: 1.8;
    color: #78350f;
    margin-bottom: 15px;
}

.explanation ul {
    list-style: none;
    padding-left: 0;
}

.explanation li {
    padding: 15px;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.5);
    border-radius: 6px;
    border-left: 4px solid #f59e0b;
    line-height: 1.6;
    color: #78350f;
}

.explanation strong {
    color: #92400e;
}

@media (max-width: 1024px) {
    .visualization-layout {
        grid-template-columns: 1fr;
    }

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

    .iv-info {
        grid-template-columns: 1fr;
    }

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

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

    .subtitle {
        font-size: 0.9em;
    }

    main {
        padding: 15px;
    }

    canvas {
        height: 250px;
    }

    .control-button {
        width: 100%;
    }
}
