:root {
  --bg: #f2f2ed;
  --panel: rgba(252, 252, 248, 0.88);
  --ink: #11110f;
  --muted: #5c5c57;
  --line: #11110f;
  --sector: #e9e9e1;
  --green: #2f8f5b;
  --red: #b64237;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.65), rgba(242, 242, 237, 0.97)),
    repeating-linear-gradient(
      90deg,
      rgba(0, 0, 0, 0.012) 0,
      rgba(0, 0, 0, 0.012) 1px,
      transparent 1px,
      transparent 28px
    ),
    var(--bg);
  color: var(--ink);
}

a {
  color: inherit;
}

.header-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: start;
}

.header-main,
.header-side {
  display: flex;
  flex-direction: column;
}

.header-main {
  gap: 6px;
}

.header-side {
  align-items: flex-end;
  gap: 6px;
  text-align: right;
}

.source-link {
  font-size: 13px;
  color: var(--muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.source-link:hover {
  color: var(--ink);
}

.shell {
  min-height: 100vh;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
}

.header {
  padding: 16px;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: baseline;
}

.title {
  margin: 0;
  font-size: clamp(30px, 4vw, 52px);
  line-height: 0.92;
  letter-spacing: -0.045em;
}

.subtitle,
.meta,
.legend {
  font-size: 13px;
  color: var(--muted);
}

.toolbar {
  padding: 14px 16px;
  align-items: center;
  flex-wrap: wrap;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
}

.stat {
  min-width: 88px;
}

.stat-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stat-value {
  font-size: 21px;
  font-weight: 700;
}

.window-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.control-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.control-label {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.control-input {
  width: 56px;
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 7px 8px;
  font: inherit;
  border-radius: 0;
}

.control-input:focus {
  outline: none;
}

.scale-legend {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  min-height: 34px;
}

.scale-legend-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(42px, 56px));
  border: 1px solid var(--ink);
}

.scale-legend-step {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 34px;
  padding: 4px 5px;
  font-size: 9px;
  line-height: 1.05;
  text-align: center;
  border-right: 1px solid rgba(17, 17, 15, 0.35);
}

.scale-legend-step:last-child {
  border-right: 0;
}

.scale-legend-step.dark {
  color: #fbfbf8;
}

button {
  border: 1px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 8px 10px;
  font: inherit;
  border-radius: 0;
  cursor: pointer;
}

button.active {
  background: var(--ink);
  color: #fbfbf8;
}

.board {
  position: relative;
  min-height: clamp(560px, 76vh, 1100px);
  overflow: hidden;
}

.status {
  padding: 22px;
  color: var(--muted);
}

.tooltip {
  position: fixed;
  z-index: 20;
  pointer-events: none;
  min-width: 220px;
  max-width: 320px;
  padding: 10px 12px;
  border: 1px solid var(--ink);
  background: rgba(252, 252, 248, 0.98);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
  font-size: 12px;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 100ms ease, transform 100ms ease;
}

.tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.sector {
  position: absolute;
  overflow: hidden;
  background: var(--sector);
  border: 2px solid var(--ink);
}

.sector-label {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  padding: 3px 5px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--ink);
  background: rgba(233, 233, 225, 0.95);
  z-index: 2;
}

.repo {
  position: absolute;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 3px;
  border: 1px solid rgba(17, 17, 15, 0.2);
  text-decoration: none;
}

.repo-name {
  font-size: 10px;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
  word-break: break-word;
}

.repo-full,
.repo-desc,
.repo-meta {
  font-size: 10px;
  line-height: 1.15;
}

.repo-full,
.repo-desc {
  margin-top: 3px;
  opacity: 0.88;
}

.repo-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.repo.compact {
  padding: 2px;
}

.repo.compact .repo-name {
  font-size: 8px;
}

.repo.compact .repo-full,
.repo.compact .repo-desc,
.repo.compact .repo-meta {
  display: none;
}

@media (max-width: 900px) {
  .shell {
    padding: 12px;
  }

  .header-grid,
  .toolbar {
    display: block;
  }

  .header-side,
  .window-bar,
  .control-bar,
  .scale-legend {
    margin-top: 8px;
  }

  .header-side {
    align-items: flex-start;
    text-align: left;
  }

  .stats {
    margin-bottom: 10px;
  }

  .scale-legend {
    margin-left: 0;
    align-items: flex-start;
    flex-direction: column;
  }

  .scale-legend-bar {
    width: 100%;
    grid-template-columns: repeat(5, 1fr);
  }

  .title {
    font-size: 28px;
  }

  .toolbar {
    padding: 12px;
  }

  .stats {
    gap: 14px;
  }

  .stat {
    min-width: 0;
  }

  button {
    padding: 7px 9px;
  }

  .board {
    min-height: 62vh;
  }

  .sector-label {
    padding: 4px;
    font-size: 11px;
  }
}
