:root {
    --ink: #0b1220;
    --muted: #475569;
    --line: #e5e9f0;
    --blue: #93c5fd;
    --blue-deep: #60a5fa;
    --radius: 0px;
    --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100svh;
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro SC",
        "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Segoe UI", sans-serif;
    color: var(--ink);
    background-color: #ffffff;
    background-image:
        radial-gradient(1000px 520px at 50% -180px, #e8f2fd 0%, rgba(232, 242, 253, 0) 70%),
        radial-gradient(700px 420px at 100% 8%, #f1f5f9 0%, rgba(241, 245, 249, 0) 65%),
        radial-gradient(rgba(148, 163, 184, 0.16) 1px, transparent 1.2px);
    background-size: auto, auto, 26px 26px;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- 页面布局 ---------- */
.page {
    position: relative;
    width: min(100%, 1000px);
    margin: 0 auto;
    padding: clamp(44px, 9vh, 86px) clamp(16px, 4vw, 28px) 72px;
    padding-left: max(clamp(16px, 4vw, 28px), env(safe-area-inset-left));
    padding-right: max(clamp(16px, 4vw, 28px), env(safe-area-inset-right));
    padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

.page-head {
    text-align: center;
    margin-bottom: clamp(30px, 5vh, 46px);
    animation: rise 0.7s var(--ease) backwards;
}

h1 {
    margin: 0;
    font-size: clamp(1.6rem, 8vw, 2.7rem);
    line-height: 1.2;
    font-weight: 650;
    letter-spacing: -0.02em;
    color: var(--ink);
    text-wrap: balance;
}

/* ---------- 楼层分组 ---------- */
.floor-list {
    display: flex;
    flex-direction: column;
    gap: clamp(26px, 4.5vh, 38px);
}

.floor-head {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 44px;
    margin: 0;
    padding: 8px 0;
    border: 0;
    background: none;
    font: inherit;
    color: inherit;
    text-align: inherit;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.floor-head:focus-visible {
    outline: 2px solid rgba(96, 165, 250, 0.65);
    outline-offset: 4px;
    border-radius: 8px;
}

.floor-head::before,
.floor-head::after {
    content: "";
    flex: 1 1 auto;
    height: 1px;
}

.floor-head::before {
    background: linear-gradient(90deg, transparent, var(--line));
}

.floor-head::after {
    background: linear-gradient(90deg, var(--line), transparent);
}

.floor-name {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    line-height: 20px;
    font-weight: 600;
    letter-spacing: 0.1em;
    color: #475569;
}

.floor-name::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--blue-deep);
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.8);
}

.floor-head:hover .floor-name {
    color: #1e293b;
}

/* 折叠 / 展开标识 */
.floor-chevron {
    position: absolute;
    right: 0;
    top: 50%;
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: rgba(241, 244, 248, 0.9);
    color: #64748b;
    transform: translateY(-50%);
    transition:
        transform 0.3s var(--ease),
        color 0.2s var(--ease),
        background 0.2s var(--ease);
}

.floor-chevron::before {
    content: "";
    width: 8px;
    height: 8px;
    border-right: 1.8px solid currentColor;
    border-bottom: 1.8px solid currentColor;
    transform: translateY(-2px) rotate(45deg);
}

.floor-head:hover .floor-chevron {
    color: #334155;
    background: #ffffff;
}

.floor-head[aria-expanded="false"] .floor-chevron {
    transform: translateY(-50%) rotate(-90deg);
}

/* 折叠区域 */
.floor-body {
    display: grid;
    grid-template-rows: 1fr;
    opacity: 1;
    transition:
        grid-template-rows 0.35s var(--ease),
        opacity 0.3s var(--ease),
        visibility 0s;
}

.floor-body-inner {
    overflow: hidden;
    min-height: 0;
    padding-top: 14px;
    transition: padding-top 0.35s var(--ease);
}

.floor.is-collapsed .floor-body-inner {
    padding-top: 0;
}

.floor.is-collapsed .floor-body {
    grid-template-rows: 0fr;
    opacity: 0;
    visibility: hidden;
    transition:
        grid-template-rows 0.35s var(--ease),
        opacity 0.25s var(--ease),
        visibility 0s 0.35s;
}

.floor.is-collapsed .card::before {
    animation-play-state: paused;
}

/* ---------- 卡片网格 ---------- */
.link-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
    gap: 18px;
}

/* ---------- 立体毛玻璃设备卡片 ---------- */
.card {
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 4 / 1;
    min-width: 0;
    padding: 0 clamp(16px, 3vw, 24px);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.9);
    text-decoration: none;
    color: inherit;
    overflow: hidden;
    isolation: isolate;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    background:
        linear-gradient(140deg,
            rgba(238, 242, 247, 0.96) 0%,
            rgba(229, 234, 241, 0.9) 48%,
            rgba(219, 226, 235, 0.88) 100%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    backdrop-filter: blur(18px) saturate(160%);
    box-shadow:
        0 0 0 1px rgba(148, 163, 184, 0.08),
        0 4px 12px -6px rgba(30, 58, 95, 0.16),
        0 1px 2px rgba(30, 58, 95, 0.06),
        inset 0 1px 0 #ffffff,
        inset 0 -1px 0 rgba(255, 255, 255, 0.6);
    transition:
        transform 0.35s var(--ease),
        box-shadow 0.35s var(--ease);
    animation: rise 0.7s var(--ease) backwards;
    animation-delay: calc(var(--i, 0) * 55ms);
}

/* 淡蓝色静态描边 + 呼吸灯 */
.card::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    padding: 1.5px;
    border-radius: inherit;
    background: linear-gradient(135deg,
            rgba(191, 219, 254, 0.95) 0%,
            rgba(147, 197, 253, 0.75) 38%,
            rgba(224, 242, 254, 0.95) 65%,
            rgba(96, 165, 250, 0.8) 100%);
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0.55;
    filter: drop-shadow(0 0 5px rgba(96, 165, 250, 0.35));
    animation: breathe 4s ease-in-out infinite;
    pointer-events: none;
}

.card:hover {
    transform: translateY(-3px);
    box-shadow:
        0 0 0 1px rgba(148, 163, 184, 0.12),
        0 8px 18px -10px rgba(30, 58, 95, 0.22),
        0 3px 6px -4px rgba(96, 165, 250, 0.14),
        inset 0 1px 0 #ffffff,
        inset 0 -1px 0 rgba(255, 255, 255, 0.6);
}

.card:active {
    transform: translateY(-1px) scale(0.997);
}

.card:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 3px #ffffff,
        0 0 0 6px rgba(96, 165, 250, 0.55),
        0 22px 44px -24px rgba(30, 58, 95, 0.3);
}

.device-info {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    min-width: 0;
    max-width: 100%;
}

.device-id {
    max-width: 100%;
    padding: 0 4px;
    font-size: clamp(19px, 2.3vw, 26px);
    line-height: 1.2;
    font-weight: 600;
    letter-spacing: 0.04em;
    font-variant-numeric: tabular-nums;
    color: #0f172a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
}

.device-remark {
    max-width: 100%;
    font-size: 13px;
    line-height: 18px;
    letter-spacing: 0.04em;
    color: var(--muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------- 右下角设备图标 ---------- */
.svg-sprite {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
}

.card-decor {
    position: absolute;
    right: clamp(8px, 2vw, 16px);
    bottom: -4%;
    height: 70%;
    width: auto;
    aspect-ratio: 1095 / 1024;
    z-index: 0;
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.3s var(--ease);
}

.card:hover .card-decor {
    opacity: 0.6;
}

/* ---------- 已点击标识 ---------- */
.card-check {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    height: clamp(18px, 24%, 26px);
    width: auto;
    aspect-ratio: 1;
    opacity: 0;
    transform: scale(0.5);
    transform-origin: top left;
    pointer-events: none;
    filter: drop-shadow(0 1px 2px rgba(18, 150, 219, 0.25));
    transition:
        opacity 0.2s var(--ease),
        transform 0.2s var(--ease);
}

.card.is-clicked .card-check {
    opacity: 1;
    transform: scale(1);
}

/* ---------- 空数据占位 ---------- */
.empty {
    display: grid;
    place-items: center;
    min-height: 96px;
    padding: 24px;
    border-radius: var(--radius);
    border: 1px dashed #dbe1ea;
    background: rgba(238, 242, 247, 0.6);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    color: #64748b;
    font-size: 13.5px;
    line-height: 20px;
    letter-spacing: 0.08em;
    animation: rise 0.7s var(--ease) backwards;
}

/* ---------- 页面尾部操作 ---------- */
.page-actions {
    display: flex;
    justify-content: center;
    margin-top: clamp(32px, 6vh, 52px);
}

.clear-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 24px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    background:
        linear-gradient(140deg,
            rgba(238, 242, 247, 0.96) 0%,
            rgba(229, 234, 241, 0.9) 48%,
            rgba(219, 226, 235, 0.88) 100%);
    -webkit-backdrop-filter: blur(18px) saturate(160%);
    backdrop-filter: blur(18px) saturate(160%);
    box-shadow:
        0 0 0 1px rgba(148, 163, 184, 0.08),
        0 4px 12px -6px rgba(30, 58, 95, 0.16),
        0 1px 2px rgba(30, 58, 95, 0.06),
        inset 0 1px 0 #ffffff,
        inset 0 -1px 0 rgba(255, 255, 255, 0.6);
    color: #475569;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0.04em;
    cursor: pointer;
    overflow: hidden;
    isolation: isolate;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition:
        transform 0.3s var(--ease),
        box-shadow 0.3s var(--ease),
        color 0.2s var(--ease);
}

.clear-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 0;
    padding: 1px;
    border-radius: inherit;
    background: linear-gradient(135deg,
            rgba(191, 219, 254, 0.95) 0%,
            rgba(147, 197, 253, 0.75) 38%,
            rgba(224, 242, 254, 0.95) 65%,
            rgba(96, 165, 250, 0.8) 100%);
    -webkit-mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask:
        linear-gradient(#fff 0 0) content-box,
        linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0.55;
    filter: drop-shadow(0 0 5px rgba(96, 165, 250, 0.35));
    animation: breathe 4s ease-in-out infinite;
    pointer-events: none;
}

.clear-btn>span {
    position: relative;
    z-index: 1;
}

.clear-btn:hover {
    transform: translateY(-2px);
    color: #1e293b;
    box-shadow:
        0 0 0 1px rgba(148, 163, 184, 0.12),
        0 8px 18px -10px rgba(30, 58, 95, 0.22),
        0 3px 6px -4px rgba(96, 165, 250, 0.14),
        inset 0 1px 0 #ffffff,
        inset 0 -1px 0 rgba(255, 255, 255, 0.6);
}

.clear-btn:active {
    transform: translateY(0) scale(0.995);
}

.clear-btn:focus-visible {
    outline: none;
    box-shadow:
        0 0 0 3px #ffffff,
        0 0 0 6px rgba(96, 165, 250, 0.55);
}

/* ---------- 清空确认弹窗 ---------- */
body.modal-open {
    overflow: hidden;
}

.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 24px;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.28);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    animation: fade-in 0.2s var(--ease);
}

.modal-panel {
    position: relative;
    width: min(100%, 380px);
    padding: 28px 24px 22px;
    border: 1px solid rgba(255, 255, 255, 0.9);
    background:
        linear-gradient(140deg,
            rgba(255, 255, 255, 0.98) 0%,
            rgba(238, 242, 247, 0.94) 100%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    backdrop-filter: blur(20px) saturate(160%);
    box-shadow:
        0 0 0 1px rgba(148, 163, 184, 0.08),
        0 28px 64px -28px rgba(30, 58, 95, 0.45),
        0 8px 20px -14px rgba(30, 58, 95, 0.25),
        inset 0 1px 0 #ffffff;
    animation: modal-in 0.25s var(--ease);
}

.modal-title {
    margin: 0 0 10px;
    font-size: 18px;
    line-height: 1.4;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: #0f172a;
}

.modal-desc {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.7;
    color: #64748b;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 24px;
}

.modal-btn {
    height: 44px;
    padding: 0 18px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.75);
    color: #334155;
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    -webkit-appearance: none;
    appearance: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    transition:
        background 0.2s var(--ease),
        border-color 0.2s var(--ease),
        color 0.2s var(--ease),
        transform 0.2s var(--ease);
}

.modal-btn:hover {
    background: #ffffff;
    border-color: #cbd5e1;
}

.modal-btn:active {
    transform: scale(0.98);
}

.modal-btn:focus-visible {
    outline: 2px solid rgba(96, 165, 250, 0.65);
    outline-offset: 2px;
}

.modal-btn--primary {
    border-color: #3b82f6;
    background: #3b82f6;
    color: #ffffff;
    box-shadow: 0 4px 12px -6px rgba(59, 130, 246, 0.6);
}

.modal-btn--primary:hover {
    border-color: #2563eb;
    background: #2563eb;
}

/* ---------- 动效 ---------- */
@keyframes rise {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

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

@keyframes breathe {

    0%,
    100% {
        opacity: 0.4;
    }

    50% {
        opacity: 1;
    }
}

@keyframes fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

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

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

/* 不支持毛玻璃时的回退 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
    .card {
        background: #e9edf3;
    }

    .empty {
        background: #eef2f7;
    }
}

/* 触屏设备取消粘滞 hover */
@media (hover: none), (pointer: coarse) {
    .floor-head:hover .floor-name {
        color: #475569;
    }

    .floor-head:hover .floor-chevron {
        color: #64748b;
        background: rgba(241, 244, 248, 0.9);
    }

    .card:hover {
        transform: none;
        box-shadow:
            0 0 0 1px rgba(148, 163, 184, 0.08),
            0 4px 12px -6px rgba(30, 58, 95, 0.16),
            0 1px 2px rgba(30, 58, 95, 0.06),
            inset 0 1px 0 #ffffff,
            inset 0 -1px 0 rgba(255, 255, 255, 0.6);
    }

    .card:hover .card-decor {
        opacity: 0.4;
    }

    .clear-btn:hover {
        transform: none;
        color: #475569;
        box-shadow:
            0 0 0 1px rgba(148, 163, 184, 0.08),
            0 4px 12px -6px rgba(30, 58, 95, 0.16),
            0 1px 2px rgba(30, 58, 95, 0.06),
            inset 0 1px 0 #ffffff,
            inset 0 -1px 0 rgba(255, 255, 255, 0.6);
    }

    .modal-btn:hover {
        background: rgba(255, 255, 255, 0.75);
        border-color: var(--line);
    }

    .modal-btn--primary:hover {
        background: #3b82f6;
        border-color: #3b82f6;
    }
}

/* 不支持 mask 渐变描边时的回退 */
@supports not ((mask-composite: exclude) or (-webkit-mask-composite: xor)) {
    .card::before,
    .clear-btn::before {
        display: none;
    }

    .card,
    .clear-btn {
        border-color: rgba(147, 197, 253, 0.65);
    }
}

/* 不支持 aspect-ratio 时的回退 */
@supports not (aspect-ratio: 4 / 1) {
    .card {
        min-height: 72px;
    }
}

/* 小屏降低毛玻璃开销 */
@media (max-width: 600px) {
    .card {
        -webkit-backdrop-filter: blur(12px) saturate(150%);
        backdrop-filter: blur(12px) saturate(150%);
    }
}

@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}