:root {
    --tg-theme-bg-color: #f2f2f7;
    /* iOS System Gray 6 (Light) */
    --tg-theme-text-color: #000000;
    --tg-theme-hint-color: #8e8e93;
    /* iOS System Gray */
    --tg-theme-link-color: #007aff;
    /* iOS Blue */
    --tg-theme-button-color: #007aff;
    --tg-theme-button-text-color: #ffffff;
    --tg-theme-secondary-bg-color: #ffffff;
    --ios-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    --ios-radius: 14px;
}

/* Telegram Dark Mode Overrides */
@media (prefers-color-scheme: dark) {
    :root {
        --tg-theme-bg-color: #000000;
        --tg-theme-secondary-bg-color: #1c1c1e;
        /* iOS System Gray 6 (Dark) */
        --ios-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    }
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--tg-theme-bg-color);
    color: var(--tg-theme-text-color);
    min-height: 100vh;
    padding-bottom: 30px;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 16px;
}

/* Header */
.header {
    text-align: left;
    margin-bottom: 24px;
    padding: 8px 4px;
}

.header h1 {
    font-size: 34px;
    font-weight: 700;
    margin-bottom: 4px;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--tg-theme-hint-color);
    font-size: 17px;
    line-height: 1.4;
}

/* Tabs: Segmented Control Style */
.tabs {
    display: flex;
    background: rgba(118, 118, 128, 0.12);
    border-radius: 9px;
    padding: 2px;
    margin-bottom: 24px;
    position: relative;
}

.tab {
    flex: 1;
    padding: 6px 12px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--tg-theme-text-color);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.tab.active {
    background: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-text-color);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
}

/* Items List */
.items-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.item-card {
    background: var(--tg-theme-secondary-bg-color);
    border-radius: var(--ios-radius);
    padding: 16px;
    box-shadow: var(--ios-shadow);
    transition: transform 0.2s ease;
    position: relative;
    overflow: hidden;
}

.item-card:active {
    transform: scale(0.98);
}

.item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
    gap: 12px;
}

.item-title {
    font-size: 17px;
    font-weight: 600;
    line-height: 1.3;
    flex: 1;
}

/* Status Badges */
.item-status {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--tg-theme-button-color);
    color: var(--tg-theme-button-text-color);
    letter-spacing: 0.5px;
}

.item-status.in_progress {
    background: #FF9500;
    /* iOS Orange */
}

.item-status.done {
    background: #34C759;
    /* iOS Green */
}

.item-description {
    font-size: 15px;
    color: var(--tg-theme-text-color);
    margin-bottom: 16px;
    line-height: 1.5;
    opacity: 0.8;
}

.item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 0.5px solid rgba(128, 128, 128, 0.2);
    padding-top: 12px;
    margin-top: 8px;
}

.item-author {
    font-size: 13px;
    color: var(--tg-theme-hint-color);
    font-weight: 400;
}

/* Vote Controls */
.vote-controls {
    display: flex;
    gap: 10px;
    align-items: center;
}

.vote-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: none;
    border-radius: 20px;
    /* Capsule */
    background: rgba(118, 118, 128, 0.12);
    /* System Fill */
    color: var(--tg-theme-text-color);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.vote-button:active {
    transform: scale(0.92);
    background: rgba(118, 118, 128, 0.2);
}

/* Active State Colors */
.vote-button.like.active {
    background: #007aff;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 122, 255, 0.3);
}

.vote-button.dislike.active {
    background: #ff3b30;
    /* iOS Red */
    color: white;
    box-shadow: 0 4px 10px rgba(255, 59, 48, 0.3);
}

/* Disabled State (during voting) */
.vote-button.disabled,
.vote-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.vote-count {
    font-weight: 600;
}

.vote-display {
    display: flex;
    gap: 12px;
    font-size: 14px;
    color: var(--tg-theme-hint-color);
}

/* Loading Spinner */
.loading {
    padding: 40px;
    text-align: center;
    color: var(--tg-theme-hint-color);
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(128, 128, 128, 0.2);
    border-top-color: var(--tg-theme-button-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

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

/* Hide Scrollbar for Tabs */
.tabs::-webkit-scrollbar {
    display: none;
}

/* Empty State */
.empty {
    text-align: center;
    padding: 40px;
    color: var(--tg-theme-hint-color);
    font-size: 17px;
}

/* Animations */
@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.item-card {
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.item-card:nth-child(1) {
    animation-delay: 0.05s;
}

.item-card:nth-child(2) {
    animation-delay: 0.1s;
}

.item-card:nth-child(3) {
    animation-delay: 0.15s;
}

/* Pull to Refresh */
.pull-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: var(--tg-theme-bg-color);
    color: var(--tg-theme-hint-color);
    font-size: 14px;
    font-weight: 500;
    transform: translateY(-100%);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.2s ease;
    z-index: 100;
    pointer-events: none;
}

.pull-indicator.visible {
    transform: translateY(0);
    opacity: 1;
}

.pull-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(128, 128, 128, 0.2);
    border-top-color: var(--tg-theme-button-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.container.refreshing {
    transform: translateY(60px);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.container {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* ==================== */
/* Main Navigation      */
/* ==================== */
.main-nav {
    display: flex;
    background: rgba(118, 118, 128, 0.12);
    border-radius: 9px;
    padding: 2px;
    margin-bottom: 16px;
}

.nav-btn {
    flex: 1;
    padding: 10px 16px;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--tg-theme-text-color);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.nav-btn.active {
    background: var(--tg-theme-secondary-bg-color);
    color: var(--tg-theme-text-color);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.12), 0 3px 1px rgba(0, 0, 0, 0.04);
}

/* View Switching */
.view {
    display: block;
}

.view.hidden {
    display: none !important;
}

/* ==================== */
/* Leaderboard Styles   */
/* ==================== */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--tg-theme-secondary-bg-color);
    border-radius: var(--ios-radius);
    padding: 16px;
    box-shadow: var(--ios-shadow);
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.leaderboard-item:nth-child(1) {
    animation-delay: 0.05s;
}

.leaderboard-item:nth-child(2) {
    animation-delay: 0.1s;
}

.leaderboard-item:nth-child(3) {
    animation-delay: 0.15s;
}

/* Rank Badge */
.rank-badge {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    background: rgba(118, 118, 128, 0.12);
    color: var(--tg-theme-text-color);
    flex-shrink: 0;
}

/* Podium Highlights */
.rank-badge.gold {
    background: linear-gradient(145deg, #FFD700, #FFA500);
    color: white;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4);
}

.rank-badge.silver {
    background: linear-gradient(145deg, #C0C0C0, #A8A8A8);
    color: white;
    box-shadow: 0 44px 12px rgba(192, 192, 192, 0.4);
}

.rank-badge.bronze {
    background: linear-gradient(145deg, #CD7F32, #A0522D);
    color: white;
    box-shadow: 0 4px 12px rgba(205, 127, 50, 0.4);
}

/* User Info */
.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 17px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-bugs {
    font-size: 13px;
    color: var(--tg-theme-hint-color);
    margin-top: 2px;
}

/* Points Display */
.points-display {
    text-align: right;
    flex-shrink: 0;
}

.points-value {
    font-size: 20px;
    font-weight: 700;
    color: var(--tg-theme-button-color);
}

.points-label {
    font-size: 11px;
    color: var(--tg-theme-hint-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}