:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-2: #f1f4f9;
  --text: #182033;
  --muted: #667085;
  --border: #d7deea;
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --focus: #2563eb;
  --added: #087443;
  --added-bg: #e6f6ed;
  --removed: #b42318;
  --removed-bg: #fff0ee;
  --changed: #9a5b00;
  --changed-bg: #fff7df;
  --type: #7a35a8;
  --type-bg: #f7edff;
  --ignored: #53606f;
  --shadow: 0 1px 3px rgba(16,24,40,.08), 0 8px 24px rgba(16,24,40,.04);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

html[data-theme="dark"],
html[data-theme="dark"] body,
html[data-site-theme="dark"],
html[data-site-theme="dark"] body,
html[data-theme="dark"] .app,
html[data-site-theme="dark"] .app,
html[data-theme="dark"] .panel,
html[data-site-theme="dark"] .panel,
html[data-theme="dark"] .workspace,
html[data-site-theme="dark"] .workspace {
  background-color: #0c111b !important;
  color: #e8edf6 !important;
}

:root[data-theme="dark"], html[data-theme="dark"], html[data-site-theme="dark"] {
  color-scheme: dark;
  --bg: #0c111b;
  --surface: #151c29;
  --surface-2: #1d2636;
  --text: #e8edf5;
  --muted: #a0aec0;
  --border: #354156;
  --primary: #8179ff;
  --primary-hover: #948eff;
  --focus: #7db7ff;
  --added: #75d5a4;
  --added-bg: #143426;
  --removed: #ff928a;
  --removed-bg: #3d201f;
  --changed: #ffd171;
  --changed-bg: #3c311a;
  --type: #d6a3ff;
  --type-bg: #33213f;
  --ignored: #b0bac8;
  --shadow: 0 1px 3px rgba(0,0,0,.3), 0 8px 28px rgba(0,0,0,.2);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); }
body { font-size: 14px; }
button, input, textarea, select { font: inherit; }
button, select, input[type="text"], input[type="search"] { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 7px; }
button { min-height: 34px; padding: 6px 11px; cursor: pointer; font-weight: 600; }
button:hover { border-color: var(--primary); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.primary { background: var(--primary); color: white; border-color: var(--primary); }
button.primary:hover { background: var(--primary-hover); }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible, summary:focus-visible, [tabindex]:focus-visible { outline: 3px solid color-mix(in srgb, var(--focus) 45%, transparent); outline-offset: 2px; }

.app-header { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 12px 20px; background: color-mix(in srgb, var(--surface) 95%, transparent); border-bottom: 1px solid var(--border); backdrop-filter: blur(12px); }
.brand { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; color: white; background: var(--primary); font: 700 15px ui-monospace, monospace; }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 16px; }
.brand small { color: var(--muted); margin-top: 2px; font-size: 11px; }
.toolbar { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
.icon-button { width: 36px; padding: 4px; font-size: 18px; }

main { width: min(1800px, 100%); margin: auto; padding: 14px 20px 38px; }
.privacy-note { display: flex; justify-content: flex-end; align-items: center; gap: 7px; margin: 0 0 10px; color: var(--muted); text-align: right; font-size: 12px; }
.service-icon { position: relative; display: inline-block; flex: 0 0 auto; color: var(--primary); }
.service-icon-lock { width: 14px; height: 14px; }
.service-icon-lock::before { position: absolute; left: 2px; bottom: 1px; width: 10px; height: 8px; border-radius: 3px; background: currentColor; content: ""; }
.service-icon-lock::after { position: absolute; left: 4px; top: 0; width: 6px; height: 7px; border: 2px solid currentColor; border-bottom: 0; border-radius: 5px 5px 0 0; content: ""; }
#themeBtn .theme-glyph { width: 14px; height: 14px; border-radius: 50%; box-shadow: -4px 2px 0 0 currentColor; }
:root[data-theme="dark"] #themeBtn .theme-glyph { width: 9px; height: 9px; border: 2px solid currentColor; box-shadow: 0 -7px 0 -4px currentColor, 0 7px 0 -4px currentColor, -7px 0 0 -4px currentColor, 7px 0 0 -4px currentColor; }
.options-panel, .editor-card, .result-card, .panel { background: var(--surface); border: 1px solid var(--border); border-radius: 11px; box-shadow: var(--shadow); }
.options-panel { margin-bottom: 14px; padding: 14px; }
.option-grid { display: flex; flex-wrap: wrap; align-items: center; gap: 18px; }
.option-grid label { display: flex; align-items: center; gap: 7px; font-weight: 600; }
.option-grid input[type="text"] { width: 120px; padding: 6px 8px; }
.ignore-editor { margin-top: 13px; }
.ignore-editor > label { display: block; margin-bottom: 5px; font-weight: 700; }
.hint, .muted { color: var(--muted); font-weight: 400; }
#ignoredPaths { width: 100%; resize: vertical; padding: 9px 10px; color: var(--text); background: var(--surface-2); border: 1px solid var(--border); border-radius: 7px; font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.inline-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
details { margin-top: 12px; border-top: 1px solid var(--border); padding-top: 10px; }
summary { cursor: pointer; font-weight: 700; }
.history-list { display: grid; gap: 7px; margin-top: 10px; }
.history-item { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 8px; background: var(--surface-2); border-radius: 7px; }
.history-item p { margin: 0; }

.editors { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 14px; }
.editor-card { min-width: 0; overflow: hidden; }
.editor-card > header, .result-header { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.editor-card h2, .result-card h2, .panel h2 { margin: 0; font-size: 15px; }
.editor-card header div { display: flex; gap: 6px; }
.editor-card header button { min-height: 29px; padding: 4px 8px; font-size: 12px; }
.code-editor { position: relative; height: clamp(280px, 39vh, 560px); overflow: hidden; background: #111827; }
.code-editor textarea, .code-editor pre { position: absolute; inset: 0; margin: 0; padding: 14px 14px 14px 52px; border: 0; overflow: auto; white-space: pre; tab-size: 2; font: 13px/1.55 ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace; }
.code-editor textarea { z-index: 2; resize: none; color: transparent; caret-color: #f8fafc; background: transparent; outline: 0; -webkit-text-fill-color: transparent; }
.code-editor textarea::selection { background: rgba(96,165,250,.35); }
.code-editor pre { z-index: 1; pointer-events: none; color: #d1d5db; background: #111827; counter-reset: line; }
.code-line { display: block; min-height: 1.55em; }
.code-line::before { counter-increment: line; content: counter(line); display: inline-block; width: 32px; margin-left: -42px; margin-right: 10px; color: #64748b; text-align: right; user-select: none; }
.token-key { color: #93c5fd; }.token-string { color: #86efac;}.token-number { color: #fde68a;}.token-boolean { color: #f0abfc;}.token-null { color: #fda4af;}
.code-editor.invalid { box-shadow: inset 0 0 0 2px var(--removed); }
.editor-message { min-height: 28px; margin: 0; padding: 6px 12px; color: var(--removed); font-size: 12px; }

.result-card { margin-top: 14px; overflow: hidden; }
.result-header h2 + p { margin: 4px 0 0; }
.busy { display: flex; gap: 8px; align-items: center; font-weight: 700; }
.busy[hidden] { display: none; }
.busy span { width: 16px; height: 16px; border: 2px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.warnings { margin: 10px 12px 0; padding: 9px 11px; border: 1px solid var(--changed); border-radius: 7px; background: var(--changed-bg); color: var(--changed); }
.warning-message { display: flex; align-items: flex-start; gap: 7px; margin: 0; }
.service-icon-warning { width: 15px; height: 15px; margin-top: 1px; border: 1.7px solid currentColor; border-radius: 50%; }
.service-icon-warning::after { position: absolute; inset: 0; display: grid; content: "!"; font: 800 10px/1 ui-sans-serif, system-ui, sans-serif; place-items: center; }
.summary { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); }
.metric { display: inline-flex; gap: 7px; align-items: center; padding: 5px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.metric.added { color: var(--added); background: var(--added-bg); }.metric.removed { color: var(--removed); background: var(--removed-bg); }.metric.changed { color: var(--changed); background: var(--changed-bg); }.metric.type-changed { color: var(--type); background: var(--type-bg); }.metric.ignored,.metric.neutral { color: var(--ignored); background: var(--surface-2); }
.result-controls { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.segmented { display: flex; flex-wrap: wrap; gap: 4px; }
.segmented button { min-height: 30px; padding: 4px 9px; font-size: 12px; }
.segmented button.active { background: var(--text); color: var(--surface); }
.search-label { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; }
.search-label input { width: min(260px, 38vw); padding: 6px 8px; }
.diff-tree { max-height: 620px; overflow: auto; padding: 6px 12px 13px; }
.diff-group { margin: 6px 0; }
.diff-group > summary { padding: 7px; border-radius: 6px; background: var(--surface-2); font-family: ui-monospace, monospace; }
.diff-item { margin: 7px 0 7px 14px; border: 1px solid var(--border); border-left-width: 4px; border-radius: 7px; overflow: hidden; }
.diff-item.added { border-left-color: var(--added); }.diff-item.removed { border-left-color: var(--removed); }.diff-item.changed { border-left-color: var(--changed); }.diff-item.type-changed { border-left-color: var(--type); }
.diff-item > summary { display: flex; align-items: center; gap: 8px; padding: 8px 9px; }
.diff-path { min-width: 0; overflow: hidden; text-overflow: ellipsis; font: 12px ui-monospace, monospace; }
.change-label { flex: 0 0 auto; padding: 3px 6px; border-radius: 5px; text-transform: uppercase; letter-spacing: .03em; font-size: 10px; font-weight: 800; }
.change-label.added { color: var(--added); background: var(--added-bg); }.change-label.removed { color: var(--removed); background: var(--removed-bg); }.change-label.changed { color: var(--changed); background: var(--changed-bg); }.change-label.type-changed { color: var(--type); background: var(--type-bg); }
.change-body { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 9px; border-top: 1px solid var(--border); }
.value-box { min-width: 0; }.value-box strong { display: block; margin-bottom: 5px; font-size: 11px; color: var(--muted); }.value-box pre { max-height: 220px; margin: 0; overflow: auto; padding: 8px; border-radius: 6px; background: var(--surface-2); font: 12px/1.45 ui-monospace, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.change-actions { grid-column: 1 / -1; display: flex; gap: 6px; }.change-actions button { min-height: 28px; padding: 3px 7px; font-size: 11px; }
.empty-state { margin: 0; padding: 32px; text-align: center; color: var(--muted); }

.bottom-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 14px; margin-top: 14px; }
.panel { min-width: 0; padding: 14px; }
.panel h2 { margin-bottom: 9px; }.panel p { margin: 7px 0; }
.badge { color: var(--muted); font-size: 10px; text-transform: uppercase; }
.output { max-height: 260px; overflow: auto; margin: 9px 0; padding: 10px; border: 1px solid var(--border); border-radius: 7px; background: var(--surface-2); font: 12px/1.45 ui-monospace, monospace; white-space: pre-wrap; }
.heuristic-label { color: var(--changed); font-size: 12px; }.breaking-total { font-size: 16px; }.breaking-list { padding-left: 20px; }.breaking-list li { margin: 6px 0; }
.panel select { padding: 6px 8px; margin-left: 6px; }

dialog { width: min(480px, calc(100vw - 32px)); padding: 18px; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(0,0,0,.5); }
dialog h2 { margin-top: 0; }.sample-choice { display: block; width: 100%; margin: 8px 0; text-align: left; }.sample-choice small { display: block; margin-top: 3px; color: var(--muted); font-weight: 400; }
.toast { position: fixed; z-index: 50; right: 18px; bottom: 18px; max-width: min(420px, calc(100vw - 36px)); padding: 10px 14px; color: white; background: #101828; border-radius: 8px; box-shadow: var(--shadow); opacity: 0; transform: translateY(10px); pointer-events: none; transition: .2s; }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .app-header { align-items: flex-start; }.editors, .bottom-grid { grid-template-columns: 1fr; }.code-editor { height: 340px; }.result-controls { flex-direction: column; }.search-label input { flex: 1; width: auto; }
}
@media (max-width: 640px) {
  .app-header { position: static; display: block; padding: 10px; }.toolbar { justify-content: flex-start; margin-top: 10px; }.toolbar button { flex: 1 0 auto; } main { padding: 10px 10px 28px; }.privacy-note { text-align: left; }.change-body { grid-template-columns: 1fr; }.bottom-grid { gap: 10px; }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; } }
