/* LogoLab - Styles */

:root {
    --bg-primary: #1e1e2e;
    --bg-secondary: #2d2d3f;
    --bg-tertiary: #3d3d52;
    --text-primary: #e0e0e0;
    --text-secondary: #a0a0a0;
    --accent-primary: #4ecdc4;
    --accent-secondary: #45b7aa;
    --accent-danger: #ff6b6b;
    --accent-warning: #ffd93d;
    --border-color: #3d3d52;
    --canvas-bg: #ffffff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    --radius: 6px;
    --radius-lg: 10px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header */
#header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: baseline;
    gap: 15px;
}

.header-left h1 {
    font-size: 1.5rem;
    color: var(--accent-primary);
    font-weight: 700;
}

.tagline {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.header-right {
    display: flex;
    gap: 8px;
}

/* Buttons */
.btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn:hover {
    background: var(--border-color);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--accent-primary);
    color: #1e1e2e;
}

.btn-primary:hover {
    background: var(--accent-secondary);
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
}

.btn-danger:hover {
    background: #ff5252;
}

.btn-small {
    padding: 4px 10px;
    font-size: 0.8rem;
    border: none;
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-small:hover {
    background: var(--border-color);
}

.btn-small.active {
    background: var(--accent-primary);
    color: #1e1e2e;
}

.btn-small.active:hover {
    background: var(--accent-secondary);
}

.icon {
    font-size: 0.9rem;
}

/* Main Content */
#main {
    flex: 1;
    display: flex;
    gap: 1px;
    background: var(--border-color);
    min-height: 0;
}

/* Panels */
.panel {
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.panel-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Editor Panel */
#editor-panel {
    flex: 1;
    min-width: 300px;
}

#editor-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

#line-numbers {
    padding: 12px 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.5;
    text-align: right;
    user-select: none;
    min-width: 40px;
    overflow: hidden;
    white-space: pre;
}

#code-editor {
    flex: 1;
    padding: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: none;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    tab-size: 2;
}

#code-editor:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: -2px;
}

#code-editor::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Canvas Panel */
#canvas-panel {
    flex: 1.2;
    min-width: 400px;
}

#canvas-container {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background: var(--bg-secondary);
    overflow: hidden;
}

#turtle-canvas {
    background: var(--canvas-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    max-width: 100%;
    max-height: 100%;
}

.coordinates {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
    padding: 2px 8px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
}

/* Output Panel */
#output-panel {
    height: 120px;
    border-top: 1px solid var(--border-color);
}

#output-console {
    flex: 1;
    padding: 10px 12px;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.4;
    overflow-y: auto;
    background: var(--bg-primary);
}

.output-line {
    margin-bottom: 2px;
}

.output-error {
    color: var(--accent-danger);
}

.output-info {
    color: var(--accent-primary);
}

/* Footer */
#footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.footer-left, .footer-right, .footer-center {
    display: flex;
    align-items: center;
    gap: 10px;
}

.footer-right a {
    color: var(--accent-primary);
    text-decoration: none;
}

.footer-right a:hover {
    text-decoration: underline;
}

.donate-link {
    color: var(--accent-warning);
    text-decoration: none;
    font-weight: 500;
    padding: 4px 12px;
    background: rgba(255, 217, 61, 0.1);
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

.donate-link:hover {
    background: rgba(255, 217, 61, 0.2);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    max-width: 800px;
    max-height: 80vh;
    width: 90%;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.2rem;
    color: var(--accent-primary);
}

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

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

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* Help Tabs */
.help-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
}

.help-tab {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.help-tab:hover {
    background: var(--border-color);
    color: var(--text-primary);
}

.help-tab.active {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.help-section {
    display: none;
}

.help-section.active {
    display: block;
}

.help-section h3 {
    margin-bottom: 15px;
    color: var(--accent-primary);
}

.help-section h4 {
    margin: 20px 0 10px;
    color: var(--text-primary);
}

.help-section table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
}

.help-section td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.help-section td:first-child {
    width: 40%;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
}

.help-section code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
}

.help-section pre {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: var(--radius);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
    overflow-x: auto;
    margin: 10px 0;
}

.help-section p {
    color: var(--text-secondary);
    margin: 8px 0;
}

/* Examples Modal */
.examples-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.example-item {
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
}

.example-item:hover {
    background: var(--border-color);
    transform: translateY(-2px);
}

.example-item h4 {
    color: var(--accent-primary);
    margin-bottom: 5px;
}

.example-item p {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

/* Difficulty Badges */
.difficulty-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 8px;
}

.difficulty-badge.beginner {
    background: #22c55e;
    color: #fff;
}

.difficulty-badge.intermediate {
    background: #f59e0b;
    color: #fff;
}

.difficulty-badge.advanced {
    background: #ef4444;
    color: #fff;
}

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

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-color);
}

/* Responsive */
@media (max-width: 900px) {
    #main {
        flex-direction: column;
    }

    #editor-panel, #canvas-panel {
        min-width: unset;
        min-height: 150px;
        flex: 1;
    }

    .tagline {
        display: none;
    }

    #output-panel {
        height: 80px;
        min-height: 60px;
    }
}

/* Landscape orientation on tablets keeps side-by-side */
@media (max-width: 900px) and (orientation: landscape) {
    #main {
        flex-direction: row;
    }

    #editor-panel, #canvas-panel {
        min-height: unset;
        flex: 1;
    }
}

@media (max-width: 600px) {
    #header {
        flex-direction: column;
        gap: 8px;
        padding: 8px 12px;
    }

    .header-right {
        flex-wrap: wrap;
        justify-content: center;
        gap: 4px;
    }

    /* Hide button text, show only icons */
    .header-right .btn span:not(.icon) {
        display: none;
    }

    .btn {
        padding: 8px 10px;
        min-width: auto;
    }

    .speed-select {
        width: 70px;
        font-size: 12px;
        padding: 6px 8px;
    }

    #footer {
        flex-direction: column;
        gap: 8px;
        padding: 8px 12px;
    }

    .footer-left, .footer-center, .footer-right {
        justify-content: center;
        width: 100%;
    }

    /* Modal improvements */
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 5vh auto;
    }

    .modal-body {
        max-height: 70vh;
        overflow-y: auto;
        padding: 15px;
    }

    /* Help modal scrollable tables */
    .help-content table {
        display: block;
        overflow-x: auto;
    }

    .help-tabs {
        flex-wrap: wrap;
        gap: 4px;
    }

    .help-tab {
        padding: 6px 10px;
        font-size: 12px;
    }

    /* Tutorials modal horizontal sidebar */
    .tutorials-body {
        flex-direction: column;
    }

    .tutorials-sidebar {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        gap: 8px;
        padding: 10px;
        flex-shrink: 0;
    }

    .tutorial-item {
        flex-shrink: 0;
        padding: 8px 12px;
    }

    .tutorials-content {
        padding: 15px;
    }

    /* Tutorial progress responsive */
    .tutorial-progress {
        flex-wrap: wrap;
        padding: 10px 15px;
        gap: 8px;
    }

    .progress-bar {
        width: 100%;
        order: 2;
    }

    .progress-text {
        font-size: 0.8rem;
    }

    .btn-complete {
        padding: 10px 20px;
        font-size: 0.9rem;
    }

    /* Canvas panel adjustments */
    #canvas-panel {
        min-width: unset;
    }

    #canvas-container {
        padding: 5px;
    }

    /* Coordinates display smaller */
    .coordinates {
        font-size: 0.7rem;
        padding: 2px 6px;
    }
}

/* Portrait mode on phones - give more space to canvas */
@media (max-width: 600px) and (orientation: portrait) {
    #editor-panel {
        flex: 1;
        min-height: 120px;
    }

    #canvas-panel {
        flex: 1.5;
    }
}

/* Very small phones (iPhone SE, etc.) */
@media (max-width: 480px) {
    #header {
        padding: 6px 10px;
    }

    .header-left h1 {
        font-size: 1.2rem;
    }

    .header-right {
        gap: 3px;
    }

    .btn {
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    .speed-select {
        width: 60px;
        font-size: 11px;
    }

    /* Hide coordinates on very small screens */
    .coordinates {
        display: none;
    }

    #footer {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .donate-link {
        padding: 3px 8px;
        font-size: 0.75rem;
    }

    /* Panel headers smaller */
    .panel-header {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    /* Examples grid single column */
    .examples-list {
        grid-template-columns: 1fr;
    }
}

/* ==================== NEW FEATURES ==================== */

/* Light Theme */
body.light-theme {
    --bg-primary: #f5f5f5;
    --bg-secondary: #ffffff;
    --bg-tertiary: #e8e8e8;
    --text-primary: #2d2d2d;
    --text-secondary: #666666;
    --border-color: #d0d0d0;
    --canvas-bg: #ffffff;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body.light-theme #code-editor {
    background: #fafafa;
}

body.light-theme #output-console {
    background: #f0f0f0;
}

body.light-theme .btn-primary {
    color: #ffffff;
}

/* Speed Select */
.speed-select {
    padding: 8px 12px;
    border: none;
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
}

.speed-select:hover {
    background: var(--border-color);
}

.speed-select:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* Warning Button (Step) */
.btn-warning {
    background: var(--accent-warning);
    color: #1e1e2e;
}

.btn-warning:hover {
    background: #e6c235;
}

/* Learn Button */
.btn-learn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-learn:hover {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);
}

/* Icon-only Button */
.btn-icon {
    padding: 8px 10px;
}

/* Editor Wrapper for Syntax Highlighting */
#editor-wrapper {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* Syntax highlighting disabled - caused rendering issues */
#syntax-highlight {
    display: none;
}

#editor-wrapper #code-editor {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    padding: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    caret-color: var(--text-primary);
    border: none;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    tab-size: 2;
}

/* Syntax Highlighting Colors */
.token-keyword { color: #569cd6; }
.token-number { color: #ce9178; }
.token-comment { color: #6a9955; font-style: italic; }
.token-variable { color: #c586c0; }
.token-string { color: #ce9178; }
.token-bracket { color: #ffd700; }
.token-operator { color: #d4d4d4; }
.token-procedure { color: #dcdcaa; }

body.light-theme .token-keyword { color: #0000ff; }
body.light-theme .token-number { color: #098658; }
body.light-theme .token-comment { color: #008000; }
body.light-theme .token-variable { color: #af00db; }
body.light-theme .token-string { color: #a31515; }
body.light-theme .token-bracket { color: #0431fa; }
body.light-theme .token-procedure { color: #795e26; }

/* Line Highlighting for Debugger */
.line-highlight {
    background: rgba(78, 205, 196, 0.2);
    display: block;
}

/* Variables Panel */
.variables-panel {
    border-top: 1px solid var(--border-color);
    max-height: 150px;
    transition: max-height 0.3s ease;
}

.variables-panel.collapsed {
    max-height: 32px;
    overflow: hidden;
}

.variables-panel .panel-header {
    cursor: pointer;
}

#variables-content {
    padding: 8px 12px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    overflow-y: auto;
    max-height: 118px;
}

.var-item {
    display: flex;
    justify-content: space-between;
    padding: 2px 0;
    border-bottom: 1px solid var(--border-color);
}

.var-name {
    color: var(--accent-primary);
}

.var-value {
    color: var(--text-secondary);
}

/* Tutorials Modal */
.modal-large {
    max-width: 900px;
    height: 80vh;
}

.tutorials-body {
    display: flex;
    gap: 20px;
    height: 100%;
    padding: 0;
}

.tutorials-sidebar {
    width: 200px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    padding: 10px;
    overflow-y: auto;
}

.tutorial-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    margin-bottom: 5px;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--text-secondary);
}

.tutorial-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.tutorial-item.active {
    background: var(--accent-primary);
    color: var(--bg-primary);
}

.lesson-num {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.8rem;
}

.tutorial-item.active .lesson-num {
    background: rgba(255,255,255,0.3);
}

/* Tutorial progress bar */
.tutorial-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    margin-bottom: 15px;
}

.progress-bar {
    flex: 1;
    height: 10px;
    background: var(--bg-secondary);
    border-radius: 5px;
    overflow: hidden;
    min-width: 100px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary), #4ade80);
    border-radius: 5px;
    transition: width 0.4s ease;
    min-width: 0;
}

.progress-text {
    font-size: 0.85rem;
    color: var(--text-secondary);
    white-space: nowrap;
    font-weight: 500;
}

.progress-text span {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Completed lesson checkmark */
.tutorial-item.completed .lesson-num {
    position: relative;
    background: #22c55e;
    color: transparent;
}

.tutorial-item.completed .lesson-num::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.85rem;
    font-weight: bold;
    color: white;
}

.tutorial-item.completed:not(.active) {
    color: var(--text-primary);
}

.tutorial-item.completed:not(.active):hover .lesson-num {
    background: #16a34a;
}

.tutorial-item.completed.active .lesson-num {
    background: rgba(34, 197, 94, 0.8);
}

.tutorials-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.tutorials-content h3 {
    color: var(--accent-primary);
    margin-bottom: 15px;
}

.tutorials-content p {
    margin-bottom: 15px;
    line-height: 1.6;
}

.tutorials-content pre {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: var(--radius);
    margin: 15px 0;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    overflow-x: auto;
}

.tutorials-content .try-it {
    background: var(--accent-primary);
    color: var(--bg-primary);
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    margin-top: 10px;
}

.tutorials-content .try-it:hover {
    background: var(--accent-secondary);
}

.tutorial-tip {
    background: rgba(78, 205, 196, 0.1);
    border-left: 3px solid var(--accent-primary);
    padding: 10px 15px;
    margin: 15px 0;
    border-radius: 0 var(--radius) var(--radius) 0;
}

.tutorial-table {
    width: 100%;
    border-collapse: collapse;
    margin: 15px 0;
}

.tutorial-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    vertical-align: top;
}

.tutorial-table td:first-child {
    width: 40%;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.9rem;
}

.tutorial-table code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
}

.tutorial-code {
    background: var(--bg-tertiary);
    padding: 15px;
    border-radius: var(--radius);
    margin: 15px 0;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 14px;
    white-space: pre-wrap;
}

.try-code {
    display: inline-block;
    background: var(--accent-primary);
    color: var(--bg-primary);
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius);
    cursor: pointer;
    font-weight: 500;
    margin: 10px 0;
    transition: all 0.2s ease;
}

.try-code:hover {
    background: var(--accent-secondary);
}

/* Challenge hints and solutions */
.challenge-help {
    margin: 15px 0;
    padding: 15px;
    background: var(--bg-tertiary);
    border-radius: var(--radius);
    border-left: 4px solid var(--accent-primary);
}

.btn-hint, .btn-solution {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    padding: 6px 12px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.85rem;
    margin-right: 8px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.btn-hint:hover {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.btn-solution:hover {
    background: #22c55e;
    color: white;
    border-color: #22c55e;
}

.hint-box, .solution-box {
    margin-top: 10px;
    padding: 12px;
    border-radius: var(--radius);
}

.hint-box {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.solution-box {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.hint-box.hidden, .solution-box.hidden {
    display: none;
}

/* Mark Complete button */
.mark-complete-section {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    text-align: center;
}

.btn-success {
    background: #22c55e;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-success:hover {
    background: #16a34a;
    transform: scale(1.02);
}

.btn-complete {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
    color: white;
    border: none;
    padding: 12px 28px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(34, 197, 94, 0.3);
}

.btn-complete:hover {
    background: linear-gradient(135deg, #16a34a 0%, #15803d 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
}

.btn-complete:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(34, 197, 94, 0.3);
}

.btn-complete:disabled,
.btn-complete.completed {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    cursor: default;
    box-shadow: none;
    transform: none;
}

.btn-complete.completed {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.btn-complete.completed::before {
    content: '✓ ';
}

.completed-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #22c55e;
    font-weight: 600;
    font-size: 1.1rem;
}

.completed-badge::before {
    content: '✓';
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: #22c55e;
    color: white;
    border-radius: 50%;
    font-size: 0.85rem;
}

.tutorials-content h4 {
    color: var(--text-primary);
    margin: 20px 0 10px;
}

.tutorials-content ul {
    margin: 10px 0 15px 20px;
    line-height: 1.8;
}

.var-section {
    padding: 4px 0;
    color: var(--text-secondary);
}

.var-empty {
    color: var(--text-secondary);
    font-style: italic;
}

/* Share Modal */
.modal-small {
    max-width: 500px;
}

.share-url-container {
    display: flex;
    gap: 10px;
    margin: 15px 0;
}

.share-url-container input {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.85rem;
}

.share-note {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Current Line Indicator */
.current-line {
    background: rgba(255, 217, 61, 0.15) !important;
}

/* Mobile touch improvements */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets for mobile */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }

    .help-tab, .tutorial-item, .example-item {
        min-height: 44px;
    }

    /* Better scrolling on touch devices */
    .modal-body, .tutorials-content, #output-console {
        -webkit-overflow-scrolling: touch;
    }

    /* Prevent text selection on buttons */
    .btn, .help-tab, .tutorial-item {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* ==================== ACCESSIBILITY ==================== */

/* Focus indicators for all interactive elements */
.btn:focus,
.btn-small:focus,
.btn-close:focus,
.help-tab:focus,
.example-item:focus,
.tutorial-item:focus {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* High contrast focus for better visibility */
.btn:focus-visible,
.btn-small:focus-visible,
.btn-close:focus-visible {
    outline: 3px solid var(--accent-primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(78, 205, 196, 0.2);
}

/* Skip link - visually hidden until focused */
.skip-link {
    position: absolute;
    top: -100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-primary);
    color: var(--bg-primary);
    padding: 12px 24px;
    border-radius: var(--radius);
    font-weight: 600;
    z-index: 9999;
    text-decoration: none;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 10px;
    outline: 3px solid var(--accent-secondary);
    outline-offset: 2px;
}

/* Visually hidden but accessible to screen readers */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }

    .btn:hover,
    .example-item:hover,
    .try-code:hover,
    .btn-success:hover {
        transform: none !important;
    }

    .progress-fill {
        transition: none !important;
    }
}

/* ============== PROCEDURE LIBRARY ============== */

.library-body {
    display: flex;
    gap: 20px;
    min-height: 450px;
    max-height: 60vh;
}

.library-sidebar {
    width: 160px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.library-search {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg-secondary);
    color: var(--text);
    font-size: 14px;
}

.library-search:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.library-search::placeholder {
    color: var(--text-secondary);
}

.library-categories {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.category-btn {
    text-align: left;
    padding: 10px 14px;
    border: none;
    background: transparent;
    color: var(--text);
    cursor: pointer;
    border-radius: var(--radius);
    font-size: 14px;
    transition: background 0.15s ease, color 0.15s ease;
}

.category-btn:hover {
    background: var(--bg-tertiary);
}

.category-btn.active {
    background: var(--accent);
    color: white;
    font-weight: 500;
}

.category-btn:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

/* Library Content Grid */
.library-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}

.library-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.library-empty p {
    margin: 8px 0;
}

/* Procedure Cards */
.library-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.library-card:hover {
    border-color: var(--accent);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.library-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.library-card-header h3 {
    margin: 0;
    font-family: var(--font-mono);
    font-size: 16px;
    color: var(--accent);
    font-weight: 600;
}

.badge {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 10px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-builtin {
    background: var(--accent);
    color: white;
}

.badge-user {
    background: var(--success);
    color: white;
}

.library-card-desc {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    line-height: 1.4;
}

.library-card-code {
    background: var(--bg-primary);
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 11px;
    font-family: var(--font-mono);
    max-height: 100px;
    overflow-y: auto;
    margin: 0;
    white-space: pre;
    line-height: 1.4;
    border: 1px solid var(--border);
}

.library-card-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.library-card-actions .btn {
    flex: 1;
    justify-content: center;
}

.btn-danger {
    background: var(--error);
    color: white;
}

.btn-danger:hover {
    background: #c0392b;
}

/* Modal Footer for Library */
.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
    display: flex;
    justify-content: center;
}

/* Mobile Responsive */
@media (max-width: 700px) {
    .library-body {
        flex-direction: column;
        min-height: auto;
        max-height: none;
    }

    .library-sidebar {
        width: 100%;
    }

    .library-categories {
        flex-direction: row;
        flex-wrap: wrap;
        gap: 6px;
    }

    .category-btn {
        padding: 8px 12px;
        font-size: 13px;
    }

    .library-content {
        max-height: 50vh;
    }

    .library-grid {
        grid-template-columns: 1fr;
    }
}
