* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    background: #f5f7fb;
    color: #1f2937;
    line-height: 1.6;
}

body.modal-open {
    overflow: hidden;
}

.topbar {
    background: #2563eb;
    color: white;
    padding: 24px 36px;
}

.topbar h1 {
    margin: 0;
    font-size: 30px;
}

.topbar p {
    margin: 4px 0 0;
    opacity: 0.9;
}

.layout {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: calc(100vh - 120px);
}

.sidebar {
    background: white;
    border-right: 1px solid #e5e7eb;
    padding: 28px 20px;
}

.sidebar h2 {
    margin-top: 0;
    font-size: 18px;
}

.lesson {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    margin-bottom: 8px;
    border-radius: 10px;
    text-decoration: none;
    color: #374151;
}

.lesson span {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #e5e7eb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    flex: 0 0 auto;
}

.lesson.active {
    background: #dbeafe;
    color: #1d4ed8;
    font-weight: bold;
}

.lesson.active span {
    background: #2563eb;
    color: white;
}

.lesson.disabled {
    opacity: 0.5;
}

.content {
    max-width: 950px;
    width: 100%;
    padding: 32px;
    margin: 0 auto;
}

.hero {
    margin-bottom: 24px;
}

.hero h2 {
    font-size: 34px;
    margin: 8px 0 4px;
}

.badge {
    display: inline-block;
    background: #dbeafe;
    color: #1d4ed8;
    font-size: 13px;
    font-weight: bold;
    padding: 5px 10px;
    border-radius: 999px;
}

.card {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 22px;
    box-shadow: 0 3px 12px rgba(0,0,0,0.04);
}

.card h3 {
    margin-top: 0;
    color: #111827;
}

pre {
    background: #111827;
    color: #f9fafb;
    padding: 18px;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 15px;
}

code,
textarea {
    font-family: Consolas, Monaco, "Courier New", monospace;
}

p code,
li code,
h4 code {
    background: #eef2ff;
    color: #3730a3;
    padding: 2px 5px;
    border-radius: 5px;
}

.tip {
    background: #fff7d6;
    border-left: 4px solid #f59e0b;
    padding: 14px 16px;
    border-radius: 8px;
    margin-top: 15px;
}

.result {
    background: #ecfdf5;
    border-left: 4px solid #10b981;
    padding: 14px 16px;
    border-radius: 8px;
    margin-top: 15px;
}

.challenge {
    background: #eff6ff;
    padding: 14px 16px;
    border-radius: 8px;
    margin: 12px 0 18px;
}

.try-button,
.run-button,
.close-button {
    border: 0;
    border-radius: 9px;
    padding: 11px 18px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
}

.try-button,
.run-button {
    background: #2563eb;
    color: white;
}

.try-button:hover,
.run-button:hover {
    background: #1d4ed8;
}

.run-button:disabled {
    opacity: 0.6;
    cursor: wait;
}

.close-button {
    background: #e5e7eb;
    color: #111827;
}

.close-button:hover {
    background: #d1d5db;
}

.small {
    font-size: 14px;
    color: #6b7280;
}

footer {
    text-align: center;
    color: #6b7280;
    padding: 24px;
}

.playground-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.72);
    padding: 20px;
    display: none;
}

.playground-modal.open {
    display: flex;
}

.playground-window {
    width: min(1500px, 100%);
    height: calc(100vh - 40px);
    margin: auto;
    background: white;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 80px rgba(0,0,0,0.28);
}

.playground-header {
    min-height: 74px;
    padding: 16px 22px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
}

.playground-header strong {
    display: block;
    font-size: 20px;
}

.playground-header span {
    display: block;
    color: #6b7280;
    font-size: 13px;
    margin-top: 2px;
}

.playground-body {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.editor-panel,
.output-panel {
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.editor-panel {
    border-right: 1px solid #d1d5db;
    background: #111827;
}

.output-panel {
    background: white;
}

.panel-title {
    min-height: 58px;
    padding: 12px 18px;
    border-bottom: 1px solid #d1d5db;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #f8fafc;
}

.editor-panel .panel-title {
    background: #0f172a;
    color: white;
    border-color: #334155;
}

.panel-title span {
    font-weight: bold;
}

.panel-title small {
    color: #64748b;
}

.editor-panel .panel-title small {
    color: #94a3b8;
}

#phpCode {
    flex: 1;
    width: 100%;
    resize: none;
    border: 0;
    outline: 0;
    padding: 22px;
    background: #111827;
    color: #f8fafc;
    font-size: 16px;
    line-height: 1.6;
    tab-size: 4;
}

.php-output {
    flex: 1;
    width: 100%;
    border: 0;
    background: white;
}

.panel-footer {
    min-height: 68px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
}

.editor-footer {
    background: #0f172a;
    border-top: 1px solid #334155;
    justify-content: space-between;
}

.output-footer {
    border-top: 1px solid #e5e7eb;
    justify-content: flex-end;
}

.run-message {
    color: #cbd5e1;
    font-size: 13px;
}

.run-message.success {
    color: #86efac;
}

.run-message.error {
    color: #fca5a5;
}

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

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid #e5e7eb;
    }

    .content {
        padding: 20px;
    }

    .playground-modal {
        padding: 0;
    }

    .playground-window {
        height: 100vh;
        border-radius: 0;
    }

    .playground-body {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }

    .editor-panel {
        border-right: 0;
        border-bottom: 1px solid #d1d5db;
    }
}
