:root {
    --bg-primary: #f5f5f7;
    --bg-secondary: #ffffff;
    --bg-card: #f8f9fa;
    --bg-accent: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    --bg-reflection: #fff9e6;
    --text-primary: #333;
    --text-secondary: #555;
    --text-tertiary: #666;
    --border-color: #e0e0e0;
    --accent-color: #667eea;
    --accent-secondary: #764ba2;
    --shadow: rgba(0, 0, 0, 0.08);
    --shadow-hover: rgba(102, 126, 234, 0.15);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-primary: #1a1a1a;
        --bg-secondary: #2d2d2d;
        --bg-card: #383838;
        --bg-accent: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        --bg-reflection: #3d3520;
        --text-primary: #e5e5e5;
        --text-secondary: #b8b8b8;
        --text-tertiary: #999;
        --border-color: #404040;
        --accent-color: #8b9df6;
        --accent-secondary: #9d7ac2;
        --shadow: rgba(0, 0, 0, 0.3);
        --shadow-hover: rgba(139, 157, 246, 0.2);
    }
}

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

body {
    font-family:
        "SF Pro Text", "SF Pro Icons", "Helvetica Neue", "Helvetica", "Arial",
        sans-serif;
    font-size: 17px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition:
        background-color 0.3s ease,
        color 0.3s ease;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

header {
    background: linear-gradient(
        135deg,
        var(--accent-color) 0%,
        var(--accent-secondary) 100%
    );
    color: white;
    padding: 80px 20px;
    text-align: center;
}

header h1 {
    font-size: 3.5em;
    margin-bottom: 20px;
    font-weight: 700;
}

header p {
    font-size: 1.3em;
    opacity: 0.95;
    max-width: 600px;
    margin: 0 auto 30px;
}

.meta {
    font-size: 1.1em;
    opacity: 0.9;
    margin-top: 20px;
}

.toc-nav {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px var(--shadow);
    transition: background-color 0.3s ease;
}

.toc-nav .container {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 15px 20px;
}

.toc-nav a {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.95em;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.toc-nav a:hover {
    color: var(--accent-color);
    background: var(--bg-card);
    transform: translateY(-1px);
}

.toc-nav a:active {
    transform: translateY(0);
}

section {
    background: var(--bg-secondary);
    margin: 40px auto;
    padding: 60px 40px;
    border-radius: 12px;
    box-shadow: 0 2px 20px var(--shadow);
    transition: background-color 0.3s ease;
}

h2 {
    font-size: 2.2em;
    margin-bottom: 25px;
    color: var(--text-primary);
    border-bottom: 3px solid var(--accent-color);
    padding-bottom: 10px;
}

h3 {
    font-size: 1.5em;
    margin: 30px 0 15px;
    color: var(--accent-color);
}

.challenge {
    background: var(--bg-accent);
    max-width: 800px;
}

.technical-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 30px;
    align-items: start; /* ensures equal vertical alignment */
}

.tech-card {
    background: var(--bg-card);
    padding: 25px;
    border-radius: 8px;
    border-left: 4px solid var(--accent-color);
    transition:
        transform 0.2s,
        box-shadow 0.2s,
        background-color 0.3s ease;
    max-width: 100%; /* prevents overflow */
    overflow-wrap: break-word;
}

.tech-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px var(--shadow-hover);
}

.tech-card h3 {
    margin-top: 0;
    font-size: 1.3em;
}

.tech-card ul {
    margin-left: 20px;
    margin-top: 10px;
}

.tech-card li {
    margin: 8px 0;
    color: var(--text-secondary);
}

.principles {
    display: flex;
    gap: 20px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.principle {
    flex: 1;
    min-width: 250px;
    background: var(--bg-card);
    padding: 25px;
    border-radius: 8px;
    border-top: 3px solid var(--accent-color);
    transition: background-color 0.3s ease;
}

.principle h4 {
    color: var(--accent-color);
    margin-bottom: 10px;
    font-size: 1.2em;
}

.impact-stats {
    display: flex;
    justify-content: space-around;
    margin: 40px 0;
    flex-wrap: wrap;
    gap: 10px;
}

.stat {
    text-align: center;
    padding: 20px;
    border: 1px dashed slateblue;
    border-radius: 20px;
}

.stat-number {
    font-size: 2.5em;
    font-weight: 700;
    color: var(--accent-color);
}

.stat-label {
    color: var(--text-tertiary);
    margin-top: 5px;
}

.reflection {
    background: var(--bg-reflection);
    padding: 25px;
    border-radius: 8px;
    border-left: 4px solid #ffc107;
    margin: 30px 0;
    transition: background-color 0.3s ease;
}

.reflection h4 {
    color: #f57c00;
    margin-bottom: 10px;
}

.goodnotes-connection {
    background: linear-gradient(
        135deg,
        var(--accent-color) 0%,
        var(--accent-secondary) 100%
    );
    color: white;
}

.goodnotes-connection h2 {
    color: white;
    border-bottom-color: rgba(255, 255, 255, 0.3);
}

.goodnotes-connection ul {
    list-style: none;
    margin-top: 20px;
}

.goodnotes-connection li {
    padding: 15px;
    margin: 10px 0;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding-left: 45px;
    position: relative;
}

.goodnotes-connection li:before {
    content: "✓";
    position: absolute;
    left: 15px;
    font-weight: bold;
    font-size: 1.3em;
}

.screenshot-placeholder {
    background: var(--bg-card);
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 60px;
    text-align: center;
    color: var(--text-tertiary);
    margin: 30px 0;
    font-style: italic;
    transition:
        background-color 0.3s ease,
        border-color 0.3s ease;
}

.screenshot-placeholder video {
    width: 100%;
    max-width: 800px;
    height: auto;
}

footer {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-tertiary);
}

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

    section {
        padding: 40px 25px;
    }

    .principles {
        flex-direction: column;
    }
}
