* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --black: #000;
  --white: #fff;
  --gray-1: #f5f5f5;
  --gray-2: #e5e5e5;
  --gray-3: #999;
  --gray-4: #555;
}

body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--white);
  color: var(--black);
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 560px;
  margin: 0 auto;
  padding: 32px 20px 64px;
}

header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 32px;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.link-btn {
  background: none;
  border: none;
  font: inherit;
  font-size: 13px;
  color: var(--gray-3);
  cursor: pointer;
  padding: 4px 0;
}
.link-btn:hover { color: var(--black); }

/* Sign-in */
.tagline {
  font-size: 15px;
  line-height: 1.6;
  color: var(--gray-4);
  margin-bottom: 28px;
  max-width: 40ch;
}
.warning {
  margin-top: 20px;
  font-size: 13px;
  color: var(--gray-4);
  border: 1px solid var(--gray-2);
  padding: 12px;
}

/* Search */
.search-wrap { position: relative; }

#search {
  width: 100%;
  font: inherit;
  font-size: 17px;
  padding: 14px 16px;
  border: 2px solid var(--black);
  border-radius: 0;
  background: var(--white);
  color: var(--black);
  outline: none;
}
#search::placeholder { color: var(--gray-3); }

#suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 10;
  background: var(--white);
  border: 2px solid var(--black);
  border-top: none;
  list-style: none;
  max-height: 320px;
  overflow-y: auto;
}
#suggestions li {
  padding: 11px 16px;
  font-size: 14px;
  line-height: 1.4;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--gray-2);
}
#suggestions li:last-child { border-bottom: none; }
#suggestions li:hover, #suggestions li.active { background: var(--black); color: var(--white); }
#suggestions li:hover .sug-carbs, #suggestions li.active .sug-carbs { color: var(--white); }
.sug-carbs { color: var(--gray-3); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Calculator */
#calc {
  margin-top: 28px;
  border: 1px solid var(--black);
  padding: 24px;
}
#calc h2 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 20px;
}
.calc-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  flex-wrap: wrap;
}
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-4);
  margin-bottom: 6px;
}
.amount-input {
  display: flex;
  align-items: baseline;
  gap: 10px;
  border-bottom: 2px solid var(--black);
}
#amount {
  width: 2.2ch;
  min-width: 1.4ch;
  font: inherit;
  font-size: 28px;
  font-weight: 600;
  border: none;
  outline: none;
  padding: 2px 0;
  color: var(--black);
  background: transparent;
  font-variant-numeric: tabular-nums;
}
#amount::-webkit-outer-spin-button, #amount::-webkit-inner-spin-button { -webkit-appearance: none; }
#amount { -moz-appearance: textfield; appearance: textfield; }
#unit {
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  border: none;
  outline: none;
  color: var(--black);
  cursor: pointer;
  padding: 2px 18px 2px 0;
  max-width: 180px;
  appearance: none;
  -webkit-appearance: none;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' fill='none' stroke='%23000' stroke-width='2'/%3E%3C/svg%3E") no-repeat right center / 11px;
}

.result { text-align: right; }
.result-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-4);
  margin-bottom: 6px;
}
#carbs-value {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.result-unit { font-size: 18px; font-weight: 500; margin-left: 3px; }

.per100 {
  margin-top: 14px;
  font-size: 13px;
  color: var(--gray-3);
}

/* Lists */
.lists {
  margin-top: 40px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 32px;
}
.list-block h3 {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-4);
  margin-bottom: 10px;
}
.list-block ul { list-style: none; }
.list-block li {
  font-size: 14px;
  line-height: 1.4;
  padding: 9px 0;
  border-bottom: 1px solid var(--gray-2);
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.list-block li:hover { color: var(--gray-4); }
.list-meta {
  color: var(--gray-3);
  font-variant-numeric: tabular-nums;
  text-align: right;
  max-width: 40%;
  flex-shrink: 0;
}

/* About */
#about {
  margin-top: 96px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-2);
}
#about h3 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gray-3);
  margin-bottom: 6px;
}
#about p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--gray-3);
  max-width: 56ch;
}
#about a {
  color: var(--gray-3);
  text-decoration: underline;
}
#about a:hover { color: var(--black); }

@media (max-width: 520px) {
  .page { padding: 24px 16px 48px; }
  .lists { grid-template-columns: 1fr; gap: 24px; }
  #carbs-value { font-size: 34px; }
  #calc { padding: 18px; }
  .calc-row { gap: 16px; }
}
