/* ============================================================
   二维码展示页样式
   目标：简洁、美观、手机与电脑自适应；不依赖任何外部 CDN
   ============================================================ */

:root {
    --brand: #1565C0;
    --brand-dark: #0D47A1;
    --brand-light: #E3F2FD;
    --bg: #EEF2F7;
    --card: #FFFFFF;
    --text: #1F2933;
    --text-dim: #64748B;
    --line: #E2E8F0;
    --radius: 18px;
    --shadow: 0 10px 30px rgba(15, 23, 42, .08), 0 2px 6px rgba(15, 23, 42, .04);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0F172A;
        --card: #16233A;
        --text: #E6EDF7;
        --text-dim: #93A4BC;
        --line: #24344D;
        --brand-light: #12233D;
        --shadow: 0 10px 30px rgba(0, 0, 0, .45);
    }
}

* { box-sizing: border-box; }

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

body {
    background:
        radial-gradient(1100px 520px at 50% -220px, rgba(21, 101, 192, .16), transparent 70%),
        var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
                 "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

.page {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: max(20px, env(safe-area-inset-top)) 18px max(24px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
}

/* ---------------- 顶部 ---------------- */

.topbar { text-align: center; margin: 6px 0 18px; }

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px 8px 12px;
    border-radius: 999px;
    background: var(--card);
    box-shadow: var(--shadow);
}

.brand-dot {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    background: linear-gradient(135deg, var(--brand), #42A5F5);
    box-shadow: 0 0 0 4px var(--brand-light);
}

.brand h1 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: .5px;
}

.subtitle {
    margin: 12px 0 0;
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.5;
}

/* ---------------- 卡片 ---------------- */

.card {
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* 二维码画框：正方形，自适应宽度 */
.frame {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 14px;
    background: #FFFFFF;
    border: 1px solid var(--line);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 老浏览器不支持 aspect-ratio 时的兜底 */
@supports not (aspect-ratio: 1 / 1) {
    .frame { height: 0; padding-bottom: 100%; }
    .frame > * { position: absolute; }
}

.frame img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background: #FFFFFF;
    image-rendering: -webkit-optimize-contrast;
}

.placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--text-dim);
    background: repeating-linear-gradient(45deg, #F8FAFC, #F8FAFC 10px, #F1F5F9 10px, #F1F5F9 20px);
    padding: 20px;
    text-align: center;
}

.placeholder-icon { color: #B0BEC5; }
.placeholder p { margin: 0; font-size: 13px; }

.spinner {
    position: absolute;
    right: 12px;
    top: 12px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2.5px solid rgba(21, 101, 192, .2);
    border-top-color: var(--brand);
    animation: spin .8s linear infinite;
}

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

/* ---------------- 刷新按钮 ---------------- */

.refresh {
    margin-top: 18px;
    width: 100%;
    min-height: 54px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 0;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--brand), #1976D2);
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: .3px;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .18s ease, opacity .18s ease;
    box-shadow: 0 6px 18px rgba(21, 101, 192, .30);
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.refresh:hover { box-shadow: 0 8px 22px rgba(21, 101, 192, .40); }
.refresh:active { transform: translateY(1px) scale(.995); }
.refresh:focus-visible { outline: 3px solid #90CAF9; outline-offset: 2px; }
.refresh:disabled { opacity: .7; cursor: default; box-shadow: none; }

.refresh.loading svg { animation: spin .9s linear infinite; }

/* ---------------- 状态与页脚 ---------------- */

.status {
    margin: 12px 0 0;
    font-size: 12.5px;
    color: var(--text-dim);
    text-align: center;
    min-height: 18px;
    line-height: 1.5;
}

.footer {
    margin-top: 16px;
    text-align: center;
}

.footer p {
    margin: 0;
    font-size: 11.5px;
    color: var(--text-dim);
    opacity: .85;
}

/* ---------------- 平板 / 电脑 ---------------- */

@media (min-width: 768px) {
    .page {
        max-width: 620px;
        padding-top: 48px;
        padding-bottom: 48px;
    }

    .topbar { margin-bottom: 24px; }
    .brand h1 { font-size: 19px; }
    .subtitle { font-size: 14px; }

    .card { padding: 26px; border-radius: 22px; }
    .frame { border-radius: 16px; }

    .refresh {
        min-height: 52px;
        font-size: 16.5px;
        max-width: 340px;
        margin-left: auto;
        margin-right: auto;
    }

    .status { font-size: 13px; }
}

@media (min-width: 1100px) {
    .page { max-width: 660px; }
}

/* 横屏手机：缩短上下留白，避免按钮被挤出屏幕 */
@media (max-height: 520px) and (orientation: landscape) {
    .page { max-width: 460px; padding-top: 12px; }
    .topbar { margin-bottom: 10px; }
    .subtitle { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .001ms !important;
    }
}
