:root {
    --bg: #f6f7fb;
    --surface: #ffffff;
    --input: #fbfbfe;
    --border: #e8e9f0;
    --input-border: #cfd2dc;
    --input-border-focus: #8b93a7;
    --text: #2a4559;
    --text-strong: #334352;
    --muted: #737b8b;
    --accent: #5a6acf;
    --accent-soft: #f0f2fb;
    --accent-btn: #d5daf3;
    --accent-btn-hover: #c4cbeb;
    --brand: #5a67ba;
    --danger: #f2383a;
    --ok: #32d16d;
    --ok-bg: #e8f9ef;
    --warn: #e8a317;
    --warn-bg: #fff6e5;
    --danger-bg: #fdecec;
    --radius: 5px;
    --radius-lg: 10px;
    --control-height: 42px;
    --fs: 1rem;
    --fs-sm: 0.875rem;
    --fs-lg: 1.5rem;
    --fs-xl: 1.75rem;
}

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

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    font-size: var(--fs);
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    letter-spacing: 0.02em;
    -webkit-font-smoothing: antialiased;
}

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

a:hover {
    text-decoration: underline;
}

h1 {
    margin: 0 0 0.6rem;
    font-size: var(--fs-lg);
    font-weight: 600;
    letter-spacing: -0.02em;
    line-height: 1.3;
    color: var(--text);
}

.site-wrap {
    width: min(800px, calc(100% - 2.5rem));
    margin-inline: auto;
}

.site-header {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.site-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    height: 64px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--brand);
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.06em;
}

.brand:hover {
    text-decoration: none;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 32px;
    flex-shrink: 0;
}

.brand-mark svg {
    display: block;
    width: 28px;
    height: 32px;
}

.site-nav {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
}

.site-nav a {
    color: var(--muted);
}

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

.site-nav .btn,
.site-nav .btn-ghost {
    color: var(--accent);
}

.dropdown {
    position: relative;
    min-width: 0;
}

.dropdown > summary {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    height: 42px;
    padding: 0 0.85rem 0 0.45rem;
    border-radius: 10px;
    list-style: none;
    cursor: pointer;
    color: var(--text);
    max-width: min(16rem, 100%);
}

.dropdown[open] > summary {
    background: var(--accent-soft);
}

.dropdown > summary::-webkit-details-marker,
.dropdown > summary::marker {
    display: none;
    content: "";
}

.dropdown-label {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropdown-caret {
    flex-shrink: 0;
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-top-color: var(--muted);
    transform: translateY(3px);
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: 0.875rem;
    font-weight: 500;
}

.dropdown-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 0.3rem);
    z-index: 10;
    min-width: max(100%, 14.5rem);
    padding: 0.35rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    white-space: nowrap;
}

.dropdown-menu a,
.dropdown-menu button {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.5rem 0.65rem;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--text-strong);
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.dropdown-menu svg {
    flex-shrink: 0;
}

.dropdown-menu a:hover,
.dropdown-menu a.is-active,
.dropdown-menu button:hover {
    background: var(--accent-soft);
    color: var(--accent);
    text-decoration: none;
}

.site-main {
    padding: 2.25rem 0 3.5rem;
}

.hero {
    padding-top: 2rem;
    text-align: center;
}

.hero-logo {
    display: block;
    width: 9.5rem;
    height: auto;
    margin: 0 auto 1.35rem;
}

.hero h1 {
    font-size: var(--fs-xl);
    font-weight: 600;
}

.lead {
    margin: 0 auto 1.5rem;
    color: var(--muted);
    font-size: var(--fs);
    line-height: 1.55;
    max-width: 38rem;
}

.hero-actions {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin: 0;
}

.muted {
    color: var(--muted);
    font-size: var(--fs);
}

.auth-form {
    max-width: 22rem;
    margin: 1.25rem auto 0;
    padding: 1.75rem 1.5rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.field {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 1rem;
    color: var(--muted);
    font-size: var(--fs-sm);
}

.field input,
.field select {
    box-sizing: border-box;
    padding: 0 0.85rem;
    height: var(--control-height);
    border: 1px solid var(--input-border);
    border-radius: 10px;
    background: var(--input);
    color: var(--text);
    font: inherit;
    font-size: var(--fs);
}

.field input::placeholder {
    color: var(--text);
    opacity: 0.3;
}

.field input:focus,
.field select:focus {
    outline: none;
    border-color: var(--input-border-focus);
}

.check-form {
    display: flex;
    align-items: flex-end;
    gap: 0.65rem;
    margin: 1.25rem 0 0;
}

.check-form .field {
    margin: 0;
}

.check-form .field-grow {
    flex: 1;
}

.check-form .btn {
    height: var(--control-height);
}

.check-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.55rem;
    margin: 1rem 0 0;
    color: var(--accent);
    font-size: var(--fs-sm);
}

.check-loader[hidden] {
    display: none;
}

.check-loader-bar {
    position: relative;
    width: min(100%, 14rem);
    height: 4px;
    overflow: hidden;
    border-radius: 99px;
    background: var(--accent-btn);
}

.check-loader-bar i {
    position: absolute;
    top: 0;
    left: 0;
    width: 40%;
    height: 100%;
    border-radius: 99px;
    background: var(--accent);
    animation: check-loader-slide 1.1s ease-in-out infinite;
}

@keyframes check-loader-slide {
    0% {
        left: -40%;
    }
    100% {
        left: 100%;
    }
}

.network-picker {
    position: relative;
}

.network-picker details {
    position: relative;
}

.network-picker summary {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 7.25rem;
    height: var(--control-height);
    padding: 0 1.85rem 0 0.65rem;
    border: 1px solid var(--input-border);
    border-radius: 10px;
    background: var(--input);
    color: var(--text);
    font: inherit;
    font-size: var(--fs);
    cursor: pointer;
    list-style: none;
}

.network-picker summary::-webkit-details-marker,
.network-picker summary::marker {
    display: none;
    content: "";
}

.network-picker summary::after {
    content: "";
    position: absolute;
    right: 0.7rem;
    width: 0;
    height: 0;
    border: 5px solid transparent;
    border-top-color: var(--muted);
    transform: translateY(3px);
}

.network-picker details[open] summary {
    border-color: var(--input-border-focus);
}

.network-icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.network-icon svg {
    display: block;
    width: 18px;
    height: 18px;
}

.network-picker-menu {
    position: absolute;
    left: 0;
    top: calc(100% + 0.35rem);
    z-index: 12;
    min-width: 100%;
    padding: 0.35rem;
    background: var(--surface);
    border: 1px solid var(--input-border);
    border-radius: 10px;
}

.network-picker-menu button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.45rem 0.55rem;
    border: 0;
    border-radius: var(--radius);
    background: none;
    color: var(--text-strong);
    font: inherit;
    font-size: var(--fs);
    text-align: left;
    white-space: nowrap;
    cursor: pointer;
}

.network-picker-menu button:hover,
.network-picker-menu button.is-active {
    background: var(--accent-soft);
    color: var(--accent);
}

.form-error {
    color: var(--danger);
    font-size: var(--fs-sm);
    margin: 0 0 1rem;
}

#check-error {
    margin: 1rem 0 0;
}

.form-error[hidden] {
    display: none;
}

#check-result {
    margin-top: 1.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--input-border);
}

#check-result:empty {
    display: none;
}

.page-footer {
    margin: 2rem 0 0;
    padding-top: 1.25rem;
    border-top: 1px solid var(--input-border);
}

.btn,
.btn-ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.65rem 1rem;
    height: var(--control-height);
    border: 0;
    border-radius: 10px;
    background: var(--accent-btn);
    color: var(--accent);
    font: inherit;
    font-size: var(--fs);
    font-weight: 500;
    letter-spacing: 0.04em;
    cursor: pointer;
}

.btn:hover,
.btn-ghost:hover {
    text-decoration: none;
    background: var(--accent-btn-hover);
}

.btn:active,
.btn-ghost:active {
    background: #b7c0e6;
}

.btn:focus-visible,
.btn-ghost:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.btn:disabled {
    opacity: 0.55;
    cursor: default;
}

.auth-form .btn {
    width: 100%;
}

.auth-switch {
    margin: 1.1rem 0 0;
    color: var(--muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.65rem;
    border-radius: 999px;
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--muted);
}

.status-pill--low {
    background: var(--ok-bg);
    color: var(--ok);
}

.status-pill--medium {
    background: var(--warn-bg);
    color: var(--warn);
}

.status-pill--high {
    background: var(--danger-bg);
    color: var(--danger);
}

.score-meter {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-rows: auto auto;
    column-gap: 0.75rem;
    align-items: center;
    min-width: 0;
}

.score-meter > .status-pill {
    grid-row: 1;
}

.score-scale-wrap {
    display: grid;
    grid-template-rows: subgrid;
    grid-row: 1 / span 2;
    align-items: center;
    min-width: 7.5rem;
}

.score-scale {
    position: relative;
    height: 8px;
    margin-inline: 0.45rem;
    border-radius: 99px;
    background: linear-gradient(
        to right,
        var(--ok) 0 var(--zone-mid),
        var(--warn) var(--zone-mid) var(--zone-high),
        var(--danger) var(--zone-high) 100%
    );
}

.score-scale--low {
    --knob: var(--ok);
}

.score-scale--medium {
    --knob: var(--warn);
}

.score-scale--high {
    --knob: var(--danger);
}

.score-scale-knob {
    position: absolute;
    top: 50%;
    left: var(--score);
    width: 14px;
    height: 14px;
    border: 2px solid var(--knob, var(--muted));
    border-radius: 50%;
    background: var(--surface);
    transform: translate(-50%, -50%);
}

.score-scale-labels {
    display: grid;
    grid-template-columns: var(--zone-mid) calc(var(--zone-high) - var(--zone-mid)) 1fr;
    margin: 0 0.45rem 0;
    color: var(--muted);
    font-size: 0.75rem;
}

.score-scale-labels span:nth-child(2) {
    text-align: center;
}

.score-scale-labels span:nth-child(3) {
    text-align: right;
}

.result-card .score-meter {
    width: 100%;
}

.result-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.15rem 1.25rem;
}

.result-fields {
    display: flex;
    flex-direction: column;
    margin: 1rem 0 0;
}

.result-fields > div {
    display: grid;
    grid-template-columns: 10.5rem 1fr;
    align-items: center;
    column-gap: 1rem;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border);
}

.result-fields > div:last-child {
    border-bottom: 0;
}

.result-fields dt,
.result-fields dd {
    margin: 0;
    padding: 0;
    line-height: 1.4;
}

.result-fields dt {
    color: var(--muted);
    font-size: var(--fs-sm);
}

.result-fields dd {
    color: var(--text-strong);
    font-size: var(--fs);
}

.history-list {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}

.history-item {
    border-bottom: 1px solid var(--border);
}

.history-item:last-child {
    border-bottom: 0;
}

.history-item > summary {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.9rem 1.1rem;
    cursor: pointer;
    list-style: none;
}

.history-item > summary::before {
    content: "";
    width: 0.35rem;
    height: 0.35rem;
    flex-shrink: 0;
    border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted);
    transform: rotate(-45deg);
}

.history-item[open] > summary::before {
    transform: rotate(45deg);
}

.history-item > summary .status-pill {
    margin-left: auto;
    flex-shrink: 0;
}

.history-item > summary::-webkit-details-marker {
    display: none;
}

.history-address {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
    font-size: var(--fs);
}

.history-network {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.history-network,
.history-item time {
    color: var(--muted);
    font-size: var(--fs-sm);
}

.history-item .result-card {
    margin: 0 1.1rem 1.15rem;
}

@media (max-width: 768px) {
    .site-header,
    .site-header-inner {
        height: auto;
        min-height: 64px;
    }

    .site-header-inner {
        padding: 0.7rem 0;
    }

    .dropdown > summary {
        max-width: min(14rem, calc(100vw - 8rem));
    }

    .hero {
        padding-top: 0.5rem;
    }

    .check-form {
        flex-direction: column;
        align-items: stretch;
    }

    .check-form .btn {
        width: 100%;
    }

    .network-picker summary {
        min-width: 0;
        width: 100%;
    }

    .result-fields > div {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }

    .history-item > summary {
        flex-wrap: wrap;
    }

    .history-address {
        flex-basis: calc(100% - 1.25rem);
    }

    .history-item > summary .status-pill {
        margin-left: auto;
    }
}
