* {
  box-sizing: border-box;
}

:root {
  --dynamic-vh: 1vh;
}

body {
  margin: 0;
  font-family: "Inter", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, #f4fbff 0%, #c9e6ff 35%, #7cb2ff 75%, #5f8dff 100%),
    radial-gradient(ellipse at 20% 30%, rgba(255, 255, 255, 0.8), rgba(255, 255, 255, 0) 55%),
    radial-gradient(ellipse at 70% 22%, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0) 50%),
    radial-gradient(ellipse at 40% 60%, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 48%),
    radial-gradient(ellipse at 80% 68%, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 52%);
  color: #fff;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
  background-blend-mode: screen, normal;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.32) 0, rgba(255, 255, 255, 0) 40%),
    radial-gradient(circle at 75% 18%, rgba(255, 255, 255, 0.28) 0, rgba(255, 255, 255, 0) 44%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0));
  opacity: 0.55;
  pointer-events: none;
}

body.overlay-open {
  overflow: hidden;
}

.welcome-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 500;
  background: rgba(9, 16, 30, 0.55);
  backdrop-filter: blur(6px);
}

.welcome-overlay[aria-hidden="true"] {
  display: none;
}

.welcome-overlay__backdrop {
  position: absolute;
  inset: 0;
  border-radius: 0;
}

.welcome-overlay__panel {
  position: relative;
  width: min(92vw, 520px);
  max-height: min(88vh, 680px);
  background: rgba(26, 36, 74, 0.92);
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 32px 70px rgba(3, 10, 38, 0.55);
  padding: 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
  color: #fff;
}

.welcome-overlay__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.welcome-overlay__header h1 {
  margin: 0;
  font-size: 1.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.welcome-overlay__header .ghost-button {
  padding: 0.3rem 0.65rem;
  font-size: 1.2rem;
  line-height: 1;
}

.welcome-overlay__content {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  font-size: 0.98rem;
  line-height: 1.6;
}

.welcome-overlay__content p {
  margin: 0;
}

.welcome-overlay__list {
  margin: 0;
  padding-left: 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.welcome-overlay__list li {
  padding-left: 0.2rem;
}

.welcome-overlay__footer {
  display: flex;
  justify-content: center;
}

.welcome-overlay__footer .primary-button {
  min-width: 160px;
}

.app {
  width: min(100%, 420px);
  height: min(100vh, 720px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 1.2rem;
  position: relative;
}

@media (max-width: 640px) {
  .app {
    gap: 0.6rem;
  }
}


.filter-bar {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  z-index: 200;
}

.filter-bar__toggles {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

.control-toggle {
  appearance: none;
  border: 1px solid rgba(12, 20, 40, 0.15);
  background: #fff;
  color: #101524;
  padding: 0.65rem 1.05rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.control-toggle:hover,
.control-toggle:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(16, 21, 36, 0.18);
  border-color: rgba(12, 20, 40, 0.25);
  outline: none;
}

.control-toggle__chevron {
  width: 0.75rem;
  height: 0.75rem;
  border-right: 2px solid rgba(16, 21, 36, 0.75);
  border-bottom: 2px solid rgba(16, 21, 36, 0.75);
  transform: rotate(45deg);
  transition: transform 0.25s ease;
}

.control-toggle__icon {
  width: 0.95rem;
  height: 0.95rem;
  border-radius: 50%;
  background: conic-gradient(#4f8bff 0deg 120deg, #ff6fb5 120deg 240deg, #ff4f5e 240deg 360deg);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.control-toggle--help {
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  justify-content: center;
}

.control-toggle__help-icon {
  font-weight: 700;
  font-size: 1.25rem;
  line-height: 1;
  color: #101524;
}

.control-toggle--open .control-toggle__chevron {
  transform: rotate(-135deg);
}

.control-toggle--open {
  box-shadow: 0 12px 28px rgba(16, 21, 36, 0.2);
  border-color: rgba(12, 20, 40, 0.32);
}

.control-panel {
  background: rgba(26, 36, 74, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 16px;
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-6px);
  transition: max-height 0.28s ease, opacity 0.28s ease, transform 0.28s ease;
}

.control-panel--open {
  max-height: 420px;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.control-panel__content {
  padding: 0.8rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: center;
}

.control-panel--settings .control-panel__content {
  flex-direction: column;
  align-items: stretch;
}

.control-panel--settings .ghost-button {
  width: 100%;
  justify-content: center;
}

.control-panel--categories .control-panel__content {
  justify-content: center;
}

.filter-button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
}

.filter-button.active {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}


.filter-reset {
  margin-top: 0.3rem;
  border-color: rgba(255, 79, 94, 0.35);
  color: #ffe5e9;
}

.filter-reset:hover,
.filter-reset:focus-visible {
  background: rgba(255, 79, 94, 0.18);
  border-color: rgba(255, 79, 94, 0.55);
}

.ghost-button,
.primary-button {
  appearance: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease, border-color 0.2s ease;
}

.ghost-button {
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  padding: 0.45rem 0.75rem;
}

.ghost-button:hover,
.ghost-button:focus-visible {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
  outline: none;
}

.ghost-button--danger {
  border-color: rgba(255, 79, 94, 0.35);
  color: #ff9ea8;
}

.ghost-button--danger:hover,
.ghost-button--danger:focus-visible {
  background: rgba(255, 79, 94, 0.12);
  border-color: rgba(255, 79, 94, 0.55);
}

.ghost-button--accent {
  border-color: rgba(123, 178, 255, 0.45);
  color: #dbe8ff;
}

.ghost-button--accent:hover,
.ghost-button--accent:focus-visible {
  background: rgba(123, 178, 255, 0.2);
  border-color: rgba(123, 178, 255, 0.6);
}

.ghost-button--file {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.primary-button {
  border: none;
  background: linear-gradient(135deg, #4f8bff, #a06bff);
  color: #fff;
  padding: 0.5rem 1rem;
  box-shadow: 0 10px 20px rgba(160, 107, 255, 0.25);
}

.primary-button:hover,
.primary-button:focus-visible {
  transform: translateY(-1px);
  outline: none;
}



.custom-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.custom-form__rows {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.custom-form__row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 140px auto;
  gap: 0.5rem;
  align-items: center;
}

.custom-form__row input,
.custom-form__row select {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(8, 8, 18, 0.5);
  color: #fff;
  font-size: 0.9rem;
}

.custom-form__row button {
  justify-self: end;
}

.custom-form__controls {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.custom-form__hint {
  margin: 0;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
}

#customFormError {
  color: #ffb3b3;
}

#customFormError.custom-form__hint--success {
  color: #9affc7;
}

@media (max-width: 420px) {
  .custom-form__row {
    grid-template-columns: minmax(0, 1fr);
  }

  .custom-form__row select,
  .custom-form__row button {
    width: 100%;
  }

  .custom-form__controls {
    flex-direction: column;
    align-items: stretch;
  }

  .custom-manager__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .custom-manager__actions {
    width: 100%;
    justify-content: flex-start;
  }
}

.custom-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 400;
}

.custom-overlay[aria-hidden="false"] {
  display: flex;
}

.custom-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 15, 28, 0.65);
  backdrop-filter: blur(6px);
}

.custom-overlay__panel {
  position: relative;
  width: min(92vw, 520px);
  max-height: min(85vh, 680px);
  background: rgba(24, 32, 68, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 20px;
  box-shadow: 0 28px 60px rgba(0, 0, 0, 0.45);
  padding: 1.2rem 1.4rem;
  color: #fff;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
}

.custom-overlay__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.custom-overlay__header h2 {
  margin: 0;
  font-size: 1.3rem;
}

.custom-overlay__header .ghost-button {
  padding: 0.3rem 0.6rem;
  font-size: 1.1rem;
  line-height: 1;
}

.custom-overlay__content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow: hidden;
}

.custom-overlay__content form {
  overflow: hidden;
}

.custom-form__rows {
  max-height: min(50vh, 380px);
  overflow-y: auto;
  padding-right: 0.4rem;
}

.custom-overlay__actions {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.mix-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.9rem;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 0.6rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.mix-toggle input {
  width: 1rem;
  height: 1rem;
}

.filter-chip {
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.1);
}

.filter-chip--multi {
  background: linear-gradient(135deg, #4f8bff, #a06bff);
}

.filter-chip--general {
  background: linear-gradient(135deg, #4f8bff, #0065ff);
}

.filter-chip--personal {
  background: linear-gradient(135deg, #ff6fb5, #ff3e9d);
}

.filter-chip--intimate {
  background: linear-gradient(135deg, #ff4f5e, #ff1d43);
}

.filter-chip--ab-specific {
  background: linear-gradient(135deg, #b46cff, #6f3bff);
}

.card-stack {
  position: relative;
  width: min(90vw, 360px);
  height: min(70vh, 520px);
  height: min(calc(var(--dynamic-vh, 1vh) * 70), 520px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.card {
  position: absolute;
  inset: 0;
  border-radius: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.4rem, 5vw, 2.3rem);
  text-align: center;
  padding: 1.5rem;
  color: #fff;
  user-select: none;
  touch-action: none;
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.35);
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.card::after {
  content: attr(data-label);
  position: absolute;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.9rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  opacity: 0.8;
}

.card--general {
  background: linear-gradient(135deg, #4f8bff, #0065ff);
}

.card--personal {
  background: linear-gradient(135deg, #ff6fb5, #ff3e9d);
}

.card--intimate {
  background: linear-gradient(135deg, #ff4f5e, #ff1d43);
}

.card--ab-specific {
  background: linear-gradient(135deg, #b46cff, #6f3bff);
}

.card--depth-accent {
  box-shadow: 0 18px 40px rgba(160, 107, 255, 0.35);
}

.loading,
.error {
  position: absolute;
  top: 58%;
  transform: translateY(-50%);
  text-align: center;
  font-size: 1.125rem;
  opacity: 0.8;
}

.error {
  color: #ffb3b3;
}

.hidden {
  display: none;
}
