/* ============================================================
   NEXORA · Component / Code editor (shared: Code Lab + Robotic Lab)
   Textarea + syntax-highlight overlay + gutter.
   ============================================================ */

.nx-editor {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  background: color-mix(in srgb, var(--n-1000) 34%, transparent);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.55;
  tab-size: 2;
}

[data-theme="light"] .nx-editor {
  background: rgba(255, 255, 255, 0.5);
}

/* Gutter */
.nx-gutter {
  padding: 12px 10px 12px 14px;
  text-align: right;
  color: var(--text-3);
  background: rgba(255, 255, 255, 0.02);
  user-select: none;
  overflow: hidden;
  white-space: pre;
  font-variant-numeric: tabular-nums;
}

.nx-gutter b {
  display: block;
  font-weight: 400;
  opacity: 0.55;
  transition: color var(--dur-fast), opacity var(--dur-fast);
}

.nx-gutter b.active {
  color: var(--accent-2);
  opacity: 1;
}

.nx-gutter b.err {
  color: var(--danger);
  opacity: 1;
}

/* Scroll surface */
.nx-scroll {
  position: relative;
  overflow: auto;
  min-width: 0;
}

.nx-code,
.nx-input {
  margin: 0;
  padding: 12px 16px;
  font: inherit;
  line-height: inherit;
  tab-size: inherit;
  white-space: pre;
  word-wrap: normal;
  overflow-wrap: normal;
  border: 0;
}

.nx-code {
  pointer-events: none;
  color: var(--text-2);
  min-height: 100%;
  min-width: 100%;
  width: max-content;
}

.nx-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--accent-2);
  outline: none;
  overflow: hidden;
  z-index: 1;
}

.nx-input::selection {
  background: color-mix(in srgb, var(--accent) 38%, transparent);
  color: transparent;
}

.nx-input::placeholder {
  color: var(--text-3);
}

/* ---------- Token colors (theme-aware) ---------------------- */

.tk-key { color: var(--code-key); font-weight: 500; }
.tk-str { color: var(--code-str); }
.tk-num { color: var(--code-num); }
.tk-com { color: var(--text-3); font-style: italic; }
.tk-fn  { color: var(--code-fn); }
.tk-tag { color: var(--code-tag); }
.tk-att { color: var(--code-att); }
.tk-sel { color: var(--code-sel); }
.tk-prop { color: var(--code-prop); }
.tk-pre { color: var(--code-pre); }

/* ---------- Find / replace bar ------------------------------- */

.nx-find {
  position: absolute;
  top: 8px;
  right: 14px;
  z-index: 4;
  display: none;
  gap: 0.35rem;
  align-items: center;
  padding: 0.4rem;
  border-radius: var(--radius-md);
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  box-shadow: var(--depth-lg), var(--glass-edge);
}

.nx-find.is-open {
  display: flex;
}

.nx-find input {
  width: 130px;
  padding: 0.35rem 0.6rem;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.06);
  border: 0;
  border-radius: var(--radius-xs);
  outline: none;
}

.nx-find input:focus {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 40%, transparent);
}

.nx-find button {
  padding: 0.35rem 0.55rem;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-2);
  border-radius: var(--radius-xs);
  transition: color var(--dur-fast), background var(--dur-fast);
}

.nx-find button:hover {
  color: var(--text-1);
  background: rgba(255, 255, 255, 0.08);
}

.nx-find .nx-find-count {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--text-3);
  min-width: 42px;
  text-align: center;
}
