:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #16202a;
  --muted: #647184;
  --line: #d9e0e8;
  --accent: #0f766e;
  --accent-dark: #115e59;
  --danger: #b42318;
  --warn: #a15c07;
  --good: #137333;
  --shadow: 0 8px 24px rgba(19, 31, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  background: var(--accent);
  color: white;
  cursor: pointer;
}

button:hover {
  background: var(--accent-dark);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

button:disabled:hover {
  background: var(--accent);
}

button.secondary:disabled:hover {
  background: #e7edf3;
}

button.secondary {
  background: #e7edf3;
  color: var(--text);
}

button.danger {
  background: var(--danger);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 10px;
  background: white;
  color: var(--text);
}

textarea {
  min-height: 86px;
  resize: vertical;
}

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

.topbar h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.1;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

.topbar-actions {
  display: grid;
  grid-template-columns: auto minmax(360px, 1fr);
  gap: 12px;
  align-items: end;
}

.language-switch {
  display: grid;
  gap: 6px;
  min-width: 92px;
  color: var(--muted);
  font-size: 13px;
}

.add-form {
  display: grid;
  grid-template-columns: minmax(260px, 420px) auto;
  gap: 8px;
  align-items: center;
}

.layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) minmax(360px, 420px);
  gap: 18px;
  padding: 18px;
  min-width: 0;
}

.panel,
.repo-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
}

.controls {
  grid-column: 1;
  grid-row: 1 / span 2;
  position: sticky;
  top: 18px;
  align-self: start;
  padding: 16px;
}

.controls label {
  display: grid;
  gap: 6px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 13px;
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: #f8fafc;
}

.stat strong {
  display: block;
  font-size: 20px;
}

.stat span {
  color: var(--muted);
  font-size: 12px;
}

.repo-list,
.pagination {
  grid-column: 2;
  display: grid;
  gap: 12px;
  align-content: start;
  min-width: 0;
}

.pagination {
  grid-column: 2;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
}

.pagination span {
  text-align: center;
}

.repo-card {
  padding: 16px;
  cursor: pointer;
}

.repo-card:hover,
.repo-card.active {
  border-color: var(--accent);
}

.repo-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

.repo-head > div:first-child {
  min-width: 0;
}

.repo-title {
  font-weight: 750;
  font-size: 17px;
  overflow-wrap: anywhere;
}

.repo-title a {
  color: var(--text);
  text-decoration: none;
}

.repo-desc {
  margin: 8px 0 12px;
  color: var(--muted);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.score {
  min-width: 68px;
  text-align: right;
  font-weight: 800;
  color: var(--accent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.chip {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  border-radius: 999px;
  padding: 3px 8px;
  background: #edf2f7;
  color: #344054;
  font-size: 12px;
  overflow-wrap: anywhere;
}

.chip.good {
  background: #e7f6ec;
  color: var(--good);
}

.chip.warn {
  background: #fff3df;
  color: var(--warn);
}

.detail {
  grid-column: 3;
  grid-row: 1 / span 2;
  position: sticky;
  top: 18px;
  align-self: start;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 18px;
  min-width: 0;
}

.detail h2 {
  margin: 0;
  font-size: 20px;
  overflow-wrap: anywhere;
}

.detail .url {
  display: block;
  margin-top: 6px;
  color: var(--accent);
  word-break: break-all;
}

.summary-block {
  margin: 14px 0 16px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.summary-block h3 {
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 700;
}

.summary-block p {
  margin: 0;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 16px 0;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.metric strong {
  font-size: 18px;
  overflow-wrap: anywhere;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.note-form {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}

.empty,
.loading {
  color: var(--muted);
  padding: 18px;
  text-align: center;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: 420px;
  padding: 12px 14px;
  border-radius: 8px;
  background: #16202a;
  color: white;
  box-shadow: var(--shadow);
}

@media (max-width: 1280px) {
  .layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .controls {
    grid-column: 1;
    grid-row: 1;
  }

  .repo-list,
  .pagination {
    grid-column: 2;
  }

  .detail {
    grid-column: 1 / -1;
    grid-row: auto;
    position: static;
    max-height: none;
  }
}

@media (max-width: 920px) {
  .layout {
    grid-template-columns: 230px minmax(0, 1fr);
  }
}

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

  .add-form,
  .topbar-actions,
  .layout {
    grid-template-columns: 1fr;
  }

  .controls {
    grid-column: 1;
    grid-row: auto;
    position: static;
  }

  .repo-list,
  .pagination,
  .detail {
    grid-column: 1;
  }
}
