:root {
  color-scheme: light dark;
  --bg: #f7f4fb;
  --surface: #ffffff;
  --surface-soft: #f7eff8;
  --text: #1e1a2e;
  --text-muted: #6a6484;
  --stroke: #dccccf;
  --accent: #e91e94;
  --accent-soft: #f9ddf0;
  --warn: #9a5b2a;
  --shadow: 0 12px 35px rgba(38, 23, 46, 0.12);
  --bg-grad-a: #fdf1f9;
  --bg-grad-b: #f5f6ff;
  --bg-grad-c: #f5f0ff;
  --blob-a: #f18aca;
  --blob-b: #bea2ff;
  --id-color: #7a708f;
  --tree-rail: #d7c9ea;
}

:root[data-theme="dark"] {
  --bg: #090913;
  --surface: #131426;
  --surface-soft: #1b1d34;
  --text: #f5f6ff;
  --text-muted: #b3b6cf;
  --stroke: #2d3050;
  --accent: #ff2fa8;
  --accent-soft: #3a1b3a;
  --warn: #ff9d6a;
  --shadow: 0 14px 36px rgba(0, 0, 0, 0.42);
  --bg-grad-a: #1a1030;
  --bg-grad-b: #0f1123;
  --bg-grad-c: #090913;
  --blob-a: #a02a88;
  --blob-b: #6d2ab0;
  --id-color: #a9b1c2;
  --tree-rail: #323656;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #090913;
    --surface: #131426;
    --surface-soft: #1b1d34;
    --text: #f5f6ff;
    --text-muted: #b3b6cf;
    --stroke: #2d3050;
    --accent: #ff2fa8;
    --accent-soft: #3a1b3a;
    --warn: #ff9d6a;
    --shadow: 0 14px 36px rgba(0, 0, 0, 0.42);
    --bg-grad-a: #1a1030;
    --bg-grad-b: #0f1123;
    --bg-grad-c: #090913;
    --blob-a: #a02a88;
    --blob-b: #6d2ab0;
    --id-color: #a9b1c2;
    --tree-rail: #323656;
  }
}

* {
  box-sizing: border-box;
}

html {
  font-size: 125%;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: "Work Sans", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 10%, var(--bg-grad-a) 0%, var(--bg-grad-b) 50%, var(--bg-grad-c) 100%);
  overflow-x: hidden;
}

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
}

.bg-blob {
  position: absolute;
  border-radius: 999px;
  filter: blur(40px);
  opacity: 0.45;
}

.bg-blob-a {
  width: 320px;
  height: 320px;
  background: var(--blob-a);
  top: -90px;
  left: -110px;
}

.bg-blob-b {
  width: 380px;
  height: 380px;
  background: var(--blob-b);
  right: -150px;
  bottom: -150px;
}

.app {
  width: min(1050px, 100%);
  margin: 0 auto;
  padding: 16px 14px 40px;
}

.app-layout {
  display: block;
}

.card {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 14px;
  animation: cardIn 360ms ease both;
}

.hero {
  position: relative;
  background: var(--surface);
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.theme-btn {
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 7px 11px;
}

.eyebrow {
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.73rem;
  color: var(--text-muted);
  font-weight: 600;
}

h1,
h2 {
  font-family: "Space Grotesk", sans-serif;
}

h1 {
  margin: 6px 0 2px;
  font-size: 1.1rem;
  line-height: 1.05;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.4;
}

.combobox-wrap {
  margin-top: 12px;
  position: relative;
}

.label {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
}

.combobox {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}

#itemQuery {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--stroke);
  background: var(--surface-soft);
  padding: 12px 13px;
  font-size: 1rem;
  color: var(--text);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}

#itemQuery:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(233, 30, 148, 0.25);
}

.clear-btn {
  border: 1px solid var(--stroke);
  background: var(--surface-soft);
  color: var(--text-muted);
  padding: 11px 12px;
  border-radius: 12px;
  font-size: 0.82rem;
  font-weight: 600;
}

.suggestions {
  margin: 8px 0 0;
  padding: 6px;
  list-style: none;
  border: 1px solid var(--stroke);
  border-radius: 13px;
  background: var(--surface);
  display: none;
}

.suggestions.open {
  display: block;
  animation: cardIn 180ms ease both;
}

.suggestion-item {
  border: 0;
  width: 100%;
  background: transparent;
  text-align: left;
  border-radius: 9px;
  padding: 9px 10px;
  display: grid;
  gap: 2px;
  cursor: pointer;
}

.suggestion-item:hover,
.suggestion-item.active {
  background: var(--accent-soft);
}

.item-name {
  font-weight: 600;
  color: var(--text);
  overflow-wrap: anywhere;
}

.item-title-row {
  display: flex;
  align-items: baseline;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 0;
  max-width: 100%;
}

.item-title-row .item-name,
.item-title-row .craft-output-name {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.item-qty-inline {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.01em;
}

.item-main {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.item-main > span {
  min-width: 0;
}

.item-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  object-fit: contain;
  flex: 0 0 42px;
  border: 0;
  background: transparent;
}

.item-icon-placeholder {
  display: inline-block;
  background: transparent;
}

.item-link {
  display: block;
  width: 100%;
  border: 0;
  background: transparent;
  padding: 0;
  margin: 0;
  text-align: left;
  color: inherit;
  cursor: pointer;
}

.item-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.item-id {
  display: block;
  margin-top: 1px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--id-color);
  font-size: 0.74rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.item-subhead {
  display: block;
  margin-top: 1px;
  color: var(--text-muted);
  font-size: 0.72rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.query-meta {
  margin: 8px 2px 0;
  color: var(--text-muted);
  font-size: 0.83rem;
}

.jump-links {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.jump-links button {
  border: 1px solid var(--stroke);
  background: var(--surface-soft);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
}

.selected-summary {
  margin-top: 12px;
}

.selected-summary h2 {
  margin: 0;
  font-size: 1.2rem;
}

.summary-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.summary-head > * {
  min-width: 0;
}

.summary-head .item-icon {
  width: 66px;
  height: 66px;
  border-radius: 10px;
  flex-basis: 66px;
}

.summary-id {
  margin-top: 4px;
}

.summary-chips {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.summary-chip {
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 0.78rem;
  font-weight: 600;
  background: var(--surface-soft);
  border: 1px solid var(--stroke);
  color: var(--text-muted);
}

.summary-chip-link {
  cursor: pointer;
}

.summary-chip-link:hover {
  border-color: var(--accent);
  color: var(--text);
}

.cards-grid {
  margin-top: 12px;
  display: grid;
  gap: 12px;
}

.card-head h2 {
  margin: 0;
  font-size: 1.1rem;
}

#craftCard .card-head {
  margin-bottom: 14px;
}

.card-head p {
  margin: 4px 0 10px;
  color: var(--text-muted);
  font-size: 0.83rem;
}

.list {
  display: grid;
  gap: 8px;
}

.row {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  background: var(--surface);
  padding: 9px 10px;
}

.row-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.row-top > div:first-child {
  min-width: 0;
}

.meta {
  margin-top: 5px;
  color: var(--text-muted);
  font-size: 0.8rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.tag {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 999px;
  border: 1px solid var(--stroke);
  background: var(--surface-soft);
  color: var(--text-muted);
  padding: 4px 8px;
}

.count-inline {
  display: inline-block;
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: 0.01em;
  white-space: nowrap;
  border: 0;
  background: transparent;
  padding: 0;
}

.select-btn,
.more-btn {
  border: 1px solid var(--stroke);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  padding: 6px 8px;
}

.drop-table-toggle {
  margin-top: 8px;
}

.drop-table {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--stroke);
  display: grid;
  gap: 6px;
}

.drop-table-header,
.drop-table-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
}

.drop-table-header {
  color: var(--text-muted);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.drop-table-item {
  min-width: 0;
}

.drop-table-percent,
.drop-table-count {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.recipes-section {
  display: grid;
  gap: 8px;
}

.recipes-section h3 {
  margin: 6px 0 2px;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.empty {
  border: 1px dashed var(--stroke);
  border-radius: 12px;
  padding: 14px;
  color: var(--text-muted);
  font-size: 0.88rem;
  background: var(--surface-soft);
}

.tree ul {
  list-style: none;
  margin: 6px 0 0 10px;
  padding: 0 0 0 8px;
  border-left: 2px solid var(--tree-rail);
}

.tree li {
  margin: 6px 0;
}

.tree-node {
  padding: 4px 0;
}

.tree-node.tree-node-top-level {
  background: var(--surface);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  padding: 8px 9px;
}

.tree-node.tree-node-child {
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 2px 0;
}

.tree-node-top {
  display: flex;
  align-items: flex-start;
  gap: 0;
}

.tree-node-main {
  min-width: 0;
  flex: 1 1 auto;
}

.tree-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.craft-output-row {
  margin-bottom: 8px;
}

.craft-output-link .item-main {
  gap: 10px;
}

.craft-output-name {
  font-weight: 700;
  color: var(--text);
  overflow-wrap: anywhere;
}

.tree-kind {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  overflow-wrap: anywhere;
}

.resource-entry {
  display: grid;
  gap: 4px;
}

.resource-options-wrap {
  margin-left: 50px;
}

.resource-options-toggle {
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--text-muted);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}

.resource-options-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

.resource-options-list {
  margin-top: 5px;
  padding-left: 10px;
  border-left: 2px solid var(--tree-rail);
  display: grid;
  gap: 6px;
}

.resource-option-row {
  min-width: 0;
}

.base-list {
  margin-top: 0;
  display: grid;
  gap: 7px;
}

.base-title {
  margin: 10px 0 6px;
  font-size: 0.95rem;
  color: var(--text);
}

.base-item {
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 2px 0;
  font-size: 0.86rem;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.footer {
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-align: center;
}

@media (min-width: 760px) {
  .app {
    padding: 22px 20px 50px;
  }

  .hero {
    padding: 18px;
  }
}

@media (min-width: 980px) {
  .app-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
    gap: 12px;
    align-items: start;
  }

  .main-column {
    display: grid;
    gap: 12px;
  }

  .main-column .selected-summary {
    margin-top: 0;
  }

  .cards-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(7px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
