:root {
  --bg-0: #0c100e;
  --bg-1: #141a16;
  --bg-2: #1c2520;
  --line: rgba(168, 196, 168, 0.14);
  --text: #e8efe6;
  --muted: #8fa393;
  --accent: #c4e05a;
  --accent-dim: rgba(196, 224, 90, 0.14);
  --signal: #5ec4a8;
  --warn: #e0b45a;
  --danger: #e07a5a;
  --rarity-common: #9aa89c;
  --rarity-uncommon: #6dbf7a;
  --rarity-rare: #5a9fe0;
  --rarity-epic: #b07ae0;
  --rarity-legendary: #e0a55a;
  --rarity-ultra: #e05a7a;
  --rarity-upgrade: #5ec4a8;
  --rarity-unknown: #a0a89a;
  --font-display: "Oxanium", sans-serif;
  --font-body: "Sora", sans-serif;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --header-h: 7.5rem;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.45;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(94, 196, 168, 0.12), transparent 55%),
    radial-gradient(900px 500px at 100% 0%, rgba(196, 224, 90, 0.08), transparent 50%),
    linear-gradient(165deg, var(--bg-0), #101612 45%, #0a0e0b);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.045;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.app {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  min-height: 100dvh;
  padding-bottom: calc(1.5rem + var(--safe-bottom));
}

/* —— Header —— */
.hero {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: 1.1rem 1.15rem 0.85rem;
  background: linear-gradient(180deg, rgba(12, 16, 14, 0.96) 60%, rgba(12, 16, 14, 0.82));
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.brand-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.35rem;
}

.brand {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.85rem, 7vw, 2.35rem);
  letter-spacing: 0.04em;
  line-height: 0.95;
  text-transform: uppercase;
  margin: 0;
  background: linear-gradient(110deg, var(--text) 20%, var(--accent) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.meta-chip {
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--signal);
  white-space: nowrap;
}

.tagline {
  margin: 0 0 0.9rem;
  color: var(--muted);
  font-size: 0.88rem;
}

.search-wrap {
  position: relative;
}

.search-wrap input {
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  border-radius: 999px;
  padding: 0.72rem 1rem 0.72rem 2.55rem;
  font: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.search-wrap input::placeholder {
  color: var(--muted);
}

.search-wrap input:focus {
  border-color: rgba(196, 224, 90, 0.45);
  box-shadow: 0 0 0 3px var(--accent-dim);
}

.search-wrap svg {
  position: absolute;
  left: 0.95rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: var(--muted);
  pointer-events: none;
}

.filters {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.75rem 0 0.15rem;
  margin: 0 -0.15rem;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.filters::-webkit-scrollbar {
  display: none;
}

.filter-btn {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.2s var(--ease), color 0.2s var(--ease), border-color 0.2s var(--ease);
}

.filter-btn:hover {
  color: var(--text);
  border-color: rgba(168, 196, 168, 0.35);
}

.filter-btn.active {
  background: var(--accent-dim);
  border-color: rgba(196, 224, 90, 0.45);
  color: var(--accent);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1.15rem 0.25rem;
}

.count {
  font-family: var(--font-display);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.view-toggle {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  overflow: hidden;
}

.view-toggle button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}

.view-toggle button.active {
  background: var(--bg-2);
  color: var(--accent);
}

/* —— List —— */
.list {
  list-style: none;
  margin: 0;
  padding: 0.35rem 1.15rem 1rem;
}

.list-item {
  opacity: 0;
  transform: translateY(12px);
  animation: rise-in 0.45s var(--ease) forwards;
}

@keyframes rise-in {
  to {
    opacity: 1;
    transform: none;
  }
}

.item-btn {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: center;
  text-align: left;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: inherit;
  padding: 0.95rem 0.15rem;
  cursor: pointer;
  font: inherit;
  transition: background 0.2s var(--ease);
}

.item-btn:active {
  background: rgba(196, 224, 90, 0.04);
}

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

.rarity-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--rarity-common);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dot, var(--rarity-common)) 22%, transparent);
  --dot: var(--rarity-common);
  background: var(--dot);
}

.rarity-dot.common { --dot: var(--rarity-common); }
.rarity-dot.uncommon { --dot: var(--rarity-uncommon); }
.rarity-dot.rare { --dot: var(--rarity-rare); }
.rarity-dot.epic { --dot: var(--rarity-epic); }
.rarity-dot.legendary { --dot: var(--rarity-legendary); }
.rarity-dot.ultra { --dot: var(--rarity-ultra); }
.rarity-dot.upgrade { --dot: var(--rarity-upgrade); }
.rarity-dot.unknown { --dot: var(--rarity-unknown); }

.item-copy {
  min-width: 0;
}

.item-name {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.item-meta {
  display: block;
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.item-right {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--muted);
}

.progress-pip {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  border: 1.5px solid var(--muted);
}

.progress-pip.done {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(196, 224, 90, 0.35);
}

.chev {
  width: 1rem;
  height: 1rem;
  opacity: 0.55;
}

.empty {
  padding: 2.5rem 1.5rem;
  text-align: center;
  color: var(--muted);
}

.empty strong {
  display: block;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 1.1rem;
  margin-bottom: 0.35rem;
}

/* —— Detail panel —— */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(4, 8, 6, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s var(--ease);
}

.overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.detail {
  position: fixed;
  left: 50%;
  bottom: 0;
  z-index: 50;
  width: min(720px, 100%);
  max-height: min(92dvh, 900px);
  transform: translate(-50%, 110%);
  background:
    linear-gradient(180deg, #1a221c 0%, var(--bg-1) 28%);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 22px 22px 0 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.38s var(--ease);
}

.detail.open {
  transform: translate(-50%, 0);
}

.detail-handle {
  width: 2.4rem;
  height: 0.28rem;
  margin: 0.65rem auto 0.25rem;
  border-radius: 999px;
  background: rgba(168, 196, 168, 0.28);
  flex: 0 0 auto;
}

.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.5rem 1.15rem 0.85rem;
  border-bottom: 1px solid var(--line);
}

.detail-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.45rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.detail-sub {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.close-btn {
  flex: 0 0 auto;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--bg-2);
  color: var(--text);
  cursor: pointer;
  font-size: 1.25rem;
  line-height: 1;
  display: grid;
  place-items: center;
}

.detail-body {
  overflow-y: auto;
  padding: 1rem 1.15rem calc(1.4rem + var(--safe-bottom));
  -webkit-overflow-scrolling: touch;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 1rem;
}

.badge {
  font-family: var(--font-display);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
}

.badge.warn {
  color: var(--warn);
  border-color: rgba(224, 180, 90, 0.35);
  background: rgba(224, 180, 90, 0.08);
}

.section-label {
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--signal);
  margin: 1.15rem 0 0.55rem;
}

.section-label:first-child {
  margin-top: 0;
}

.note {
  margin: 0.35rem 0 0.85rem;
  padding: 0.7rem 0.85rem;
  border-left: 2px solid var(--warn);
  background: rgba(224, 180, 90, 0.06);
  color: var(--muted);
  font-size: 0.86rem;
}

.ingredient-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 0.75rem;
  align-items: start;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
  animation: fade-slide 0.35s var(--ease) both;
}

@keyframes fade-slide {
  from {
    opacity: 0;
    transform: translateX(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.check {
  appearance: none;
  width: 1.35rem;
  height: 1.35rem;
  margin-top: 0.1rem;
  border: 1.5px solid var(--muted);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  position: relative;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.15s var(--ease);
}

.check:checked {
  background: var(--accent);
  border-color: var(--accent);
}

.check:checked::after {
  content: "";
  position: absolute;
  left: 0.35rem;
  top: 0.12rem;
  width: 0.28rem;
  height: 0.55rem;
  border: solid var(--bg-0);
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.check:active {
  transform: scale(0.92);
}

.ing-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.98rem;
}

.ing-qty {
  font-family: var(--font-display);
  font-size: 0.95rem;
  color: var(--accent);
  white-space: nowrap;
}

.ing-locs {
  margin: 0.45rem 0 0;
  padding: 0;
  list-style: none;
}

.ing-locs li {
  position: relative;
  padding: 0.2rem 0 0.2rem 0.85rem;
  color: var(--muted);
  font-size: 0.82rem;
}

.ing-locs li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.55rem;
  width: 0.35rem;
  height: 0.35rem;
  border-radius: 50%;
  background: var(--signal);
  opacity: 0.7;
}

.ing-locs li.best {
  color: var(--text);
}

.ing-locs li.best::before {
  background: var(--accent);
  box-shadow: 0 0 6px rgba(196, 224, 90, 0.4);
}

.ing-locs li.tbd {
  color: var(--warn);
}

.ing-locs li.tbd::before {
  background: var(--warn);
}

.hint {
  margin: 0.35rem 0 0;
  font-size: 0.78rem;
  color: var(--muted);
  font-style: italic;
}

.crafted-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
  padding: 0.85rem 0.95rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(196, 224, 90, 0.05);
}

.crafted-row label {
  font-family: var(--font-display);
  font-size: 0.88rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.sources {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.75rem;
}

.sources a {
  color: var(--signal);
}

.status {
  padding: 2rem 1.15rem;
  text-align: center;
  color: var(--muted);
}

@media (min-width: 720px) {
  .hero {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .toolbar,
  .list {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .detail-head,
  .detail-body {
    padding-left: 1.5rem;
    padding-right: 1.5rem;
  }

  .item-btn:hover {
    background: rgba(196, 224, 90, 0.04);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .list-item {
    opacity: 1;
    transform: none;
  }

  .detail {
    transition: none;
  }
}
