:root {
    --bg: #f4f7f4;
    --bg-soft: #e6efe6;
    --surface: #ffffff;
    --surface-strong: #f8fbf8;
    --text: #132418;
    --muted: #3d5545;
    --line: #cfe0d1;
    --primary: #1f7a4a;
    --primary-deep: #165c38;
    --accent: #d8a623;
    --shadow: 0 14px 30px rgba(18, 36, 26, 0.09);
    --radius: 16px;
    --nav-height: 72px;
    /* Section theme colors (section bg + matching nav active) */
    --theme-problem: #e8f0f5;
    --theme-problem-nav: #5a8fa8;
    --theme-objectives: #f5f0e8;
    --theme-objectives-nav: #a88b5a;
    --theme-architecture: #f0e8f5;
    --theme-architecture-nav: #7a5a9e;
    --theme-hardware: #e8f5ee;
    --theme-hardware-nav: #3d8f5c;
    --theme-software: #e8f2f8;
    --theme-software-nav: #4a7fb8;
    --theme-prototype: #f8f0e8;
    --theme-prototype-nav: #b8926a;
    --theme-circuit: #f5eef2;
    --theme-circuit-nav: #9e6a85;
    --theme-timeline: #eef5e8;
    --theme-timeline-nav: #6a9e5a;
    --theme-conclusion: #f0f5e8;
    --theme-conclusion-nav: #7a9e5a;
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    background:
        radial-gradient(circle at 10% 10%, rgba(216, 166, 35, 0.16), transparent 38%),
        radial-gradient(circle at 85% 0%, rgba(31, 122, 74, 0.16), transparent 42%),
        var(--bg);
    color: var(--text);
    font-family: "Manrope", "Segoe UI", sans-serif;
    line-height: 1.7;
}

img {
    max-width: 100%;
    display: block;
}

h1,
h2,
h3 {
    margin: 0;
    line-height: 1.2;
    font-family: "Space Grotesk", "Trebuchet MS", sans-serif;
    letter-spacing: -0.02em;
}

h2 {
    margin-bottom: 0.8rem;
    font-size: clamp(1.35rem, 2vw, 1.95rem);
}

h3 {
    font-size: 1.05rem;
}

p,
li {
    color: var(--muted);
}

.container {
    width: min(1100px, 92%);
    margin: 0 auto;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--primary-deep);
    color: #fff;
    padding: 0.6rem 1rem;
    z-index: 1000;
}

.skip-link:focus {
    left: 1rem;
    top: 1rem;
    border-radius: 8px;
}

.hero {
    padding: 4.5rem 0 3rem;
    background: linear-gradient(180deg, #4a148c 0%, #6a1b9a 50%, #7b1fa2 100%);
    border-radius: 0 0 32px 32px;
    transition: background 0.4s ease, box-shadow 0.4s ease;
}

.hero:hover {
    background: linear-gradient(180deg, #6a1b9a 0%, #7b1fa2 50%, #8e24aa 100%);
    box-shadow: 0 12px 40px rgba(106, 27, 154, 0.4);
}

.hero__content {
    background: linear-gradient(145deg, #4a148c 0%, #6a1b9a 45%, #7b1fa2 100%);
    color: #fff;
    border-radius: 26px;
    padding: clamp(1.4rem, 3.5vw, 3rem);
    box-shadow: 0 12px 32px rgba(74, 20, 140, 0.4);
    position: relative;
    overflow: hidden;
    transition: transform 0.35s ease, box-shadow 0.35s ease, background 0.35s ease;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.hero__content:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 48px rgba(74, 20, 140, 0.5);
    background: linear-gradient(145deg, #6a1b9a 0%, #7b1fa2 45%, #8e24aa 100%);
}

.hero__content::after {
    content: "";
    position: absolute;
    width: 220px;
    height: 220px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    right: -70px;
    top: -70px;
    transition: transform 0.4s ease, opacity 0.4s ease;
}

.hero__content:hover::after {
    transform: scale(1.15);
    opacity: 0.35;
}

.eyebrow {
    margin: 0 0 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-size: 0.74rem;
    color: rgba(255, 255, 255, 0.95);
    font-weight: 700;
}

.hero h1 {
    font-size: clamp(1.8rem, 4.3vw, 3.1rem);
    max-width: 18ch;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.hero__byline {
    margin: 0.55rem 0 0;
    color: rgba(255, 255, 255, 0.92);
    font-size: 0.96rem;
    font-weight: 600;
    letter-spacing: 0.01em;
}

.hero__lead {
    color: rgba(255, 255, 255, 0.95);
    max-width: 62ch;
    margin: 1rem 0 1.2rem;
}

.hero__lead strong {
    display: inline-block;
    padding: 0.08rem 0.5rem;
    margin: 0 0.1rem;
    border-radius: 999px;
    background: linear-gradient(135deg, #f5e6b8, #fff4d4);
    color: #2d4a5c;
    font-weight: 800;
    box-shadow: 0 6px 16px rgba(40, 80, 120, 0.2);
}

.hero__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
}

.hero__meta span {
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    padding: 0.4rem 0.8rem;
    font-size: 0.86rem;
    color: #f3fff8;
}

.site-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    background: rgba(244, 247, 244, 0.95);
    border-bottom: 1px solid var(--line);
}

.nav-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: var(--nav-height);
    gap: 1rem;
}

.brand {
    margin: 0;
    color: var(--primary-deep);
    font-family: "Space Grotesk", sans-serif;
    font-weight: 700;
    white-space: nowrap;
}

.nav-list {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    list-style: none;
    gap: 0.45rem;
    margin: 0;
    padding: 0;
}

.nav-list a {
    text-decoration: none;
    color: var(--text);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 0.45rem 0.65rem;
    border-radius: 9px;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.nav-list a:hover,
.nav-list a:focus-visible {
    background: var(--primary);
    color: #fff;
}

/* Active nav item matches its section theme */
.nav-list a.active[data-section="problem"] { background: var(--theme-problem-nav); color: #fff; }
.nav-list a.active[data-section="objectives"] { background: var(--theme-objectives-nav); color: #fff; }
.nav-list a.active[data-section="architecture"] { background: var(--theme-architecture-nav); color: #fff; }
.nav-list a.active[data-section="hardware"] { background: var(--theme-hardware-nav); color: #fff; }
.nav-list a.active[data-section="software"] { background: var(--theme-software-nav); color: #fff; }
.nav-list a.active[data-section="prototype"] { background: var(--theme-prototype-nav); color: #fff; }
.nav-list a.active[data-section="circuit"] { background: var(--theme-circuit-nav); color: #fff; }
.nav-list a.active[data-section="timeline"] { background: var(--theme-timeline-nav); color: #fff; }
.nav-list a.active[data-section="conclusion"] { background: var(--theme-conclusion-nav); color: #fff; }

.nav-toggle {
    display: none;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 10px;
    width: 42px;
    height: 42px;
    padding: 0.5rem;
    cursor: pointer;
}

.nav-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text);
    margin: 4px 0;
}

.page-content {
    padding: 2rem 0 2.8rem;
}

.panel {
    background: linear-gradient(180deg, var(--surface), var(--surface-strong));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: clamp(1rem, 2.8vw, 2rem);
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
    scroll-margin-top: calc(var(--nav-height) + 18px);
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
}

.panel:hover {
    box-shadow: 0 20px 45px rgba(18, 36, 26, 0.14), 0 8px 20px rgba(18, 36, 26, 0.08);
    transform: translateY(-2px);
    border-color: rgba(31, 122, 74, 0.25);
}

/* Section-specific backgrounds (match nav active theme) */
.panel--problem { background: linear-gradient(180deg, var(--theme-problem), #fff); border-color: rgba(90, 143, 168, 0.25); }
.panel--objectives { background: linear-gradient(180deg, var(--theme-objectives), #fff); border-color: rgba(168, 139, 90, 0.25); }
.panel--architecture { background: linear-gradient(180deg, var(--theme-architecture), #fff); border-color: rgba(122, 90, 158, 0.25); }
.panel--hardware { background: linear-gradient(180deg, var(--theme-hardware), #fff); border-color: rgba(61, 143, 92, 0.25); }
.panel--software { background: linear-gradient(180deg, var(--theme-software), #fff); border-color: rgba(74, 127, 184, 0.25); }
.panel--prototype { background: linear-gradient(180deg, var(--theme-prototype), #fff); border-color: rgba(184, 146, 106, 0.25); }
.panel--circuit { background: linear-gradient(180deg, var(--theme-circuit), #fff); border-color: rgba(158, 106, 133, 0.25); }
.panel--timeline { background: linear-gradient(180deg, var(--theme-timeline), #fff); border-color: rgba(106, 158, 90, 0.25); }
.panel--conclusion { background: linear-gradient(180deg, var(--theme-conclusion), #fff); border-color: rgba(122, 158, 90, 0.25); }

.panel--problem:hover { border-color: rgba(90, 143, 168, 0.45); }
.panel--objectives:hover { border-color: rgba(168, 139, 90, 0.45); }
.panel--architecture:hover { border-color: rgba(122, 90, 158, 0.45); }
.panel--hardware:hover { border-color: rgba(61, 143, 92, 0.45); }
.panel--software:hover { border-color: rgba(74, 127, 184, 0.45); }
.panel--prototype:hover { border-color: rgba(184, 146, 106, 0.45); }
.panel--circuit:hover { border-color: rgba(158, 106, 133, 0.45); }
.panel--timeline:hover { border-color: rgba(106, 158, 90, 0.45); }
.panel--conclusion:hover { border-color: rgba(122, 158, 90, 0.45); }

.section-intro {
    margin-top: 0;
}

.callout {
    border-left: 4px solid var(--accent);
    background: #fff9ea;
    border-radius: 10px;
    padding: 0.8rem 1rem;
    margin-top: 1rem;
}

.hardware-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
    gap: 1rem;
}

.card {
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 0.85rem;
    background: #fff;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 24px rgba(17, 42, 24, 0.12);
}

.card img {
    width: 100%;
    aspect-ratio: 4 / 3;
    object-fit: contain;
    border-radius: 10px;
    background: var(--bg-soft);
    margin-bottom: 0.8rem;
}

.image-figure {
    margin: 1rem 0 0;
}

.system-image {
    border-radius: 12px;
    border: 1px solid var(--line);
}

figcaption {
    font-size: 0.9rem;
    margin-top: 0.6rem;
}

.tool-list li,
.check-list li {
    margin-bottom: 0.45rem;
}

.two-col {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.8rem;
}

.two-col article {
    padding: 0.85rem;
    border: 1px dashed var(--line);
    border-radius: 10px;
    background: #fff;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 620px;
    background: #fff;
    border: 1px solid var(--line);
}

caption {
    caption-side: top;
    text-align: left;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.6rem;
}

th,
td {
    border-bottom: 1px solid var(--line);
    padding: 0.72rem;
    text-align: left;
}

thead th,
tfoot th {
    background: #edf7ef;
    color: var(--primary-deep);
}

.timeline {
    display: grid;
    gap: 0.7rem;
}

.timeline article {
    border-left: 4px solid var(--primary);
    background: #fff;
    border-radius: 10px;
    padding: 0.55rem 0.8rem;
}

.note {
    margin-bottom: 0;
    font-size: 0.92rem;
}

.site-footer {
    background: #102a1a;
    color: #e6f5ec;
    padding: 1.2rem 0;
    border-top: 4px solid var(--accent);
}

.site-footer p {
    margin: 0.25rem 0;
    color: #d8ebe0;
}

.reveal {
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.reveal.is-visible {
    opacity: 1;
    transform: translateY(0);
}

@media (max-width: 980px) {
    .nav-toggle {
        display: inline-block;
    }

    .nav-list {
        position: absolute;
        left: 4%;
        right: 4%;
        top: calc(var(--nav-height) - 4px);
        flex-direction: column;
        align-items: stretch;
        background: #fff;
        border: 1px solid var(--line);
        border-radius: 12px;
        padding: 0.7rem;
        box-shadow: var(--shadow);
        max-height: 0;
        overflow: hidden;
        opacity: 0;
        pointer-events: none;
        transition: max-height 0.25s ease, opacity 0.25s ease;
    }

    .nav-list.is-open {
        max-height: 70vh;
        opacity: 1;
        pointer-events: auto;
    }

    .nav-list a {
        padding: 0.65rem;
    }

    .two-col {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    :root {
        --nav-height: 64px;
    }

    body {
        font-size: 0.97rem;
    }

    .hero {
        padding-top: 1rem;
    }

    .hero__meta {
        gap: 0.5rem;
    }

    .hero__meta span {
        font-size: 0.8rem;
    }

    .panel {
        margin-bottom: 0.8rem;
    }
}