:root {
  --font-size: 18px;
  --font-color: #32ff6a;
  --bg-color: #000000;
  --chat-font-size: 11.5px;
  --chat-font-color: #ccd1ff;
  --chat-bg-color: #0a0b12;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  font-family: Consolas, Monaco, 'Courier New', monospace;
}

#workspace-shell {
  width: 100%;
  height: 100vh;
  display: flex;
  overflow: hidden;
}

#file-explorer {
  width: 220px;
  min-width: 120px;
  max-width: 600px;
  height: 100%;
  border-right: none;
  background: rgba(7, 7, 7, 0.88);
  overflow-y: auto;
  overflow-x: hidden;
  flex-shrink: 0;
  z-index: 5;
  scrollbar-width: thin;
  scrollbar-color: #2a7a3a #0a0a0a;
}

#file-explorer::-webkit-scrollbar {
  width: 6px;
}

#file-explorer::-webkit-scrollbar-track {
  background: #0a0a0a;
}

#file-explorer::-webkit-scrollbar-thumb {
  background: #2a7a3a;
  border-radius: 3px;
}

#file-explorer::-webkit-scrollbar-thumb:hover {
  background: #32ff6a;
}

#sidebar-resizer {
  width: 4px;
  min-width: 4px;
  height: 100%;
  cursor: col-resize;
  background: #1a1a1a;
  flex-shrink: 0;
  transition: background 0.15s ease;
  z-index: 10;
}

#sidebar-resizer:hover,
#sidebar-resizer.dragging {
  background: #32ff6a;
}

.explorer-title {
  font-size: 12px;
  color: #9a9a9a;
  letter-spacing: 0.08em;
  padding: 12px 14px;
  border-bottom: 1px solid #1f1f1f;
}

#file-list {
  list-style: none;
  margin: 0;
  padding: 6px 0;
}

#file-list li {
  margin: 0;
}

#file-list button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: #8ecf8e;
  font-size: 12px;
  font-family: inherit;
  padding: 5px 12px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#file-list button:hover,
#file-list button:focus-visible {
  background: rgba(60, 120, 60, 0.2);
  outline: none;
}

#file-list button.active {
  background: rgba(70, 170, 90, 0.24);
  color: #c4ffc4;
}

#app {
  flex: 1;
  min-width: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  outline: none;
  position: relative;
  scrollbar-width: thin;
  scrollbar-color: #2a7a3a #0a0a0a;
}

#app::-webkit-scrollbar {
  width: 6px;
}

#app::-webkit-scrollbar-track {
  background: #0a0a0a;
}

#app::-webkit-scrollbar-thumb {
  background: #2a7a3a;
  border-radius: 3px;
}

#app::-webkit-scrollbar-thumb:hover {
  background: #32ff6a;
}

#code-layout {
  display: flex;
  align-items: flex-start;
  min-height: 100%;
}

#line-numbers {
  display: none;
  margin: 0;
  padding-right: 12px;
  margin-right: 12px;
  min-width: 42px;
  text-align: right;
  white-space: pre;
  color: #46624c;
  border-right: 1px solid rgba(55, 95, 62, 0.45);
  font-size: var(--font-size);
  line-height: 1.35;
  user-select: none;
  pointer-events: none;
}

#app.show-line-numbers #line-numbers {
  display: block;
}

#code-screen {
  margin: 0;
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--font-color);
  font-size: var(--font-size);
  line-height: 1.35;
  text-shadow: 0 0 6px color-mix(in srgb, var(--font-color) 60%, transparent);
}

#caret {
  position: fixed;
  width: 10px;
  height: calc(var(--font-size) + 2px);
  background: var(--font-color);
  box-shadow: 0 0 8px color-mix(in srgb, var(--font-color) 75%, transparent);
  animation: blink 1s steps(2, jump-none) infinite;
  pointer-events: none;
}

#fullscreen-tip {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  min-height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid transparent;
  background: rgba(5, 5, 5, 0);
  color: #a8a8a8;
  padding: 6px 12px;
  font-size: 12px;
  z-index: 20;
  opacity: 0;
  transition: opacity 0.2s ease, background-color 0.2s ease, border-color 0.2s ease;
}

#fullscreen-tip:hover,
#fullscreen-tip:focus-visible {
  opacity: 1;
  background: rgba(5, 5, 5, 0.88);
  border-bottom-color: #2d2d2d;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

#panel-toggle {
  position: fixed;
  right: 10px;
  bottom: 10px;
  width: 36px;
  height: 36px;
  border: 1px solid #2b2b2b;
  background: #111;
  color: #c8c8c8;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.2s ease;
  z-index: 20;
}

#chat-settings-toggle {
  position: fixed;
  right: 52px;
  bottom: 10px;
  width: 36px;
  height: 36px;
  border: 1px solid #2b2b2b;
  background: #111;
  color: #c8c8c8;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.2s ease;
  z-index: 20;
}

#panel-toggle:hover,
#panel-toggle:focus-visible,
#chat-settings-toggle:hover,
#chat-settings-toggle:focus-visible {
  opacity: 1;
}

#control-panel,
#chat-control-panel {
  position: fixed;
  right: 10px;
  bottom: 54px;
  width: 280px;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid #2b2b2b;
  border-radius: 6px;
  background: rgba(10, 10, 10, 0.92);
  color: #d6d6d6;
  z-index: 20;
}

#chat-control-panel {
  right: 52px;
  max-height: min(72vh, 520px);
  overflow-y: auto;
}

#chat-control-panel::-webkit-scrollbar {
  width: 6px;
}

#chat-control-panel::-webkit-scrollbar-track {
  background: #0a0a0a;
}

#chat-control-panel::-webkit-scrollbar-thumb {
  background: #3b3b3b;
  border-radius: 3px;
}

#control-panel.hidden,
#chat-control-panel.hidden {
  display: none;
}

#control-panel h2,
#chat-control-panel h2 {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: 700;
}

#control-panel label,
#chat-control-panel label {
  font-size: 12px;
}

#control-panel .inline-control,
#chat-control-panel .inline-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

#control-panel input[type='range'],
#control-panel input[type='url'],
#control-panel input[type='file'],
#control-panel input[type='color'],
#control-panel input[type='text'],
#control-panel textarea,
#chat-control-panel input[type='range'],
#chat-control-panel input[type='url'],
#chat-control-panel input[type='file'],
#chat-control-panel input[type='color'],
#chat-control-panel input[type='text'],
#chat-control-panel textarea {
  width: 100%;
}

#control-panel input[type='url'],
#control-panel input[type='text'],
#control-panel textarea,
#chat-control-panel input[type='url'],
#chat-control-panel input[type='text'],
#chat-control-panel textarea {
  background: #0f0f0f;
  color: #ddd;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 6px 8px;
}

#control-panel textarea,
#chat-control-panel textarea {
  resize: vertical;
  min-height: 92px;
  font-family: Consolas, Monaco, 'Courier New', monospace;
  font-size: 11px;
}

.panel-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.panel-actions button {
  border: 1px solid #333;
  background: #151515;
  color: #ddd;
  border-radius: 4px;
  padding: 6px;
  font-size: 12px;
  cursor: pointer;
}

.panel-actions button:hover,
.panel-actions button:focus-visible {
  background: #1f1f1f;
}

/* ─── Floating Console Window ─────────────────────────────── */
#console-win {
  position: fixed;
  top: 80px;
  left: 260px;
  width: 560px;
  height: 260px;
  min-width: 280px;
  min-height: 140px;
  display: flex;
  flex-direction: column;
  background: rgba(4, 10, 4, 0.95);
  border: 1px solid #1e4a1e;
  border-radius: 6px;
  z-index: 40;
  box-shadow: 0 0 24px rgba(50, 255, 106, 0.1), 0 4px 20px rgba(0,0,0,0.7);
  overflow: hidden;
}

#console-win.hidden {
  display: none;
}

#console-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(10, 36, 10, 0.9);
  border-bottom: 1px solid #1e4a1e;
  cursor: move;
  flex-shrink: 0;
  user-select: none;
  border-radius: 6px 6px 0 0;
}

.console-title {
  font-size: 11px;
  color: #5adf7a;
  letter-spacing: 0.04em;
  font-family: Consolas, Monaco, 'Courier New', monospace;
}

#console-close {
  background: transparent;
  border: none;
  color: #666;
  font-size: 13px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

#console-close:hover {
  color: #ff5555;
}

#console-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 10px;
  font-family: Consolas, Monaco, 'Courier New', monospace;
  font-size: 11.5px;
  color: #aadcaa;
  line-height: 1.65;
  scrollbar-width: thin;
  scrollbar-color: #1e4a1e #050a05;
}

#console-body::-webkit-scrollbar { width: 5px; }
#console-body::-webkit-scrollbar-track { background: #050a05; }
#console-body::-webkit-scrollbar-thumb { background: #1e4a1e; border-radius: 3px; }
#console-body::-webkit-scrollbar-thumb:hover { background: #32ff6a; }

.console-line { white-space: pre-wrap; word-break: break-all; }
.console-ts   { color: #446044; }
.ctag         { font-weight: bold; }
.ctag-detect  { color: #ffd700; }
.ctag-block   { color: #32ff6a; }
.ctag-alert   { color: #ff5555; }
.ctag-info    { color: #44ddff; }
.ctag-attack  { color: #ff8844; }
.ctag-defend  { color: #88ff44; }
.ctag-warn    { color: #ffaa00; }

#console-resizer {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: se-resize;
  background: linear-gradient(
    135deg,
    transparent 40%,
    #1e4a1e 40%,
    #1e4a1e 55%,
    transparent 55%,
    transparent 65%,
    #1e4a1e 65%,
    #1e4a1e 80%,
    transparent 80%
  );
}

  /* ─── System Monitor Window ───────────────────────────────── */
  #sysmon-win {
    position: fixed;
    top: 80px;
    left: 860px;
    width: 420px;
    height: 340px;
    min-width: 300px;
    min-height: 240px;
    display: flex;
    flex-direction: column;
    background: rgba(2, 8, 14, 0.96);
    border: 1px solid #0a3a5a;
    border-radius: 6px;
    z-index: 41;
    box-shadow: 0 0 24px rgba(50, 180, 255, 0.08), 0 4px 20px rgba(0,0,0,0.8);
    overflow: hidden;
  }

  #sysmon-win.hidden { display: none; }

  #sysmon-titlebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background: rgba(4, 14, 28, 0.95);
    border-bottom: 1px solid #0a3a5a;
    cursor: move;
    flex-shrink: 0;
    user-select: none;
    border-radius: 6px 6px 0 0;
  }

  .sysmon-wintitle {
    font-size: 11px;
    color: #44aadd;
    letter-spacing: 0.04em;
    font-family: Consolas, Monaco, 'Courier New', monospace;
  }

  #sysmon-close {
    background: transparent;
    border: none;
    color: #556;
    font-size: 13px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    transition: color 0.15s;
  }
  #sysmon-close:hover { color: #ff5555; }

  #sysmon-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 10px 4px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    scrollbar-width: thin;
    scrollbar-color: #0a3a5a #020810;
  }
  #sysmon-body::-webkit-scrollbar { width: 5px; }
  #sysmon-body::-webkit-scrollbar-track { background: #020810; }
  #sysmon-body::-webkit-scrollbar-thumb { background: #0a3a5a; border-radius: 3px; }

  .sysmon-section {
    display: flex;
    flex-direction: column;
    gap: 3px;
  }

  .sysmon-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
  }

  .sysmon-label {
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 10.5px;
    color: #667788;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .sysmon-val {
    font-family: Consolas, Monaco, 'Courier New', monospace;
    font-size: 11px;
    letter-spacing: 0.02em;
  }

  .cpu-color    { color: #32ff6a; }
  .mem-color    { color: #44ccff; }
  .netin-color  { color: #ffaa00; }
  .netout-color { color: #ff5555; }

  .sysmon-chart {
    display: block;
    width: 100%;
    height: 60px;
    background: rgba(0,0,0,0.3);
    border: 1px solid #0a2030;
    border-radius: 3px;
  }

  #sysmon-resizer {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: se-resize;
    background: linear-gradient(
      135deg,
      transparent 40%,
      #0a3a5a 40%,
      #0a3a5a 55%,
      transparent 55%,
      transparent 65%,
      #0a3a5a 65%,
      #0a3a5a 80%,
      transparent 80%
    );
  }

/* ─── Chat Window ─────────────────────────────────────────── */
#chat-win {
  position: fixed;
  top: 210px;
  left: 520px;
  width: 440px;
  height: 280px;
  min-width: 280px;
  min-height: 170px;
  display: flex;
  flex-direction: column;
  background: rgba(8, 8, 14, 0.95);
  border: 1px solid #394050;
  border-radius: 6px;
  z-index: 42;
  box-shadow: 0 0 22px rgba(130, 160, 255, 0.09), 0 4px 20px rgba(0, 0, 0, 0.72);
  overflow: hidden;
}

#chat-win.hidden {
  display: none;
}

#chat-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  background: rgba(26, 30, 42, 0.95);
  border-bottom: 1px solid #394050;
  cursor: move;
  flex-shrink: 0;
  user-select: none;
  border-radius: 6px 6px 0 0;
}

.chat-title {
  font-size: 11px;
  color: #a8b7ff;
  letter-spacing: 0.04em;
  font-family: Consolas, Monaco, 'Courier New', monospace;
}

#chat-close {
  background: transparent;
  border: none;
  color: #666;
  font-size: 13px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}

#chat-close:hover {
  color: #ff5555;
}

#chat-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  scrollbar-width: thin;
  scrollbar-color: #394050 #0a0b12;
  background-color: var(--chat-bg-color);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
}

#chat-composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 10px;
  border-top: 1px solid #2e3444;
  background: rgba(10, 12, 20, 0.94);
}

#chat-live-input {
  flex: 1;
  min-width: 0;
  background: #0f131f;
  color: var(--chat-font-color);
  border: 1px solid #394050;
  border-radius: 16px;
  padding: 7px 11px;
  font-family: Consolas, Monaco, 'Courier New', monospace;
  font-size: var(--chat-font-size);
  outline: none;
}

#chat-live-input:focus {
  border-color: #5573aa;
}

#chat-send-btn {
  border: 1px solid #3c4d71;
  background: #1e2b44;
  color: #d9e5ff;
  border-radius: 14px;
  padding: 6px 12px;
  font-size: 11px;
  cursor: pointer;
  white-space: nowrap;
}

#chat-send-btn:hover,
#chat-send-btn:focus-visible {
  background: #25385c;
}

#chat-body::-webkit-scrollbar { width: 5px; }
#chat-body::-webkit-scrollbar-track { background: #0a0b12; }
#chat-body::-webkit-scrollbar-thumb { background: #394050; border-radius: 3px; }

.chat-line {
  display: flex;
  width: 100%;
}

.chat-line--theirs {
  justify-content: flex-start;
}

.chat-line--mine {
  justify-content: flex-end;
}

.chat-bubble {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 7px 10px;
  border: 1px solid #394050;
  border-radius: 12px;
  background: rgba(22, 24, 36, 0.9);
}

.chat-bubble--theirs {
  border-top-left-radius: 4px;
  border-color: #3a4050;
  background: rgba(24, 28, 42, 0.9);
}

.chat-bubble--mine {
  border-top-right-radius: 4px;
  border-color: #30517f;
  background: rgba(18, 40, 74, 0.92);
}

.chat-user {
  font-family: Consolas, Monaco, 'Courier New', monospace;
  font-size: calc(var(--chat-font-size) - 1.5px);
  letter-spacing: 0.04em;
  opacity: 0.95;
}

.chat-line--theirs .chat-user {
  color: #7cd7ff;
}

.chat-line--mine .chat-user {
  color: #9ec2ff;
  text-align: right;
}

.chat-meta {
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-line--mine .chat-meta {
  justify-content: flex-end;
}

.chat-avatar-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 1px;
}

.chat-line--theirs .chat-avatar-dot {
  background: #57d7ff;
  box-shadow: 0 0 6px rgba(87, 215, 255, 0.35);
}

.chat-line--mine .chat-avatar-dot {
  background: #8fa8ff;
  box-shadow: 0 0 6px rgba(143, 168, 255, 0.35);
}

.chat-time {
  font-family: Consolas, Monaco, 'Courier New', monospace;
  font-size: calc(var(--chat-font-size) - 2px);
  color: #7180a3;
  opacity: 0.95;
}

.chat-msg {
  font-family: Consolas, Monaco, 'Courier New', monospace;
  font-size: var(--chat-font-size);
  line-height: 1.5;
  color: var(--chat-font-color);
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-line--mine .chat-msg {
  color: var(--chat-font-color);
}

.chat-type-caret {
  display: inline-block;
  margin-left: 2px;
  color: #a8b7ff;
  text-shadow: 0 0 6px rgba(168, 183, 255, 0.4);
  animation: blink 1s steps(2, jump-none) infinite;
}

.chat-note {
  font-family: Consolas, Monaco, 'Courier New', monospace;
  font-size: 11px;
  color: #606a90;
  opacity: 0.9;
}

#chat-resizer {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: se-resize;
  background: linear-gradient(
    135deg,
    transparent 40%,
    #394050 40%,
    #394050 55%,
    transparent 55%,
    transparent 65%,
    #394050 65%,
    #394050 80%,
    transparent 80%
  );
}
