:root {
  --bg: #eef4f0;
  --bg-accent: #d4e7dc;
  --panel: rgba(252, 255, 253, 0.9);
  --panel-border: rgba(20, 65, 48, 0.12);
  --text: #16231d;
  --muted: #51655b;
  --primary: #146c4f;
  --primary-dark: #0f543e;
  --success: #16643f;
  --shadow: 0 18px 40px rgba(18, 49, 37, 0.1);
  --radius: 24px;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #f7fbf9;
  --backdrop: rgba(12, 22, 19, 0.54);
  --input-border: rgba(20, 65, 48, 0.16);
  --danger: #b42318;
  --checkbox-bg: #ffffff;
  --checkbox-border: rgba(20, 65, 48, 0.28);
  --surface-soft: rgba(255, 255, 255, 0.7);
  --card-bg: rgba(255, 255, 255, 0.86);
  --diff-bg: #101917;
  --diff-text: #eef7f3;
  --diff-meta: #d8ddcb;
}

:root[data-theme="dark"] {
  --bg: #0c1210;
  --bg-accent: #173128;
  --panel: rgba(21, 31, 28, 0.98);
  --panel-border: rgba(137, 208, 175, 0.18);
  --text: #f4fbf7;
  --muted: #c1d2ca;
  --primary: #7af0be;
  --primary-dark: #58d6a1;
  --success: #8ff0b8;
  --shadow: 0 24px 56px rgba(0, 0, 0, 0.48);
  --surface: rgba(31, 43, 39, 1);
  --surface-strong: #24322d;
  --surface-soft: rgba(27, 39, 35, 0.92);
  --card-bg: rgba(26, 37, 33, 0.96);
  --backdrop: rgba(3, 8, 6, 0.78);
  --input-border: rgba(157, 222, 191, 0.26);
  --danger: #ff8f87;
  --checkbox-bg: #101916;
  --checkbox-border: rgba(201, 241, 222, 0.52);
  --diff-bg: #0d1412;
  --diff-text: #f0faf5;
  --diff-meta: #dde9e2;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  font-size: 19px;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.82), transparent 28%),
    radial-gradient(circle at bottom right, rgba(120, 187, 155, 0.14), transparent 28%),
    linear-gradient(135deg, var(--bg), #f8fcfa 42%, var(--bg-accent));
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(122, 240, 190, 0.08), transparent 24%),
    radial-gradient(circle at bottom right, rgba(72, 130, 104, 0.16), transparent 26%),
    linear-gradient(135deg, #0a100e, var(--bg) 42%, var(--bg-accent));
}

body.modal-open {
  overflow: hidden;
}

.shell {
  width: min(1240px, calc(100% - 36px));
  margin: 0 auto;
  padding: 56px 0 72px;
}

.hero {
  margin-bottom: 28px;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--primary);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 16px;
  max-width: 12ch;
  font-size: clamp(2.6rem, 5.8vw, 5rem);
  line-height: 0.98;
}

.lede {
  max-width: 52rem;
  font-size: 1.18rem;
  line-height: 1.7;
  color: var(--muted);
}

.panel {
  backdrop-filter: blur(14px);
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px;
}

.panel + .panel {
  margin-top: 22px;
}

.compare-form {
  display: grid;
  gap: 22px;
}

.form-intro {
  display: grid;
  gap: 6px;
}

.form-title {
  margin: 0;
  font-size: 1.28rem;
  font-weight: 700;
}

.form-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.branch-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 16px;
  align-items: end;
}

.field {
  display: grid;
  gap: 10px;
}

.field span {
  font-size: 1rem;
  font-weight: 600;
}

.repo-input-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
}

input {
  width: 100%;
  border: 1px solid var(--input-border);
  border-radius: 16px;
  background: var(--surface);
  padding: 16px 18px;
  font: inherit;
  color: inherit;
  font-size: 1.04rem;
  line-height: 1.4;
}

input,
button,
.filter-chip,
.file-card,
.filter-picker-button,
.modal-close-button {
  transition:
    background-color 180ms ease,
    border-color 180ms ease,
    color 180ms ease,
    transform 180ms ease,
    box-shadow 180ms ease;
}

input:focus {
  outline: 3px solid rgba(20, 108, 79, 0.2);
  border-color: rgba(20, 108, 79, 0.5);
}

button {
  font: inherit;
  cursor: pointer;
}

.swap-button,
.hide-button,
.diff-button,
.theme-toggle-button,
.secondary-button {
  border: 1px solid var(--input-border);
  background: var(--surface-strong);
  color: var(--text);
  border-radius: 16px;
  padding: 13px 18px;
  transition: transform 180ms ease, border-color 180ms ease;
  min-height: 50px;
  font-weight: 600;
}

.swap-button:hover,
.hide-button:hover,
.diff-button:hover,
.theme-toggle-button:hover,
.secondary-button:hover,
.primary-button:hover {
  transform: translateY(-1px);
  border-color: rgba(20, 108, 79, 0.28);
}

.theme-toggle-button {
  min-width: 140px;
}

.secondary-button {
  white-space: nowrap;
}

.repo-meta {
  margin: -8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.repo-meta a {
  color: var(--primary);
  font-weight: 700;
  text-decoration: none;
}

.repo-meta a:hover {
  text-decoration: underline;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: flex-start;
  align-items: center;
}

.toggle {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: var(--muted);
}

.toggle input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.primary-button {
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), #2b9a73);
  color: #f8fffb;
  padding: 15px 26px;
  font-weight: 700;
  min-height: 52px;
}

.status {
  min-height: 28px;
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.6;
}

.results-head {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 18px;
}

.results-meta {
  color: var(--muted);
  font-size: 0.98rem;
  text-align: right;
}

.empty-state {
  border: 1px dashed var(--input-border);
  border-radius: 20px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.7;
  background: var(--surface-soft);
}

.results-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.filter-section {
  display: inline-grid;
  width: min(100%, 49%);
  margin-bottom: 20px;
  margin-right: 14px;
  vertical-align: top;
  padding: 0;
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  background: var(--surface-soft);
}

.filter-picker {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.filter-picker-button {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 58px;
  padding: 14px 16px;
  border: 1px solid var(--input-border);
  border-radius: 18px;
  background: var(--surface-strong);
  text-align: left;
}

.filter-picker-button::after {
  content: "+";
  font-size: 1.25rem;
  color: var(--primary);
}

.filter-picker-button[aria-expanded="true"]::after {
  content: "-";
}

.filter-picker-title,
.filter-picker-summary {
  display: block;
}

.filter-picker-title {
  font-size: 1.02rem;
  font-weight: 700;
}

.filter-picker-summary {
  color: var(--muted);
  font-size: 0.94rem;
}

.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  align-items: stretch;
}

.filter-chip {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--input-border);
  border-radius: 18px;
  background: var(--surface);
  color: var(--muted);
  cursor: pointer;
  width: 100%;
  min-height: 100%;
}

.filter-chip:hover {
  border-color: rgba(20, 108, 79, 0.28);
  box-shadow: 0 8px 24px rgba(20, 65, 48, 0.08);
}

.filter-checkbox {
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  padding: 0;
  border: 1px solid var(--checkbox-border);
  border-radius: 6px;
  background: var(--checkbox-bg);
  appearance: none;
  -webkit-appearance: none;
  display: block;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  flex-shrink: 0;
  position: relative;
}

.filter-checkbox:focus-visible {
  outline: 3px solid rgba(20, 108, 79, 0.24);
  outline-offset: 2px;
}

.filter-checkbox:checked {
  background: var(--primary);
  border-color: var(--primary-dark);
}

.filter-checkbox:checked::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: solid #ffffff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.filter-chip-content {
  display: grid;
  gap: 5px;
  width: 100%;
  min-width: 0;
  align-content: start;
}

.filter-chip-content strong {
  color: var(--text);
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 700;
}

.filter-chip-content small,
.filter-chip-content em {
  color: var(--muted);
  font-style: normal;
  line-height: 1.45;
  word-break: break-word;
}

.filter-checkbox:checked + .filter-chip-content strong {
  color: var(--primary);
}

.filter-checkbox:checked + .filter-chip-content small,
.filter-checkbox:checked + .filter-chip-content em {
  color: var(--text);
}

.file-card {
  border: 1px solid rgba(20, 65, 48, 0.12);
  border-radius: 22px;
  background: var(--card-bg);
  padding: 22px;
  animation: rise 220ms ease;
  min-height: 100%;
}

.file-head {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: start;
}

.file-path {
  margin: 0 0 8px;
  font-size: 1.12rem;
  line-height: 1.5;
  font-weight: 700;
  word-break: break-word;
}

.file-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.98rem;
  line-height: 1.6;
}

.file-side {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.diff-button {
  background: rgba(20, 108, 79, 0.08);
  border-color: rgba(20, 108, 79, 0.18);
}

.diff-panel {
  border-radius: 18px;
  background: var(--diff-bg);
  color: var(--diff-text);
  overflow: hidden;
  border: 1px solid rgba(122, 197, 167, 0.14);
}

.diff-panel.loading,
.diff-panel.error,
.diff-panel.muted {
  padding: 18px 20px;
  background: rgba(16, 25, 23, 0.96);
}

.diff-panel.error {
  color: #ffcdc0;
}

.diff-panel.muted {
  color: #d8c7b8;
}

.diff-code {
  margin: 0;
  padding: 14px 0;
  overflow: auto;
  font-family: Consolas, "Courier New", monospace;
  font-size: 1rem;
  line-height: 1.75;
  white-space: pre-wrap;
}

.diff-line {
  display: block;
  padding: 2px 18px;
  color: var(--diff-text);
}

.diff-line-add {
  background: rgba(46, 160, 67, 0.2);
  color: #c8f7d1;
}

.diff-line-remove {
  background: rgba(248, 81, 73, 0.18);
  color: #ffd7d5;
}

.diff-line-hunk {
  background: rgba(56, 139, 253, 0.14);
  color: #c6dcff;
}

.diff-line-meta {
  color: var(--diff-meta);
}

:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .file-card,
:root[data-theme="dark"] .filter-section,
:root[data-theme="dark"] .diff-modal-card {
  backdrop-filter: blur(18px);
}

:root[data-theme="dark"] .theme-toggle-button,
:root[data-theme="dark"] .swap-button,
:root[data-theme="dark"] .hide-button,
:root[data-theme="dark"] .diff-button,
:root[data-theme="dark"] .modal-close-button,
:root[data-theme="dark"] .filter-picker-button {
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

:root[data-theme="dark"] .theme-toggle-button:hover,
:root[data-theme="dark"] .swap-button:hover,
:root[data-theme="dark"] .hide-button:hover,
:root[data-theme="dark"] .diff-button:hover,
:root[data-theme="dark"] .modal-close-button:hover,
:root[data-theme="dark"] .filter-picker-button:hover,
:root[data-theme="dark"] .filter-chip:hover {
  border-color: rgba(122, 240, 190, 0.42);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

.diff-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 24px;
}

.diff-modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--backdrop);
  backdrop-filter: blur(8px);
}

.diff-modal-card {
  position: relative;
  z-index: 1;
  width: min(1100px, 100%);
  max-height: min(88vh, 920px);
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 18px;
  padding: 24px;
  border-radius: 26px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 24px 80px rgba(15, 36, 29, 0.24);
}

.diff-modal-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.diff-modal-head h2 {
  margin-bottom: 0;
  font-size: 1.35rem;
  line-height: 1.4;
  word-break: break-word;
}

.modal-close-button {
  border: 1px solid var(--input-border);
  background: var(--surface-strong);
  border-radius: 16px;
  min-height: 50px;
  padding: 12px 18px;
  font-weight: 700;
}

.diff-modal-body {
  overflow: auto;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-top: 22px;
  padding: 18px 22px;
  border-radius: 22px;
  border: 1px solid var(--panel-border);
  background: linear-gradient(135deg, var(--surface-soft), var(--panel));
  box-shadow: 0 18px 44px rgba(15, 36, 29, 0.1);
}

.footer-credit,
.footer-time {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.footer-credit {
  font-weight: 700;
  color: var(--text);
}

.footer-time time {
  color: var(--primary);
  font-weight: 700;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 760px) {
  html {
    font-size: 17px;
  }

  .shell {
    width: min(100% - 18px, 1100px);
    padding-top: 24px;
    padding-bottom: 40px;
  }

  .branch-grid,
  .results-head,
  .file-head,
  .toolbar {
    grid-template-columns: 1fr;
    display: grid;
  }

  .panel {
    padding: 20px;
  }

  .app-footer {
    grid-template-columns: 1fr;
    display: grid;
    align-items: start;
  }

  .filter-section {
    width: 100%;
    margin-right: 0;
  }

  .file-card {
    padding: 18px;
  }

  .results-meta {
    text-align: left;
  }

  .file-side {
    justify-content: start;
  }

  .swap-button,
  .hide-button,
  .diff-button,
  .secondary-button,
  .theme-toggle-button,
  .primary-button {
    width: 100%;
  }

  .repo-input-row {
    grid-template-columns: 1fr;
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .results-list {
    grid-template-columns: 1fr;
  }

  .diff-modal {
    padding: 12px;
  }

  .diff-modal-card {
    padding: 18px;
    max-height: 92vh;
  }

  .diff-modal-head {
    grid-template-columns: 1fr;
    display: grid;
  }
}

@media (min-width: 761px) and (max-width: 1024px) {
  .shell {
    width: min(100% - 28px, 1100px);
  }

  .branch-grid {
    grid-template-columns: 1fr 140px 1fr;
  }

  .filter-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .results-list {
    grid-template-columns: 1fr;
  }
}

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