:root {
  --bg: #0B0B0C;
  --fg: #EDEDEE;
  --fg-dim: #8A8A8E;
  --border: #232326;
  --accent: #E8A33D;
  --glow-1: #E8A33D;
  --glow-2: #4D5BFF;
  --glow-3: #7A3DE8;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: "Instrument Sans", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  position: relative;
}

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

.bg-mesh::before,
.bg-mesh::after,
.bg-mesh span {
  content: "";
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.22;
  will-change: transform;
}

.bg-mesh::before {
  width: 55vmax;
  height: 55vmax;
  top: -18vmax;
  left: -12vmax;
  background: var(--glow-1);
  animation: drift1 34s ease-in-out infinite;
}

.bg-mesh::after {
  width: 60vmax;
  height: 60vmax;
  bottom: -22vmax;
  right: -16vmax;
  background: var(--glow-2);
  animation: drift2 40s ease-in-out infinite;
}

.bg-mesh span {
  width: 42vmax;
  height: 42vmax;
  top: 30%;
  left: 55%;
  background: var(--glow-3);
  opacity: 0.16;
  animation: drift3 46s ease-in-out infinite;
}

.bg-grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

@keyframes drift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(6vmax, 8vmax) scale(1.08); }
}

@keyframes drift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-7vmax, -5vmax) scale(1.06); }
}

@keyframes drift3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-5vmax, 6vmax) scale(0.94); }
}

@media (prefers-reduced-motion: reduce) {
  .bg-mesh::before,
  .bg-mesh::after,
  .bg-mesh span {
    animation: none;
  }
}

.mono {
  font-family: "Space Mono", "SF Mono", "Menlo", "Consolas", monospace;
}

.dim {
  color: var(--fg-dim);
}

#app {
  position: relative;
  z-index: 2;
  height: 100dvh;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

#app:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.brand {
  position: fixed;
  z-index: 2;
  left: 18px;
  top: 16px;
  font-size: 13px;
  letter-spacing: 0.02em;
  color: var(--fg);
  opacity: 0.85;
  pointer-events: none;
}

@media (max-width: 480px) {
  .brand {
    left: 14px;
    top: 12px;
  }
}

.meta-row {
  margin-bottom: 28px;
}

#fact-date {
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.fact {
  max-width: 640px;
  text-align: center;
  font-size: clamp(22px, 4.2vw, 38px);
  line-height: 1.45;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin: 0;
  opacity: 1;
  transition: opacity 220ms ease;
}

.fact.transitioning {
  opacity: 0;
}

.fact.skeleton {
  width: min(560px, 80vw);
  height: 1.45em;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--border) 25%, rgba(255, 255, 255, 0.08) 50%, var(--border) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

::view-transition-old(root),
::view-transition-new(root) {
  animation: none;
}

::view-transition-old(fact-text),
::view-transition-new(fact-text) {
  animation-duration: 220ms;
}

#fact-text {
  view-transition-name: fact-text;
}

@media (prefers-reduced-motion: reduce) {
  .fact {
    transition: none;
  }
  .fact.skeleton {
    animation: none;
  }
}

.source-row {
  margin-top: 32px;
  min-height: 16px;
}

.disclaimer {
  display: block;
  margin-top: 14px;
  font-size: 10px;
  letter-spacing: 0.02em;
  opacity: 0.5;
  text-align: center;
}

.source-link {
  font-size: 12px;
  letter-spacing: 0.02em;
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: color 150ms ease, border-color 150ms ease;
}

.source-link:hover,
.source-link:focus-visible {
  color: var(--accent);
  border-bottom-color: var(--accent);
  outline: none;
}

.action-row {
  display: flex;
  gap: 8px;
  margin-top: 18px;
}

.action-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  color: var(--fg-dim);
  cursor: pointer;
  transition: color 150ms ease, border-color 150ms ease, background 150ms ease;
}

.action-btn:hover,
.action-btn:focus-visible {
  color: var(--fg);
  border-color: rgba(255, 255, 255, 0.18);
  outline: none;
}

.action-btn.active {
  color: var(--accent);
  border-color: var(--accent);
}

.toast {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: 64px;
  transform: translate(-50%, 8px);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--fg);
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(20, 20, 22, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease, transform 200ms ease;
}

.toast-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.saved-panel {
  position: fixed;
  z-index: 6;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  transition: background 200ms ease;
}

.saved-panel[hidden] {
  display: none;
}

.saved-panel-open {
  background: rgba(0, 0, 0, 0.55);
}

.saved-panel-inner {
  width: 100%;
  max-width: 560px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: #131316;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 16px 18px 24px;
  transform: translateY(100%);
  transition: transform 220ms ease;
}

.saved-panel-open .saved-panel-inner {
  transform: translateY(0);
}

@media (min-width: 640px) {
  .saved-panel {
    align-items: center;
  }
  .saved-panel-inner {
    border-radius: 16px;
    border-bottom: 1px solid var(--border);
    transform: translateY(12px) scale(0.98);
    opacity: 0;
    transition: transform 220ms ease, opacity 220ms ease;
  }
  .saved-panel-open .saved-panel-inner {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.saved-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  color: var(--fg-dim);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.saved-list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.saved-item {
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.saved-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.saved-item-fact {
  margin: 0 0 8px;
  font-size: 15px;
  line-height: 1.4;
}

.saved-item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.saved-item-remove {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
}

.saved-empty {
  font-size: 12px;
  text-align: center;
  padding: 24px 0;
}

.hint {
  position: fixed;
  z-index: 2;
  right: 18px;
  bottom: 16px;
  font-size: 11px;
  letter-spacing: 0.04em;
  opacity: 0.55;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 600ms ease;
}

.hint.hint-first {
  opacity: 0.9;
  animation: hint-pulse 1.8s ease-in-out infinite;
}

@keyframes hint-pulse {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.5; }
}

@media (prefers-reduced-motion: reduce) {
  .hint.hint-first {
    animation: none;
  }
}

@media (max-width: 480px) {
  .hint {
    right: 14px;
    bottom: 12px;
  }
}
