.ecosystem { --node-accent: var(--violet); }

/* ---- top bar ---- */
.eco-bar {
  position: fixed;
  z-index: 6;
  top: 0;
  left: 0;
  right: 0;
  height: var(--bar-height);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 clamp(16px, 3.2vw, 42px);
  border-bottom: 1px solid var(--hairline);
  background: #fdfdffe0;
  backdrop-filter: blur(14px);
}

.eco-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  letter-spacing: .12em;
  color: #4a4270;
  text-decoration: none;
  padding: 8px 2px;
  transition: color .3s;
}

.eco-back:hover,
.eco-back:focus-visible { color: var(--violet); }
.eco-back span { font-size: 14px; line-height: 1; transition: transform .35s var(--ease-out); }
.eco-back:hover span { transform: translateX(-3px); }

.eco-title {
  margin: 0;
  flex: 1;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: .42em;
  text-transform: uppercase;
  color: #2b2657;
}

.eco-count {
  font-size: 11px;
  letter-spacing: .16em;
  color: #6b628f;
  font-variant-numeric: tabular-nums;
}

.eco-tools { display: flex; align-items: center; gap: 10px; }

.eco-search {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border: 1px solid #1714471f;
  border-radius: 2px;
  background: #fff9;
  transition: border-color .3s, background .3s, box-shadow .3s;
}

.eco-search:focus-within {
  border-color: #6c3af166;
  background: #fff;
  box-shadow: 0 0 0 3px #6c3af10f;
}

.eco-search input {
  width: clamp(96px, 13vw, 168px);
  border: 0;
  outline: none;
  background: none;
  font: inherit;
  font-size: 12px;
  letter-spacing: .04em;
  color: var(--ink);
}

.eco-search input::placeholder { color: #8d86ab; letter-spacing: .06em; }

.eco-add {
  height: 32px;
  padding: 0 16px;
  border: 1px solid #6c3af140;
  border-radius: 2px;
  background: #fff;
  color: #3c2f79;
  font-size: 12px;
  letter-spacing: .1em;
  cursor: pointer;
  transition: background .3s, color .3s, border-color .3s, transform .3s var(--ease-out);
}

.eco-add:hover,
.eco-add:focus-visible {
  background: var(--violet);
  border-color: var(--violet);
  color: #fff;
  transform: translateY(-1px);
}

.eco-add:active { transform: translateY(0); }

/* ---- stage ---- */
#eco-stage {
  position: fixed;
  inset: var(--bar-height) 0 0;
  overflow: hidden;
  isolation: isolate;
  opacity: 0;
  transition: opacity 700ms var(--ease-out);
}

body.scene-ready #eco-stage { opacity: 1; }

#eco-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.eco-hub {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 104px;
  height: 104px;
  margin: 0;
  display: block;
  pointer-events: none;
  opacity: .95;
  filter: drop-shadow(0 10px 26px #3b1c7a30);
}

.eco-hub img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: hub-breathe 7s ease-in-out infinite;
}

@keyframes hub-breathe {
  0%, 100% { transform: scale(.97); opacity: .9; }
  50% { transform: scale(1.03); opacity: 1; }
}

.eco-nodes { position: absolute; inset: 0; }

/* ---- node labels ---- */
.node-wrap {
  position: absolute;
  transform: translate(14px, calc(-50% + var(--nudge-y, 0px)));
  --node-accent: var(--violet);
  --nudge-y: 0px;
  transition: opacity .45s var(--ease-out), filter .45s var(--ease-out);
}

.node-wrap[data-align=end] { transform: translate(calc(-100% - 14px), calc(-50% + var(--nudge-y, 0px))); }
.node-wrap[data-align=center] { transform: translate(-50%, calc(-100% - 10px + var(--nudge-y, 0px))); }

.node-wrap[data-accent=cyan] { --node-accent: #2b93a8; }
.node-wrap[data-accent=indigo] { --node-accent: #4a56c4; }
.node-wrap[data-accent=lilac] { --node-accent: #8f6bf0; }

.node {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  text-decoration: none;
  color: var(--ink);
  outline: none;
  cursor: pointer;
  padding: 3px 2px;
  border-radius: 2px;
  transition: transform .35s var(--ease-out);
}

.node-wrap[data-align=end] .node { align-items: flex-end; text-align: right; }
.node-wrap[data-align=center] .node { align-items: center; text-align: center; }

.node-name {
  font-size: 13px;
  letter-spacing: .05em;
  line-height: 1.32;
  white-space: nowrap;
  transition: color .3s, letter-spacing .4s var(--ease-out);
  text-shadow: 0 0 14px #fdfdff, 0 0 6px #fdfdff, 0 0 3px #fdfdff;
}

.node-cat {
  font-size: 10px;
  line-height: 1.2;
  letter-spacing: .16em;
  color: #6d6493;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity .3s, transform .3s var(--ease-out);
}

.node-wrap:hover .node-name,
.node-wrap:focus-within .node-name { color: var(--node-accent); letter-spacing: .07em; }

.node-wrap:hover .node-cat,
.node-wrap:focus-within .node-cat { opacity: .82; transform: none; }

.node-wrap:hover .node,
.node-wrap:focus-within .node { transform: translateY(-1px); }

.node:focus-visible { outline: 1px solid #6c3af166; outline-offset: 4px; }

.node-remove {
  position: absolute;
  top: -9px;
  right: -15px;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 1px solid #1714471f;
  border-radius: 50%;
  background: #fff;
  color: #7c7398;
  font-size: 11px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, color .25s, border-color .25s, transform .25s var(--ease-out);
  box-shadow: 0 2px 6px #1714471a;
}

.node-wrap[data-align=end] .node-remove { right: auto; left: -15px; }
.node-wrap[data-align=center] .node-remove { right: -20px; }

.node-wrap:hover .node-remove,
.node-wrap:focus-within .node-remove { opacity: 1; pointer-events: auto; }

.node-remove:hover,
.node-remove:focus-visible {
  color: #c0345a;
  border-color: #c0345a55;
  transform: scale(1.12);
}

/* entrance / removal / filtering states */
.node-wrap.is-entering { opacity: 0; }
.node-wrap.is-leaving { opacity: 0; filter: blur(2px); pointer-events: none; }
.node-wrap.is-dim { opacity: .16; filter: saturate(.2); }
.node-wrap.is-dim .node-remove { display: none; }

/* ---- empty state ---- */
.eco-empty {
  position: absolute;
  left: 50%;
  bottom: clamp(48px, 13vh, 132px);
  transform: translateX(-50%);
  text-align: center;
  width: min(340px, 82vw);
  opacity: 0;
  transition: opacity .5s ease;
}

.eco-empty[data-visible=true] { opacity: 1; }
.eco-empty-title { margin: 0 0 6px; font-size: 14px; letter-spacing: .18em; color: #3a3268; }
.eco-empty-text { margin: 0 0 16px; font-size: 12px; line-height: 1.7; letter-spacing: .05em; color: #7a719b; }
.eco-empty .eco-add { height: 34px; }

/* ---- add drawer ---- */
.eco-drawer {
  position: fixed;
  z-index: 8;
  top: var(--bar-height);
  right: 0;
  bottom: 0;
  width: min(360px, 92vw);
  padding: 28px 26px;
  background: #fdfdfff2;
  backdrop-filter: blur(18px);
  border-left: 1px solid var(--hairline);
  box-shadow: -24px 0 60px #2a1a5a12;
  transform: translateX(102%);
  transition: transform .5s var(--ease-out);
  overflow-y: auto;
}

.eco-drawer[data-open=true] { transform: none; }

.eco-drawer h2 {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: .3em;
  text-transform: uppercase;
  color: #2b2657;
}

.eco-drawer p.eco-hint { margin: 0 0 22px; font-size: 11px; line-height: 1.7; letter-spacing: .04em; color: #7a719b; }

.eco-field { display: block; margin-bottom: 14px; }
.eco-field span { display: block; margin-bottom: 6px; font-size: 11px; letter-spacing: .14em; color: #5b5382; }

.eco-field input,
.eco-field textarea,
.eco-field select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid #1714471f;
  border-radius: 2px;
  background: #fff;
  font: inherit;
  font-size: 13px;
  letter-spacing: .03em;
  color: var(--ink);
  outline: none;
  transition: border-color .25s, box-shadow .25s;
}

.eco-field textarea { resize: vertical; min-height: 56px; }

.eco-field input:focus,
.eco-field textarea:focus,
.eco-field select:focus { border-color: #6c3af166; box-shadow: 0 0 0 3px #6c3af10f; }

.eco-form-error { margin: 0 0 12px; font-size: 12px; line-height: 1.6; color: #c0345a; min-height: 1px; }
.eco-actions { display: flex; gap: 10px; margin-top: 20px; }

.eco-actions button {
  height: 34px;
  padding: 0 18px;
  border-radius: 2px;
  font-size: 12px;
  letter-spacing: .1em;
  cursor: pointer;
  border: 1px solid #1714471f;
  background: #fff;
  color: #3c2f79;
  transition: background .3s, border-color .3s, color .3s, transform .2s;
}

.eco-actions button[type=submit] { background: var(--violet); border-color: var(--violet); color: #fff; }
.eco-actions button[type=submit]:disabled { opacity: .5; cursor: progress; }
.eco-actions button[type=button]:hover { border-color: #6c3af166; color: var(--violet); }
.eco-actions button:active { transform: translateY(1px); }

/* ---- admin token dialog ---- */
.eco-auth {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #17144726;
  backdrop-filter: blur(6px);
  animation: auth-fade 240ms var(--ease-out) both;
}

.eco-auth[hidden] { display: none; }

@keyframes auth-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.eco-auth-card {
  width: min(340px, 92vw);
  margin: 0;
  padding: 26px 24px 22px;
  border: 1px solid var(--hairline);
  border-radius: 3px;
  background: #fdfdff;
  box-shadow: 0 26px 70px #17144726;
  animation: auth-rise 320ms var(--ease-out) both;
}

@keyframes auth-rise {
  from { opacity: 0; transform: translateY(10px) scale(.99); }
  to { opacity: 1; transform: none; }
}

.eco-auth-eyebrow {
  margin: 0 0 8px;
  font-size: 10px;
  letter-spacing: .34em;
  text-transform: uppercase;
  color: #8d86ab;
}

.eco-auth-card h2 {
  margin: 0 0 8px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: .16em;
  color: #241f4d;
}

.eco-auth-text {
  margin: 0 0 18px;
  font-size: 12px;
  line-height: 1.7;
  letter-spacing: .03em;
  color: #7a719b;
}

.eco-auth-error {
  margin: 0 0 4px;
  font-size: 12px;
  line-height: 1.6;
  color: #c0345a;
  min-height: 1px;
}

.eco-auth .eco-actions { margin-top: 16px; }

/* ---- toast ---- */
.eco-toast {
  position: fixed;
  z-index: 9;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 14px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 9px 16px;
  border: 1px solid #1714471f;
  border-radius: 2px;
  background: #fffe;
  backdrop-filter: blur(12px);
  box-shadow: 0 10px 30px #2214531f;
  font-size: 12px;
  letter-spacing: .05em;
  color: #3a3268;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s, transform .3s var(--ease-out);
}

.eco-toast[data-visible=true] { opacity: 1; transform: translate(-50%, 0); pointer-events: auto; }

.eco-toast button {
  border: 0;
  background: none;
  padding: 0;
  font: inherit;
  font-size: 12px;
  letter-spacing: .1em;
  color: var(--violet);
  cursor: pointer;
}

/* ---- responsive ---- */
@media (max-width: 820px) {
  :root { --bar-height: 56px; }
  .eco-bar { gap: 10px; padding: 0 14px; }
  .eco-title { display: none; }
  .eco-search { padding: 0 8px; }
  .eco-search input { width: 96px; }
}

@media (max-width: 620px) {
  :root { --bar-height: 52px; }
  .eco-search { display: none; }
  .eco-count { font-size: 10px; letter-spacing: .06em; white-space: nowrap; }
  .eco-add { padding: 0 12px; font-size: 11px; letter-spacing: .04em; }
  .eco-back { font-size: 11px; letter-spacing: .06em; }
  .node-name { font-size: 12px; letter-spacing: .03em; }
  .node-cat { font-size: 9px; letter-spacing: .1em; }
  .eco-hub { width: 68px; height: 68px; }
  .eco-hub img { animation-duration: 9s; }

  /* the add panel becomes a bottom sheet on phones */
  .eco-drawer {
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 82vh;
    border-left: 0;
    border-top: 1px solid var(--hairline);
    border-radius: 14px 14px 0 0;
    padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
    box-shadow: 0 -24px 60px #2a1a5a1a;
    transform: translateY(102%);
  }

  .eco-drawer[data-open=true] { transform: none; }
}

@media (hover: none) {
  .node-remove { opacity: 1; pointer-events: auto; }
  .node-cat { opacity: .72; transform: none; }
}
