:root {
    --primary: #8B5CF6;
    --primary-hover: #7C3AED;
    --secondary: #A78BFA;
    --accent: #F472B6;
    --bg-color: #0F0A1A;
    --surface-color: rgba(255, 255, 255, 0.05);
    --surface-border: rgba(255, 255, 255, 0.1);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --text-main: #FFFFFF;
    --text-muted: #9CA3AF;
    --border-radius: 16px;
    --transition: all 0.25s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.glass-bg {
    position: fixed;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle at 50% 50%, rgba(139, 92, 246, 0.1), transparent 40%),
                radial-gradient(circle at 80% 20%, rgba(244, 114, 182, 0.05), transparent 30%);
    z-index: -1;
    pointer-events: none;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 1rem;
    gap: 1rem;
}

header {
    text-align: left;
    padding: 1rem 2rem;
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.workspace {
    display: grid;
    grid-template-columns: 250px 1fr 1fr;
    gap: 1rem;
    flex: 1;
    min-height: 0; /* needed for nested scrolling */
}

.card {
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    border-radius: var(--border-radius);
    backdrop-filter: blur(12px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.card h2 {
    font-size: 1.1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--surface-border);
    background: rgba(0, 0, 0, 0.2);
}

.sidebar {
    display: flex;
    flex-direction: column;
}

.block-list {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    overflow-y: auto;
    flex: 1;
}

.draggable-block {
    background: rgba(139, 92, 246, 0.1);
    border: 1px solid rgba(139, 92, 246, 0.3);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    transition: var(--transition);
    user-select: none;
}

.draggable-block:hover {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.draggable-block:active {
    cursor: grabbing;
}

.settings-panel {
    padding: 1rem;
    border-top: 1px solid var(--surface-border);
    background: rgba(0, 0, 0, 0.2);
}

.settings-panel h3 {
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

input[type="text"],
select,
textarea {
    width: 100%;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--surface-border);
    color: var(--text-main);
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    font-size: 0.9rem;
    transition: var(--transition);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139, 92, 246, 0.2);
}

.builder-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--surface-border);
    background: rgba(0, 0, 0, 0.2);
}

.builder-header h2 {
    border-bottom: none;
}

.clear-btn {
    margin-right: 1rem;
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    color: #ef4444;
    border-color: rgba(239, 68, 68, 0.5);
}

.clear-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

.drop-zone {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 200px;
}

.drop-zone.drag-over {
    background: rgba(139, 92, 246, 0.05);
    box-shadow: inset 0 0 0 2px var(--primary);
}

.empty-state {
    margin: auto;
    color: var(--text-muted);
    font-style: italic;
    padding: 2rem;
    border: 1px dashed var(--surface-border);
    border-radius: 12px;
    text-align: center;
}

.builder-block {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--surface-border);
    border-radius: 8px;
    padding: 1rem;
    position: relative;
    cursor: grab;
    animation: fadeIn 0.3s ease;
}

.builder-block.dragging {
    opacity: 0.5;
}

.builder-block-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.builder-block-title {
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--secondary);
}

.builder-block-actions {
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    background: var(--surface-color);
    border: 1px solid var(--surface-border);
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.action-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.1);
}

.action-btn.delete:hover {
    color: #ef4444;
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.builder-block-preview {
    font-size: 0.85rem;
    color: var(--text-muted);
    background: rgba(0,0,0,0.2);
    padding: 0.5rem;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--surface-border);
    background: rgba(0, 0, 0, 0.2);
}

.preview-header h2 {
    border-bottom: none;
}

.preview-actions {
    display: flex;
    gap: 0.5rem;
    margin-right: 1rem;
}

.btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
}

.btn.primary:hover {
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn.secondary {
    background: var(--surface-color);
    color: var(--text-main);
}

.btn.outline {
    background: transparent;
    border: 1px solid var(--surface-border);
}

.btn.outline:hover {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
}

.preview-content-wrapper {
    flex: 1;
    overflow-y: auto;
    position: relative;
    background: #0d1117; /* GitHub dark mode bg */
}

#visual-preview {
    padding: 2rem;
    color: #c9d1d9;
}

#markdown-code {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    padding: 1.5rem;
    background: #0d1117;
    color: #58a6ff;
    font-family: 'Fira Code', monospace;
    font-size: 0.85rem;
    border: none;
    resize: none;
}

.hidden {
    display: none !important;
}

/* GitHub Markdown Basic Styles */
.markdown-body h1, .markdown-body h2 { border-bottom: 1px solid #30363d; padding-bottom: 0.3em; margin-top: 24px; margin-bottom: 16px; font-weight: 600; line-height: 1.25; }
.markdown-body h1 { font-size: 2em; }
.markdown-body h2 { font-size: 1.5em; }
.markdown-body p { margin-top: 0; margin-bottom: 16px; }
.markdown-body img { max-width: 100%; box-sizing: content-box; background-color: transparent; }
.markdown-body a { color: #58a6ff; text-decoration: none; }
.markdown-body ul { padding-left: 2em; margin-top: 0; margin-bottom: 16px; }

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 100;
}

.modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 500px;
    z-index: 101;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--surface-border);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--surface-border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.close-btn {
    background: none; border: none; font-size: 1.5rem; color: var(--text-muted); cursor: pointer;
}
.close-btn:hover { color: var(--text-main); }

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

/* Badges input specific */
.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
    margin-top: 1rem;
}

.badge-option {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--surface-border);
    padding: 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    text-align: center;
    font-size: 0.8rem;
    transition: var(--transition);
}

.badge-option:hover {
    border-color: var(--secondary);
}

.badge-option.selected {
    background: rgba(139, 92, 246, 0.2);
    border-color: var(--primary);
    color: var(--text-main);
}
