@font-face {
  font-family: Bricolage;
  src: url("./fonts/BricolageGrotesque.woff2") format("woff2");
  font-weight: 400 800;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("./fonts/JetBrainsMono-Regular.woff2") format("woff2");
  font-display: swap;
}

:root {
  color-scheme: dark;
  --page: #151617;
  --surface: #1d1f20;
  --surface-hover: #242728;
  --line: #363839;
  --text: #faf9f6;
  --muted: #afb2b5;
  --mark: #8e9699;
  --mint: #a6ebcf;
  --mint-ink: #122921;
  --above: #ffa996;
  --below: var(--mint);
  --gutter: clamp(18px, 5.35vw, 40px);
  --header-height: 68px;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --chart-label: clamp(58px, 16vw, 132px);
  --chart-gap: clamp(10px, 4.2vw, 24px);
  font-family: Bricolage, "Trebuchet MS", sans-serif;
  background: var(--page);
  color: var(--text);
}

:root[data-theme="light"] {
  color-scheme: light;
  --page: #f8f7f3;
  --surface: #fffefb;
  --surface-hover: #eeeee9;
  --line: #d0d2cd;
  --text: #1d2622;
  --muted: #525f59;
  --mark: #687770;
  --mint: #a6ebcf;
  --above: #a13e31;
  --below: #176b52;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden], .icon-library { display: none !important; }
body { margin: 0; }
h1, h2, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

button:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--below);
  outline-offset: 3px;
}

svg { width: 1.25rem; height: 1.25rem; flex: none; }

.shell {
  width: min(calc(100% - 2 * var(--gutter)), 780px);
  margin-inline: auto;
}

.header { border-bottom: 1px solid var(--line); }

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: calc(var(--header-height) - 1px);
}

.brand {
  display: flex;
  gap: 10px;
  align-items: center;
  font-size: clamp(25px, 6.4vw, 34px);
  font-weight: 800;
  letter-spacing: -.065em;
  line-height: 1;
}

.brand img {
  width: clamp(28px, 7vw, 37px);
  height: auto;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 11px;
}

.icon-button:hover, .reference:hover { background: var(--surface-hover); }

.main {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - var(--header-height));
  min-height: calc(100dvh - var(--header-height));
  padding-top: clamp(16px, 4.35vw, 42px);
}

.comparison-heading {
  display: flex;
  gap: 17px;
  align-items: center;
  margin-bottom: clamp(11px, 3.1vw, 26px);
  color: var(--muted);
  font-size: clamp(14px, 3.55vw, 18px);
  font-weight: 650;
}

.comparison-button {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: clamp(22px, 5.7vw, 30px);
  font-weight: 800;
  letter-spacing: -.045em;
  text-align: left;
}

.comparison-button span { overflow-wrap: anywhere; }
.comparison-button svg { transform: rotate(90deg); color: var(--muted); }

.reference {
  display: flex;
  align-items: center;
  gap: clamp(6px, 2.3vw, 12px);
  width: 100%;
  min-height: clamp(64px, 16.6vw, 82px);
  padding: 10px clamp(8px, 2.9vw, 16px);
  border: 1px solid var(--line);
  border-radius: clamp(11px, 2.8vw, 16px);
  background: var(--surface);
  text-align: left;
}

.reference-icon {
  display: grid;
  flex: none;
  place-items: center;
  width: clamp(27px, 7.2vw, 36px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: color-mix(in srgb, var(--text) 7%, transparent);
}

.reference-copy { flex: 1; min-width: 0; overflow-wrap: anywhere; line-height: 1.22; }

.reference-copy span {
  display: block;
  color: var(--muted);
  font-size: clamp(12px, 2.9vw, 15px);
  font-weight: 700;
}

.reference-copy strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(15px, 3.75vw, 20px);
  font-weight: 780;
}

.reference-chevron { width: 14px; color: var(--muted); }
.reference .unit-price { flex: 0 1 auto; }

.unit-price {
  font-family: var(--mono);
  font-size: clamp(14px, 3.9vw, 20px);
  font-variant-numeric: tabular-nums;
  letter-spacing: -.07em;
  text-align: right;
  overflow-wrap: anywhere;
}

.price-unit {
  color: var(--muted);
  font-size: .75em;
  letter-spacing: -.055em;
}

.results { margin-top: clamp(23px, 7.2vw, 42px); }

.results-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.results-heading h2 {
  font-size: clamp(17px, 5.1vw, 28px);
  font-weight: 800;
  letter-spacing: -.047em;
  line-height: 1.08;
}

.sort-button {
  display: flex;
  align-items: center;
  justify-content: end;
  gap: 3px;
  max-width: 32%;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: clamp(11px, 3.1vw, 16px);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.sort-button svg { width: 14px; color: var(--text); }
.sort-button[data-descending="true"] svg { transform: rotate(180deg); }

.axis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: calc(100% - var(--chart-label) - var(--chart-gap));
  padding: clamp(8px, 1.4vw, 11px) 0 10px;
  color: var(--muted);
  font: clamp(9px, 2.56vw, 13px)/1.3 var(--mono);
  overflow-wrap: anywhere;
}

.axis span:nth-child(2) { color: var(--text); text-align: center; }
.axis span:last-child { text-align: right; }

.products, .dialog-options {
  margin: 0;
  padding: 0;
  list-style: none;
}

.products { border-top: 1px solid var(--line); }
.products li { border-bottom: 1px solid var(--line); }

.product {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, var(--chart-label));
  column-gap: var(--chart-gap);
  align-items: baseline;
  width: 100%;
  min-height: clamp(94px, 24.9vw, 112px);
  padding: clamp(13px, 3.7vw, 18px) 0 12px;
  border: 0;
  background: transparent;
  text-align: left;
}

.product:hover .product-name { text-decoration: underline; text-underline-offset: .2em; }
.product-heading { min-width: 0; }
.product-name {
  font-size: clamp(16px, 4.35vw, 23px);
  font-weight: 800;
  letter-spacing: -.04em;
  overflow-wrap: anywhere;
}

.reference-label {
  display: inline-block;
  margin-inline-start: 4px;
  color: var(--muted);
  font-size: clamp(11px, 2.9vw, 14px);
  font-weight: 700;
  white-space: nowrap;
}

.reference-label::before { content: "•"; color: var(--mark); margin-inline-end: 4px; }
.product .unit-price { width: max-content; max-width: calc(var(--chart-label) + var(--chart-gap)); justify-self: end; }

.product-details {
  grid-column: 1 / -1;
  margin-top: 3px;
  color: var(--muted);
  font-size: clamp(12px, 3.2vw, 16px);
  font-weight: 650;
}

.track {
  position: relative;
  grid-column: 1;
  align-self: center;
  height: 2px;
  margin-top: 7px;
  background: var(--line);
}

.track::before {
  content: "";
  position: absolute;
  left: 50%;
  inset-block: -7px;
  border-left: 1px solid var(--mark);
}

.mark {
  position: absolute;
  top: 50%;
  width: var(--deviation);
  height: 6px;
  border-radius: 2px;
  background: var(--text);
  transform: translateY(-50%);
}

.track[data-direction="below"] .mark { right: 50%; background: var(--below); }
.track[data-direction="above"] .mark { left: 50%; background: var(--above); }
.track[data-direction="equal"] .mark {
  left: 50%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
}

.deviation {
  grid-column: 2;
  align-self: center;
  margin-top: 7px;
  font: clamp(12px, 3.4vw, 18px)/1.2 var(--mono);
  letter-spacing: -.06em;
  text-align: right;
  overflow-wrap: anywhere;
}

.deviation[data-direction="below"] { color: var(--below); }
.deviation[data-direction="above"] { color: var(--above); }

.main-actions {
  margin-top: auto;
  padding-top: clamp(34px, 8vw, 54px);
  padding-bottom: max(25px, env(safe-area-inset-bottom));
}

.primary, .secondary, .danger {
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 750;
}

.primary { background: var(--mint); color: var(--mint-ink); }
.primary:hover { background: #c1f5de; }
.secondary { border-color: var(--line); background: var(--surface); }
.secondary:hover { background: var(--surface-hover); }
.danger { padding-inline: 0; background: transparent; color: var(--above); }
.danger:hover { text-decoration: underline; }

.add-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: clamp(48px, 12.3vw, 56px);
  font-size: clamp(16px, 3.85vw, 20px);
  font-weight: 800;
  letter-spacing: -.025em;
}

.add-button svg { width: 16px; height: 16px; }
.empty { padding-block: 18px; color: var(--muted); }

dialog {
  width: min(calc(100% - 2 * var(--gutter)), 440px);
  max-height: calc(100dvh - 32px);
  padding: clamp(16px, 4.5vw, 25px);
  border: 1px solid var(--line);
  border-radius: 15px;
  background: var(--surface);
  color: var(--text);
}

dialog::backdrop { background: rgb(0 0 0 / 58%); }
.dialog-heading { display: flex; gap: 10px; align-items: center; justify-content: space-between; }
.dialog-heading h2 { font-size: clamp(19px, 4.7vw, 24px); font-weight: 800; letter-spacing: -.04em; }
.dialog-heading .icon-button { flex: none; }
dialog form { display: grid; gap: 14px; }
dialog label { display: grid; min-width: 0; gap: 5px; font-size: .9rem; font-weight: 650; }

dialog input:not([type="checkbox"]), dialog select {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--page);
  font-size: 16px;
  font-weight: 500;
}

dialog .checkbox { display: flex; align-items: center; gap: 8px; }
dialog input[type="checkbox"] { width: 17px; height: 17px; margin: 0; accent-color: var(--mint); }
.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.dialog-options { margin-top: 14px; }

.dialog-options button {
  width: 100%;
  min-height: 44px;
  padding: 9px 10px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  overflow-wrap: anywhere;
  text-align: left;
}

.dialog-options button:hover { background: var(--surface-hover); }
.dialog-options button[aria-current="true"] { color: var(--below); font-weight: 750; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-top: 6px; }
.dialog-actions .primary { margin-inline-start: auto; }
.dialog-options + .dialog-actions { margin-top: 16px; }
.form-message, .storage-status { color: var(--above); font-size: .9rem; }

.storage-status {
  position: fixed;
  inset: auto var(--gutter) 4px;
  padding: 5px;
  background: var(--page);
  text-align: center;
}

@media (min-width: 600px) {
  :root { --header-height: 76px; }
  .icon-button { width: 42px; height: 42px; }
}
