:root {
    --bg: #f3f4f8;
    --bg1: #ffffff;
    --bg2: #eef0f5;
    --bg3: #e4e7ef;
    --line: #d5dae4;
    --line2: #c3c9d6;
    --text: #1a1d26;
    --muted: #667085;
    --accent: #4d6ef0;
    --accent-2: #3d5ce0;
    --accent-bg: rgba(77, 110, 240, .12);
    --ok: #2f9d6a;
    --warn: #c4921a;
    --danger: #d45252;
    --mod: #c4921a;
    --r: 8px;
    --r-sm: 6px;
    --top-h: 56px;
    --page-card-tint: 100%;
    --color-global-bg: var(--bg);
    --color-global-text: var(--text);
    --color-link: var(--accent);
    --color-accent: var(--accent);
    --color-accent-2: var(--accent-2);
    --color-quote: var(--muted);
    color-scheme: light;
}

.dark {
    --bg: #0e1015;
    --bg1: #151821;
    --bg2: #1b1f2a;
    --bg3: #242936;
    --line: #2c3241;
    --line2: #3a4153;
    --text: #e8eaf0;
    --muted: #8f96a7;
    --accent: #7c9cff;
    --accent-2: #5b7cf0;
    --accent-bg: rgba(124, 156, 255, .14);
    --ok: #5fd39a;
    --warn: #f0c060;
    --danger: #ff7a7a;
    --mod: #f0c060;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

html { scroll-behavior: smooth; }

body {
    min-height: 100dvh;
    background: var(--bg);
    color: var(--text);
    font: 13px/1.4 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    overflow-x: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }

button { cursor: pointer; }

button:disabled { cursor: default; opacity: .4; }

a { color: var(--accent); }

.text-link { color: var(--accent); text-decoration: none; }

.text-link:hover { text-decoration: underline; }

code, kbd {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
}

kbd {
    background: var(--bg3);
    border: 1px solid var(--line2);
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 1px 6px;
}

.muted { color: var(--muted); }

.small { font-size: 11.5px; }

.grow { flex: 1; }

.hbox { display: flex; gap: 8px; align-items: center; }

.hbox .look-meta { display: inline; margin-top: 0; }

.vbox { display: flex; flex-direction: column; gap: 6px; }

.hidden { display: none !important; }

input[type="text"],
input[type="email"],
input[type="number"],
input[type="search"],
select,
textarea {
    background: var(--bg3);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    padding: 6px 8px;
    min-width: 0;
    outline: none;
    transition: border-color .15s;
    width: 100%;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

textarea { resize: vertical; }

input[type="range"] { accent-color: var(--accent); min-width: 0; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    background: var(--bg3);
    border: 1px solid var(--line2);
    border-radius: var(--r-sm);
    padding: 6px 12px;
    text-decoration: none;
    color: var(--text);
    white-space: nowrap;
    font: inherit;
    cursor: pointer;
    transition: background .15s, border-color .15s;
}

.btn:hover:not(:disabled) { border-color: var(--accent); }

.btn:focus-visible,
.chip-btn:focus-visible,
.icon-btn:focus-visible,
.skill-toggle:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn.primary {
    background: var(--accent-2);
    border-color: var(--accent);
    color: #fff;
    font-weight: 600;
}

.btn.primary:hover:not(:disabled) { background: var(--accent); }

.btn.accent { background: var(--accent-bg); border-color: var(--accent); }

.btn.ghost {
    background: transparent;
    border-color: transparent;
    color: var(--muted);
}

.btn.ghost:hover:not(:disabled) { color: var(--text); border-color: var(--line2); }

.btn.small { padding: 3px 8px; font-size: 12px; }

.btn.big { padding: 9px 18px; font-size: 14px; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 26px;
    padding: 0 6px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    color: var(--muted);
}

.icon-btn:hover:not(:disabled) { color: var(--text); background: var(--bg3); }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.chip-btn {
    display: inline-flex;
    align-items: center;
    background: var(--bg3);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 3px 11px;
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    line-height: inherit;
    text-decoration: none;
    cursor: default;
}

a.chip-btn, button.chip-btn { cursor: pointer; }

.chip-btn:hover { border-color: var(--accent); }

.chip-btn.on,
.chip-btn[aria-pressed="true"] {
    background: var(--accent-bg);
    border-color: var(--accent);
}

.chip {
    font-size: 10.5px;
    color: var(--muted);
    background: var(--bg3);
    border-radius: 4px;
    padding: 1px 6px;
    white-space: nowrap;
}

.lead { margin: 2px 0 12px; color: var(--muted); }

.topbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    min-height: var(--top-h);
    background: var(--bg1);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 20;
    min-width: 0;
    flex-wrap: nowrap;
}

.brand {
    font-weight: 650;
    letter-spacing: -.01em;
    color: var(--text);
    text-decoration: none;
    padding: 0 6px 0 2px;
}

.brand:hover { color: var(--accent); }

.brand-thumb {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex: none;
}

#tagline,
.topbar-kicker {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 42vw;
}

.topbar-nav {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-wrap: nowrap;
    min-width: 0;
}

.shell { position: relative; z-index: 10; min-height: 100dvh; }

#interactive-bg {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 0;
}

.page {
    max-width: 820px;
    margin: 0 auto;
    padding: 18px 16px 64px;
}

.page-card {
    background: color-mix(in srgb, var(--bg1) var(--page-card-tint, 100%), transparent);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 18px 18px 8px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, .08);
}

.dark .page-card { box-shadow: 0 12px 36px rgba(0, 0, 0, .5); }

.page-head { padding-bottom: 8px; }

.page-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.page-actions:not(:has(a, button, .chip)) { display: none; }

.page-head .chips { margin-top: 12px; }

.page-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 0 8px;
    border-top: 1px solid var(--line);
    margin-top: 8px;
}

.section { border-top: 1px solid var(--line); margin: 0 -18px; padding: 0 18px; }

.section:first-of-type { border-top: none; }

.section-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 11px 0 9px;
}

.section-head h3 {
    margin: 0;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text);
}

.section-body { padding-bottom: 12px; }

.section[id],
.project-card[id],
.skill-item[id],
.experience-item {
    scroll-margin-top: calc(var(--top-h) + 12px);
}

.section-head .icon-btn,
.experience-item .icon-btn,
.skill-item .icon-btn {
    opacity: 0;
}

.section-head:hover .icon-btn,
.experience-item:hover .icon-btn,
.skill-item:hover .icon-btn,
.icon-btn:focus-visible {
    opacity: 1;
}

.look-name {
    font-size: 16px;
    font-weight: 650;
    overflow-wrap: anywhere;
    color: var(--text);
}

.look-name.big { font-size: 22px; }

.look-desc {
    color: var(--text);
    opacity: .85;
    margin-top: 2px;
}

.look-meta {
    color: var(--muted);
    font-size: 11.5px;
    margin-top: 4px;
    display: block;
}

.fg-prose { color: var(--text); line-height: 1.55; }

.fg-prose p { margin: 0 0 .85rem; }

.fg-prose p:last-child { margin-bottom: 0; }

.fg-prose a,
.fg-prose .text-link { color: var(--accent); }

.fg-prose strong { color: var(--text); font-weight: 650; }

.fg-list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.fg-list li {
    position: relative;
    padding-left: 14px;
    margin: 0 0 6px;
    color: var(--text);
    line-height: 1.5;
}

.fg-list li:last-child { margin-bottom: 0; }

.fg-list li::before {
    content: "";
    position: absolute;
    left: 0;
    top: .55em;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--muted);
}

.essay-figure {
    margin: 12px -18px 8px;
    color: var(--text);
}

.essay-figure > .diagram,
.essay-figure > svg,
.essay-figure > img {
    width: 100%;
    height: auto;
    display: block;
    border: none;
    border-radius: 0;
    background: var(--bg3);
    padding: 14px 18px;
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.essay-caption {
    margin: 6px 18px 0;
    font-size: 11.5px;
    line-height: 1.4;
    color: var(--muted);
}

.fg-prose code,
.essay-section code {
    background: var(--bg3);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 1px 6px;
}

.notes { margin-top: 8px; }

.notes summary {
    cursor: pointer;
    color: var(--muted);
    font-size: 13px;
}

.notes summary:hover { color: var(--text); }

.card-head {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: space-between;
}

.card-head .item-name,
.card-head .look-name { font-weight: 600; font-size: 14px; margin: 0; }

.card-body { padding: 6px 0 8px; }

.card-body .chips { margin-top: 8px; }

.spread { justify-content: space-between; align-items: flex-start; width: 100%; }

.is-highlighted {
    outline: 2px solid var(--accent);
    outline-offset: 4px;
    border-radius: var(--r-sm);
}

.project-writeup { padding: 0 0 16px; }

.project-writeup + .project-writeup {
    border-top: 1px solid var(--line);
    margin-top: 8px;
    padding-top: 16px;
}

a.chip-btn:hover { border-color: var(--accent); }

.project-writeup .essay-figure { margin: 0 0 8px; }

.project-writeup .essay-figure > .diagram,
.project-writeup .essay-figure > svg,
.project-writeup .essay-figure > img {
    max-height: 168px;
    object-fit: contain;
}

.project-writeup .media-figure { margin: 8px 0 12px; }

.project-writeup .media-figure .carousel-slide { max-height: 280px; }

.project-writeup .media-figure .carousel-media { max-height: 280px; }

.project-archive .media-figure { margin: 10px 0 8px; }

.project-archive .media-figure .carousel-slide { max-height: 240px; }

.project-archive .media-figure .carousel-media { max-height: 240px; }

.project-writeup .look-name { margin: 0; }

.project-writeup .look-name a,
.project-writeup > a {
    color: inherit;
    text-decoration: none;
}

.project-writeup > a:hover .look-name { color: var(--accent); }

.writeup-dek {
    margin: 2px 0 10px;
    color: var(--text);
    opacity: .85;
    font-size: 13px;
    line-height: 1.45;
}

.writeup-grid { display: flex; flex-direction: column; gap: 10px; }

.project-archive {
    border-top: 1px solid var(--line);
    padding: 12px 0;
}

.project-archive:first-child { border-top: none; }

.project-archive h3 { margin: 0; font-size: 14px; font-weight: 650; }

.fg-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; align-items: center; }

.experience-item { padding: 12px 0; }

.experience-item + .experience-item { border-top: 1px solid var(--line); }

.experience-item:first-child { padding-top: 0; }

.experience-item .look-name a {
    color: inherit;
    text-decoration: none;
}

.experience-item .look-name a:hover { color: var(--accent); }

.experience-item .look-meta { margin: 0; }

.skill-item + .skill-item { border-top: 1px solid var(--line); }

.skills-grid {
    display: grid;
    gap: 16px;
    grid-template-columns: 1fr;
}

@media (min-width: 720px) {
    .skills-grid.cols-2,
    .skills-grid.cols-3,
    .skills-grid.cols-4 { grid-template-columns: 1fr 1fr; }
}

.subgroup { display: flex; flex-direction: column; gap: 4px; }

.subgroup-title {
    font-weight: 600;
    margin: 0;
    color: var(--text);
}

.skill-item .hbox i { font-size: 15px; }

.skill-toggle {
    cursor: pointer;
    user-select: none;
    width: 100%;
    background: none;
    border: none;
    text-align: left;
    font: inherit;
    color: inherit;
    border-radius: var(--r-sm);
}

.skill-toggle:hover { background: transparent; }

.skill-content {
    display: grid;
    grid-template-rows: 0fr;
    transition: grid-template-rows .3s ease-out;
}

.skill-content.open { grid-template-rows: 1fr; }

.skill-content > div {
    overflow: hidden;
    opacity: 0;
    transition: opacity .3s;
}

.skill-content.open > div { opacity: 1; }

.skill-toggle-icon { color: var(--muted); font-size: 11px; transition: transform .2s; }

.elsewhere-list { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.field { padding: 6px 0; }

.field-head { display: flex; align-items: center; gap: 6px; min-height: 22px; }

.field-label { font-weight: 500; }

.field-body { margin-top: 4px; }

.field.inline { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

.form-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 640px) {
    .form-grid { grid-template-columns: 1fr 1fr; }
}

.contact-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 8px; }

.doc { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.35; }

.note {
    border-radius: var(--r-sm);
    padding: 8px 10px;
    margin: 0;
    font-size: 12px;
}

.note.ok { background: rgba(95, 211, 154, .1); border: 1px solid rgba(95, 211, 154, .4); color: var(--ok); }

.note.error { background: rgba(255, 122, 122, .1); border: 1px solid rgba(255, 122, 122, .45); color: var(--danger); }

.note.warn { background: rgba(240, 192, 96, .1); border: 1px solid rgba(240, 192, 96, .4); color: var(--warn); }

.backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    background: rgba(4, 5, 8, .66);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: var(--bg1);
    border: 1px solid var(--line2);
    border-radius: 12px;
    width: min(620px, 100%);
    max-height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
    overflow: auto;
}

.modal-head { display: flex; align-items: center; padding: 14px 18px 8px; gap: 8px; }

.modal-head h2 { margin: 0; font-size: 17px; flex: 1; }

.modal-body { padding: 6px 18px 16px; overflow: auto; flex: 1; }

.modal-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--line); }

.media-figure { margin: 12px -18px 8px; }

.media-carousel {
    position: relative;
    width: 100%;
    overflow: hidden;
    border: none;
    border-radius: 0;
    background: var(--bg3);
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.carousel-slides {
    display: flex;
    transition: transform .3s ease-out;
    will-change: transform;
}

.carousel-slide {
    min-width: 100%;
    min-height: 180px;
    max-height: 560px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    background: var(--bg3);
}

.carousel-media {
    max-width: 100%;
    max-height: 560px;
    width: auto;
    height: auto;
    object-fit: contain;
    background: transparent;
}

.card > img.carousel-media {
    width: 100%;
    height: 160px;
    object-fit: cover;
    border-radius: 5px;
}

.carousel-prev,
.carousel-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    background: var(--bg1);
    border: 1px solid var(--line);
    color: var(--text);
}

.carousel-prev { left: 8px; }

.carousel-next { right: 8px; }

.carousel-dots {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    z-index: 2;
}

.carousel-dot {
    height: 4px;
    width: 22px;
    border: none;
    border-radius: 2px;
    padding: 0;
    background: var(--line2);
    cursor: pointer;
}

.carousel-dot.on { background: var(--accent); }

.bg-sim-panel {
    position: fixed;
    z-index: 60;
    right: 14px;
    bottom: 14px;
    width: min(26rem, calc(100vw - 2rem));
    max-height: min(38rem, calc(100dvh - 2rem));
    overflow: auto;
    padding: 12px 14px;
    background: var(--bg1);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--r);
    box-shadow: 0 12px 36px rgba(0, 0, 0, .28);
}

.dark .bg-sim-panel { box-shadow: 0 12px 36px rgba(0, 0, 0, .5); }

.bg-sim-panel[hidden] { display: none; }

.bg-sim-modes { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 10px; }

.bg-sim-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.bg-sim-head .look-name { font-size: 14px; }

.bg-sim-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-left: auto; }

.bg-sim-row {
    display: grid;
    grid-template-columns: 5.2rem 1fr 3.6rem;
    gap: 8px;
    align-items: center;
    margin-top: 8px;
}

.bg-sim-row input[type="range"] { width: 100%; }

.bg-sim-row input[type="number"] {
    width: 100%;
    text-align: right;
    -moz-appearance: textfield;
    appearance: textfield;
}

.bg-sim-row input[type="number"]::-webkit-inner-spin-button,
.bg-sim-row input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.bg-sim-warn-mark {
    margin-left: .15rem;
    font-weight: 700;
    visibility: hidden;
}

.bg-sim-row-warn span[data-label],
.bg-sim-row-warn input[type="number"],
.bg-sim-row-warn .bg-sim-warn-mark { color: var(--warn); }

.bg-sim-row-warn input[type="number"] { border-color: var(--warn); }

.bg-sim-row-warn input[type="range"] { accent-color: var(--warn); }

.bg-sim-row-warn .bg-sim-warn-mark { visibility: visible; }

.bg-sim-hint { margin: 10px 0 0; color: var(--muted); line-height: 1.45; }

.bg-sim-note { margin: 6px 0 0; color: var(--muted); line-height: 1.45; font-size: 11.5px; }

body.bg-can-grab, body.bg-can-grab * { cursor: grab !important; }

body.bg-grabbing, body.bg-grabbing * {
    cursor: grabbing !important;
    user-select: none !important;
}

html.theme-transitioning,
html.theme-transitioning body,
html.theme-transitioning * {
    transition: background-color .15s ease, color .15s ease, border-color .15s ease !important;
}

.spin { animation: spin .8s linear infinite; display: inline-block; }

@keyframes spin { to { transform: rotate(360deg); } }

#footer-easter-egg { cursor: pointer; user-select: none; justify-content: center; }

#footer-easter-egg:hover { color: var(--accent); }

@media (max-width: 767px) {
    .section-head .icon-btn,
    .experience-item .icon-btn,
    .skill-item .icon-btn { opacity: 1; }
}

@media (max-width: 800px) {
    .topbar { gap: 4px; padding: 8px 10px; }
    #tagline, .topbar-kicker { display: none; }
    .nav-label { display: none; }
}

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