:root {
  --bg: #ffffff;
  --bg-rgb: 255, 255, 255;
  --edge-offset: 20px;
  --header-height: 44px;
  --ui-font: "Helvetica Neue", Helvetica, Arial, sans-serif;
  --bubble-font: "SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --text: #0a0a0a;
  --glass-bright: rgba(250, 252, 255, 0.96);
  --glass-mid: rgba(238, 242, 246, 0.92);
  --glass-dim: rgba(232, 236, 241, 0.9);
  --glass-edge: rgba(255, 255, 255, 0.7);
  --glass-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
  --glass-inner: rgba(255, 255, 255, 0.5);
  --glass-highlight: rgba(255, 255, 255, 0.7);
  --glass-outline: rgba(170, 176, 186, 0.18);
  --glass-inner-line: rgba(255, 255, 255, 0.4);
  --ripple: rgba(var(--bg-rgb), 0.7);
  --ripple-shadow: rgba(0, 0, 0, 0.08);
  --ripple-line: rgba(78, 86, 98, 0.24);
  --toggle-bg: rgba(255, 255, 255, 0.65);
  --toggle-border: rgba(0, 0, 0, 0.08);
}

body[data-theme="dark"] {
  --bg: #0a0a0a;
  --bg-rgb: 10, 10, 10;
  --text: #f1f1f1;
  --glass-bright: rgba(52, 52, 52, 0.94);
  --glass-mid: rgba(36, 36, 36, 0.94);
  --glass-dim: rgba(26, 26, 26, 0.96);
  --glass-edge: rgba(0, 0, 0, 0);
  --glass-shadow: 0 18px 42px rgba(0, 0, 0, 0.65);
  --glass-inner: rgba(255, 255, 255, 0);
  --glass-highlight: rgba(255, 255, 255, 0);
  --glass-outline: rgba(255, 255, 255, 0);
  --glass-inner-line: rgba(255, 255, 255, 0);
  --ripple: rgba(var(--bg-rgb), 0.7);
  --ripple-shadow: rgba(0, 0, 0, 0.08);
  --ripple-line: rgba(255, 255, 255, 0.22);
  --toggle-bg: rgba(18, 18, 18, 0.72);
  --toggle-border: rgba(255, 255, 255, 0.08);
}

body[data-theme="sunset"] {
  --bg:
    radial-gradient(
      160% 140% at 50% 30%,
      rgba(255, 252, 248, 0.6) 0%,
      rgba(255, 233, 228, 0.42) 18%,
      rgba(244, 204, 198, 0.28) 36%,
      rgba(224, 176, 182, 0.2) 52%,
      rgba(150, 150, 170, 0.08) 68%,
      rgba(20, 24, 36, 0.05) 82%
    ),
    linear-gradient(
      0deg,
      #2b1e22 0%,
      #3a2528 4%,
      #46302b 8%,
      #52352d 12%,
      #5e3a2e 16%,
      #6a4030 20%,
      #764633 24%,
      #824c36 28%,
      #8f533a 32%,
      #9c5a40 36%,
      #aa6248 40%,
      #b86b52 44%,
      #c5755d 48%,
      #d07f69 52%,
      #db8976 56%,
      #e39484 60%,
      #eca092 64%,
      #efaa9f 68%,
      #f2b4ac 72%,
      #f0c6c4 76%,
      #f1e0e6 80%,
      #cab7c0 84%,
      #a28c9f 88%,
      #675b82 92%,
      #32294a 96%,
      #120a24 100%
    );
  --bg-rgb: 216, 150, 120;
  --text: #f2e3d7;
  --glass-bright: rgba(245, 242, 238, 0.92);
  --glass-mid: rgba(231, 226, 220, 0.9);
  --glass-dim: rgba(214, 207, 200, 0.9);
  --glass-edge: rgba(255, 255, 255, 0);
  --glass-shadow: 0 20px 50px rgba(24, 12, 8, 0.45);
  --glass-inner: rgba(255, 255, 255, 0.3);
  --glass-highlight: rgba(255, 255, 255, 0.55);
  --glass-outline: rgba(255, 255, 255, 0);
  --glass-inner-line: rgba(255, 255, 255, 0);
  --ripple-line: rgba(255, 232, 220, 0.28);
  --toggle-bg: rgba(58, 46, 42, 0.7);
  --toggle-border: rgba(255, 214, 194, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  font-family: var(--ui-font);
  font-weight: 400;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

body[data-theme="sunset"] {
  background-color: #120a24;
  background: #120a24;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  isolation: isolate;
}

#sunset-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 1;
  isolation: isolate;
  transition: opacity 0.6s ease;
}

body[data-theme="sunset"] #sunset-layer {
  opacity: 1;
}

#sunset-layer::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 86%;
  width: clamp(110px, 15vw, 180px);
  height: clamp(110px, 15vw, 180px);
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, #ffe6d7 0%, #e89b75 58%, #c95f39 100%);
  box-shadow:
    0 0 150px rgba(238, 170, 120, 0.46),
    0 0 320px rgba(206, 108, 64, 0.28);
  filter: blur(8px);
  z-index: 2;
  transform: translate(-50%, -50%) translateY(-24vh);
  opacity: 0.95;
  animation: sunsetSun 50s linear infinite;
  will-change: transform, opacity;
}

body.sunset-enter #sunset-layer::before {
  animation: sunsetRise 12.8s linear 1 both;
}

#sunset-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(
      0deg,
      rgba(224, 120, 74, 0.22) 0%,
      rgba(214, 108, 68, 0.16) 30%,
      rgba(150, 86, 66, 0.1) 55%,
      rgba(88, 58, 50, 0.06) 80%,
      rgba(0, 0, 0, 0) 100%
    ),
    radial-gradient(circle at 50% 68%, rgba(230, 132, 86, 0.22), rgba(120, 72, 56, 0.12) 55%, rgba(0, 0, 0, 0) 70%);
  opacity: 0.04;
  mix-blend-mode: soft-light;
  z-index: 3;
  animation: sunsetPulse 20s ease-in-out infinite;
}

#sunset-layer .sunset-gradient {
  position: absolute;
  inset: 0;
  background: var(--bg);
  background-size: 160% 160%;
  background-repeat: no-repeat;
  z-index: 0;
  animation: sunsetShift 50s linear infinite;
}

body.sunset-enter #sunset-layer .sunset-gradient {
  animation: sunsetShiftRise 12.8s linear 1 both;
}

#sunset-layer .sunset-night {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    0deg,
    rgba(16, 10, 30, 0.95) 0%,
    rgba(20, 12, 34, 0.9) 40%,
    rgba(26, 16, 42, 0.75) 70%,
    rgba(34, 22, 52, 0.6) 100%
  );
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: multiply;
  z-index: 1;
  animation: nightFall 50s ease-in-out infinite;
}

body.sunset-enter #sunset-layer .sunset-night {
  animation: nightLift 12.8s linear 1 both;
}

#ripple-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 1;
}

.bg-ripple {
  position: absolute;
  width: var(--ripple-size, 130px);
  height: var(--ripple-size, 130px);
  border-radius: 50%;
  border: 1.2px solid var(--ripple-line);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.05),
    0 8px 24px var(--ripple-shadow);
  transform: translate(-50%, -50%) scale(0.24);
  opacity: 0;
  animation: bgRipple 980ms cubic-bezier(0.2, 0.65, 0.15, 1) forwards;
  will-change: transform, opacity;
}

#bubble-field {
  position: absolute;
  inset: 0;
  z-index: 2;
}


#theme-toggle {
  position: absolute;
  top: var(--edge-offset);
  right: var(--edge-offset);
  width: var(--header-height);
  height: var(--header-height);
  border-radius: 999px;
  border: 1px solid var(--toggle-border);
  background: var(--toggle-bg);
  backdrop-filter: blur(12px) saturate(1.2);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.12);
  display: grid;
  place-items: center;
  z-index: 5;
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}


#site-header {
  position: absolute;
  top: var(--edge-offset);
  left: var(--edge-offset);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 12px;
  z-index: 6;
}

#menu-toggle {
  font-family: var(--ui-font);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  color: var(--text);
  background: var(--toggle-bg);
  border: 1px solid var(--toggle-border);
  padding: 0 12px;
  height: var(--header-height);
  line-height: var(--header-height);
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(12px) saturate(1.2);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#menu-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.16);
}

#menu-toggle:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.25);
  outline-offset: 6px;
  border-radius: 8px;
}

.menu-bubble {
  display: grid;
  gap: 10px;
  padding: 0;
  min-width: unset;
  border: none;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.menu-bubble.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.menu-bubble a {
  font-family: var(--ui-font);
  color: var(--text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.01em;
  background: var(--toggle-bg);
  border: 1px solid var(--toggle-border);
  padding: 0 12px;
  height: var(--header-height);
  line-height: var(--header-height);
  border-radius: 999px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(12px) saturate(1.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.menu-bubble a.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.menu-bubble a:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.16);
}

#theme-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 50px rgba(0, 0, 0, 0.16);
}

#theme-toggle svg {
  width: 20px;
  height: 20px;
  color: var(--text);
}

#theme-toggle svg {
  display: none;
}

body[data-theme="light"] #theme-toggle .icon-sun {
  display: block;
}

body[data-theme="dark"] #theme-toggle .icon-moon {
  display: block;
}

body[data-theme="sunset"] #theme-toggle .icon-sunset {
  display: block;
}

#theme-toggle .icon-moon {
  transform: translate(-1px, 1px);
  transform-origin: center;
}

.bubble {
  font-family: var(--bubble-font, var(--ui-font));
  font-weight: 500;
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--bubble-pad-y, 12px) var(--bubble-pad-x, 18px);
  color: var(--text);
  text-decoration: none;
  border-radius: var(--bubble-radius, 46px);
  background: linear-gradient(180deg, var(--glass-bright) 0%, var(--glass-mid) 56%, var(--glass-dim) 100%);
  border: 1px solid var(--glass-outline);
  backdrop-filter: blur(14px) saturate(1.02);
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.12),
    inset 0 1px 0 var(--glass-highlight),
    inset 0 -4px 8px rgba(0, 0, 0, 0.03);
  user-select: none;
  cursor: grab;
  touch-action: none;
  will-change: transform;
  transition: box-shadow 0.35s ease, border-color 0.35s ease;
  overflow: visible;
}

.bubble::before {
  content: "";
  position: absolute;
  inset: 6% 10% auto 10%;
  height: 42%;
  border-radius: inherit;
  background: radial-gradient(circle at top, rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0));
  opacity: 0.06;
  pointer-events: none;
}

.bubble::after {
  content: "";
  position: absolute;
  inset: var(--bubble-inset, 10px);
  border-radius: inherit;
  border: 1px solid var(--glass-inner-line);
  box-shadow: none;
  pointer-events: none;
  opacity: 0.45;
}

body[data-theme="dark"] .bubble {
  background: rgba(24, 24, 24, 0.98);
  border-color: transparent;
  box-shadow: none;
  backdrop-filter: none;
}

body[data-theme="dark"] .bubble::before {
  opacity: 0;
}

body[data-theme="dark"] .bubble::after {
  opacity: 0;
}

.bubble.text-only::after,
.bubble.has-image::after {
  content: none;
}


.bubble span {
  position: relative;
  z-index: 2;
  line-height: 1.08;
  letter-spacing: -0.01em;
  font-weight: inherit;
  padding: 0;
  max-width: 100%;
  width: 100%;
  display: block;
  white-space: pre-line;
  word-break: normal;
  hyphens: none;
  text-wrap: balance;
  overflow-wrap: anywhere;
}

.bubble::after,
.bubble span,
.bubble.has-image img {
  filter: saturate(0.92) contrast(0.96);
}

.bubble span {
  color: rgba(0, 0, 0, 0.68);
}

body[data-theme="dark"] .bubble span {
  color: rgba(255, 255, 255, 0.92);
}

body[data-theme="sunset"] .bubble span {
  color: rgba(30, 22, 18, 0.9);
}

body[data-theme="sunset"] #menu-toggle,
body[data-theme="sunset"] #theme-toggle svg {
  color: #ffffff;
}

body[data-theme="sunset"] .bubble {
  background: rgba(255, 255, 255, 0.12);
  border-color: transparent;
  backdrop-filter: blur(38px) saturate(2.15) contrast(1.08);
  -webkit-backdrop-filter: blur(38px) saturate(2.15) contrast(1.08);
  box-shadow: 0 16px 34px rgba(22, 10, 8, 0.2);
}

body[data-theme="sunset"] .bubble::before {
  opacity: 0;
}

body[data-theme="sunset"] .bubble::after,
body[data-theme="sunset"] .bubble.text-only::after,
body[data-theme="sunset"] .bubble.has-image::after {
  content: "";
  position: absolute;
  inset: 0;
  padding: 0.2px;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(255, 170, 220, 0.32), rgba(120, 190, 255, 0.3));
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  opacity: 0.12;
  pointer-events: none;
}

body[data-theme="sunset"] .bubble.has-image img {
  filter: saturate(1.05) contrast(0.96) brightness(1.02);
}

@keyframes sunsetShift {
  0% {
    filter: brightness(1.16) saturate(1.02) hue-rotate(-4deg);
    background-position: 50% 100%;
  }
  22% {
    filter: brightness(1.12) saturate(1.01) hue-rotate(-3deg);
    background-position: 46% 70%;
  }
  42% {
    filter: brightness(0.82) saturate(0.94) hue-rotate(-5deg);
    background-position: 54% 56%;
  }
  58% {
    filter: brightness(0.52) saturate(0.88) hue-rotate(-7deg);
    background-position: 56% 44%;
  }
  74% {
    filter: brightness(0.5) saturate(0.87) hue-rotate(-8deg);
    background-position: 52% 38%;
  }
  90% {
    filter: brightness(0.92) saturate(0.95) hue-rotate(-5deg);
    background-position: 49% 64%;
  }
  100% {
    filter: brightness(1.16) saturate(1.02) hue-rotate(-4deg);
    background-position: 50% 100%;
  }
}

@keyframes sunsetSun {
  0% {
    transform: translate(-50%, -50%) translateY(-24vh);
    opacity: 0.95;
  }
  24% {
    transform: translate(-50%, -50%) translateY(2vh);
    opacity: 0.85;
  }
  44% {
    transform: translate(-50%, -50%) translateY(26vh);
    opacity: 0.24;
  }
  54% {
    transform: translate(-50%, -50%) translateY(36vh);
    opacity: 0;
  }
  72% {
    transform: translate(-50%, -50%) translateY(36vh);
    opacity: 0;
  }
  86% {
    transform: translate(-50%, -50%) translateY(16vh);
    opacity: 0.46;
  }
  100% {
    transform: translate(-50%, -50%) translateY(-24vh);
    opacity: 0.95;
  }
}

@keyframes sunsetRise {
  0% {
    transform: translate(-50%, -50%) translateY(40vh);
    opacity: 0;
  }
  40% {
    transform: translate(-50%, -50%) translateY(6vh);
    opacity: 0.55;
  }
  100% {
    transform: translate(-50%, -50%) translateY(-24vh);
    opacity: 0.95;
  }
}

@keyframes sunsetShiftRise {
  0% {
    filter: brightness(0.44) saturate(0.84) hue-rotate(-8deg);
    background-position: 52% 36%;
  }
  24% {
    filter: brightness(0.5) saturate(0.86) hue-rotate(-8deg);
    background-position: 53% 39%;
  }
  42% {
    filter: brightness(0.84) saturate(0.93) hue-rotate(-6deg);
    background-position: 50% 56%;
  }
  66% {
    filter: brightness(1.08) saturate(0.98) hue-rotate(-5deg);
    background-position: 48% 74%;
  }
  100% {
    filter: brightness(1.16) saturate(1.02) hue-rotate(-4deg);
    background-position: 50% 100%;
  }
}

@keyframes sunsetPulse {
  0% {
    opacity: 0.006;
    filter: hue-rotate(-0.4deg) saturate(1);
    transform: translateY(0);
  }
  50% {
    opacity: 0.012;
    filter: hue-rotate(0.4deg) saturate(1.01);
    transform: translateY(-0.15%);
  }
  100% {
    opacity: 0.006;
    filter: hue-rotate(-0.4deg) saturate(1);
    transform: translateY(0);
  }
}

@keyframes nightFall {
  0% {
    opacity: 0.04;
  }
  24% {
    opacity: 0.1;
  }
  44% {
    opacity: 0.56;
  }
  60% {
    opacity: 0.92;
  }
  76% {
    opacity: 0.82;
  }
  90% {
    opacity: 0.24;
  }
  100% {
    opacity: 0.04;
  }
}

@keyframes nightLift {
  0% {
    opacity: 0.96;
  }
  22% {
    opacity: 0.92;
  }
  44% {
    opacity: 0.56;
  }
  68% {
    opacity: 0.2;
  }
  100% {
    opacity: 0.04;
  }
}

@keyframes bgRipple {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.24);
  }
  14% {
    opacity: 0.34;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.62);
  }
}

.bubble.is-focused {
  border-color: var(--glass-edge);
  box-shadow:
    0 22px 55px rgba(0, 0, 0, 0.18),
    0 0 0 1px rgba(255, 255, 255, 0.26),
    inset 0 1px 0 var(--glass-highlight),
    inset 0 -8px 14px rgba(0, 0, 0, 0.06);
}

.bubble.has-image {
  flex-direction: column;
  gap: 0;
  align-items: stretch;
  justify-content: start;
  padding: 0;
  overflow: hidden;
  display: block;
  align-content: start;
  justify-items: stretch;
  row-gap: 0;
}

.bubble.image-only {
  grid-template-rows: var(--bubble-image-height, 120px);
  row-gap: 0;
}

.bubble.image-only span {
  display: none;
}

.bubble.has-image::before {
  opacity: 0.08;
}

.bubble.has-image::after {
  content: none;
}

.bubble.has-image img {
  position: absolute;
  top: var(--bubble-inset, 10px);
  left: var(--bubble-inset, 10px);
  width: calc(100% - 2 * var(--bubble-inset, 10px));
  height: calc(100% - 2 * var(--bubble-inset, 10px));
  border-radius: var(--bubble-image-radius, 22px);
  object-fit: cover;
  display: block;
  justify-self: stretch;
  opacity: 0.9;
  filter: saturate(0.92) contrast(0.95) brightness(1.02);
  pointer-events: none;
  z-index: 1;
}

.bubble.has-image span {
  position: absolute;
  z-index: 2;
  left: 50%;
  bottom: var(--bubble-text-pad-bottom, 10px);
  transform: translate(-50%, 8px);
  margin: 0;
  padding: 0 var(--bubble-text-pad-x, 0px);
  box-sizing: border-box;
  background: transparent;
  text-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
  align-self: stretch;
  width: calc(100% - 2 * var(--bubble-inset, 10px));
  max-width: var(--bubble-text-width, 100%);
  min-height: var(--bubble-text-height, auto);
  line-height: 1.12;
  font-size: var(--bubble-image-font, inherit);
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.bubble.has-image.is-focused span {
  opacity: 1;
  transform: translate(-50%, 0);
}

.bubble.is-dragging {
  cursor: grabbing;
}

.bubble:focus-visible {
  outline: 2px solid rgba(0, 0, 0, 0.25);
  outline-offset: 4px;
}

body[data-theme="dark"] .bubble:focus-visible {
  outline-color: rgba(255, 255, 255, 0.4);
}


body[data-theme="dark"] #menu-toggle:focus-visible {
  outline-color: rgba(255, 255, 255, 0.35);
}

@media (max-width: 700px) {
  :root {
    --edge-offset: 14px;
    --header-height: 40px;
  }

  #theme-toggle {
    width: var(--header-height);
    height: var(--header-height);
  }
}
