:root {
    /* Main Theme Colors */
    --duo-orange: #ff9600;
    --duo-orange-shadow: #cc7800;
    --duo-orange-light: #fff3e0;
    --duo-orange-dark: #995a00;

    --duo-blue: #1cb0f6;
    --duo-blue-shadow: #1899d6;
    --duo-blue-light: #ddf4ff;
    --duo-blue-dark: #007bb5;

    --duo-green: #58cc02;
    --duo-green-shadow: #46a302;
    --duo-green-light: #d7ffb8;
    --duo-green-dark: #2b7000;

    --duo-gray-bg: #f7f7f7;
    --duo-gray-border: #e5e5e5;
    --duo-gray-border-shadow: #c0c0c0;
    --duo-gray-text: #888888;
    --duo-gray-dark: #333333;

    --duo-red: #ff4b4b;
    --duo-red-shadow: #ea2b2b;
    --duo-red-light: #ffdfe0;
    --duo-red-dark: #b51c1c;

    /* Pixel round clip-path */
    --pixel-round-sm: polygon(4px 0, calc(100% - 4px) 0,
            calc(100% - 4px) 2px, 100% 2px,
            100% calc(100% - 2px), calc(100% - 4px) calc(100% - 2px),
            calc(100% - 4px) 100%, 4px 100%,
            4px calc(100% - 2px), 0 calc(100% - 2px),
            0 2px, 4px 2px);

    /* Bottom Modal Top Pixel Clip Path */
    --pixel-modal-top: polygon(0 16px, 4px 16px, 4px 10px, 8px 10px, 8px 6px, 12px 6px, 12px 2px, 18px 2px, 18px 0,
            calc(100% - 18px) 0, calc(100% - 18px) 2px, calc(100% - 12px) 2px, calc(100% - 12px) 6px,
            calc(100% - 8px) 6px, calc(100% - 8px) 10px, calc(100% - 4px) 10px, calc(100% - 4px) 16px,
            100% 16px, 100% 100%, 0 100%);

    /* Speech Bubble Pixel Clip Path */
    --pixel-bubble-path: polygon(0 20px, 4px 20px, 4px 16px, 8px 16px, 8px 12px, 32px 12px, 32px 8px, 36px 8px, 36px 4px,
            40px 4px, 40px 0px, 44px 0px, 44px 4px, 48px 4px, 48px 8px, 52px 8px, 52px 12px,
            calc(100% - 8px) 12px, calc(100% - 8px) 16px, calc(100% - 4px) 16px, calc(100% - 4px) 20px,
            100% 20px, 100% calc(100% - 8px), calc(100% - 4px) calc(100% - 8px),
            calc(100% - 4px) calc(100% - 4px), calc(100% - 8px) calc(100% - 4px),
            calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 4px), 4px calc(100% - 4px),
            4px calc(100% - 8px), 0 calc(100% - 8px));

    --safe-top: max(env(safe-area-inset-top, 0px), 12px);
    --safe-bottom: max(env(safe-area-inset-bottom, 0px), 16px);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    box-shadow: none !important;
}

html,
body {
    height: 100%;
    height: 100dvh;
    background-color: #ffffff;
    color: var(--duo-gray-dark);
    image-rendering: pixelated;
    position: relative;
    font-weight: 500;
}

h1,
h2,
h3,
h4,
h5,
h6,
b,
strong,
.font-bold,
.step-counter,
.unit-tag,
.section-title,
.bubble-heading,
.action-btn,
.sheet-title {
    font-weight: 700 !important;
}

button,
.pixel-btn,
.action-btn,
.quiz-opt-btn,
.slot-item,
.sheet-action-btn,
.nav-tab,
.node-btn,
.sidebar-nav-item {
    transition: none !important;
}

button:active:not(:disabled),
.pixel-btn:active:not(:disabled),
.action-btn:active:not(:disabled),
.quiz-opt-btn:active:not(:disabled),
.sheet-action-btn:active:not(:disabled),
.node-btn:active:not(:disabled),
.sidebar-nav-item:active {
    transform: scale(0.95) !important;
    filter: brightness(0.85) !important;
}

/* Loading Screen Overlay (Requirement 6: Centered /loading.gif) */
.loading-screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999;
}

.loading-container-box {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    width: 100%;
}

.loading-img {
    width: 128px;
    height: 128px;
    object-fit: contain;
}

/* Duolingo PC Desktop 3-Column Layout */
.app-desktop-layout {
    display: grid;
    grid-template-columns: 240px 1fr 320px;
    min-height: 100dvh;
    max-width: 1240px;
    margin: 0 auto;
    width: 100%;
    background: #ffffff;
}

.left-sidebar {
    border-right: 2px solid var(--duo-gray-border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: #ffffff;
    height: 100dvh;
    position: sticky;
    top: 0;
}

.sidebar-top {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.sidebar-logo {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0 8px;
}

.sidebar-logo img {
    height: 38px;
    object-fit: contain;
}

.sidebar-nav-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    font-size: 15px;
    font-weight: 700;
    color: var(--duo-gray-dark);
    clip-path: var(--pixel-round-sm);
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    text-transform: uppercase;
}

.sidebar-nav-item.active {
    background: var(--duo-blue-light);
    color: var(--duo-blue-dark);
    border: 2px solid var(--duo-blue);
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-cms-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 700;
    color: #ffffff;
    background: var(--duo-red);
    clip-path: var(--pixel-round-sm);
    border: none;
    cursor: pointer;
    width: 100%;
}

.middle-main-content {
    padding: 24px 20px;
    overflow-y: auto;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.right-sidebar {
    border-left: 2px solid var(--duo-gray-border);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    background: #ffffff;
    height: 100dvh;
    position: sticky;
    top: 0;
    overflow-y: auto;
}

.user-stat-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 15px;
    font-weight: 700;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    color: var(--duo-gray-dark);
}

.right-stat-card {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 14px 16px;
    border: 2px solid var(--duo-gray-border);
    clip-path: var(--pixel-round-sm);
    background: #ffffff;
}

.quest-card {
    background: #ffffff;
    border: 2px solid var(--duo-gray-border);
    clip-path: var(--pixel-round-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.quest-progress-bg {
    flex: 1;
    height: 12px;
    background: var(--duo-gray-border);
    clip-path: var(--pixel-round-sm);
}

.quest-progress-fill {
    height: 100%;
    background: var(--duo-orange);
    clip-path: var(--pixel-round-sm);
}

.mobile-top-bar,
.mobile-bottom-nav {
    display: none !important;
}

@media (max-width: 768px) {
    .app-desktop-layout {
        display: flex;
        flex-direction: column;
        min-height: 100dvh;
    }

    .left-sidebar,
    .right-sidebar {
        display: none !important;
    }

    .middle-main-content {
        padding: 12px 16px 80px;
    }

    .mobile-top-bar {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        padding: 12px 16px;
        border-bottom: 2px solid var(--duo-gray-border);
        background: #ffffff;
        position: sticky;
        top: 0;
        z-index: 50;
    }

    .mobile-bottom-nav {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100vw;
        height: 60px;
        background: #ffffff;
        border-top: 2px solid var(--duo-gray-border);
        align-items: center;
        justify-content: space-around;
        z-index: 100;
    }

    .mobile-nav-btn {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        font-size: 11px;
        font-weight: 700;
        color: var(--duo-gray-dark);
        background: none;
        border: none;
        cursor: pointer;
    }

    .mobile-nav-btn.active {
        color: var(--duo-blue);
    }

    .mobile-step-picker {
        display: flex !important;
    }

    .desktop-step-list {
        display: none !important;
    }

    .notes-grid-container {
        grid-template-columns: 1fr !important;
    }
}

.mobile-step-picker {
    display: none;
}


/* Step Runner View */
.step-runner-view {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    background: #ffffff;
    position: relative;
    overflow: hidden;
}

.step-runner-header {
    width: 100%;
    padding: var(--safe-top) 20px 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    border-bottom: 2px solid var(--duo-gray-border);
    background: #ffffff;
}

.step-runner-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.step-runner-footer {
    border-top: 2px solid var(--duo-gray-border);
    padding: 12px 20px var(--safe-bottom);
    background: #ffffff;
    flex-shrink: 0;
}

.progress-bar-container {
    flex-grow: 1;
    height: 16px;
    background-color: var(--duo-gray-border);
    clip-path: var(--pixel-round-sm);
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    width: 20%;
    background-color: var(--duo-orange);
    clip-path: var(--pixel-round-sm);
    transition: width 0.3s steps(8, end);
}

.step-counter {
    font-size: 13px;
    font-weight: 700;
    color: var(--duo-orange-dark);
    background-color: var(--duo-orange-light);
    padding: 4px 8px;
    clip-path: var(--pixel-round-sm);
    border: 1.5px solid var(--duo-orange);
    flex-shrink: 0;
}

.close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    clip-path: var(--pixel-round-sm);
}

.close-btn:hover {
    background-color: var(--duo-gray-bg);
}

.unit-tag {
    font-size: 11px;
    font-weight: 700;
    color: var(--duo-orange);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--duo-gray-dark);
    margin-bottom: 12px;
    letter-spacing: -0.3px;
}

.concept-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Custom Character Avatar (Requirement 5) */
.character-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mascot-avatar-img {
    width: 52px;
    height: 52px;
    object-fit: contain;
    flex-shrink: 0;
}

.character-info h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--duo-gray-dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

.character-info p {
    font-size: 13px;
    font-weight: 500;
    color: var(--duo-gray-text);
}

/* Custom Color Speech Bubble (Restored 100% to example.html) */
@keyframes pixelBubbleBounce {
    0% {
        opacity: 0.3;
        transform: translateY(6px) scale(0.98);
    }

    60% {
        opacity: 1;
        transform: translateY(-2px) scale(1.005);
    }

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

.speech-bubble-wrapper {
    position: relative;
    filter: drop-shadow(0 4px 0 var(--duo-orange-shadow));
    transform-origin: 40px top;
    width: 100%;
}

.speech-bubble-wrapper.animating {
    animation: pixelBubbleBounce 0.24s steps(6, end) forwards;
}

.speech-bubble-frame {
    background-color: var(--duo-orange);
    clip-path: var(--pixel-bubble-path);
    padding: 3px;
    display: flex;
}

.speech-bubble-inner {
    background-color: #ffffff;
    clip-path: var(--pixel-bubble-path);
    width: 100%;
    min-height: 220px;
    padding: 24px 16px 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 12px;
}

.bubble-heading {
    font-size: 15px;
    font-weight: 700;
    color: var(--duo-orange-dark);
    display: flex;
    align-items: center;
    gap: 6px;
    letter-spacing: -0.2px;
}

.bubble-desc {
    font-size: 14.5px;
    font-weight: 500;
    line-height: 1.55;
    color: var(--duo-gray-dark);
    letter-spacing: -0.2px;
}

.step-img-embed {
    width: 100%;
    max-height: 240px;
    object-fit: cover;
    clip-path: var(--pixel-round-sm);
    border: 2px solid var(--duo-gray-border);
    margin: 4px 0;
}

.step-code-block {
    background: #1e272e;
    color: #00d2d3;
    clip-path: var(--pixel-round-sm);
    padding: 12px;
    font-family: monospace;
    font-size: 13px;
    font-weight: 700;
    white-space: pre-wrap;
    line-height: 1.5;
    overflow-x: auto;
}

/* Ace Editor Container (Requirement 7: Clean Code Editor) */
.ace-editor-box {
    width: 100%;
    border: 2px solid var(--duo-gray-border);
    clip-path: var(--pixel-round-sm);
    overflow: hidden;
    margin-top: 8px;
}

#aceCodeEditor {
    width: 100%;
    height: 180px;
    font-size: 13px;
    font-weight: 500;
}

.ace-run-bar {
    background: #1e272e;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.coddy-terminal {
    background: #000000;
    color: #1dd1a1;
    font-family: monospace;
    font-size: 12px;
    font-weight: 700;
    padding: 10px;
    clip-path: var(--pixel-round-sm);
    min-height: 48px;
    max-height: 120px;
    overflow-y: auto;
    margin-top: 6px;
}

.test-case-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 700;
    clip-path: var(--pixel-round-sm);
    margin-top: 4px;
}

.test-badge-pass {
    background: #d7ffb8;
    color: #2b7000;
    border: 1px solid #58cc02;
}

.test-badge-fail {
    background: #ffdfe0;
    color: #b51c1c;
    border: 1px solid #ff4b4b;
}

/* Tips */
.tip-box {
    background-color: var(--duo-orange-light);
    border: 1.5px solid var(--duo-orange);
    clip-path: var(--pixel-round-sm);
    padding: 10px 12px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.tip-icon {
    flex-shrink: 0;
    margin-top: 1px;
}

.tip-text {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--duo-orange-dark);
    line-height: 1.45;
}

/* Quiz Options */
.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}

.quiz-opt-btn {
    background: #ffffff;
    border: 2px solid var(--duo-gray-border);
    clip-path: var(--pixel-round-sm);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    font-weight: 700;
    color: var(--duo-gray-dark);
    cursor: pointer;
    text-align: left;
}

.quiz-opt-btn:hover {
    background: var(--duo-gray-bg);
}

.quiz-opt-btn.correct {
    background: var(--duo-green-light);
    border-color: var(--duo-green);
    color: var(--duo-green-dark);
}

.quiz-opt-btn.wrong {
    background: var(--duo-red-light);
    border-color: var(--duo-red);
    color: #900;
}

.quiz-num-badge {
    width: 22px;
    height: 22px;
    background: var(--duo-gray-border);
    clip-path: var(--pixel-round-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #555;
}

.quiz-opt-btn.correct .quiz-num-badge {
    background: var(--duo-green);
    color: #fff;
}

/* Footer Action Button */
.action-btn {
    width: 100%;
    padding: 13px 20px;
    clip-path: var(--pixel-round-sm);
    border: none;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    cursor: pointer;
    text-transform: uppercase;
    background-color: var(--duo-orange);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.action-btn:disabled {
    background-color: #e5e5e5;
    color: #afafaf;
    cursor: not-allowed;
}

/* Bottom Sheet */
.bottom-sheet-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 90;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.bottom-sheet-backdrop.show {
    opacity: 1;
    pointer-events: auto;
}

.bottom-sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    z-index: 100;
    transform: translateY(105%);
    transition: transform 0.2s cubic-bezier(0.1, 0.9, 0.2, 1);
    clip-path: var(--pixel-modal-top);
    border: none !important;
    padding: 24px 20px max(env(safe-area-inset-bottom, 0px), 22px);
    box-sizing: border-box;
}

.bottom-sheet.show {
    transform: translateY(0);
}

.bottom-sheet.correct {
    background-color: var(--duo-green-light);
}

.bottom-sheet.wrong {
    background-color: var(--duo-red-light);
}

.bottom-sheet.orange {
    background-color: var(--duo-orange-light);
}

.bottom-sheet-inner {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
}

.sheet-badge-wrap {
    display: flex;
    align-items: center;
    margin-bottom: 2px;
}

.sheet-icon-badge {
    width: 36px;
    height: 36px;
    clip-path: var(--pixel-round-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.bottom-sheet.correct .sheet-icon-badge {
    background: var(--duo-green);
}

.bottom-sheet.wrong .sheet-icon-badge {
    background: var(--duo-red);
}

.bottom-sheet.orange .sheet-icon-badge {
    background: var(--duo-orange);
}

.sheet-title {
    font-size: 19px;
    font-weight: 700;
    letter-spacing: -0.3px;
    line-height: 1.3;
}

.bottom-sheet.correct .sheet-title {
    color: var(--duo-green-dark);
}

.bottom-sheet.wrong .sheet-title {
    color: var(--duo-red-dark);
}

.bottom-sheet.orange .sheet-title {
    color: var(--duo-orange-dark);
}

.sheet-message {
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    color: var(--duo-gray-dark);
    margin-bottom: 6px;
}

.sheet-btn-wrap {
    width: 100%;
}

.sheet-action-btn {
    width: 100%;
    padding: 14px 20px;
    clip-path: var(--pixel-round-sm);
    border: none;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-transform: uppercase;
}

.bottom-sheet.correct .sheet-action-btn {
    background-color: var(--duo-green);
}

.bottom-sheet.wrong .sheet-action-btn {
    background-color: var(--duo-red);
}

.bottom-sheet.orange .sheet-action-btn {
    background-color: var(--duo-orange);
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgb(255, 255, 255);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-content {
    background: #ffffff !important;
    clip-path: var(--pixel-round-sm);
    border-radius: 0 !important;
    width: 100%;
    max-width: 460px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 700;
    color: var(--duo-gray-dark);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--duo-gray-dark);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 500;
    border: 2px solid var(--duo-gray-border);
    clip-path: var(--pixel-round-sm);
    background: #ffffff;
    color: var(--duo-gray-dark);
    outline: none;
    user-select: text !important;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    border-color: var(--duo-orange);
}

/* Course Map Nodes */
.course-roadmap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 24px;
    padding: 20px 0;
}

.section-banner-card {
    width: 100%;
    background: var(--duo-blue);
    color: #ffffff;
    clip-path: var(--pixel-round-sm);
    padding: 16px 20px;
    margin-bottom: 12px;
}

.section-banner-card h2 {
    font-size: 18px;
    font-weight: 700;
}

.section-banner-card p {
    font-size: 13px;
    opacity: 0.9;
    font-weight: 500;
}

.unit-header-card {
    width: 100%;
    background-color: var(--duo-orange);
    color: #ffffff;
    clip-path: var(--pixel-round-sm);
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.unit-header-info h2 {
    font-size: 16px;
    font-weight: 700;
}

.unit-header-info p {
    font-size: 12.5px;
    opacity: 0.9;
    font-weight: 500;
}

.node-btn {
    width: 64px;
    height: 64px;
    clip-path: var(--pixel-round-sm);
    border: none;
    background-color: var(--duo-orange);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    position: relative;
}

.node-btn.completed {
    background-color: var(--duo-green);
}

.node-btn.locked {
    background-color: var(--duo-gray-border);
    color: var(--duo-gray-text);
    cursor: not-allowed;
}

/* CMS Dashboard */
.cms-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
    padding: 20px;
    overflow-y: auto !important;
    height: auto !important;
    max-height: none !important;
}

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

@media (max-width: 840px) {
    .cms-grid {
        grid-template-columns: 1fr;
    }
}

.cms-panel {
    background: #ffffff;
    border: 2px solid var(--duo-gray-border);
    clip-path: var(--pixel-round-sm);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    height: auto !important;
    max-height: none !important;
    overflow: visible !important;
}

.cms-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--duo-gray-border);
    padding-bottom: 8px;
    overflow-x: auto;
}

.cms-tab {
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 700;
    border: none;
    background: var(--duo-gray-bg);
    color: var(--duo-gray-dark);
    clip-path: var(--pixel-round-sm);
    cursor: pointer;
    white-space: nowrap;
}

.cms-tab.active {
    background: var(--duo-orange);
    color: #ffffff;
}

.step-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1.5px solid var(--duo-gray-border);
    clip-path: var(--pixel-round-sm);
    cursor: pointer;
    background: var(--duo-gray-bg);
}

.step-list-item.selected {
    border-color: var(--duo-orange);
    background: var(--duo-orange-light);
}

.preview-box {
    border: 2px dashed var(--duo-gray-border);
    clip-path: var(--pixel-round-sm);
    padding: 16px;
    background: var(--duo-gray-bg);
    overflow: visible;
    height: auto !important;
    max-height: none !important;
}

/* CMS Save Toast */
.cms-save-toast {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--duo-green);
    color: #fff;
    padding: 10px 24px;
    clip-path: var(--pixel-round-sm);
    font-size: 14px;
    font-weight: 700;
    z-index: 999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
}

.cms-save-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
    pointer-events: auto;
}

/* Dark Mode Toggle Switch */
.theme-toggle-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
}

.theme-toggle-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--duo-gray-dark);
}

.theme-toggle {
    position: relative;
    width: 48px;
    height: 26px;
    cursor: pointer;
}

.theme-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.theme-toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--duo-gray-border);
    clip-path: var(--pixel-round-sm);
    transition: background 0.2s;
}

.theme-toggle-slider::before {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background: #ffffff;
    clip-path: var(--pixel-round-sm);
    transition: transform 0.2s;
}

.theme-toggle input:checked+.theme-toggle-slider {
    background: var(--duo-blue);
}

.theme-toggle input:checked+.theme-toggle-slider::before {
    transform: translateX(22px);
}

/* ========================================
   DARK MODE THEME
   ======================================== */
[data-theme="dark"] {
    --duo-gray-bg: #1a1a2e;
    --duo-gray-border: #2d2d44;
    --duo-gray-border-shadow: #1e1e35;
    --duo-gray-text: #9999aa;
    --duo-gray-dark: #e0e0ee;

    --duo-orange-light: #2e2215;
    --duo-blue-light: #162535;
    --duo-green-light: #1a2e10;
    --duo-red-light: #2e1515;
}

[data-theme="dark"] html,
[data-theme="dark"] body,
html[data-theme="dark"],
html[data-theme="dark"] body {
    background-color: #0f0f1a;
    color: var(--duo-gray-dark);
}

[data-theme="dark"] .app-desktop-layout {
    background: #16162a;
}

[data-theme="dark"] .left-sidebar {
    background: #16162a;
    border-color: var(--duo-gray-border);
}

[data-theme="dark"] .right-sidebar {
    background: #16162a;
    border-color: var(--duo-gray-border);
}

[data-theme="dark"] .sidebar-nav-item {
    color: var(--duo-gray-dark);
}

[data-theme="dark"] .sidebar-nav-item.active {
    background: var(--duo-blue-light);
    color: var(--duo-blue);
    border-color: var(--duo-blue);
}

[data-theme="dark"] .right-stat-card {
    background: #1e1e35;
    border-color: var(--duo-gray-border);
}

[data-theme="dark"] .quest-card {
    background: #1e1e35;
    border-color: var(--duo-gray-border);
}

[data-theme="dark"] .mobile-top-bar {
    background: #16162a;
    border-color: var(--duo-gray-border);
}

[data-theme="dark"] .mobile-bottom-nav {
    background: #16162a;
    border-color: var(--duo-gray-border);
}

[data-theme="dark"] .mobile-nav-btn {
    color: var(--duo-gray-text);
}

[data-theme="dark"] .mobile-nav-btn.active {
    color: var(--duo-blue);
}

/* Step Runner Dark */
[data-theme="dark"] .step-runner-view {
    background: #16162a;
}

[data-theme="dark"] .step-runner-header {
    background: #16162a;
    border-color: var(--duo-gray-border);
}

[data-theme="dark"] .step-runner-footer {
    background: #16162a;
    border-color: var(--duo-gray-border);
}

[data-theme="dark"] .speech-bubble-inner {
    background-color: #1e1e35;
}

[data-theme="dark"] .bubble-desc {
    color: var(--duo-gray-dark);
}

[data-theme="dark"] .quiz-opt-btn {
    background: #1e1e35;
    border-color: var(--duo-gray-border);
    color: var(--duo-gray-dark);
}

[data-theme="dark"] .quiz-opt-btn:hover {
    background: #252545;
}

[data-theme="dark"] .action-btn:disabled {
    background-color: #2d2d44;
    color: #555566;
}

/* Bottom Sheet Dark */
[data-theme="dark"] .bottom-sheet.correct {
    background-color: #1a2e10;
}

[data-theme="dark"] .bottom-sheet.wrong {
    background-color: #2e1515;
}

[data-theme="dark"] .bottom-sheet.orange {
    background-color: #2e2215;
}

[data-theme="dark"] .sheet-message {
    color: var(--duo-gray-dark);
}

/* Modal Dark */
[data-theme="dark"] .modal-overlay {
    background: #0f0f1a;
}

[data-theme="dark"] .modal-content {
    background: #1e1e35 !important;
}

/* Forms Dark */
[data-theme="dark"] .form-input,
[data-theme="dark"] .form-textarea,
[data-theme="dark"] .form-select {
    background: #252545;
    color: var(--duo-gray-dark);
    border-color: var(--duo-gray-border);
}

/* CMS Dark */
[data-theme="dark"] .cms-panel {
    background: #1e1e35;
    border-color: var(--duo-gray-border);
}

[data-theme="dark"] .cms-tab {
    background: #252545;
    color: var(--duo-gray-dark);
}

[data-theme="dark"] .step-list-item {
    background: #252545;
    border-color: var(--duo-gray-border);
}

[data-theme="dark"] .step-list-item.selected {
    background: var(--duo-orange-light);
    border-color: var(--duo-orange);
}

[data-theme="dark"] .preview-box {
    background: #252545;
    border-color: var(--duo-gray-border);
}

/* Course Map Dark */
[data-theme="dark"] .node-btn {
    filter: brightness(0.9);
}

[data-theme="dark"] .loading-screen-overlay {
    background: #0f0f1a;
}

/* Community Dark */
[data-theme="dark"] .community-post-card {
    background: #1e1e35;
    border-color: var(--duo-gray-border);
}

[data-theme="dark"] .community-reply-card {
    background: #252545;
    border-color: var(--duo-gray-border);
}

[data-theme="dark"] .community-compose-box {
    background: #1e1e35;
    border-color: var(--duo-gray-border);
}

/* Dark mode character info */
[data-theme="dark"] .character-info h3 {
    color: var(--duo-gray-dark);
}

[data-theme="dark"] .character-info p {
    color: var(--duo-gray-text);
}

/* Brand header dark */
[data-theme="dark"] .brand-header {
    background: #16162a;
    border-color: var(--duo-gray-border);
}

/* Retro 8-Bit Pixel Modal System Animations & Overlay */
@keyframes pixelModalBounce {
    0% {
        opacity: 0;
        transform: translateY(-24px) scale(0.94);
    }
    60% {
        opacity: 1;
        transform: translateY(4px) scale(1.02);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.rooti-modal-active {
    background: rgba(15, 23, 42, 0.72) !important;
    backdrop-filter: blur(3px);
}

.pixel-modal-card button.pixel-btn {
    transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.pixel-modal-card button.pixel-btn:active {
    transform: translateY(3px) !important;
    box-shadow: 0 1px 0 rgba(0,0,0,0.5) !important;
}

/* Node Button Locked State */
.node-btn.locked {
    background: #e0e0e0 !important;
    color: #999999 !important;
    box-shadow: none !important;
    cursor: not-allowed !important;
    border-color: #cccccc !important;
}

/* Responsive CMS Grid & Mobile Styling */
@media (max-width: 768px) {
    .cms-grid-responsive {
        grid-template-columns: 1fr !important;
    }
    .cms-container {
        width: 100% !important;
        padding: 10px !important;
    }
}