* {
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background: #f5f5f5;
    color: #333;
}

header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

h1 {
    margin: 0 0 10px 0;
    color: #2563eb;
    font-size: 28px;
}

.subtitle {
    color: #666;
    font-size: 14px;
}

#notebook {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.cell {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    overflow: hidden;
    border: 2px solid transparent;
    transition: border-color 0.2s;
}

.cell:hover {
    border-color: #e5e7eb;
}

.cell-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
}

.cell-label {
    font-size: 12px;
    color: #6b7280;
    font-weight: 600;
}

.cell-actions {
    display: flex;
    gap: 5px;
    align-items: center;
}

.cell-action-btn {
    background: none;
    border: none;
    color: #6b7280;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    transition: background 0.2s;
}

.cell-action-btn:hover {
    background: #e5e7eb;
    color: #374151;
}

.template-select {
    font-size: 12px;
    padding: 4px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: white;
    color: #374151;
}

.code-editor {
    width: 100%;
    min-height: 100px;
    font-family: 'Fira Code', 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 14px;
    padding: 15px;
    border: none;
    resize: vertical;
    line-height: 1.5;
    color: #1f2937;
    background: #fafafa;
    border-left: 3px solid #2563eb;
    tab-size: 2;
}

.code-editor:focus {
    outline: none;
    background: white;
    border-left-color: #1d4ed8;
}

.cell-controls {
    padding: 10px 15px;
    background: #fafafa;
    border-top: 1px solid #e5e7eb;
    display: flex;
    gap: 10px;
    align-items: center;
}

.run-button {
    background: #2563eb;
    color: white;
    border: none;
    padding: 8px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

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

.run-button:active {
    transform: scale(0.98);
}

.run-button.running {
    background: #9ca3af;
    cursor: wait;
}

.run-button.running::before {
    content: "⏳";
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.clear-button {
    background: #ef4444;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}

.clear-button:hover {
    background: #dc2626;
}

.output-area {
    padding: 15px;
    background: white;
    min-height: 40px;
    border-top: 1px solid #e5e7eb;
}

.output {
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-5px); }
    to { opacity: 1; transform: translateY(0); }
}

.output-message {
    font-size: 16px;
    color: #059669;
    font-weight: 600;
    margin-bottom: 10px;
}

.output-data {
    margin-top: 10px;
}

.data-number {
    font-size: 32px;
    font-weight: 700;
    color: #2563eb;
    margin: 15px 0;
}

.data-array {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 10px 0;
}

.array-item {
    background: #eff6ff;
    color: #1e40af;
    padding: 6px 12px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
}

.data-json {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
    overflow-x: auto;
}

.data-json pre {
    margin: 0;
    font-family: 'Monaco', 'Menlo', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    color: #374151;
}

.output-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 12px;
    color: #991b1b;
    font-size: 14px;
}

.output-error strong {
    display: block;
    margin-bottom: 5px;
    color: #dc2626;
}

.execution-time {
    font-size: 12px;
    color: #6b7280;
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px solid #e5e7eb;
}

.add-cell-btn {
    background: white;
    color: #2563eb;
    border: 2px dashed #2563eb;
    padding: 12px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    margin: 10px 0;
    width: 100%;
    transition: all 0.2s;
}

.add-cell-btn:hover {
    background: #eff6ff;
    border-color: #1d4ed8;
}

.context-info {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
    padding: 10px 15px;
    margin-top: 20px;
    font-size: 13px;
    color: #92400e;
}

.context-info strong {
    color: #78350f;
}

.empty-output {
    color: #9ca3af;
    font-style: italic;
    font-size: 14px;
}

/* Math-specific styling */
.math-result {
    text-align: center;
    margin: 20px 0;
    padding: 15px;
    background: #f0f9ff;
    border-radius: 8px;
    border: 1px solid #bae6fd;
}

.math-title {
    font-size: 18px;
    color: #0369a1;
    margin-bottom: 10px;
    font-weight: 600;
}

.math-value {
    font-size: 32px;
    font-weight: bold;
    color: #2563eb;
    font-family: 'Times New Roman', serif;
}

/* Network error specific */
.network-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    padding: 12px;
}

.network-error strong {
    color: #dc2626;
    display: block;
    margin-bottom: 8px;
}

.network-error .error-detail {
    font-size: 12px;
    color: #991b1b;
    margin-top: 5px;
}