:root {
    color-scheme: light;
    --page-bg: #ffffff;
    --line: rgba(15, 23, 42, 0.08);
    --muted: #64748b;
}

* {
    -webkit-tap-highlight-color: transparent;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    color: #0f172a;
    background-color: var(--page-bg);
    background-image:
        radial-gradient(ellipse 55% 42% at 8% -10%, rgba(59, 130, 246, 0.1), transparent 72%),
        radial-gradient(ellipse 42% 32% at 96% 0%, rgba(16, 185, 129, 0.07), transparent 72%);
    font-family: "Inter", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
        system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-feature-settings: "tnum" 1;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(15, 23, 42, 0.032) 1px, transparent 1px),
        linear-gradient(90deg, rgba(15, 23, 42, 0.032) 1px, transparent 1px);
    background-size: 58px 58px;
    -webkit-mask-image: radial-gradient(ellipse 82% 64% at 50% 0%, #000 18%, transparent 76%);
    mask-image: radial-gradient(ellipse 82% 64% at 50% 0%, #000 18%, transparent 76%);
}

::selection {
    color: #0f172a;
    background: rgba(96, 165, 250, 0.28);
}

a {
    color: inherit;
    text-decoration: none;
}

button,
input {
    font: inherit;
}

button {
    -webkit-appearance: none;
}

.is-hidden {
    display: none !important;
}

.text-2xs {
    font-size: 0.6875rem;
    line-height: 1rem;
}

.text-3xs {
    font-size: 0.625rem;
    line-height: 0.875rem;
}

button:disabled,
input:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

details[open] .details-chevron {
    transform: rotate(180deg);
}

.brand-gradient {
    color: transparent;
    background-image: linear-gradient(100deg, #2563eb 0%, #0284c7 48%, #059669 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

.brand-mark {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    color: #eff6ff;
    border: 1px solid rgba(96, 165, 250, 0.28);
    background:
        linear-gradient(145deg, rgba(37, 99, 235, 0.92), rgba(8, 145, 178, 0.85));
    box-shadow:
        0 10px 34px -16px rgba(37, 99, 235, 0.9),
        inset 0 1px 0 rgba(255, 255, 255, 0.16);
}

.brand-mark::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(130deg, rgba(255, 255, 255, 0.2), transparent 48%);
    pointer-events: none;
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    background: rgba(255, 255, 255, 0.82);
    -webkit-backdrop-filter: saturate(180%) blur(16px);
    backdrop-filter: saturate(180%) blur(16px);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.4rem;
    padding: 0 0.9rem;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 9999px;
    color: #64748b;
    background: rgba(248, 250, 252, 0.9);
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.status-dot {
    width: 0.375rem;
    height: 0.375rem;
    flex: 0 0 auto;
    border-radius: 9999px;
    background: #34d399;
    box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.14);
    animation: status-pulse-green 2.6s ease-out infinite;
}

.author-link {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2.4rem;
    padding: 0 0.85rem;
    border: 1px solid rgba(37, 99, 235, 0.2);
    border-radius: 9999px;
    color: #1d4ed8;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.04),
        inset 0 1px 0 #ffffff;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    transition:
        color 160ms ease,
        border-color 160ms ease,
        background-color 160ms ease,
        box-shadow 160ms ease,
        transform 160ms ease;
}

.author-link:hover {
    color: #1e40af;
    border-color: rgba(37, 99, 235, 0.36);
    background: #eff6ff;
    box-shadow:
        0 8px 22px -16px rgba(37, 99, 235, 0.7),
        inset 0 1px 0 #ffffff;
    transform: translateY(-1px);
}

.author-link:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.24);
}

.author-arrow {
    opacity: 0.65;
    transition:
        opacity 160ms ease,
        transform 160ms ease;
}

.author-link:hover .author-arrow {
    opacity: 1;
    transform: translate(1px, -1px);
}

.footer-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #475569;
    font-weight: 500;
    transition: color 160ms ease;
}

.footer-link:hover {
    color: #1d4ed8;
}

.footer-link:focus-visible {
    outline: none;
    border-radius: 0.3rem;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.22);
}

@media (max-width: 380px) {
    .author-link {
        gap: 0.3rem;
        padding: 0 0.65rem;
        font-size: 0.7rem;
    }

    .author-link > svg:first-child {
        display: none;
    }
}

.glass-card {
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    box-shadow:
        0 24px 60px -36px rgba(15, 23, 42, 0.28),
        0 1px 2px rgba(15, 23, 42, 0.04);
    -webkit-backdrop-filter: blur(18px);
    backdrop-filter: blur(18px);
}

.inset-panel {
    border: 1px solid rgba(15, 23, 42, 0.06);
    background: #f8fafc;
}

.eyebrow {
    color: #0284c7;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    line-height: 1.4;
    text-transform: uppercase;
}

.title-emblem {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border: 1px solid rgba(59, 130, 246, 0.18);
    border-radius: 0.9rem;
    color: #2563eb;
    background: linear-gradient(145deg, #eff6ff, #dbeafe);
    box-shadow:
        inset 0 1px 0 #ffffff,
        0 8px 20px -18px rgba(37, 99, 235, 0.55);
}

.title-emblem-emerald {
    color: #059669;
    border-color: rgba(16, 185, 129, 0.2);
    background: linear-gradient(145deg, #ecfdf5, #d1fae5);
    box-shadow:
        inset 0 1px 0 #ffffff,
        0 8px 20px -18px rgba(5, 150, 105, 0.5);
}

.flash-target {
    position: relative;
}

.flash-target::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 30;
    border-radius: inherit;
    pointer-events: none;
    opacity: 0;
    background: rgba(var(--flash-rgb, 59, 130, 246), 0.08);
    box-shadow:
        inset 0 0 0 3px rgba(var(--flash-rgb, 59, 130, 246), 0.68),
        0 0 34px rgba(var(--flash-rgb, 59, 130, 246), 0.32);
}

.flash-target[data-flash-color="emerald"] {
    --flash-rgb: 16, 185, 129;
}

.flash-target.data-flash::after {
    animation: data-flash-pulse 880ms ease-out;
}

@keyframes data-flash-pulse {
    0% { opacity: 0; }
    16% { opacity: 0.95; }
    34% { opacity: 0.1; }
    52% { opacity: 0.8; }
    100% { opacity: 0; }
}

.field {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 0.9rem;
    outline: none;
    color: #111827;
    background: #ffffff;
    transition:
        border-color 160ms ease,
        box-shadow 160ms ease,
        background-color 160ms ease;
}

.field::placeholder {
    color: #9ca3af;
}

.field:hover {
    border-color: #9ca3af;
}

.field:focus {
    border-color: #3b82f6;
    background: #ffffff;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.field:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.camera-select {
    appearance: none;
    -webkit-appearance: none;
    padding-right: 2.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none'%3E%3Cpath d='m6 9 6 6 6-6' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.9rem center;
    background-size: 0.9rem;
    cursor: pointer;
}

.camera-select:disabled {
    cursor: not-allowed;
}

.zoom-slider {
    width: 100%;
    min-width: 0;
    height: 1.5rem;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    outline: none;
    background: transparent;
    cursor: pointer;
}

.zoom-slider::-webkit-slider-runnable-track {
    height: 0.3rem;
    border-radius: 9999px;
    background: #e5e7eb;
}

.zoom-slider::-webkit-slider-thumb {
    width: 1rem;
    height: 1rem;
    margin-top: -0.35rem;
    border: 2px solid #ffffff;
    border-radius: 9999px;
    appearance: none;
    -webkit-appearance: none;
    background: #2563eb;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.28);
}

.zoom-slider::-moz-range-track {
    height: 0.3rem;
    border-radius: 9999px;
    background: #e5e7eb;
}

.zoom-slider::-moz-range-thumb {
    width: 1rem;
    height: 1rem;
    border: 2px solid #ffffff;
    border-radius: 9999px;
    background: #2563eb;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.28);
}

.zoom-slider:focus-visible::-webkit-slider-thumb {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.22);
}

.zoom-slider:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.zoom-slider:disabled::-webkit-slider-thumb {
    background: #9ca3af;
}

.zoom-slider:disabled::-moz-range-thumb {
    background: #9ca3af;
}

.room-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: clamp(2.15rem, 8vw, 3.45rem);
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.17em;
    padding-left: 0.17em;
    color: #0f172a;
    text-shadow: none;
}

.room-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 1.25rem;
    font-weight: 650;
    letter-spacing: 0.38em;
    padding-left: calc(1rem + 0.38em);
    text-align: center;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2rem;
    padding: 0.35rem 0.75rem;
    border: 1px solid #e5e7eb;
    border-radius: 9999px;
    color: #475569;
    background: rgba(255, 255, 255, 0.9);
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: color 180ms ease, border-color 180ms ease, background-color 180ms ease;
}

.status-dot {
    width: 0.45rem;
    height: 0.45rem;
    flex: 0 0 auto;
    border-radius: 9999px;
    background: #64748b;
    box-shadow: 0 0 0 0 rgba(100, 116, 139, 0.4);
}

.status-pill[data-state="connecting"] {
    color: #92400e;
    border-color: #fde68a;
    background: #fffbeb;
}

.status-pill[data-state="connecting"] .status-dot {
    background: #fbbf24;
    animation: status-pulse-warm 1.8s ease-out infinite;
}

.status-pill[data-state="online"] {
    color: #047857;
    border-color: #a7f3d0;
    background: #ecfdf5;
}

.status-pill[data-state="online"] .status-dot {
    background: #34d399;
    animation: status-pulse-green 2.2s ease-out infinite;
}

.status-pill[data-state="error"] {
    color: #be123c;
    border-color: #fecdd3;
    background: #fff1f2;
}

.status-pill[data-state="error"] .status-dot {
    background: #fb7185;
}

.status-pill[data-state="idle"] .status-dot {
    background: #94a3b8;
}

.camera-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 9999px;
    color: #cbd5e1;
    background: rgba(2, 6, 23, 0.56);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    font-size: 0.7rem;
    font-weight: 600;
    line-height: 1.2;
}

.camera-chip .status-dot {
    width: 0.4rem;
    height: 0.4rem;
}

.camera-chip[data-state="scanning"] {
    color: #bae6fd;
    border-color: rgba(56, 189, 248, 0.3);
}

.camera-chip[data-state="scanning"] .status-dot {
    background: #38bdf8;
    animation: status-pulse-sky 1.8s ease-out infinite;
}

.camera-chip[data-state="starting"] {
    color: #fde68a;
}

.camera-chip[data-state="starting"] .status-dot {
    background: #fbbf24;
    animation: status-pulse-warm 1.8s ease-out infinite;
}

.camera-chip[data-state="error"] {
    color: #fda4af;
}

.camera-chip[data-state="error"] .status-dot {
    background: #fb7185;
}

.camera-shell {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    aspect-ratio: 4 / 3;
    min-height: 260px;
    border-radius: 1.3rem;
    background:
        radial-gradient(circle at 50% 38%, rgba(30, 64, 175, 0.24), transparent 52%),
        #020617;
}

#reader {
    position: absolute;
    inset: 0;
    z-index: 1;
    width: 100%;
    height: 100%;
}

#reader video {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    object-fit: cover !important;
}

#reader__scan_region {
    display: block !important;
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 100% !important;
}

#reader__dashboard,
#reader__dashboard_section,
#reader__header_message,
#reader__status_span {
    display: none !important;
}

#reader img {
    display: none !important;
}

.scan-overlay {
    position: absolute;
    inset: 9%;
    z-index: 5;
    pointer-events: none;
}

.scan-corner {
    position: absolute;
    width: 2rem;
    height: 2rem;
    border-color: rgba(125, 211, 252, 0.9);
    filter: drop-shadow(0 0 7px rgba(56, 189, 248, 0.55));
}

.scan-corner-tl {
    top: 0;
    left: 0;
    border-top: 2px solid;
    border-left: 2px solid;
    border-top-left-radius: 0.7rem;
}

.scan-corner-tr {
    top: 0;
    right: 0;
    border-top: 2px solid;
    border-right: 2px solid;
    border-top-right-radius: 0.7rem;
}

.scan-corner-bl {
    bottom: 0;
    left: 0;
    border-bottom: 2px solid;
    border-left: 2px solid;
    border-bottom-left-radius: 0.7rem;
}

.scan-corner-br {
    right: 0;
    bottom: 0;
    border-right: 2px solid;
    border-bottom: 2px solid;
    border-bottom-right-radius: 0.7rem;
}

.scan-line {
    position: absolute;
    top: 10%;
    right: 7%;
    left: 7%;
    height: 2px;
    border-radius: 9999px;
    background: linear-gradient(90deg, transparent, #7dd3fc 22%, #22d3ee 50%, #7dd3fc 78%, transparent);
    box-shadow: 0 0 18px rgba(34, 211, 238, 0.78);
    animation: scan-sweep 2.7s ease-in-out infinite;
}

.camera-placeholder {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    text-align: center;
    background:
        radial-gradient(circle at 50% 30%, rgba(37, 99, 235, 0.16), transparent 54%),
        rgba(2, 6, 23, 0.68);
    -webkit-backdrop-filter: blur(3px);
    backdrop-filter: blur(3px);
}

.qr-frame {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    max-width: 27rem;
    aspect-ratio: 1 / 1;
    padding: 1.4rem;
    overflow: hidden;
    border-radius: 1.5rem;
    background: #ffffff;
    box-shadow:
        0 20px 50px -28px rgba(15, 23, 42, 0.24),
        0 0 0 1px rgba(15, 23, 42, 0.05);
}

.qr-image {
    display: block;
    width: 100% !important;
    height: auto !important;
    max-width: 100%;
    border-radius: 0.35rem;
    -webkit-touch-callout: default;
    -webkit-user-select: auto;
    user-select: auto;
}

.qr-renderer {
    position: fixed;
    top: 0;
    left: -10000px;
    width: 512px;
    height: 512px;
    overflow: hidden;
    pointer-events: none;
    opacity: 0;
}

#qrcode img,
#qrcode canvas {
    width: 100% !important;
    height: auto !important;
    max-width: 100% !important;
    border-radius: 0.35rem;
}

#qrcode table {
    width: 100% !important;
    height: auto !important;
}

.waiting-rings {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 6.4rem;
    height: 6.4rem;
    color: #94a3b8;
}

.waiting-rings::before,
.waiting-rings::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 9999px;
}

.waiting-rings::before {
    animation: waiting-ring 2.8s ease-out infinite;
}

.waiting-rings::after {
    animation: waiting-ring 2.8s 1.4s ease-out infinite;
}

.waiting-rings svg {
    position: relative;
    z-index: 1;
}

#qr-panel:fullscreen {
    overflow: auto;
    border: 0;
    border-radius: 0;
    background:
        radial-gradient(circle at 50% 38%, rgba(59, 130, 246, 0.08), transparent 55%),
        #ffffff;
    padding: 1.75rem;
}

#qr-panel:fullscreen .qr-section {
    display: flex;
    flex: 1;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

#qr-panel:fullscreen .qr-frame {
    width: min(68vh, 74vw);
    max-width: none;
}

.fatal-overlay {
    display: flex;
}

.toast-line {
    transition: opacity 180ms ease;
}

@keyframes status-pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.38); }
    70% { box-shadow: 0 0 0 6px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}

@keyframes status-pulse-sky {
    0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.4); }
    70% { box-shadow: 0 0 0 6px rgba(56, 189, 248, 0); }
    100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

@keyframes status-pulse-warm {
    0% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.36); }
    70% { box-shadow: 0 0 0 6px rgba(251, 191, 36, 0); }
    100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

@keyframes scan-sweep {
    0%, 100% { top: 10%; opacity: 0.35; }
    50% { top: 89%; opacity: 1; }
}

@keyframes waiting-ring {
    0% { transform: scale(0.55); opacity: 0.65; }
    85%, 100% { transform: scale(1.45); opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
    html {
        scroll-behavior: auto;
    }

    *,
    *::before,
    *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}
