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

:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary-color: #64748b;
    --background: #f8fafc;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --border-color: #e2e8f0;
    --success-color: #16a34a;
    --error-color: #dc2626;
    --warning-color: #d97706;
    --rating-color: #ea580c;
    --tag-bg: #f1f5f9;
    --tag-hover: #e2e8f0;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --transition-speed: 0.25s;
}

/* Dark mode theme */
body.dark-mode {
    --primary-color: #60a5fa;
    --primary-hover: #93c5fd;
    --secondary-color: #94a3b8;
    --background: #0f172a;
    --card-bg: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --success-color: #4ade80;
    --error-color: #f87171;
    --warning-color: #fbbf24;
    --rating-color: #fb923c;
    --tag-bg: #334155;
    --tag-hover: #475569;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background-color 0.2s ease, color 0.2s ease;
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 24px;
    padding: 16px 0;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 400;
}

/* ========================================
   DASHBOARD LAYOUT
   ======================================== */

.dashboard-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

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

@media (min-width: 1100px) {
    .dashboard-layout {
        grid-template-columns: 1fr 420px;
    }
}

.main-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.side-column {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ========================================
   PRIMARY CONTROLS (Always Visible)
   ======================================== */

.primary-controls {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 16px 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 10px;
    z-index: 100;
}

.rating-action-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 16px;
}

.rating-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.rating-separator {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.input-group-inline {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.input-group-inline label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-group-inline select {
    padding: 8px 10px;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    min-width: 80px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-group-inline select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.1);
}

.action-compact {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

.matching-count-inline {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.matching-count-inline #problem-count {
    font-weight: 600;
    color: var(--primary-color);
}

.btn-randomize {
    padding: 10px 20px;
    font-size: 0.875rem;
    white-space: nowrap;
}

@media (max-width: 600px) {
    .rating-action-row {
        flex-direction: column;
        align-items: stretch;
    }

    .rating-compact {
        justify-content: center;
    }

    .action-compact {
        flex-direction: column;
        margin-left: 0;
        gap: 8px;
    }

    .btn-randomize {
        width: 100%;
    }
}

/* ========================================
   ACCORDION SECTIONS
   ======================================== */

.accordion-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.accordion-section {
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: box-shadow var(--transition-speed) ease;
}

.accordion-section:hover {
    box-shadow: var(--shadow-sm);
}

.accordion-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    text-align: left;
    transition: background-color 0.15s ease;
}

.accordion-header:hover {
    background: var(--tag-bg);
}

.accordion-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.accordion-icon {
    width: 16px;
    height: 16px;
    position: relative;
    transition: transform var(--transition-speed) ease;
}

.accordion-icon::before,
.accordion-icon::after {
    content: '';
    position: absolute;
    background: var(--text-secondary);
    transition: transform var(--transition-speed) ease, opacity var(--transition-speed) ease;
}

.accordion-icon::before {
    width: 10px;
    height: 2px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.accordion-icon::after {
    width: 2px;
    height: 10px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.accordion-section.open .accordion-icon::after {
    transform: translate(-50%, -50%) rotate(90deg);
    opacity: 0;
}

.accordion-badge {
    font-size: 0.75rem;
    padding: 2px 8px;
    background: var(--tag-bg);
    color: var(--text-secondary);
    border-radius: 4px;
    font-weight: 500;
}

.accordion-badge.active {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-speed) ease, padding var(--transition-speed) ease;
}

.accordion-section.open .accordion-content {
    max-height: 1000px;
    padding: 0 16px 16px 16px;
}

.section-hint {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

/* ========================================
   FILTER SECTIONS (Legacy support)
   ======================================== */

.filter-section {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px 24px;
    margin-bottom: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.filter-section h2 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Rating Inputs */
.rating-inputs {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.input-group {
    flex: 1;
    min-width: 140px;
}

.input-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.input-group select {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.9375rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Tag Controls */
.tag-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.tag-match-mode {
    display: flex;
    gap: 20px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tag-match-mode label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.tag-match-mode input[type="radio"] {
    width: 14px;
    height: 14px;
    accent-color: var(--primary-color);
}

/* Tags Grid */
.tags-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 6px;
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}

.tag-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--tag-bg);
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.tag-checkbox:hover {
    background: var(--tag-hover);
}

.tag-checkbox input {
    cursor: pointer;
    width: 13px;
    height: 13px;
    accent-color: var(--primary-color);
}

.tag-checkbox input:checked + span {
    color: var(--primary-color);
    font-weight: 500;
}

/* Handle Input */
.handle-input {
    display: flex;
    gap: 10px;
}

.handle-input input {
    flex: 1;
    padding: 10px 12px;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--card-bg);
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.handle-input input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.handle-input input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.handle-status {
    margin-top: 10px;
    font-size: 0.8125rem;
}

.handle-status.success {
    color: var(--success-color);
}

.handle-status.error {
    color: var(--error-color);
}

/* Buttons */
.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: white;
    background: var(--primary-color);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s ease, transform 0.1s ease;
}

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

.btn-primary:active {
    transform: scale(0.98);
}

.btn-primary:disabled {
    background: var(--secondary-color);
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-secondary:hover {
    background: var(--tag-bg);
    border-color: var(--text-secondary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.75rem;
}

/* Action Section (Legacy) */
.action-section {
    text-align: center;
    padding: 24px 0;
}

.matching-count {
    font-size: 0.9375rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

#problem-count {
    font-weight: 600;
    color: var(--primary-color);
}

/* Error Container */
.error-container {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 16px;
    color: var(--error-color);
    text-align: center;
    font-size: 0.875rem;
}

body.dark-mode .error-container {
    background: rgba(220, 38, 38, 0.1);
    border-color: rgba(220, 38, 38, 0.3);
}

.error-container.hidden {
    display: none;
}

/* Loading */
.loading {
    text-align: center;
    padding: 32px 24px;
}

.loading.hidden {
    display: none;
}

.spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 12px;
    animation: spin 0.8s linear infinite;
}

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

.loading p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* Result Section */
.result-section {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

.result-section.hidden {
    display: none;
}

.result-section h2 {
    text-align: center;
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.problem-card {
    padding: 16px;
    background: var(--tag-bg);
    border-radius: 6px;
}

.problem-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.problem-id {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.problem-rating {
    font-weight: 600;
    color: var(--rating-color);
    background: rgba(234, 88, 12, 0.1);
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 0.8125rem;
}

body.dark-mode .problem-rating {
    background: rgba(251, 146, 60, 0.15);
}

.problem-name {
    font-size: 1.125rem;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--text-primary);
    line-height: 1.4;
}

.problem-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 16px;
}

.problem-tags span {
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 3px 8px;
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    border-radius: 3px;
}

body.dark-mode .problem-tags span {
    background: rgba(96, 165, 250, 0.15);
}

.problem-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.problem-actions .btn-primary,
.problem-actions .btn-secondary {
    padding: 8px 14px;
    font-size: 0.8125rem;
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle:hover {
    background: var(--tag-bg);
    border-color: var(--text-secondary);
}

/* Theme icon using CSS */
.theme-icon {
    width: 16px;
    height: 16px;
    display: block;
    position: relative;
}

/* Moon icon (dark mode toggle - shown in light mode) */
.theme-icon::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--text-secondary);
    box-shadow: inset -4px -2px 0 0 var(--text-secondary);
    background: transparent;
    top: 2px;
    left: 2px;
}

/* Sun icon (shown in dark mode) */
body.dark-mode .theme-icon::before {
    width: 8px;
    height: 8px;
    border: none;
    box-shadow: none;
    background: var(--text-secondary);
    top: 4px;
    left: 4px;
}

body.dark-mode .theme-icon::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    background:
        linear-gradient(var(--text-secondary), var(--text-secondary)) center/2px 4px no-repeat,
        linear-gradient(var(--text-secondary), var(--text-secondary)) center/4px 2px no-repeat;
    top: 0;
    left: 0;
}

/* ========================================
   PROFILE STATS SECTION
   ======================================== */

.profile-stats {
    background: linear-gradient(135deg, var(--card-bg) 0%, var(--tag-bg) 100%);
    border-radius: 10px;
    padding: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
    position: relative;
}

.profile-stats.hidden {
    display: none;
}

.profile-collapse-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    background: var(--tag-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
    z-index: 2;
}

.profile-collapse-btn:hover {
    background: var(--tag-hover);
}

.collapse-icon {
    width: 10px;
    height: 10px;
    position: relative;
}

.collapse-icon::before {
    content: '';
    position: absolute;
    width: 8px;
    height: 2px;
    background: var(--text-secondary);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(45deg);
    transition: transform var(--transition-speed) ease;
}

.collapse-icon::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 2px;
    background: var(--text-secondary);
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    transition: transform var(--transition-speed) ease;
}

.profile-stats.collapsed .collapse-icon::before {
    transform: translate(-50%, -50%) rotate(-45deg);
}

.profile-stats.collapsed .collapse-icon::after {
    transform: translate(-50%, -50%) rotate(45deg);
}

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
    padding-right: 32px;
}

.profile-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--primary-color);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.profile-name-rank {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-handle {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.profile-rank {
    font-size: 0.6875rem;
    padding: 2px 8px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: capitalize;
    display: inline-block;
    width: fit-content;
}

.profile-details {
    max-height: 2000px;
    overflow: hidden;
    transition: max-height 0.4s ease, opacity 0.3s ease, padding 0.3s ease;
    padding-top: 12px;
}

.profile-stats.collapsed .profile-details {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}

.stat-item {
    text-align: center;
    padding: 12px 8px;
    background: var(--card-bg);
    border-radius: 6px;
    border: 1px solid var(--border-color);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.stat-item:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
    line-height: 1.2;
    margin-bottom: 2px;
}

.stat-label {
    font-size: 0.625rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    display: block;
}

/* Rating Trend Section */
.rating-trend-section {
    background: var(--card-bg);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
    border: 1px solid var(--border-color);
}

.rating-trend-section h3 {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rating-trend {
    display: flex;
    align-items: center;
    gap: 10px;
}

.trend-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.trend-text {
    font-size: 1rem;
    font-weight: 600;
}

.trend-text.increasing {
    color: var(--success-color);
}

.trend-text.decreasing {
    color: var(--error-color);
}

.trend-text.stable {
    color: var(--warning-color);
}

.trend-details {
    margin-top: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.trend-details span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* Collapsible Breakdown Sections */
.collapsible-breakdown {
    background: var(--card-bg);
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.breakdown-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.breakdown-toggle:hover {
    background: var(--tag-bg);
}

.breakdown-toggle h3 {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0;
}

.breakdown-icon {
    width: 10px;
    height: 10px;
    position: relative;
    transition: transform var(--transition-speed) ease;
}

.breakdown-icon::before {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    border-right: 2px solid var(--text-secondary);
    border-bottom: 2px solid var(--text-secondary);
    transform: rotate(45deg);
    top: 1px;
    left: 2px;
}

.collapsible-breakdown.open .breakdown-icon {
    transform: rotate(180deg);
}

.breakdown-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-speed) ease, padding var(--transition-speed) ease;
}

.collapsible-breakdown.open .breakdown-content {
    max-height: 500px;
    padding: 0 12px 12px 12px;
}

/* Rating Breakdown Bars */
.rating-breakdown {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rating-bar-item {
    display: flex;
    align-items: center;
    gap: 10px;
}

.rating-bar-label {
    min-width: 70px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 500;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
}

.rating-bar-container {
    flex: 1;
    height: 20px;
    background: var(--tag-bg);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.rating-bar {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease-out;
    min-width: 2px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 6px;
}

.rating-bar-inner-count {
    font-size: 0.625rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.rating-bar-count {
    min-width: 40px;
    text-align: right;
    font-size: 0.75rem;
    color: var(--text-primary);
    font-weight: 600;
}

/* Rating bar colors based on Codeforces difficulty */
.rating-bar.r-800 { background: linear-gradient(90deg, #808080, #9a9a9a); }
.rating-bar.r-1000 { background: linear-gradient(90deg, #008000, #00b000); }
.rating-bar.r-1200 { background: linear-gradient(90deg, #03a89e, #04d4c8); }
.rating-bar.r-1400 { background: linear-gradient(90deg, #0000ff, #3535ff); }
.rating-bar.r-1600 { background: linear-gradient(90deg, #aa00aa, #d400d4); }
.rating-bar.r-1900 { background: linear-gradient(90deg, #ff8c00, #ffab40); }
.rating-bar.r-2100 { background: linear-gradient(90deg, #ff7700, #ff9944); }
.rating-bar.r-2400 { background: linear-gradient(90deg, #ff0000, #ff4545); }
.rating-bar.r-2700 { background: linear-gradient(90deg, #aa0000, #dd0000); }

/* Tags Breakdown */
.tags-breakdown {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag-stat-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--tag-bg);
    border-radius: 5px;
    font-size: 0.75rem;
    border: 1px solid var(--border-color);
    transition: background 0.15s ease, transform 0.15s ease;
}

.tag-stat-item:hover {
    background: var(--tag-hover);
    transform: translateY(-1px);
}

.tag-stat-name {
    color: var(--text-primary);
    font-weight: 500;
}

.tag-stat-count {
    color: var(--text-secondary);
    font-size: 0.6875rem;
}

.tag-stat-percent {
    background: var(--primary-color);
    color: white;
    padding: 1px 6px;
    border-radius: 3px;
    font-size: 0.625rem;
    font-weight: 600;
}

/* Problem Statistics */
.problem-stats {
    display: flex;
    gap: 12px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.problem-stat {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.problem-stat strong {
    color: var(--text-primary);
    font-weight: 500;
}

/* Practice Timer */
.timer-section {
    background: var(--tag-bg);
    border-radius: 6px;
    padding: 16px;
    margin-top: 16px;
    text-align: center;
}

.timer-section h3 {
    font-size: 0.6875rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
}

.timer-display {
    font-size: 2rem;
    font-weight: 600;
    color: var(--primary-color);
    margin: 6px 0 12px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    letter-spacing: 0.05em;
}

.timer-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Problem History */
.history-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
}

.checkbox-label input {
    cursor: pointer;
    width: 14px;
    height: 14px;
    accent-color: var(--primary-color);
}

.history-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

#history-count {
    font-weight: 600;
    color: var(--primary-color);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    text-decoration: none;
    font-size: 0.75rem;
    font-weight: 500;
    padding: 0;
    transition: opacity 0.15s ease;
}

.btn-link:hover {
    opacity: 0.8;
}

/* Weak Tags Section */
.weak-tags-section {
    background: var(--card-bg);
    border-radius: 8px;
    padding: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.weak-tags-section h2 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.weak-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.weak-tag {
    padding: 5px 10px;
    background: rgba(217, 119, 6, 0.1);
    border: 1px solid rgba(217, 119, 6, 0.2);
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--warning-color);
}

body.dark-mode .weak-tag {
    background: rgba(251, 191, 36, 0.1);
    border-color: rgba(251, 191, 36, 0.2);
    color: var(--warning-color);
}

/* Connection Status */
.connection-status {
    position: fixed;
    bottom: 16px;
    right: 16px;
    padding: 6px 14px;
    border-radius: 5px;
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 1000;
    transition: opacity 0.2s ease;
}

.connection-status.online {
    background: rgba(22, 163, 74, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(22, 163, 74, 0.2);
}

.connection-status.offline {
    background: rgba(220, 38, 38, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(220, 38, 38, 0.2);
}

.connection-status.hidden {
    opacity: 0;
    pointer-events: none;
}

/* Error with Retry Button */
.error-actions {
    margin-top: 10px;
}

.btn-retry {
    padding: 6px 14px;
    background: var(--error-color);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.8125rem;
    font-weight: 500;
    transition: opacity 0.15s ease;
}

.btn-retry:hover {
    opacity: 0.9;
}

.btn-retry.hidden {
    display: none;
}

/* Footer */
footer {
    text-align: center;
    padding: 24px 0;
    color: var(--text-secondary);
    font-size: 0.75rem;
}

footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
}

footer a:hover {
    text-decoration: underline;
}

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

/* ========================================
   PRACTICE GUIDE SECTION STYLES
   ======================================== */

.practice-guide-section {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.practice-guide-section.hidden {
    display: none;
}

.practice-guide {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.guide-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.guide-header h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.confidence-badge {
    font-size: 0.6875rem;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 3px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.confidence-badge.high {
    background: rgba(22, 163, 74, 0.1);
    color: var(--success-color);
}

.confidence-badge.medium {
    background: rgba(217, 119, 6, 0.1);
    color: var(--warning-color);
}

.confidence-badge.low {
    background: rgba(100, 116, 139, 0.1);
    color: var(--text-secondary);
}

/* Guide Stats Grid */
.guide-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.guide-stat {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    background: var(--tag-bg);
    border-radius: 6px;
}

.stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.level-icon {
    background: rgba(37, 99, 235, 0.1);
    position: relative;
}

.stat-icon.level-icon::before {
    content: '';
    width: 16px;
    height: 16px;
    background: var(--primary-color);
    clip-path: polygon(50% 0%, 100% 25%, 100% 75%, 50% 100%, 0% 75%, 0% 25%);
}

.stat-icon.target-icon {
    background: rgba(22, 163, 74, 0.1);
    position: relative;
}

.stat-icon.target-icon::before {
    content: '';
    width: 16px;
    height: 16px;
    border: 2px solid var(--success-color);
    border-radius: 50%;
}

.stat-icon.target-icon::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: var(--success-color);
    border-radius: 50%;
}

.stat-icon.peak-icon {
    background: rgba(234, 88, 12, 0.1);
    position: relative;
}

.stat-icon.peak-icon::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 14px solid var(--rating-color);
}

.guide-stat .stat-content {
    flex: 1;
    min-width: 0;
}

.guide-stat .stat-title {
    display: block;
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.guide-stat .stat-main {
    display: block;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

.guide-stat .stat-sub {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* Rating Chart */
.rating-chart {
    padding: 12px 0;
}

.rating-chart h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.chart-container {
    display: flex;
    align-items: flex-end;
    gap: 3px;
    height: 100px;
    padding: 12px 0;
    overflow-x: auto;
}

.chart-bar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 28px;
    height: 100%;
    justify-content: flex-end;
}

.chart-bar {
    width: 20px;
    background: var(--primary-color);
    border-radius: 3px 3px 0 0;
    min-height: 3px;
    transition: height 0.3s ease, background 0.2s ease;
    opacity: 0.7;
}

.chart-bar:hover {
    opacity: 1;
}

.chart-bar.target {
    background: var(--success-color);
    opacity: 1;
}

.chart-label {
    font-size: 0.5625rem;
    color: var(--text-secondary);
    margin-top: 6px;
    transform: rotate(-45deg);
    white-space: nowrap;
}

/* Focus Topics Section */
.focus-topics-section {
    padding: 12px 0;
}

.focus-topics-section h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.section-description {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.focus-topics-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.focus-topic-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--tag-bg);
    border-radius: 5px;
    border-left: 3px solid transparent;
}

.focus-topic-item.high {
    border-left-color: var(--error-color);
}

.focus-topic-item.medium {
    border-left-color: var(--warning-color);
}

.focus-topic-item.low {
    border-left-color: var(--text-secondary);
}

.focus-tag {
    font-weight: 500;
    color: var(--text-primary);
    min-width: 100px;
    font-size: 0.8125rem;
}

.focus-reason {
    font-size: 0.75rem;
    color: var(--text-secondary);
    flex: 1;
}

/* Guide Actions */
.guide-actions {
    display: flex;
    justify-content: center;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* ========================================
   RECOMMENDED PROBLEMS SECTION STYLES
   ======================================== */

.recommended-problems-section {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 16px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.recommended-problems-section.hidden {
    display: none;
}

.recommended-problems h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.recommended-problems-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    margin-top: 12px;
}

.recommended-problem-card {
    background: var(--tag-bg);
    border-radius: 6px;
    padding: 12px;
    border: 1px solid var(--border-color);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.recommended-problem-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.rec-problem-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.rec-problem-id {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.6875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.rec-problem-rating {
    font-weight: 600;
    font-size: 0.6875rem;
    color: var(--rating-color);
    background: rgba(234, 88, 12, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
}

body.dark-mode .rec-problem-rating {
    background: rgba(251, 146, 60, 0.15);
}

.rec-problem-name {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.rec-problem-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 8px;
}

.rec-problem-tags span {
    font-size: 0.625rem;
    font-weight: 500;
    padding: 2px 6px;
    background: rgba(100, 116, 139, 0.1);
    color: var(--text-secondary);
    border-radius: 2px;
}

.rec-problem-tags span.matched {
    background: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
}

body.dark-mode .rec-problem-tags span.matched {
    background: rgba(96, 165, 250, 0.15);
}

.rec-problem-reasons {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: 10px;
}

.rec-problem-reasons .reason {
    font-size: 0.625rem;
    padding: 2px 5px;
    background: rgba(22, 163, 74, 0.1);
    color: var(--success-color);
    border-radius: 2px;
}

body.dark-mode .rec-problem-reasons .reason {
    background: rgba(74, 222, 128, 0.1);
}

.rec-problem-link {
    display: inline-block;
    width: 100%;
    text-align: center;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.05);
    border: 1px solid var(--primary-color);
    border-radius: 5px;
    text-decoration: none;
    transition: background 0.15s ease;
}

.rec-problem-link:hover {
    background: rgba(37, 99, 235, 0.1);
}

body.dark-mode .rec-problem-link {
    background: rgba(96, 165, 250, 0.05);
}

body.dark-mode .rec-problem-link:hover {
    background: rgba(96, 165, 250, 0.15);
}

.no-recommendations {
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    padding: 20px;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media (max-width: 900px) {
    .side-column {
        order: -1;
    }

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

@media (max-width: 600px) {
    .container {
        padding: 12px;
    }

    header {
        margin-bottom: 16px;
        padding: 12px 0;
    }

    header h1 {
        font-size: 1.25rem;
    }

    .primary-controls {
        padding: 12px 16px;
    }

    .tags-grid {
        grid-template-columns: repeat(2, 1fr);
        max-height: 220px;
    }

    .handle-input {
        flex-direction: column;
    }

    .problem-actions {
        flex-direction: column;
    }

    .problem-actions .btn-primary,
    .problem-actions .btn-secondary {
        width: 100%;
        text-align: center;
    }

    .theme-toggle {
        top: 10px;
        right: 10px;
        padding: 6px 10px;
    }

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

    .guide-stats {
        grid-template-columns: 1fr;
    }

    .chart-container {
        height: 80px;
    }

    .focus-topic-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .focus-tag {
        min-width: auto;
    }
}

/* Scrollbar styling for tags grid */
.tags-grid::-webkit-scrollbar {
    width: 6px;
}

.tags-grid::-webkit-scrollbar-track {
    background: var(--tag-bg);
    border-radius: 3px;
}

.tags-grid::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.tags-grid::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ========================================
   CHEATSHEET STYLES
   ======================================== */

/* Toggle Button */
.btn-cheatsheet-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    margin-top: 16px;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.3);
}

.btn-cheatsheet-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-cheatsheet-toggle:active {
    transform: translateY(0);
}

.cheatsheet-icon {
    width: 16px;
    height: 16px;
    background: white;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M4 19.5A2.5 2.5 0 0 1 6.5 17H20'/%3E%3Cpath d='M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z'/%3E%3C/svg%3E") center/contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2'%3E%3Cpath d='M4 19.5A2.5 2.5 0 0 1 6.5 17H20'/%3E%3Cpath d='M6.5 2H20v20H6.5A2.5 2.5 0 0 1 4 19.5v-15A2.5 2.5 0 0 1 6.5 2z'/%3E%3C/svg%3E") center/contain no-repeat;
}

/* Cheatsheet Container */
.cheatsheet-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cheatsheet-container.hidden {
    display: none;
}

.cheatsheet-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.cheatsheet-modal {
    position: relative;
    width: 95%;
    max-width: 1200px;
    height: 90vh;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Cheatsheet Header */
.cheatsheet-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
}

.cheatsheet-header h2 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.cheatsheet-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

#cheatsheet-search {
    width: 280px;
    padding: 10px 16px;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-primary);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

#cheatsheet-search:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

#cheatsheet-search::placeholder {
    color: var(--text-secondary);
}

.cheatsheet-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.cheatsheet-close:hover {
    background: var(--tag-bg);
    color: var(--text-primary);
}

/* Cheatsheet Tabs */
.cheatsheet-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--tag-bg);
}

.cheatsheet-tab {
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.cheatsheet-tab:hover {
    background: var(--card-bg);
    color: var(--text-primary);
}

.cheatsheet-tab.active {
    background: var(--primary-color);
    color: white;
}

/* Cheatsheet Content */
.cheatsheet-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.cheatsheet-panel {
    display: none;
}

.cheatsheet-panel.active {
    display: block;
}

/* Strategies Grid */
.strategies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 16px;
}

/* Cheatsheet Sections */
.cheatsheet-section {
    background: var(--tag-bg);
    border-radius: 10px;
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.cheatsheet-section:hover {
    box-shadow: var(--shadow-md);
}

.cheatsheet-section-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    transition: background 0.15s ease;
}

.cheatsheet-section-header:hover {
    background: var(--card-bg);
}

.cheatsheet-section-header h3 {
    flex: 1;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.section-toggle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 300;
    transition: transform 0.2s ease;
}

.cheatsheet-section.expanded .section-toggle {
    transform: rotate(45deg);
}

.cheatsheet-section-content {
    display: none;
    padding: 0 20px 20px;
}

.cheatsheet-section.expanded .cheatsheet-section-content {
    display: block;
}

/* Section Icons */
.section-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.section-icon-code {
    background: rgba(59, 130, 246, 0.15);
}

.section-icon-code::before {
    content: '</>';
    font-size: 0.75rem;
    font-weight: 700;
    color: #3b82f6;
    font-family: monospace;
}

.section-icon-calculator {
    background: rgba(16, 185, 129, 0.15);
}

.section-icon-calculator::before {
    content: 'f(x)';
    font-size: 0.625rem;
    font-weight: 700;
    color: #10b981;
    font-family: serif;
    font-style: italic;
}

.section-icon-layers {
    background: rgba(245, 158, 11, 0.15);
}

.section-icon-layers::before {
    content: '';
    width: 16px;
    height: 14px;
    background:
        linear-gradient(#f59e0b, #f59e0b) 0 0/14px 3px no-repeat,
        linear-gradient(#f59e0b, #f59e0b) 0 5px/12px 3px no-repeat,
        linear-gradient(#f59e0b, #f59e0b) 0 10px/10px 3px no-repeat;
}

.section-icon-zap {
    background: rgba(234, 179, 8, 0.15);
}

.section-icon-zap::before {
    content: '';
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 12px solid #eab308;
}

.section-icon-search {
    background: rgba(139, 92, 246, 0.15);
}

.section-icon-search::before {
    content: '';
    width: 12px;
    height: 12px;
    border: 2px solid #8b5cf6;
    border-radius: 50%;
    position: relative;
}

.section-icon-git-branch {
    background: rgba(236, 72, 153, 0.15);
}

.section-icon-git-branch::before {
    content: '';
    width: 14px;
    height: 14px;
    border-left: 2px solid #ec4899;
    border-bottom: 2px solid #ec4899;
    border-bottom-left-radius: 8px;
}

.section-icon-database {
    background: rgba(14, 165, 233, 0.15);
}

.section-icon-database::before {
    content: '';
    width: 14px;
    height: 12px;
    border: 2px solid #0ea5e9;
    border-radius: 3px;
}

.section-icon-type {
    background: rgba(168, 85, 247, 0.15);
}

.section-icon-type::before {
    content: 'Aa';
    font-size: 0.625rem;
    font-weight: 700;
    color: #a855f7;
}

.section-icon-move {
    background: rgba(34, 197, 94, 0.15);
}

.section-icon-move::before {
    content: '';
    width: 14px;
    height: 2px;
    background: #22c55e;
    position: relative;
}

.section-icon-move::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    border-top: 2px solid #22c55e;
    border-right: 2px solid #22c55e;
    transform: rotate(45deg);
    right: 8px;
}

/* Strategy Subsections */
.strategy-subsection {
    margin-bottom: 16px;
}

.strategy-subsection:last-child {
    margin-bottom: 0;
}

.strategy-subsection h4 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.strategy-subsection ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.strategy-subsection li {
    position: relative;
    padding-left: 16px;
    margin-bottom: 6px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.strategy-subsection li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 6px;
    height: 6px;
    background: var(--primary-color);
    border-radius: 50%;
}

.pitfalls li::before {
    background: var(--error-color);
}

.cheatsheet-section .complexity-note {
    font-size: 0.875rem;
    color: var(--primary-color);
    font-weight: 500;
    padding: 8px 12px;
    background: rgba(37, 99, 235, 0.08);
    border-radius: 6px;
    margin: 0;
}

body.dark-mode .cheatsheet-section .complexity-note {
    background: rgba(96, 165, 250, 0.1);
}

/* Code Blocks */
.code-block {
    position: relative;
    background: #1e293b;
    border-radius: 8px;
    overflow: hidden;
}

body.dark-mode .code-block {
    background: #0f172a;
    border: 1px solid var(--border-color);
}

.code-block pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
}

.code-block code {
    font-family: 'SF Mono', 'Monaco', 'Consolas', 'Liberation Mono', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    color: #e2e8f0;
    white-space: pre;
}

.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #e2e8f0;
}

.copy-code-btn.copied {
    background: rgba(34, 197, 94, 0.3);
    color: #4ade80;
}

/* Formula Cards */
.formula-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.formula-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 16px;
    background: var(--card-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.formula-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.formula-code {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.8125rem;
    color: var(--primary-color);
    background: rgba(37, 99, 235, 0.08);
    padding: 6px 10px;
    border-radius: 4px;
    word-break: break-word;
}

body.dark-mode .formula-code {
    background: rgba(96, 165, 250, 0.1);
}

/* Complexity Table */
.complexity-container {
    display: grid;
    gap: 24px;
}

.complexity-table-wrapper {
    background: var(--tag-bg);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.complexity-table-wrapper h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.complexity-table {
    width: 100%;
    border-collapse: collapse;
}

.complexity-table th,
.complexity-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.complexity-table th {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--card-bg);
}

.complexity-table tbody tr:hover {
    background: var(--card-bg);
}

.constraint-cell {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-weight: 600;
    color: var(--primary-color);
}

.complexity-cell {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-weight: 500;
    color: var(--text-primary);
}

.note-cell {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.complexity-tips {
    background: var(--tag-bg);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.complexity-tips h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.complexity-tips ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.complexity-tips li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.complexity-tips li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 8px;
    width: 8px;
    height: 8px;
    background: var(--success-color);
    border-radius: 2px;
}

.complexity-calculator {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1) 0%, rgba(139, 92, 246, 0.1) 100%);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.complexity-calculator h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.complexity-calculator p {
    font-size: 0.9375rem;
    color: var(--text-primary);
}

#complexity-n {
    width: 120px;
    padding: 6px 10px;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--text-primary);
    margin: 0 4px;
}

#complexity-result {
    font-weight: 600;
    color: var(--primary-color);
}

.calc-hint {
    font-size: 0.8125rem !important;
    color: var(--text-secondary) !important;
    margin-top: 8px;
}

/* Contest Tips */
.contest-tips-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.tips-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
}

.tips-card {
    background: var(--tag-bg);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.tips-card h3 {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.tips-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.tips-card li {
    position: relative;
    padding-left: 18px;
    margin-bottom: 8px;
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.tips-card li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 7px;
    width: 6px;
    height: 6px;
    background: var(--success-color);
    border-radius: 50%;
}

.tips-card.warning-card {
    background: rgba(239, 68, 68, 0.05);
    border-color: rgba(239, 68, 68, 0.2);
}

body.dark-mode .tips-card.warning-card {
    background: rgba(248, 113, 113, 0.05);
    border-color: rgba(248, 113, 113, 0.2);
}

.tips-card.warning-card li::before {
    background: var(--error-color);
}

.template-section {
    background: var(--tag-bg);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border-color);
}

.template-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
}

/* Cheatsheet Responsive */
@media (max-width: 768px) {
    .cheatsheet-modal {
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .cheatsheet-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px;
    }

    .cheatsheet-controls {
        width: 100%;
    }

    #cheatsheet-search {
        flex: 1;
        width: auto;
    }

    .cheatsheet-tabs {
        overflow-x: auto;
        padding: 12px 16px;
        gap: 8px;
    }

    .cheatsheet-tab {
        white-space: nowrap;
        padding: 8px 14px;
        font-size: 0.8125rem;
    }

    .cheatsheet-content {
        padding: 16px;
    }

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

    .formula-cards {
        grid-template-columns: 1fr;
    }

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

    .complexity-table {
        font-size: 0.8125rem;
    }

    .complexity-table th,
    .complexity-table td {
        padding: 10px 12px;
    }
}

/* Scrollbar styling for cheatsheet */
.cheatsheet-content::-webkit-scrollbar {
    width: 8px;
}

.cheatsheet-content::-webkit-scrollbar-track {
    background: var(--tag-bg);
    border-radius: 4px;
}

.cheatsheet-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

.cheatsheet-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Formulas container */
.formulas-container {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ========================================
   NAVIGATION BAR
   ======================================== */

.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    z-index: 1000;
    box-shadow: var(--shadow-sm);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.125rem;
    color: var(--text-primary);
}

.brand-icon {
    font-size: 1.5rem;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
    background: var(--tag-bg);
    color: var(--text-primary);
}

.nav-link.active {
    background: var(--primary-color);
    color: white;
}

.nav-icon {
    font-size: 1rem;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Move theme toggle to navbar */
.navbar .theme-toggle {
    position: static;
}

/* ========================================
   PAGE CONTAINER
   ======================================== */

.page-container {
    padding-top: 60px;
    min-height: 100vh;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Adjust primary controls sticky position */
.primary-controls {
    top: 70px;
}

/* ========================================
   PROFILE PAGE STYLES
   ======================================== */

.profile-page-container {
    max-width: 1100px;
    padding: 30px 20px;
}

.profile-empty-state {
    text-align: center;
    padding: 80px 20px;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.5;
}

.profile-empty-state h2 {
    font-size: 1.5rem;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.profile-empty-state p {
    color: var(--text-secondary);
    margin-bottom: 30px;
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
}

.profile-input-box {
    display: flex;
    gap: 12px;
    justify-content: center;
    max-width: 400px;
    margin: 0 auto;
}

.handle-input-large {
    flex: 1;
    padding: 14px 18px;
    font-size: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-primary);
    transition: border-color 0.15s ease;
}

.handle-input-large:focus {
    outline: none;
    border-color: var(--primary-color);
}

.profile-status {
    margin-top: 16px;
    font-size: 0.875rem;
}

.profile-status.error {
    color: var(--error-color);
}

.profile-loading {
    text-align: center;
    padding: 80px 20px;
}

.profile-loading p {
    margin-top: 16px;
    color: var(--text-secondary);
}

.profile-error {
    text-align: center;
    padding: 60px 20px;
}

.profile-error h2 {
    color: var(--error-color);
    margin-bottom: 12px;
}

.profile-error p {
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* Profile Header Large */
.profile-header-large {
    display: flex;
    align-items: center;
    gap: 30px;
    padding: 30px;
    background: linear-gradient(135deg, var(--card-bg) 0%, var(--tag-bg) 100%);
    border-radius: 16px;
    border: 1px solid var(--border-color);
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.profile-avatar-section {
    display: flex;
    align-items: center;
    gap: 20px;
}

.profile-avatar-large {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.profile-main-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.profile-handle-large {
    font-size: 1.75rem;
    font-weight: 700;
}

.profile-rank-badge {
    padding: 6px 14px;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 600;
    color: white;
    display: inline-block;
    width: fit-content;
    text-transform: capitalize;
}

.profile-name {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.profile-quick-stats {
    display: flex;
    gap: 24px;
    flex: 1;
    justify-content: center;
}

.quick-stat {
    text-align: center;
    min-width: 80px;
}

.quick-stat-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.quick-stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 4px;
}

/* Profile Sections */
.profile-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    border: 1px solid var(--border-color);
    margin-bottom: 20px;
}

.profile-section h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.section-subtitle {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

/* ========================================
   STREAK HEATMAP
   ======================================== */

.heatmap-section {
    overflow-x: auto;
}

.streak-heatmap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.heatmap-grid {
    display: flex;
    gap: 3px;
}

.heatmap-days {
    display: flex;
    flex-direction: column;
    gap: 20px;
    padding-right: 8px;
    font-size: 0.625rem;
    color: var(--text-secondary);
    padding-top: 8px;
}

.heatmap-weeks {
    display: flex;
    gap: 3px;
}

.heatmap-week {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.heatmap-day {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    background: var(--tag-bg);
    cursor: pointer;
    transition: transform 0.1s ease;
}

.heatmap-day:hover {
    transform: scale(1.3);
}

.heatmap-day.level-0 {
    background: var(--tag-bg);
}

.heatmap-day.level-1 {
    background: rgba(22, 163, 74, 0.3);
}

.heatmap-day.level-2 {
    background: rgba(22, 163, 74, 0.5);
}

.heatmap-day.level-3 {
    background: rgba(22, 163, 74, 0.7);
}

.heatmap-day.level-4 {
    background: #16a34a;
}

body.dark-mode .heatmap-day.level-1 {
    background: rgba(74, 222, 128, 0.2);
}

body.dark-mode .heatmap-day.level-2 {
    background: rgba(74, 222, 128, 0.4);
}

body.dark-mode .heatmap-day.level-3 {
    background: rgba(74, 222, 128, 0.6);
}

body.dark-mode .heatmap-day.level-4 {
    background: #4ade80;
}

.heatmap-legend {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
    margin-top: 12px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.legend-box {
    width: 12px;
    height: 12px;
    border-radius: 2px;
}

.legend-box.level-0 { background: var(--tag-bg); }
.legend-box.level-1 { background: rgba(22, 163, 74, 0.3); }
.legend-box.level-2 { background: rgba(22, 163, 74, 0.5); }
.legend-box.level-3 { background: rgba(22, 163, 74, 0.7); }
.legend-box.level-4 { background: #16a34a; }

body.dark-mode .legend-box.level-1 { background: rgba(74, 222, 128, 0.2); }
body.dark-mode .legend-box.level-2 { background: rgba(74, 222, 128, 0.4); }
body.dark-mode .legend-box.level-3 { background: rgba(74, 222, 128, 0.6); }
body.dark-mode .legend-box.level-4 { background: #4ade80; }

.streak-stats {
    display: flex;
    gap: 30px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.streak-stat {
    text-align: center;
}

.streak-stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success-color);
}

.streak-stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ========================================
   RATING CHART (SVG)
   ======================================== */

.progress-section .rating-chart {
    min-height: 300px;
    padding: 0;
}

.rating-svg {
    width: 100%;
    height: auto;
}

.rating-svg text {
    font-family: inherit;
}

.no-data {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.progress-insights {
    display: flex;
    gap: 16px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.insight-card {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: var(--tag-bg);
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

.insight-emoji {
    font-size: 1.5rem;
}

.insight-text {
    flex: 1;
}

.insight-text strong {
    display: block;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.insight-text p {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

/* ========================================
   MONTHLY ACTIVITY CHART
   ======================================== */

.monthly-chart {
    padding: 20px 0;
}

.monthly-bars {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 180px;
}

.monthly-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    height: 100%;
}

.monthly-bar-container {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.monthly-bar {
    width: 100%;
    max-width: 40px;
    background: linear-gradient(180deg, var(--primary-color) 0%, #60a5fa 100%);
    border-radius: 4px 4px 0 0;
    min-height: 4px;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    transition: height 0.3s ease;
}

.monthly-bar-value {
    font-size: 0.625rem;
    font-weight: 600;
    color: white;
    padding: 4px 0;
}

.monthly-bar-label {
    font-size: 0.6875rem;
    color: var(--text-secondary);
    margin-top: 8px;
    text-align: center;
}

/* ========================================
   DIFFICULTY BARS
   ======================================== */

.difficulty-bars {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.difficulty-bar-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.difficulty-label {
    width: 80px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    text-align: right;
}

.difficulty-bar-container {
    flex: 1;
    height: 24px;
    background: var(--tag-bg);
    border-radius: 4px;
    overflow: hidden;
}

.difficulty-bar {
    height: 100%;
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 10px;
    min-width: fit-content;
}

.difficulty-count {
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.difficulty-percent {
    width: 50px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
}

/* ========================================
   TAGS CHART
   ======================================== */

.tags-chart {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tag-bar-item {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tag-bar-label {
    width: 120px;
    font-size: 0.8125rem;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tag-bar-container {
    flex: 1;
    height: 20px;
    background: var(--tag-bg);
    border-radius: 4px;
    overflow: hidden;
}

.tag-bar {
    height: 100%;
    background: var(--primary-color);
    border-radius: 4px;
    display: flex;
    align-items: center;
    padding: 0 8px;
}

.tag-bar-count {
    font-size: 0.6875rem;
    font-weight: 600;
    color: white;
}

.tag-bar-percent {
    width: 40px;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-align: right;
}

/* ========================================
   CHEATSHEET PAGE STYLES
   ======================================== */

.cheatsheet-page-container {
    max-width: 1200px;
    padding: 30px 20px;
}

.cheatsheet-page-container .cheatsheet-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 0;
    border: none;
    background: transparent;
}

.cheatsheet-page-container .cheatsheet-header h1 {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.cheatsheet-subtitle {
    color: var(--text-secondary);
    font-size: 1rem;
}

.cheatsheet-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 30px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.category-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    background: var(--tag-bg);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

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

.category-btn.active {
    background: var(--primary-color);
    color: white;
}

.category-icon {
    font-size: 1rem;
}

/* Cheatsheet section styles for page */
.cheatsheet-page-container .cheatsheet-section {
    margin-bottom: 30px;
    padding: 24px;
}

.cheatsheet-page-container .cheatsheet-section h2 {
    font-size: 1.375rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.cheatsheet-card {
    background: var(--card-bg);
    border-radius: 10px;
    padding: 20px;
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
}

.cheatsheet-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.cheatsheet-card h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.cheatsheet-card ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cheatsheet-card li {
    position: relative;
    padding-left: 20px;
    margin-bottom: 8px;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.cheatsheet-card li::before {
    content: '';
    position: absolute;
    left: 0;
    top: 9px;
    width: 6px;
    height: 6px;
    background: var(--primary-color);
    border-radius: 50%;
}

.cheatsheet-card code {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.8125rem;
    background: var(--tag-bg);
    padding: 2px 6px;
    border-radius: 4px;
    color: var(--primary-color);
}

.cheatsheet-card pre {
    background: #1e293b;
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
}

.cheatsheet-card pre code {
    background: transparent;
    padding: 0;
    color: #e2e8f0;
    font-size: 0.8125rem;
    line-height: 1.6;
}

body.dark-mode .cheatsheet-card pre {
    background: #0f172a;
    border: 1px solid var(--border-color);
}

.pattern-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.pattern-item {
    padding: 16px;
    background: var(--tag-bg);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.pattern-item h4 {
    color: var(--primary-color);
    margin-bottom: 8px;
}

.pattern-item code {
    display: block;
    margin-bottom: 8px;
}

.pattern-item p {
    margin: 0;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.code-comparison {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
}

.code-comparison .code-block {
    margin: 0;
}

.code-comparison .code-block h4 {
    padding: 12px 16px;
    margin: 0;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    font-size: 0.8125rem;
}

.code-comparison .code-block p {
    padding: 12px 16px;
    margin: 0;
    font-size: 0.75rem;
    color: #94a3b8;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.algo-table, .ds-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.algo-table th, .algo-table td,
.ds-table th, .ds-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.algo-table th, .ds-table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    background: var(--tag-bg);
}

.algo-table td, .ds-table td {
    color: var(--text-primary);
}

.formula-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.formula-item {
    padding: 12px 16px;
    background: var(--tag-bg);
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.formula {
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.8125rem;
    color: var(--primary-color);
}

/* ========================================
   RESPONSIVE ADJUSTMENTS FOR NAV
   ======================================== */

@media (max-width: 768px) {
    .navbar {
        padding: 0 12px;
        flex-wrap: wrap;
        height: auto;
        min-height: 60px;
        padding-top: 10px;
        padding-bottom: 10px;
    }

    .nav-brand {
        font-size: 1rem;
    }

    .brand-text {
        display: none;
    }

    .nav-links {
        order: 3;
        width: 100%;
        justify-content: center;
        margin-top: 8px;
        gap: 4px;
    }

    .nav-link {
        padding: 8px 14px;
        font-size: 0.8125rem;
    }

    .nav-link span:last-child {
        display: none;
    }

    .page-container {
        padding-top: 100px;
    }

    .primary-controls {
        top: 110px;
    }

    .profile-header-large {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }

    .profile-avatar-section {
        flex-direction: column;
    }

    .profile-quick-stats {
        flex-wrap: wrap;
        gap: 16px;
    }

    .quick-stat {
        min-width: 70px;
    }

    .quick-stat-value {
        font-size: 1.25rem;
    }

    .streak-stats {
        flex-wrap: wrap;
        justify-content: center;
    }

    .monthly-bars {
        height: 140px;
    }

    .insight-card {
        min-width: 100%;
    }

    .cheatsheet-categories {
        padding: 12px;
    }

    .category-btn {
        padding: 8px 12px;
        font-size: 0.8125rem;
    }

    .category-btn .category-name {
        display: none;
    }

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