:root {
    --bg: #ffffff;
    --page-surface: #f4f3f0;
    --panel: rgba(255, 255, 255, 0.96);
    --panel-strong: #ffffff;
    --text: #1c1917;
    --muted: #57534e;
    --muted-soft: #78716c;
    --line: #e7e5e4;
    --line-strong: #d6d3d1;
    --accent: #9a3412;
    --success: #1f6b4f;
    --success-soft: #e5f1ea;
    --success-line: #8eb7a0;
    --graph-node: #fcfcfb;
    --graph-node-stroke: #a8a29e;
    --graph-edge: #a8a29e;
    --shadow-card: 0 24px 60px rgba(28, 25, 23, 0.08);
    --shadow-soft: 0 12px 32px rgba(28, 25, 23, 0.05);
}

* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font: 16px/1.7 "IBM Plex Sans", sans-serif;
}

#celebration-layer {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 40;
}

.page-shell {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 44px 18px 72px;
}

.page {
    flex: 1 0 auto;
    width: min(100%, 920px);
    margin: 0 auto;
    padding: clamp(24px, 4vw, 44px);
    /* Outer shell box styling disabled to keep a plain white page background.
    border: 1px solid var(--line);
    border-radius: 32px;
    background: var(--page-surface);
    box-shadow: var(--shadow-card);
    */
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
}

.hero {
    max-width: 720px;
    margin: 0 auto 34px;
    text-align: center;
}

.eyebrow {
    margin: 0 0 14px;
    color: var(--accent);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    text-transform: none;
}

h1 {
    margin: 0 auto;
    max-width: 13ch;
    font-size: clamp(2.45rem, 6.5vw, 4.1rem);
    line-height: 1.02;
    letter-spacing: -0.055em;
}

h2 {
    margin: 0 0 20px;
    font-size: 1.08rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    text-align: left;
}

#stats,
.muted {
    color: var(--muted);
}

#stats {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.3rem;
    width: fit-content;
    max-width: 100%;
    margin: 20px auto 0;
    padding: 10px 16px;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.86);
    box-shadow: 0 8px 22px rgba(28, 25, 23, 0.04);
    font-size: 1rem;
}

.stat-chunk {
    display: inline-flex;
    align-items: baseline;
    gap: 0.35rem;
}

.stat-label {
    color: var(--muted-soft);
}

.stat-divider {
    margin: 0 0.55rem;
    color: var(--line-strong);
}

.panel {
    margin-top: 24px;
    padding: clamp(20px, 3vw, 28px);
    border: 1px solid var(--line);
    border-radius: 24px;
    background: var(--panel);
    box-shadow: var(--shadow-soft);
}

.search-form {
    display: grid;
    gap: 18px;
}

.field-grid {
    display: grid;
    gap: 18px;
}

.field {
    display: grid;
    gap: 10px;
}

.field span {
    color: var(--muted);
    font-size: 0.94rem;
    font-weight: 600;
}

input {
    width: 100%;
    min-width: 0;
    border: 1.5px solid var(--line-strong);
    border-radius: 14px;
    padding: 15px 16px;
    background: var(--panel-strong);
    color: var(--text);
    font: inherit;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

input::placeholder {
    color: #a8a29e;
}

input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(154, 52, 18, 0.08);
}

.actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
}

button {
    appearance: none;
    border: 1.5px solid var(--text);
    border-radius: 999px;
    padding: 12px 20px;
    background: var(--panel-strong);
    color: var(--text);
    cursor: pointer;
    font: inherit;
    font-weight: 500;
    transition: background-color 0.18s ease, color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}

button:not(.secondary) {
    background: var(--text);
    color: #ffffff;
    box-shadow: 0 10px 24px rgba(28, 25, 23, 0.12);
}

button:hover {
    transform: translateY(-1px);
    background: #292524;
    color: #ffffff;
}

button.secondary:hover {
    background: #f5f5f4;
    color: var(--text);
}

#status {
    flex: 1 1 220px;
    min-height: 1.5em;
    font-size: 0.92rem;
    text-align: left;
}

#text {
    margin: 0;
    min-height: 64px;
    padding: 0;
    border: 0;
    background: none;
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-word;
    overflow-wrap: anywhere;
    font: 500 1rem/1.9 "IBM Plex Sans", sans-serif;
}

#text:empty {
    display: none;
}

#text strong {
    color: var(--accent);
}

#text .result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-weight: 400;
}

#text .result-meta span:first-child {
    color: var(--text);
    font-weight: 500;
}

#viz-wrap {
    margin-top: 22px;
    padding: 18px 18px 8px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: #fafaf9;
}

svg {
    display: block;
    width: 100%;
    height: 280px;
    overflow: visible;
}

.node {
    fill: var(--graph-node);
    stroke: var(--graph-node-stroke);
    stroke-width: 2.2;
}

.edge {
    stroke: var(--graph-edge);
    stroke-width: 2.5;
}

.label {
    fill: var(--text);
    font-size: 15px;
    font-weight: 500;
    dominant-baseline: hanging;
    text-anchor: middle;
    pointer-events: none;
}

.lb-list {
    display: grid;
    gap: 12px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.lb-item {
    display: grid;
    grid-template-columns: 2rem 1fr;
    gap: 12px;
    align-items: start;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #ffffff;
    box-shadow: 0 8px 22px rgba(28, 25, 23, 0.04);
    transition: background-color 0.25s ease, transform 0.25s ease;
}

.lb-item-hit {
    animation: lb-item-hit 1400ms ease;
    border-color: var(--success);
    background: var(--success);
    box-shadow: 0 12px 28px rgba(31, 107, 79, 0.24);
    color: #ffffff;
}

.lb-item-hit .lb-rank,
.lb-item-hit .lb-length,
.lb-item-hit .lb-arrow {
    color: #ffffff;
}

.lb-item-hit .lb-arrow {
    opacity: 0.9;
}

.lb-rank {
    color: var(--muted-soft);
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.6;
}

.lb-body {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.lb-length {
    color: var(--muted-soft);
    font-size: 0.84rem;
    font-weight: 500;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.lb-route {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    line-height: 1.6;
}

.lb-arrow {
    color: var(--accent);
    opacity: 0.7;
}

.tech-drawer {
    position: fixed;
    top: 16px;
    right: 18px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    z-index: 30;
}

.tech-toggle {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 8px 22px rgba(28, 25, 23, 0.06);
    cursor: pointer;
    color: var(--muted-soft);
    line-height: 0;
    list-style: none;
    user-select: none;
}

.tech-toggle::marker {
    content: "";
}

.tech-toggle::-webkit-details-marker {
    display: none;
}

.tech-toggle:hover {
    color: var(--text);
}

.tech-toggle svg {
    width: 18px;
    height: 18px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 2.2;
    transition: transform 0.18s ease;
}

.tech-drawer[open] .tech-toggle svg {
    transform: rotate(180deg);
}

.tech-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    margin-top: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: var(--shadow-soft);
    text-align: center;
}

.tech-panel-label {
    color: var(--muted-soft);
    font-size: 0.78rem;
    font-weight: 500;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.tech-grid {
    display: grid;
    grid-template-columns: repeat(2, 44px);
    gap: 12px;
    justify-content: center;
}

.tech-credit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 4px;
}

.tech-credit-label {
    color: var(--muted-soft);
    font-size: 0.84rem;
}

.tech-credit-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.84rem;
    transition: transform 0.18s ease, color 0.18s ease, opacity 0.18s ease;
}

.tech-credit-link:hover {
    color: var(--accent);
    transform: translateY(-1px);
}

.tech-credit-link svg {
    width: 16px;
    height: 16px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.6;
}

.tech-credit-link span {
    letter-spacing: -0.01em;
}

.tech-badge {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1.5px solid var(--line-strong);
    border-radius: 999px;
    background: #fcfcfb;
    color: var(--text);
    opacity: 0.92;
    transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.tech-badge::after {
    content: attr(title);
    position: absolute;
    top: 50%;
    right: calc(100% + 10px);
    transform: translateY(-50%);
    padding: 6px 9px;
    border: 1px solid var(--line-strong);
    background: #ffffff;
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    box-shadow: 0 4px 14px rgba(17, 17, 17, 0.06);
    transition: opacity 0.14s ease, transform 0.14s ease;
}

.tech-badge:hover {
    transform: translateY(-1px);
    border-color: var(--text);
    background: #f7f7f6;
}

.tech-badge:hover::after {
    opacity: 1;
    transform: translateY(-50%) translateX(-2px);
}

.tech-badge svg {
    width: 21px;
    height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-linecap: round;
    stroke-linejoin: round;
    stroke-width: 1.7;
}

.tech-python svg path:first-of-type,
.tech-python svg circle:first-of-type {
    fill: #111111;
    stroke: #111111;
}

.tech-python svg path:last-of-type,
.tech-python svg circle:last-of-type {
    fill: #9ca3af;
    stroke: #9ca3af;
}

.tech-fastapi svg {
    fill: var(--accent);
    stroke: none;
}

.tech-frontend svg rect {
    fill: #ffffff;
    stroke: currentColor;
}

.tech-d3 svg circle {
    fill: currentColor;
    stroke: none;
}

.leaderboard-hit h2 {
    animation: leaderboard-hit 900ms ease;
}

.leaderboard-hit .lb-item-hit .lb-length,
.leaderboard-hit .lb-item-hit .lb-arrow,
.leaderboard-hit .lb-item-hit .lb-rank {
    color: #ffffff;
}

.confetti-piece {
    position: fixed;
    top: -10vh;
    width: var(--confetti-size);
    height: calc(var(--confetti-size) * 1.4);
    background: var(--confetti-color);
    box-shadow: 0 0 0 1px rgba(17, 17, 17, 0.06);
    opacity: 0;
    transform: translate3d(0, -10vh, 0) rotate(var(--confetti-spin-start));
    animation-name: confetti-fall;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

.confetti-piece[data-shape="circle"] {
    border-radius: 999px;
}

.confetti-piece[data-shape="square"] {
    border-radius: 2px;
}

@keyframes confetti-fall {
    0% {
        opacity: 0;
        transform: translate3d(0, -10vh, 0) rotate(var(--confetti-spin-start));
    }

    10% {
        opacity: 1;
    }

    100% {
        opacity: 0;
        transform: translate3d(var(--confetti-drift), 112vh, 0) rotate(var(--confetti-spin-end));
    }
}

@keyframes leaderboard-hit {
    0% {
        color: var(--text);
        transform: translateY(0);
    }

    35% {
        color: var(--success);
        transform: translateY(-1px);
    }

    100% {
        color: var(--text);
        transform: translateY(0);
    }
}

@keyframes lb-item-hit {
    0% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(6px);
    }

    70% {
        background: var(--success-soft);
    }

    100% {
        transform: translateX(0);
        background: transparent;
    }
}

::selection {
    background: rgba(154, 52, 18, 0.12);
    color: var(--text);
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #ffffff;
}

::-webkit-scrollbar-thumb {
    background: #cfcfcf;
}

::-webkit-scrollbar-thumb:hover {
    background: #b7b7b7;
}

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

    svg {
        height: 320px;
    }
}

@media (max-width: 640px) {
    .page-shell {
        padding: 30px 14px 56px;
    }

    .page {
        padding: 22px 16px;
        /* border-radius: 24px; */
        border-radius: 0;
    }

    .tech-drawer {
        top: 10px;
        right: 12px;
    }

    h1 {
        max-width: 11ch;
    }

    #stats {
        display: flex;
        width: 100%;
        border-radius: 18px;
    }

    .panel {
        padding: 18px;
        border-radius: 20px;
    }

    .actions {
        align-items: stretch;
    }

    .actions button {
        flex: 1 1 180px;
    }

    svg {
        height: 300px;
    }

    .label {
        font-size: 10px;
    }
}
