.demo-widget-container {
    width: 100%;
    max-width: var(--maxw, 1180px);
    margin: 40px auto;
    padding: 0 32px;
    box-sizing: border-box;
    font-family: 'IBM Plex Sans', system-ui, sans-serif;
    --bg: #0B0E11;
    --surface: #12161B;
    --surface2: #181D23;
    --line: #262C33;
    --text: #E8E6DF;
    --text-dim: #8B93A0;
    --violet: #8B7CF6;
    --amber: #F5A623;
    --green: #6FCF97;
    --error: #ff7b72;
}

.demo-wrapper {
    display: flex;
    gap: 20px;
    background: var(--bg);
    border-radius: 12px;
    border: 1px solid var(--line);
    padding: 20px;
    color: var(--text);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    height: 590px;
    overflow: hidden;
}

.demo-sidebar {
    flex: 1;
    min-width: 250px;
    max-width: 300px;
    display: flex;
    flex-direction: column;
    gap: 15px;
    border-right: 1px solid var(--line);
    padding-right: 20px;
}

.task-title {
    margin: 0;
    font-size: 1.1rem;
    color: var(--amber);
    font-family: 'IBM Plex Sans Condensed', sans-serif;
    font-weight: 700;
}

.task-desc {
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-dim);
}

.task-mode-badge {
    display: inline-block;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.72rem;
    font-weight: bold;
    letter-spacing: 0.02em;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 4px;
    padding: 3px 8px;
    margin-bottom: 6px;
    color: var(--text-dim);
}

.task-sample-note {
    font-size: 0.75rem;
    font-style: italic;
    color: var(--text-dim);
    opacity: 0.8;
    margin-top: -8px;
}

.hp-indicator {
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.8rem;
    color: var(--amber);
    margin-bottom: 8px;
}

.reward-note {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin: -5px 0 10px;
}

.mentor-message {
    background: var(--surface);
    border-radius: 8px;
    padding: 15px;
    font-size: 0.9rem;
    border: 1px solid var(--line);
    line-height: 1.5;
    display: flex;
    gap: 10px;
    font-family: 'IBM Plex Mono', monospace;
}

.mentor-message.success {
    border-color: var(--green);
    background: rgba(111, 207, 151, 0.1);
}

.mentor-message.error {
    border-color: var(--error);
    background: rgba(255, 123, 114, 0.1);
}

.mentor-avatar {
    background: var(--violet);
    color: var(--bg);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex-shrink: 0;
}

.demo-main {
    flex: 3;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.demo-editor-panel, .demo-terminal-panel {
    background: var(--surface2);
    border: 1px solid var(--line);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.demo-editor-panel {
    flex: 1.5;
}

.demo-terminal-panel {
    flex: 1;
}

.panel-header {
    background: var(--surface);
    padding: 8px 15px;
    font-size: 0.85rem;
    color: var(--text-dim);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: 'IBM Plex Mono', monospace;
}

#cm-editor {
    flex: 1;
    overflow-y: auto;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.9rem;
}
#cm-editor .cm-editor {
    height: 100%;
}

.btn-run {
    background: var(--amber);
    color: var(--bg);
    border: none;
    border-radius: 5px;
    padding: 5px 12px;
    cursor: pointer;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
    font-family: 'IBM Plex Mono', monospace;
}
.btn-run:disabled {
    background: var(--surface);
    color: var(--text-dim);
    cursor: not-allowed;
    border: 1px dashed var(--line);
}

.spinner {
    display: inline-block;
    width: 12px;
    height: 12px;
    border: 2px solid rgba(11, 14, 17, 0.3);
    border-radius: 50%;
    border-top-color: var(--bg);
    animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.term-output {
    flex: 1;
    padding: 10px 15px;
    overflow-y: auto;
    font-family: 'IBM Plex Mono', monospace;
    font-size: 0.85rem;
    color: var(--text);
}
.term-output div { margin-bottom: 4px; }
.term-output .prompt { color: var(--amber); }
.term-err { color: var(--error); }
.file-modified { color: var(--error); }
.file-staged { color: var(--green); }

.term-input-row {
    display: flex;
    padding: 10px 15px;
    background: var(--bg);
    border-top: 1px solid var(--line);
    align-items: center;
    gap: 10px;
}
.term-input-row .prompt {
    color: var(--amber);
    font-family: 'IBM Plex Mono', monospace;
}
#term-input {
    background: transparent;
    border: none;
    color: var(--text);
    font-family: 'IBM Plex Mono', monospace;
    flex: 1;
    outline: none;
}

.demo-fallback {
    background: var(--bg);
    border-radius: 12px;
    border: 1px solid var(--line);
    padding: 40px 20px;
    text-align: center;
    color: var(--text);
}
.demo-fallback-visual {
    width: 100%;
    max-width: 400px;
    margin: 0 auto 20px;
}
.term-mockup { background: var(--surface2); border: 1px solid var(--line); border-radius: 8px; padding: 20px; text-align: left; font-family: 'IBM Plex Mono', monospace; font-size: 13.5px; height: 180px; overflow: hidden; position: relative; margin: 0 auto; width: 100%; box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.term-line { color: var(--text); opacity: 0; margin-bottom: 8px; animation: showLine 8s infinite; }
.term-line span { color: var(--amber); }
.term-line.red { color: #FF5F56; }
.term-line.ok { color: var(--green); }
.term-line.dim { color: var(--text-dim); }
.term-line.loading { animation: showLine 8s infinite; }
.term-line:nth-child(1) { animation-delay: 0s; }
.term-line:nth-child(2) { animation-delay: 1.5s; }
.term-line:nth-child(3) { animation-delay: 3s; }
.term-line:nth-child(4) { animation-delay: 4s; }
.term-line:nth-child(5) { animation-delay: 5s; }

@keyframes showLine {
  0% { opacity: 0; transform: translateY(10px); }
  5% { opacity: 1; transform: translateY(0); }
  95% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; }
}


.demo-fallback-content h3 { color: var(--amber); margin-bottom: 10px; }
.demo-fallback-content p { color: var(--text-dim); margin-bottom: 20px; }

.demo-success-overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(11, 14, 17, 0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 12px;
}
.success-card {
    background: var(--surface);
    padding: 30px;
    border-radius: 12px;
    border: 1px solid var(--green);
    text-align: center;
    box-shadow: 0 0 30px rgba(111, 207, 151, 0.2);
    position: relative;
    z-index: 20;
}
.success-card h2 { color: var(--green); margin-bottom: 15px; }
.success-card .btn { margin-top: 15px; }
.rewards { display: flex; gap: 15px; justify-content: center; margin-bottom: 15px; }
.reward { background: var(--bg); padding: 8px 15px; border-radius: 20px; font-weight: bold; border: 1px solid var(--line); color: var(--text); }
.reward.xp { color: var(--violet); }
.reward.hp { color: var(--amber); }

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    top: -10px;
    animation: fall 3s linear infinite;
}
@keyframes fall {
    to { transform: translateY(500px) rotate(720deg); opacity: 0; }
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 14, 17, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.25s ease-in-out;
}
.modal-overlay.active {
    opacity: 1;
}
.modal-content {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 12px;
    width: 90%;
    max-width: 550px;
    padding: 24px;
    box-sizing: border-box;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    position: relative;
    transform: scale(0.9);
    transition: transform 0.25s ease-in-out;
}
.modal-overlay.active .modal-content {
    transform: scale(1);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--line);
    padding-bottom: 12px;
    margin-bottom: 15px;
}
.modal-header h3 {
    margin: 0;
    color: var(--text);
    font-family: 'IBM Plex Sans Condensed', sans-serif;
    font-weight: 700;
    font-size: 18px;
}
.close-modal {
    font-size: 24px;
    color: var(--text-dim);
    cursor: pointer;
    transition: color 0.15s;
}
.close-modal:hover {
    color: var(--text);
}
.hint-level-box {
    background: var(--surface2);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
}
.reveal-btn {
    width: 100%;
    background: var(--violet);
    color: var(--bg);
    border: none;
    padding: 10px;
    border-radius: 4px;
    cursor: pointer;
    font-family: 'IBM Plex Sans', sans-serif;
    font-weight: bold;
    font-size: 13px;
    transition: background 0.15s, opacity 0.15s;
}
.reveal-btn:hover:not(:disabled) {
    opacity: 0.9;
}
.reveal-btn:disabled {
    background: var(--surface);
    color: var(--text-dim);
    border: 1px dashed var(--line);
    cursor: not-allowed;
}
.hint-html-title {
    font-family: 'IBM Plex Mono', monospace;
    font-weight: bold;
    color: var(--violet);
    font-size: 13px;
    margin-bottom: 6px;
}
.hint-html-content {
    color: var(--text);
    font-family: 'IBM Plex Sans', sans-serif;
    font-size: 13px;
    line-height: 1.5;
}
