:root {
    color-scheme: light;
    --background: #ffffff;
    --foreground: #18181b;
    --card: #ffffff;
    --muted: #f4f4f5;
    --muted-foreground: #71717a;
    --border: #e4e4e7;
    --accent: #f4f4f5;
    --accent-foreground: #18181b;
    --ring: #a1a1aa;
    --radius: 6px;
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--background);
    color: var(--foreground);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

body {
    display: flex;
    flex-direction: column;
}

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

.header {
    flex: 0 0 64px;
    height: 64px;
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border);
    background: var(--background);
}

.header h1 {
    width: 100%;
    margin: 0;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 18px;
    font-weight: 650;
}

.header-info {
    flex: 0 0 auto;
    min-height: 48px;
    padding: 8px 24px;
    display: flex;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--border);
    background: #fafafa;
    color: #3f3f46;
    font-size: 13px;
}

.info-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.status-icon::before {
    content: "·";
    color: var(--muted-foreground);
    font-style: normal;
    font-weight: 700;
}

.info-pill {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 2px 8px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--background);
    color: var(--foreground);
    font-size: 12px;
    line-height: 1;
}

.license-badge {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.license-expired {
    border-color: #fecaca;
    background: #fef2f2;
    color: #991b1b;
}

.main-container {
    min-height: 0;
    flex: 1 1 auto;
    display: grid;
    grid-template-columns: 288px minmax(0, 1fr);
    background: var(--background);
}

.sidebar {
    min-width: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border-right: 1px solid var(--border);
    background: #fafafa;
}

.search-container {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background: #fafafa;
}

.search-box {
    position: relative;
}

.search-box input {
    width: 100%;
    height: 36px;
    padding: 0 62px 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    outline: none;
    background: var(--background);
    color: var(--foreground);
    font-size: 13px;
    box-shadow: 0 1px 2px rgb(0 0 0 / 0.03);
}

.search-box input:focus {
    border-color: var(--ring);
    box-shadow: 0 0 0 3px rgb(161 161 170 / 0.18);
}

.search-box i {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    color: var(--muted-foreground);
    font-style: normal;
    pointer-events: none;
}

.search-icon::before {
    content: "⌕";
    font-size: 18px;
}

.clear-search {
    display: none;
    right: 38px !important;
    cursor: pointer;
    pointer-events: auto !important;
}

.clear-search::before {
    content: "×";
    font-size: 18px;
}

.clear-search.show {
    display: block;
}

.version-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px 24px;
}

.version-group {
    margin: 2px 0 8px;
}

.group-title {
    min-height: 34px;
    padding: 7px 10px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-radius: var(--radius);
    color: #3f3f46;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    user-select: none;
}

.group-title:hover {
    background: var(--accent);
    color: var(--accent-foreground);
}

.group-chevron::before {
    content: "⌄";
    display: block;
    color: var(--muted-foreground);
    font-style: normal;
    transition: transform 150ms ease;
}

.group-title.collapsed .group-chevron::before {
    transform: rotate(-90deg);
}

.version-count {
    margin-left: 5px;
    color: var(--muted-foreground);
    font-size: 11px;
    font-weight: 400;
}

.version-list {
    margin: 3px 0 0;
    padding: 0;
    list-style: none;
}

.version-list:not(.show) {
    display: none;
}

.version-item {
    min-height: 34px;
    margin: 2px 0;
    padding: 7px 10px 7px 24px;
    display: flex;
    align-items: center;
    border-radius: var(--radius);
    color: #52525b;
    cursor: pointer;
    font-size: 13px;
}

.version-item:hover {
    background: var(--accent);
    color: var(--foreground);
}

.version-item.active {
    background: #e4e4e7;
    color: var(--foreground);
    font-weight: 600;
}

.version-item.hidden,
.version-group.hidden {
    display: none;
}

.content {
    min-width: 0;
    position: relative;
    overflow: hidden;
    background: var(--background);
}

#versionFrame {
    width: 100%;
    height: 100%;
    display: none;
    border: 0;
    background: var(--background);
}

.loading-indicator,
.error-message,
.no-results {
    display: none;
    color: var(--muted-foreground);
    font-size: 13px;
    text-align: center;
}

.loading-indicator,
.error-message {
    position: absolute;
    inset: 0;
    place-content: center;
}

.loading-indicator.show,
.error-message.show {
    display: grid;
}

.no-results.show {
    display: block;
    padding: 36px 16px;
}

.loading-icon::before {
    content: "";
    width: 22px;
    height: 22px;
    margin: 0 auto 10px;
    display: block;
    border: 2px solid var(--border);
    border-top-color: #52525b;
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

.error-icon::before,
.empty-icon::before {
    content: "!";
    width: 28px;
    height: 28px;
    margin: 0 auto 8px;
    display: grid;
    place-content: center;
    border: 1px solid var(--border);
    border-radius: 50%;
    color: #52525b;
    font-style: normal;
}

.empty-icon::before {
    content: "–";
}

.mobile-menu-btn,
.sidebar-close-btn {
    display: none;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--background);
    color: var(--foreground);
    cursor: pointer;
}

.mobile-menu-btn {
    min-height: 34px;
    padding: 0 10px;
    gap: 6px;
    font-size: 13px;
}

.menu-icon::before {
    content: "☰";
    font-style: normal;
}

.close-icon::before {
    content: "×";
    font-style: normal;
    font-size: 20px;
}

.sidebar-overlay {
    display: none;
}

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

@media (max-width: 768px) {
    .header h1 {
        padding: 0 16px;
    }

    .header-info {
        padding: 8px 16px;
        gap: 12px;
    }

    .main-container {
        grid-template-columns: 1fr;
    }

    .mobile-menu-btn {
        display: inline-flex;
    }

    .sidebar {
        width: min(86vw, 300px);
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 30;
        transform: translateX(-102%);
        transition: transform 180ms ease;
        box-shadow: 8px 0 24px rgb(0 0 0 / 0.12);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .sidebar-close-btn {
        width: 32px;
        height: 32px;
        display: inline-flex;
        position: absolute;
        top: 10px;
        right: 10px;
        z-index: 2;
    }

    .search-container {
        padding: 52px 12px 12px;
    }

    .sidebar-overlay.show {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 20;
        background: rgb(0 0 0 / 0.45);
    }
}

@media (max-width: 520px) {
    .header-info {
        min-height: 62px;
    }

    .info-item {
        width: 100%;
    }

    .mobile-menu-btn span {
        display: none;
    }
}
