/* Coding Unity - Online HTML Editor */
.cu-he {
  --cu-accent: #805aed;
  --cu-accent-dark: #6d4cc7;
  --cu-ink: #26222f;
  --cu-muted: #4c455f;
  --cu-line: #dfdee3;
  --cu-soft: #f7f7f8;
  --cu-ed-bg: #1e1b29;
  --cu-ed-fg: #ece9f5;
  --cu-ed-gutter: #77718a;
  --cu-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  border: 1px solid var(--cu-line);
  border-radius: 12px;
  background: #fff;
  overflow: hidden;
  margin: 0 0 2.5rem;
  color: var(--cu-ink);
  min-height: 640px;
  text-align: left;
}
.cu-he *,
.cu-he *::before,
.cu-he *::after { box-sizing: border-box; }

/* toolbar */
.cu-he__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--cu-line);
  background: var(--cu-soft);
}
.cu-he__group { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; }

.cu-he .cu-he__btn,
.cu-he .cu-he__select {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  height: 34px;
  padding: 0 0.8rem;
  border: 1px solid var(--cu-line);
  border-radius: 8px;
  background: #fff;
  color: var(--cu-ink);
  cursor: pointer;
  box-shadow: none;
  text-transform: none;
  letter-spacing: 0;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s;
}
.cu-he .cu-he__select {
  padding-right: 1.8rem;
  background-image: linear-gradient(45deg, transparent 50%, var(--cu-muted) 50%), linear-gradient(135deg, var(--cu-muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) 15px, calc(100% - 9px) 15px;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  width: auto;
}
.cu-he .cu-he__btn:hover,
.cu-he .cu-he__select:hover { border-color: var(--cu-accent); color: var(--cu-accent-dark); background-color: #fff; }
.cu-he .cu-he__btn--primary { background: var(--cu-accent); border-color: var(--cu-accent); color: #fff; }
.cu-he .cu-he__btn--primary:hover { background: var(--cu-accent-dark); border-color: var(--cu-accent-dark); color: #fff; }
.cu-he .cu-he__btn--reset { min-width: 86px; }
.cu-he .cu-he__btn.is-warn { border-color: #d93025; color: #d93025; }
.cu-he .cu-he__btn:focus-visible,
.cu-he .cu-he__select:focus-visible,
.cu-he .cu-he__tab:focus-visible,
.cu-he .cu-he__link:focus-visible { outline: 2px solid var(--cu-accent); outline-offset: 2px; }

.cu-he__check { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 13px; font-weight: 600; color: var(--cu-muted); cursor: pointer; margin: 0 0 0 0.25rem; }
.cu-he__check input { margin: 0; accent-color: var(--cu-accent); width: 16px; height: 16px; }

/* body grid */
.cu-he__body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  height: 580px;
}
.cu-he--stacked .cu-he__body {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: 340px 480px;
  height: auto;
}

/* editors */
.cu-he__editors { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--cu-ed-bg); }
.cu-he__tabs { display: flex; gap: 2px; padding: 6px 6px 0; background: #16141f; }
.cu-he .cu-he__tab {
  appearance: none;
  margin: 0;
  border: 0;
  border-radius: 6px 6px 0 0;
  padding: 0.55rem 1rem;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  background: transparent;
  color: #a29db3;
  cursor: pointer;
  box-shadow: none;
  text-transform: none;
}
.cu-he .cu-he__tab:hover { color: #fff; background: rgba(255, 255, 255, 0.05); }
.cu-he .cu-he__tab.is-active { background: var(--cu-ed-bg); color: #fff; box-shadow: inset 0 2px 0 var(--cu-accent); }

.cu-he__pane { display: none; flex: 1; min-height: 0; }
.cu-he__pane.is-active { display: flex; }

.cu-he__gutter,
.cu-he .cu-he__code {
  font-family: var(--cu-mono);
  font-size: 13.5px;
  line-height: 1.6;
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  margin: 0;
}
.cu-he__gutter {
  flex: none;
  min-width: 3.2em;
  padding-left: 0.5rem;
  padding-right: 0.6rem;
  text-align: right;
  color: var(--cu-ed-gutter);
  background: transparent;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0;
  overflow: hidden;
  user-select: none;
  white-space: pre;
}
.cu-he .cu-he__code {
  flex: 1;
  min-width: 0;
  height: 100%;
  max-width: none;
  padding-left: 0.75rem;
  padding-right: 0.75rem;
  border: 0;
  border-radius: 0;
  outline: none;
  resize: none;
  background: transparent;
  color: var(--cu-ed-fg);
  caret-color: #8efbda;
  white-space: pre;
  overflow: auto;
  tab-size: 2;
  box-shadow: none;
}
.cu-he .cu-he__code:focus { background: transparent; color: var(--cu-ed-fg); box-shadow: none; border: 0; }
.cu-he .cu-he__code::selection { background: rgba(128, 90, 237, 0.45); }

/* output */
.cu-he__output { display: flex; flex-direction: column; min-width: 0; min-height: 0; border-left: 1px solid var(--cu-line); }
.cu-he--stacked .cu-he__output { border-left: 0; border-top: 1px solid var(--cu-line); }
.cu-he__bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.75rem;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--cu-muted);
  background: var(--cu-soft);
  border-bottom: 1px solid var(--cu-line);
}
.cu-he__status { font-weight: 500; letter-spacing: 0; text-transform: none; }
.cu-he__frame { flex: 1; width: 100%; min-height: 0; border: 0; background: #fff; display: block; }

.cu-he__console { flex: none; height: 150px; display: flex; flex-direction: column; border-top: 1px solid var(--cu-line); }
.cu-he .cu-he__link {
  appearance: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  font: inherit;
  color: var(--cu-accent-dark);
  cursor: pointer;
  box-shadow: none;
}
.cu-he .cu-he__link:hover { text-decoration: underline; background: none; color: var(--cu-accent-dark); }
.cu-he__log { flex: 1; overflow: auto; font-family: var(--cu-mono); font-size: 12.5px; line-height: 1.5; background: #fff; }
.cu-he__log:empty::before { content: "console.log() output and errors appear here"; display: block; padding: 0.5rem 0.75rem; color: #9a95a8; font-family: inherit; }
.cu-he__entry { padding: 0.3rem 0.75rem; border-bottom: 1px solid #f0eff3; white-space: pre-wrap; word-break: break-word; color: var(--cu-ink); }
.cu-he__entry--warn { background: #fff8e6; color: #7a5600; }
.cu-he__entry--error { background: #fdecec; color: #b3261e; }
.cu-he__entry--info { color: #1a5fb4; }

.cu-he__hint { margin: 0; padding: 0.55rem 0.75rem; font-size: 12px; color: var(--cu-muted); border-top: 1px solid var(--cu-line); background: var(--cu-soft); }

/* mobile: always stacked */
@media (max-width: 782px) {
  .cu-he__body,
  .cu-he--stacked .cu-he__body {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: 320px 440px;
    height: auto;
  }
  .cu-he__output { border-left: 0; border-top: 1px solid var(--cu-line); }
  .cu-he .cu-he__btn--layout { display: none; }
  .cu-he__toolbar { justify-content: flex-start; }
  .cu-he__console { height: 120px; }
}

/* page content around the tool */
.cu-tool-content { max-width: 820px; }
.cu-tool-content h2 { margin-top: 2rem; }
.cu-tool-content kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  padding: 0.1em 0.45em;
  border: 1px solid #dfdee3;
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #f7f7f8;
}
