* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: #111827;
    background: #f9fafb;
    -webkit-font-smoothing: antialiased;
    font-size: 14px;
}

.pa-practice a,
.pa-problem-page a {
    color: #2563eb;
    text-decoration: none;
}

.pa-practice a:hover,
.pa-problem-page a:hover {
    text-decoration: underline;
}

.pa-practice {
    max-width: 1280px;
    margin: auto;
    padding: 24px;
}

.pa-problem-page {
    width: 100%;
    padding: 16px;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--pa-header-height, 70px));
    overflow: hidden;
}

.pa-problem-top-ad {
    flex-shrink: 0;
    margin-bottom: 16px;
    border-radius: 8px;
    overflow: hidden;
}

.pa-problem-split-layout {
    display: grid;
    grid-template-columns: 40% 1fr;
    gap: 16px;
    flex-grow: 1;
    min-height: 0;
}

/* --- Hero Section --- */
.pa-practice-hero {
    background: #0f172a;
    color: #ffffff;
    padding: 32px 40px;
    border-radius: 12px;
    margin-bottom: 24px;
}

.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    font-size: 0.75rem;
    color: #94a3b8;
    margin: 0 0 8px 0;
}

.pa-practice-hero h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0 0 12px 0;
    color: #f8fafc;
}

.pa-practice-hero p {
    font-size: 0.95rem;
    color: #cbd5e1;
    max-width: 700px;
    margin: 0;
    line-height: 1.5;
}

/* --- Stats Cards --- */
.pa-practice-stats {
    display: flex;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.05);
    margin-bottom: 32px;
    overflow: hidden;
    position: sticky;
    top: calc(var(--pa-header-height, 4.25rem) + 8px);
    z-index: 15;
}

.pa-practice-stats div {
    flex: 1;
    padding: 16px 20px;
    border-right: 1px solid #e5e7eb;
}

.pa-practice-stats div:last-child {
    border-right: none;
}

.pa-practice-stats svg {
    margin-bottom: 0 !important;
    vertical-align: middle;
    width: 20px;
    height: 20px;
    display: inline-block;
}

.pa-practice-stats strong {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    margin-left: 6px;
    vertical-align: middle;
    display: inline-block;
}

.pa-practice-stats span {
    display: block;
    color: #6b7280;
    font-size: 0.85rem;
    font-weight: 500;
    margin-top: 6px;
}

.pa-practice-layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 24px;
    align-items: start;
}

.pa-ad-sidebar {
    position: sticky;
    top: calc(var(--pa-header-height, 4.25rem) + 90px);
}

.ad-placeholder {
    background: #f1f5f9;
    border: 2px dashed #cbd5e1;
    border-radius: 8px;
    height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #64748b;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.875rem;
}


.pa-practice-filters,
.pa-problem-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}

.pa-problem-copy,
.pa-editor-panel {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    overflow-y: auto;
}

.pa-problem-copy {
    padding: 24px;
}

.pa-problem-copy section {
    margin-bottom: 20px;
}

.pa-problem-copy header {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e5e7eb;
}









/* --- Filters --- */
.pa-practice-filters {
    display: grid;
    grid-template-columns: repeat(6, minmax(120px, 1fr));
    gap: 12px;
    padding: 16px 20px;
    position: sticky;
    top: calc(var(--pa-header-height, 4.25rem) + 90px);
    z-index: 10;
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
}

.pa-practice-filters label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #4b5563;
    display: grid;
    gap: 6px;
}

.pa-practice-filters input,
.pa-practice-filters select,
.pa-practice-filters button {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: #ffffff;
    font-size: 0.875rem;
    font-family: inherit;
    color: #111827;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pa-practice-filters input:focus,
.pa-practice-filters select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.pa-practice-filters button {
    background: #f3f4f6;
    color: #374151;
    font-weight: 500;
    cursor: pointer;
    border: 1px solid #d1d5db;
    height: 100%;
}

.pa-practice-filters button:hover {
    background: #e5e7eb;
}

/* --- Problem List & Cards --- */
.pa-problem-list {
    display: grid;
    gap: 12px;
    max-height: 800px;
    overflow-y: auto;
    padding-right: 8px; /* space for scrollbar */
}

/* Custom Scrollbar for Problem List */
.pa-problem-list::-webkit-scrollbar {
    width: 6px;
}
.pa-problem-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}
.pa-problem-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.pa-problem-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

.pa-problem-card {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    text-decoration: none;
    color: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pa-problem-card:hover {
    text-decoration: none;
    border-color: #cbd5e1;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
}

.pa-problem-card h2 {
    margin: 0 0 8px 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #111827;
}

.pa-problem-card:hover h2 {
    color: #2563eb;
}

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

.problem-tags span,
.status {
    background: #f1f5f9;
    color: #475569;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status.completed {
    background: #dcfce7;
    color: #166534;
}

.status.in_progress {
    background: #fef9c3;
    color: #854d0e;
}

.problem-meta {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    white-space: nowrap;
    justify-content: center;
}

.problem-meta span {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}


.pa-problem-copy h1 {
    margin: 0 0 12px 0;
    font-size: clamp(1.25rem, 3vw, 1.5rem);
    font-weight: 600;
    color: #111827;
}

.pa-problem-copy h2 {
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
    margin: 28px 0 12px 0;
}

.pa-problem-copy p {
    font-size: 0.95rem;
    line-height: 1.6;
    color: #374151;
    margin: 0 0 16px 0;
}

.pa-problem-copy pre {
    white-space: pre-wrap;
    background: #f8f9fa;
    color: #374151;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
    overflow: auto;
    font-family: 'ui-monospace', 'SFMono-Regular', 'Menlo', 'Monaco', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    margin: 0;
}

.sample-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    background: #ffffff;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.sample-grid pre {
    background: #f8f9fa;
    border: 1px solid #e5e7eb;
}

.sample-grid strong {
    font-size: 0.85rem;
    font-weight: 700;
    color: #111827;
    display: block;
    margin-bottom: 8px;
}

.pa-problem-copy details {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    margin-bottom: 8px;
    background: #ffffff;
}

.pa-problem-copy details summary {
    padding: 12px 16px;
    font-weight: 600;
    color: #374151;
    cursor: pointer;
    user-select: none;
}

.pa-problem-copy details summary:hover {
    background: #f8f9fa;
}

.pa-problem-copy details p {
    padding: 0 16px 16px;
    margin: 0;
    font-size: 0.95rem;
}

.pa-problem-copy {
    overflow-y: auto;
    padding-right: 12px;
}

.pa-problem-copy::-webkit-scrollbar {
    width: 6px;
}
.pa-problem-copy::-webkit-scrollbar-track {
    background: #f1f5f9;
}
.pa-problem-copy::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.pa-editor-panel {
    position: sticky;
    top: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.pa-editor-panel::-webkit-scrollbar {
    width: 6px;
}
.pa-editor-panel::-webkit-scrollbar-track {
    background: #f1f5f9;
}
.pa-editor-panel::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.editor-status {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    background: #1e293b;
    color: #f8fafc;
    font-size: 0.875rem;
    font-weight: 500;
    border-bottom: 1px solid #0f172a;
    flex-shrink: 0;
}

.pa-editor-panel iframe {
    display: block;
    width: 100%;
    flex-grow: 1;
    border: 0;
    background: #1e1e1e;
}

.completion-box {
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.completion-box button {
    background: #2563eb;
    color: #ffffff;
    border: 0;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background 0.15s ease;
}

.completion-box button:hover {
    background: #1d4ed8;
}

.completion-box a {
    margin-left: 16px;
    font-weight: 500;
    font-size: 0.875rem;
}

.hint-list details {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 12px 0;
}

.hint-list summary {
    font-weight: 500;
    color: #111827;
    cursor: pointer;
    outline: none;
    font-size: 0.95rem;
}

.hint-list div {
    margin-top: 12px;
    color: #4b5563;
    font-size: 0.95rem;
    line-height: 1.5;
}

.loading,
.empty,
.error {
    padding: 40px;
    text-align: center;
    font-size: 0.95rem;
    color: #6b7280;
}

.error {
    color: #b91c1c;
    background: #fef2f2;
    border-radius: 8px;
    border: 1px solid #f87171;
}

@media (max-width: 991px) {
    .pa-practice-layout {
        grid-template-columns: 1fr;
    }
    .pa-ad-sidebar {
        position: static;
        margin-top: 24px;
    }
    .ad-placeholder {
        height: auto;
        padding: 40px;
    }
    
    .pa-problem-split-layout {
        grid-template-columns: 1fr;
    }
    .pa-problem-page {
        height: auto;
        overflow: visible;
    }
    .pa-problem-copy {
        overflow-y: visible;
    }
    .pa-editor-panel {
        min-height: 800px;
    }
}

@media (max-width: 768px) {
    .pa-practice-stats {
        position: static;
        flex-wrap: wrap;
    }
    .pa-practice-stats div {
        flex: 1 1 50%;
        border-bottom: 1px solid #e5e7eb;
    }
    .pa-practice-stats div:nth-child(even) {
        border-right: none;
    }
    .pa-practice-stats div:nth-last-child(-n+2) {
        border-bottom: none;
    }
    .pa-practice-filters {
        grid-template-columns: repeat(3, 1fr);
        top: calc(var(--pa-header-height, 4.25rem) + 16px);
    }
}

@media (max-width: 576px) {
    .pa-practice-stats div {
        flex: 1 1 100%;
        border-right: none;
        border-bottom: 1px solid #e5e7eb;
    }
    .pa-practice-stats div:last-child {
        border-bottom: none;
    }
    .pa-practice-filters {
        grid-template-columns: 1fr;
        position: static;
    }
}
