:root {
    color-scheme: light;
    --paper: #f4f3ef;
    --ink: #151515;
    --muted: #6c6c68;
    --line: #d8d6cf;
    --orange: #f16538;
    --green: #214d3a;
    --stage: #202321;
    --toolbar: #171918;
    --focus: #f16538;
    font-family: Inter, "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
    font-synthesis: none;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    min-width: 320px;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--stage);
    color: var(--ink);
}

button,
input {
    font: inherit;
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 3px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.topbar {
    position: relative;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 68px;
    padding: 0 max(20px, env(safe-area-inset-right)) 0 max(20px, env(safe-area-inset-left));
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    min-width: 0;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    place-items: center;
    border-radius: 4px;
    background: var(--orange);
    color: #fff;
    font-size: 20px;
    font-weight: 800;
}

.brand-copy {
    display: grid;
    gap: 2px;
    min-width: 0;
}

.brand-copy strong {
    font-size: 15px;
    line-height: 1.1;
    letter-spacing: 0;
}

.brand-copy small {
    color: var(--muted);
    font-size: 11px;
    line-height: 1.2;
}

.topbar-actions,
.zoom-controls {
    display: flex;
    align-items: center;
}

.topbar-actions {
    gap: 8px;
}

.icon-button,
.tool-button,
.zoom-value {
    border: 0;
    cursor: pointer;
}

.icon-button {
    display: inline-flex;
    height: 38px;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

.icon-button {
    width: 38px;
    background: transparent;
    color: var(--ink);
    font-size: 21px;
}

.icon-button:hover {
    background: #e7e5df;
}

.viewer {
    height: calc(100svh - 172px);
    background: var(--stage);
}

.viewer:fullscreen {
    height: 100svh;
}

.viewer-toolbar {
    position: relative;
    z-index: 5;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    height: 54px;
    padding: 0 max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
    background: var(--toolbar);
    border-bottom: 1px solid #333634;
    color: #f5f4f0;
}

.zoom-controls {
    justify-self: start;
    gap: 7px;
}

.tool-button,
.zoom-value {
    height: 34px;
    border-radius: 4px;
    background: transparent;
    color: #f5f4f0;
}

.tool-button {
    width: 34px;
    font-size: 20px;
}

.tool-button:hover,
.zoom-value:hover {
    background: #303330;
}

.tool-button:disabled {
    cursor: default;
    opacity: 0.35;
}

.zoom-value {
    width: 58px;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.range-wrap {
    display: flex;
    align-items: center;
    width: 112px;
    height: 34px;
}

#zoom-range {
    width: 100%;
    accent-color: var(--orange);
    cursor: pointer;
}

.document-status {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #bdbfbb;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--orange);
}

.fullscreen-button {
    justify-self: end;
}

.canvas-scroll {
    position: relative;
    display: flex;
    height: calc(100% - 54px);
    overflow: auto;
    overscroll-behavior: contain;
    padding: 24px;
    background-color: var(--stage);
    scrollbar-color: #5e625f var(--stage);
    scrollbar-width: thin;
}

.canvas-scroll.is-draggable {
    cursor: grab;
}

.canvas-scroll.is-dragging {
    cursor: grabbing;
    user-select: none;
}

.poster-frame {
    position: relative;
    flex: 0 0 auto;
    width: 640px;
    aspect-ratio: 1982 / 2793;
    margin: auto;
    overflow: hidden;
    background: #efefed;
    border-radius: 3px;
    box-shadow: 0 18px 52px rgba(0, 0, 0, 0.34), 0 1px 0 rgba(255, 255, 255, 0.12);
}

.poster-frame::after {
    position: absolute;
    inset: 0;
    content: "";
    pointer-events: none;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.poster-frame.is-loading::before {
    position: absolute;
    inset: 0;
    content: "";
    background: #deded9;
}

.poster-frame img {
    display: block;
    width: 100%;
    height: auto;
}

.noscript-message {
    position: absolute;
    inset: auto 20px 20px;
    margin: 0;
    color: #fff;
    text-align: center;
}

.toast {
    position: fixed;
    z-index: 30;
    left: 50%;
    bottom: calc(22px + env(safe-area-inset-bottom));
    max-width: calc(100vw - 32px);
    padding: 10px 14px;
    border-radius: 4px;
    background: #111;
    color: #fff;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 8px);
    transition: opacity 160ms ease, transform 160ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

.participants-footer {
    position: relative;
    z-index: 10;
    height: 104px;
    background: #f2f2f2;
    color: #616161;
}

.participants-inner {
    width: min(100%, 1180px);
    height: 100%;
    margin: 0 auto;
    padding: 11px max(20px, env(safe-area-inset-right)) 11px max(20px, env(safe-area-inset-left));
}

.participants-inner h2 {
    margin: 0 0 3px;
    color: #616161;
    font-size: 13px;
    font-weight: 600;
    line-height: 20px;
}

.participant-list {
    display: grid;
    gap: 0;
    margin: 0;
    padding: 0;
    list-style: none;
}

.participant-list li {
    height: 20px;
}

.participant-list a {
    display: inline-flex;
    align-items: baseline;
    gap: 7px;
    color: #616161;
    font-size: 11px;
    line-height: 20px;
    text-decoration: none;
}

.participant-list a:hover {
    color: #262626;
    text-decoration: underline;
}

.participant-role {
    color: #262626;
    font-weight: 600;
}

@media (min-width: 769px) {
    html,
    body {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        background: #f3f3f1;
    }

    .topbar,
    .viewer-toolbar {
        display: none;
    }

    .viewer,
    .viewer:fullscreen {
        height: 100svh;
        background: #f3f3f1;
    }

    .canvas-scroll {
        width: 100%;
        height: 100svh;
        align-items: center;
        justify-content: center;
        padding: 0;
        overflow: hidden;
        overscroll-behavior: auto;
        background: #f3f3f1;
    }

    .poster-frame {
        width: min(100vw, calc(100svh * 1982 / 2793)) !important;
        height: 100svh;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .poster-frame::after {
        display: none;
    }

    .poster-frame img {
        width: 100%;
        height: 100%;
        object-fit: contain;
    }
}

@media (max-width: 640px) {
    .topbar {
        height: 60px;
        padding-right: max(12px, env(safe-area-inset-right));
        padding-left: max(12px, env(safe-area-inset-left));
    }

    .brand {
        gap: 9px;
    }

    .brand-mark {
        width: 34px;
        height: 34px;
    }

    .brand-copy small {
        display: none;
    }

    .viewer {
        height: calc(100svh - 164px);
    }

    .viewer-toolbar {
        grid-template-columns: 1fr auto;
        height: 50px;
    }

    .document-status {
        display: none;
    }

    .range-wrap {
        width: min(28vw, 102px);
    }

    .canvas-scroll {
        height: calc(100% - 50px);
        padding: 12px;
    }

    .participants-inner {
        padding-right: max(14px, env(safe-area-inset-right));
        padding-left: max(14px, env(safe-area-inset-left));
    }
}

@media (max-width: 380px) {
    .brand-copy strong {
        font-size: 13px;
    }

    .range-wrap {
        width: 72px;
    }

    .zoom-controls {
        gap: 3px;
    }

    .zoom-value {
        width: 52px;
    }
}

@media (max-width: 768px) {
    html,
    body {
        height: auto;
        min-height: 100%;
        overflow-x: hidden;
        overflow-y: auto;
        background: #f3f3f1;
    }

    .topbar,
    .viewer-toolbar {
        display: none;
    }

    .viewer,
    .viewer:fullscreen {
        height: auto;
        min-height: 0;
        background: #f3f3f1;
    }

    .canvas-scroll {
        width: 100%;
        height: auto;
        min-height: 0;
        padding: 0;
        overflow: visible;
        overscroll-behavior: auto;
        background: #f3f3f1;
    }

    .poster-frame {
        width: 100vw !important;
        height: auto;
        margin: 0;
        border-radius: 0;
        box-shadow: none;
    }

    .poster-frame::after {
        display: none;
    }

    .poster-frame img {
        width: 100%;
        height: auto;
        object-fit: contain;
    }

    .participants-footer {
        height: auto;
        min-height: max(104px, calc(100svh - 140.92vw));
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
    }
}
