:root {
    --bg: #fbfaf8;
    --bg-raised: #ffffff;
    --bg-tint: #f1f5f3;
    --text: #17201d;
    --text-muted: #5c6763;
    --text-faint: #8a938f;
    --accent: #1f7a6e;
    --accent-soft: rgba(31, 122, 110, 0.10);
    --border: rgba(23, 32, 29, 0.12);
    --border-strong: rgba(23, 32, 29, 0.22);
    --shadow: 0 1px 2px rgba(23, 32, 29, 0.05), 0 8px 24px -12px rgba(23, 32, 29, 0.15);
    --topbar-bg: rgba(251, 250, 248, 0.85);

    --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

    --measure: 65ch;
    --wide: 1080px;
    --radius: 12px;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0e1412;
        --bg-raised: #151d1a;
        --bg-tint: #131c19;
        --text: #e9eeeb;
        --text-muted: #a0aca7;
        --text-faint: #77837e;
        --accent: #6ecfbe;
        --accent-soft: rgba(110, 207, 190, 0.12);
        --border: rgba(233, 238, 235, 0.14);
        --border-strong: rgba(233, 238, 235, 0.26);
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.7);
        --topbar-bg: rgba(14, 20, 18, 0.85);
    }
}

:root[data-theme="dark"] {
    --bg: #0e1412;
    --bg-raised: #151d1a;
    --bg-tint: #131c19;
    --text: #e9eeeb;
    --text-muted: #a0aca7;
    --text-faint: #77837e;
    --accent: #6ecfbe;
    --accent-soft: rgba(110, 207, 190, 0.12);
    --border: rgba(233, 238, 235, 0.14);
    --border-strong: rgba(233, 238, 235, 0.26);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -12px rgba(0, 0, 0, 0.7);
    --topbar-bg: rgba(14, 20, 18, 0.85);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 5rem;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 17px;
    line-height: 1.65;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
    font-family: var(--font-serif);
    font-weight: 600;
    line-height: 1.2;
    letter-spacing: -0.01em;
    margin: 0;
}

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

a {
    color: var(--accent);
    text-decoration-color: color-mix(in srgb, var(--accent) 40%, transparent);
    text-underline-offset: 3px;
}
a:hover { text-decoration-color: currentColor; }

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

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 3px;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--bg-raised);
    padding: 0.6rem 1rem;
    z-index: 100;
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* Top bar */
.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: var(--topbar-bg);
    backdrop-filter: saturate(1.4) blur(10px);
    border-bottom: 1px solid var(--border);
}

.topbar-inner {
    max-width: var(--wide);
    margin: 0 auto;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.brand {
    font-family: var(--font-serif);
    font-size: 1.05rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: var(--text);
    text-decoration: none;
}

.nav {
    display: flex;
    gap: 1.4rem;
    margin-left: auto;
    font-size: 0.9rem;
}

.nav a {
    color: var(--text-muted);
    text-decoration: none;
}
.nav a:hover { color: var(--accent); }

.theme-toggle {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 999px;
    width: 2rem;
    height: 2rem;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.theme-toggle:hover { color: var(--accent); border-color: var(--border-strong); }

/* Layout */
.section {
    max-width: var(--wide);
    margin: 0 auto;
    padding: 3.5rem 1.5rem;
    border-top: 1px solid var(--border);
}

.section-title {
    font-size: 0.78rem;
    font-family: var(--font-sans);
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 1.75rem;
}

.section-intro {
    color: var(--text-muted);
    margin-top: -1rem;
    margin-bottom: 2rem;
}

.prose { max-width: var(--measure); }
.prose p { color: var(--text-muted); }

/* Hero */
.hero {
    max-width: var(--wide);
    margin: 0 auto;
    padding: 5rem 1.5rem 4rem;
}

.eyebrow {
    font-size: 0.8rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 0.9rem;
}

.hero h1 {
    font-size: clamp(2.6rem, 7vw, 4.2rem);
    margin-bottom: 1.25rem;
}

.lede {
    font-size: clamp(1.1rem, 2.2vw, 1.35rem);
    line-height: 1.55;
    color: var(--text-muted);
    max-width: min(58ch, 100%);
    margin-bottom: 2rem;
}

.cta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.btn {
    display: inline-block;
    padding: 0.65rem 1.25rem;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    color: var(--text);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}
.btn:hover { background: var(--accent-soft); border-color: var(--accent); }

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--bg);
}
.btn-primary:hover {
    background: color-mix(in srgb, var(--accent) 85%, var(--text));
    border-color: transparent;
    color: var(--bg);
}

.hero-links {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    padding: 0;
    margin: 0;
    font-size: 0.92rem;
}

/* Selected work cards */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.card {
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
}

.card-metric {
    font-family: var(--font-mono);
    font-size: 0.82rem;
    letter-spacing: 0.02em;
    color: var(--accent);
    margin-bottom: 0.5rem;
}

.card h3 {
    font-size: 1.15rem;
    margin-bottom: 0.6rem;
}

.card p:last-child {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin: 0;
}

/* EverPal */
.everpal {
    background: var(--bg-tint);
    max-width: none;
    padding-left: 0;
    padding-right: 0;
}

.everpal-inner {
    max-width: var(--wide);
    margin: 0 auto;
    padding: 0 1.5rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 0.9fr);
    gap: 3rem;
    align-items: center;
}

.everpal-logo {
    width: 150px;
    margin-bottom: 1.25rem;
}

.badge {
    display: inline-block;
    font-size: 0.75rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    background: var(--accent-soft);
    border-radius: 999px;
    padding: 0.3rem 0.75rem;
    margin-bottom: 1rem;
}

.everpal h2 {
    font-size: clamp(1.6rem, 3.4vw, 2.2rem);
    margin-bottom: 1rem;
    max-width: 22ch;
}

.everpal-copy p { color: var(--text-muted); }

.stack {
    font-size: 0.88rem;
    color: var(--text-faint) !important;
}
.stack strong { color: var(--text-muted); }

.everpal-shot img {
    display: block;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

/* Timeline */
.timeline {
    list-style: none;
    margin: 0;
    padding: 0;
    max-width: 780px;
}

.entry {
    position: relative;
    padding: 0 0 2.25rem 1.5rem;
    border-left: 1px solid var(--border);
}
.entry:last-child { padding-bottom: 0; border-left-color: transparent; }

.entry::before {
    content: "";
    position: absolute;
    left: -4.5px;
    top: 0.6rem;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent);
}

.entry-head {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.15rem;
}

.entry h3 { font-size: 1.2rem; }

.dates {
    font-size: 0.82rem;
    color: var(--text-faint);
    font-variant-numeric: tabular-nums;
    margin-left: auto;
}

.role {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--accent);
    margin: 0.35rem 0 0.15rem;
}

.role-dates {
    font-weight: 400;
    color: var(--text-faint);
    font-size: 0.85rem;
}

.project {
    font-size: 0.9rem;
    color: var(--text-faint);
    font-style: italic;
    margin-bottom: 0.6rem;
}

.entry ul {
    margin: 0.5rem 0 0.75rem;
    padding-left: 1.1rem;
    color: var(--text-muted);
    font-size: 0.95rem;
}
.entry li { margin-bottom: 0.3rem; }

.entry.compact p:not(.role):not(.tech) {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.tech {
    font-size: 0.82rem;
    color: var(--text-faint);
    margin: 0;
}

/* Skills */
.skills { margin: 0; }

.skill-row {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 1.5rem;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border);
}
.skill-row:last-child { border-bottom: none; }

.skills dt {
    font-weight: 600;
    font-size: 0.95rem;
}
.skills dt span {
    display: block;
    font-weight: 400;
    font-size: 0.8rem;
    color: var(--text-faint);
}

.skills dd {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.95rem;
}

/* Projects */
.projects {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.75rem;
}

.projects h3 {
    font-size: 1.1rem;
    margin-bottom: 0.4rem;
}

.projects p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-bottom: 0.4rem;
}

/* Background */
.two-col {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 2.5rem;
}

.two-col h3 {
    font-size: 1.05rem;
    margin-bottom: 0.75rem;
}

.two-col p {
    color: var(--text-muted);
    font-size: 0.95rem;
}
.two-col strong { color: var(--text); }

/* Contact */
.contact .prose { margin-bottom: 1.75rem; }

.footer {
    max-width: var(--wide);
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
    border-top: 1px solid var(--border);
    color: var(--text-faint);
    font-size: 0.85rem;
}

@media (max-width: 820px) {
    .everpal-inner {
        grid-template-columns: 1fr;
        gap: 2rem;
    }
    .skill-row {
        grid-template-columns: 1fr;
        gap: 0.35rem;
    }
}

@media (max-width: 620px) {
    body { font-size: 16px; }
    .nav { display: none; }
    .theme-toggle { margin-left: auto; }
    .hero { padding-top: 3.5rem; }
    .section { padding: 2.75rem 1.25rem; }
    .hero, .everpal-inner, .footer, .topbar-inner { padding-left: 1.25rem; padding-right: 1.25rem; }
    .dates { margin-left: 0; width: 100%; }
}

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