:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-muted: #f0f3f7;
  --line: #d9dee8;
  --line-strong: #b9c2d0;
  --text: #1f2328;
  --muted: #687385;
  --accent: #5b5bd6;
  --accent-soft: #ededff;
  --gitlab: #fc6d26;
  --green: #1f8a4c;
  --green-bg: #e9f8ef;
  --red: #c53535;
  --red-bg: #fdecec;
  --yellow-bg: #fff7dd;
  --shadow: 0 18px 45px rgba(31, 35, 40, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
}

[hidden] {
  display: none !important;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

code,
pre,
.diff-table {
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
}

.app-shell {
  min-height: 100vh;
}

.auth-screen {
  display: grid;
  min-height: 100vh;
  min-height: 100svh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(252, 109, 38, 0.12), rgba(91, 91, 214, 0.1)),
    var(--bg);
}

.auth-panel {
  display: grid;
  width: min(100%, 390px);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-panel h1 {
  font-size: 1.7rem;
}

.unlock-button,
.logout-button {
  min-height: 40px;
  border: 1px solid var(--gitlab);
  border-radius: 7px;
  background: var(--gitlab);
  color: #fff;
  padding: 8px 12px;
  font-weight: 850;
}

.unlock-button:hover,
.logout-button:hover {
  background: #e85f1f;
}

.auth-panel.is-loading .unlock-button {
  opacity: 0.72;
  pointer-events: none;
}

.auth-error {
  min-height: 20px;
  margin-bottom: 0;
  color: var(--red);
  font-size: 0.9rem;
  font-weight: 750;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.topbar-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.logout-button {
  min-width: 82px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--gitlab);
  font-size: 0.77rem;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 1.55rem;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 1.45rem;
  line-height: 1.25;
}

h3 {
  font-size: 1rem;
}

.top-stats,
.change-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.stat {
  min-width: 96px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.stat strong {
  display: block;
  margin-top: 2px;
  font-size: 1rem;
}

.stat.positive strong,
.positive {
  color: var(--green);
}

.stat.negative strong,
.negative {
  color: var(--red);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 380px) minmax(0, 1fr);
  height: calc(100vh - 98px);
}

.sidebar {
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface);
}

.controls {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.field input,
.field select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
}

.field input:focus,
.field select:focus,
button:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(91, 91, 214, 0.24);
  outline-offset: 2px;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr 130px;
  gap: 10px;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 650;
}

.toggle-row input {
  width: 17px;
  height: 17px;
  accent-color: var(--accent);
}

.results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.83rem;
  font-weight: 800;
}

.results-head button,
.diff-toolbar button,
.copy-button {
  min-height: 34px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
  padding: 6px 10px;
  font-weight: 750;
}

.results-head button:hover,
.diff-toolbar button:hover,
.copy-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.commit-list {
  display: grid;
  align-content: start;
  gap: 8px;
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.commit-item {
  display: grid;
  gap: 8px;
  width: 100%;
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 12px;
  text-align: left;
}

.commit-item:hover {
  border-color: var(--line-strong);
  box-shadow: 0 8px 24px rgba(31, 35, 40, 0.07);
}

.commit-item.is-selected {
  border-color: var(--accent);
  border-left-color: var(--gitlab);
  background: #fbfbff;
}

.commit-item.is-mine {
  border-left-color: var(--gitlab);
  background: #fffaf7;
}

.commit-item.is-mine.is-selected {
  border-color: var(--gitlab);
  background: #fff4ed;
}

.commit-subject {
  overflow-wrap: anywhere;
  font-weight: 800;
  line-height: 1.3;
}

.commit-meta,
.commit-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  color: var(--muted);
  font-size: 0.8rem;
}

.commit-author.is-current-user,
.detail-author.is-current-user {
  color: var(--gitlab);
  font-size: 1.05rem;
  font-weight: 950;
}

.detail-author.is-current-user {
  display: inline-block;
  border-bottom: 3px solid rgba(252, 109, 38, 0.32);
  font-size: 1.12rem;
}

.commit-foot code {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
}

.mini-stat {
  font-weight: 750;
}

.list-empty,
.empty-state,
.no-diff {
  padding: 30px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: var(--surface);
  color: var(--muted);
}

.list-empty {
  display: grid;
  gap: 6px;
  padding: 18px;
}

.list-empty strong,
.empty-state h2,
.no-diff h3 {
  color: var(--text);
}

.details {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  padding: 22px;
}

.commit-detail {
  display: grid;
  gap: 18px;
  max-width: 1280px;
  margin: 0 auto;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.detail-title {
  min-width: 0;
}

.detail-title h2 {
  overflow-wrap: anywhere;
}

.copy-button {
  flex: 0 0 auto;
  min-width: 92px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.detail-grid div {
  min-width: 0;
  padding: 13px 14px;
  background: var(--surface);
}

.detail-grid dt {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.detail-grid dd {
  margin: 5px 0 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.detail-grid code {
  font-size: 0.82rem;
}

.commit-body {
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 14px;
  color: var(--text);
  white-space: pre-wrap;
}

.change-summary {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.diff-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.diff-toolbar h3 {
  margin-bottom: 0;
}

.diff-toolbar div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.file-list {
  display: grid;
  gap: 14px;
}

.file-block {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.file-block summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-muted);
  cursor: pointer;
  list-style: none;
}

.file-block summary::-webkit-details-marker {
  display: none;
}

.file-block:not([open]) summary {
  border-bottom: 0;
}

.status-badge {
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 3px 8px;
  background: #fff;
  font-size: 0.72rem;
  font-weight: 850;
  text-transform: uppercase;
}

.status-added {
  border-color: rgba(31, 138, 76, 0.32);
  background: var(--green-bg);
  color: var(--green);
}

.status-deleted {
  border-color: rgba(197, 53, 53, 0.3);
  background: var(--red-bg);
  color: var(--red);
}

.status-renamed {
  border-color: rgba(252, 109, 38, 0.38);
  background: #fff0e8;
  color: #a94a1d;
}

.file-path {
  overflow: hidden;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.86rem;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-numbers {
  display: flex;
  gap: 9px;
  font-size: 0.82rem;
  font-weight: 850;
}

.renamed-path {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.82rem;
}

.file-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.file-meta code {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 3px 8px;
  font-size: 0.74rem;
}

.diff-scroll {
  overflow: auto;
}

.diff-table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 0.82rem;
  line-height: 1.45;
}

.diff-table td {
  border-bottom: 1px solid rgba(217, 222, 232, 0.72);
  vertical-align: top;
}

.line-number {
  width: 64px;
  border-right: 1px solid var(--line);
  background: #fbfcfe;
  color: var(--muted);
  padding: 2px 10px;
  text-align: right;
  user-select: none;
}

.code {
  padding: 2px 12px;
  white-space: pre;
}

.marker {
  display: inline-block;
  width: 18px;
  color: var(--muted);
  user-select: none;
}

.line-addition .line-number,
.line-addition .code {
  background: var(--green-bg);
}

.line-deletion .line-number,
.line-deletion .code {
  background: var(--red-bg);
}

.line-meta .code {
  color: var(--muted);
  font-style: italic;
}

.hunk-row td {
  background: var(--accent-soft);
  color: #3d3d92;
  padding: 6px 12px;
  font-weight: 850;
}

.no-hunks {
  margin: 0;
  padding: 14px;
  color: var(--muted);
}

.no-diff {
  background: var(--yellow-bg);
}

@media (max-width: 980px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    align-items: stretch;
    justify-content: flex-start;
  }

  .top-stats {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  }

  .stat {
    min-width: 0;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .commit-list {
    max-height: 42vh;
    max-height: 42svh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .details {
    overflow: visible;
  }

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

@media (max-width: 640px) {
  .auth-screen {
    place-items: start center;
    padding: max(18px, env(safe-area-inset-top)) 14px max(18px, env(safe-area-inset-bottom));
  }

  .auth-panel {
    width: 100%;
    gap: 14px;
    margin-top: 9vh;
    margin-top: 9svh;
    padding: 20px;
  }

  .auth-panel h1 {
    font-size: 1.42rem;
  }

  .unlock-button,
  .logout-button {
    min-height: 44px;
  }

  .topbar,
  .details {
    padding: 14px;
  }

  .topbar {
    gap: 14px;
  }

  h1 {
    font-size: 1.35rem;
  }

  h2 {
    font-size: 1.24rem;
  }

  .topbar-actions {
    gap: 10px;
  }

  .top-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .stat {
    padding: 8px 10px;
  }

  .stat strong {
    font-size: 0.94rem;
  }

  .logout-button {
    width: 100%;
  }

  .controls {
    gap: 10px;
    padding: 12px;
  }

  .field input,
  .field select {
    min-height: 44px;
  }

  .filter-grid,
  .detail-grid {
    grid-template-columns: 1fr;
  }

  .toggle-row {
    align-items: flex-start;
  }

  .toggle-row input {
    flex: 0 0 auto;
    margin-top: 2px;
  }

  .results-head {
    padding: 10px 12px;
  }

  .commit-list {
    max-height: 46vh;
    max-height: 46svh;
    min-height: 230px;
    padding: 10px;
  }

  .commit-item {
    gap: 7px;
    padding: 11px;
  }

  .commit-meta,
  .commit-foot {
    gap: 6px 10px;
  }

  .detail-header,
  .diff-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .detail-header {
    gap: 14px;
    padding: 14px;
  }

  .copy-button {
    width: 100%;
  }

  .file-block summary {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px;
  }

  .status-badge {
    justify-self: start;
  }

  .file-path {
    grid-column: 1 / -1;
    order: 2;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .file-numbers {
    justify-self: end;
  }

  .file-meta {
    padding: 8px 10px;
  }

  .file-meta code {
    max-width: 100%;
    border-radius: 8px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  .diff-table {
    min-width: 640px;
    font-size: 0.78rem;
  }

  .line-number {
    width: 48px;
    padding: 2px 6px;
  }

  .code {
    padding: 2px 8px;
  }
}
