.cookie-card,
.cookie-toggle {
  position: fixed;
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: max(16px, env(safe-area-inset-bottom, 0px));
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: rgba(255, 255, 255, 0.82);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.8) inset,
    0 1px 2px rgba(28, 25, 23, 0.05),
    0 16px 40px -24px rgba(28, 25, 23, 0.25);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  backdrop-filter: blur(28px) saturate(160%);
  color: #1c1917;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}

.cookie-card {
  bottom: calc(max(16px, env(safe-area-inset-bottom, 0px)) + 40px);
  width: min(20rem, calc(100% - 32px));
  padding: 14px 16px 16px;
  border-radius: 12px;
  font-size: 11px;
  line-height: 1.5;
  animation: cookie-in 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
  transform-origin: bottom right;
}

.cookie-card.is-closing {
  animation: cookie-out 0.16s ease-in forwards;
  pointer-events: none;
}

@keyframes cookie-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes cookie-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

.cookie-card[hidden] {
  display: none;
}

.cookie-title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.cookie-text {
  margin: 0;
  color: #57534e;
}

.cookie-text a {
  color: inherit;
}

.cookie-options {
  list-style: none;
  margin: 0;
  padding: 0;
}

.cookie-options li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid rgba(28, 25, 23, 0.08);
}

.cookie-options li:first-child {
  border-top: 0;
}

.cookie-option {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.cookie-name {
  font-weight: 500;
}

.cookie-desc,
.cookie-state {
  color: #78716c;
}

.cookie-state {
  font-size: 10px;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.cookie-switch {
  appearance: none;
  -webkit-appearance: none;
  flex: none;
  width: 30px;
  height: 18px;
  margin: 0;
  border-radius: 9px;
  background: rgba(28, 25, 23, 0.18);
  position: relative;
  cursor: pointer;
  transition: background 0.15s ease;
}

.cookie-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgba(28, 25, 23, 0.2);
  transition: transform 0.15s ease;
}

.cookie-switch:checked {
  background: #1c1917;
}

.cookie-switch:checked::after {
  transform: translateX(12px);
}

.cookie-actions {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.cookie-actions button {
  font: inherit;
  font-size: 10px;
  letter-spacing: 0.04em;
  padding: 6px 4px;
  border: 1px solid rgba(28, 25, 23, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  color: #1c1917;
  cursor: pointer;
  white-space: nowrap;
}

.cookie-actions button:hover {
  background: #fff;
}

.cookie-actions button.primary {
  border-color: #1c1917;
  background: #1c1917;
  color: #f5f5f4;
}

.cookie-actions button.primary:hover {
  background: #292524;
}

.cookie-toggle {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 50%;
  color: #78716c;
  cursor: pointer;
}

.cookie-toggle:hover,
.cookie-toggle[aria-expanded="true"] {
  color: #1c1917;
}

.cookie-actions button:focus-visible,
.cookie-switch:focus-visible,
.cookie-toggle:focus-visible {
  outline: 2px solid #1c1917;
  outline-offset: 2px;
}

/* On phones the home footer reaches the corner, so the button and card sit above it. */
@media (max-width: 640px) {
  .cookie-toggle {
    bottom: 72px;
  }

  .cookie-card {
    bottom: 112px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .cookie-card,
  .cookie-card.is-closing,
  .cookie-switch,
  .cookie-switch::after {
    animation: none;
    transition: none;
  }
}
