:root {
    /* Amber Gold / Dark Theme */
    --bg-main: #1A150A;
    --bg-panel: rgba(38, 30, 15, 0.8);
    --bg-card: rgba(51, 41, 20, 0.9);
    --border-color: rgba(243, 156, 18, 0.15);
    --border-hover: rgba(243, 156, 18, 0.4);
    
    --text-main: #FDF9F1;
    --text-muted: #A89578;
    
    --primary: #F39C12;
    --primary-hover: #D68910;
    --secondary: #FFEAA7;
    --accent: #00CEC9;
    --success: #2ECC71;
    --danger: #E74C3C;
    
    --ours-bg: rgba(0, 206, 201, 0.15); 
    --ours-border: rgba(0, 206, 201, 0.5);
    --theirs-bg: rgba(243, 156, 18, 0.15);
    --theirs-border: rgba(243, 156, 18, 0.5);
    
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(243, 156, 18, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(0, 206, 201, 0.05) 0%, transparent 40%);
}

.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.flex-1 { flex: 1; min-height: 0; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.h-full { height: 100%; }

.text-primary { color: var(--primary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }

.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Glass Panels */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px 0 rgba(0,0,0,0.3);
    padding: 24px;
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
}
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 700;
}
.brand svg { color: var(--primary); }

.status-badge {
    background: var(--bg-card);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.85rem;
    border: 1px solid var(--border-color);
    color: var(--secondary);
}

/* Main Content */
.main-content {
    flex: 1;
    min-height: 0;
    position: relative;
}

.step-section {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    opacity: 0; pointer-events: none;
    transition: opacity 0.3s ease;
}
.step-section.active {
    opacity: 1; pointer-events: auto;
    position: relative;
    height: 100%;
}

/* Textarea */
.editor-textarea {
    width: 100%;
    flex: 1;
    background: rgba(0,0,0,0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-family: var(--font-mono);
    font-size: 0.95rem;
    padding: 16px;
    resize: none;
    outline: none;
    line-height: 1.6;
    transition: border-color 0.2s;
}
.editor-textarea:focus { border-color: var(--primary); }
.editor-textarea::placeholder { color: rgba(255,255,255,0.2); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: inherit;
}
.btn-sm { padding: 6px 12px; font-size: 0.85rem; }
.btn-icon { padding: 8px; border-radius: 50%; width: 36px; height: 36px; display: inline-flex; justify-content: center; align-items: center; }

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #000; }
.btn-primary:not(:disabled):hover { background: var(--primary-hover); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-card); color: var(--text-main); border: 1px solid var(--border-color); }
.btn-secondary:not(:disabled):hover { border-color: var(--primary); }
.btn-ghost { background: transparent; color: var(--text-muted); }
.btn-ghost:not(:disabled):hover { color: var(--text-main); background: rgba(255,255,255,0.05); }

/* Resolution Toolbar */
.resolution-toolbar {
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.conflict-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}
.conflict-counter {
    font-weight: 600;
    font-size: 1.1rem;
    min-width: 130px;
    text-align: center;
}

/* Document Flow (Context + Conflicts) */
.document-flow {
    overflow-y: auto;
    padding: 0; /* padding handled inside items for full width bg */
}
.document-flow::-webkit-scrollbar { width: 8px; }
.document-flow::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 4px; }

.context-block {
    padding: 12px 24px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-muted);
    white-space: pre-wrap;
    background: rgba(0,0,0,0.1);
}
.context-block:empty { display: none; }

.conflict-block {
    margin: 16px 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
    scroll-margin-top: 24px; /* for smooth scroll to anchor */
}
.conflict-block.resolved {
    opacity: 0.7;
    border-color: var(--success);
}
.conflict-block.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.conflict-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: rgba(255,255,255,0.02);
    border-bottom: 1px solid var(--border-color);
}
.conflict-title { font-weight: 600; color: var(--secondary); font-size: 0.9rem; letter-spacing: 0.5px; }
.conflict-actions { display: flex; gap: 8px; }

.conflict-actions .btn-sm { font-size: 0.8rem; padding: 4px 10px; }
.btn-ours { border-color: var(--ours-border); color: #00CEC9; background: rgba(0,206,201,0.05); }
.btn-ours:hover { background: var(--ours-bg); }
.btn-theirs { border-color: var(--theirs-border); color: var(--primary); background: rgba(243,156,18,0.05); }
.btn-theirs:hover { background: var(--theirs-bg); }

/* Side-by-side Diff View */
.diff-view {
    display: flex;
    min-height: 100px;
}
.diff-side {
    flex: 1;
    padding: 16px 24px;
    width: 50%;
    overflow-x: auto;
}
.diff-side.ours {
    background: var(--ours-bg);
    border-right: 1px solid var(--border-color);
}
.diff-side.theirs {
    background: var(--theirs-bg);
}
.diff-content {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    white-space: pre-wrap;
    word-break: break-all;
}
.diff-metadata {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-bottom: 8px;
    opacity: 0.7;
}

/* Resolved View */
.resolved-view {
    padding: 16px 24px;
    background: rgba(46, 204, 113, 0.05);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-content {
    width: 100%;
    max-width: 800px;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: var(--bg-main);
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    z-index: 1000;
    transition: opacity 0.3s, transform 0.3s;
}
.toast.hidden { opacity: 0; transform: translate(-50%, 20px); }
