:root {
    --brand: #2563eb;
    --brand-hover: #1d4ed8;
    --ink: #172033;
    --muted: #667085;
    --line: #dfe3e8;
    --surface: #ffffff;
    --canvas: #e8ebef;
}

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    color: var(--ink);
    background: var(--canvas);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
a,
output {
    font: inherit;
    letter-spacing: 0;
}

.hidden {
    display: none !important;
}

.viewer-header {
    position: sticky;
    top: 0;
    z-index: 10;
    min-height: 60px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.08);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--ink);
    font-size: 15px;
    font-weight: 700;
    text-decoration: none;
}

.brand img {
    border-radius: 6px;
}

.viewer-tools {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    overflow-x: auto;
}

.icon-btn,
.command-btn {
    flex: 0 0 auto;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: #344054;
    background: var(--surface);
    cursor: pointer;
    text-decoration: none;
}

.icon-btn {
    width: 38px;
    padding: 0;
}

.command-btn {
    padding: 0 12px;
    font-size: 13px;
    font-weight: 650;
    white-space: nowrap;
}

.icon-btn svg,
.command-btn svg,
.screenshot-meta svg {
    width: 18px;
    height: 18px;
}

.icon-btn:hover:not(:disabled),
.command-btn:hover:not(:disabled) {
    border-color: #aeb5c0;
    background: #f7f8fa;
}

.command-btn-primary {
    border-color: var(--brand);
    color: #ffffff;
    background: var(--brand);
}

.command-btn-primary:hover:not(:disabled) {
    border-color: var(--brand-hover);
    background: var(--brand-hover);
}

.icon-btn:disabled,
.command-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.icon-btn:focus-visible,
.command-btn:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.28);
    outline-offset: 2px;
}

.zoom-label {
    min-width: 44px;
    color: var(--muted);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    text-align: center;
}

.separator {
    width: 1px;
    height: 28px;
    margin: 0 3px;
    background: var(--line);
}

.viewer-main {
    min-height: calc(100vh - 60px);
}

.state-view {
    min-height: calc(100vh - 60px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px;
    text-align: center;
}

.state-view strong {
    font-size: 17px;
}

.state-view p {
    max-width: 440px;
    margin: 8px 0 18px;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.state-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.spinner {
    width: 38px;
    height: 38px;
    margin-bottom: 16px;
    border: 3px solid #dfe7f8;
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.9s linear infinite;
}

.screenshot-view {
    min-width: 100%;
}

.screenshot-stage {
    min-height: calc(100vh - 106px);
    overflow: auto;
    padding: 24px;
    text-align: center;
}

#screenshotImage {
    display: block;
    max-width: none;
    height: auto;
    margin: 0 auto;
    border: 1px solid rgba(16, 24, 40, 0.12);
    background: #ffffff;
    box-shadow: 0 6px 24px rgba(16, 24, 40, 0.16);
}

#screenshotImage.is-fit {
    width: auto;
    max-width: 100%;
}

.screenshot-meta {
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 18px;
    padding: 9px 16px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    background: var(--surface);
    font-size: 12px;
}

.screenshot-meta a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--muted);
    text-decoration: none;
}

.screenshot-meta a:hover {
    color: var(--ink);
}

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

@media (max-width: 680px) {
    .viewer-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .viewer-tools {
        width: 100%;
        justify-content: flex-start;
        overflow-x: visible;
    }

    .viewer-tools .command-btn {
        width: 38px;
        padding: 0;
    }

    .viewer-tools .command-btn span,
    .viewer-tools .zoom-label,
    .viewer-tools .separator {
        display: none;
    }

    .screenshot-stage {
        min-height: calc(100vh - 150px);
        padding: 12px;
    }

    .screenshot-meta {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .spinner {
        animation-duration: 1.8s;
    }
}
