:root {
    --bg-main: #0F0A1A;
    --bg-panel: rgba(15, 10, 26, 0.6);
    --bg-input: rgba(255, 255, 255, 0.05);
    --border-color: rgba(108, 99, 255, 0.3);
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    
    --color-primary: #6C63FF;
    --color-secondary: #A78BFA;
    --color-accent: #22D3EE;
    
    --diff-add-bg: rgba(34, 197, 94, 0.15);
    --diff-add-fg: #4ADE80;
    --diff-rem-bg: rgba(239, 68, 68, 0.15);
    --diff-rem-fg: #F87171;
    --diff-mov-bg: rgba(59, 130, 246, 0.15);
    --diff-mov-fg: #60A5FA;
    --diff-ren-bg: rgba(168, 85, 247, 0.15);
    --diff-ren-fg: #C084FC;
    --diff-fmt-bg: rgba(156, 163, 175, 0.1);
    --diff-fmt-fg: #9CA3AF;
    
    --gutter-bg: rgba(0, 0, 0, 0.3);
    
    --font-mono: 'JetBrains Mono', monospace;
    --font-sans: system-ui, -apple-system, sans-serif;
    --radius: 6px;
}

.theme-light {
    --bg-main: #F8FAFC;
    --bg-panel: #FFFFFF;
    --bg-input: #F1F5F9;
    --border-color: #E2E8F0;
    --text-main: #0F172A;
    --text-muted: #64748B;
    
    --gutter-bg: #F1F5F9;
    
    --diff-add-bg: rgba(34, 197, 94, 0.2);
    --diff-add-fg: #166534;
    --diff-rem-bg: rgba(239, 68, 68, 0.2);
    --diff-rem-fg: #991B1B;
    --diff-mov-bg: rgba(59, 130, 246, 0.2);
    --diff-mov-fg: #1E40AF;
    --diff-ren-bg: rgba(168, 85, 247, 0.2);
    --diff-ren-fg: #6B21A8;
    --diff-fmt-bg: rgba(156, 163, 175, 0.2);
    --diff-fmt-fg: #4B5563;
}

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

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    transition: background-color 0.3s, color 0.3s;
}

.app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

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

header h1 {
    font-size: 1.5rem;
    color: var(--color-primary);
    margin-bottom: 0.25rem;
}

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

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.2s;
}

.icon-btn:hover {
    color: var(--color-primary);
    background: rgba(108, 99, 255, 0.1);
}

.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}
.btn-primary:hover {
    background: #5A52D5;
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}
.btn-secondary:hover {
    border-color: var(--color-primary);
}
.btn-secondary.active {
    background: rgba(108, 99, 255, 0.1);
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}
.btn-large {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.input-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    flex: 1;
    min-height: 300px;
    margin-bottom: 1rem;
}

@media (max-width: 900px) {
    .input-section { grid-template-columns: 1fr; }
}

.panel {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-panel);
    overflow: hidden;
    position: relative;
    transition: box-shadow 0.2s, border-color 0.2s;
}
.panel.drag-over {
    border-color: var(--color-accent);
    box-shadow: 0 0 15px rgba(34, 211, 238, 0.3);
}
.panel.drag-over::after {
    content: "Drop file here";
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 10, 26, 0.8);
    color: var(--color-accent);
    font-size: 1.2rem;
    font-weight: bold;
    z-index: 10;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: rgba(0,0,0,0.1);
    border-bottom: 1px solid var(--border-color);
}
.panel-header h2 {
    font-size: 0.9rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.code-input {
    flex: 1;
    width: 100%;
    resize: none;
    padding: 1rem;
    background: var(--bg-input);
    color: var(--text-main);
    border: none;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    line-height: inherit;
    outline: none;
}

.code-input:focus {
    box-shadow: inset 0 0 0 1px var(--color-accent);
}

.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.view-toggles, .context-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

select {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 0.4rem;
    border-radius: 4px;
    outline: none;
}

.summary-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.metrics {
    display: flex;
    gap: 1.5rem;
    margin-top: 0.5rem;
}

.metric {
    display: flex;
    flex-direction: column;
}
.metric .val { font-size: 1.5rem; font-weight: bold; }
.metric .lbl { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; }

.metric-add .val { color: var(--diff-add-fg); }
.metric-rem .val { color: var(--diff-rem-fg); }
.metric-mov .val { color: var(--diff-mov-fg); }
.metric-ren .val { color: var(--diff-ren-fg); }
.metric-fmt .val { color: var(--diff-fmt-fg); }

/* Diff Output */
.diff-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    background: var(--bg-panel);
    font-family: var(--font-mono);
    font-size: 0.85rem;
    overflow-x: auto;
    margin-bottom: 2rem;
}

.diff-header {
    padding: 0.5rem 1rem;
    background: var(--bg-input);
    border-bottom: 1px solid var(--border-color);
    color: var(--text-muted);
    font-weight: bold;
}

.side-by-side {
    display: grid;
    grid-template-columns: 50% 50%;
}
.side-by-side .pane-left { border-right: 1px solid var(--border-color); }
.side-by-side .diff-content {
    grid-column: 1 / span 2;
    display: flex;
    flex-direction: column;
}

.diff-row {
    display: flex;
    width: 100%;
}

.diff-row:hover {
    background: rgba(255,255,255,0.02);
}

.diff-cell {
    flex: 1;
    display: flex;
    border-bottom: 1px solid rgba(255,255,255,0.03);
    min-height: 24px;
}
.diff-cell.left { border-right: 1px solid var(--border-color); }
.diff-cell.empty { opacity: 0; pointer-events: none; }

.context-expander { background: var(--bg-input); }
.context-expander .content { color: var(--text-muted); text-align: center; }

.diff-row.active-nav {
    outline: 2px solid var(--color-accent);
    outline-offset: -2px;
}

.gutter {
    width: 40px;
    min-width: 40px;
    background: var(--gutter-bg);
    color: var(--text-muted);
    text-align: right;
    padding: 0 0.5rem;
    user-select: none;
    border-right: 1px solid rgba(255,255,255,0.05);
}

.content {
    padding: 0 0.5rem;
    white-space: pre;
    flex: 1;
    overflow-wrap: break-word;
    word-break: break-all;
}

/* Unified View */
.unified { display: block; }
.unified .diff-header.pane-right { display: none; }
.unified .diff-row {
    display: flex;
}
.unified .diff-cell { display: none; border-right: none; }
.unified .diff-cell.active { display: flex; width: 100%; }

/* Line highlights */
.line-add { background: var(--diff-add-bg); }
.line-rem { background: var(--diff-rem-bg); }
.line-mov { background: var(--diff-mov-bg); }
.line-ren { background: var(--diff-ren-bg); }
.line-fmt { background: var(--diff-fmt-bg); }

/* Token highlights */
.tok-add { background: var(--diff-add-fg); color: #000; padding: 0 2px; border-radius: 2px;}
.tok-rem { background: var(--diff-rem-fg); color: #000; padding: 0 2px; border-radius: 2px; text-decoration: line-through; }
.tok-mov { background: var(--diff-mov-fg); color: #fff; padding: 0 2px; border-radius: 2px;}
.tok-ren { background: var(--diff-ren-fg); color: #fff; padding: 0 2px; border-radius: 2px;}

.hidden { display: none !important; }
