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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f5f5f5;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: #007d9c;
    color: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.header-left {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-title {
    display: inline-block;
}

.header-right {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex-shrink: 0;
    align-items: flex-end;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-refresh {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    justify-content: flex-end;
}

.header-right button {
    background: white;
    color: #007d9c;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s;
}

.header-right button:hover:not(:disabled) {
    background: #f0f0f0;
    transform: translateY(-1px);
}

.header-right button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.header-right label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: white;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
}

.header-right input[type="checkbox"] {
    cursor: pointer;
}

.btn-render {
    background: #28a745 !important;
    color: white !important;
}

.btn-render:hover:not(:disabled) {
    background: #218838 !important;
}

.btn-save {
    background: #ffc107 !important;
    color: #333 !important;
}

.btn-save:hover:not(:disabled) {
    background: #e0a800 !important;
}

.btn-create {
    background: #17a2b8 !important;
    color: white !important;
}

.btn-create:hover:not(:disabled) {
    background: #138496 !important;
}

h1 {
    font-size: 1.5rem;
    font-weight: 500;
    margin: 0;
}

h1 a {
    color: white;
    text-decoration: none;
    transition: opacity 0.2s;
}

h1 a:hover {
    opacity: 0.8;
}

.github-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    transition: all 0.2s;
    flex-shrink: 0;
}

.github-badge:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.github-badge svg {
    width: 24px;
    height: 24px;
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
    margin-top: 0.25rem;
}

main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    overflow: hidden;
}

.config-bar {
    background: white;
    padding: 0.75rem 2rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 2rem;
}

.example-groups {
    display: flex;
    gap: 2rem;
    align-items: center;
}

.example-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: flex-start;
}

.group-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #6c757d;
    letter-spacing: 0.5px;
}

.button-group {
    display: inline-block;
}

.button-group button {
    margin-right: 0.5rem;
}

.config-bar label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
}

.config-bar input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

.status-text {
    margin-left: auto;
    font-size: 0.9rem;
    color: #6c757d;
}

.panel {
    background: white;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 0.75rem 1rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: #495057;
}

.panel-content {
    flex: 1;
    position: relative;
    overflow: hidden;
}

textarea {
    width: 100%;
    height: 100%;
    border: none;
    padding: 1rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.5;
    resize: none;
    outline: none;
}

#preview {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    display: none;
}

#error {
    padding: 1rem;
    overflow: auto;
    background: #fff5f5;
    color: #c53030;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    display: none;
}

button {
    background: #007d9c;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background 0.2s;
}

button:hover {
    background: #006080;
}

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

button.example-root {
    background: #0d7b8f;
}

button.example-root:hover {
    background: #0a5f6b;
}

button.example-nested {
    background: #8b6f47;
}

button.example-nested:hover {
    background: #6d5837;
}

.spinner {
    display: none;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007d9c;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Footer with cheatsheet */
.cheatsheet-footer {
    background: white;
    border-top: 1px solid #e9ecef;
    padding: 0;
    margin: 0;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.1);
    box-sizing: border-box;
}

.cheatsheet-content {
    font-size: 0.85rem;
    line-height: 1.4;
    color: #495057;
    padding: 1rem 0 4rem 2rem;
    overflow: auto;
}

.cheat-section {
    float: left;
    width: 25%;
    padding: 0 10px;
    box-sizing: border-box;
}

.cheat-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #007d9c;
    margin: 0 0 0.5rem 0;
}

.cheatsheet-content h4:first-child {
    margin-top: 0;
}

.cheatsheet-content ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.cheatsheet-content li {
    margin: 0.25rem 0;
}

.cheatsheet-content code {
    background: #f5f5f5;
    padding: 0.2em 0.4em;
    border-radius: 3px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.8em;
}

/* Modal for creating new files */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 2rem;
    border-radius: 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    width: 90%;
    max-width: 400px;
}

.modal-content h2 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #007d9c;
}

.modal-content > div {
    margin-bottom: 1rem;
    display: flex;
    gap: 1rem;
}

.modal-content label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.modal-content input[type="radio"] {
    cursor: pointer;
}

.modal-content input[type="text"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.modal-content input[type="text"]:focus {
    outline: none;
    border-color: #007d9c;
    box-shadow: 0 0 0 3px rgba(0, 125, 156, 0.1);
}

.modal-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
}

.modal-buttons button {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
}

.modal-buttons button:first-child {
    background: #007d9c;
    color: white;
}

.modal-buttons button:first-child:hover {
    background: #006080;
}

.modal-buttons button:last-child {
    background: #e9ecef;
    color: #495057;
}

.modal-buttons button:last-child:hover {
    background: #dee2e6;
}

.close {
    color: #aaa;
    float: right;
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
}

.close:hover,
.close:focus {
    color: #007d9c;
}
