/* --- GLOBAL RESET & BOX SIZING FIX --- */
* {
    box-sizing: border-box; /* CRITICAL: Prevents padding from breaking width */
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--bg-page);
}

:root {
    /* DARK MODE (DEFAULT) VARIABLES */
    --bg-page: #121212;
    --bg-card: #1e1e1e;
    --bg-problem: #37474f;
    --bg-icon-strip: #181818;
    
    --text-primary: #e0e0e0;
    --text-muted: #a0a0a0;
    --text-hint: #e1bee7;
    
    --accent-blue: #64b5f6;
    --border-tryit: #00bfa5;
    --state-success: #66bb6a;
    --state-error: #ef5350;
    --highlight-math: #ff4081; 
    --text-annotation: #ffcc80; 
    --border-hint: #ba68c8;
    --video-accent: #ff5252; 
    
    --scrollbar-thumb: #333;
    --scrollbar-hover: #555;
}

/* LIGHT MODE OVERRIDES */
body.light-mode {
    --bg-page: #ffffff; 
    --bg-card: #f9f9f9; 
    --bg-problem: #e3f2fd; 
    --bg-icon-strip: #f0f0f0;
    
    --text-primary: #212121;
    --text-muted: #616161;
    --text-hint: #7b1fa2;
    
    --accent-blue: #1976d2; 
    --border-tryit: #00796b;
    --state-success: #2e7d32;
    --state-error: #c62828;
    --highlight-math: #d81b60; 
    --text-annotation: #e65100; 
    --border-hint: #8e24aa;
    --video-accent: #d32f2f;

    --scrollbar-thumb: #bbb;
    --scrollbar-hover: #999;
}

/* RESET & LAYOUT STRUCTURE */
body {
    font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    overflow: hidden; 
    height: 100vh;
    width: 100vw;
    transition: background-color 0.3s, color 0.3s;
}

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-page);
}
::-webkit-scrollbar-thumb {
    background-color: var(--scrollbar-thumb);
    border-radius: 4px;
    border: 2px solid var(--bg-page);
}
::-webkit-scrollbar-thumb:hover {
    background-color: var(--scrollbar-hover);
}

/* --- NEW: LEFT SIDEBAR (HAMBURGER MENU) --- */
.left-sidebar {
    position: relative;
    top: 0;
    left: 0;
    width: 12vw;
    min-width: 144px;
    max-width: 210px;
    height: 100%;
    background-color: var(--bg-card);
    border-right: 1px solid #444;
    z-index: 100;
    transition: width 0.3s ease;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    flex-shrink: 0;
}

.left-sidebar.open {
    left: 0; /* Slide in */
}
body.light-mode .left-sidebar {
    border-right-color: #ddd;
    box-shadow: 5px 0 15px rgba(0,0,0,0.1);
}

.ls-header {
    padding: 0;
    background: var(--bg-icon-strip);
    font-weight: bold;
    font-size: 1.05rem;
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--accent-blue);
    overflow: hidden;
}

.sidebar-logo {
    max-width: 100%;
    width: 100%;
    height: 67px;
    display: block;
    object-fit: cover;
    object-position: center 45%;
    content: url('logo/logo_dark.jpeg');
}

body.light-mode .sidebar-logo {
    content: url('logo/logo.jpeg');
}

/* --- Search Bar Styles --- */
.ls-search-container {
    padding: 10px 15px;
    background: var(--bg-icon-strip);
    border-bottom: 1px solid #444;
}
body.light-mode .ls-search-container { border-bottom-color: #ddd; }

#ls-search-input {
    width: 100%;
    padding: 6px 8px;
    border-radius: 6px;
    border: 1px solid #555;
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
    font-size: 0.75rem;
    transition: all 0.2s;
}

#ls-search-input:focus {
    outline: none;
    border-color: var(--accent-blue);
    background: rgba(255,255,255,0.15);
}

body.light-mode #ls-search-input {
    background: #fff;
    border-color: #ccc;
    color: #000;
}

.ls-close-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    display: none;
}
.ls-close-btn:hover { color: var(--state-error); }

.ls-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

/* --- Sidebar Footer --- */
.ls-footer {
    margin-top: auto;
    padding: 10px 8px;
    background: transparent;
}
body.light-mode .ls-footer {
    background: transparent;
}

.reset-progress-btn {
    width: 100%;
    padding: 10px;
    background: rgba(239, 83, 80, 0.1);
    color: var(--state-error);
    border: 1px solid var(--state-error);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: bold;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 0.7rem;
}
.reset-progress-btn:hover {
    background: var(--state-error);
    color: #fff;
}

/* Developer Menu Dropdown Styles */
.dev-menu-header {
    font-size: 0.65rem;
    color: var(--accent-blue);
    font-weight: bold;
    margin-bottom: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    transition: all 0.2s;
}

.dev-menu-header:hover {
    color: var(--accent-blue);
    opacity: 0.8;
}

.dev-menu-toggle {
    width: 14px;
    height: 14px;
    display: inline-block;
    transition: transform 0.2s;
}

.dev-menu-toggle.open {
    transform: rotate(180deg);
}

.dev-menu-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.dev-menu-content.open {
    max-height: 200px;
}

.dev-menu-content button {
    margin-bottom: 8px;
}

/* --- Sidebar Categories --- */
.ls-category-header {
    padding: 10px 8px 3px 8px;
    color: var(--accent-blue);
    font-weight: bold;
    font-size: 0.65rem;
    text-transform: uppercase;
    border-bottom: 2px solid #444;
    margin-top: 3px;
    background: var(--bg-card);
    position: sticky;
    top: 0;
}

/* Updated Item (With Indentation) */
.ls-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding: 6px 8px;
    background: transparent;
    border: none;
    border-bottom: 1px solid #333;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.7rem;
    gap: 6px;
}

.ls-item-name {
    flex: 1;
    text-align: left;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ls-item-topic {
    flex-shrink: 0;
    text-align: right;
    white-space: nowrap;
}
body.light-mode .ls-item { border-bottom-color: #ddd; }

.ls-item:hover {
    background: rgba(100, 181, 246, 0.1);
    padding-left: 10px;
    color: var(--accent-blue);
}

.ls-item.active {
    background: rgba(100, 181, 246, 0.2);
    color: var(--accent-blue);
    border-left: 3px solid var(--accent-blue);
    padding-left: 5px;
    box-shadow: inset 0 0 15px rgba(100, 181, 246, 0.15);
    font-weight: 500;
}

/* Hamburger Button */
.hamburger-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 50;
    background: var(--bg-card);
    border: 1px solid #444;
    color: var(--text-primary);
    padding: 8px;
    border-radius: 8px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.hamburger-btn:hover {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.layout-wrapper {
    display: flex;
    height: 100%;
    width: 100%;
}

/* --- COLUMN 1: MAIN CONTENT PANE --- */
.main-content-pane {
    flex: 1; 
    height: 100%;
    display: flex;
    flex-direction: column; 
    position: relative;
    background-color: var(--bg-page);
    min-width: 300px;
    overflow: hidden;
}

.scroll-area {
    flex: 1; 
    overflow-y: auto;
    padding: 0;
    position: relative;
}

/* --- RESIZER HANDLE --- */
.resizer {
    width: 5px;
    height: 100%;
    background: #444;
    cursor: col-resize;
    z-index: 150;
    transition: background 0.2s;
    display: none; 
}
.resizer:hover, .resizer.active {
    background: var(--accent-blue);
}

/* --- COLUMN 2: SIDE PANEL (COLLAPSIBLE) --- */
.side-panel-pane {
    width: 0; 
    height: 100%;
    background-color: var(--bg-card); 
    display: flex;
    flex-direction: column;
    border-left: 1px solid #444;
    overflow: hidden;
    position: relative;
}
body.light-mode .side-panel-pane { border-left-color: #ddd; }

.side-panel-pane.animated {
    transition: width 0.3s ease;
}

/* Panel Content Containers */
.panel-content {
    width: 100%;
    height: 100%;
    display: none; 
    overflow-y: auto;
    min-width: 0; 
}
.panel-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.desmos-frame {
    width: 100%;
    height: 100%;
    border: none;
}

/* Book & Answer Key Specifics */
#panel-concepts-sidebar, #panel-answers-content {
    padding: 20px;
    box-sizing: border-box;
    min-height: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    color: var(--text-primary);
    width: 100%;
    max-width: 100%;
}

/* AGGRESSIVE TEXT WRAPPING FOR SIDEBAR CONCEPTS */
.side-concept-item {
    background: rgba(128, 128, 128, 0.1);
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 15px;
    border-left: 3px solid var(--accent-blue);
    
    overflow-wrap: anywhere;
    word-break: break-word; 
    white-space: normal;
    max-width: 100%;
}

/* --- BOOK TAB FEATURES (Search & Pin) --- */

/* 1. Sticky Header Container */
.book-sticky-header {
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 10;
    padding-bottom: 10px;
    border-bottom: 2px solid #333;
    margin-bottom: 15px;
}
body.light-mode .book-sticky-header {
    border-bottom-color: #ccc;
}

/* 2. Search Bar */
.book-search-input {
    width: 100%;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #555;
    color: var(--text-primary);
    border-radius: 6px;
    margin-top: 10px;
    font-family: inherit;
}
.book-search-input:focus {
    outline: none;
    border-color: var(--accent-blue);
}
body.light-mode .book-search-input {
    background: #fff;
    border-color: #ccc;
}

/* 3. Pinned Section */
#book-pinned-container {
    display: none;
    background: rgba(255, 215, 0, 0.05);
    border: 1px solid #ffd700;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 10px;
    max-height: 200px;
    overflow-y: auto;
}

/* 4. Pin Button Styling */
.pin-btn {
    float: right;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    opacity: 0.3;
    transition: all 0.2s;
    margin-left: 10px;
    filter: grayscale(100%);
}
.pin-btn:hover { opacity: 1; transform: scale(1.1); filter: grayscale(0%); }
.pin-btn.active { opacity: 1; filter: grayscale(0%); text-shadow: 0 0 5px gold; }

/* Adjust card styling to fit the pin button in the header */
.side-concept-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.side-concept-header {
    color: var(--accent-blue);
    font-weight: bold;
    margin-bottom: 5px;
    font-size: 0.95rem;
    text-transform: uppercase;
    overflow-wrap: anywhere;
    white-space: normal;
}

.answer-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.answer-list li {
    padding: 8px 0;
    border-bottom: 1px solid #444;
    display: flex;
    gap: 10px;
    font-size: 0.95rem;
}
body.light-mode .answer-list li { border-bottom-color: #ddd; }

.answer-list li strong {
    color: var(--state-success);
    min-width: 30px;
}

/* SCRATCHPAD STYLES */
#panel-scratch {
    display: none;
    flex-direction: column;
    background: #121212 !important; 
    height: 100%;
}

.scratch-toolbar {
    height: 50px;
    background: #1e1e1e;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    border-bottom: 1px solid #333;
    flex-shrink: 0;
}

.tool-btn {
    background: #333;
    border: 1px solid #555;
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.tool-btn:hover { background: #555; }
.tool-btn:active { transform: scale(0.95); }

.tool-btn.active-tool {
    background: var(--accent-blue);
    color: #fff;
    border-color: var(--accent-blue);
}
.tool-btn svg { width: 18px; height: 18px; stroke: currentColor; stroke-width: 2; fill: none; }

#scratch-canvas {
    flex-grow: 1;
    cursor: crosshair;
    touch-action: none;
    display: block;
}

/* --- SCRATCHPAD BACKGROUNDS --- */

/* Mode 1: Large Grid (Notebook) */
#scratch-canvas.bg-grid {
    background-image: 
        linear-gradient(#333 1px, transparent 1px),
        linear-gradient(90deg, #333 1px, transparent 1px);
    background-size: 40px 40px;
    background-position: -1px -1px;
}

/* Mode 2: Fine Graph Paper */
#scratch-canvas.bg-graph {
    background-image: 
        linear-gradient(#333 1px, transparent 1px),
        linear-gradient(90deg, #333 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: -1px -1px;
}

/* --- COLUMN 3: ICON STRIP (FIXED) --- */
.icon-strip-pane {
    width: 39px;
    height: 100%;
    background-color: var(--bg-icon-strip);
    border-left: 1px solid #444;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    padding-bottom: 0px;
    z-index: 200;
    flex-shrink: 0;
    box-sizing: border-box;
}
body.light-mode .icon-strip-pane { border-left-color: #ddd; }

.icon-group-top {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.icon-group-bottom {
    margin-top: auto; 
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.icon-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 10px;
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
    margin-bottom: 15px;
    color: var(--text-muted);
    width: 44px;
    height: 44px;
}
.icon-btn:hover {
    background-color: rgba(128,128,128,0.2);
    color: var(--text-primary);
}
.icon-btn.active {
    background-color: rgba(100, 181, 246, 0.2);
    color: var(--accent-blue);
}
.icon-btn svg {
    width: 24px;
    height: 24px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}

/* Container & Layout */
.app-container {
    max-width: 960px;
    width: 100%;
    box-sizing: border-box;
    margin: 0 auto;
    padding: 10px 20px 60px 20px;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Header */
header {
    margin: -10px -20px 0 -20px;
    text-align: center;
    background: transparent;
    padding: 8px 35px;
    border-radius: 0;
    box-sizing: border-box;
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}
body.light-mode header {
    background: transparent;
}
h1 {
    color: #ffffff;
    font-size: 2rem;
    margin: 0;
}
body.light-mode h1 {
    color: #ffffff;
}
.subtitle {
    color: var(--accent-blue);
    font-weight: bold;
    font-size: 0.65rem;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 0 0 auto;
    letter-spacing: 0.5px;
}

.subtitle-class {
    color: var(--accent-blue);
    font-weight: bold;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 0 0 auto;
    display: none;
}

.subtitle-topic {
    color: var(--accent-blue);
    font-weight: bold;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 0 0 auto;
    display: none;
}

/* Navigation */
nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(8px);
    padding: 8px 0 25px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    min-height: 50px;
}
body.light-mode nav {
    background: rgba(255, 255, 255, 0.85);
    border-color: #ddd;
}

/* Position subtitles outside the centered buttons */
nav > .subtitle-class {
    position: absolute;
    left: 20px;
}

nav > .subtitle-topic {
    position: absolute;
    right: 20px;
}

.nav-btn {
    background: transparent;
    border: 1px solid var(--accent-blue);
    color: var(--text-primary);
    padding: 8px 24px;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}
.nav-btn:hover {
    background: rgba(100, 181, 246, 0.1);
}
.nav-btn.active {
    background: var(--accent-blue);
    color: #fff;
    box-shadow: 0 0 15px rgba(100, 181, 246, 0.3);
    font-weight: 600;
}

/* Views */
.view-section {
    display: none;
    animation: fadeIn 0.4s ease;
    width: 100%;
}
.view-section.active {
    display: block;
}

#home-view.active {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Concept Box */
.concept-box {
    background: linear-gradient(135deg, #1e3c72, #2a5298);
    border-left: 5px solid var(--accent-blue);
    padding: 25px;
    border-radius: 8px;
    margin-bottom: 40px;
    color: #fff; 
}
body.light-mode .concept-box {
    background: linear-gradient(135deg, #A8DADC, #85B8D0);
    color: #fff;
}
.concept-title {
    font-size: 1.2rem;
    font-weight: bold;
    color: #fff;
    margin-bottom: 15px;
    text-transform: uppercase;
}
.concept-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}
.concept-item {
    background: rgba(0,0,0,0.2);
    padding: 20px;
    border-radius: 8px;
    
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

.concept-item .MathJax {
    text-align: center;
}

.concept-item strong {
    font-size: 1.1rem;
    margin-bottom: 10px;
    display: block;
    color: #ffffff;
}

/* Worked Example Card */
.example-card {
    background-color: var(--bg-card);
    border-radius: 8px;
    margin-bottom: 40px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    border: 1px solid #444;
}
body.light-mode .example-card { border-color: #ddd; }

.example-header {
    padding: 15px 25px;
    border-bottom: 1px solid #444;
    color: var(--accent-blue);
    font-weight: bold;
    text-transform: uppercase;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
body.light-mode .example-header { border-bottom-color: #ddd; }

.problem-box {
    background-color: var(--bg-problem);
    padding: 20px 25px;
    font-size: 1.1rem;
    border-bottom: 1px solid #444;
    color: var(--text-primary);
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}

/* Dynamic Image Styling */
.content-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 15px auto;
    border-radius: 6px;
    border: 1px solid #444;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
}
body.light-mode .content-image {
    border-color: #ccc;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

body.light-mode .problem-box { border-bottom-color: #ddd; }

.step-container {
    padding: 20px 25px;
}
.step {
    border-left: 2px solid #666;
    padding-left: 20px;
    margin-bottom: 20px;
}
body.light-mode .step { border-left-color: #ccc; }

.step:last-child { margin-bottom: 0; }
.step-math {
    font-size: 1.1rem;
    margin-bottom: 5px;
}
.step-annotation {
    color: var(--text-annotation);
    font-style: italic;
    font-size: 0.9rem;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}
.alg-move {
    color: var(--highlight-math);
    font-weight: bold;
}

/* Try It Section */
.try-it-container {
    border: 2px solid var(--border-tryit);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 50px;
    position: relative;
}
.try-it-label {
    position: absolute;
    top: -12px;
    left: 20px;
    background: var(--bg-page);
    color: var(--border-tryit);
    padding: 0 10px;
    font-weight: bold;
    font-size: 0.9rem;
}

/* Interactive Question Card */
.question-card {
    background-color: var(--bg-card);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 30px;
    border: 1px solid #444;
}
body.light-mode .question-card { border-color: #ddd; }

.q-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 1px solid #444;
    padding-bottom: 10px;
    position: relative;
}
body.light-mode .q-header { border-bottom-color: #ddd; }

.q-num {
    font-weight: bold;
    color: var(--text-muted);
}
.q-tag {
    font-size: 0.8rem;
    border: 1px solid var(--accent-blue);
    color: var(--accent-blue);
    padding: 2px 8px;
    border-radius: 4px;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    white-space: nowrap;
}
/* --- NEW: Clickable Tag Styles --- */
.q-tag.clickable {
    cursor: pointer;
    background: rgba(100, 181, 246, 0.1);
    transition: all 0.2s ease;
}
.q-tag.clickable:hover {
    background: var(--accent-blue);
    color: #fff;
    box-shadow: 0 0 10px rgba(100, 181, 246, 0.4);
}

/* --- NEW: Sidebar Example Styling --- */
.sidebar-ex-card {
    border: 1px solid #444;
    border-radius: 6px;
    margin-bottom: 20px;
    background: rgba(0,0,0,0.2);
    overflow: hidden;
}
body.light-mode .sidebar-ex-card {
    border-color: #ccc;
    background: rgba(255,255,255,0.5);
}

.sidebar-ex-header {
    background: #2a2a2a;
    padding: 10px;
    font-weight: bold;
    color: var(--accent-blue);
    font-size: 0.9rem;
    border-bottom: 1px solid #444;
}
body.light-mode .sidebar-ex-header {
    background: #e0e0e0;
    border-bottom-color: #ccc;
}
.q-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* BOOKMARK BUTTON STYLES */
.bookmark-btn {
    background: transparent;
    border: 1px solid #60bd79;
    cursor: pointer;
    color: #60bd79;
    padding: 0;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.bookmark-btn:hover {
    background: #60bd79;
    color: #fff;
    box-shadow: 0 0 8px #60bd79;
}
.bookmark-btn.active {
    background: #60bd79;
    color: #fff;
    border-color: #60bd79;
}
.bookmark-btn svg {
    width: 16px;
    height: 16px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
}
.bookmark-btn.active svg {
    fill: currentColor;
}

/* VIDEO FEATURES */
.video-toggle-btn {
    background: transparent;
    border: 1px solid var(--video-accent);
    color: var(--video-accent);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.video-toggle-btn:hover {
    background: var(--video-accent);
    color: #fff;
    box-shadow: 0 0 8px var(--video-accent);
}
.video-toggle-btn svg { width: 14px; height: 14px; fill: currentColor; }

.video-panel {
    display: none;
    margin-top: 15px;
    margin-bottom: 15px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}
.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
}
.video-container iframe, .video-container video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}
.video-fallback-link {
    display: block;
    text-align: center;
    color: var(--video-accent);
    padding: 8px;
    font-size: 0.9rem;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.05);
    border-top: 1px solid #333;
}
.video-fallback-link:hover {
    text-decoration: underline;
    background: rgba(255, 255, 255, 0.1);
}

.hint-toggle-btn {
    background: transparent;
    border: 1px solid var(--border-hint);
    color: var(--text-hint);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}
.hint-toggle-btn:hover {
    background: var(--border-hint);
    color: #fff;
    box-shadow: 0 0 8px var(--border-hint);
}
.hint-toggle-btn svg { width: 16px; height: 16px; stroke: currentColor; stroke-width: 2; fill: none; }

.q-body {
    font-size: 1.1rem;
    margin-bottom: 20px;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: normal;
}
.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 20px;
}
@media (max-width: 600px) {
    .options-grid { grid-template-columns: 1fr; }
    .side-panel-pane { display: none !important; }
    .resizer { display: none !important; }
}
.opt-btn {
    background: transparent;
    border: 1px solid #666;
    color: var(--text-primary);
    padding: 15px;
    border-radius: 6px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
    font-size: 1rem;
}
body.light-mode .opt-btn { border-color: #ccc; }

.opt-btn:hover:not(:disabled) {
    background: rgba(128,128,128,0.1);
    border-color: var(--text-primary);
}
.opt-btn.selected {
    border-color: var(--accent-blue);
    background: rgba(100, 181, 246, 0.1);
}
.opt-btn.correct {
    background: rgba(102, 187, 106, 0.2) !important;
    border-color: var(--state-success) !important;
}
.opt-btn.wrong {
    background: rgba(239, 83, 80, 0.2) !important;
    border-color: var(--state-error) !important;
    opacity: 0.7;
}

.check-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent-blue);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
}
.check-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* --- Lock Screen Input Styles --- */
.lock-input {
    background: rgba(255,255,255,0.05);
    border: 1px solid #555;
    color: var(--text-primary);
    padding: 12px;
    border-radius: 6px;
    width: 100%;
    max-width: 200px;
    margin-bottom: 10px;
    text-align: center;
    font-size: 1rem;
}
.lock-input:focus {
    border-color: var(--accent-blue);
    outline: none;
    background: rgba(255,255,255,0.1);
}
body.light-mode .lock-input {
    background: #fff;
    border-color: #ccc;
    color: #000;
}

.feedback-panel {
    margin-top: 20px;
    padding: 15px;
    border-radius: 6px;
    display: none;
    animation: fadeIn 0.3s ease;
}
.hint-panel {
    background: rgba(225, 190, 231, 0.1);
    border: 1px solid var(--border-hint);
    color: var(--text-hint);
}
.hint-text-item { margin-bottom: 8px; font-size: 0.95rem; }
.hint-more-btn {
    background: none;
    border: none;
    color: var(--accent-blue);
    cursor: pointer;
    text-decoration: underline;
    font-size: 0.9rem;
    padding: 0;
    margin-top: 5px;
    font-family: inherit;
}
.hint-more-btn:hover { color: var(--text-primary); }

.solution-panel {
    background: rgba(102, 187, 106, 0.1);
    border: 1px solid var(--state-success);
    color: var(--text-primary);
}
.sol-header {
    color: var(--state-success);
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 10px;
    text-transform: uppercase;
}

/* COMPACT PROGRESS BAR FOOTER */
#global-progress {
    background: var(--bg-icon-strip);
    border-top: 1px solid #444;
    padding: 6px 15px;
    box-sizing: border-box;
    width: 100%;
}

/* Row 1: Progress Track (no percentage) */
.progress-top-row {
    text-align: center;
    margin-bottom: 6px;
}
.percent-text {
    color: var(--text-muted);
    font-weight: bold;
    font-size: 0.75rem;
    text-align: center;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}
.progress-track {
    height: 4px;
    background: #444;
    border-radius: 2px;
    overflow: hidden;
    width: 100%;
}
body.light-mode .progress-track { background: #ccc; }
.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--accent-blue), #ba68c8);
    transition: width 0.5s ease;
}

/* Row 2: Emojis (left) | Percentage (center) | Stats (right) */
.progress-bottom-row {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    margin-top: 5px;
    font-size: 0.75rem;
    color: var(--text-muted);
    font-weight: bold;
    gap: 10px;
    position: relative;
}

.rewards-container {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.stats-column {
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: center;
    margin-left: auto;
}

.stat-box { 
    min-width: auto;
    text-align: left;
}

/* Compact Rewards */
.reward-item {
    opacity: 0.3; 
    filter: grayscale(100%);
    transition: all 0.5s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    color: var(--text-primary);
    font-size: 0.75rem;
}
.reward-item span { font-size: 1.2rem; }

.reward-item.revealed {
    opacity: 1;
    filter: grayscale(0%);
    transform: translateY(-1px);
    text-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

/* Data Loader Overlay */
#data-loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-page);
    z-index: 5000;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: var(--text-primary);
}
.loader-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 12px;
    border: 1px solid var(--accent-blue);
    text-align: center;
    max-width: 500px;
    width: 90%;
}
.loader-title { font-size: 1.5rem; color: var(--accent-blue); margin-bottom: 20px; }
.file-btn-wrapper {
    position: relative;
    overflow: hidden;
    display: inline-block;
    margin-top: 20px;
}
.btn-upload {
    border: 2px solid var(--text-muted);
    color: var(--text-muted);
    background-color: transparent;
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 10px;
    font-size: 0.9rem;
}
.btn-upload:hover { border-color: var(--accent-blue); color: var(--accent-blue); }

select.lesson-select {
    background: var(--bg-page);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--accent-blue);
    font-size: 1rem;
    width: 100%;
    margin-bottom: 15px;
}
.btn-load-selected {
    background: var(--accent-blue);
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1.1rem;
    width: 100%;
}
.btn-load-selected:hover { filter: brightness(1.1); }

.divider {
    margin: 25px 0;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.divider::before, .divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #666;
}

#xml-file-input {
    position: absolute;
    font-size: 100px;
    opacity: 0;
    right: 0;
    top: 0;
    cursor: pointer;
}

/* --- LOGIN/REGISTER UI --- */
.login-section {
    padding: 2px 15px;
    margin: 10px 0;
}

.login-button-group {
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    gap: 0;
    margin-bottom: 2px;
}

.login-btn {
    text-align: left;
    padding: 4px 0;
    border: none;
    border-radius: 0;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.6rem;
    background: transparent;
    color: var(--accent-blue);
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.register-btn {
    text-align: right;
    padding: 4px 0;
    border: none;
    border-radius: 0;
    cursor: pointer;
    font-weight: bold;
    font-size: 0.6rem;
    background: transparent;
    color: var(--accent-blue);
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.login-btn:hover, .register-btn:hover {
    background: transparent;
    color: var(--accent-blue);
    opacity: 0.8;
    transform: none;
}

.user-info {
    background: rgba(100, 181, 246, 0.1);
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 10px;
    text-align: center;
}

.user-info p {
    margin: 5px 0;
    font-size: 0.85rem;
    color: var(--accent-blue);
}

.logout-btn {
    width: 100%;
    padding: 8px;
    background: #ef5350;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: #e53935;
}

/* Login/Register Modal */
.auth-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.auth-modal.active {
    display: flex;
}

.auth-modal-content {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    border: 1px solid #444;
}

.auth-modal-content h2 {
    color: var(--accent-blue);
    margin-bottom: 20px;
    text-align: center;
}

.auth-modal-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 1px solid #444;
}

.auth-modal-tab {
    flex: 1;
    padding: 10px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-weight: bold;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.auth-modal-tab.active {
    color: var(--accent-blue);
    border-bottom-color: var(--accent-blue);
}

.auth-form-group {
    display: none;
}

.auth-form-group.active {
    display: block;
}

.auth-form-group input {
    width: 100%;
    padding: 12px;
    margin-bottom: 15px;
    background: #2a2a2a;
    border: 1px solid #444;
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1rem;
}

.auth-form-group input:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 10px rgba(100, 181, 246, 0.3);
}

.password-strength {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
    font-size: 0.8rem;
}

.password-strength label {
    flex-shrink: 0;
}

.strength-bar {
    flex: 1;
    height: 4px;
    background: #444;
    border-radius: 2px;
    overflow: hidden;
}

.strength-meter {
    height: 100%;
    width: 0%;
    transition: all 0.3s;
}

.strength-weak { background: #ef5350; width: 33%; }
.strength-fair { background: #ffa726; width: 66%; }
.strength-strong { background: #66bb6a; width: 100%; }

.strength-text {
    flex-shrink: 0;
    color: #999;
}

.auth-submit-btn {
    width: 100%;
    padding: 12px;
    background: var(--accent-blue);
    color: #000;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    font-size: 1rem;
    transition: all 0.2s;
}

.auth-submit-btn:hover {
    background: #42a5f5;
    transform: scale(1.02);
}

.auth-submit-btn:disabled {
    background: #666;
    cursor: not-allowed;
    transform: none;
}

.auth-error {
    color: #ef5350;
    font-size: 0.85rem;
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(239, 83, 80, 0.1);
    border-radius: 4px;
    display: none;
}

.auth-error.active {
    display: block;
}

/* Progress Save Banner */
.progress-banner {
    background: linear-gradient(135deg, #ff6b6b, #ff5252);
    padding: 6px 8px;
    color: white;
    font-weight: bold;
    border-radius: 0;
    margin: 0;
    font-size: 0.5rem;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
}

.progress-banner.saved {
    background: linear-gradient(135deg, #66bb6a, #4caf50);
}

.progress-banner .banner-close-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 1.2rem;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.progress-banner .banner-close-btn:hover {
    opacity: 0.8;
}

body.light-mode .auth-modal-content {
    background: #f5f5f5;
    border-color: #ddd;
}

body.light-mode .auth-form-group input {
    background: #fff;
    border-color: #ddd;
    color: #000;
}
