.skynet-editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 19;
  pointer-events: none;
}

.skynet-editor-overlay[hidden] { display: none; }

.skynet-editor-window {
  position: fixed;
  top: 50%;
  left: 50%;
  display: flex;
  flex-direction: column;
  width: min(1080px, calc(100vw - 32px));
  height: min(760px, calc(100dvh - 32px));
  min-width: min(520px, calc(100vw - 16px));
  min-height: 320px;
  max-width: calc(100vw - 16px);
  max-height: calc(100dvh - 16px);
  overflow: hidden;
  pointer-events: auto;
  transform: translate(-50%, -50%);
  border: 2px solid #d8ddd8;
  border-right-color: #485149;
  border-bottom-color: #485149;
  color: #9affb6;
  background: #030705;
  box-shadow: none;
  font: 12px/1.35 "DejaVu Sans Mono", "Liberation Mono", Consolas, monospace;
  letter-spacing: .015em;
  overscroll-behavior: contain;
}

.skynet-editor-window.is-active { box-shadow: none; }
.skynet-editor-window:focus-visible { outline: 2px solid #71ff9a; outline-offset: 3px; }
.skynet-editor-window.is-moving,
.skynet-editor-window.is-resizing { user-select: none; }

.skynet-editor-body {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  flex: 1;
  min-height: 0;
}

.skynet-editor-titlebar {
  position: relative;
  flex: 0 0 auto;
  min-height: 36px;
  padding: 2px 4px 2px 8px;
  color: #061108;
  background: linear-gradient(90deg, #4e9762, #adb3ad 72%);
}

.skynet-editor-titlebar strong { font: inherit; font-weight: 800; }
.skynet-editor-session { margin-left: auto; font-size: 10px; opacity: .72; }
.skynet-editor-window .skynet-editor-window-control {
  position: relative;
  z-index: 20;
  display: grid;
  place-items: center;
  flex: 0 0 34px;
  width: 34px;
  height: 32px;
  min-width: 34px;
  margin-left: auto;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  cursor: pointer;
  touch-action: manipulation;
}

.skynet-editor-window-control::before {
  content: "×";
  display: grid;
  place-items: center;
  width: 14px;
  height: 14px;
  border: 1px solid #d8ddd8;
  border-right-color: #485149;
  border-bottom-color: #485149;
  color: #061108;
  background: #adb3ad;
  box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .45);
  font-weight: 700;
  line-height: 12px;
}

.skynet-editor-window .skynet-editor-window-control:hover,
.skynet-editor-window .skynet-editor-window-control:focus-visible {
  background: transparent;
  box-shadow: none;
  outline: 2px solid #07100a;
  outline-offset: -4px;
}

.skynet-editor-window-control:hover::before,
.skynet-editor-window-control:focus-visible::before { background: #71ff9a; }

.skynet-editor-signal {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #71ff9a;
  box-shadow: 0 0 9px #71ff9a;
}

.skynet-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 35px;
  padding: 4px 6px;
  border-bottom: 1px solid #465249;
  color: #121713;
  background: #a8ada8;
}

.skynet-editor-toolbar button {
  min-height: 25px;
  padding: 3px 9px;
  border: 1px solid #e5e9e5;
  border-right-color: #444b45;
  border-bottom-color: #444b45;
  border-radius: 0;
  color: #101510;
  background: #b9beb9;
  box-shadow: none;
  font: inherit;
  letter-spacing: 0;
  text-transform: none;
}

.skynet-editor-toolbar button:hover,
.skynet-editor-toolbar button:focus-visible {
  color: #e8ffed;
  background: #275d37;
  outline: 1px solid #07100a;
}

.skynet-editor-spacer { flex: 1; }
.skynet-editor-hint { color: #273128; font-size: 10px; }

.skynet-editor-buffer-wrap {
  position: relative;
  min-height: 0;
  overflow: hidden;
  background: #020604;
}

.skynet-editor-buffer,
.skynet-editor-fallback {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.skynet-editor-buffer[hidden],
.skynet-editor-fallback[hidden] { display: none; }

.skynet-editor-fallback {
  resize: none;
  padding: 12px 14px;
  border: 0;
  outline: 0;
  color: #b6ffc8;
  caret-color: #d7ffe1;
  background: #020604;
  font: 13px/1.45 "DejaVu Sans Mono", "Liberation Mono", Consolas, monospace;
  tab-size: 2;
}

.skynet-editor-loading {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  color: #76ff9c;
  background: #020604;
  animation: skynet-editor-blink 1s steps(2, end) infinite;
}

.skynet-editor-loading[hidden] { display: none; }

.skynet-editor-footer {
  min-height: 42px;
  border-top: 1px solid #617267;
  background: #020604;
}

.skynet-editor-modeline {
  padding: 3px 8px;
  color: #061108;
  background: #91a195;
  font-weight: 800;
}

.skynet-editor-modeline[data-kind="dirty"] { color: #180d00; background: #ffc96b; }
.skynet-editor-modeline[data-kind="error"] { color: #1d0000; background: #ff7777; }
.skynet-editor-modeline[data-kind="saved"] { color: #001509; background: #79ff9e; }
.skynet-editor-minibuffer { padding: 4px 8px; color: #78a783; font-size: 10px; }

.skynet-editor-window .ace_editor { color: #b7ffc9; background: #020604; }
.skynet-editor-window .ace_gutter { color: #5f9b6e; background: #071109; }
.skynet-editor-window .ace_gutter-active-line { background: #102617; }
.skynet-editor-window .ace_marker-layer .ace_active-line { background: rgba(71, 255, 123, .07); }
.skynet-editor-window .ace_cursor { color: #d4ffdf; border-left-width: 2px; }
.skynet-editor-window .ace_selection { background: rgba(83, 255, 132, .24); }
.skynet-editor-window .ace_scroller { box-shadow: inset 0 0 28px rgba(36, 255, 98, .035); }

.skynet-editor-resize-hint {
  position: absolute;
  right: 2px;
  bottom: 2px;
  z-index: 4;
  width: 16px;
  height: 16px;
  pointer-events: none;
  background: linear-gradient(135deg, transparent 45%, #3d4e40 46%, #3d4e40 53%, transparent 54%, transparent 64%, #3d4e40 65%, #3d4e40 72%, transparent 73%);
}

.skynet-editor-resize-edge { position: absolute; z-index: 12; touch-action: none; }
.skynet-editor-resize-edge[data-edge="n"],
.skynet-editor-resize-edge[data-edge="s"] { left: 20px; right: 20px; height: 12px; cursor: ns-resize; }
.skynet-editor-resize-edge[data-edge="n"] { top: -5px; }
.skynet-editor-resize-edge[data-edge="s"] { bottom: -5px; }
.skynet-editor-resize-edge[data-edge="e"],
.skynet-editor-resize-edge[data-edge="w"] { top: 20px; bottom: 20px; width: 12px; cursor: ew-resize; }
.skynet-editor-resize-edge[data-edge="e"] { right: -5px; }
.skynet-editor-resize-edge[data-edge="w"] { left: -5px; }
.skynet-editor-resize-edge[data-edge="nw"],
.skynet-editor-resize-edge[data-edge="ne"],
.skynet-editor-resize-edge[data-edge="sw"],
.skynet-editor-resize-edge[data-edge="se"] { width: 26px; height: 26px; }
.skynet-editor-resize-edge[data-edge="nw"] { top: -6px; left: -6px; cursor: nwse-resize; }
.skynet-editor-resize-edge[data-edge="ne"] { top: -6px; right: -6px; cursor: nesw-resize; }
.skynet-editor-resize-edge[data-edge="sw"] { bottom: -6px; left: -6px; cursor: nesw-resize; }
.skynet-editor-resize-edge[data-edge="se"] { right: -6px; bottom: -6px; cursor: nwse-resize; }

@keyframes skynet-editor-blink { 50% { opacity: .58; } }

@media (max-width: 640px) {
  .skynet-editor-window { inset: 0; width: 100%; height: 100dvh; min-width: 0; min-height: 0; max-width: none; max-height: none; border-width: 0; box-shadow: none; transform: none; }
  .skynet-editor-window.is-active { box-shadow: none; }
  .skynet-editor-session, .skynet-editor-hint { display: none; }
  .skynet-editor-toolbar { min-height: 44px; }
  .skynet-editor-toolbar button { min-height: 34px; }
  .skynet-editor-resize-hint, .skynet-editor-resize-edge { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .skynet-editor-loading { animation: none; }
}
