html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f5f7fa;
    color: #333;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.header {
    background-color: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    padding: 10px 20px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    height: 30px;
    margin-right: 10px;
}

.title {
    display: flex;
    align-items: center;
    font-size: 1.2rem;
    color: #2c3e50;
}

.title-separator {
    margin: 0 15px;
    color: #ccc;
    font-weight: 300;
}

.title-main {
    font-weight: 600;
}

.title-sub {
    font-weight: 400;
}

/* Sidebar Navigation */
.sidebar {
    position: fixed;
    top: 70px;
    left: 0;
    width: 220px;
    height: calc(100vh - 70px);
    background-color: #f5f7fa;
    border-right: 1px solid #e0e0e0;
    padding: 20px;
    overflow-y: auto;
    z-index: 98;
}

.sidebar h3 {
    margin-top: 0;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
}

.nav-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav-group {
    margin-bottom: 20px;
}

.nav-group h4 {
    margin: 15px 0 8px 0;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-item {
    display: block;
}

.nav-item a {
    display: block;
    padding: 8px 12px;
    color: #2c3e50;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-size: 14px;
}

.nav-item a:hover {
    background-color: #e8f4f8;
    color: #1976d2;
}

.nav-item.active a {
    background-color: #1976d2;
    color: white;
    font-weight: 500;
}

/* Main content area adjusted for sidebar */
.main-content {
    margin-left: 240px;
    margin-top: 70px;
    padding: 20px;
    min-height: calc(100vh - 70px);
    width: calc(100vw - 240px);
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Content area for iframe-loaded pages (no header/sidebar margins) */
.iframe-content {
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 30px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Full-width container for home page */
.home-container {
    width: 100%;
    max-width: none;
    padding: 30px 10px;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
}

/* Home page specific styles */
.intro {
    margin: 30px 0 40px 0;
    text-align: center;
    color: #666;
    font-size: 18px;
    line-height: 1.6;
}

.demo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 20px;
    margin-top: 40px;
}

.demo-card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.demo-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: all 0.3s ease;
    border: 1px solid #e8e9ea;
    display: flex;
    flex-direction: column;
    height: auto;
}

.demo-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.demo-preview {
    flex: 0 0 180px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.preview-placeholder {
    width: 160px;
    height: 120px;
    position: relative;
}

.preview-graph {
    width: 100%;
    height: 100%;
    position: relative;
}

.graph-axis {
    position: absolute;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 1px;
}

.graph-axis:not(.vertical) {
    bottom: 20px;
    left: 20px;
    width: 120px;
    height: 2px;
}

.graph-axis.vertical {
    bottom: 20px;
    left: 20px;
    width: 2px;
    height: 80px;
}

.data-points {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.point {
    position: absolute;
    width: 6px;
    height: 6px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.point:nth-child(1) { top: 70px; left: 40px; }
.point:nth-child(2) { top: 50px; left: 60px; }
.point:nth-child(3) { top: 40px; left: 80px; }
.point:nth-child(4) { top: 25px; left: 100px; }

.regression-line {
    position: absolute;
    top: 75px;
    left: 25px;
    width: 90px;
    height: 2px;
    background: rgba(255, 255, 255, 0.9);
    transform: rotate(-25deg);
    transform-origin: left center;
    border-radius: 1px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.demo-content {
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.demo-content h3 {
    margin: 0 0 12px 0;
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
}

.demo-content p {
    margin: 0;
    color: #666;
    line-height: 1.5;
    font-size: 14px;
}

/* Responsive Design for Tablets */
@media (max-width: 1024px) {
    .demo-grid {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
        gap: 16px;
    }
    
    .container {
        max-width: 900px;
        padding: 20px;
    }
    
    .home-container {
        padding: 20px 8px;
    }
    
    .main-content {
        margin-left: 240px;
        padding: 15px;
    }

    .iframe-content {
        padding: 15px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: 10px;
        width: 100vw;
    }

    .iframe-content {
        padding: 10px;
    }
    
    .demo-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 12px;
    }
    
    .home-container {
        padding: 15px 5px;
    }
    
    .header {
        padding: 10px 15px;
    }
    
    .title {
        font-size: 1rem;
    }
    
    .demo-area {
        flex-direction: column;
        gap: 20px;
    }
    
    canvas {
        max-width: 100%;
        height: auto;
    }
}

h1 {
    color: #2c3e50;
    margin: 0 0 30px 0;
    text-align: center;
    font-size: 2rem;
    font-weight: 600;
}

.demo-area {
    display: flex;
    gap: 30px;
    align-items: flex-start;
}

.plot-container {
    flex: 2;
}

canvas {
    border: 2px solid #ddd;
    border-radius: 8px;
    background: white;
}

.controls {
    flex: 1;
    background: #f5f7fa;
    padding: 25px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #e0e0e0;
}

.control-group {
    margin-bottom: 25px;
}

.control-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: #2c3e50;
}

.slider-container {
    position: relative;
}

input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: #ddd;
    outline: none;
    -webkit-appearance: none;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #007bff;
    cursor: pointer;
    border: none;
}

.value-display {
    text-align: center;
    font-weight: bold;
    color: #007bff;
    margin-top: 5px;
}

.equation {
    background: #f0f8ff;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    font-size: 16px;
    font-weight: 500;
    color: #2c3e50;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    border: 1px solid #d0e0f0;
    word-break: break-all;
    overflow-wrap: break-word;
    line-height: 1.4;
}

.info {
    margin: 20px 0;
    padding: 20px 15%;
    background: #f0f8ff;
    border: 1px solid #d0e0f0;
    border-radius: 8px;
    font-size: 16px;
    color: #2c3e50;
    text-align: justify;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.info strong {
    text-align: center;
    display: block;
}

.solution-btn {
    width: 100%;
    padding: 12px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    margin: 25px 0 20px 0;
    transition: background-color 0.2s;
}

.solution-btn:hover {
    background: #218838;
}

.solution-btn:active {
    background: #1e7e34;
}

.plot-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
}

.generate-data-btn,
.clear-data-btn {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

.generate-data-btn {
    background: #6c757d;
    color: white;
}

.generate-data-btn:hover {
    background: #5a6268;
}

.generate-data-btn:active {
    background: #495057;
}

.clear-data-btn {
    background: #dc3545;
    color: white;
}

.clear-data-btn:hover {
    background: #c82333;
}

.clear-data-btn:active {
    background: #bd2130;
}

/* Degree description styling for polynomial regularisation demo */
.degree-description {
    margin-top: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 13px;
    color: #666;
    text-align: center;
    font-style: italic;
}

/* Side-by-side regularisation sliders */
.regularization-row {
    display: flex;
    gap: 15px;
}

.reg-slider-group {
    flex: 1;
}

.reg-slider-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: #2c3e50;
    text-align: center;
}

.reg-slider-group .slider-container {
    position: relative;
}

.reg-slider-group .value-display {
    font-size: 13px;
}

/* Minimal styles for RNN demo stats display */
.display-group {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.display-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.display-item:last-child {
    margin-bottom: 0;
}

/* Fix solution-btn sizing when used in plot-buttons flexbox */
.plot-buttons .solution-btn {
    width: auto;
    flex: 1;
    margin: 0;
    padding: 10px;
    font-size: 14px;
}