:root {
  color-scheme: light;
  --surface: #ffffff;
  --surface-muted: #f3f4f6;
  --text: #171717;
  --text-muted: #525252;
  --border: #d4d4d4;
  --accent: #234f87;
  --accent-text: #ffffff;
  --danger: #a11d2f;
  --focus: #006edb;
  --space-1: 0.5rem;
  --space-2: 1rem;
  --space-3: 1.5rem;
  --radius: 0.35rem;
  font-family: system-ui, sans-serif;
  line-height: 1.5;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface: #171717;
  --surface-muted: #262626;
  --text: #f5f5f5;
  --text-muted: #d4d4d4;
  --border: #525252;
  --accent: #8bbcf3;
  --accent-text: #101820;
  --danger: #ff9ba8;
  --focus: #8bc5ff;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    color-scheme: dark;
    --surface: #171717;
    --surface-muted: #262626;
    --text: #f5f5f5;
    --text-muted: #d4d4d4;
    --border: #525252;
    --accent: #8bbcf3;
    --accent-text: #101820;
    --danger: #ff9ba8;
    --focus: #8bc5ff;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
}

a {
  color: var(--accent);
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.link--skip-link {
  position: absolute;
  top: 0;
  left: -100vw;
  padding: var(--space-1);
  background: var(--surface);
  z-index: 2;
}

.link--skip-link:focus {
  left: 0;
}

.site-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-2);
  border-bottom: 1px solid var(--border);
}

.site-nav,
.cart-line-actions {
  display: flex;
  align-items: end;
  gap: var(--space-1);
  flex-wrap: wrap;
}

.page-shell {
  width: min(70rem, 100% - 2rem);
  margin-inline: auto;
  padding-block: var(--space-3);
}

.product-grid,
.cart-lines,
.variant-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
  gap: var(--space-2);
}

.product-card,
.product-detail,
.cart-line,
.empty-state,
.error-page {
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
}

.product-detail {
  max-width: 48rem;
}

.cart-lines {
  display: grid;
  gap: var(--space-2);
}

.cart-line {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
}

.cart-total {
  font-size: 1.2rem;
}

form {
  display: flex;
  align-items: end;
  gap: var(--space-1);
  flex-wrap: wrap;
  margin-block: var(--space-2);
}

.field {
  display: grid;
  gap: 0.25rem;
}

input,
select,
.button,
.link {
  min-height: 2.75rem;
  font: inherit;
}

input,
select {
  padding: 0.55rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
}

.button,
.link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-decoration: none;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button--primary,
.link--primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-text);
}

.button--secondary,
.link--secondary {
  background: var(--surface);
  color: var(--text);
}

.button--destructive,
.link--destructive {
  border-color: var(--danger);
  color: var(--danger);
  background: var(--surface);
}

.feedback {
  min-height: 1.5rem;
}

.feedback--success {
  color: var(--text);
}

.feedback--error,
.field-error,
.cart-line-status {
  color: var(--danger);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 42rem) {
  .site-header,
  .cart-line {
    align-items: stretch;
    flex-direction: column;
  }

  .cart-line-actions,
  .cart-line-actions form {
    align-items: stretch;
  }
}
