:root {
  color-scheme: light;
  --ink: #111;
  --muted: #656565;
  --line: #dedede;
  --page-width: 1120px;
  --gutter: 24px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: proxima-nova, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

button,
input,
select {
  color: inherit;
  font: inherit;
}

button,
select {
  cursor: pointer;
}

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

[hidden] {
  display: none !important;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 18px max(var(--gutter), calc((100vw - var(--page-width)) / 2));
  border-bottom: 1px solid var(--line);
}

.copyright {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.page-content {
  width: min(var(--page-width), calc(100% - 2 * var(--gutter)));
  margin: 0 auto;
  padding: clamp(40px, 6vw, 80px) 0 80px;
}

.intro {
  max-width: 680px;
  margin-bottom: 28px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 12px;
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1.08;
}

.intro-copy {
  max-width: 620px;
  margin-bottom: 30px;
  color: #333;
  font-size: 16px;
}

.search-field {
  display: grid;
  gap: 8px;
  max-width: 580px;
  position: relative;
}

.search-field label {
  font-size: 13px;
  font-weight: 600;
}

.search-field input {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: #fff;
  padding: 10px 0;
}

.search-results {
  position: absolute;
  z-index: 2;
  top: calc(100% + 4px);
  right: 0;
  left: 0;
  max-height: 320px;
  overflow: auto;
  border: 1px solid var(--line);
  background: #fff;
}

@media (min-width: 769px) {
  .search-results {
    display: flex;
    align-items: flex-start;
  }

  .search-group {
    flex: 1;
    min-width: 0;
  }

  .search-group + .search-group {
    border-left: 1px solid var(--line);
  }
}

.search-results :is(button, .ingredient-link) {
  display: block;
  width: 100%;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  padding: 12px;
  color: inherit;
  text-align: left;
  text-decoration: none;
}

.search-results :is(button, .ingredient-link):last-child {
  border-bottom: 0;
}

.search-results :is(button, .ingredient-link):hover,
.entry-list :is(button, .ingredient-link):hover,
.category-panel button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.search-results .empty-state {
  margin: 0;
  padding: 12px;
}

.result-type {
  margin: 0;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
}

.search-group + .search-group .result-type {
  border-top: 1px solid var(--line);
}

.app-status {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.retry-button,
.mode-button,
.alphabet button,
.entry-list button,
.product-accordion button,
.inci-list button {
  border: 0;
  border-radius: 0;
  background: transparent;
}

.retry-button {
  padding: 4px 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.mode-navigation {
  display: flex;
  flex-wrap: wrap;
  gap: 0 28px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 28px;
}

.mode-button {
  position: relative;
  min-height: 44px;
  padding: 10px 0;
  font-size: 13px;
  letter-spacing: 0.045em;
  color: var(--muted);
  font-weight: 600;
}

.mode-button[aria-pressed="true"] {
  color: var(--ink);
}

.mode-button[aria-pressed="true"]::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--ink);
  content: "";
}

.browser-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.65fr);
  gap: clamp(32px, 6vw, 80px);
  align-items: start;
}

@media (min-width: 769px) {
  #product-browser { grid-area: 1 / 1; }
  #product-detail { grid-area: 1 / 2; }
}

.product-browse-link,
.product-page-link {
  display: inline-block;
  margin-bottom: 14px;
  color: inherit;
  text-underline-offset: 3px;
}

.product-page-link {
  margin-inline-end: 16px;
}

@media (min-width: 769px) {
  .product-browse-link { display: none; }
}

.alphabet {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 0 0 16px;
}

.alphabet button {
  min-width: 28px;
  min-height: 30px;
  padding: 3px 6px;
}

.alphabet button[aria-pressed="true"] {
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
}

.alphabet button:disabled {
  color: #aaa;
  cursor: default;
}

.entry-list,
.category-panel ul {
  margin: 0;
  padding: 0;
  list-style: none;
}

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

.entry-list :is(button, .ingredient-link),
.category-panel button {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 8px 0;
  color: inherit;
  text-align: left;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.entry-list [aria-current="true"],
.category-panel button[aria-pressed="true"] {
  font-weight: 700;
}

.detail-panel {
  min-width: 0;
  border-top: 1px solid var(--line);
  padding-top: 22px;
  scroll-margin-top: 20px;
}

.detail-panel > :is(h1, h2) {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: clamp(24px, 3vw, 34px);
  font-weight: 500;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.detail-common-name {
  margin-bottom: 20px;
  color: var(--muted);
}

.detail-description {
  max-width: 65ch;
  margin-bottom: 26px;
  line-height: 1.65;
}

.detail-section {
  border-top: 1px solid var(--line);
  padding: 18px 0;
}

.detail-section :is(h2, h3) {
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.detail-section p:last-child,
.detail-section ul:last-child,
.detail-section dl:last-child {
  margin-bottom: 0;
}

.detail-section ul,
.reference-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding-left: 18px;
}

.detail-section li p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.reference-meta {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.detail-section > dl {
  display: grid;
  grid-template-columns: minmax(120px, 0.4fr) minmax(0, 1fr);
  gap: 8px 18px;
  margin: 0;
}

.detail-section dt {
  color: var(--muted);
}

.detail-section dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}

.product-accordion {
  border-top: 1px solid var(--line);
}

.product-category {
  border-bottom: 1px solid var(--line);
  padding: 4px 0;
}

.category-trigger {
  display: flex;
  width: 100%;
  min-height: 44px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 0;
  text-align: left;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.category-trigger:hover,
.category-trigger[aria-expanded="true"] {
  text-decoration: underline;
  text-underline-offset: 4px;
}

.category-symbol {
  flex: 0 0 auto;
  font-size: 18px;
  font-weight: 400;
  line-height: 1;
}

.category-panel {
  padding: 0 0 12px 16px;
}

.category-panel button {
  font-size: 14px;
}

.reference-list a {
  color: inherit;
  text-underline-offset: 3px;
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 18px 0;
  color: var(--muted);
}

.product-summary {
  margin-bottom: 20px;
  color: var(--muted);
}

.inci-list {
  margin: 0;
  padding-left: 28px;
}

.inci-list li {
  padding: 6px 0;
}

.inci-list :is(button, .ingredient-link) {
  display: inline-block;
  padding: 2px 0;
  color: inherit;
  text-align: left;
  text-decoration: underline;
  text-decoration-color: #aaa;
  text-underline-offset: 3px;
}

.inci-list :is(button, .ingredient-link):hover {
  text-decoration-color: var(--ink);
}

.detail-section .related-products {
  padding: 0;
  list-style: none;
}

.related-products a {
  display: inline-block;
  padding: 8px 0;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.detail-panel a,
.ingredient-page > p a {
  color: inherit;
  text-underline-offset: 3px;
}

@media (max-width: 768px) {
  :root { --gutter: 20px; }

  .page-content {
    padding: 44px 0 64px;
  }

  .intro {
    margin-bottom: 24px;
  }

  .browser-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 32px;
  }

  .detail-panel {
    padding-top: 18px;
  }

}

@media (max-width: 480px) {
  .site-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }

  .page-content {
    padding-top: 36px;
  }

  .mode-navigation {
    gap: 20px;
  }

  .detail-section > dl {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .detail-section dd + dt {
    margin-top: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
}
