:root {
  --bg: #060b11;
  --bg-deep: #02060b;
  --panel: rgba(7, 13, 19, 0.84);
  --panel-soft: rgba(11, 17, 24, 0.6);
  --stroke: rgba(224, 171, 120, 0.33);
  --stroke-strong: rgba(238, 190, 139, 0.62);
  --text: #f2dec8;
  --muted: rgba(233, 208, 176, 0.82);
  --muted-soft: rgba(204, 183, 155, 0.62);
  --amber: #f3be87;
  --amber-strong: #ffcb8f;
  --teal: #9ad9ca;
  --teal-strong: #bbf8ea;
  --shadow: 0 35px 90px rgba(0, 0, 0, 0.45);
  --panel-shadow: inset 0 0 0 1px rgba(228, 173, 120, 0.12), 0 30px 70px rgba(0, 0, 0, 0.36);
  --display-font: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", "Georgia", serif;
  --ui-font: "Avenir Next", "Segoe UI", "Helvetica Neue", sans-serif;
  --radius-xl: 34px;
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 14px;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--ui-font);
  color: var(--text);
  background:
    radial-gradient(circle at 20% 18%, rgba(30, 92, 106, 0.18), transparent 22%),
    radial-gradient(circle at 82% 76%, rgba(173, 101, 46, 0.18), transparent 25%),
    linear-gradient(135deg, #03070d 0%, #071019 48%, #05070a 100%);
  overflow: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
}

body::before {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 208, 153, 0.06), transparent 18%),
    radial-gradient(circle at 10% 82%, rgba(72, 164, 173, 0.08), transparent 18%),
    radial-gradient(circle at 92% 12%, rgba(72, 164, 173, 0.07), transparent 14%);
  mix-blend-mode: screen;
}

body::after {
  background:
    linear-gradient(transparent 0%, rgba(0, 0, 0, 0.24) 100%),
    radial-gradient(circle at center, transparent 52%, rgba(0, 0, 0, 0.42) 100%);
}

.ambient-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 160px 160px;
  mask-image: radial-gradient(circle at center, black 55%, transparent 95%);
}

.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: minmax(320px, 410px) minmax(0, 1fr);
  gap: 22px;
  height: 100vh;
  padding: 18px;
}

.control-panel,
.stage-panel {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(229, 174, 121, 0.26);
  border-radius: var(--radius-xl);
  background: linear-gradient(180deg, rgba(14, 20, 28, 0.9), rgba(5, 10, 15, 0.84));
  box-shadow: var(--shadow);
}

.control-panel {
  padding: 28px 28px 24px;
  box-shadow: var(--panel-shadow);
}

.control-panel::before,
.stage-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top left, rgba(255, 206, 153, 0.06), transparent 28%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), transparent 28%);
  pointer-events: none;
}

.brand-row {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
}

.brand-star {
  width: 26px;
  color: var(--amber);
  opacity: 0.92;
}

h1 {
  margin: 0 0 14px;
  font-family: var(--display-font);
  font-size: clamp(3.35rem, 5vw, 4.8rem);
  font-weight: 400;
  line-height: 0.92;
  letter-spacing: -0.06em;
  color: var(--amber-strong);
}

.lede {
  margin: 0 0 22px;
  font-size: 1rem;
  line-height: 1.55;
  color: var(--muted);
  max-width: 26ch;
}

.signal-input-shell {
  position: relative;
  padding: 18px 18px 14px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--stroke);
  background:
    linear-gradient(180deg, rgba(13, 19, 27, 0.88), rgba(7, 11, 18, 0.9)),
    radial-gradient(circle at top left, rgba(255, 200, 140, 0.05), transparent 32%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

textarea {
  width: 100%;
  min-height: 255px;
  resize: none;
  border: 0;
  padding: 0;
  font-family: var(--display-font);
  font-size: 1rem;
  line-height: 1.82;
  color: #ecd7bd;
  background: transparent;
  outline: none;
}

textarea::selection {
  background: rgba(255, 204, 151, 0.2);
}

.signal-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--muted-soft);
}

.ignite-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  width: 100%;
  margin-top: 18px;
  padding: 18px 22px;
  border: 1px solid rgba(248, 194, 143, 0.46);
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, rgba(110, 62, 24, 0.8), rgba(255, 192, 126, 0.18)),
    radial-gradient(circle at top center, rgba(255, 231, 189, 0.24), transparent 54%);
  color: #f7deb8;
  font-family: var(--display-font);
  font-size: 1.05rem;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 248, 235, 0.2),
    0 16px 38px rgba(100, 55, 26, 0.34);
  transition: transform 220ms ease, box-shadow 220ms ease, border-color 220ms ease;
}

.ignite-button:hover,
.ignite-button:focus-visible {
  transform: translateY(-2px) scale(1.01);
  border-color: rgba(248, 204, 152, 0.72);
  box-shadow:
    inset 0 1px 0 rgba(255, 248, 235, 0.22),
    0 18px 44px rgba(104, 58, 27, 0.42);
}

.ignite-button:focus-visible,
.mode-button:focus-visible {
  outline: 2px solid rgba(185, 247, 233, 0.7);
  outline-offset: 3px;
}

.ignite-button svg {
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 22px;
}

.metric-card {
  display: grid;
  gap: 8px;
  padding: 18px 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(229, 174, 121, 0.23);
  background: linear-gradient(180deg, rgba(13, 20, 27, 0.78), rgba(9, 13, 20, 0.9));
  min-height: 172px;
}

.metric-card[data-metric="calm"] {
  color: var(--teal);
}

.metric-card[data-metric="momentum"] {
  color: #f0ab67;
}

.metric-card[data-metric="clarity"] {
  color: #9ce8d5;
}

.metric-icon {
  width: 20px;
  opacity: 0.95;
}

.metric-label {
  display: block;
  font-family: var(--display-font);
  font-size: 0.88rem;
  color: var(--text);
}

.metric-value {
  font-family: var(--display-font);
  font-size: clamp(2rem, 4vw, 2.5rem);
  font-weight: 400;
  letter-spacing: -0.04em;
  color: currentColor;
}

.sparkline {
  align-self: end;
  width: 100%;
  height: 34px;
  overflow: visible;
}

.sparkline polyline {
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.panel-affirmation {
  display: grid;
  justify-items: center;
  gap: 12px;
  margin-top: 28px;
  color: var(--muted-soft);
}

.affirmation-line {
  width: 82%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(245, 191, 136, 0.7), transparent);
}

.panel-affirmation p {
  margin: 0;
  font-family: var(--display-font);
  font-size: 0.95rem;
}

.stage-panel {
  background:
    radial-gradient(circle at 56% 48%, rgba(183, 119, 48, 0.06), transparent 18%),
    radial-gradient(circle at 24% 22%, rgba(75, 164, 171, 0.12), transparent 18%),
    linear-gradient(160deg, rgba(3, 8, 13, 0.96), rgba(4, 10, 16, 0.88));
}

#signal-canvas,
.node-layer,
.stage-vignette {
  position: absolute;
  inset: 0;
}

#signal-canvas {
  width: 100%;
  height: 100%;
}

.stage-vignette {
  background:
    radial-gradient(circle at center, transparent 0%, transparent 58%, rgba(0, 0, 0, 0.32) 100%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), transparent 24%, transparent 78%, rgba(0, 0, 0, 0.22));
  pointer-events: none;
}

.core-pulse {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 160px;
  height: 160px;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.core-rings,
.core-center {
  position: absolute;
  inset: 0;
  border-radius: 50%;
}

.core-rings {
  background:
    radial-gradient(circle, rgba(255, 206, 140, 0.3), transparent 42%),
    radial-gradient(circle, rgba(255, 230, 190, 0.12), transparent 70%);
  box-shadow:
    inset 0 0 0 1px rgba(255, 216, 168, 0.24),
    0 0 80px rgba(247, 188, 123, 0.22);
  animation: breathe 6s ease-in-out infinite;
}

.core-rings::before,
.core-rings::after {
  content: "";
  position: absolute;
  inset: 16px;
  border: 1px solid rgba(244, 197, 146, 0.24);
  border-radius: 50%;
}

.core-rings::after {
  inset: 34px;
}

.core-center {
  inset: 44px;
  background:
    radial-gradient(circle at center, #fff4d8 0%, #ffd79f 32%, #f1a85a 60%, rgba(241, 168, 90, 0) 100%);
  box-shadow:
    0 0 22px rgba(255, 214, 149, 0.86),
    0 0 70px rgba(247, 179, 103, 0.55);
}

.node-layer {
  pointer-events: none;
}

.signal-node {
  position: absolute;
  min-width: 132px;
  max-width: 188px;
  transform: translate(-50%, -50%);
  transition: opacity 300ms ease;
}

.signal-node.hidden {
  opacity: 0;
}

.signal-node .node-orb {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin-bottom: 10px;
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 220, 175, 0.32);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 0 34px rgba(0, 0, 0, 0.28);
}

.signal-node[data-tone="amber"] .node-orb {
  background: radial-gradient(circle at 30% 30%, rgba(255, 224, 182, 0.36), rgba(143, 83, 35, 0.3));
  color: #ffd4a2;
}

.signal-node[data-tone="teal"] .node-orb {
  background: radial-gradient(circle at 30% 30%, rgba(200, 255, 248, 0.22), rgba(50, 116, 119, 0.34));
  color: #baf3e6;
}

.node-orb svg {
  width: 26px;
  height: 26px;
}

.node-label-text {
  font-family: var(--display-font);
  font-size: clamp(1.02rem, 1.45vw, 1.22rem);
  line-height: 1.16;
  color: #f4e1c8;
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.44);
}

.insight-card {
  position: absolute;
  width: min(100%, 260px);
  padding: 22px 20px;
  border-radius: 24px;
  border: 1px solid rgba(232, 179, 126, 0.34);
  background:
    linear-gradient(180deg, rgba(8, 14, 20, 0.86), rgba(7, 11, 17, 0.74)),
    radial-gradient(circle at top left, rgba(255, 213, 166, 0.07), transparent 36%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.05),
    0 22px 48px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(8px);
}

.insight-top {
  top: 48px;
  right: 44px;
}

.insight-middle {
  top: 348px;
  right: 44px;
}

.insight-bottom {
  bottom: 140px;
  right: 44px;
}

.insight-heading {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display-font);
  font-size: 1rem;
  color: var(--amber-strong);
}

.insight-glyph {
  color: #f7c78f;
}

.insight-card p {
  margin: 18px 0 0;
  font-family: var(--display-font);
  font-size: 1rem;
  line-height: 1.6;
  color: #f0dcc0;
}

.insight-rule {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 22px;
  margin-top: 18px;
  color: rgba(247, 195, 141, 0.72);
}

.insight-rule::before,
.insight-rule::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(242, 191, 136, 0.44);
}

.insight-rule span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.mode-bar {
  position: absolute;
  left: 50%;
  bottom: 28px;
  display: inline-flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(229, 174, 121, 0.28);
  border-radius: 22px;
  background: rgba(8, 12, 18, 0.72);
  backdrop-filter: blur(8px);
  transform: translateX(-50%);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.26);
}

.mode-button {
  border: 0;
  border-radius: 16px;
  padding: 12px 18px;
  color: var(--muted);
  background: transparent;
  font-family: var(--display-font);
  font-size: 1rem;
  cursor: pointer;
  transition: background 220ms ease, color 220ms ease, transform 220ms ease;
}

.mode-button:hover {
  transform: translateY(-1px);
  color: #f4e1c8;
}

.mode-button.active {
  background: rgba(255, 205, 149, 0.12);
  color: var(--amber-strong);
  box-shadow: inset 0 0 0 1px rgba(243, 190, 135, 0.28);
}

.stage-directions {
  position: absolute;
  left: 34px;
  bottom: 34px;
  max-width: 290px;
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--muted-soft);
}

.stage-directions strong {
  color: var(--text);
  font-weight: 600;
}

@keyframes breathe {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.92;
  }

  50% {
    transform: scale(1.06);
    opacity: 1;
  }
}

@media (max-width: 1180px) {
  body {
    overflow: auto;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .stage-panel {
    min-height: 860px;
  }

  .insight-top,
  .insight-middle,
  .insight-bottom {
    right: 22px;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 12px;
    gap: 14px;
  }

  .control-panel,
  .stage-panel {
    border-radius: 26px;
  }

  .control-panel {
    padding: 22px 18px 20px;
  }

  h1 {
    font-size: 3.2rem;
  }

  .metrics-grid {
    grid-template-columns: 1fr;
  }

  .stage-panel {
    min-height: 960px;
  }

  .core-pulse {
    top: 45%;
    width: 122px;
    height: 122px;
  }

  .insight-card {
    left: 16px;
    right: 16px;
    width: auto;
  }

  .insight-top {
    top: 18px;
  }

  .insight-middle {
    top: auto;
    bottom: 228px;
  }

  .insight-bottom {
    bottom: 122px;
  }

  .mode-bar {
    left: 16px;
    right: 16px;
    bottom: 20px;
    transform: none;
    justify-content: center;
  }

  .mode-button {
    flex: 1 1 0;
    padding-inline: 10px;
    font-size: 0.94rem;
  }

  .stage-directions {
    display: none;
  }
}

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