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

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #0f0f1a;
    color: #e0e0e0;
    height: 100vh;
    overflow: hidden;
}

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

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    background: #161625;
    border-bottom: 1px solid #2a2a3e;
    flex-shrink: 0;
    gap: 12px;
    flex-wrap: wrap;
}

.logo {
    font-size: 1.15rem;
    font-weight: 700;
    color: #e94560;
    white-space: nowrap;
}

.logo i {
    margin-right: 8px;
}

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

.tb-btn {
    background: #2a2a3e;
    border: none;
    color: #ccc;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.15s;
    white-space: nowrap;
}

.tb-btn:hover {
    background: #3a3a52;
    color: #fff;
}

.tb-btn.small {
    padding: 4px 10px;
    font-size: 0.75rem;
}

.api-key-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
}

.api-input {
    background: #1e1e30;
    border: 1px solid #3a3a52;
    color: #e0e0e0;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    width: 180px;
    outline: none;
}

.api-input:focus {
    border-color: #e94560;
}

.api-input::placeholder {
    color: #666;
}

.model-select {
    background: #1e1e30;
    border: 1px solid #3a3a52;
    color: #e0e0e0;
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    outline: none;
    max-width: 240px;
    cursor: pointer;
}

.model-select:focus {
    border-color: #e94560;
}

.model-select:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.main-split {
    display: flex;
    flex: 1;
    min-height: 0;
}

.editor-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2a2a3e;
    min-width: 0;
}

.tabs {
    display: flex;
    background: #12121e;
    border-bottom: 1px solid #2a2a3e;
    flex-shrink: 0;
}

.tab {
    padding: 8px 20px;
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    transition: all 0.15s;
    border-bottom: 2px solid transparent;
}

.tab:hover {
    color: #ccc;
}

.tab.active {
    color: #e94560;
    border-bottom-color: #e94560;
}

.editor-content {
    flex: 1;
    position: relative;
    min-height: 0;
}

.code-area {
    display: none;
    width: 100%;
    height: 100%;
    background: #0d0d1a;
    color: #e0e0e0;
    border: none;
    outline: none;
    resize: none;
    font-family: 'Cascadia Code', 'Fira Code', 'JetBrains Mono', 'Consolas', monospace;
    font-size: 14px;
    line-height: 1.6;
    padding: 16px;
    tab-size: 2;
    position: absolute;
    top: 0;
    left: 0;
}

.code-area.active {
    display: block;
}

.code-area:focus {
    background: #0a0a14;
}

.preview-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.preview-toolbar {
    padding: 8px 16px;
    background: #12121e;
    border-bottom: 1px solid #2a2a3e;
    font-size: 0.82rem;
    font-weight: 600;
    color: #888;
    flex-shrink: 0;
}

.preview-toolbar i {
    margin-right: 6px;
}

#previewFrame {
    flex: 1;
    border: none;
    background: #fff;
    width: 100%;
}

.bottom-split {
    display: flex;
    height: 200px;
    border-top: 1px solid #2a2a3e;
    flex-shrink: 0;
    min-height: 0;
}

.prompt-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #2a2a3e;
    min-width: 0;
}

.prompt-header {
    padding: 6px 14px;
    background: #12121e;
    border-bottom: 1px solid #2a2a3e;
    font-size: 0.8rem;
    font-weight: 600;
    color: #888;
    flex-shrink: 0;
}

.prompt-header i {
    margin-right: 6px;
}

.prompt-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 10px;
    gap: 8px;
}

.prompt-body textarea {
    flex: 1;
    background: #1a1a2e;
    border: 1px solid #2a2a3e;
    color: #e0e0e0;
    padding: 10px;
    border-radius: 8px;
    resize: none;
    font-family: inherit;
    font-size: 0.85rem;
    outline: none;
    min-height: 60px;
}

.prompt-body textarea:focus {
    border-color: #e94560;
}

.prompt-body textarea::placeholder {
    color: #555;
}

.prompt-body button {
    align-self: flex-end;
    background: #e94560;
    border: none;
    color: #fff;
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    transition: all 0.15s;
}

.prompt-body button:hover {
    background: #d63850;
}

.prompt-body button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.explainer-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.explainer-header {
    padding: 6px 14px;
    background: #12121e;
    border-bottom: 1px solid #2a2a3e;
    font-size: 0.8rem;
    font-weight: 600;
    color: #888;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.explainer-header i {
    margin-right: 6px;
}

.explainer-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px 16px;
    font-size: 0.88rem;
    line-height: 1.6;
    background: #12121e;
}

.explainer-body .placeholder {
    color: #555;
    font-style: italic;
}

.explainer-body p {
    margin-bottom: 8px;
}

.explainer-body code {
    background: #1e1e30;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 0.82rem;
    font-family: 'Cascadia Code', 'Fira Code', monospace;
}

.explainer-body pre {
    background: #0a0a14;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    border: 1px solid #2a2a3e;
}

.explainer-body pre code {
    background: none;
    padding: 0;
}

.explainer-body .error-msg {
    color: #e94560;
}

.explainer-body .loading {
    color: #888;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

@media (max-width: 768px) {
    .main-split {
        flex-direction: column;
    }
    .editor-panel {
        border-right: none;
        border-bottom: 1px solid #2a2a3e;
    }
    .bottom-split {
        flex-direction: column;
        height: auto;
    }
    .prompt-panel {
        border-right: none;
        border-bottom: 1px solid #2a2a3e;
    }
    .api-input {
        width: 120px;
    }
}
