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

:root {
  --bg-top: #edf4ff;
  --bg-bottom: #c9d8f2;
  --glass-border: rgba(255, 255, 255, 0.42);
  --text: #142033;
  --text-muted: rgba(20, 32, 51, 0.72);
  --shadow-soft: 0 18px 60px rgba(34, 55, 88, 0.16);
  --shadow-card: 0 10px 30px rgba(28, 44, 72, 0.16);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --blur: 26px;
}

body.theme-dark {
  --bg-top: #0d1322;
  --bg-bottom: #1b2741;
  --glass-border: rgba(255, 255, 255, 0.14);
  --text: #eef4ff;
  --text-muted: rgba(238, 244, 255, 0.72);
  --shadow-soft: 0 20px 64px rgba(0, 0, 0, 0.34);
  --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
}

body.theme-dark {
  color-scheme: dark;
}

body {
  position: relative;
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), transparent 28%),
    radial-gradient(circle at top right, rgba(164, 196, 255, 0.55), transparent 24%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
  transition:
    background 320ms ease,
    color 220ms ease;
}

body.theme-dark {
  background:
    radial-gradient(circle at top left, rgba(130, 150, 255, 0.14), transparent 26%),
    radial-gradient(circle at top right, rgba(112, 214, 255, 0.12), transparent 22%),
    linear-gradient(180deg, var(--bg-top) 0%, var(--bg-bottom) 100%);
}

body.modal-open {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.04));
  transition: background 320ms ease;
}

body.theme-dark::before {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

button,
select,
input {
  font: inherit;
}

.container {
  position: relative;
  z-index: 1;
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0 56px;
}

.bg-orb {
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  filter: blur(12px);
  pointer-events: none;
  opacity: 0.9;
  transition:
    background 320ms ease,
    opacity 320ms ease,
    transform 320ms ease;
}

.bg-orb--violet {
  top: -80px;
  right: -40px;
  width: 280px;
  height: 280px;
  background: radial-gradient(circle, rgba(204, 188, 255, 0.95), rgba(204, 188, 255, 0.1) 70%);
}

.bg-orb--blue {
  left: -60px;
  bottom: 10%;
  width: 260px;
  height: 260px;
  background: radial-gradient(circle, rgba(142, 215, 255, 0.85), rgba(142, 215, 255, 0.08) 70%);
}

body.theme-dark .bg-orb--violet {
  background: radial-gradient(circle, rgba(122, 107, 219, 0.5), rgba(122, 107, 219, 0.06) 70%);
  transform: scale(1.03);
}

body.theme-dark .bg-orb--blue {
  background: radial-gradient(circle, rgba(82, 176, 255, 0.35), rgba(82, 176, 255, 0.04) 70%);
  transform: scale(0.97);
}

.glass-panel {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.44), rgba(255, 255, 255, 0.24));
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(var(--blur)) saturate(180%);
  -webkit-backdrop-filter: blur(var(--blur)) saturate(180%);
  transition:
    background 280ms ease,
    border-color 280ms ease,
    box-shadow 280ms ease,
    transform 180ms ease,
    color 220ms ease;
}

body.theme-dark .glass-panel {
  background: linear-gradient(180deg, rgba(26, 35, 59, 0.55), rgba(18, 26, 44, 0.38));
}

.hero,
.controls,
.character,
.empty-state,
.character-modal__dialog {
  border-radius: var(--radius-xl);
}

.hero {
  padding: 28px 28px 30px;
  margin-bottom: 18px;
}

.hero__topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 10px;
}

.eyebrow {
  margin: 0;
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(20, 32, 51, 0.55);
  transition: color 220ms ease;
}

body.theme-dark .eyebrow {
  color: rgba(238, 244, 255, 0.55);
}

.theme-toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  width: 128px;
  min-height: 48px;
  padding: 4px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.3));
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 20px rgba(62, 89, 138, 0.12);
  backdrop-filter: blur(18px) saturate(180%);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  overflow: hidden;
  transition:
    background 280ms ease,
    border-color 280ms ease,
    box-shadow 280ms ease,
    transform 180ms ease,
    color 220ms ease;
}

body.theme-dark .theme-toggle {
  border-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(41, 56, 89, 0.72), rgba(24, 35, 58, 0.45));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.2);
}

.theme-toggle::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: calc(50% - 4px);
  height: calc(100% - 8px);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.62));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 8px 18px rgba(77, 103, 150, 0.2);
  transition:
    transform 280ms cubic-bezier(0.16, 1, 0.3, 1),
    background 280ms ease,
    box-shadow 280ms ease;
}

body.theme-dark .theme-toggle::before {
  transform: translateX(100%);
  background: linear-gradient(180deg, rgba(134, 172, 255, 0.9), rgba(88, 129, 224, 0.72));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    0 8px 18px rgba(23, 31, 54, 0.34);
}

.theme-toggle:focus-visible,
#searchBar:focus,
.filter-chip:focus-visible,
.sort-select:focus-visible,
.character:focus-visible,
.character-modal__close:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 4px rgba(122, 170, 255, 0.18),
    0 12px 30px rgba(79, 112, 173, 0.18);
}

.theme-toggle__emoji,
.theme-toggle__label {
  position: relative;
  z-index: 1;
  transition:
    transform 280ms cubic-bezier(0.16, 1, 0.3, 1),
    opacity 200ms ease,
    color 220ms ease;
}

.theme-toggle__emoji {
  width: 40px;
  text-align: center;
  font-size: 1rem;
  line-height: 1;
}

.theme-toggle__label {
  font-size: 0.95rem;
}

body.theme-dark .theme-toggle__emoji,
body.theme-dark .theme-toggle__label {
  transform: translateX(30px);
}

h1 {
  margin: 0;
  font-size: clamp(2.25rem, 6vw, 4.5rem);
  line-height: 0.98;
  letter-spacing: -0.05em;
  font-weight: 800;
}

.controls {
  padding: 14px;
  margin-bottom: 18px;
}

#searchWrapper {
  position: relative;
}

.controls__toolbar {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-top: 14px;
}

.search-icon {
  position: absolute;
  left: 18px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.1rem;
  color: rgba(20, 32, 51, 0.45);
  transition: color 220ms ease;
}

body.theme-dark .search-icon {
  color: rgba(238, 244, 255, 0.48);
}

#searchBar {
  width: 100%;
  min-height: 62px;
  padding: 0 20px 0 48px;
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0.38));
  color: var(--text);
  font-size: 1rem;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.7),
    0 8px 24px rgba(79, 112, 173, 0.12);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition:
    background 280ms ease,
    border-color 280ms ease,
    box-shadow 280ms ease,
    color 220ms ease;
}

body.theme-dark #searchBar {
  border-color: rgba(255, 255, 255, 0.16);
  background: linear-gradient(180deg, rgba(29, 40, 67, 0.8), rgba(21, 31, 51, 0.48));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 8px 24px rgba(0, 0, 0, 0.2);
}

#searchBar::placeholder {
  color: rgba(20, 32, 51, 0.46);
}

body.theme-dark #searchBar::placeholder {
  color: rgba(238, 244, 255, 0.42);
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  flex: 1;
}

.filter-chip,
.sort-select {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.56), rgba(255, 255, 255, 0.24));
  color: var(--text);
  font-size: 0.94rem;
  font-weight: 600;
  box-shadow: 0 8px 20px rgba(79, 112, 173, 0.08);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  transition:
    transform 180ms ease,
    background 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease,
    color 220ms ease;
}

.filter-chip {
  cursor: pointer;
}

.filter-chip:hover,
.sort-group:hover .sort-select {
  transform: translateY(-1px);
}

.filter-chip.is-active {
  background: linear-gradient(180deg, rgba(132, 177, 255, 0.9), rgba(95, 141, 228, 0.72));
  border-color: rgba(101, 149, 237, 0.75);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(74, 111, 198, 0.22);
}

body.theme-dark .filter-chip,
body.theme-dark .sort-select {
  border-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(34, 47, 76, 0.78), rgba(23, 33, 54, 0.48));
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.16);
}

body.theme-dark .filter-chip.is-active {
  background: linear-gradient(180deg, rgba(136, 173, 255, 0.9), rgba(88, 130, 224, 0.74));
  border-color: rgba(151, 186, 255, 0.55);
  color: #f7fbff;
}

.sort-group {
  position: relative;
  min-width: 210px;
}

.sort-group::after {
  content: "▾";
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
  pointer-events: none;
  color: rgba(20, 32, 51, 0.58);
  font-size: 0.9rem;
  transition: color 220ms ease;
}

body.theme-dark .sort-group::after {
  color: rgba(238, 244, 255, 0.62);
}

.sort-select {
  width: 100%;
  padding-right: 38px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
}

.status {
  min-height: 1.4rem;
  margin: 12px 4px 0;
  font-size: 0.94rem;
  color: var(--text-muted);
  transition: color 220ms ease;
}

#charactersList {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}

.character,
.empty-state {
  position: relative;
  overflow: hidden;
  width: 100%;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.56), rgba(255, 255, 255, 0.3));
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  transition:
    background 280ms ease,
    border-color 280ms ease,
    box-shadow 280ms ease,
    transform 180ms ease,
    color 220ms ease;
}

.character {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: center;
  text-align: left;
  cursor: default;
}

.character--interactive {
  cursor: pointer;
}

body.theme-dark .character,
body.theme-dark .empty-state {
  border-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(27, 38, 63, 0.7), rgba(18, 26, 44, 0.46));
}

.character::before,
.empty-state::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.32), transparent 38%);
  pointer-events: none;
  transition: background 280ms ease;
}

body.theme-dark .character::before,
body.theme-dark .empty-state::before {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), transparent 38%);
}

.character__content {
  position: relative;
  z-index: 1;
  min-width: 0;
}

.character h2 {
  margin: 0 0 8px;
  font-size: 1.15rem;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.character p {
  margin: 0;
  font-size: 0.95rem;
  color: var(--text-muted);
  transition: color 220ms ease;
}

.character__hint {
  display: inline-block;
  margin-top: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  color: rgba(20, 32, 51, 0.58);
}

body.theme-dark .character__hint {
  color: rgba(238, 244, 255, 0.58);
}

.character img {
  position: relative;
  z-index: 1;
  width: 82px;
  height: 104px;
  object-fit: cover;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.35);
  box-shadow: 0 8px 18px rgba(44, 66, 102, 0.18);
  transition:
    border-color 280ms ease,
    background 280ms ease,
    box-shadow 280ms ease;
}

body.theme-dark .character img {
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.2);
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-muted);
}

.character-modal[hidden] {
  display: none !important;
}

.character-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
}

.character-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(10, 18, 32, 0.44);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.character-modal__dialog {
  position: relative;
  z-index: 1;
  width: min(720px, 100%);
  max-height: min(90vh, 820px);
  overflow: auto;
  padding: 28px;
}

.character-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0.24));
  color: var(--text);
  cursor: pointer;
}

body.theme-dark .character-modal__close {
  border-color: rgba(255, 255, 255, 0.14);
  background: linear-gradient(180deg, rgba(34, 47, 76, 0.78), rgba(23, 33, 54, 0.48));
}

.character-modal__header {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 18px;
  align-items: start;
  margin-bottom: 20px;
}

.character-modal__header h2 {
  margin: 6px 0 8px;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  line-height: 1.02;
}

.character-modal__subtitle {
  margin: 0;
  color: var(--text-muted);
}

.character-modal__image {
  width: 160px;
  height: 200px;
  object-fit: cover;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.character-modal__details {
  display: grid;
  gap: 10px;
  margin: 0;
}

.character-modal__detail {
  padding: 14px 16px;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.4), rgba(255, 255, 255, 0.18));
}

body.theme-dark .character-modal__detail {
  border-color: rgba(255, 255, 255, 0.12);
  background: linear-gradient(180deg, rgba(27, 38, 63, 0.62), rgba(18, 26, 44, 0.36));
}

.character-modal__detail dt {
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(20, 32, 51, 0.56);
}

body.theme-dark .character-modal__detail dt {
  color: rgba(238, 244, 255, 0.58);
}

.character-modal__list {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 8px;
}

.character-modal__list li {
  color: inherit;
}

.character-modal__list strong {
  color: var(--text);
}

  font-style: normal;
  font-weight: 600;
  color: rgba(20, 32, 51, 0.55);
  transition: color 220ms ease;
}

body.theme-dark .italics {
  color: rgba(238, 244, 255, 0.54);
}

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

@media (hover: hover) {
  .character:hover,
  .theme-toggle:hover,
  .filter-chip:hover,
  .sort-group:hover .sort-select,
  .character-modal__close:hover {
    transform: translateY(-2px);
  }

  .character:hover {
    box-shadow: 0 14px 34px rgba(28, 44, 72, 0.18);
  }
}

@media (max-width: 760px) {
  .controls__toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .sort-group {
    min-width: 0;
  }

  .character-modal__header {
    grid-template-columns: 1fr;
  }

  .character-modal__image {
    width: 100%;
    max-width: 220px;
    height: 220px;
  }
}

@media (max-width: 680px) {
  .container {
    width: min(100% - 20px, 1100px);
    padding: 18px 0 32px;
  }

  .hero {
    padding: 22px 20px 24px;
  }

  .hero__topbar {
    flex-wrap: wrap;
    align-items: flex-start;
  }

  .controls {
    padding: 12px;
  }

  .quick-filters {
    gap: 8px;
  }

  .character {
    grid-template-columns: 1fr;
    align-items: start;
  }

  .character img {
    width: 100%;
    max-width: 180px;
    height: 180px;
  }

  .character-modal__dialog {
    padding: 22px 18px;
  }

  .bg-orb--violet {
    width: 180px;
    height: 180px;
  }

  .bg-orb--blue {
    width: 150px;
    height: 150px;
  }
}
