:root {
  --bg: #ffffff;
  --ink: #111111;
  --muted: #6b6b6b;
  --panel: #d9d9d6;
  --card: #ffffff;
  --pants: #d9d9d9;
  --match: #1f9d3a;
  --miss: #d33b2c;
  --accent: #111111;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, system-ui, -apple-system, sans-serif;
}

.layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) minmax(340px, 440px);
  gap: 32px;
  padding: 40px;
  max-width: 1600px;
  margin: 0 auto;
  align-items: start;
}

/* ---------- logo ---------- */
/* Spans the full sidebar so it lines up with the search panel below it. */
.logo {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  width: 100%;
  container-type: inline-size;
  border: 2px solid var(--ink);
  color: var(--ink);
  text-decoration: none;
  margin-bottom: 40px;
}
.logo span {
  aspect-ratio: 1 / 0.9;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 8cqi; /* scales with the logo's width */
  border-right: 2px solid var(--ink);
  border-bottom: 2px solid var(--ink);
}
.logo span:nth-child(5n) { border-right: 0; }
.logo span:nth-child(n + 6) { border-bottom: 0; }

/* ---------- search panel ---------- */
.panel {
  background: var(--panel);
  border-radius: var(--radius);
}
.search-form { padding: 14px 14px 12px; }

.field {
  display: grid;
  grid-template-columns: 1fr 76px 22px;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 8px;
  font-style: italic;
  font-weight: 500;
  font-size: 15px;
  cursor: default;
}
.field.hot { background: rgba(255, 255, 255, 0.45); }
.field input[type="number"] {
  width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 3px 8px;
  font: inherit;
  font-style: normal;
  font-size: 14px;
  text-align: center;
  background: var(--card);
  color: var(--ink);
  -moz-appearance: textfield;
}
.field input[type="number"]::placeholder { color: #c4c4c4; font-style: italic; }
.field input[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
.field input[type="number"]:focus { outline: 2px solid var(--ink); }

.field input[type="checkbox"] {
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--card);
  margin: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.field input[type="checkbox"]::after {
  content: "";
  width: 8px;
  height: 4px;
  border-left: 1.6px solid var(--muted);
  border-bottom: 1.6px solid var(--muted);
  transform: translateY(-1px) rotate(-45deg);
  opacity: 0.35;
}
.field input[type="checkbox"]:checked { background: var(--ink); }
.field input[type="checkbox"]:checked::after { border-color: #fff; opacity: 1; }
.field input[type="checkbox"]:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin: 10px 6px 4px;
  font-size: 13px;
}
.option { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
.option select {
  border: 0;
  border-radius: 999px;
  padding: 3px 8px;
  font: inherit;
  background: var(--card);
}
.unit-toggle, .gender-toggle { display: inline-flex; background: var(--card); border-radius: 999px; padding: 2px; }
.unit-toggle button, .gender-toggle button {
  border: 0;
  background: transparent;
  font: inherit;
  padding: 2px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.unit-toggle button.active, .gender-toggle button.active { background: var(--ink); color: #fff; }

/* Full-width All / Men / Women switch at the top of the search panel */
.gender-toggle { display: flex; margin: 0 0 10px; }
.gender-toggle button { flex: 1; padding: 5px 0; font-size: 14px; font-weight: 600; }
.gender-toggle button:focus-visible, .unit-toggle button:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }

.search-btn, .reset-btn {
  display: block;
  width: 100%;
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-style: italic;
  font-weight: 500;
  cursor: pointer;
}
.search-btn {
  margin-top: 10px;
  padding: 5px;
  font-size: 16px;
  background: var(--card);
}
.search-btn:hover { background: var(--ink); color: #fff; }
.reset-btn {
  margin-top: 6px;
  background: transparent;
  font-size: 12px;
  color: var(--muted);
}
.hint { font-size: 12px; color: var(--muted); line-height: 1.5; margin: 14px 4px; }

/* ---------- diagram ---------- */
.diagram-wrap { padding-top: 40px; }
#diagram { width: 100%; max-height: calc(100vh - 80px); display: block; }
#diagram .body { fill: var(--pants); }
#diagram .dim { cursor: pointer; }
#diagram .dim line { stroke: var(--ink); stroke-width: 2.5; }
#diagram .dim .dash { stroke-dasharray: 10 6 2 6; }
#diagram .dim .pill { fill: var(--bg); stroke: var(--ink); stroke-width: 2.5; stroke-dasharray: 6 4; }
#diagram .dim.filled .pill { stroke-dasharray: none; }
#diagram .dim.hot .pill { fill: var(--ink); stroke-dasharray: none; }
#diagram .dim.hot line { stroke-width: 4; }
#diagram .dim.off { opacity: 0.3; }

/* Entry boxes inside the diagram's circles (sized in SVG units, so they scale with it) */
#diagram foreignObject input {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: normal 600 28px Inter, system-ui, sans-serif;
  text-align: center;
  cursor: pointer;
  -moz-appearance: textfield;
}
#diagram foreignObject input::-webkit-inner-spin-button,
#diagram foreignObject input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
#diagram foreignObject input::placeholder {
  color: var(--ink);
  opacity: 1;
  font-style: italic;
  font-weight: 500;
  font-size: 34px;
}
#diagram foreignObject input:focus { outline: none; cursor: text; }
#diagram .dim.hot foreignObject input,
#diagram .dim.hot foreignObject input::placeholder { color: #fff; }

/* ---------- results ---------- */
.results { padding: 18px; max-height: calc(100vh - 80px); overflow-y: auto; position: sticky; top: 40px; }
.results-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 4px 14px;
  font-size: 13px;
  font-weight: 600;
}
#results { list-style: none; margin: 0; padding: 0; display: grid; gap: 22px; }

.card { display: grid; grid-template-columns: 120px 30px 1fr; gap: 12px; align-items: start; }
.thumb {
  aspect-ratio: 1;
  background: var(--card);
  border-radius: 12px;
  display: grid;
  place-items: center;
}
.thumb svg { width: 72%; height: 72%; }
.thumb img { width: 100%; height: 100%; object-fit: contain; border-radius: 12px; }

.marks { list-style: none; padding: 4px 0 0; margin: 0; display: grid; gap: 2px; }
.marks li {
  font-weight: 800;
  font-size: 15px;
  line-height: 19px;
  text-align: center;
  position: relative;
}
.marks .ok { color: var(--match); }
.marks .bad { color: var(--miss); }
.marks .na { color: #b5b5b2; }
.marks .unknown { color: #8f8f8b; }

.info h3 { margin: 4px 0 6px; font-size: 17px; font-weight: 600; }
.info h3 a { color: inherit; text-decoration: none; }
.info h3 a:hover { text-decoration: underline; }
.info .brand { font-style: italic; font-size: 15px; margin: 0 0 4px; }
.info .size { font-style: normal; font-size: 12px; color: var(--muted); }
.info .meas { font-size: 12px; color: var(--muted); margin: 0 0 8px; font-variant-numeric: tabular-nums; }
.info .meas b { color: var(--ink); font-weight: 600; }
.info .meas .bad { color: var(--miss); }
.info .meas .ok { color: var(--match); }
.swatches { display: flex; flex-wrap: wrap; gap: 6px; }
.swatches span {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--card);
}
.price { font-size: 13px; font-weight: 600; margin-left: auto; align-self: center; white-space: nowrap; }
.info-row { display: flex; align-items: center; gap: 6px; }

.empty { text-align: center; color: var(--muted); font-style: italic; padding: 40px 0; }

/* ---------- responsive ---------- */
@media (max-width: 1200px) {
  .layout { grid-template-columns: 280px minmax(0, 1fr); }
  .results { grid-column: 1 / -1; position: static; max-height: none; }
  #results { grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
}
@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; padding: 20px 16px; gap: 20px; }
  .sidebar { display: grid; justify-items: start; }
  .search-form { width: 100%; }
  .logo { margin-bottom: 8px; }
  .diagram-wrap { padding-top: 0; }
  #diagram { max-height: 60vh; }
  #results { grid-template-columns: 1fr; }
  .card { grid-template-columns: 96px 24px 1fr; }
}
