.ui-icon {
  display: inline-block;
  flex: none;
  width: 1.125rem;
  height: 1.125rem;
  background-color: currentColor;
  mask: var(--icon-image) center / contain no-repeat;
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--line-bright), 0 2px 0 var(--shadow);
  min-width: 0;
}
.button {
  display: inline-flex;
  min-height: var(--control-size);
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: .5rem 1rem;
  border: 1px solid var(--line-bright);
  background: var(--surface-high);
  box-shadow: var(--control-shadow);
  font-weight: 700;
  font-size: .875rem;
  color: var(--text);
  text-align: center;
}
.button:hover { background: var(--surface-hover); }
.button:active { box-shadow: inset 0 2px 0 var(--shadow); }
.button.primary {
  background: var(--green-button);
  border-color: var(--green-edge) var(--green-shadow) #203717;
  box-shadow: inset 0 -2px 0 var(--green-shadow), 0 2px 0 var(--shadow);
  color: #fff;
}
.button.primary:hover { background: var(--green-hover); }
.button.primary:active { box-shadow: inset 0 2px 0 var(--green-shadow); }
.button.small { min-height: 2.25rem; padding: .35rem .625rem; }
.button.danger { color: var(--danger); }
.text-link, .back-link {
  color: var(--green);
  font-size: .875rem;
  font-weight: 650;
}
.text-link:hover, .back-link:hover { text-decoration: underline; text-underline-offset: .22em; }
.back-link { display: inline-flex; align-items: center; gap: var(--space-2); align-self: start; }
.page-heading { margin-bottom: var(--space-6); }
.page-heading h1 {
  font-size: clamp(1.875rem, 4vw, 2.375rem);
  font-weight: 800;
  letter-spacing: -.04em;
}
.page-heading p { margin-top: var(--space-2); color: var(--muted); }
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}
.section-heading h2 { font-weight: 750; }
.empty-state {
  grid-column: 1 / -1;
  display: grid;
  justify-items: center;
  gap: var(--space-2);
  padding: var(--space-8) var(--space-4);
  border: 1px dashed var(--line-bright);
  text-align: center;
}
.empty-state p, .muted { color: var(--muted); }
.empty-state a { margin-top: var(--space-2); }
.notice {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--line);
  border-left: 3px solid var(--green-edge);
  background: var(--inset);
  color: var(--muted);
  font-size: .875rem;
}
.notice .ui-icon { color: var(--green); }
.filter-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(8.5rem, max-content);
  gap: var(--space-3);
}
.search-field {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border: 1px solid var(--line-bright);
  padding: 0 var(--space-3);
  min-height: var(--control-size);
  min-width: 0;
  background: var(--inset);
  box-shadow: inset 0 2px 0 var(--shadow);
  color: var(--dim);
}
.search-field:focus-within { border-color: var(--green-edge); outline: 1px solid var(--green-edge); }
.search-input {
  width: 100%;
  min-width: 0;
  padding: .5rem 0;
  outline: none;
  border: 0;
  background: transparent;
  color: var(--text);
}
.search-input::placeholder { color: var(--dim); opacity: 1; }
.select-input, .number-input {
  min-width: 0;
  min-height: var(--control-size);
  padding: .5rem .75rem;
  background-color: var(--inset);
  color: var(--text);
  border: 1px solid var(--line-bright);
  border-radius: 0;
  box-shadow: inset 0 2px 0 var(--shadow);
}
.select-input {
  appearance: none;
  background-image: url('../assets/ui/chevron-down.png');
  background-position: right .75rem center;
  background-repeat: no-repeat;
  background-size: .875rem;
  padding-right: 2rem;
}
.select-input:hover { border-color: var(--green-edge); }
.number-input[aria-invalid="true"] { border-color: var(--danger); }
.segmented {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}
.segment-button {
  border: 1px solid var(--line);
  background: var(--inset);
  color: var(--muted);
  padding: .5rem .875rem;
  min-height: 2.375rem;
  font-weight: 650;
  font-size: .875rem;
}
.segment-button:hover { color: var(--text); }
.segment-button[aria-pressed="true"] {
  color: var(--text);
  background: var(--surface-high);
  border-color: var(--line-bright);
  box-shadow: inset 0 -2px 0 var(--green-edge);
}
.item-image {
  display: block;
  width: 1.75rem;
  height: 1.75rem;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(1px 2px 0 #1118);
  flex: none;
}
.item-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}
.item-tile {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.625rem;
  height: 2.625rem;
  background: var(--inset);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--shadow);
}
.item-copy { display: grid; gap: .1rem; min-width: 0; }
.item-name { font-size: .9375rem; line-height: 1.35; overflow-wrap: anywhere; }
.item-subtitle {
  font-size: .8125rem;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.item-picker { min-width: 0; }
.item-picker-trigger, .item-picker-option {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
  background: var(--inset);
  color: var(--text);
  text-align: start;
}
.item-picker-trigger {
  justify-content: space-between;
  gap: var(--space-2);
  min-height: var(--control-size);
  height: 100%;
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--line-bright);
  box-shadow: inset 0 2px 0 var(--shadow);
}
.item-picker-trigger:hover, .item-picker-trigger[aria-expanded="true"] { border-color: var(--green-edge); }
.item-picker-trigger .item-label { gap: var(--space-2); }
.item-picker-trigger .ui-icon { flex: none; }
.item-picker .item-tile { width: 2rem; height: 2rem; }
.item-picker .item-image { width: 1.375rem; height: 1.375rem; }
.item-picker-options {
  position: absolute;
  z-index: 1;
  inset-inline: 0;
  inset-block-start: calc(100% + var(--space-1));
  max-height: min(17rem, 45vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-1);
  border: 1px solid var(--line-bright);
  background: var(--surface);
  box-shadow: 0 3px 0 var(--shadow);
}
.item-picker-option { padding: var(--space-2); border: 1px solid transparent; }
.item-picker-option[aria-pressed="true"] { border-inline-start-color: var(--green-edge); color: var(--green); }
.item-picker-option:hover, .item-picker-option:focus-visible { background: var(--surface-hover); }
.item-picker-option:focus-visible { outline-offset: -2px; }
@media (max-width: 550px) {
  .item-picker-trigger { gap: var(--space-1); padding-inline: var(--space-1); }
  .item-picker-trigger .item-label { gap: var(--space-1); }
  .item-picker-trigger .item-tile { width: 1.625rem; height: 1.625rem; }
  .item-picker-trigger .item-image { width: 1.125rem; height: 1.125rem; }
  .item-picker-trigger .ui-icon { width: .875rem; height: .875rem; }
}
.item-link { display: inline-flex; min-width: 0; }
.item-link:hover .item-name, .recipe-card:hover .item-name { color: var(--green); }
.recipe-card, .catalog-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
  padding: .625rem .75rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 var(--line-bright), 0 2px 0 var(--shadow);
}
.recipe-card:hover, .catalog-card:hover { background: var(--surface-hover); border-color: var(--line-bright); }
.output-count {
  align-self: start;
  flex: none;
  margin-top: .15rem;
  padding: 0 .28rem;
  border: 1px solid var(--line);
  color: var(--green);
  font-size: .75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.quantity { display: grid; justify-items: end; font-variant-numeric: tabular-nums; }
.quantity strong { font-size: .875rem; white-space: nowrap; }
.quantity small { color: var(--muted); font-size: .75rem; white-space: nowrap; }
.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr));
  gap: var(--space-3);
}
.crafting-grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-size), 2.375rem);
  gap: .1875rem;
}
.crafting-slot {
  display: grid;
  place-items: center;
  width: 2.375rem;
  height: 2.375rem;
  background: var(--surface-hover);
  border: 1px solid var(--line-bright);
  box-shadow: inset 2px 2px 0 var(--surface), inset -1px -1px 0 #615c59;
}
.crafting-slot.filled:hover, .crafting-slot.output { border-color: var(--green-edge); }
.crafting-slot .item-image { width: 1.5rem; height: 1.5rem; }

.item-placeholder {
  display: grid;
  place-items: center;
  outline: 1px solid var(--line-bright);
  outline-offset: -0.24rem;
  color: var(--muted);
  font-weight: 700;
}

.result-grid > .empty-state { grid-column: 1 / -1; }
.button:disabled { opacity: .55; cursor: default; }
.empty-state button { margin-top: var(--space-2); }
