:root {
  color-scheme: dark;
  --bg: #070b14;
  --panel: rgba(13, 22, 41, 0.8);
  --panel-solid: #101a2e;
  --text: #edf6ff;
  --muted: #93a4c0;
  --faint: rgba(196, 215, 242, 0.08);
  --line: rgba(166, 195, 237, 0.15);
  --line-bright: rgba(188, 226, 255, 0.32);
  --accent: #7ad9ff;
  --accent-strong: #5d83ff;
  --accent-soft: rgba(103, 195, 255, 0.16);
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.36);
  --radius-lg: 26px;
  --radius-md: 15px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

:root[data-palette="tide"] {
  --accent: #65f9d3;
  --accent-strong: #28b1dd;
  --accent-soft: rgba(74, 229, 193, 0.16);
}

:root[data-palette="ember"] {
  --accent: #ffb071;
  --accent-strong: #ff5e7d;
  --accent-soft: rgba(255, 133, 102, 0.18);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #eaf0fb;
  --panel: rgba(255, 255, 255, 0.83);
  --panel-solid: #fff;
  --text: #12213b;
  --muted: #60718d;
  --faint: rgba(53, 81, 122, 0.055);
  --line: rgba(50, 74, 112, 0.16);
  --line-bright: rgba(48, 105, 160, 0.29);
  --shadow: 0 20px 58px rgba(65, 83, 120, 0.16);
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #eaf0fb;
    --panel: rgba(255, 255, 255, 0.83);
    --panel-solid: #fff;
    --text: #12213b;
    --muted: #60718d;
    --faint: rgba(53, 81, 122, 0.055);
    --line: rgba(50, 74, 112, 0.16);
    --line-bright: rgba(48, 105, 160, 0.29);
    --shadow: 0 20px 58px rgba(65, 83, 120, 0.16);
  }
}

* {
  box-sizing: border-box;
}

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

body {
  min-width: 320px;
  background:
    radial-gradient(circle at 7% -12%, rgba(89, 126, 255, 0.19), transparent 31rem),
    radial-gradient(circle at 100% 92%, rgba(67, 219, 245, 0.11), transparent 31rem),
    linear-gradient(145deg, rgba(255, 255, 255, 0.024), transparent 34%),
    var(--bg);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
canvas:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

button:active {
  transform: translateY(1px) scale(0.985);
}

.app-shell {
  width: min(1510px, 100%);
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  min-height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 21px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 47px;
  height: 47px;
  place-items: center;
  overflow: hidden;
  border: 1px solid rgba(158, 224, 255, 0.5);
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, rgba(235, 253, 255, 0.78) 0 4%, transparent 5%),
    radial-gradient(circle, rgba(129, 219, 255, 0.54), rgba(50, 104, 255, 0.1) 50%, transparent 72%);
  box-shadow: 0 0 0 6px rgba(126, 209, 255, 0.045), 0 0 34px var(--accent-soft);
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span {
  position: absolute;
  content: "";
  border: 1px solid rgba(192, 235, 255, 0.58);
  border-radius: 50%;
}

.brand-mark::before {
  width: 32px;
  height: 12px;
  transform: rotate(-32deg);
}

.brand-mark::after {
  width: 17px;
  height: 35px;
  transform: rotate(41deg);
}

.brand-mark span {
  width: 5px;
  height: 5px;
  border: 0;
  background: #f4fdff;
  box-shadow: 0 0 12px #fff;
}

.brand-mark span:nth-child(2) {
  width: 3px;
  height: 3px;
  transform: translate(12px, -11px);
}

.brand-mark span:nth-child(3) {
  width: 3px;
  height: 3px;
  transform: translate(-13px, 13px);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.17em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 3vw, 1.58rem);
  font-weight: 780;
  letter-spacing: -0.055em;
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.top-actions,
.canvas-toolbar,
.archive-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.icon-button,
.glass-button,
.primary-button,
.mood-card,
.saved-sky-main,
.remove-sky {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 12px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.icon-button,
.glass-button {
  color: var(--text);
  background: color-mix(in srgb, var(--panel) 89%, transparent);
  backdrop-filter: blur(16px) saturate(135%);
}

.icon-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  font-size: 0.78rem;
  font-weight: 680;
}

.icon-button:hover,
.glass-button:hover {
  border-color: var(--line-bright);
  background: rgba(75, 102, 150, 0.24);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.13);
  transform: translateY(-1px);
}

.sound-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #75ffc5;
  box-shadow: 0 0 12px #75ffc5;
}

.icon-button[aria-pressed="false"] .sound-dot {
  background: #8994a9;
  box-shadow: none;
}

.expand-corners {
  width: 12px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  opacity: 0.78;
}

.primary-button {
  position: relative;
  overflow: hidden;
  padding: 0 17px;
  color: #071525;
  border-color: transparent;
  background: linear-gradient(135deg, var(--accent), #d9f6ff);
  box-shadow: 0 11px 30px var(--accent-soft);
  font-weight: 830;
}

.primary-button::before {
  position: absolute;
  inset: 0;
  content: "";
  background: linear-gradient(110deg, transparent 24%, rgba(255, 255, 255, 0.42) 48%, transparent 70%);
  transform: translateX(-125%);
  transition: transform 480ms ease;
}

.primary-button:hover::before {
  transform: translateX(125%);
}

.primary-button:hover {
  box-shadow: 0 15px 40px var(--accent-soft);
  transform: translateY(-1px);
}

.button-spark {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 7px;
  vertical-align: 2px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 10px currentColor;
}

.compact {
  flex: 1 1 130px;
  min-height: 44px;
  font-size: 0.81rem;
}

.studio-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.72fr) minmax(310px, 0.73fr);
  gap: 21px;
  align-items: stretch;
}

.sky-panel,
.control-panel {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.sky-panel {
  position: relative;
  min-height: min(72vh, 755px);
  isolation: isolate;
  background: #07101e;
}

.sky-panel::before {
  position: absolute;
  z-index: 3;
  inset: 0;
  content: "";
  pointer-events: none;
  border: 1px solid rgba(224, 245, 255, 0.075);
  border-radius: inherit;
}

#skyCanvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: min(72vh, 755px);
  touch-action: none;
  user-select: none;
  cursor: crosshair;
}

#skyCanvas.is-shaping {
  cursor: grabbing;
}

.canvas-vignette,
.canvas-grain {
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
}

.canvas-vignette {
  background:
    linear-gradient(180deg, rgba(1, 6, 17, 0.33), transparent 29%, transparent 64%, rgba(1, 6, 17, 0.3)),
    radial-gradient(ellipse at center, transparent 42%, rgba(0, 0, 0, 0.25) 100%);
}

.canvas-grain {
  opacity: 0.16;
  background-image: radial-gradient(rgba(255,255,255,0.32) 0.45px, transparent 0.7px);
  background-size: 5px 5px;
  mix-blend-mode: soft-light;
}

.canvas-copy {
  position: absolute;
  z-index: 2;
  top: 27px;
  left: 27px;
  max-width: 335px;
  pointer-events: none;
}

.canvas-copy h2 {
  margin: 0 0 9px;
  color: #f8fcff;
  font-size: clamp(1.25rem, 2.4vw, 1.8rem);
  font-weight: 740;
  letter-spacing: -0.05em;
  line-height: 1.04;
  text-shadow: 0 3px 22px rgba(0, 0, 0, 0.47);
}

.canvas-copy p:last-child {
  margin: 0;
  color: rgba(224, 241, 255, 0.78);
  font-size: 0.84rem;
  line-height: 1.55;
  text-shadow: 0 2px 13px rgba(0, 0, 0, 0.47);
}

.live-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 17px;
  padding: 7px 11px;
  color: #e0f9ff;
  border: 1px solid rgba(210, 243, 255, 0.23);
  border-radius: 999px;
  background: rgba(3, 12, 27, 0.48);
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.13);
  font-size: 0.62rem;
  font-weight: 820;
  letter-spacing: 0.14em;
  backdrop-filter: blur(11px);
}

.live-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #72ffc1;
  box-shadow: 0 0 12px #72ffc1;
  animation: pulse 2s infinite;
}

.canvas-stats {
  position: absolute;
  z-index: 2;
  top: 24px;
  right: 24px;
  display: grid;
  min-width: 105px;
  gap: 8px;
  padding: 12px 13px;
  border: 1px solid rgba(215, 239, 255, 0.17);
  border-radius: 14px;
  background: rgba(5, 13, 28, 0.5);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.17);
  backdrop-filter: blur(13px);
  pointer-events: none;
}

.canvas-stats div {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.canvas-stats span {
  color: rgba(218, 237, 255, 0.57);
  font-size: 0.57rem;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.canvas-stats strong {
  color: #f2fbff;
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.canvas-toolbar {
  position: absolute;
  z-index: 2;
  right: 22px;
  bottom: 22px;
  left: 22px;
}

.glass-button {
  padding: 0 14px;
  font-weight: 680;
}

.control-panel {
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.045), transparent 32%),
    var(--panel);
  backdrop-filter: blur(22px) saturate(130%);
}

.panel-section {
  padding: 22px;
  border-bottom: 1px solid var(--line);
}

.atmosphere-section {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.021), transparent);
}

.section-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.seed-label,
.archive-count {
  flex: 0 0 auto;
  padding: 4px 0 0;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 810;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.1em;
}

.mood-grid {
  display: grid;
  gap: 9px;
}

.mood-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  color: var(--text);
  text-align: left;
  background: rgba(255, 255, 255, 0.026);
}

.mood-card:hover {
  border-color: rgba(160, 219, 255, 0.45);
  background: rgba(255, 255, 255, 0.055);
  transform: translateX(2px);
}

.mood-card.selected {
  border-color: var(--accent);
  background: linear-gradient(90deg, var(--accent-soft), rgba(255, 255, 255, 0.04));
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05), 0 5px 17px rgba(0, 0, 0, 0.09);
}

.mood-text {
  min-width: 0;
}

.mood-card strong,
.mood-card small {
  display: block;
}

.mood-card strong {
  font-size: 0.85rem;
  letter-spacing: -0.01em;
}

.mood-card small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.7rem;
}

.mood-select {
  width: 9px;
  height: 9px;
  margin-left: auto;
  border: 1px solid var(--line-bright);
  border-radius: 50%;
  opacity: 0.55;
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.mood-card.selected .mood-select {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: 0 0 14px var(--accent);
  opacity: 1;
  transform: scale(1.08);
}

.mood-swatch,
.saved-orb {
  display: inline-block;
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
}

.mood-swatch {
  box-shadow: 0 0 18px currentColor;
}

.orbital {
  color: #8bcbff;
  background: radial-gradient(circle at 33% 31%, #e2faff, #6996ff 35%, #20347d 72%);
}

.tide {
  color: #5dffd2;
  background: radial-gradient(circle at 33% 31%, #d8fff4, #45d9d2 38%, #075a6e 75%);
}

.ember {
  color: #ffab75;
  background: radial-gradient(circle at 33% 31%, #fff0c9, #ff8565 39%, #862041 75%);
}

.sliders {
  display: grid;
  gap: 21px;
}

.slider-row {
  display: grid;
  gap: 11px;
}

.slider-copy {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.slider-row label {
  color: var(--text);
  font-size: 0.85rem;
  font-weight: 770;
}

.slider-row small {
  color: var(--muted);
  font-size: 0.71rem;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  width: 100%;
  height: 22px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.archive-section {
  display: flex;
  flex: 1;
  flex-direction: column;
}

.archive-list {
  display: grid;
  min-height: 84px;
  max-height: 224px;
  gap: 8px;
  margin-bottom: 14px;
  overflow-y: auto;
  scrollbar-color: var(--line-bright) transparent;
  scrollbar-width: thin;
}

.archive-list::-webkit-scrollbar {
  width: 7px;
}

.archive-list::-webkit-scrollbar-thumb {
  border-radius: 99px;
  background: var(--line-bright);
}

.empty-archive {
  display: grid;
  min-height: 74px;
  place-items: center;
  padding: 13px;
  color: var(--muted);
  border: 1px dashed var(--line-bright);
  border-radius: 13px;
  background: var(--faint);
  text-align: center;
  font-size: 0.76rem;
  line-height: 1.42;
}

.saved-sky {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 160ms ease, transform 160ms ease;
}

.saved-sky:hover {
  border-color: var(--line-bright);
  transform: translateY(-1px);
}

.saved-sky-main {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  color: var(--text);
  border: 0;
  border-radius: 0;
  background: transparent;
  text-align: left;
}

.saved-sky-main:hover {
  background: var(--accent-soft);
}

.saved-orb {
  width: 24px;
  height: 24px;
  box-shadow: 0 0 14px currentColor;
}

.saved-copy {
  min-width: 0;
}

.saved-copy strong,
.saved-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-copy strong {
  font-size: 0.74rem;
}

.saved-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.63rem;
}

.remove-sky {
  min-height: 44px;
  padding: 0 10px;
  color: var(--muted);
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  font-size: 0.67rem;
}

.remove-sky:hover {
  color: #ffc1c1;
  background: rgba(255, 92, 105, 0.09);
}

.tip-card {
  display: flex;
  gap: 10px;
  padding: 17px 22px 21px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.019), transparent);
}

.tip-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.56;
}

.tip-card strong {
  color: var(--text);
}

.tip-separator {
  padding: 0 3px;
  color: var(--accent);
}

.tip-line {
  width: 2px;
  flex: 0 0 auto;
  border-radius: 4px;
  background: linear-gradient(var(--accent), transparent);
  box-shadow: 0 0 10px var(--accent-soft);
}

.toast {
  position: fixed;
  z-index: 10;
  bottom: 22px;
  left: 50%;
  width: min(90vw, 410px);
  padding: 13px 17px;
  color: #effaff;
  border: 1px solid rgba(202, 238, 255, 0.25);
  border-radius: 14px;
  background: rgba(6, 14, 29, 0.91);
  box-shadow: 0 20px 55px rgba(0, 0, 0, 0.38);
  font-size: 0.84rem;
  text-align: center;
  opacity: 0;
  transform: translate(-50%, 18px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  backdrop-filter: blur(16px) saturate(130%);
}

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

@keyframes pulse {
  50% {
    opacity: 0.45;
    transform: scale(0.68);
  }
}

@media (max-width: 980px) {
  .studio-layout {
    grid-template-columns: 1fr;
  }

  .sky-panel,
  #skyCanvas {
    min-height: 535px;
  }

  .control-panel {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .archive-section,
  .tip-card {
    grid-column: 1 / -1;
  }

  .tip-card {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 620px) {
  .app-shell {
    padding: 11px;
  }

  .topbar {
    min-height: 58px;
    margin-bottom: 12px;
  }

  .top-actions {
    gap: 6px;
  }

  .icon-button {
    min-width: 44px;
    padding: 0 10px;
    font-size: 0.72rem;
  }

  .sky-panel,
  #skyCanvas {
    min-height: 510px;
    border-radius: 18px;
  }

  .canvas-copy {
    top: 19px;
    left: 18px;
    max-width: 245px;
  }

  .canvas-copy p:last-child {
    font-size: 0.74rem;
  }

  .canvas-stats {
    top: 18px;
    right: 17px;
    min-width: 81px;
    padding: 9px;
  }

  .canvas-toolbar {
    right: 14px;
    bottom: 14px;
    left: 14px;
  }

  .canvas-toolbar button {
    flex: 1 1 135px;
  }

  .control-panel {
    display: block;
    margin-top: 10px;
    border-radius: 18px;
  }

  .panel-section {
    padding: 19px;
  }

  .tip-card {
    padding: 17px 19px 20px;
  }

  .archive-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .archive-actions .primary-button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 390px) {
  .brand-mark {
    width: 39px;
    height: 39px;
  }

  .expand-label,
  .top-actions .sound-button .sound-on {
    display: none;
  }

  .canvas-stats {
    display: none;
  }

  .canvas-copy {
    max-width: 255px;
  }

  .live-pill {
    margin-bottom: 13px;
  }
}

@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;
  }
}
