* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #0d1117;
    color: #c9d1d9;
    min-height: 100vh;
}

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

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid #30363d;
    margin-bottom: 1rem;
}

header h1 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 600;
}

.controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.btn, .btn-small {
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
}

.btn:hover, .btn-small:hover {
    background: #30363d;
}

.btn-icon {
    padding: 0.4rem 0.6rem;
}

.toggle-label {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.875rem;
    color: #c9d1d9;
    cursor: pointer;
}

select.btn {
    appearance: none;
    padding-right: 1.5rem;
    background-image: linear-gradient(45deg, transparent 50%, #c9d1d9 50%),
                      linear-gradient(135deg, #c9d1d9 50%, transparent 50%);
    background-position: calc(100% - 12px) center, calc(100% - 7px) center;
    background-size: 5px 5px;
    background-repeat: no-repeat;
}

.inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.pane {
    display: flex;
    flex-direction: column;
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    overflow: hidden;
}

.pane.drag-over {
    border-color: #238636;
    background: #0d2a14;
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: #0d1117;
    border-bottom: 1px solid #30363d;
}

.pane-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #c9d1d9;
}

.pane-actions {
    display: flex;
    gap: 0.4rem;
}

.diff-input {
    width: 100%;
    min-height: 220px;
    padding: 0.75rem;
    background: #0d1117;
    color: #c9d1d9;
    border: none;
    resize: vertical;
    font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    outline: none;
}

.diff-input:focus {
    background: #010409;
}

.output-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stats {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: #c9d1d9;
}

.stats .additions { color: #3fb950; }
.stats .deletions { color: #f85149; }

.hint {
    padding: 1rem;
    text-align: center;
    color: #8b949e;
    font-size: 0.9rem;
}

.diff-output {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    overflow: hidden;
}

.toast {
    position: fixed;
    bottom: 1.5rem;
    left: 50%;
    transform: translateX(-50%);
    background: #21262d;
    color: #c9d1d9;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    z-index: 1000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

.toast.error {
    border-color: #f85149;
    color: #f85149;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
}

.modal {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 8px;
    padding: 1.5rem;
    max-width: 400px;
    width: 90%;
}

.modal h3 {
    margin-top: 0;
}

.shortcut-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.shortcut {
    display: flex;
    justify-content: space-between;
    font-size: 0.875rem;
}

kbd {
    background: #21262d;
    border: 1px solid #30363d;
    border-radius: 4px;
    padding: 1px 6px;
    font-family: monospace;
    font-size: 0.8rem;
}

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

/* light theme overrides */
body.light-theme {
    background: #ffffff;
    color: #24292f;
}

body.light-theme .pane,
body.light-theme .diff-output,
body.light-theme .modal {
    background: #f6f8fa;
    border-color: #d0d7de;
}

body.light-theme .pane-header,
body.light-theme .diff-input {
    background: #ffffff;
    border-color: #d0d7de;
    color: #24292f;
}

body.light-theme .pane-label,
body.light-theme .toggle-label,
body.light-theme .stats {
    color: #24292f;
}

body.light-theme .btn,
body.light-theme .btn-small {
    background: #f6f8fa;
    color: #24292f;
    border-color: #d0d7de;
}

body.light-theme .btn:hover,
body.light-theme .btn-small:hover {
    background: #eaeef2;
}

body.light-theme header {
    border-color: #d0d7de;
}

body.light-theme .hint {
    color: #57606a;
}

body.light-theme kbd {
    background: #f6f8fa;
    border-color: #d0d7de;
    color: #24292f;
}

body.light-theme .toast {
    background: #f6f8fa;
    color: #24292f;
    border-color: #d0d7de;
}

/* diff2html dark mode overrides — applied when body is NOT .light-theme */
body:not(.light-theme) .d2h-wrapper,
body:not(.light-theme) .d2h-file-header,
body:not(.light-theme) .d2h-file-wrapper {
    background: #161b22;
    border-color: #30363d;
    color: #c9d1d9;
}

body:not(.light-theme) .d2h-code-line,
body:not(.light-theme) .d2h-code-side-line,
body:not(.light-theme) .d2h-code-linenumber,
body:not(.light-theme) .d2h-code-side-linenumber {
    background: #0d1117;
    color: #c9d1d9;
    border-color: #30363d;
}

body:not(.light-theme) .d2h-ins,
body:not(.light-theme) .d2h-ins .d2h-code-line,
body:not(.light-theme) .d2h-ins .d2h-code-side-line {
    background: #0f2f1c !important;
    color: #c9d1d9 !important;
}

body:not(.light-theme) .d2h-del,
body:not(.light-theme) .d2h-del .d2h-code-line,
body:not(.light-theme) .d2h-del .d2h-code-side-line {
    background: #3a1014 !important;
    color: #c9d1d9 !important;
}

body:not(.light-theme) .d2h-ins-highlight,
body:not(.light-theme) ins.d2h-change {
    background: #1b4721 !important;
    color: #c9d1d9 !important;
}

body:not(.light-theme) .d2h-del-highlight,
body:not(.light-theme) del.d2h-change {
    background: #6b1822 !important;
    color: #c9d1d9 !important;
}

body:not(.light-theme) .d2h-info {
    background: #0d1117;
    color: #8b949e;
    border-color: #30363d;
}

body:not(.light-theme) .d2h-code-linenumber {
    color: #6e7681;
}

body:not(.light-theme) .d2h-cntx,
body:not(.light-theme) .d2h-emptyplaceholder {
    background: #0d1117 !important;
}

body:not(.light-theme) .d2h-file-name,
body:not(.light-theme) .d2h-tag {
    color: #c9d1d9;
}
