:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text",
    Inter, ui-sans-serif, system-ui, "Segoe UI", sans-serif;
  background: #ffffff;
  color: #1d1d1f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: #ffffff;
}

.app {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

.page-content {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

@supports (height: 100svh) {
  .page-content { min-height: 100svh; }
}

.hidden { display: none !important; }

/* --- Top bar --- */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  margin-left: calc(-50vw + 50%);
  margin-right: calc(-50vw + 50%);
  padding-left: calc(50vw - 50%);
  padding-right: calc(50vw - 50%);
  border-bottom: 1px solid #e5e5ea;
}

.eyebrow {
  margin: 0;
  color: #1d1d1f;
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  padding-top: 6px;
}

.toolbar { display: flex; gap: 6px; }
.tool { position: relative; }

.tool-btn {
  border: 1px solid #e5e5ea;
  background: #ffffff;
  color: #6e6e73;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 550;
  font-size: 0.84rem;
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.tool-btn:hover { background: #f5f5f7; color: #1d1d1f; }
.tool-btn.active { background: #1d1d1f; color: #ffffff; border-color: #1d1d1f; }

.tool-count { color: #a1a1a6; font-weight: 500; }
.tool-btn.active .tool-count { color: rgba(255,255,255,.65); }

.panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 320px;
  max-width: calc(100vw - 32px);
  background: #ffffff;
  border: 1px solid #e5e5ea;
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.05);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.panel[hidden] { display: none; }
.panel-narrow { width: 220px; }

label { font-weight: 600; font-size: 0.86rem; color: #1d1d1f; }

input[type="text"], select {
  border: 1px solid #e5e5ea;
  border-radius: 10px;
  padding: 8px 10px;
  color: #1d1d1f;
  background: #fafafa;
  outline: none;
  font-size: 0.86rem;
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
input[type="text"]:focus, select:focus {
  border-color: #1d1d1f;
  box-shadow: 0 0 0 3px rgba(29,29,31,0.06);
}

textarea {
  min-height: 90px;
  resize: vertical;
  border: 1px solid #e5e5ea;
  border-radius: 12px;
  padding: 12px;
  color: #1d1d1f;
  background: #fafafa;
  outline: none;
  font-size: 0.9rem;
  line-height: 1.5;
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
textarea:focus { border-color: #1d1d1f; box-shadow: 0 0 0 3px rgba(29,29,31,0.06); }

.button-row { display: flex; flex-wrap: wrap; gap: 6px; }
.button-row button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 7px 13px;
  cursor: pointer;
  color: #ffffff;
  background: #1d1d1f;
  font-weight: 550;
  font-size: 0.8rem;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}
.button-row button:hover:not(:disabled) { background: #000; }
.secondary { background: #ffffff !important; color: #1d1d1f !important; border-color: #d2d2d7 !important; }
.secondary:hover:not(:disabled) { background: #f5f5f7 !important; }
.secondary.small { padding: 6px 10px; font-size: 0.78rem; }
.ghost { background: transparent !important; color: #6e6e73 !important; border: 1px solid #d2d2d7; border-radius: 999px; padding: 7px 13px; cursor: pointer; font-weight: 550; font-size: 0.8rem; transition: background .15s ease, color .15s ease; }
.ghost:hover:not(:disabled) { background: #f5f5f7 !important; color: #1d1d1f !important; }
.ghost.small { padding: 5px 10px; font-size: 0.76rem; }
.ghost.danger { color: #ff3b30 !important; border-color: #ffd6d3 !important; }
.ghost.danger:hover { background: #fff3f2 !important; }

button { font: inherit; }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.panel-label {
  margin: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #86868b;
  font-weight: 600;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; }

.add-row { display: flex; flex-direction: column; gap: 6px; }

.people-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 220px;
  overflow-y: auto;
}
.people-list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  background: #f5f5f7;
  border: 1px solid #ececee;
  padding: 8px 10px;
  border-radius: 9px;
}
.p-info { min-width: 0; }
.p-name {
  font-size: 0.84rem;
  font-weight: 600;
  color: #1d1d1f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.p-meta {
  margin-top: 1px;
  font-size: 0.72rem;
  color: #a1a1a6;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.people-list .p-remove {
  background: none;
  border: none;
  color: #c7c7cc;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0 2px;
  flex-shrink: 0;
}
.people-list .p-remove:hover { color: #ff3b30; }
.people-empty { color: #a1a1a6; font-size: 0.82rem; }

/* --- Matrix workspace --- */
.workspace {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  padding: 10px 0;
}

.board-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 32px;
  width: 100%;
  flex-wrap: wrap;
}

.matrix-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.matrix-wrap {
  display: grid;
  grid-template-columns: 30px 22px 1fr;
  grid-template-rows: 20px 1fr 20px 30px;
  width: min(100%, calc(100vh - 260px), 820px);
}
@supports (height: 100svh) {
  .matrix-wrap { width: min(100%, calc(100svh - 260px), 820px); }
}

.legend {
  width: 320px;
  flex-shrink: 0;
  align-self: flex-start;
  margin-top: 20px;
  background: #ffffff;
  border: 1px solid #e5e5ea;
  border-radius: 16px;
  box-shadow: 0 6px 20px rgba(0,0,0,.04);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: min(100%, calc(100vh - 280px), 640px);
}

.legend-title {
  margin: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #86868b;
  font-weight: 600;
}

.legend-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.legend-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background .15s ease;
}
.legend-item:hover { background: #f5f5f7; }
.legend-item.selected { background: #f0f0f2; }

.legend-swatch {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 5px;
}

.legend-main { flex: 1; min-width: 0; }

.legend-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.legend-name {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 600;
  color: #1d1d1f;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-avg {
  flex-shrink: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: #1d1d1f;
  font-variant-numeric: tabular-nums;
}

.legend-sub {
  margin-top: 2px;
  font-size: 0.72rem;
  color: #86868b;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

.legend-empty { color: #a1a1a6; font-size: 0.8rem; padding: 6px 8px; }

.axis-label {
  color: #a1a1a6;
  font-size: 0.78rem;
  font-weight: 550;
  display: flex;
  align-items: center;
  justify-content: center;
}
.axis-y {
  grid-column: 1;
  grid-row: 2;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
}
.axis-x { grid-column: 3; grid-row: 4; }

.tick-col {
  grid-column: 2;
  grid-row: 2;
  position: relative;
}
.tick-row {
  grid-column: 3;
  grid-row: 3;
  position: relative;
}
.tick-label {
  position: absolute;
  color: #b0b0b6;
  font-size: 0.68rem;
  font-weight: 500;
  white-space: nowrap;
}
.tick-col .tick-label { right: 6px; }
.tick-row .tick-label { top: 2px; }

.matrix-frame {
  grid-column: 3;
  grid-row: 2;
  position: relative;
  aspect-ratio: 1 / 1;
  background: #fafafa;
  border: 1px solid #e5e5ea;
  border-radius: 16px;
  /* Dots always stay inside (PAD in app.js guarantees it), but a crowded
     dot's label is allowed to spill past the edge rather than get clipped
     or forced to dodge sideways — see renderProblems() in app.js. */
  overflow: visible;
}

.gridline { position: absolute; background: #a8a8ae; }
.gridline-h { top: 50%; left: 0; right: 0; height: 1.5px; }
.gridline-v { left: 50%; top: 0; bottom: 0; width: 1.5px; }

.gridline-quarter-h {
  left: 0; right: 0; height: 0;
  background: none;
  border-top: 1px dotted #dcdce0;
}
.gridline-quarter-v {
  top: 0; bottom: 0; width: 0;
  background: none;
  border-left: 1px dotted #dcdce0;
}

.dot-tooltip {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -100%);
  background: #1d1d1f;
  color: #ffffff;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 0.72rem;
  font-weight: 550;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
  z-index: 5;
}

.quadrant-label {
  grid-column: 3;
  grid-row: 1;
  font-size: 0.78rem;
  font-weight: 700;
  color: #a8342a;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  padding-bottom: 2px;
}

.matrix-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  /* SVG roots clip to their own box by default regardless of the parent's
     overflow — must be explicit here too, or labels near the edge still
     get cut off despite .matrix-frame allowing overflow. */
  overflow: visible;
}

.matrix-svg.labels-hidden text { display: none; }

.problem-dot { cursor: grab; }
.problem-dot:active { cursor: grabbing; }
.problem-dot.locked { cursor: default; }
.problem-dot.locked:active { cursor: default; }
.problem-dot circle {
  stroke: #ffffff;
  stroke-width: 2;
  transition: stroke .15s ease, stroke-width .15s ease, filter .15s ease, opacity .15s ease;
}
.problem-dot.selected circle { stroke: #1d1d1f; stroke-width: 3; }
/* Unlocked = position is a manual drag guess, not backed by any interviewee's
   score. Muted until real per-mention data drives the axis (see .locked). */
.problem-dot:not(.locked) circle { filter: saturate(0.45) brightness(1.06); opacity: 0.8; }
.problem-dot text {
  font-size: 11px;
  font-weight: 600;
  fill: #1d1d1f;
  pointer-events: none;
  paint-order: stroke;
  stroke: #fafafa;
  stroke-width: 3px;
}

.add-problem-button {
  border: 0;
  border-radius: 999px;
  padding: 10px 22px;
  background: #1d1d1f;
  color: #f5f5f7;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, transform .12s ease;
}
.add-problem-button:hover { background: #000; }
.add-problem-button:active { transform: scale(0.97); }

/* --- Detail side panel --- */
.detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 340px;
  max-width: calc(100vw - 32px);
  background: #ffffff;
  border-left: 1px solid #e5e5ea;
  box-shadow: -12px 0 32px rgba(0,0,0,.08);
  padding: 22px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  z-index: 30;
}

.detail-close {
  align-self: flex-end;
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: #a1a1a6;
  cursor: pointer;
  padding: 0;
}
.detail-close:hover { color: #1d1d1f; }

.detail-name {
  font-size: 1.05rem;
  font-weight: 650;
  border: none;
  background: transparent;
  padding: 0;
  outline: none;
}
.detail-name:focus { box-shadow: none; border-bottom: 1px solid #1d1d1f; }

.detail-scores { display: flex; flex-direction: column; gap: 10px; }
.detail-scores label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: #6e6e73;
  font-weight: 550;
}
.detail-scores span { color: #1d1d1f; font-weight: 650; }
.detail-scores input[type="range"] { width: 100%; accent-color: #1d1d1f; }
.detail-scores input[type="range"].computed { accent-color: #0071e3; }
.detail-scores input[type="range"]:disabled { opacity: 0.75; }
.detail-scores span.computed { color: #0071e3; }

.detail-colors {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 7px;
}
.color-swatch {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
}
.color-swatch.active {
  border-color: #ffffff;
  box-shadow: 0 0 0 2px #1d1d1f;
}

.detail-label { font-size: 0.8rem; }
.detail-notes { min-height: 80px; font-size: 0.86rem; }

.mentions-head { margin-top: 4px; }
.add-mention-row { display: flex; gap: 6px; }
.add-mention-row select { flex: 1; }

.mentions-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 160px;
  overflow-y: auto;
}
.mentions-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: #f5f5f7;
  border: 1px solid #ececee;
  padding: 7px 10px;
  border-radius: 9px;
  font-size: 0.8rem;
  color: #3a3a3c;
}
.m-name-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.mentions-list .m-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 600;
}
.m-company {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.7rem;
  color: #a1a1a6;
  font-weight: 500;
}
.mentions-list .m-scores { display: flex; gap: 6px; flex-shrink: 0; }
.m-score-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
}
.m-score-cap {
  font-size: 0.6rem;
  font-weight: 700;
  color: #a1a1a6;
  letter-spacing: 0.02em;
}
.m-score-input {
  width: 40px;
  padding: 3px 2px;
  font-size: 0.72rem;
  text-align: center;
  border: 1px solid #d2d2d7;
  border-radius: 6px;
  background: #ffffff;
  color: #0071e3;
  font-weight: 600;
}
.m-score-input::placeholder { color: #c7c7cc; font-weight: 500; }
.mentions-list .m-remove {
  background: none;
  border: none;
  color: #c7c7cc;
  cursor: pointer;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.mentions-list .m-remove:hover { color: #ff3b30; }

.site-footer {
  padding: 12px 0;
  border-top: 1px solid #f5f5f5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.footer-left { color: #a3a3a3; font-size: 0.75rem; font-weight: 400; }
.footer-links { display: flex; align-items: center; gap: 6px; }
.footer-links a {
  color: #a3a3a3;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  transition: color .15s ease;
}
.footer-links a:hover { color: #525252; }
.footer-icon { width: 12px; height: 12px; display: block; }

@media (max-width: 600px) {
  .app { padding: 16px 0 28px; }
  .toolbar { gap: 4px; }
  .tool-btn { padding: 6px 11px; font-size: 0.78rem; }
  .panel {
    position: fixed;
    top: 68px;
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
  }
  .detail-panel { width: 100%; max-width: none; }
  .legend { display: none; }
}
