@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700;800&family=Inter:wght@300;400;500;600;700&display=swap');

/* --- CUSTOM PRISM DARK THEME --- */
code[class*="language-"],
pre[class*="language-"] {
    color: #f8f8f2;
    background: none;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', Courier, monospace;
    font-size: 0.95em;
    text-align: left;
    white-space: pre;
    word-spacing: normal;
    word-break: normal;
    word-wrap: normal;
    line-height: 1.6;
    tab-size: 4;
    hyphens: none;
}
pre[class*="language-"] {
    padding: 1.2em;
    margin: .5em 0;
    overflow-x: auto;
    overflow-y: hidden;
    background: #111827;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    min-width: 0;
}
.token.comment,
.token.prolog,
.token.doctype,
.token.cdata {
    color: #6b7280;
    font-style: italic;
}
.token.punctuation {
    color: #9ca3af;
}
.token.property,
.token.tag,
.token.constant,
.token.symbol,
.token.deleted {
    color: #f43f5e;
}
.token.boolean,
.token.number {
    color: #a78bfa;
}
.token.selector,
.token.attr-name,
.token.string,
.token.char,
.token.builtin,
.token.inserted {
    color: #34d399;
}
.token.operator,
.token.entity,
.token.url,
.language-css .token.string,
.style .token.string {
    color: #f59e0b;
}
.token.atrule,
.token.attr-value,
.token.keyword {
    color: #38bdf8;
    font-weight: 500;
}
.token.function,
.token.class-name {
    color: #fb7185;
}
.token.regex,
.token.important,
.token.variable {
    color: #e11d48;
}

/* --- CORE DESIGN SYSTEM --- */
:root, body.theme-default {
    --bg-dark: #0B0F19;
    --bg-card: #131B2E;
    --bg-sidebar: #0F1626;
    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    
    --primary: #0EA5E9; /* Sky Blue */
    --primary-glow: rgba(14, 165, 233, 0.15);
    --secondary: #8B5CF6; /* Purple */
    --accent: #F59E0B; /* Amber */
    
    --easy: #10B981; /* Emerald */
    --medium: #F59E0B; /* Amber */
    --hard: #EF4444; /* Rose */
    
    --text-primary: #F3F4F6;
    --text-secondary: #9CA3AF;
    --text-muted: #6B7280;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.theme-cyberpunk {
    --bg-dark: #030008;
    --bg-card: #0c0817;
    --bg-sidebar: #05030b;
    --border-color: rgba(255, 0, 127, 0.2);
    --border-hover: rgba(0, 240, 255, 0.4);
    
    --primary: #FF007F; /* Neon Pink */
    --primary-glow: rgba(255, 0, 127, 0.15);
    --secondary: #00F0FF; /* Neon Cyan */
    --accent: #FFE600; /* Neon Yellow */
    
    --easy: #39FF14; /* Neon Green */
    --medium: #FF8C00; /* Neon Orange */
    --hard: #FF003C; /* Neon Red */
    
    --text-primary: #ECEFF4;
    --text-secondary: #00F0FF;
    --text-muted: #707A8A;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.theme-light {
    --bg-dark: #F3F4F6;
    --bg-card: #FFFFFF;
    --bg-sidebar: #ECEFF1;
    --border-color: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.15);
    
    --primary: #4F46E5; /* Indigo */
    --primary-glow: rgba(79, 70, 229, 0.1);
    --secondary: #7C3AED; /* Violet */
    --accent: #D97706; /* Amber */
    
    --easy: #059669; /* Emerald */
    --medium: #D97706; /* Amber */
    --hard: #DC2626; /* Red */
    
    --text-primary: #1F2937;
    --text-secondary: #4B5563;
    --text-muted: #9CA3AF;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.theme-forest {
    --bg-dark: #080D0A;
    --bg-card: #101B15;
    --bg-sidebar: #0C1410;
    --border-color: rgba(52, 211, 153, 0.1);
    --border-hover: rgba(52, 211, 153, 0.25);
    
    --primary: #10B981; /* Emerald */
    --primary-glow: rgba(16, 185, 129, 0.15);
    --secondary: #059669; /* Darker Emerald */
    --accent: #F59E0B; /* Amber */
    
    --easy: #34D399;
    --medium: #FBBF24;
    --hard: #F87171;
    
    --text-primary: #F0FDFA;
    --text-secondary: #99F6E4;
    --text-muted: #5F9A87;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    transition: background-color 0.4s ease, color 0.4s ease, border-color 0.4s ease;
}

/* --- SIDEBAR --- */
aside {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 2.5rem;
    letter-spacing: -0.02em;
}

.logo span {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-links a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: 10px;
    transition: var(--transition-smooth);
    border: 1px solid transparent;
}

.nav-links a:hover, .nav-links li.active a {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.03);
    border-color: var(--border-color);
}

.nav-links li.active a {
    background: linear-gradient(135deg, rgba(14, 165, 233, 0.1), rgba(139, 92, 246, 0.05));
    border-color: rgba(14, 165, 233, 0.25);
    box-shadow: inset 0 0 12px rgba(14, 165, 233, 0.05);
}

.nav-links svg {
    width: 20px;
    height: 20px;
    stroke: currentColor;
    fill: none;
    stroke-width: 2;
}

.nav-footer {
    margin-top: auto;
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    border-top: 1px solid var(--border-color);
    padding-top: 1.5rem;
}

/* --- MAIN CONTENT CONTAINER --- */
main {
    margin-left: 280px;
    flex-grow: 1;
    min-height: 100vh;
    padding: 2.5rem;
    width: calc(100% - 280px);
}

.page-view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.page-view.active {
    display: block;
}

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

/* --- HEADER --- */
header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
}

h1 {
    font-family: 'Outfit', sans-serif;
    font-size: 2.25rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.01em;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.streak-widget {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.1), rgba(239, 68, 68, 0.05));
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 12px;
    padding: 0.65rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    color: #FFF;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.streak-widget:hover {
    transform: scale(1.03);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.15);
}

/* --- DASHBOARD HOME VIEW --- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.stat-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: var(--transition-smooth);
}

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

.stat-info h3 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stat-value {
    font-family: 'Outfit', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
}

.progress-circle-container {
    width: 64px;
    height: 64px;
    position: relative;
}

.progress-circle-svg {
    transform: rotate(-90deg);
}

.progress-circle-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.04);
    stroke-width: 4px;
}

.progress-circle-bar {
    fill: none;
    stroke-width: 4px;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s ease;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    border: 1px solid var(--border-color);
}

.dashboard-sections {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
}

.section-box {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2rem;
}

.section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.categories-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
}

.category-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.01) 0%, rgba(255, 255, 255, 0) 100%);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
    cursor: default;
    transition: var(--transition-smooth);
    display: flex;
    flex-direction: column;
    gap: 0;
}

.category-card:hover {
    border-color: rgba(14, 165, 233, 0.3);
    background-color: rgba(255, 255, 255, 0.01);
    transform: translateY(-2px);
}

.category-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.category-name {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    font-size: 1.1rem;
    color: #fff;
}

.category-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.category-progress-bar {
    height: 6px;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    overflow: hidden;
    margin-top: 1.5rem;
    position: relative;
}

.category-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 10px;
    width: 0%;
    transition: width 0.8s ease;
}

/* ── Dashboard per-pattern rows ────────────────────────────── */
.dash-patterns-list {
    margin-top: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    border-top: 1px solid var(--border-color);
    padding-top: 0.75rem;
}
.dash-pat-row {
    display: grid;
    grid-template-columns: 1.4rem 1fr auto 80px;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.4rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s;
    font-size: 0.8rem;
}
.dash-pat-row:hover {
    background: rgba(14,165,233,0.07);
}
.dash-pat-pip { font-size: 0.75rem; text-align: center; }
.dash-pat-name { color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dash-pat-count { font-size: 0.72rem; color: var(--text-muted); font-family: 'JetBrains Mono', monospace; white-space: nowrap; }
.dash-pat-bar {
    height: 4px;
    background: rgba(255,255,255,0.05);
    border-radius: 4px;
    overflow: hidden;
}
.dash-pat-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    border-radius: 4px;
    transition: width 0.5s ease;
}

.streak-calendar-box {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.calendar-day-header {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
    font-weight: 600;
}

.calendar-day {
    aspect-ratio: 1;
    border-radius: 8px;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
}

.calendar-day.checked {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.25), rgba(16, 185, 129, 0.15));
    border-color: var(--easy);
    color: #fff;
    font-weight: 600;
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.calendar-day.today {
    border-color: var(--primary);
    color: #fff;
    font-weight: 600;
}

.checkin-btn {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 12px;
    color: #fff;
    padding: 0.85rem;
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.checkin-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(14, 165, 233, 0.35);
}

.checkin-btn:disabled {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* --- STUDY CENTER VIEW --- */
.study-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 1.5rem;
    height: calc(100vh - 160px);
}

.study-sidebar {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    overflow-y: auto;
}

.study-search {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.65rem 1rem;
    color: #fff;
    font-size: 0.9rem;
    width: 100%;
}

.study-search:focus {
    outline: none;
    border-color: var(--primary);
}

.study-cat-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.study-cat-title {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.study-pat-item {
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.study-pat-item:hover, .study-pat-item.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.03);
}

.study-pat-item.active {
    background-color: rgba(14, 165, 233, 0.1);
    border-left: 3px solid var(--primary);
}

.study-pat-count {
    font-size: 0.7rem;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.study-main {
    display: grid;
    grid-template-rows: auto 1fr;
    gap: 1.5rem;
    overflow: hidden;
}

/* Theory-only full-width pane (Study Center) */
.study-theory-full {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    overflow-y: auto;
    line-height: 1.8;
    min-width: 0;
}

.study-theory-full .markdown-body h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
    margin: 1.5rem 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}
.study-theory-full .markdown-body h3 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--primary);
    margin: 1.25rem 0 0.5rem 0;
}
.study-theory-full .markdown-body h4 {
    font-size: 1rem;
    color: var(--accent);
    margin: 1rem 0 0.5rem 0;
}
.study-theory-full .markdown-body ul {
    padding-left: 1.5rem;
    margin: 0.5rem 0 1rem 0;
}
.study-theory-full .markdown-body ul li {
    margin-bottom: 0.4rem;
    color: var(--text-secondary);
    line-height: 1.6;
}
.study-theory-full .markdown-body pre {
    overflow-x: auto;
    background: rgba(0,0,0,0.35);
    border-radius: 8px;
    padding: 1rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
}

/* Practice 2-column layout */
.practice-layout-2col {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: 1.5rem;
    height: calc(100vh - 160px);
    min-width: 0;
}

.practice-main {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-right: 0.25rem;
    min-width: 0;
}

.practice-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 1rem;
    color: var(--text-muted);
    font-size: 1rem;
}

/* Practice pattern header */
.practice-pattern-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: rgba(14,165,233,0.06);
    border: 1px solid rgba(14,165,233,0.18);
    border-radius: 14px;
    margin-bottom: 0.25rem;
    position: sticky;
    top: 0;
    z-index: 5;
    backdrop-filter: blur(8px);
}
.practice-pattern-hdr-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
}
.practice-pattern-hdr-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

/* ── Problem Block ─────────────────────────────────────── */
.practice-problem-block {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    transition: border-color 0.2s;
    height: auto;
    flex-shrink: 0;
}
.practice-problem-block:hover {
    border-color: rgba(14,165,233,0.3);
}

/* Clickable header row */
.ppb-toggle {
    user-select: none;
}
.ppb-toggle:hover {
    background: rgba(14,165,233,0.04);
}
.ppb-expand-body {
    animation: ppb-slide-in 0.18s ease;
}
@keyframes ppb-slide-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Problem header row */
.ppb-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1.1rem 1.25rem 0.9rem;
    border-bottom: 1px solid var(--border-color);
}
.ppb-number {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--primary);
    background: rgba(14,165,233,0.1);
    border: 1px solid rgba(14,165,233,0.2);
    border-radius: 6px;
    padding: 0.15rem 0.5rem;
    flex-shrink: 0;
    margin-top: 0.15rem;
}
.ppb-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.35rem;
    line-height: 1.3;
}
.ppb-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 0.5rem;
}
.ppb-complexity {
    font-size: 0.72rem;
    color: var(--text-muted);
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    font-family: 'JetBrains Mono', monospace;
}
.ppb-lc-link {
    font-size: 0.72rem;
    color: var(--primary);
    border: 1px solid rgba(14,165,233,0.3);
    border-radius: 4px;
    padding: 0.15rem 0.45rem;
    text-decoration: none;
    transition: background 0.15s;
}
.ppb-lc-link:hover { background: rgba(14,165,233,0.1); }

.ppb-approach {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0;
}
.ppb-status-wrap {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

/* Coding area */
.ppb-coding {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}
.ppb-coding-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.ppb-coding-label::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--primary);
}
/* ── Per-problem CodeMirror Editor ─────────────────────────────────────── */
.ppb-cm-wrap {
    border: 1px solid var(--border-color);
    border-radius: 10px 10px 0 0;
    overflow: hidden;
    transition: border-color 0.2s;
}
.ppb-cm-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(14,165,233,0.10);
}
.ppb-cm-wrap .CodeMirror {
    height: 260px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.84rem;
    line-height: 1.65;
    background: #0d1117;
    color: #e6edf3;
    border-radius: 0;
}
.ppb-cm-wrap .CodeMirror-scroll {
    min-height: 260px;
}
.ppb-cm-wrap .CodeMirror-gutters {
    background: #0b0f19;
    border-right: 1px solid rgba(255,255,255,0.06);
}
.ppb-cm-wrap .CodeMirror-linenumber {
    color: rgba(255,255,255,0.2);
    font-size: 0.75rem;
    padding: 0 8px 0 6px;
}

/* ── Run / Submit action bar ────────────────────────────────────────────── */
.ppb-run-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: #0b0f19;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 10px 10px;
    flex-wrap: wrap;
}
.ppb-run-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.9rem;
    background: rgba(14,165,233,0.12);
    border: 1px solid rgba(14,165,233,0.3);
    border-radius: 7px;
    color: var(--primary);
    font-family: 'Outfit', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    white-space: nowrap;
}
.ppb-run-btn:hover:not(:disabled) {
    background: rgba(14,165,233,0.22);
    border-color: var(--primary);
    transform: translateY(-1px);
}
.ppb-run-btn:active:not(:disabled) { transform: translateY(0); }
.ppb-run-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ppb-submit-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.9rem;
    background: rgba(16,185,129,0.10);
    border: 1px solid rgba(16,185,129,0.28);
    border-radius: 7px;
    color: #34d399;
    font-family: 'Outfit', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
    white-space: nowrap;
}
.ppb-submit-btn:hover:not(:disabled) {
    background: rgba(16,185,129,0.22);
    border-color: #34d399;
    transform: translateY(-1px);
}
.ppb-submit-btn:active:not(:disabled) { transform: translateY(0); }
.ppb-submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ppb-gear-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    background: transparent;
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 7px;
    color: var(--text-muted);
    font-size: 0.85rem;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
    padding: 0;
}
.ppb-gear-btn:hover { color: #fff; border-color: rgba(255,255,255,0.2); }

.ppb-lang-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.2rem 0.55rem;
    background: rgba(245,158,11,0.10);
    border: 1px solid rgba(245,158,11,0.22);
    border-radius: 6px;
    color: #f59e0b;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.ppb-shortcut-hint {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-family: 'JetBrains Mono', monospace;
    opacity: 0.7;
}

.ppb-autosave-badge {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 0.65rem;
    color: var(--text-muted);
    opacity: 0.6;
}

/* ── Inline execution console ───────────────────────────────────────────── */
.ppb-console {
    margin-top: 0.6rem;
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 10px;
    overflow: hidden;
    animation: ppb-slide-in 0.18s ease;
}
.ppb-console-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.85rem;
    background: #0b0f19;
    border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ppb-console-title {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.ppb-console-title::before {
    content: '';
    display: inline-block;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #34d399;
    box-shadow: 0 0 6px #34d399;
}
.ppb-console-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.7rem;
    cursor: pointer;
    padding: 0.1rem 0.4rem;
    border-radius: 5px;
    transition: color 0.15s;
}
.ppb-console-clear:hover { color: var(--hard); }
.ppb-console-body {
    background: #060a12;
    padding: 0.75rem 1rem;
    max-height: 240px;
    overflow-y: auto;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.78rem;
    line-height: 1.7;
}
.ppb-console-body .terminal-line-error  { color: #f87171; }
.ppb-console-body .terminal-line-success { color: #34d399; }
.ppb-console-body .terminal-line-info    { color: #94a3b8; }
.ppb-console-body .terminal-line-warning { color: #fbbf24; }
.ppb-console-body .terminal-line         { color: #e6edf3; }

/* spinner for run button */
@keyframes ppb-spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
.ppb-spinning { animation: ppb-spin 0.8s linear infinite; display: inline-block; }

/* Accordion: View Implementation */
.ppb-impl {
    border-top: none;
}
.ppb-impl > summary {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1.25rem;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    user-select: none;
    list-style: none;
    transition: color 0.15s, background 0.15s;
    border-top: 1px solid var(--border-color);
}
.ppb-impl > summary::-webkit-details-marker { display: none; }
.ppb-impl > summary::before {
    content: '▶';
    font-size: 0.65rem;
    color: var(--primary);
    transition: transform 0.2s;
    display: inline-block;
}
.ppb-impl[open] > summary::before { transform: rotate(90deg); }
.ppb-impl > summary:hover {
    color: #fff;
    background: rgba(255,255,255,0.02);
}
.ppb-impl[open] > summary {
    color: var(--primary);
    border-bottom: 1px solid var(--border-color);
}
.ppb-impl-body {
    padding: 0.75rem 1.25rem 1rem;
    overflow-x: auto;
}
.ppb-impl-body pre[class*="language-"] {
    margin: 0;
    border-radius: 10px;
    font-size: 0.82rem;
    max-height: 480px;
    overflow-y: auto;
    overflow-x: auto;
}

.study-header-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.study-split {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    gap: 1.5rem;
    overflow: hidden;
}

.study-theory-pane {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.5rem;
    overflow-y: auto;
    line-height: 1.6;
}

.study-code-pane {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.code-header {
    background-color: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-tabs {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
}

.code-tab {
    padding: 0.4rem 0.85rem;
    border-radius: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    cursor: pointer;
    background-color: transparent;
    border: 1px solid transparent;
    transition: var(--transition-smooth);
    white-space: nowrap;
}

.code-tab.active {
    background-color: rgba(14, 165, 233, 0.1);
    color: #fff;
    border-color: rgba(14, 165, 233, 0.2);
}

.code-body {
    flex-grow: 1;
    overflow-x: auto;
    overflow-y: auto;
    padding: 0;
    margin: 0;
    min-width: 0;
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0.35rem 0.75rem;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition-smooth);
}

.copy-btn:hover {
    color: #fff;
    border-color: var(--border-hover);
}

/* Master Status Widget */
.status-select-btn {
    padding: 0.4rem 0.8rem;
    border-radius: 8px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: var(--transition-smooth);
}

/* Markdown styling inside theory pane */
.markdown-body h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.35rem;
    margin: 1.5rem 0 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
    color: #fff;
}

.markdown-body h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    margin: 1.25rem 0 0.5rem 0;
    color: #fff;
}

.markdown-body ul, .markdown-body ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.markdown-body li {
    margin-bottom: 0.35rem;
}

.markdown-body p {
    margin-bottom: 1rem;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 1rem 0;
}

.markdown-body th, .markdown-body td {
    border: 1px solid var(--border-color);
    padding: 0.65rem 0.85rem;
    font-size: 0.9rem;
    text-align: left;
}

.markdown-body th {
    background-color: rgba(255, 255, 255, 0.02);
    font-weight: 600;
}

/* --- PATTERN QUIZ VIEW --- */
.quiz-container {
    max-width: 800px;
    margin: 0 auto;
}

.quiz-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 2.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.quiz-progress-bar {
    height: 8px;
    background-color: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 2rem;
}

.quiz-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    width: 0%;
    transition: width 0.3s ease;
}

.quiz-question {
    font-size: 1.25rem;
    line-height: 1.6;
    margin-bottom: 2rem;
    font-weight: 500;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.quiz-option {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.quiz-option:hover {
    border-color: var(--border-hover);
    color: #fff;
    background-color: rgba(255, 255, 255, 0.04);
}

.quiz-option.correct {
    background: rgba(16, 185, 129, 0.15) !important;
    border-color: var(--easy) !important;
    color: #fff !important;
}

.quiz-option.wrong {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: var(--hard) !important;
    color: #fff !important;
}

/* --- FLASHCARDS VIEW --- */
.flashcard-wrapper {
    max-width: 600px;
    margin: 0 auto 2.5rem auto;
    perspective: 1000px;
    height: 380px;
}

.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.flashcard.flipped {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 24px;
    padding: 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border: 1px solid var(--border-color);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.flashcard-front {
    background: linear-gradient(135deg, var(--bg-card) 0%, rgba(15, 22, 38, 0.9) 100%);
}

.flashcard-back {
    background: linear-gradient(135deg, rgba(15, 22, 38, 0.9) 0%, var(--bg-card) 100%);
    transform: rotateY(180deg);
}

.flashcard-hint {
    font-size: 0.8rem;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 600;
}

.flashcard-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
    gap: 1rem;
}

.flashcard-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.75rem;
    font-weight: 700;
}

.flashcard-footer {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.flashcard-actions {
    display: flex;
    justify-content: center;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.flashcard-btn {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    color: var(--text-secondary);
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.flashcard-btn:hover {
    color: #fff;
    border-color: var(--border-hover);
}

.flashcard-btn.success-btn:hover {
    background-color: rgba(16, 185, 129, 0.1);
    border-color: var(--easy);
    color: var(--easy);
}

/* --- PATTERN SHORTCUTS VIEW --- */
.shortcuts-layout {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.shortcuts-header-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 1.25rem 2rem;
}

.shortcuts-search {
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 0.65rem 1.25rem;
    color: #fff;
    font-size: 0.95rem;
    width: 320px;
}

.shortcuts-search:focus {
    outline: none;
    border-color: var(--primary);
}

.shortcuts-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
}

.shortcut-box {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 2rem;
}

.checklist-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    background-color: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    margin-bottom: 0.75rem;
    transition: var(--transition-smooth);
    cursor: pointer;
}

.checklist-item:hover {
    border-color: var(--border-hover);
    background-color: rgba(255, 255, 255, 0.02);
}

.checklist-item input {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.checklist-item.checked span {
    text-decoration: line-through;
    color: var(--text-muted);
}

/* Badge Difficulty */
.badge {
    padding: 0.25rem 0.65rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.easy {
    background-color: rgba(16, 185, 129, 0.1);
    color: var(--easy);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge.medium {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--medium);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge.hard {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--hard);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Custom Scrollbars */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* --- STUDY MODE TOGGLE & TAB SWITCHER --- */
.study-mode-toggle {
    display: flex;
    background-color: rgba(0, 0, 0, 0.15);
    border-bottom: 1px solid var(--border-color);
    padding: 2px 2px 0 2px;
}

.mode-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    font-family: 'Outfit', sans-serif;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.mode-tab:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.02);
}

.mode-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    background-color: rgba(255, 255, 255, 0.04);
}

/* --- SANDBOX LAYOUT --- */
.sandbox-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 1.25rem;
    position: relative;
}

.sandbox-editor-container {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

/* CodeMirror Custom Styling to align with Design System */
.CodeMirror {
    height: 380px !important;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', Courier, monospace !important;
    font-size: 0.95rem !important;
    line-height: 1.6 !important;
}

/* Dynamic theming hooks for CodeMirror in dark/light mode */
.cm-s-material-darker.CodeMirror {
    background-color: var(--bg-dark) !important;
    color: var(--text-primary) !important;
}

.cm-s-material-darker .CodeMirror-gutters {
    background-color: var(--bg-sidebar) !important;
    border-right: 1px solid var(--border-color) !important;
}

.cm-s-material-darker .CodeMirror-linenumber {
    color: var(--text-muted) !important;
    opacity: 0.75;
}

.cm-s-material-darker .CodeMirror-cursor {
    border-left: 2px solid var(--primary) !important;
}

.cm-s-material-darker .CodeMirror-selected {
    background-color: var(--primary-glow) !important;
}

.cm-s-material-darker .CodeMirror-activeline-background {
    background-color: rgba(255, 255, 255, 0.02) !important;
}

/* --- SANDBOX CONTROLS --- */
.sandbox-controls {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.sandbox-input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-grow: 1;
}

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

.sandbox-buttons {
    display: flex;
    gap: 0.75rem;
}

/* --- TERMINAL CONSOLE --- */
.sandbox-terminal {
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    background-color: #05080e;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    margin-top: 0.5rem;
}

.terminal-header {
    background-color: #0b111e;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    padding: 0.65rem 1.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    letter-spacing: 0.03em;
}

.terminal-output {
    padding: 1.25rem;
    margin: 0;
    font-family: 'JetBrains Mono', 'Fira Code', 'Courier New', Courier, monospace !important;
    font-size: 0.9rem !important;
    line-height: 1.6 !important;
    color: #e2e8f0;
    background-color: #05080e !important;
    height: 180px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    border: none !important;
    border-radius: 0 !important;
}

/* Terminal log line styles */
.terminal-line {
    display: block;
    margin-bottom: 0.25rem;
}

.terminal-line-success {
    color: var(--easy) !important;
}

.terminal-line-error {
    color: var(--hard) !important;
}

.terminal-line-info {
    color: var(--primary) !important;
}

.terminal-line-warning {
    color: var(--accent) !important;
}

/* --- COMPILER SETTINGS OVERLAY --- */
.sandbox-settings-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(5, 8, 14, 0.7);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 15;
    border-radius: 12px;
    animation: fadeIn 0.2s ease;
}

.settings-content {
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    width: 90%;
    max-width: 380px;
    padding: 1.5rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    animation: scaleUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleUp {
    from {
        transform: scale(0.92);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
    margin-bottom: 1.25rem;
}

.settings-header h4 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
    line-height: 1;
}

.close-btn:hover {
    color: var(--text-primary);
}

.setting-item {
    margin-bottom: 1rem;
}

.setting-item label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    display: block;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* --- CODE BLOCK HIGHLIGHT CORRECTIONS FOR LIGHT THEME --- */
body.theme-light pre[class*="language-"] {
    background: #0f172a; /* Keep dark editor for code, or let it adapt. Usually coders prefer dark code boxes. */
}
body.theme-light .cm-s-material-darker.CodeMirror {
    background-color: #f8fafc !important;
    color: #0f172a !important;
}
body.theme-light .cm-s-material-darker .CodeMirror-gutters {
    background-color: #f1f5f9 !important;
    border-right: 1px solid rgba(0, 0, 0, 0.08) !important;
}
body.theme-light .cm-s-material-darker .CodeMirror-linenumber {
    color: #64748b !important;
}
body.theme-light .cm-s-material-darker .CodeMirror-cursor {
    border-left: 2px solid #4f46e5 !important;
}
body.theme-light .cm-s-material-darker .CodeMirror-selected {
    background-color: rgba(79, 70, 229, 0.15) !important;
}
body.theme-light .cm-s-material-darker .CodeMirror-activeline-background {
    background-color: rgba(0, 0, 0, 0.02) !important;
}
body.theme-light .sandbox-terminal {
    background-color: #020617;
}
body.theme-light .terminal-header {
    background-color: #0f172a;
    color: #94a3b8;
}
body.theme-light .terminal-output {
    background-color: #020617 !important;
}

/* --- CODEMIRROR SYNTAX THEME CUSTOMIZATIONS --- */

/* Light Theme Syntax Highlight */
body.theme-light .cm-s-material-darker .cm-keyword { color: #4f46e5 !important; font-weight: 600; }
body.theme-light .cm-s-material-darker .cm-atom { color: #059669 !important; font-weight: 600; }
body.theme-light .cm-s-material-darker .cm-number { color: #d97706 !important; }
body.theme-light .cm-s-material-darker .cm-def { color: #2563eb !important; }
body.theme-light .cm-s-material-darker .cm-variable { color: #1f2937 !important; }
body.theme-light .cm-s-material-darker .cm-variable-2 { color: #4b5563 !important; }
body.theme-light .cm-s-material-darker .cm-type { color: #0891b2 !important; font-weight: 600; }
body.theme-light .cm-s-material-darker .cm-comment { color: #9ca3af !important; font-style: italic; }
body.theme-light .cm-s-material-darker .cm-string { color: #059669 !important; }
body.theme-light .cm-s-material-darker .cm-operator { color: #4b5563 !important; }
body.theme-light .cm-s-material-darker .cm-builtin { color: #7c3aec !important; }
body.theme-light .cm-s-material-darker .cm-meta { color: #9333ea !important; }

/* Cyberpunk Neon Syntax Highlight */
body.theme-cyberpunk .cm-s-material-darker .cm-keyword { color: #FF007F !important; font-weight: 600; text-shadow: 0 0 4px rgba(255, 0, 127, 0.4); }
body.theme-cyberpunk .cm-s-material-darker .cm-atom { color: #FFE600 !important; font-weight: 600; }
body.theme-cyberpunk .cm-s-material-darker .cm-number { color: #00F0FF !important; }
body.theme-cyberpunk .cm-s-material-darker .cm-def { color: #00F0FF !important; font-weight: 600; }
body.theme-cyberpunk .cm-s-material-darker .cm-variable { color: #ECEFF4 !important; }
body.theme-cyberpunk .cm-s-material-darker .cm-variable-2 { color: #00F0FF !important; }
body.theme-cyberpunk .cm-s-material-darker .cm-type { color: #FFE600 !important; font-weight: 600; }
body.theme-cyberpunk .cm-s-material-darker .cm-comment { color: #707A8A !important; font-style: italic; }
body.theme-cyberpunk .cm-s-material-darker .cm-string { color: #39FF14 !important; text-shadow: 0 0 4px rgba(57, 255, 20, 0.4); }
body.theme-cyberpunk .cm-s-material-darker .cm-operator { color: #FF007F !important; }
body.theme-cyberpunk .cm-s-material-darker .cm-builtin { color: #FFE600 !important; }
body.theme-cyberpunk .cm-s-material-darker .cm-meta { color: #00F0FF !important; }

/* Forest Emerald Syntax Highlight */
body.theme-forest .cm-s-material-darker .cm-keyword { color: #10B981 !important; font-weight: 600; }
body.theme-forest .cm-s-material-darker .cm-atom { color: #F59E0B !important; font-weight: 600; }
body.theme-forest .cm-s-material-darker .cm-number { color: #34D399 !important; }
body.theme-forest .cm-s-material-darker .cm-def { color: #6EE7B7 !important; }
body.theme-forest .cm-s-material-darker .cm-variable { color: #F0FDFA !important; }
body.theme-forest .cm-s-material-darker .cm-variable-2 { color: #34D399 !important; }
body.theme-forest .cm-s-material-darker .cm-type { color: #10B981 !important; font-weight: 600; }
body.theme-forest .cm-s-material-darker .cm-comment { color: #5F9A87 !important; font-style: italic; }
body.theme-forest .cm-s-material-darker .cm-string { color: #FBBF24 !important; }
body.theme-forest .cm-s-material-darker .cm-operator { color: #10B981 !important; }
body.theme-forest .cm-s-material-darker .cm-builtin { color: #34D399 !important; }
body.theme-forest .cm-s-material-darker .cm-meta { color: #F59E0B !important; }

/* Reference Links Buttons */
.ref-btn {
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    cursor: pointer;
    text-decoration: none;
    margin-left: 0.75rem;
    vertical-align: middle;
    transition: var(--transition-smooth);
}

.ref-btn.leetcode-btn {
    background-color: rgba(245, 158, 11, 0.08);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.ref-btn.leetcode-btn .btn-icon {
    width: 11px;
    height: 11px;
    stroke-width: 2.8;
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ref-btn.leetcode-btn:hover {
    background-color: rgba(245, 158, 11, 0.16);
    border-color: rgba(245, 158, 11, 0.5);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.15), 0 0 1px rgba(245, 158, 11, 0.5);
    transform: translateY(-1.5px);
}

.ref-btn.leetcode-btn:hover .btn-icon {
    transform: translate(1px, -1px);
}

/* --- PWA OFFLINE / ONLINE NOTIFICATION BANNERS --- */
.status-banner {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: 12px;
    font-weight: 500;
    font-size: 0.95rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.1);
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.4s ease;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.status-banner.visible {
    transform: translateY(0);
    opacity: 1;
}

.status-banner.offline-banner {
    background-color: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.status-banner.offline-banner svg {
    color: #ef4444;
}

.status-banner.online-banner {
    background-color: rgba(16, 185, 129, 0.12);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #a7f3d0;
}

.status-banner.online-banner svg {
    color: #10b981;
}

/* ═══════════════════════════════════════════════════════════
   STUDY CENTER REDESIGN
═══════════════════════════════════════════════════════════ */

/* Sticky toolbar at top of theory pane */
.sc-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255,255,255,0.01);
    flex-shrink: 0;
    gap: 1rem;
    flex-wrap: wrap;
}

/* "Practice Arena" gradient button in toolbar */
.sc-practice-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    white-space: nowrap;
    transition: filter 0.15s, transform 0.1s;
    box-shadow: 0 2px 10px rgba(14,165,233,0.25);
}
.sc-practice-btn:hover { filter: brightness(1.08); }
.sc-practice-btn:active { transform: scale(0.97); }

/* Tab bar */
.sc-tab-bar {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255,255,255,0.015);
    flex-shrink: 0;
}
.sc-tab {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.65rem 1.1rem;
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    color: var(--text-secondary);
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.sc-tab:hover { color: #fff; background: rgba(255,255,255,0.02); }
.sc-tab.active {
    color: #fff;
    border-bottom-color: var(--primary);
    background: rgba(255,255,255,0.02);
}

/* Scrollable content area inside the tab */
.sc-tab-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}
.sc-theory-body {
    max-width: 900px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Code block in template tab */
.sc-code-block {
    background: rgba(0,0,0,0.35);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    font-size: 0.78rem;
    line-height: 1.7;
    overflow-x: auto;
    overflow-y: visible;
    margin: 0;
}

/* ── Related Problems section ────────────────────────── */
.rp-section {
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px;
    background: rgba(255,255,255,0.015);
    padding: 1.1rem 1.25rem;
}
.rp-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 0.5rem;
}
.rp-section-title {
    font-family: 'Outfit', sans-serif;
    font-size: 0.8rem;
    font-weight: 800;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.rp-goto-btn {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary);
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 0;
    font-family: 'Outfit', sans-serif;
    transition: opacity 0.15s;
}
.rp-goto-btn:hover { opacity: 0.8; text-decoration: underline; }

/* 2-column problem card grid */
.rp-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 0.85rem;
}
.rp-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 14px;
    padding: 0.85rem 1rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.1s;
}
.rp-card:hover {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.12);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    transform: translateY(-1px);
}

/* Difficulty badges inside rp-cards */
.rp-badge {
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    padding: 0.15rem 0.45rem;
    border-radius: 5px;
    white-space: nowrap;
    flex-shrink: 0;
}
.rp-badge.rp-easy   { background: rgba(16,185,129,0.12); color: #34d399; border: 1px solid rgba(52,211,153,0.25); }
.rp-badge.rp-medium { background: rgba(245,158,11,0.12);  color: #f59e0b; border: 1px solid rgba(245,158,11,0.25); }
.rp-badge.rp-hard   { background: rgba(239,68,68,0.12);   color: #f87171; border: 1px solid rgba(248,113,113,0.25); }

/* ═══════════════════════════════════════════════════════════
   PRACTICE VIEW REDESIGN
═══════════════════════════════════════════════════════════ */

/* Action link buttons in pattern header */
.ppb-action-link {
    font-size: 0.75rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    padding: 0.3rem 0.75rem;
    border-radius: 9px;
    border: 1px solid;
    text-decoration: none;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: background 0.15s, filter 0.15s;
}
.ppb-action-link:hover { filter: brightness(1.15); }
.ppb-action-primary {
    color: var(--primary);
    border-color: rgba(14,165,233,0.3);
}
.ppb-action-primary:hover { background: rgba(14,165,233,0.1); }

/* Color-coded status dropdown */
.ppb-status {
    font-size: 0.72rem;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
    padding: 0.3rem 0.75rem;
    border-radius: 10px;
    cursor: pointer;
    border: 1px solid;
    outline: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    appearance: auto;
}
.ppb-status-notstarted {
    background: rgba(255,255,255,0.03);
    border-color: var(--border-color);
    color: var(--text-secondary);
}
.ppb-status-inprogress {
    background: rgba(245,158,11,0.12);
    border-color: rgba(245,158,11,0.35);
    color: #f59e0b;
}
.ppb-status-mastered {
    background: rgba(52,211,153,0.12);
    border-color: rgba(52,211,153,0.35);
    color: #34d399;
}

/* details/summary for reference implementation */
.ppb-impl > summary {
    padding: 0.65rem 1rem;
    border-radius: 10px;
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.07);
    cursor: pointer;
    font-size: 0.78rem;
    color: var(--text-secondary);
    font-weight: 600;
    list-style: none;
    transition: background 0.15s;
    user-select: none;
}
.ppb-impl > summary:hover { background: rgba(255,255,255,0.04); color: #fff; }
.ppb-impl[open] > summary { border-radius: 10px 10px 0 0; border-bottom-color: transparent; }

/* ── Code Template variation cards ──────────────────────── */
.sc-variation-card {
    background: rgba(255,255,255,0.02);
    border: 1px solid rgba(255,255,255,0.07);
    border-radius: 14px;
    overflow: hidden;
    transition: border-color 0.15s;
}
.sc-variation-card[open] {
    border-color: rgba(14,165,233,0.25);
}
.sc-variation-card > summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.8rem 1rem;
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: background 0.15s;
}
.sc-variation-card > summary:hover { background: rgba(255,255,255,0.03); }
.sc-variation-card > summary::-webkit-details-marker { display: none; }
.sc-variation-card[open] > summary { background: rgba(14,165,233,0.04); }
