:root {
    --page-bg: #eaf4f6;
    --card-bg: #ffffff;
    --card-border: #d7e5eb;
    --text-main: #223040;
    --text-soft: #728394;
    --text-blue: #2d5b90;
    --blue: #4f83bd;
    --blue-dark: #3d6fa8;
    --green: #1f9f69;
    --green-soft: #eefaf5;
    --icon-green: #59b704;
    --icon-green-dark: #1c9200;
    --icon-green-shadow: rgba(28, 146, 0, 0.28);
    --orange: #f8a81b;
    --orange-dark: #ee8d07;
    --line-bg: #f7fbfd;
    --shadow-card: 0 28px 76px rgba(72, 102, 118, 0.18);
    --shadow-soft: 0 16px 34px rgba(57, 101, 139, 0.16);
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    height: 100svh;
    font-family: "Segoe UI", "PingFang SC", "Microsoft YaHei",
        "Noto Sans SC", Arial, sans-serif;
    color: var(--text-main);
    background:
        radial-gradient(
            circle at 50% 20%,
            rgba(255, 255, 255, 0.96) 0,
            rgba(255, 255, 255, 0.42) 230px,
            transparent 460px
        ),
        linear-gradient(180deg, #eaf4f6 0%, #edf6f7 100%);
}

button {
    font: inherit;
}

.page {
    height: 100svh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: clamp(10px, 2vh, 24px);
    overflow: hidden;
}

.access-card {
    width: min(100%, 660px);
    max-height: calc(100svh - 20px);
    padding: clamp(18px, 3vh, 28px) clamp(24px, 4vw, 40px);
    border: 1px solid var(--card-border);
    border-radius: 24px;
    background: linear-gradient(180deg, #ffffff 0%, #fbfefe 100%);
    box-shadow: var(--shadow-card);
    overflow-y: auto;
    scrollbar-width: none;
}

.access-card::-webkit-scrollbar {
    width: 0;
    height: 0;
}

.scan-panel {
    display: grid;
    justify-items: center;
    gap: clamp(10px, 1.6vh, 14px);
    margin-bottom: clamp(12px, 2vh, 18px);
    text-align: center;
}

.scanner {
    position: relative;
    width: clamp(112px, 18vh, 138px);
    height: clamp(112px, 18vh, 138px);
    display: grid;
    place-items: center;
    border-radius: 50%;
}

.scanner::before,
.scanner::after {
    content: "";
    position: absolute;
    inset: 12px;
    border-radius: inherit;
    background: rgba(79, 131, 189, 0.14);
    animation: scan-pulse 1.4s ease-out infinite;
}

.scanner::after {
    animation-delay: 0.45s;
}

.scan-ring {
    position: absolute;
    inset: 7px;
    border-radius: 50%;
    background:
        conic-gradient(
            from 0deg,
            rgba(79, 131, 189, 0.05),
            rgba(79, 131, 189, 0.92),
            rgba(31, 159, 105, 0.78),
            rgba(79, 131, 189, 0.05)
        );
    animation: scan-spin 1.1s linear infinite;
    box-shadow: 0 18px 42px rgba(58, 103, 144, 0.16);
}

.scan-ring::after {
    content: "";
    position: absolute;
    inset: 8px;
    border-radius: inherit;
    background: #fff;
}

.scan-sweep {
    position: absolute;
    width: 68px;
    height: 2px;
    left: 50%;
    top: 50%;
    transform-origin: left center;
    border-radius: 999px;
    background: linear-gradient(
        90deg,
        rgba(79, 131, 189, 0.92),
        transparent
    );
    animation: scan-spin 1.1s linear infinite;
    z-index: 2;
}

.security-badge {
    position: relative;
    z-index: 3;
    width: 72%;
    height: 72%;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #fff;
    box-shadow:
        0 18px 36px rgba(68, 94, 112, 0.15),
        inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.shield-shape {
    width: 68%;
    height: 68%;
    display: block;
}

.scan-title {
    margin: 0;
    color: var(--text-main);
    font-size: clamp(23px, 3.6vh, 28px);
    line-height: 1.2;
    font-weight: 850;
    letter-spacing: 0;
}

.scan-subtitle {
    margin: 0;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.45;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    min-height: 34px;
    padding: 7px 14px;
    border: 1px solid #dce9ef;
    border-radius: 999px;
    color: var(--text-blue);
    background: #f7fbfd;
    font-size: 16px;
    line-height: 1.25;
    font-weight: 800;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--blue);
    box-shadow: 0 0 0 7px rgba(79, 131, 189, 0.12);
    animation: dot-breathe 1s ease-in-out infinite;
}

.url-panel {
    margin: 0 0 clamp(12px, 2vh, 18px);
    padding: 10px 14px;
    border: 1px solid #dbe8ef;
    border-radius: 16px;
    background: #f8fbfd;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.url-label {
    margin: 0 0 5px;
    color: var(--text-soft);
    font-size: 14px;
    line-height: 1.4;
    font-weight: 800;
}

.url-value {
    min-height: 23px;
    display: block;
    color: var(--text-blue);
    font-size: 16px;
    line-height: 1.45;
    font-weight: 850;
    overflow-wrap: anywhere;
}

.section-block {
    border: 1px solid #dbe8ef;
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.9);
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.78);
}

.section-block + .section-block {
    margin-top: 10px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 44px;
    padding: 10px 14px;
    border-bottom: 1px solid #dbe8ef;
    background: linear-gradient(180deg, #f8fbfd 0%, #f2f8fb 100%);
}

.section-title {
    margin: 0;
    color: var(--text-main);
    font-size: 15px;
    line-height: 1.35;
    font-weight: 850;
}

.section-meta {
    color: #9aa7ba;
    font-size: 12px;
    line-height: 1.2;
    font-weight: 850;
    letter-spacing: 0.08em;
}

.route-list {
    display: grid;
    gap: 9px;
    padding: 10px 12px 12px;
}

.route-card {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) 46px;
    align-items: center;
    gap: 12px;
    min-height: 58px;
    padding: 8px 10px;
    border: 1px solid #dce9f0;
    border-radius: 18px;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(247, 251, 253, 0.94)),
        var(--line-bg);
    box-shadow: 0 12px 26px rgba(60, 92, 116, 0.08);
}

.signal-badge,
.copy-badge {
    position: relative;
    width: 44px;
    height: 44px;
    display: grid;
    place-items: center;
    border: 0;
    border-radius: 17px;
    color: #fff;
    background: linear-gradient(
        145deg,
        var(--icon-green) 0%,
        var(--icon-green-dark) 100%
    );
    box-shadow:
        0 12px 22px var(--icon-green-shadow),
        inset 0 1px 1px rgba(255, 255, 255, 0.28);
}

.signal-bars {
    height: 21px;
    display: inline-flex;
    align-items: flex-end;
    gap: 4px;
}

.signal-bars span {
    width: 6px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.28);
}

.signal-bars span:nth-child(1) {
    height: 10px;
}

.signal-bars span:nth-child(2) {
    height: 17px;
}

.signal-bars span:nth-child(3) {
    height: 24px;
}

.route-kicker {
    margin: 0 0 3px;
    color: var(--text-soft);
    font-size: 13px;
    line-height: 1.25;
    font-weight: 850;
}

.route-title {
    margin: 0;
    color: var(--text-main);
    font-size: 17px;
    line-height: 1.22;
    font-weight: 850;
    letter-spacing: 0;
}

.route-status {
    width: fit-content;
    margin: 5px 0 0;
    padding: 3px 9px;
    border-radius: 999px;
    color: #16714e;
    background: var(--green-soft);
    font-size: 13px;
    line-height: 1.2;
    font-weight: 850;
}

body.is-scanning .route-status {
    color: #346b93;
    background: rgba(82, 153, 213, 0.14);
}

body.is-error .route-status {
    color: #a34b3d;
    background: rgba(236, 113, 91, 0.14);
}

.copy-badge {
    cursor: pointer;
    transition:
        transform 0.18s ease,
        filter 0.18s ease,
        box-shadow 0.18s ease;
}

.copy-badge::before,
.copy-badge::after {
    content: "";
    position: absolute;
    left: 50%;
    top: 50%;
    width: 38%;
    height: 44%;
    border: 2px solid currentColor;
    border-radius: 18%;
    box-sizing: border-box;
}

.copy-badge::before {
    opacity: 0.78;
    transform: translate(-62%, -34%);
}

.copy-badge::after {
    background: rgba(255, 255, 255, 0.08);
    transform: translate(-34%, -62%);
}

.copy-badge:hover {
    transform: translateY(-1px);
    filter: saturate(1.08);
    box-shadow:
        0 15px 26px var(--icon-green-shadow),
        inset 0 1px 1px rgba(255, 255, 255, 0.32);
}

.actions {
    display: grid;
    gap: 10px;
    padding: 10px 12px 12px;
}

.action-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}

.action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  text-decoration: none;
    width: 100%;
    min-height: 50px;
    border: 0;
    border-radius: 12px;
    color: #ffffff;
    background: linear-gradient(
        180deg,
        var(--icon-green) 0%,
        var(--icon-green-dark) 100%
    );
    box-shadow: 0 16px 34px var(--icon-green-shadow);
    cursor: pointer;
    font-size: 19px;
    line-height: 1.2;
    font-weight: 850;
    letter-spacing: 0;
    text-shadow: 0 1px 1px rgba(12, 68, 0, 0.42);
    transition:
        transform 0.18s ease,
        filter 0.18s ease,
        box-shadow 0.18s ease,
        opacity 0.18s ease;
}

.action-button.secondary {
    min-height: 46px;
    font-size: 18px;
}

.copy-badge:focus-visible,
.action-button:focus-visible {
    outline: 3px solid rgba(89, 183, 4, 0.34);
    outline-offset: 3px;
}

.action-button:hover {
    transform: translateY(-1px);
    filter: saturate(1.05);
    box-shadow: 0 18px 34px var(--icon-green-shadow);
}

.copy-badge:disabled,
.action-button:disabled,
.action-button[aria-disabled="true"] {
    cursor: not-allowed;
    opacity: 0.48;
    transform: none;
    filter: grayscale(0.1);
}

.copy-badge:disabled {
    opacity: 0.82;
}

.action-button:disabled {
    opacity: 0.68;
}

.brand-footer {
    margin-top: clamp(14px, 2.2vh, 22px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-logo {
    width: 135px;
    height: 44px;
    max-width: 100%;
    display: block;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 32px;
    z-index: 20;
    min-width: 220px;
    max-width: calc(100vw - 32px);
    padding: 12px 18px;
    border-radius: 999px;
    color: #fff;
    background: rgba(38, 50, 63, 0.92);
    box-shadow: 0 16px 36px rgba(34, 44, 54, 0.22);
    text-align: center;
    font-size: 15px;
    line-height: 1.45;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 12px);
}

.toast.is-visible {
    animation: toast-show 2.4s ease both;
}

.is-ready .scanner::before,
.is-ready .scanner::after,
.is-ready .scan-ring,
.is-ready .scan-sweep,
.is-error .scanner::before,
.is-error .scanner::after,
.is-error .scan-ring,
.is-error .scan-sweep {
    animation-play-state: paused;
}

.is-ready .scan-sweep,
.is-error .scan-sweep {
    opacity: 0;
}

.is-ready .status-badge {
    color: #16714e;
    border-color: #d8eee4;
    background: var(--green-soft);
}

.is-ready .status-dot {
    background: var(--green);
    box-shadow: 0 0 0 7px rgba(31, 159, 105, 0.13);
    animation: none;
}

.is-error .status-badge {
    color: #9a4b36;
    border-color: #f1d9ce;
    background: #fff5f0;
}

.is-error .status-dot {
    background: #d36d43;
    box-shadow: 0 0 0 7px rgba(211, 109, 67, 0.14);
    animation: none;
}

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

@keyframes scan-pulse {
    0% {
        opacity: 0.58;
        transform: scale(0.84);
    }
    100% {
        opacity: 0;
        transform: scale(1.34);
    }
}

@keyframes dot-breathe {
    0%,
    100% {
        opacity: 0.58;
        transform: scale(0.92);
    }
    50% {
        opacity: 1;
        transform: scale(1.05);
    }
}

@keyframes toast-show {
    0% {
        opacity: 0;
        transform: translate(-50%, 12px);
    }
    12%,
    82% {
        opacity: 1;
        transform: translate(-50%, 0);
    }
    100% {
        opacity: 0;
        transform: translate(-50%, 8px);
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        scroll-behavior: auto !important;
    }
}

@media (max-width: 720px) {
    .page {
        align-items: flex-start;
        padding: 10px;
    }

    .access-card {
        width: calc(100vw - 20px);
        max-height: calc(100svh - 20px);
        padding: 18px 16px;
        border-radius: 20px;
    }

    .scanner {
        width: min(104px, 18vh);
        height: min(104px, 18vh);
    }

    .security-badge {
        width: 72%;
        height: 72%;
    }

    .scan-title {
        font-size: 22px;
    }

    .route-card {
        grid-template-columns: 46px minmax(0, 1fr) 42px;
        gap: 10px;
        min-height: 54px;
        padding: 7px 9px;
    }

    .signal-badge,
    .copy-badge {
        width: 40px;
        height: 40px;
        border-radius: 15px;
    }

    .route-title {
        font-size: 16px;
    }

    .section-head {
        min-height: 42px;
        padding: 9px 12px;
    }

    .route-list,
    .actions {
        padding: 10px;
    }

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

    .action-button {
        min-height: 46px;
        font-size: 18px;
    }
}

@media (max-width: 430px) {
    .access-card {
        padding: 12px;
    }

    .scan-panel {
        gap: 8px;
        margin-bottom: 10px;
    }

    .scan-title {
        font-size: 20px;
    }

    .scan-subtitle {
        font-size: 12px;
        line-height: 1.35;
    }

    .status-badge {
        font-size: 14px;
        white-space: normal;
        justify-content: center;
        text-align: center;
    }

    .url-value {
        font-size: 14px;
    }

    .section-block + .section-block {
        margin-top: 8px;
    }

    .section-head {
        min-height: 40px;
        padding: 8px 10px;
    }

    .section-title {
        font-size: 14px;
    }

    .section-meta {
        font-size: 11px;
    }

    .route-list,
    .actions {
        padding: 8px;
    }

    .route-card {
        grid-template-columns: 40px minmax(0, 1fr) 38px;
        gap: 8px;
    }

    .signal-badge,
    .copy-badge {
        width: 36px;
        height: 36px;
        border-radius: 12px;
    }

    .route-title {
        font-size: 15px;
    }

    .route-status,
    .route-kicker {
        font-size: 12px;
    }
}

@media (max-height: 700px) {
    .access-card {
        padding-top: 14px;
        padding-bottom: 14px;
    }

    .scanner {
        width: 104px;
        height: 104px;
    }

    .scan-subtitle {
        display: none;
    }

    .section-head {
        min-height: 38px;
        padding-top: 7px;
        padding-bottom: 7px;
    }

    .route-list,
    .actions {
        padding-top: 8px;
        padding-bottom: 8px;
    }

    .brand-footer {
        margin-top: 10px;
    }

    .route-card {
        min-height: 50px;
    }
}
