/* ── Reset & Base ── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #0d1117;
    --surface: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --text-muted: #8b949e;
    --accent: #58a6ff;
    --green: #3fb950;
    --green-bg: rgba(63, 185, 80, 0.15);
    --green-inline: rgba(63, 185, 80, 0.30);
    --red: #f85149;
    --red-bg: rgba(248, 81, 73, 0.15);
    --red-inline: rgba(248, 81, 73, 0.35);
    --radius: 8px;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Menlo', monospace;
}

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

/* ── Container ── */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

/* ── Header ── */
header {
    margin-bottom: 2rem;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 0.25rem;
}

.back-link {
    color: var(--accent);
    text-decoration: none;
    font-size: 0.875rem;
    display: inline-block;
    margin-bottom: 0.5rem;
}
.back-link:hover {
    text-decoration: underline;
}

/* ── Mode selector ── */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1.25rem;
}

.mode-selector,
.input-mode-selector {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.mode-selector > label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.input-mode-selector > label {
    color: var(--text-muted);
    font-size: 0.875rem;
}

.mode-buttons {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.mode-buttons input[type="radio"] {
    display: none;
}

.mode-btn {
    padding: 0.35rem 1rem;
    font-size: 0.8125rem;
    cursor: pointer;
    color: var(--text-muted);
    background: var(--surface);
    border-right: 1px solid var(--border);
    transition: background 0.15s, color 0.15s;
    user-select: none;
}
.mode-btn:last-of-type {
    border-right: none;
}

.mode-buttons input[type="radio"]:checked + .mode-btn {
    background: var(--accent);
    color: #fff;
}

/* ── Text inputs ── */
.text-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

@media (max-width: 700px) {
    .text-inputs {
        grid-template-columns: 1fr;
    }
}

.input-group label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

textarea {
    width: 100%;
    min-height: 240px;
    padding: 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    resize: vertical;
    outline: none;
    tab-size: 4;
    transition: border-color 0.15s;
}

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

textarea[readonly] {
    opacity: 0.7;
    cursor: default;
    min-height: 160px;
}

/* ── Actions ── */
.actions {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.btn-primary, .btn-secondary {
    padding: 0.6rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
    background: var(--surface);
    color: var(--text-muted);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    color: var(--text);
    border-color: var(--text-muted);
}

/* ── Stats bar ── */
.stats-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 1.25rem;
    font-size: 0.8125rem;
    font-family: var(--font-mono);
}

.stat-added   { color: var(--green); }
.stat-removed { color: var(--red); }
.stat-unchanged { color: var(--text-muted); }
.stat-mode {
    margin-left: auto;
    color: var(--accent);
    text-transform: capitalize;
}

/* ── Inline diff (word & char) ── */
.diff-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow-x: auto;
    margin-bottom: 1.5rem;
}

.inline-diff {
    padding: 1rem;
    font-family: var(--font-mono);
    font-size: 0.875rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.diff-equal {
    color: var(--text);
}

.diff-delete {
    background: var(--red-bg);
    color: var(--red);
    text-decoration: line-through;
    text-decoration-color: rgba(248, 81, 73, 0.5);
    border-radius: 3px;
    padding: 0.1em 0.05em;
}

.diff-insert {
    background: var(--green-bg);
    color: var(--green);
    border-radius: 3px;
    padding: 0.1em 0.05em;
}

/* ── Line diff table ── */
.line-diff-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
}

.line-diff-table tr {
    border-bottom: 1px solid var(--border);
}
.line-diff-table tr:last-child {
    border-bottom: none;
}

.line-num {
    width: 3rem;
    min-width: 3rem;
    text-align: right;
    padding: 0.2rem 0.5rem;
    color: var(--text-muted);
    user-select: none;
    font-size: 0.75rem;
    vertical-align: top;
}

.line-marker {
    width: 1.5rem;
    text-align: center;
    font-weight: 700;
    user-select: none;
    vertical-align: top;
    padding-top: 0.2rem;
}

.line-content {
    padding: 0.2rem 0.75rem;
    white-space: pre-wrap;
    word-break: break-word;
    line-height: 1.6;
}

/* Line-level row colours */
.line-equal .line-content { color: var(--text); }
.line-equal .line-marker  { color: var(--text-muted); }

.line-delete {
    background: var(--red-bg);
}
.line-delete .line-marker { color: var(--red); }
.line-delete .line-content { color: var(--text); }

.line-insert {
    background: var(--green-bg);
}
.line-insert .line-marker { color: var(--green); }
.line-insert .line-content { color: var(--text); }

/* Inline word highlights within lines */
.inline-delete {
    background: var(--red-inline);
    border-radius: 3px;
    padding: 0.05em 0.15em;
}

.inline-insert {
    background: var(--green-inline);
    border-radius: 3px;
    padding: 0.05em 0.15em;
}

/* ── Originals collapsible ── */
.originals {
    margin-top: 1rem;
}

.originals summary {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
    user-select: none;
}
.originals summary:hover {
    color: var(--accent);
}

/* ── Hidden utility ── */
.hidden {
    display: none !important;
}

/* ── Error banner ── */
.error-banner {
    padding: 0.75rem 1rem;
    background: var(--red-bg);
    border: 1px solid var(--red);
    border-radius: var(--radius);
    color: var(--red);
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

/* ── File drop zones ── */
.file-inputs .input-group {
    display: flex;
    flex-direction: column;
}

.file-drop {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.file-drop:hover,
.file-drop.drag-over {
    border-color: var(--accent);
    background: rgba(88, 166, 255, 0.05);
}

.file-drop.has-file {
    border-color: var(--green);
    border-style: solid;
}

.file-drop input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-drop-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    pointer-events: none;
    text-align: center;
    padding: 1rem;
}

.file-icon {
    font-size: 2.5rem;
    line-height: 1;
}

.file-text {
    color: var(--text-muted);
    font-size: 0.875rem;
}
.file-text em {
    color: var(--accent);
    font-style: normal;
    text-decoration: underline;
}

.file-name {
    color: var(--green);
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    word-break: break-all;
}
