* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body {
    border-left: 2px solid black;
    border-right: 2px solid black;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 1600px;
    margin: 0 auto;
}

header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 65px;
    padding: 0.5rem 1.5rem;
    border-bottom: 2px solid black;
    flex-shrink: 0;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    padding-right: 1.5rem;
    border-right: 2px solid black;
}

.logo a {
    text-decoration: none;
    color: black;
    font-weight: 500;
    font-size: clamp(1rem, 2vw, 1.1rem);
    letter-spacing: -0.01em;
    white-space: nowrap;
}

nav {
    flex: 1;
    display: flex;
    justify-content: flex-end;
    min-width: 200px;
}

nav ul {
    display: flex;
    list-style: none;
    gap: clamp(1.5rem, 4vw, 3rem);
    flex-wrap: wrap;
    justify-content: flex-end;
}

nav a {
    text-decoration: none;
    color: black;
    font-weight: 400;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    white-space: nowrap;
}

nav a:hover {
    text-decoration: underline;
    text-underline-offset: 4px;
}

.page-heading {
    padding: 1.5rem 1.5rem 0.5rem;
    border-bottom: 2px solid black;
}

.page-heading h1 {
    font-family: 'Cormorant Garamond', 'Times New Roman', Times, Baskerville, Georgia, serif;
    font-weight: 500;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.page-heading p {
    color: #4a4a4a;
    font-size: clamp(0.85rem, 2vw, 0.95rem);
    margin-top: 0.25rem;
}

.main {
    display: flex;
    flex: 1;
    border-bottom: 2px solid black;
    flex-wrap: wrap;
}

.sidebar {
    width: 240px;
    border-right: 2px solid black;
    padding: 1.5rem 1rem;
    display: flex;
    flex-direction: column;
    background-color: #fafafa;
    flex-shrink: 0;
}

.sidebar h2 {
    font-family: 'Cormorant Garamond', 'Times New Roman', Times, serif;
    font-weight: 500;
    font-size: clamp(1.3rem, 3vw, 1.5rem);
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.5rem;
}

.sidebar a {
    text-decoration: none;
    color: black;
    padding: 0.5rem 0;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    border-bottom: 1px dotted #e0e0e0;
}

.sidebar a:hover {
    padding-left: 0.5rem;
    background-color: #f0f0f0;
    text-decoration: underline;
    text-underline-offset: 4px;
}

.text-container {
    border-right: 2px solid black;
    padding: 1.5rem;
    flex: 1;
    line-height: 1.6;
    color: #333;
    min-width: 280px;
}

.text-container h2 {
    font-family: 'Cormorant Garamond', 'Times New Roman', Times, serif;
    font-weight: 500;
    font-size: clamp(1.5rem, 4vw, 1.8rem);
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.text-container p {
    margin-bottom: 1rem;
}

.formula-block {
    font-family: 'Courier New', monospace;
    background-color: #f8f9fa;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    font-size: 1.1rem;
    overflow-x: auto;
    white-space: nowrap;
    border: 1px solid #e0e0e0;
    border-left: 4px solid #1e3a5f;
}

.example-box {
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    font-size: 0.95rem;
    line-height: 1.6;
    border-left: 4px solid #4a4a4a;
}

.example-box strong {
    color: #1e3a5f;
    display: block;
    margin-bottom: 0.5rem;
}


.table-wrapper {
    overflow-x: auto;
    margin: 1.5rem 0;
    border: 1px solid #ddd;
    background: white;
}

.derivative-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
    min-width: 400px;
}

.derivative-table th {
    background-color: #1e3a5f;
    color: white;
    font-weight: 500;
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.95rem;
    border: 1px solid #1e3a5f;
}

.derivative-table td {
    padding: 0.75rem 1rem;
    border: 1px solid #ddd;
    font-family: 'Courier New', monospace;
}

.derivative-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.step-list {
    margin: 1.5rem 0 1.5rem 2rem;
    padding-left: 0;
}

.step-list li {
    margin-bottom: 0.75rem;
    padding-left: 0.5rem;
}

.data-container {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    width: 320px;
    align-self: start;
    flex-shrink: 0;
}

.data-container img {
    max-width: 100%;
    height: auto;
    border: 1px solid #bbb;
    background: white;
}

.image-caption {
    font-size: 0.75rem;
    color: #555;
    margin-top: 0.4rem;
    text-align: center;
    width: 100%;
    border-top: 1px dotted #aaa;
    padding-top: 0.4rem;
    margin-bottom: 1.5rem;
}

.extra-images {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.extra-images img {
    border: 1px solid #ccc;
    width: 100%;
    height: auto;
}

footer {
    border-top: 2px solid black;
    background-color: #fafafa;
    padding: 2rem 1.5rem 1rem;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
}

.footer-content h3 {
    font-family: 'Cormorant Garamond', 'Times New Roman', Times, serif;
    font-weight: 500;
    font-size: clamp(1.3rem, 3vw, 1.5rem);
    margin-bottom: 1.5rem;
    letter-spacing: -0.02em;
    border-bottom: 1px solid #ddd;
    padding-bottom: 0.5rem;
}

.references-list {
    list-style: none;
    margin-bottom: 2rem;
}

.references-list li {
    display: flex;
    align-items: baseline;
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
    font-size: clamp(0.85rem, 2vw, 0.9rem);
    line-height: 1.5;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.references-list li:last-child {
    border-bottom: none;
}

.ref-number {
    font-family: monospace;
    color: #666;
    min-width: 40px;
    font-size: 0.85rem;
    flex-shrink: 0;
}

.references-list a {
    color: #0066cc;
    text-decoration: none;
    margin-right: 0.5rem;
    word-break: break-word;
}

.references-list a:hover {
    text-decoration: underline;
    text-underline-offset: 2px;
}

.ref-source {
    color: #666;
    font-size: 0.85rem;
}

.footer-bottom {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #ddd;
    text-align: center;
    font-size: 0.85rem;
    color: #666;
}

.footer-bottom a {
    color: #0066cc;
    text-decoration: none;
}

.footer-bottom a:hover {
    text-decoration: underline;
}

@media (max-width: 1024px) {
    .main {
        flex-wrap: wrap;
    }

    .sidebar {
        width: 200px;
    }

    .data-container {
        width: 280px;
    }
    
    .formula-block {
        white-space: normal;
        word-break: break-word;
    }
}

@media (max-width: 768px) {
    header {
        padding: 0.5rem 1rem;
    }

    .logo {
        padding-right: 1rem;
        border-right: 1px solid black;
    }

    .main {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 2px solid black;
        padding: 1rem;
    }

    .text-container {
        border-right: none;
        border-bottom: 2px solid black;
        padding: 1rem;
    }

    .data-container {
        width: 100%;
        padding: 1rem;
        align-items: center;
    }

    .extra-images {
        max-width: 400px;
        margin-left: auto;
        margin-right: auto;
        width: 100%;
    }
}

@media (max-width: 480px) {
    header {
        flex-direction: column;
        height: auto;
        padding: 0.5rem;
    }

    .logo {
        border-right: none;
        border-bottom: 1px solid black;
        padding-right: 0;
        padding-bottom: 0.5rem;
        width: 100%;
        text-align: center;
    }

    nav {
        justify-content: center;
        width: 100%;
    }

    nav ul {
        justify-content: center;
        gap: 1rem;
    }

    .page-heading {
        padding: 1rem 0.5rem 0.5rem;
    }

    .sidebar a {
        text-align: center;
    }

    .references-list li {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .ref-number {
        min-width: auto;
    }

    footer {
        padding: 1.5rem 1rem 1rem;
    }
}

@media print {
    body {
        border: none;
        max-width: 100%;
    }

    .sidebar,
    .data-container,
    footer {
        display: none;
    }

    .text-container {
        border: none;
    }
    
    .formula-block {
        background: #ffffff;
        border: 1px solid #000;
    }
    
    .example-box {
        background: #ffffff;
        border: 1px solid #000;
    }
    
    .derivative-table th {
        background-color: #eee;
        color: black;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

@media (prefers-contrast: high) {
    body {
        border-color: black;
    }
}