* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  font-family: 'IBM Plex Sans', 'Segoe UI', sans-serif;
  color: #e7e9ea;
  background-color: #0f1419;
  overflow: hidden;
}

.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-image: radial-gradient(circle, #2f3336 1px, transparent 1px);
  background-size: 18px 18px;
  opacity: 0.5;
  animation:
    bg-grid-drift 100s linear infinite,
    bg-grid-pulse 10s ease-in-out infinite;
}

.cursor-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.5s ease;
  background: radial-gradient(
    circle 360px at var(--glow-x, 50%) var(--glow-y, 50%),
    rgba(29, 155, 240, 0.028) 0%,
    rgba(29, 155, 240, 0.01) 45%,
    transparent 75%
  );
}

body.is-cursor-glow-active .cursor-glow {
  opacity: 0.55;
}

.bg-decor {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-decor-coin {
  position: absolute;
  opacity: 0.22;
  transform: translate(-50%, -50%) translate(var(--shift-x, 0), var(--shift-y, 0))
    rotate(var(--slot-rotate, 0deg));
  will-change: transform;
}

.bg-decor-coin--btc {
  left: 9%;
  top: 27%;
  width: 58px;
  height: 58px;
  --slot-rotate: 7deg;
}

.bg-decor-coin--eth {
  left: 74%;
  top: 10%;
  width: 38px;
  height: 38px;
  --slot-rotate: -15deg;
}

.bg-decor-coin--avax {
  left: 93%;
  top: 66%;
  width: 48px;
  height: 48px;
  --slot-rotate: 4deg;
}

@media (max-width: 640px) {
  .bg-decor {
    display: none;
  }
}

.page {
  position: relative;
  z-index: 1;
  height: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 24px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.cards-grid {
  width: 100%;
  height: 100%;
  max-height: 640px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 42px;
}

.coin-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 12px;
  text-align: center;
  background: #1a1f26;
  border: 1px solid #2f3336;
  border-radius: 24px;
  min-height: 0;
  transition:
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.22s ease,
    box-shadow 0.22s ease,
    background-color 0.22s ease;
}

.coin-card:not(.coin-card--empty):hover {
  transform: translateY(-3px);
  border-color: #4a5568;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.32);
}

.coin-card--empty {
  border-style: dashed;
  border-color: #3d4450;
  background: #151a20;
  transition:
    border-color 0.22s ease,
    background-color 0.22s ease,
    box-shadow 0.22s ease;
}

.coin-card--empty:hover {
  border-color: #5c6b7a;
  background: #181e26;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.card-menu-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #8b98a5;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  transition: background 0.15s ease, color 0.15s ease;
}

.card-menu-btn span {
  display: block;
  width: 14px;
  height: 2px;
  border-radius: 1px;
  background: currentColor;
}

.card-menu-btn:hover,
.card-menu-btn:focus-visible {
  background: #2f3336;
  color: #e7e9ea;
  outline: none;
}

.card-menu {
  position: absolute;
  top: 44px;
  right: 10px;
  min-width: 132px;
  padding: 6px;
  border-radius: 12px;
  background: #232a33;
  border: 1px solid #3d4450;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  display: none;
  flex-direction: column;
  gap: 2px;
  z-index: 5;
}

.card-menu.is-open {
  display: flex;
}

.card-menu-item {
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #e7e9ea;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.card-menu-item:hover,
.card-menu-item:focus-visible {
  background: #2f3336;
  outline: none;
}

.card-menu-item--danger {
  color: #ff8a80;
}

.slot-add-btn {
  position: relative;
  width: 72px;
  height: 72px;
  border: none;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  color: #1d9bf0;
  padding: 0;
}

.slot-add-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid #2f3336;
  animation: slot-add-pulse 2.4s ease-in-out infinite;
}

.slot-add-plus {
  position: relative;
  font-size: 40px;
  font-weight: 600;
  line-height: 1;
  animation: slot-add-breathe 2.4s ease-in-out infinite;
}

.slot-add-btn:hover .slot-add-ring,
.slot-add-btn:focus-visible .slot-add-ring {
  border-color: #1d9bf0;
}

.slot-add-btn:hover .slot-add-plus,
.slot-add-btn:focus-visible .slot-add-plus {
  color: #6ec8ff;
}

.slot-add-btn:focus-visible {
  outline: 2px solid #1d9bf0;
  outline-offset: 4px;
}

@keyframes slot-add-pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.85;
  }
  50% {
    transform: scale(1.06);
    opacity: 1;
  }
}

@keyframes slot-add-breathe {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.08);
  }
}

.modal {
  padding: 0;
  border: none;
  background: transparent;
  max-width: calc(100vw - 32px);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.62);
  animation: backdrop-in 0.28s ease forwards;
}

.modal[open] .modal-panel {
  animation: modal-panel-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.modal-panel {
  width: min(420px, calc(100vw - 32px));
  padding: 20px;
  border-radius: 20px;
  background: #1a1f26;
  border: 1px solid #2f3336;
  color: #e7e9ea;
  transform-origin: center center;
}

.info-panel {
  width: min(480px, calc(100vw - 32px));
}

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

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

.modal-close {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: #2f3336;
  color: #e7e9ea;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover,
.modal-close:focus-visible {
  background: #3d4450;
  outline: none;
}

.search-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #8b98a5;
  margin-bottom: 8px;
}

.search-row {
  display: flex;
  gap: 8px;
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #3d4450;
  background: #0f1419;
  color: #e7e9ea;
  font: inherit;
  font-size: 15px;
  text-transform: uppercase;
}

.search-input:focus {
  outline: 2px solid #1d9bf0;
  outline-offset: 0;
  border-color: #1d9bf0;
}

.search-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: #6e767d;
}

.search-status {
  margin: 12px 0 0;
  font-size: 13px;
  color: #8b98a5;
}

.search-status.is-error {
  color: #ff8a80;
}

.search-preview {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #2f3336;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.search-preview.is-revealed {
  animation: search-preview-in 0.38s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.search-preview.is-revealed .search-preview-icon {
  animation: preview-icon-pop 0.45s cubic-bezier(0.34, 1.4, 0.64, 1) 0.06s both;
}

.search-preview.is-revealed .search-preview-text,
.search-preview.is-revealed #search-attach-btn {
  animation: search-preview-fade-up 0.35s cubic-bezier(0.22, 1, 0.36, 1) 0.1s both;
}

.search-preview-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  object-fit: contain;
}

.search-preview-text {
  flex: 1;
  min-width: 120px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.search-preview-pair {
  font-weight: 600;
}

.search-preview-price {
  font-size: 18px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.btn-primary {
  padding: 10px 14px;
  border: none;
  border-radius: 10px;
  background: #1d9bf0;
  color: #fff;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.btn-primary:hover,
.btn-primary:focus-visible {
  background: #1a8cd8;
  outline: none;
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#search-attach-btn {
  width: 100%;
}

.info-pair {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 600;
}

.info-average {
  margin: 0 0 14px;
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.provider-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.provider-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
  border-radius: 10px;
  background: #0f1419;
  font-variant-numeric: tabular-nums;
}

.provider-list li.provider-row--missing {
  background: #12161c;
  border: 1px solid #252b33;
}

.provider-name {
  font-size: 13px;
  font-weight: 600;
  color: #8b98a5;
}

.provider-price {
  font-size: 14px;
  font-weight: 700;
}

.provider-price.is-missing {
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: normal;
  color: #8b98a5;
  font-style: italic;
}

.info-summary,
.info-errors {
  margin: 12px 0 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #8b98a5;
  line-height: 1.4;
  background: #151a20;
  border: 1px solid #2f3336;
}

.info-meta {
  margin: 12px 0 0;
  font-size: 12px;
  color: #6e767d;
}

.coin-icon {
  width: 58%;
  max-width: 88px;
  min-width: 56px;
  aspect-ratio: 1;
  border-radius: 50%;
  object-fit: contain;
  transition: transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

.coin-card:not(.coin-card--empty):hover .coin-icon {
  transform: scale(1.05);
}

.coin-pair {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #e7e9ea;
}

.price {
  margin: 0;
  font-size: 21px;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: #ffffff;
}

.price.up {
  color: #00c853;
}

.price.down {
  color: #ff5252;
}

/* 4K / великі монітори */
@media (min-width: 1600px) {
  .page {
    max-width: 1280px;
    padding: 32px 48px;
  }

  .cards-grid {
    gap: 52px;
    max-height: 760px;
  }

  .coin-card {
    padding: 20px 16px;
    border-radius: 28px;
  }

  .coin-icon {
    max-width: 104px;
  }

  .coin-pair {
    font-size: 17px;
  }

  .price {
    font-size: 24px;
  }
}

@media (min-width: 2000px) {
  .page {
    max-width: 1480px;
  }

  .cards-grid {
    gap: 56px;
    max-height: 840px;
  }

  .coin-icon {
    max-width: 112px;
  }

  .price {
    font-size: 26px;
  }
}

/* Планшет */
@media (max-width: 1024px) {
  .page {
    max-width: 100%;
    padding: 20px 24px;
  }

  .cards-grid {
    gap: 32px;
    max-height: 580px;
  }

  .coin-icon {
    max-width: 80px;
  }

  .coin-pair {
    font-size: 14px;
  }

  .price {
    font-size: 19px;
  }
}

/* Телефон */
@media (max-width: 640px) {
  body {
    overflow: auto;
  }

  .page {
    height: auto;
    min-height: 100%;
    padding: 16px 14px;
  }

  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, auto);
    gap: 14px;
    height: auto;
    max-height: none;
  }

  .coin-card {
    gap: 6px;
    padding: 14px 10px;
    border-radius: 20px;
  }

  .coin-icon {
    width: 54%;
    max-width: 64px;
    min-width: 44px;
  }

  .coin-pair {
    font-size: 13px;
  }

  .price {
    font-size: 17px;
  }
}

@media (max-width: 380px) {
  .cards-grid {
    gap: 10px;
  }

  .coin-card {
    padding: 12px 8px;
  }

  .coin-icon {
    max-width: 56px;
  }

  .price {
    font-size: 16px;
  }
}

/* Низький екран ноутбука (висота) */
@media (max-height: 720px) {
  .page {
    padding: 12px 16px;
  }

  .cards-grid {
    gap: 28px;
    max-height: 520px;
  }

  .coin-card {
    gap: 5px;
    padding: 12px 8px;
    border-radius: 20px;
  }

  .coin-icon {
    max-width: 72px;
    min-width: 48px;
  }

  .coin-pair {
    font-size: 13px;
  }

  .price {
    font-size: 17px;
  }
}

@keyframes bg-grid-drift {
  0% {
    background-position: 0 0;
  }
  100% {
    background-position: 18px 18px;
  }
}

@keyframes bg-grid-pulse {
  0%,
  100% {
    opacity: 0.42;
  }
  50% {
    opacity: 0.58;
  }
}

@keyframes backdrop-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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

@keyframes search-preview-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes search-preview-fade-up {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes preview-icon-pop {
  from {
    opacity: 0;
    transform: scale(0.82);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .bg-grid {
    animation: none;
    opacity: 0.5;
  }

  .cursor-glow {
    opacity: 0.2;
    transition: none;
    background: radial-gradient(
      circle 420px at 50% 42%,
      rgba(29, 155, 240, 0.018) 0%,
      transparent 65%
    );
  }

  .bg-decor-coin {
    transform: translate(-50%, -50%) rotate(var(--slot-rotate, 0deg));
  }

  .coin-card,
  .coin-card--empty,
  .coin-icon {
    transition: none;
  }

  .coin-card:not(.coin-card--empty):hover,
  .coin-card--empty:hover {
    transform: none;
  }

  .coin-card:not(.coin-card--empty):hover .coin-icon {
    transform: none;
  }

  .modal::backdrop,
  .modal[open] .modal-panel,
  .search-preview.is-revealed,
  .search-preview.is-revealed .search-preview-icon,
  .search-preview.is-revealed .search-preview-text,
  .search-preview.is-revealed #search-attach-btn {
    animation: none;
  }

  .slot-add-ring,
  .slot-add-plus {
    animation: none;
  }
}
