@import url("https://fonts.googleapis.com/css2?family=Rubik:wght@400;500;600;700&display=swap");

:root {
  color-scheme: dark;
  --bg: #0c0b10;
  --panel: #16131c;
  --panel-2: #1f1a26;
  --panel-3: #0f0c13;
  --ink: #f6f2ff;
  --muted: #a294b8;
  --accent: #ff7a59;
  --accent-2: #ffd166;
  --stroke: rgba(255, 255, 255, 0.08);
  --shadow: 0 18px 46px rgba(2, 8, 20, 0.55);
  --shadow-soft: 0 10px 24px rgba(2, 8, 20, 0.35);
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

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

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(900px 520px at 12% -12%, rgba(255, 122, 89, 0.18), transparent),
    radial-gradient(700px 520px at 100% -10%, rgba(255, 209, 102, 0.12), transparent),
    radial-gradient(520px 420px at 30% 100%, rgba(32, 24, 40, 0.55), transparent),
    linear-gradient(180deg, #0b0910 0%, #07060c 100%);
  color: var(--ink);
  font-family: "Rubik", system-ui, sans-serif;
}

body.no-scroll {
  overflow: hidden;
  padding-right: var(--scrollbar-width, 0px);
}

.bg-glow {
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'><defs><pattern id='d' width='22' height='22' patternUnits='userSpaceOnUse'><circle cx='1.5' cy='1.5' r='1.5' fill='rgba(42,171,238,0.15)'/></pattern></defs><rect width='200' height='200' fill='url(%23d)'/></svg>");
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

.topbar {
  position: sticky;
  top: 16px;
  z-index: 2;
  width: min(560px, 94vw);
  margin: 16px auto 0;
  padding: 10px 12px;
  background: rgba(15, 20, 28, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(16px);
}

.topbar-left {
  display: flex;
  align-items: center;
  width: 100%;
}

.topnav {
  display: flex;
  justify-content: center;
  gap: 6px;
  width: 100%;
}

.nav-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid transparent;
  background: transparent;
  transition: 0.2s ease;
  position: relative;
}

.nav-link:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
}

.nav-link.is-active {
  color: #ffffff;
  background: transparent;
  box-shadow: none;
}


.app {
  position: relative;
  z-index: 1;
  width: min(560px, 94vw);
  margin: 18px auto 80px;
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  padding: 22px 20px 26px;
  box-shadow: var(--shadow);
}

.panel-head {
  display: grid;
  gap: 12px;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(22px, 3.4vw, 30px);
  font-weight: 700;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent);
}

.lead {
  color: var(--muted);
  margin: 0;
  max-width: 640px;
}

.controls {
  margin-top: 18px;
  display: grid;
  gap: 18px;
  grid-template-columns: 1fr;
  align-items: end;
}

.gift-dependent {
  display: grid;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px);
  transition: max-height 0.6s ease, opacity 0.6s ease, transform 0.6s ease;
  pointer-events: none;
}

.controls.has-gift .gift-dependent {
  max-height: 220px;
  opacity: 1;
  /* `transform` creates a stacking context; it can cause dropdowns to render under
     following fields. Use `none` when visible so popovers layer correctly. */
  transform: none;
  pointer-events: auto;
  /* Allow dropdown popovers to escape the animated container. */
  overflow: visible;
}

.gift-dependent.is-hidden {
  display: none;
}

.actions {
  margin-top: 16px;
  display: flex;
  justify-content: stretch;
}

.primary-btn {
  width: 100%;
  border: none;
  cursor: pointer;
  color: #0b0f14;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 22px rgba(79, 140, 255, 0.28);
  transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 28px rgba(79, 140, 255, 0.32);
  filter: brightness(1.04);
}

.primary-btn:active {
  transform: translateY(0);
  box-shadow: 0 8px 18px rgba(79, 140, 255, 0.22);
}

.primary-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  filter: grayscale(0.2);
  box-shadow: none;
  transform: none;
}

.toast {
  position: fixed;
  right: 12px;
  top: calc(12px + env(safe-area-inset-top, 0px));
  transform: translate(0, -12px) scale(0.98);
  background: linear-gradient(145deg, rgba(18, 22, 30, 0.94), rgba(12, 16, 24, 0.96));
  color: var(--ink);
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 12px 28px rgba(2, 8, 20, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
  font-size: 12px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: center;
  min-width: min(240px, 86vw);
  max-width: min(340px, 86vw);
  backdrop-filter: blur(16px);
}

.toast::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  padding: 1px;
  background: linear-gradient(130deg, rgba(255, 122, 89, 0.6), rgba(255, 209, 102, 0.35));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.7;
  pointer-events: none;
}

.toast__icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 30% 30%, rgba(255, 209, 102, 0.9), rgba(255, 122, 89, 0.9));
  color: #140c10;
  box-shadow: 0 8px 16px rgba(255, 122, 89, 0.22);
  font-weight: 700;
  font-size: 15px;
}

.toast.is-error .toast__icon {
  background: radial-gradient(circle at 30% 30%, rgba(255, 108, 108, 0.95), rgba(255, 78, 78, 0.9));
  color: #1a0b0b;
  box-shadow: 0 8px 16px rgba(255, 80, 80, 0.22);
}

.toast.is-error::before {
  background: linear-gradient(130deg, rgba(255, 108, 108, 0.7), rgba(255, 160, 160, 0.35));
}

.toast__content {
  display: grid;
  gap: 4px;
}

.toast__title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.toast__msg {
  color: var(--muted);
  font-size: 11px;
}

.toast__bar {
  grid-column: 1 / -1;
  height: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-top: 6px;
}

.toast__bar span {
  display: block;
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, rgba(255, 122, 89, 0.95), rgba(255, 209, 102, 0.95));
  transform-origin: left;
  transform: scaleX(0);
}

.toast.is-visible {
  animation: toast-in 0.38s cubic-bezier(0.2, 0.9, 0.2, 1) forwards,
    toast-out 0.32s ease 1.7s forwards;
}

.toast.is-visible .toast__bar span {
  animation: toast-progress 1.6s linear forwards;
}

@keyframes toast-in {
  from {
    transform: translate(0, -10px) scale(0.96);
    opacity: 0;
  }
  to {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
}

@keyframes toast-out {
  from {
    transform: translate(0, 0) scale(1);
    opacity: 1;
  }
  to {
    transform: translate(0, -8px) scale(0.98);
    opacity: 0;
  }
}

@keyframes toast-progress {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  .toast.is-visible {
    animation: none;
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }

  .toast.is-visible .toast__bar span {
    animation: none;
    transform: scaleX(1);
  }
}

.field {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

select,
button {
  font: inherit;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin-top: 18px;
}

.card {
  background: linear-gradient(180deg, rgba(22, 28, 38, 0.96), rgba(16, 20, 28, 0.96));
  border: 1px solid var(--stroke);
  border-radius: var(--radius-md);
  padding: 16px;
  display: grid;
  gap: 12px;
  box-shadow: var(--shadow-soft);
}

.tracked-card {
  position: relative;
  overflow: hidden;
}

.tracked-meta {
  display: grid;
  gap: 10px;
  font-size: 12px;
  color: var(--muted);
}

.tracked-meta span {
  border-radius: 10px;
}

.tracked-meta--list {
  display: grid;
  gap: 10px;
}

.meta-item {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 10px 30px;
  border-radius: 18px;
  background: linear-gradient(120deg, rgba(22, 28, 38, 0.92), rgba(14, 18, 26, 0.92));
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow: 0 8px 16px rgba(2, 8, 20, 0.22);
}

.meta-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.48);
}

.meta-value {
  font-weight: 600;
  color: var(--ink);
}


.meta-item::before {
  content: "";
  position: absolute;
  left: 12px;
  top: 50%;
  width: 6px;
  height: 6px;
  transform: translateY(-50%);
  border-radius: 999px;
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.02);
}

.meta-model::before {
  background: linear-gradient(135deg, rgba(255, 209, 102, 1), rgba(255, 164, 99, 1));
}

.meta-pattern::before {
  background: linear-gradient(135deg, rgba(255, 122, 89, 1), rgba(255, 84, 129, 1));
}

.meta-backdrop::before {
  background: linear-gradient(135deg, rgba(42, 171, 238, 1), rgba(79, 255, 204, 1));
}

.card-actions {
  display: flex;
  justify-content: flex-end;
}

.delete-btn {
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
  color: #ffb3b3;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  transition: 0.2s ease;
  box-shadow: 0 8px 14px rgba(2, 8, 20, 0.18);
}

.delete-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  transform: translateY(-1px);
}

.delete-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.delete-icon {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(7, 9, 14, 0.68);
  display: grid;
  place-items: center;
  z-index: 20;
  backdrop-filter: blur(10px);
  opacity: 1;
  transition: opacity 0.22s ease;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal {
  width: min(420px, 90vw);
  background: linear-gradient(180deg, rgba(18, 22, 30, 0.98), rgba(12, 16, 24, 0.98));
  border: none;
  border-radius: 18px;
  padding: 18px 18px 16px;
  box-shadow: 0 18px 40px rgba(2, 8, 20, 0.45);
  animation: modal-in 0.25s ease;
  opacity: 1;
  transition: transform 0.22s ease, opacity 0.22s ease;
}

.modal-head {
  display: grid;
  gap: 8px;
}

.modal h2 {
  margin: 0;
  font-size: 18px;
}

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

.modal-actions {
  margin-top: 16px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.ghost-btn,
.danger-btn {
  border-radius: 0;
  padding: 10px 14px;
  border: none;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
  transition: 0.2s ease;
}

.ghost-btn:hover {
  background: transparent;
}

.danger-btn {
  background: transparent;
  border-color: transparent;
  color: #ffd4d4;
}

.danger-btn:hover {
  background: transparent;
}

@keyframes modal-in {
  from {
    transform: translateY(12px) scale(0.98);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.modal-backdrop.is-closing {
  opacity: 0;
}

.modal-backdrop.is-closing .modal {
  transform: translateY(8px) scale(0.98);
  opacity: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.card-head {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
}

.card-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.gift-thumb {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  object-fit: contain;
}

.tracked-card {
  gap: 10px;
}

.count {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--stroke);
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

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

.gift-select {
  position: relative;
}

.gift-select.is-open {
  /* Keep the open dropdown above other fields (esp. when other ancestors animate). */
  z-index: 10;
}

.gift-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(20, 26, 36, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--ink);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: 0.2s ease;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02), 0 10px 18px rgba(2, 8, 20, 0.25);
}

.gift-trigger:hover {
  border-color: rgba(42, 171, 238, 0.55);
  box-shadow: inset 0 0 0 1px rgba(42, 171, 238, 0.18),
    0 12px 24px rgba(42, 171, 238, 0.25);
}

.gift-trigger img {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: contain;
  background: var(--panel-3);
  border: 1px solid var(--stroke);
}

.gift-trigger .gift-title {
  flex: 1;
  text-align: left;
  font-weight: 500;
}

.gift-caret {
  width: 10px;
  height: 10px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: 0.2s ease;
}

.gift-select.is-open .gift-caret {
  transform: rotate(-135deg);
}

.gift-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 10px);
  background: rgba(16, 20, 28, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 10px;
  box-shadow: var(--shadow);
  display: none;
  z-index: 5;
}

.gift-select.is-open .gift-list {
  display: grid;
  gap: 8px;
}

.list-search input,
.field-input {
  width: 100%;
  background: rgba(18, 22, 30, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--ink);
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.field-input::placeholder {
  color: var(--muted);
  text-transform: none;
  letter-spacing: 0;
}

.list-search input:focus,
.field-input:focus {
  border-color: rgba(42, 171, 238, 0.7);
  box-shadow: 0 0 0 3px rgba(42, 171, 238, 0.18),
    inset 0 0 0 1px rgba(42, 171, 238, 0.35);
}

.list-items {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
  padding-right: 4px;
}

.list-items button {
  display: flex;
  align-items: center;
  background: rgba(18, 22, 30, 0.96);
  border: 1px solid transparent;
  color: var(--ink);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  text-align: left;
  cursor: pointer;
  transition: 0.2s ease;
}

.list-items button:hover,
.list-items button.is-active {
  border-color: rgba(42, 171, 238, 0.45);
  background: rgba(42, 171, 238, 0.1);
}

.list-items .rarity {
  font-size: 12px;
  color: var(--muted);
  margin-left: 6px;
}

.gift-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(18, 22, 30, 0.96);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  color: var(--ink);
  transition: 0.2s ease;
  text-align: left;
}

.gift-item:hover,
.gift-item.is-active {
  border-color: rgba(42, 171, 238, 0.45);
  background: rgba(42, 171, 238, 0.1);
}

.gift-item img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  object-fit: contain;
  background: var(--panel-3);
  border: 1px solid var(--stroke);
}

@media (max-width: 680px) {
  .topbar {
    width: 92vw;
    top: 12px;
  }

  .topnav {
    flex-wrap: wrap;
  }

  .controls {
    grid-template-columns: 1fr;
  }
}
