:root {
  color-scheme: dark;
  --glass-border: rgba(255, 255, 255, 0.24);
  --glass-border-subtle: rgba(255, 255, 255, 0.12);
  --glass-fill: rgba(18, 25, 51, 0.38);
  --glass-fill-deep: rgba(7, 10, 25, 0.54);
  --ink: #f6f8ff;
  --muted: rgba(225, 231, 255, 0.62);
  --pointer-x: 0px;
  --pointer-y: 0px;
  --ui-gutter: clamp(18px, 3vw, 42px);
  --ui-top: clamp(18px, 3.5vh, 32px);
  --dock-bottom: max(58px, calc(env(safe-area-inset-bottom) + 58px));
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
}

body {
  overflow: hidden;
  background: #02030c;
  color: var(--ink);
  font-family:
    Inter,
    ui-sans-serif,
    -apple-system,
    BlinkMacSystemFont,
    "SF Pro Display",
    "Segoe UI",
    sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

.app {
  width: 100%;
  height: 100dvh;
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(
      ellipse 78% 58% at 50% 47%,
      rgba(32, 55, 147, 0.16),
      transparent 70%
    ),
    linear-gradient(145deg, #070a1d 0%, #02040c 48%, #070719 100%);
}

.liquid-background {
  position: absolute;
  z-index: -1;
  inset: -10%;
  overflow: hidden;
  pointer-events: none;
}

.liquid-orb {
  position: absolute;
  display: block;
  width: clamp(300px, 44vw, 720px);
  aspect-ratio: 1;
  border-radius: 50%;
  filter: blur(34px);
  opacity: 0.66;
  will-change: transform;
}

.liquid-orb-one {
  top: -19%;
  left: -11%;
  background: radial-gradient(
    circle at 38% 38%,
    rgba(127, 168, 255, 0.34),
    rgba(90, 82, 239, 0.14) 38%,
    transparent 69%
  );
  transform: translate(var(--pointer-x), var(--pointer-y));
  animation: drift-one 18s ease-in-out infinite alternate;
}

.liquid-orb-two {
  right: -13%;
  bottom: -26%;
  background: radial-gradient(
    circle at 42% 43%,
    rgba(120, 92, 255, 0.27),
    rgba(37, 89, 216, 0.13) 43%,
    transparent 70%
  );
  transform: translate(
    calc(var(--pointer-x) * -0.7),
    calc(var(--pointer-y) * -0.7)
  );
  animation: drift-two 22s ease-in-out infinite alternate;
}

.liquid-orb-three {
  top: 23%;
  left: 36%;
  width: clamp(220px, 28vw, 470px);
  opacity: 0.35;
  background: radial-gradient(
    circle,
    rgba(167, 223, 255, 0.14),
    rgba(91, 124, 255, 0.08) 39%,
    transparent 70%
  );
  animation: breathe 10s ease-in-out infinite;
}

.orbital-grid {
  position: absolute;
  inset: 0;
  opacity: 0.2;
  background-image:
    linear-gradient(rgba(205, 219, 255, 0.1) 1px, transparent 1px),
    linear-gradient(90deg, rgba(205, 219, 255, 0.1) 1px, transparent 1px);
  background-position: 50% 50%;
  background-size: 84px 84px;
  -webkit-mask-image: radial-gradient(
    ellipse at center,
    transparent 4%,
    #000 75%
  );
  mask-image: radial-gradient(ellipse at center, transparent 4%, #000 75%);
}

.header,
.settings,
.controls,
.canvas-note {
  z-index: 20;
}
.settings-trigger {
  display: none;
}

.header {
  position: absolute;
  top: var(--ui-top);
  left: var(--ui-gutter);
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 18px 11px 10px;
  border: 1px solid var(--glass-border-subtle);
  border-radius: 20px;
  background: linear-gradient(
    135deg,
    rgba(255, 255, 255, 0.1),
    rgba(255, 255, 255, 0.025)
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.13),
    0 12px 32px rgba(0, 0, 0, 0.13);
  backdrop-filter: blur(22px) saturate(1.45);
  -webkit-backdrop-filter: blur(22px) saturate(1.45);
  animation: surface-in 700ms cubic-bezier(0.2, 0.85, 0.25, 1) both;
}

.brand-mark {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  border: 1px solid rgba(240, 245, 255, 0.42);
  border-radius: 13px;
  background: linear-gradient(
    145deg,
    rgba(213, 229, 255, 0.39),
    rgba(124, 150, 255, 0.08)
  );
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.44),
    0 7px 18px rgba(60, 91, 213, 0.19);
}

.brand-mark span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #ecf3ff;
  box-shadow:
    0 0 0 4px rgba(198, 214, 255, 0.16),
    0 0 22px 2px rgba(153, 185, 255, 0.76);
}
.brand-copy {
  min-width: 158px;
}
.eyebrow,
.header p {
  text-transform: uppercase;
}
.eyebrow {
  margin: 1px 0 5px !important;
  color: rgba(214, 224, 255, 0.7) !important;
  font-size: 8px !important;
  font-weight: 700;
  letter-spacing: 0.16em !important;
  opacity: 1 !important;
}
.header h1 {
  font-size: 19px;
  font-weight: 680;
  letter-spacing: 0.24em;
  line-height: 1.05;
}
.header p:not(.eyebrow) {
  margin-top: 6px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 540;
  letter-spacing: 0.12em;
}

.status-chip,
.live-indicator {
  display: inline-flex;
  align-items: center;
}
.status-chip {
  gap: 6px;
  margin-top: 11px;
  color: rgba(226, 238, 255, 0.86);
  font-size: 8px;
  font-weight: 650;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.status-chip > i,
.live-indicator i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #a9edcf;
  box-shadow:
    0 0 0 3px rgba(124, 227, 182, 0.11),
    0 0 12px rgba(124, 227, 182, 0.75);
}

.settings {
  position: absolute;
  top: var(--ui-top);
  right: var(--ui-gutter);
  width: min(238px, 25vw);
  padding: 16px 16px 15px;
  border: 1px solid var(--glass-border);
  border-radius: 23px;
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.16),
      rgba(255, 255, 255, 0.025) 46%
    ),
    var(--glass-fill);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.2),
    inset 0 -1px rgba(1, 5, 22, 0.24),
    0 20px 52px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(28px) saturate(1.35);
  -webkit-backdrop-filter: blur(28px) saturate(1.35);
  animation: surface-in 820ms 100ms cubic-bezier(0.2, 0.85, 0.25, 1) both;
}

.settings::before,
.controls::before,
.header::before {
  position: absolute;
  top: 0;
  left: 10%;
  right: 10%;
  height: 1px;
  content: "";
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.7),
    transparent
  );
  opacity: 0.42;
}
.settings-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 17px;
}
.settings-mobile-heading {
  display: none;
}
.settings-title {
  color: rgba(246, 248, 255, 0.94);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.live-indicator {
  gap: 6px;
  color: rgba(212, 223, 255, 0.65);
  font-size: 7px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.live-indicator i {
  width: 5px;
  height: 5px;
}
.settings label {
  display: block;
  margin-bottom: 15px;
}
.settings label:last-child {
  margin-bottom: 0;
}
.settings label span {
  display: flex;
  justify-content: space-between;
  margin-bottom: 9px;
  color: rgba(223, 230, 255, 0.75);
  font-size: 8px;
  font-weight: 670;
  letter-spacing: 0.075em;
  text-transform: uppercase;
}
.settings output {
  color: rgba(255, 255, 255, 0.96);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 8px;
  font-weight: 600;
  letter-spacing: 0;
}

.settings input[type="range"] {
  width: 100%;
  height: 5px;
  appearance: none;
  border-radius: 999px;
  outline: none;
  background: linear-gradient(
    90deg,
    rgba(203, 220, 255, 0.98) 0%,
    rgba(157, 183, 255, 0.94) var(--fill, 50%),
    rgba(255, 255, 255, 0.13) var(--fill, 50%),
    rgba(255, 255, 255, 0.08) 100%
  );
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.26),
    0 1px rgba(255, 255, 255, 0.06);
  cursor: ew-resize;
}

.settings input[type="range"]::-webkit-slider-thumb {
  width: 14px;
  height: 14px;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 50%;
  background: linear-gradient(145deg, #ffffff, #bfcdf8);
  box-shadow:
    0 2px 8px rgba(3, 7, 25, 0.48),
    inset 0 1px rgba(255, 255, 255, 0.95);
}
.settings input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  border: 1px solid rgba(255, 255, 255, 0.84);
  border-radius: 50%;
  background: #eaf0ff;
}

.controls {
  position: absolute;
  bottom: var(--dock-bottom);
  left: 50%;
  display: flex;
  gap: 8px;
  width: min(804px, calc(100% - (var(--ui-gutter) * 2)));
  padding: 7px;
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  background:
    linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.16),
      rgba(255, 255, 255, 0.035) 44%
    ),
    var(--glass-fill-deep);
  box-shadow:
    inset 0 1px 1px rgba(255, 255, 255, 0.2),
    inset 0 -1px rgba(0, 0, 0, 0.16),
    0 18px 48px rgba(0, 0, 0, 0.27);
  backdrop-filter: blur(30px) saturate(1.55);
  -webkit-backdrop-filter: blur(30px) saturate(1.55);
  transform: translateX(-50%);
  animation: dock-in 800ms 170ms cubic-bezier(0.2, 0.85, 0.25, 1) both;
}

.controls input,
.controls select,
.controls button {
  height: 45px;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 15px;
  outline: none;
  transition:
    border-color 220ms ease,
    background 220ms ease,
    box-shadow 220ms ease,
    transform 220ms cubic-bezier(0.2, 0.85, 0.25, 1),
    opacity 220ms ease;
}
.controls input,
.controls select {
  background: rgba(2, 5, 16, 0.31);
  color: #f7f9ff;
  box-shadow:
    inset 0 1px rgba(0, 0, 0, 0.28),
    0 1px rgba(255, 255, 255, 0.05);
}
.controls input {
  flex: 1;
  min-width: 0;
  padding: 0 15px;
  font-size: 13px;
  letter-spacing: 0.01em;
}
.controls input::placeholder {
  color: rgba(214, 223, 255, 0.4);
}
.controls select {
  min-width: 126px;
  padding: 0 13px;
  color: rgba(240, 244, 255, 0.88);
  font-size: 11px;
  cursor: pointer;
}
.controls input:focus,
.controls select:focus {
  border-color: rgba(189, 210, 255, 0.68);
  background: rgba(65, 83, 151, 0.28);
  box-shadow:
    0 0 0 4px rgba(143, 174, 255, 0.12),
    inset 0 1px rgba(255, 255, 255, 0.09);
}
.controls button {
  padding: 0 17px;
  color: rgba(250, 252, 255, 0.96);
  font-size: 9px;
  font-weight: 750;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

#generateButton {
  min-width: 113px;
  border-color: rgba(235, 243, 255, 0.44);
  background: linear-gradient(
    145deg,
    rgba(180, 203, 255, 0.94),
    rgba(112, 139, 233, 0.84)
  );
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.55),
    0 8px 18px rgba(71, 99, 216, 0.28);
  color: #101831;
}
#resetButton {
  background: rgba(255, 255, 255, 0.08);
}
.controls button:hover {
  border-color: rgba(255, 255, 255, 0.43);
  transform: translateY(-1px);
}
#generateButton:hover {
  background: linear-gradient(145deg, #d0e1ff, #849ef1);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.62),
    0 12px 22px rgba(71, 99, 216, 0.38);
}
#resetButton:hover {
  background: rgba(255, 255, 255, 0.16);
}
.controls button:active {
  transform: translateY(0) scale(0.975);
}
.controls button:disabled {
  cursor: wait;
  opacity: 0.74;
}
#generateButton.is-generating span::after {
  content: " · Building";
  opacity: 0.67;
}
.controls button:focus-visible,
.settings input[type="range"]:focus-visible {
  outline: 2px solid rgba(210, 225, 255, 0.9);
  outline-offset: 3px;
}

.canvas-container,
#starCanvas {
  width: 100%;
  height: 100%;
}
.canvas-container {
  position: relative;
  z-index: 0;
}
#starCanvas {
  display: block;
  cursor: grab;
  touch-action: none;
}
#starCanvas.dragging {
  cursor: grabbing;
}

.canvas-note {
  position: absolute;
  bottom: calc(var(--dock-bottom) + 76px);
  left: 50%;
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 6px 10px 6px 8px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 999px;
  background: rgba(13, 18, 43, 0.2);
  box-shadow:
    inset 0 1px rgba(255, 255, 255, 0.05),
    0 6px 18px rgba(0, 0, 0, 0.08);
  color: rgba(218, 227, 255, 0.43);
  font-size: 7px;
  font-weight: 600;
  letter-spacing: 0.055em;
  text-transform: uppercase;
  backdrop-filter: blur(14px) saturate(1.25);
  -webkit-backdrop-filter: blur(14px) saturate(1.25);
  transform: translateX(-50%);
  animation: note-in 800ms 240ms cubic-bezier(0.2, 0.85, 0.25, 1) both;
}

.page-footer {
  position: absolute;
  left: 50%;
  bottom: 12px;
  z-index: 25;
  transform: translateX(-50%);
  padding: 0 16px;
  color: rgba(211, 223, 255, 0.62);
  font-size: 10px;
  line-height: 1.5;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-align: center;
  opacity: 0.9;
  white-space: nowrap;
  pointer-events: none;
}

.canvas-note b {
  padding: 0 5px;
  color: rgba(199, 213, 255, 0.36);
}
.canvas-note-icon {
  display: inline-grid;
  width: 16px;
  height: 16px;
  place-items: center;
  margin-right: 6px;
  border-radius: 50%;
  background: rgba(185, 204, 255, 0.14);
  color: #b8ccff;
  font-size: 12px;
}
main.app:has(.settings.is-open) .canvas-note {
  opacity: 0;
  pointer-events: none;
}
.app.is-forming .settings,
.app.is-forming .header {
  animation: glass-settle 700ms ease both;
}

@keyframes surface-in {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}
@keyframes dock-in {
  from {
    opacity: 0;
    transform: translate(-50%, 16px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
}
@keyframes note-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}
@keyframes glass-settle {
  50% {
    filter: brightness(1.18);
  }
}
@keyframes drift-one {
  from {
    margin: 0;
  }
  to {
    margin: 5% -3%;
  }
}
@keyframes drift-two {
  from {
    margin: 0;
  }
  to {
    margin: -4% 4%;
  }
}
@keyframes breathe {
  50% {
    transform: scale(1.17);
    opacity: 0.55;
  }
}

@media (max-height: 680px) and (min-width: 761px) {
  :root {
    --ui-top: 16px;
    --dock-bottom: max(48px, calc(env(safe-area-inset-bottom) + 48px));
  }
  .settings {
    padding-top: 13px;
    padding-bottom: 12px;
  }
  .settings-heading {
    margin-bottom: 12px;
  }
  .settings label {
    margin-bottom: 10px;
  }
  .settings label span {
    margin-bottom: 6px;
  }
  .canvas-note {
    bottom: calc(var(--dock-bottom) + 62px);
  }
}

@media (max-width: 760px) {
  :root {
    --ui-gutter: 14px;
    --ui-top: 14px;
    --dock-bottom: max(48px, calc(env(safe-area-inset-bottom) + 48px));
  }
  .header {
    padding: 8px 13px 9px 8px;
    border-radius: 17px;
  }
  .brand-mark {
    width: 31px;
    height: 31px;
    border-radius: 11px;
  }
  .brand-copy {
    min-width: 132px;
  }
  .header h1 {
    font-size: 17px;
  }
  .settings-trigger {
    position: absolute;
    top: var(--ui-top);
    right: var(--ui-gutter);
    z-index: 21;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 39px;
    padding: 0 13px;
    border: 1px solid var(--glass-border);
    border-radius: 14px;
    background: rgba(18, 25, 51, 0.48);
    box-shadow:
      inset 0 1px rgba(255, 255, 255, 0.16),
      0 10px 26px rgba(0, 0, 0, 0.2);
    color: rgba(246, 248, 255, 0.92);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
  }
  .settings-trigger-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #a9edcf;
    box-shadow: 0 0 10px rgba(124, 227, 182, 0.7);
  }
  .settings {
    top: 50%;
    left: 50%;
    right: auto;
    width: min(360px, calc(100% - 24px));
    max-height: min(560px, 58vh);
    overflow-y: auto;
    padding: 16px 16px 15px;
    border-width: 1px;
    border-radius: 20px;
    transform: translate(50%, -50%);
    opacity: 0;
    pointer-events: none;
    animation: none;
    transition:
      transform 260ms cubic-bezier(0.2, 0.85, 0.25, 1),
      opacity 220ms ease;
  }
  .settings.is-open {
    transform: translate(-50%, -50%);
    opacity: 1;
    pointer-events: auto;
  }
  .settings-mobile-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
  }
  .settings-close {
    width: 34px;
    height: 34px;
    border: 1px solid var(--glass-border-subtle);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
  }
  .settings-heading {
    display: none;
  }
  .settings label {
    margin-bottom: 17px;
  }
  .settings label span {
    margin-bottom: 9px;
    font-size: 9px;
  }
  .settings input[type="range"] {
    height: 7px;
  }
  .settings input[type="range"]::-webkit-slider-thumb {
    width: 20px;
    height: 20px;
  }
  .settings input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
  }
  .app.is-forming .settings {
    animation: none;
  }
  .controls {
    width: calc(100% - 20px);
    flex-wrap: wrap;
    gap: 6px;
    padding: 6px;
    border-radius: 18px;
  }
  .controls input {
    flex-basis: 100%;
    height: 40px;
  }
  .controls select,
  .controls button {
    height: 40px;
  }
  .controls select {
    flex: 1 1 0;
    min-width: 0;
  }
  .controls button {
    flex: 0 1 auto;
    padding: 0 12px;
  }
  .canvas-note {
    display: none;
  }
  .page-footer {
    bottom: max(8px, env(safe-area-inset-bottom));
    font-size: 8px;
    letter-spacing: 0.04em;
  }
}

@media (max-width: 420px) {
  .eyebrow {
    display: none;
  }
  .header p:not(.eyebrow) {
    display: none;
  }
  .header {
    padding-right: 11px;
  }
  .brand-copy {
    min-width: 0;
  }
  .eyebrow {
    margin-bottom: 3px !important;
  }
  .status-chip {
    margin-top: 7px;
  }
  .controls select {
    flex-basis: 0;
  }
  .controls button {
    padding: 0 10px;
  }
  .canvas-note {
    font-size: 6px;
  }
}

@media (max-width: 760px) and (max-height: 700px) {
  .settings {
    top: 44%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
