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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    padding: 20px;
    max-width: 900px;
    margin: 0 auto;
    line-height: 1.6;
}

h1 {
    margin-bottom: 20px;
    font-size: 1.8rem;
}

h2 {
    margin-bottom: 10px;
    font-size: 1.3rem;
}

h2:focus {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

summary h2 {
    display: inline;
    margin: 0;
    cursor: pointer;
}

summary {
    cursor: pointer;
    user-select: none;
    margin-bottom: 15px;
}

details {
    margin-bottom: 20px;
}

h3 {
    margin-top: 10px;
    margin-bottom: 8px;
    font-size: 1.1rem;
    color: #333;
}

summary h3 {
    display: inline;
    margin: 0;
}

#examples-container {
    margin-left: 20px;
}

.chapter-section {
    margin-bottom: 20px;
}

.chapter-section > details {
    margin-top: 8px;
    margin-left: 20px;
}

.chapter-examples {
    margin-left: 20px;
    margin-top: 8px;
}

.chapter-examples ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chapter-examples li {
    margin: 5px 0;
}

.example-btn {
    background-color: #f0f0f0;
    border: 1px solid #ccc;
    padding: 8px 16px;
    font-size: 14px;
}

.example-btn:hover {
    background-color: #e0e0e0;
}

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

label {
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
}

#code-editor {
    width: 100%;
    min-height: 250px;
    padding: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    border: 2px solid #ccc;
    border-radius: 4px;
    resize: vertical;
    background-color: #f5f5f5;
}

#code-editor:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

button {
    padding: 10px 20px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
}

#run-button {
    background-color: #0066cc;
    color: white;
}

#run-button:hover:not(:disabled) {
    background-color: #0052a3;
}

#run-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

#clear-input-button,
#clear-output-button {
    background-color: #666;
    color: white;
    margin-bottom: 8px;
    margin-top: 4px;
}

#clear-input-button:hover,
#clear-output-button:hover {
    background-color: #555;
}

button:focus {
    outline: 3px solid #0066cc;
    outline-offset: 2px;
}

#output-container {
    margin-top: 10px;
}

#output {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 14px;
    background-color: #1e1e1e;
    color: #d4d4d4;
    border: 2px solid #333;
    border-radius: 4px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-y: auto;
}

.error {
    color: #f48771;
}

.status {
    font-size: 14px;
    margin-bottom: 8px;
    font-style: italic;
    color: #666;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Custom input dialog */
.input-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.input-dialog[hidden] {
    display: none;
}

.input-dialog-content {
    background-color: white;
    padding: 24px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    min-width: 400px;
    max-width: 90%;
}

.input-dialog-content label {
    font-size: 16px;
    margin-bottom: 12px;
    display: block;
    color: #333;
}

.input-dialog-content input {
    width: 100%;
    padding: 10px;
    font-size: 14px;
    border: 2px solid #ccc;
    border-radius: 4px;
    margin-bottom: 16px;
    font-family: 'Consolas', 'Monaco', monospace;
}

.input-dialog-content input:focus {
    outline: none;
    border-color: #0066cc;
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.input-dialog-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.input-dialog-buttons button {
    padding: 8px 20px;
    font-size: 14px;
}

#input-dialog-ok {
    background-color: #0066cc;
    color: white;
}

#input-dialog-ok:hover {
    background-color: #0052a3;
}

#input-dialog-cancel {
    background-color: #666;
    color: white;
}

#input-dialog-cancel:hover {
    background-color: #555;
}

@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 1.5rem;
    }

    .input-dialog-content {
        min-width: 300px;
    }
}
