:root {
    --bg-main: #0D1117;
    --bg-panel: #161B22;
    --bg-input: #0D1117;
    --border-color: #30363D;
    --text-main: #C9D1D9;
    --text-muted: #8B949E;

    --primary: #238636;
    --primary-hover: #2EA043;
    --secondary: #58A6FF;
    --accent: #F78166;
    --danger: #F85149;

    --border-radius: 12px;
    --border-radius-sm: 6px;
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
    --transition: all 0.2s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--secondary);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    text-decoration: underline;
}

.hidden {
    display: none !important;
}

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* Header */
header {
    margin-bottom: 2.5rem;
    text-align: center;
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    position: relative;
    margin-bottom: 0.5rem;
}

header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: #FFFFFF;
}

header p {
    color: var(--text-muted);
    max-width: 600px;
    margin: 0 auto;
}

.rate-limit {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.rate-limit .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.rate-limit.ok .dot {
    background-color: var(--primary);
}

.rate-limit.warn .dot {
    background-color: #D29922;
}

.rate-limit.bad .dot {
    background-color: var(--danger);
}

/* Panels */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.panel-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: #FFF;
    margin-bottom: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

/* Search Section */
.search-section {
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.search-tabs {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--text-main);
}

.tab-btn.active {
    color: #FFF;
    border-bottom-color: var(--primary);
}

.search-bar,
.compare-bar {
    display: flex;
    gap: 0.75rem;
}

.compare-bar {
    align-items: center;
}

.vs-badge {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    color: var(--text-muted);
}

input[type="text"] {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    color: var(--text-main);
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-family: var(--font-family);
    transition: var(--transition);
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--secondary);
    box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

.btn {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border: 1px solid rgba(240, 246, 252, 0.1);
    border-radius: var(--border-radius-sm);
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-family);
    white-space: nowrap;
}

.primary-btn {
    background: var(--primary);
    color: #FFF;
}

.primary-btn:hover {
    background: var(--primary-hover);
}

/* History Tags */
.recent-lookups {
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.history-tags {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.tag {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition);
    border-radius: 20px;
}

.tag:hover {
    border-color: var(--secondary);
    color: var(--secondary);
}

.tag.clear-btn {
    border-color: transparent;
    color: var(--danger);
}

.tag.clear-btn:hover {
    background: rgba(248, 81, 73, 0.1);
}

/* Error State */
.error-panel {
    background: rgba(248, 81, 73, 0.1);
    border: 1px solid rgba(248, 81, 73, 0.4);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 2rem;
    color: var(--danger);
}

.error-icon {
    width: 24px;
    height: 24px;
}

/* Repo Header */
.repo-header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.repo-header.compact {
    gap: 0.5rem;
}

.repo-title {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.owner-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-input);
}

.owner-avatar.t-avatar {
    width: 32px;
    height: 32px;
}

.repo-title h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.repo-title h2 a {
    color: var(--secondary);
}

.badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 2rem;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: 500;
}

.repo-description {
    font-size: 1.05rem;
    color: var(--text-main);
}

.repo-description.t-desc {
    font-size: 0.95rem;
}

.repo-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.meta-item .icon {
    width: 16px;
    height: 16px;
}

.meta-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.stats-grid.compact {
    gap: 1rem;
}

.stat-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.25rem;
    text-align: center;
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: #484F58;
}

.stat-title {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: #FFF;
}

.stats-grid.compact .stat-value {
    font-size: 1.3rem;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

/* Compare Grid */
.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* Language Chart */
.lang-container {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.chart-wrapper {
    flex-shrink: 0;
    width: 200px;
    height: 200px;
}

.lang-legend {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.lang-legend.compact {
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.legend-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.legend-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-main);
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-value {
    color: var(--text-muted);
    font-family: monospace;
}

.compact-lang-bar {
    display: flex;
    height: 8px;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 1rem;
}

.lang-segment {
    height: 100%;
}

/* Readme */
.markdown-body {
    font-family: var(--font-family);
    font-size: 0.95rem;
    color: var(--text-main);
    overflow: hidden;
    max-height: 500px;
    overflow-y: auto;
}

.markdown-body h1,
.markdown-body h2 {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.3em;
    margin-top: 1.5em;
    margin-bottom: 1em;
    color: #FFF;
}

.markdown-body a {
    color: var(--secondary);
}

.markdown-body code {
    background: rgba(110, 118, 129, 0.4);
    padding: 0.2em 0.4em;
    border-radius: 6px;
    font-family: monospace;
}

.markdown-body pre {
    background: var(--bg-input);
    padding: 1rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 1em 0;
}

/* Contributors */
.contributor-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border-color);
}

.contributor-item:last-child {
    border-bottom: none;
}

.contributor-item img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

.contributor-info {
    flex: 1;
}

.contributor-name {
    font-size: 0.9rem;
    font-weight: 500;
}

.contributor-commits {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Commits */
.commit-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.commit-item:last-child {
    border-bottom: none;
}

.commit-msg {
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.commit-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* Loading Skeleton */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(13, 17, 23, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(88, 166, 255, 0.2);
    border-top-color: var(--secondary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

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

.skeleton-text {
    height: 1rem;
    background: var(--border-color);
    margin-bottom: 0.5rem;
    border-radius: 4px;
    animation: pulse 1.5s infinite;
}

.w-80 {
    width: 80%;
}

.w-60 {
    width: 60%;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

@media (max-width: 900px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .compare-grid {
        grid-template-columns: 1fr;
    }

    .lang-container {
        flex-direction: column;
        align-items: flex-start;
    }
}

@media (max-width: 500px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .compare-bar,
    .search-bar {
        flex-direction: column;
    }
}