:root {
  color-scheme: light;
  --paper: #eeeade;
  --sheet: #faf7ed;
  --ink: #11120f;
  --soft-ink: #56584f;
  --line: #11120f;
  --hairline: rgba(17, 18, 15, 0.24);
  --blue: #2357ff;
  --blue-soft: #d9e1ff;
  --coral: #ff5c4a;
  --coral-soft: #ffd8d2;
  --lime: #c8ff2f;
  --lime-dark: #618600;
  --shadow: rgba(17, 18, 15, 0.16);
  --grid: rgba(17, 18, 15, 0.075);
}

body.dark {
  color-scheme: dark;
  --paper: #121410;
  --sheet: #1c1e18;
  --ink: #f1eedf;
  --soft-ink: #a8aa9e;
  --line: #f1eedf;
  --hairline: rgba(241, 238, 223, 0.25);
  --blue: #7595ff;
  --blue-soft: #202b52;
  --coral: #ff7768;
  --coral-soft: #522923;
  --lime: #c8ff2f;
  --lime-dark: #c8ff2f;
  --shadow: rgba(0, 0, 0, 0.35);
  --grid: rgba(241, 238, 223, 0.07);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px),
    var(--paper);
  background-size: 28px 28px;
  color: var(--ink);
  font-family: "Arial Narrow", "Avenir Next Condensed", "Helvetica Neue", Arial, sans-serif;
  transition: background-color 0.2s, color 0.2s;
}

button, input, textarea { font: inherit; }
button { color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--lime); outline-offset: 2px; }
.site-shell { width: min(1400px, calc(100% - 42px)); margin: 0 auto; }
.kicker { margin: 0; font: 800 10px/1 "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; letter-spacing: 0.18em; }

.masthead {
  min-height: 104px;
  display: grid;
  grid-template-columns: minmax(270px, 1fr) 1fr auto;
  align-items: center;
  gap: 30px;
  border-bottom: 2px solid var(--line);
}
.wordmark { width: fit-content; display: flex; align-items: baseline; color: var(--ink); text-decoration: none; font-size: 23px; font-weight: 950; letter-spacing: -0.07em; }
.wordmark span:last-child { padding: 5px 7px 4px 5px; background: var(--ink); color: var(--paper); font: 800 15px/1 "IBM Plex Mono", monospace; letter-spacing: 0.01em; transform: rotate(-3deg); }
.edition { margin: 0; color: var(--soft-ink); font: 700 8px/1.55 "IBM Plex Mono", monospace; letter-spacing: 0.12em; }
.mast-actions { display: flex; align-items: center; gap: 12px; }
.local-pill { padding: 9px 11px; border: 1px solid var(--line); background: var(--sheet); font: 700 8px "IBM Plex Mono", monospace; letter-spacing: 0.09em; }
.local-pill i { width: 6px; height: 6px; display: inline-block; margin-right: 7px; border-radius: 50%; background: var(--lime-dark); box-shadow: 0 0 0 4px color-mix(in srgb, var(--lime) 20%, transparent); }
.icon-button { width: 36px; height: 36px; border: 1px solid var(--line); background: var(--sheet); font-size: 15px; }
.icon-button:hover { background: var(--lime); color: #11120f; }

.hero { min-height: 350px; display: grid; grid-template-columns: 115px minmax(0, 1fr) 320px; align-items: end; gap: 30px; padding: 55px 0 45px; border-bottom: 2px solid var(--line); }
.hero-index { align-self: start; color: var(--blue); font: 900 70px/0.8 "IBM Plex Mono", monospace; letter-spacing: -0.12em; }
.hero h1 { margin: 13px 0 -8px; font-size: clamp(65px, 9.4vw, 145px); font-weight: 950; line-height: 0.74; letter-spacing: -0.085em; text-transform: uppercase; }
.hero h1 em { color: var(--coral); font-family: Georgia, "Times New Roman", serif; font-size: 0.64em; font-weight: 400; letter-spacing: -0.06em; text-transform: none; }
.hero-note { align-self: center; padding: 18px 0 0; border-top: 5px solid var(--ink); }
.hero-note .arrow { display: block; margin-bottom: 28px; color: var(--blue); font-size: 44px; font-weight: 300; }
.hero-note p { margin: 0; color: var(--soft-ink); font-size: 13px; font-weight: 600; line-height: 1.6; }

.command-bar { min-height: 70px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 24px; padding: 9px; border: 2px solid var(--line); border-top: 0; background: var(--sheet); box-shadow: 8px 8px 0 var(--ink); }
.view-switch { display: grid; grid-template-columns: 90px 90px; min-height: 46px; border: 1px solid var(--line); }
.view-switch button { border: 0; border-right: 1px solid var(--line); background: transparent; font: 800 9px "IBM Plex Mono", monospace; letter-spacing: 0.09em; }
.view-switch button:last-child { border-right: 0; }
.view-switch button.is-active { background: var(--blue); color: white; }
.options { min-width: 0; display: flex; align-items: center; gap: 20px; }
.options label { display: flex; align-items: center; gap: 8px; color: var(--soft-ink); font: 700 8px "IBM Plex Mono", monospace; letter-spacing: 0.06em; cursor: pointer; white-space: nowrap; }
.options input { position: absolute; opacity: 0; pointer-events: none; }
.options label > span { width: 13px; height: 13px; display: inline-grid; place-items: center; border: 1px solid var(--line); background: var(--paper); }
.options input:checked + span { background: var(--lime); box-shadow: inset 0 0 0 3px var(--paper); }
.command-actions { display: flex; align-items: center; gap: 10px; }
.command-actions button { padding: 9px 0; border: 0; background: transparent; font: 800 8px "IBM Plex Mono", monospace; letter-spacing: 0.07em; }
.command-actions button:hover { color: var(--blue); }
.command-actions i { color: var(--hairline); font-style: normal; }

.source-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; margin-top: 40px; }
.source-panel { min-width: 0; position: relative; border: 2px solid var(--line); background: var(--sheet); box-shadow: 8px 8px 0 var(--ink); overflow: hidden; }
.source-before { border-top: 10px solid var(--blue); }
.source-after { border-top: 10px solid var(--coral); }
.source-head { min-height: 66px; display: grid; grid-template-columns: minmax(145px, 1fr) minmax(160px, 1fr) auto; align-items: center; gap: 14px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.source-label { display: flex; align-items: center; gap: 10px; font: 800 9px "IBM Plex Mono", monospace; letter-spacing: 0.08em; }
.source-label b { width: 31px; height: 31px; display: grid; place-items: center; background: var(--blue); color: white; font-size: 13px; }
.source-after .source-label b { background: var(--coral); color: #11120f; }
.file-name { min-width: 0; display: flex; flex-direction: column; gap: 3px; color: var(--soft-ink); font: 700 7px "IBM Plex Mono", monospace; letter-spacing: 0.09em; }
.file-name input { width: 100%; padding: 0; border: 0; border-bottom: 1px solid transparent; outline: 0; background: transparent; color: var(--ink); font: 700 10px "IBM Plex Mono", monospace; }
.file-name input:focus { border-bottom-color: var(--blue); }
.source-head > button { padding: 8px 9px; border: 1px solid var(--line); background: transparent; font: 800 7px "IBM Plex Mono", monospace; letter-spacing: 0.07em; }
.source-head > button:hover { background: var(--lime); color: #11120f; }
.editor-shell { height: 350px; display: grid; grid-template-columns: 50px minmax(0, 1fr); background: color-mix(in srgb, var(--sheet) 90%, var(--blue) 10%); }
.source-after .editor-shell { background: color-mix(in srgb, var(--sheet) 90%, var(--coral) 10%); }
.line-gutter { height: 100%; margin: 0; padding: 20px 10px 20px 0; overflow: hidden; border-right: 1px solid var(--hairline); color: var(--soft-ink); background: color-mix(in srgb, var(--paper) 75%, transparent); font: 500 11px/1.65 "IBM Plex Mono", monospace; text-align: right; user-select: none; }
.editor-shell textarea { width: 100%; height: 100%; display: block; resize: none; padding: 20px; border: 0; outline: 0; background: transparent; color: var(--ink); font: 500 12px/1.65 "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; tab-size: 2; white-space: pre; }
.source-before textarea:focus { box-shadow: inset 4px 0 0 var(--blue); }
.source-after textarea:focus { box-shadow: inset 4px 0 0 var(--coral); }
.source-foot { min-height: 42px; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 0 14px; border-top: 1px solid var(--line); color: var(--soft-ink); font: 700 7px "IBM Plex Mono", monospace; letter-spacing: 0.08em; }
.drop-screen { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; background: color-mix(in srgb, var(--lime) 88%, transparent); color: #11120f; font: 950 clamp(40px, 8vw, 90px)/1 "IBM Plex Mono", monospace; opacity: 0; pointer-events: none; }
.source-panel.is-dragging .drop-screen { opacity: 1; }

.scoreboard { min-height: 132px; display: grid; grid-template-columns: 1.25fr repeat(4, 0.82fr) 1.15fr; margin-top: 58px; border: 2px solid var(--line); background: var(--ink); color: var(--paper); box-shadow: 8px 8px 0 var(--blue); }
.score-main, .score-cell, .score-status { padding: 18px; border-right: 1px solid color-mix(in srgb, var(--paper) 28%, transparent); }
.score-main span, .score-cell span, .score-main small, .score-cell small, .score-status span, .score-status small { display: block; font: 700 7px "IBM Plex Mono", monospace; letter-spacing: 0.12em; }
.score-main strong, .score-cell strong { display: inline-block; margin: 10px 5px 4px 0; font: 900 51px/0.8 "IBM Plex Mono", monospace; letter-spacing: -0.1em; }
.score-cell strong { font-size: 39px; }
.score-add strong { color: var(--lime); }
.score-remove strong { color: var(--coral); }
.score-status { display: flex; align-items: center; gap: 12px; border-right: 0; }
.score-status i { width: 13px; height: 13px; flex: 0 0 auto; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 7px color-mix(in srgb, var(--lime) 15%, transparent); }
.score-status small { margin-top: 7px; color: color-mix(in srgb, var(--paper) 62%, transparent); }

.result-section { margin-top: 95px; }
.result-title-row { display: flex; align-items: end; justify-content: space-between; gap: 35px; margin-bottom: 25px; }
.result-title-row h2, .legend-section h2 { margin: 7px 0 0; font-size: clamp(45px, 6vw, 82px); font-weight: 950; line-height: 0.9; letter-spacing: -0.07em; text-transform: uppercase; }
.result-actions { display: flex; align-items: center; gap: 7px; }
.result-actions button { height: 38px; padding: 0 11px; border: 1px solid var(--line); background: var(--sheet); font: 800 8px "IBM Plex Mono", monospace; letter-spacing: 0.07em; }
.result-actions button:disabled { opacity: 0.35; cursor: default; }
.result-actions button:not(:disabled):hover { background: var(--lime); color: #11120f; }
.result-actions > span { min-width: 50px; color: var(--soft-ink); font: 700 8px "IBM Plex Mono", monospace; text-align: center; }
.result-actions .patch-button { margin-left: 8px; }
.result-actions .patch-button.is-solid { margin-left: 0; background: var(--ink); color: var(--paper); }
.diff-frame { border: 2px solid var(--line); background: var(--sheet); box-shadow: 12px 12px 0 var(--ink); overflow: hidden; }
.diff-columns { min-height: 51px; display: grid; grid-template-columns: 1fr 1fr; border-bottom: 2px solid var(--line); background: var(--ink); color: var(--paper); }
.diff-columns span { display: flex; align-items: center; padding: 0 17px; font: 800 8px "IBM Plex Mono", monospace; letter-spacing: 0.09em; }
.diff-columns span:first-child { border-right: 1px solid color-mix(in srgb, var(--paper) 35%, transparent); }
.diff-output { max-height: 700px; overflow: auto; background: var(--sheet); font: 500 11px/1.6 "IBM Plex Mono", "SFMono-Regular", Consolas, monospace; }
.diff-row { min-width: 820px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); border-bottom: 1px solid var(--hairline); }
.diff-row:last-child { border-bottom: 0; }
.diff-cell { min-width: 0; display: grid; grid-template-columns: 45px 25px minmax(0, 1fr); border-right: 1px solid var(--hairline); background: var(--sheet); }
.diff-cell:last-child { border-right: 0; }
.diff-cell.is-empty { background: color-mix(in srgb, var(--paper) 78%, var(--ink) 4%); }
.diff-cell.is-delete { background: var(--coral-soft); }
.diff-cell.is-insert { background: color-mix(in srgb, var(--lime) 28%, var(--sheet)); }
.line-number, .line-sign { padding: 6px 8px; color: var(--soft-ink); background: color-mix(in srgb, var(--paper) 60%, transparent); text-align: right; user-select: none; }
.line-sign { padding-left: 4px; padding-right: 4px; text-align: center; }
.line-code { min-height: 30px; padding: 6px 10px; overflow-wrap: anywhere; white-space: pre-wrap; }
.inline-delete { background: var(--coral); color: #11120f; }
.inline-insert { background: var(--lime); color: #11120f; }
.diff-row.is-change-start { border-top: 3px solid var(--blue); scroll-margin-top: 14px; }
.fold-row { min-width: 820px; display: grid; place-items: center; min-height: 43px; border-bottom: 1px solid var(--hairline); background: repeating-linear-gradient(-45deg, transparent, transparent 7px, var(--grid) 7px, var(--grid) 14px); color: var(--soft-ink); font: 800 8px "IBM Plex Mono", monospace; letter-spacing: 0.08em; }
.unified-row { min-width: 620px; display: grid; grid-template-columns: 45px 45px 25px minmax(0, 1fr); border-bottom: 1px solid var(--hairline); }
.unified-row.is-delete { background: var(--coral-soft); }
.unified-row.is-insert { background: color-mix(in srgb, var(--lime) 28%, var(--sheet)); }
.unified-row.is-change-start { border-top: 3px solid var(--blue); scroll-margin-top: 14px; }
.unified-row .line-number { border-right: 1px solid var(--hairline); }
.unified-row .line-code { padding-left: 12px; }
.empty-diff { min-height: 260px; display: grid; place-items: center; padding: 40px; text-align: center; }
.empty-diff strong { display: block; font-size: clamp(28px, 5vw, 60px); font-weight: 950; letter-spacing: -0.06em; text-transform: uppercase; }
.empty-diff span { display: block; margin-top: 10px; color: var(--soft-ink); font: 700 9px "IBM Plex Mono", monospace; letter-spacing: 0.08em; }

.legend-section { display: grid; grid-template-columns: 0.8fr 1.2fr; gap: 70px; margin-top: 100px; padding: 55px 0; border-top: 8px solid var(--ink); border-bottom: 2px solid var(--line); }
.legend-section h2 { max-width: 480px; font-size: clamp(42px, 5vw, 70px); }
.legend-list { margin: 0; border-top: 1px solid var(--line); }
.legend-list > div { min-height: 68px; display: grid; grid-template-columns: 160px 1fr; align-items: center; gap: 20px; border-bottom: 1px solid var(--line); }
.legend-list dt { display: flex; align-items: center; gap: 10px; font: 800 9px "IBM Plex Mono", monospace; letter-spacing: 0.08em; }
.legend-list dd { margin: 0; color: var(--soft-ink); font-size: 12px; font-weight: 600; line-height: 1.5; }
.legend-block { width: 16px; height: 16px; display: inline-block; border: 1px solid var(--line); background: var(--sheet); }
.legend-block.add { background: var(--lime); }
.legend-block.remove { background: var(--coral); }
.legend-block.inline { background: var(--blue); }
.legend-block.fold { background: repeating-linear-gradient(-45deg, var(--paper), var(--paper) 3px, var(--ink) 3px, var(--ink) 4px); }

footer { min-height: 112px; display: flex; align-items: center; justify-content: space-between; gap: 25px; color: var(--soft-ink); font: 700 8px "IBM Plex Mono", monospace; letter-spacing: 0.09em; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 20; padding: 14px 18px; transform: translateY(10px); border: 2px solid #11120f; background: var(--lime); box-shadow: 6px 6px 0 #11120f; color: #11120f; font: 800 9px "IBM Plex Mono", monospace; letter-spacing: 0.08em; opacity: 0; pointer-events: none; transition: 0.18s; }
.toast.show { transform: translateY(0); opacity: 1; }

@media (max-width: 1100px) {
  .hero { grid-template-columns: 80px minmax(0, 1fr) 250px; }
  .hero-index { font-size: 54px; }
  .command-bar { grid-template-columns: auto 1fr; }
  .command-actions { grid-column: 1 / -1; justify-content: flex-end; border-top: 1px solid var(--hairline); padding-top: 8px; }
  .scoreboard { grid-template-columns: 1.1fr repeat(4, 0.8fr); }
  .score-status { grid-column: 1 / -1; min-height: 62px; border-top: 1px solid color-mix(in srgb, var(--paper) 28%, transparent); }
  .score-cell:nth-child(5) { border-right: 0; }
  .result-title-row { align-items: flex-start; flex-direction: column; }
}

@media (max-width: 820px) {
  .site-shell { width: min(100% - 26px, 1400px); }
  .masthead { grid-template-columns: 1fr auto; }
  .edition { display: none; }
  .hero { min-height: 0; grid-template-columns: 1fr; gap: 28px; padding: 42px 0 38px; }
  .hero-index { position: absolute; right: 24px; font-size: 45px; }
  .hero-note { max-width: 430px; }
  .hero-note .arrow { margin-bottom: 10px; }
  .command-bar { display: block; }
  .view-switch { margin-bottom: 10px; }
  .options { flex-wrap: wrap; padding: 8px 4px; }
  .command-actions { justify-content: flex-start; margin-top: 8px; }
  .source-grid { grid-template-columns: 1fr; }
  .scoreboard { grid-template-columns: 1fr 1fr; }
  .score-main { grid-column: 1 / -1; }
  .score-main, .score-cell { border-bottom: 1px solid color-mix(in srgb, var(--paper) 28%, transparent); }
  .score-cell:nth-child(odd) { border-right: 0; }
  .score-status { grid-column: 1 / -1; }
  .result-actions { width: 100%; flex-wrap: wrap; }
  .legend-section { grid-template-columns: 1fr; gap: 40px; }
}

@media (max-width: 560px) {
  .masthead { min-height: 80px; }
  .local-pill { display: none; }
  .hero h1 { font-size: 56px; }
  .view-switch { grid-template-columns: 1fr 1fr; }
  .options { align-items: flex-start; flex-direction: column; }
  .command-actions { flex-wrap: wrap; }
  .command-actions i { display: none; }
  .source-head { grid-template-columns: 1fr auto; }
  .file-name { grid-row: 2; grid-column: 1 / -1; padding-bottom: 10px; }
  .editor-shell { height: 310px; grid-template-columns: 40px minmax(0, 1fr); }
  .line-gutter { padding-right: 7px; }
  .editor-shell textarea { padding: 20px 14px; }
  .scoreboard { display: grid; }
  .score-main strong { font-size: 45px; }
  .result-actions .patch-button { margin-left: 0; }
  .result-actions .patch-button.is-solid { flex: 1; }
  .diff-output { max-height: 560px; }
  .legend-list > div { grid-template-columns: 115px 1fr; }
  footer { align-items: flex-start; flex-direction: column; justify-content: center; }
  footer span:nth-child(2) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

/* Application-shell redesign: dense compare IDE, not landing page. */
@media (min-width: 901px) {
  body { overflow: hidden; background: var(--paper); }
  .site-shell {
    width: 100%;
    height: 100dvh;
    display: grid;
    grid-template-rows: 56px 52px minmax(220px, 36vh) 58px minmax(0, 1fr);
    overflow: hidden;
  }
  .hero, .legend-section, footer { display: none; }
  .masthead {
    min-height: 0;
    padding: 0 18px;
    border-bottom: 1px solid var(--line);
    background: var(--ink);
    color: var(--paper);
  }
  .wordmark { color: var(--paper); }
  .wordmark span:last-child { background: var(--lime); color: #11120f; transform: none; border-radius: 999px; }
  .edition { color: color-mix(in srgb, var(--paper) 58%, transparent); }
  .local-pill, .icon-button { border-color: color-mix(in srgb, var(--paper) 35%, transparent); background: transparent; color: var(--paper); border-radius: 999px; }
  .command-bar {
    min-height: 0;
    padding: 6px 12px;
    border: 0;
    border-bottom: 1px solid var(--line);
    background: var(--sheet);
    box-shadow: none;
  }
  .view-switch { min-height: 38px; height: 38px; border: 0; gap: 4px; }
  .view-switch button { border: 0; border-radius: 999px; background: var(--paper); }
  .view-switch button.is-active { background: var(--blue); }
  .source-grid { min-height: 0; margin: 0; gap: 0; }
  .source-panel { height: 100%; border: 0; border-right: 1px solid var(--line); border-radius: 0; box-shadow: none; }
  .source-panel:last-child { border-right: 0; }
  .source-before, .source-after { border-top: 0; }
  .source-before .source-head { box-shadow: inset 5px 0 0 var(--blue); }
  .source-after .source-head { box-shadow: inset 5px 0 0 var(--coral); }
  .source-head { min-height: 54px; }
  .source-label b, .source-after .source-label b { border-radius: 50%; }
  .editor-shell { height: calc(100% - 92px); }
  .source-foot { min-height: 38px; }
  .scoreboard {
    min-height: 0;
    margin: 0;
    border: 0;
    border-top: 1px solid color-mix(in srgb, var(--paper) 25%, transparent);
    border-bottom: 1px solid var(--line);
    box-shadow: none;
  }
  .score-main, .score-cell, .score-status { min-height: 58px; padding: 9px 15px; }
  .score-main strong, .score-cell strong { margin: 5px 4px 0 0; font-size: 22px; }
  .score-main span, .score-cell span, .score-main small, .score-cell small { display: inline; margin-right: 5px; }
  .result-section { min-height: 0; display: flex; flex-direction: column; margin: 0; }
  .result-title-row { min-height: 54px; flex: 0 0 auto; align-items: center; margin: 0; padding: 7px 14px; border-bottom: 1px solid var(--line); background: var(--sheet); }
  .result-title-row .kicker { display: none; }
  .result-title-row h2 { margin: 0; font: 900 16px "IBM Plex Mono", monospace; letter-spacing: -0.03em; text-transform: uppercase; }
  .result-actions button { height: 34px; border: 0; border-radius: 999px; background: var(--paper); }
  .result-actions .patch-button.is-solid { background: var(--blue); color: white; }
  .diff-frame { min-height: 0; flex: 1; border: 0; box-shadow: none; }
  .diff-columns { min-height: 38px; }
  .diff-output { height: calc(100% - 38px); max-height: none; }
}

@media (max-width: 900px) {
  .hero, .legend-section { display: none; }
  .site-shell { width: min(100% - 20px, 1400px); }
  .masthead { min-height: 64px; }
  .source-grid { margin-top: 18px; }
  .source-panel { box-shadow: none; border-radius: 18px; }
  .source-before, .source-after { border-top-width: 6px; }
  .command-bar { margin-top: 12px; border: 1px solid var(--line); border-radius: 18px; box-shadow: none; }
  .scoreboard { border-radius: 18px; overflow: hidden; box-shadow: none; }
  .diff-frame { border-radius: 18px; box-shadow: none; }
}
