:root {
    --bg-base: #f1f5f9;
    --bg-panel: rgba(255, 255, 255, 0.8);
    --bg-input: #ffffff;
    --border-light: rgba(15, 23, 42, 0.1);
    --border-focus: rgba(59, 130, 246, 0.5);

    --text-main: #0f172a;
    --text-muted: #64748b;

    --primary: #3b82f6;
    --primary-hover: #2563eb;

    --diff-bg-add: #dcfce7;
    --diff-text-add: #166534;
    --diff-bg-del: #fee2e2;
    --diff-text-del: #991b1b;
    --diff-bg-empty: #f8fafc;

    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);

    --radius-lg: 12px;
    --radius-md: 8px;
    --radius-sm: 4px;
}

[data-theme="dark"] {
    --bg-base: #0f172a;
    --bg-panel: rgba(30, 41, 59, 0.7);
    --bg-input: #1e293b;
    --border-light: rgba(255, 255, 255, 0.1);
    --border-focus: rgba(56, 189, 248, 0.5);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;

    --primary: #38bdf8;
    --primary-hover: #7dd3fc;

    --diff-bg-add: rgba(22, 163, 74, 0.2);
    --diff-text-add: #4ade80;
    --diff-bg-del: rgba(220, 38, 38, 0.2);
    --diff-text-del: #f87171;
    --diff-bg-empty: rgba(15, 23, 42, 0.5);

    --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    transition: background-color 0.3s, color 0.3s;
}

svg {
    display: block;
}

.w-4 {
    width: 1rem;
}

.h-4 {
    height: 1rem;
}

.w-5 {
    width: 1.25rem;
}

.h-5 {
    height: 1.25rem;
}

.w-6 {
    width: 1.5rem;
}

.h-6 {
    height: 1.5rem;
}

.ml-1 {
    margin-left: 0.25rem;
}

.hidden {
    display: none !important;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

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

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

.text-sm {
    font-size: 0.875rem;
}

.font-medium {
    font-weight: 500;
}

.uppercase {
    text-transform: uppercase;
}

.tracking-wider {
    letter-spacing: 0.05em;
}

.w-full {
    width: 100%;
}

.flex {
    display: flex;
}

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

    .hidden-sm {
        display: none;
    }
}

/* Glass Panel */
.glass-panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--shadow-sm);
}

/* App Structure */
.app-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -0.025em;
}

.brand-icon {
    background: var(--primary);
    color: var(--bg-base);
    padding: 0.5rem;
    border-radius: var(--radius-md);
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.preset-group {
    display: flex;
    background: rgba(0, 0, 0, 0.05);
    padding: 0.25rem;
    border-radius: var(--radius-md);
}

[data-theme="dark"] .preset-group {
    background: rgba(0, 0, 0, 0.3);
}

.divider {
    width: 1px;
    height: 24px;
    background: var(--border-light);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

[data-theme="dark"] .btn-primary {
    color: #000;
}

.btn-outline {
    background: transparent;
    color: var(--text-muted);
    border-color: transparent;
}

.btn-outline:hover {
    color: var(--text-main);
}

.preset-group .btn-outline.active {
    background: var(--bg-panel);
    color: var(--text-main);
    border-color: var(--border-light);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

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

.btn-icon:hover {
    color: var(--text-main);
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Workspace */
.workspace {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    flex: 1;
}

/* Input Section */
.editor-pane {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--bg-panel);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1rem;
    box-shadow: var(--shadow-sm);
    height: 300px;
}

.pane-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.code-input {
    flex: 1;
    resize: none;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    background: var(--bg-input);
    border: 1px solid var(--border-light);
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.6;
}

.code-input:focus {
    border-color: var(--border-focus);
}

.action-row {
    max-width: 400px;
    margin: 0 auto;
    width: 100%;
}

/* Output Section */
.output-section {
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.output-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.02);
}

[data-theme="dark"] .output-header {
    background: rgba(0, 0, 0, 0.2);
}

.diff-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.stat-item.add {
    color: var(--diff-text-add);
}

.stat-item.del {
    color: var(--diff-text-del);
}

/* Diff Container Styles */
.diff-container {
    width: 100%;
    overflow-x: auto;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.875rem;
    line-height: 1.5;
    background: var(--bg-input);
}

.diff-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.diff-table td {
    padding: 0;
    vertical-align: top;
}

/* Side-by-Side Specifics */
.diff-container.side-by-side .diff-table td {
    width: 50%;
}

.diff-pane {
    position: relative;
    height: 100%;
}

.diff-container.side-by-side .diff-pane.left {
    border-right: 1px solid var(--border-light);
}

.diff-line {
    display: flex;
    width: 100%;
    min-height: 1.5em;
    /* force empty lines to render */
}

/* Number Columns */
.diff-line-num {
    width: 3rem;
    min-width: 3rem;
    padding: 0 0.5rem;
    color: var(--text-muted);
    text-align: right;
    user-select: none;
    opacity: 0.5;
    background: rgba(0, 0, 0, 0.02);
    border-right: 1px solid var(--border-light);
    flex-shrink: 0;
}

[data-theme="dark"] .diff-line-num {
    background: rgba(0, 0, 0, 0.2);
}

/* Content Column */
.diff-line-content {
    flex: 1;
    padding: 0 1rem;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Line Types */
.diff-line.empty {
    background-color: var(--diff-bg-empty);
}

.diff-line.empty .diff-line-num {
    border-color: transparent;
}

.diff-line.added {
    background-color: var(--diff-bg-add);
}

.diff-line.added .diff-line-num {
    color: var(--diff-text-add);
    opacity: 0.8;
    border-color: var(--diff-text-add);
}

.diff-line.added .diff-line-content {
    color: var(--diff-text-add);
}

.diff-line.removed {
    background-color: var(--diff-bg-del);
}

.diff-line.removed .diff-line-num {
    color: var(--diff-text-del);
    opacity: 0.8;
    border-color: var(--diff-text-del);
}

.diff-line.removed .diff-line-content {
    color: var(--diff-text-del);
}

/* Inline Specifics */
.diff-container.inline .diff-table td {
    width: 100%;
}

.diff-container.inline .diff-line-num {
    width: 3rem;
}

.diff-container.inline .diff-line-num.left-num {
    border-right: none;
    opacity: 0.3;
}

.diff-container.inline .diff-line-num.right-num {
    opacity: 0.7;
}