:root {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --accent-hover: #059669;
    --accent-light: #d1fae5;
    --border: #e2e8f0;
    --addition: #dcfce7;
    --addition-text: #166534;
    --deletion: #fee2e2;
    --deletion-text: #991b1b;
    --shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
    --radius: 12px;
    --radius-sm: 8px;
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --accent: #34d399;
    --accent-hover: #10b981;
    --accent-light: #064e3b;
    --border: #334155;
    --addition: #064e3b;
    --addition-text: #6ee7b7;
    --deletion: #450a0a;
    --deletion-text: #fca5a5;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
}

.container { max-width: 1200px; margin: 0 auto; padding: 2rem 1rem; }

header { text-align: center; margin-bottom: 2rem; }

h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--accent), #06b6d4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline { color: var(--text-secondary); font-size: 1.1rem; margin-bottom: 1rem; }

.trust-badges { display: flex; justify-content: center; flex-wrap: wrap; gap: 0.5rem; }

.badge {
    padding: 0.35rem 0.75rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Options Bar */
.options-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.option-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    user-select: none;
}

.option-toggle input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
}

.option-toggle:hover { color: var(--text-primary); }

/* Compare Section */
.compare-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.text-panel {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    position: relative;
}

.text-panel.drag-over {
    border-color: var(--accent);
    border-style: dashed;
    background: var(--accent-light);
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.panel-header label { font-weight: 600; }

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

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover { border-color: var(--accent); }

.btn-clear {
    padding: 0.35rem 0.75rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
}

.btn-clear:hover { color: var(--accent); border-color: var(--accent); }

.file-input { display: none; }

textarea {
    width: 100%;
    height: 250px;
    padding: 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.9rem;
    resize: vertical;
    transition: border-color 0.2s;
}

textarea:focus { outline: none; border-color: var(--accent); }

textarea::placeholder { color: var(--text-muted); }

.stats { margin-top: 0.5rem; font-size: 0.8rem; color: var(--text-muted); }

/* Actions */
.actions { 
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 2rem; 
}

.btn-primary {
    padding: 1rem 2.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(16,185,129,0.3);
    transition: all 0.2s;
}

.btn-primary:hover { background: var(--accent-hover); transform: translateY(-2px); }

.btn-secondary {
    padding: 0.6rem 1.2rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

/* Results Section */
.results-section {
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: 1px solid var(--border);
    margin-bottom: 2rem;
}

.results-section.hidden { display: none; }

.results-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-header h2 { font-size: 1.25rem; }

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

/* Similarity Bar */
.similarity-bar {
    margin-bottom: 1.25rem;
    padding: 1rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
}

.similarity-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.similarity-label strong {
    font-size: 1.25rem;
    color: var(--accent);
}

.similarity-track {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.similarity-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), #06b6d4);
    border-radius: 4px;
    transition: width 0.5s ease;
    width: 0%;
}

/* Diff Legend & Output */
.diff-legend { display: flex; gap: 1.5rem; margin-bottom: 1rem; flex-wrap: wrap; }

.legend-item { padding: 0.25rem 0.75rem; border-radius: 4px; font-size: 0.85rem; }
.legend-item.addition { background: var(--addition); color: var(--addition-text); }
.legend-item.deletion { background: var(--deletion); color: var(--deletion-text); }
.legend-item.unchanged { background: var(--bg-tertiary); color: var(--text-muted); }

.diff-summary { 
    padding: 1rem; 
    background: var(--bg-tertiary); 
    border-radius: var(--radius-sm); 
    margin-bottom: 1rem;
}

.diff-output {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 0.85rem;
    max-height: 400px;
    overflow-y: auto;
}

.diff-line { 
    padding: 0.4rem 1rem; 
    border-bottom: 1px solid var(--border); 
    white-space: pre-wrap;
    word-break: break-word;
}

.diff-line:last-child { border-bottom: none; }
.diff-line.addition { background: var(--addition); color: var(--addition-text); }
.diff-line.deletion { background: var(--deletion); color: var(--deletion-text); }
.diff-line.unchanged { color: var(--text-muted); }

/* FAQ Section */
.faq-section { margin-top: 2.5rem; }
.faq-section h2 { font-size: 1.5rem; margin-bottom: 1.25rem; text-align: center; }

.faq-item {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    overflow: hidden;
}

.faq-item summary {
    padding: 1rem 1.25rem;
    font-weight: 600;
    cursor: pointer;
    list-style: none;
    transition: background 0.2s;
}

.faq-item summary:hover { background: var(--bg-tertiary); }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: '+'; float: right; color: var(--text-muted); font-weight: 400; }
.faq-item[open] summary::after { content: '−'; }
.faq-item p { padding: 0 1.25rem 1.25rem; color: var(--text-secondary); line-height: 1.7; }

/* Footer */
footer { 
    text-align: center; 
    margin-top: 3rem; 
    padding-top: 2rem; 
    border-top: 1px solid var(--border); 
    color: var(--text-muted); 
    font-size: 0.875rem; 
}

footer a { color: var(--accent); text-decoration: none; }
footer a:hover { text-decoration: underline; }

.footer-links { margin-top: 0.5rem; font-size: 0.8rem; }
.footer-links a { color: var(--text-secondary); }

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    background: var(--bg-secondary);
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    font-size: 1.25rem;
    z-index: 100;
    transition: transform 0.2s;
}

.theme-toggle:hover { transform: scale(1.1); }

/* Responsive */
@media (max-width: 768px) {
    .compare-section { grid-template-columns: 1fr; }
    h1 { font-size: 2rem; }
    textarea { height: 180px; }
    .options-bar { gap: 0.75rem; }
    .option-toggle { font-size: 0.85rem; }
    .actions { flex-direction: column; align-items: center; }
    .results-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .container { padding: 1rem 0.75rem; }
    .trust-badges { gap: 0.35rem; }
    .badge { font-size: 0.7rem; padding: 0.25rem 0.5rem; }
}
