:root {
    --bg: #f1f7ff;
    --panel: #ffffff;
    --ink: #15202b;
    --muted: #566575;
    --line: #d8e5f2;
    --accent: #007a78;
    --accent-deep: #00545b;
    --ok: #1b8d60;
    --warn: #c98a00;
    --danger: #c5323f;
    --mono: "IBM Plex Mono", monospace;
    --display: "Space Grotesk", sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--display);
    color: var(--ink);
    line-height: 1.5;
    background: radial-gradient(circle at 15% 20%, #daf3f0 0%, transparent 36%),
        radial-gradient(circle at 82% 8%, #dbe8fb 0%, transparent 45%),
        linear-gradient(180deg, #f4f9ff 0%, #e7f0f9 100%);
    min-height: 100vh;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 25;
    backdrop-filter: blur(10px);
    background: color-mix(in srgb, #f4f9ff 84%, #ffffff 16%);
    border-bottom: 1px solid var(--line);
}

.nav {
    width: min(1200px, 94vw);
    margin: 0 auto;
    min-height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.brand {
    font-weight: 700;
    letter-spacing: 0.02em;
}

.menu {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
}

.menu a {
    color: #0b5878;
    text-decoration: none;
    white-space: nowrap;
    min-height: 40px;
    display: inline-flex;
    align-items: center;
}

.bg-glow {
    position: fixed;
    width: 35vw;
    height: 35vw;
    border-radius: 999px;
    filter: blur(80px);
    pointer-events: none;
    opacity: 0.35;
}

.bg-glow-1 {
    top: -10vw;
    left: -6vw;
    background: #68d1c8;
}

.bg-glow-2 {
    right: -10vw;
    bottom: -10vw;
    background: #8eb5f6;
}

.app-shell {
    width: min(1200px, 94vw);
    margin: 28px auto 48px;
    position: relative;
    z-index: 1;
    animation: rise-in 520ms ease-out;
}

.hero h1 {
    margin: 0;
    font-size: clamp(1.8rem, 5vw, 2.6rem);
    letter-spacing: 0.02em;
}

.hero p {
    margin: 8px 0 24px;
    color: var(--muted);
}

.control-panel,
.panel,
.summary-card {
    background: color-mix(in srgb, var(--panel) 88%, #ffffff 12%);
    border: 1px solid color-mix(in srgb, var(--line) 80%, #0000 20%);
    border-radius: 18px;
    padding: 16px;
    box-shadow: 0 8px 25px rgba(111, 83, 56, 0.1);
}

.control-panel {
    display: grid;
    gap: 12px;
}

.field-grid {
    display: grid;
    gap: 12px;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
}

.field-row {
    display: grid;
    gap: 6px;
}

label {
    font-size: 0.9rem;
    color: var(--muted);
}

input,
select,
button {
    font: inherit;
}

input,
select {
    border-radius: 12px;
    border: 1px solid #bfd3e8;
    padding: 10px 12px;
    min-height: 44px;
    background: #fbfdff;
}

.button-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    border-radius: 999px;
    padding: 9px 14px;
    min-height: 44px;
    border: 1px solid #9fc0df;
    background: #f3f9ff;
    cursor: pointer;
    transition: transform 140ms ease, box-shadow 140ms ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 7px 16px rgba(30, 67, 104, 0.14);
}

.btn.primary {
    background: linear-gradient(135deg, #007a78, #005f6e);
    border-color: #00505d;
    color: #fff;
}

.btn.ghost {
    background: #ebf5ff;
}

.summary-card {
    margin-top: 14px;
    display: grid;
    grid-template-columns: repeat(4, minmax(100px, 1fr));
    gap: 10px;
}

.summary-item {
    border-radius: 12px;
    border: 1px dashed var(--line);
    padding: 10px;
}

.summary-item b {
    display: block;
    font-size: 0.84rem;
    color: var(--muted);
    margin-bottom: 4px;
}

.grid-two {
    display: grid;
    gap: 14px;
    margin-top: 14px;
    grid-template-columns: 2fr 1fr;
}

.panel h2 {
    margin-top: 0;
    font-size: 1.1rem;
}

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

.waterfall-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin: 6px 0 12px;
}

.waterfall-filters label {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    font-size: 0.86rem;
    color: #445867;
    border: 1px solid #d2e1f0;
    border-radius: 999px;
    padding: 6px 10px;
    background: #f8fcff;
}

.waterfall-filters .btn {
    min-height: 34px;
    padding: 6px 12px;
}

.hop-card {
    border: 1px solid #d2e1f0;
    border-radius: 12px;
    padding: 10px;
    background: #fcfeff;
    animation: float-in 300ms ease both;
}

.hop-head {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.hop-index {
    font-family: var(--mono);
    font-weight: 600;
    color: var(--accent-deep);
}

.hop-status {
    font-family: var(--mono);
    background: #e7f4f8;
    border: 1px solid #b7d9df;
    border-radius: 999px;
    padding: 2px 8px;
}

.hop-status.status-ok {
    background: #e9f8ef;
    border-color: #a9debf;
    color: #176444;
}

.hop-status.status-warn {
    background: #fff7e5;
    border-color: #f0d6a1;
    color: #8f6200;
}

.hop-status.status-danger {
    background: #fdecee;
    border-color: #efb5bc;
    color: #a02936;
}

.hop-status.status-neutral {
    color: #285a66;
}

.hop-time {
    margin-left: auto;
    font-family: var(--mono);
    font-weight: 600;
}

.hop-url {
    margin-top: 8px;
    font-family: var(--mono);
    font-size: 0.84rem;
    word-break: break-all;
}

.hop-details {
    margin-top: 8px;
    color: #465157;
    font-size: 0.86rem;
    line-height: 1.5;
    word-break: break-word;
}

.latency-ok {
    color: var(--ok);
}

.latency-warn {
    color: var(--warn);
}

.latency-danger {
    color: var(--danger);
}

.stack-list {
    display: grid;
    gap: 8px;
    max-height: 330px;
    overflow: auto;
}

.stack-item {
    border: 1px solid #d2e1f0;
    border-radius: 10px;
    padding: 8px;
    background: #fcfeff;
    font-size: 0.9rem;
}

.history-item {
    display: grid;
    gap: 8px;
}

.history-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.history-actions .btn {
    min-height: 34px;
    padding: 6px 12px;
}

.param-parser {
    display: grid;
    gap: 10px;
}

.param-group {
    border: 1px solid #d2e1f0;
    border-radius: 10px;
    padding: 8px;
}

.param-group h3 {
    margin: 0 0 8px;
    font-size: 0.92rem;
}

.kv {
    font-family: var(--mono);
    font-size: 0.82rem;
    color: #394248;
    word-break: break-word;
}

.source-dialog {
    width: min(1000px, 95vw);
    border: 1px solid #bfd2e6;
    border-radius: 14px;
    padding: 12px;
}

.source-dialog::backdrop {
    background: rgba(18, 28, 32, 0.6);
}

.source-dialog pre {
    max-height: 62vh;
    overflow: auto;
    white-space: pre-wrap;
    background: #f7fbff;
    border: 1px solid #d5e5f3;
    border-radius: 10px;
    padding: 12px;
    font-size: 0.8rem;
    font-family: var(--mono);
}

.hidden {
    display: none;
}

.site-footer {
    width: min(1200px, 94vw);
    margin: 0 auto 34px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: #f8fbff;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.legal-links {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
    order: 3;
}

.legal-links a {
    color: #0b5878;
    text-decoration: none;
    font-size: 0.94rem;
}

.legal-note {
    color: var(--muted);
    font-size: 0.86rem;
    order: 2;
}

.ad-slot {
    min-height: 110px;
    border: 1px dashed #a8c1db;
    border-radius: 12px;
    background: linear-gradient(180deg, #fdfefe, #f3f8ff);
    display: grid;
    place-items: center;
    color: #4f6070;
    font-size: 0.9rem;
    text-align: center;
    padding: 18px;
    margin: 8px 0;
    order: 1;
}

@keyframes rise-in {
    from {
        transform: translateY(8px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes float-in {
    from {
        transform: translateX(-8px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@media (max-width: 900px) {
    .nav {
        align-items: flex-start;
        flex-direction: column;
        padding: 10px 0;
    }

    .menu {
        width: 100%;
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap;
        padding-bottom: 4px;
    }

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

    .field-grid {
        grid-template-columns: 1fr;
    }

    .summary-card {
        grid-template-columns: repeat(2, minmax(100px, 1fr));
    }
}

@media (max-width: 640px) {

    .app-shell,
    .site-footer,
    .nav {
        width: 92vw;
    }

    .app-shell {
        margin: 18px auto 30px;
    }

    .control-panel,
    .panel,
    .summary-card {
        padding: 12px;
        border-radius: 14px;
    }

    .button-row .btn {
        flex: 1 1 100%;
    }

    .summary-card {
        grid-template-columns: 1fr;
    }

    .summary-item {
        padding: 9px;
    }

    .hop-card {
        margin-left: 0 !important;
    }

    .hop-head {
        align-items: flex-start;
        flex-direction: column;
        gap: 4px;
    }

    .hop-time {
        margin-left: 0;
    }

    .stack-list {
        max-height: none;
        overflow: visible;
    }

    .panel h2 {
        font-size: 1rem;
    }

    .waterfall-filters {
        align-items: stretch;
    }

    .waterfall-filters label,
    .waterfall-filters .btn {
        width: 100%;
    }

    .hop-url,
    .kv {
        font-size: 0.78rem;
    }

    .ad-slot {
        min-height: 90px;
        font-size: 0.84rem;
    }
}