/* ============================================================
   Global Variables & Base
   ============================================================ */
:root {
  --bg0: #000000;
  --bg1: #000000;
  --fg: #c7c7c7;
  --muted: #94a3b8;
  --cyan: #66d9ef;
  --green: #33ff66;
  --red: #ff6b6b;
  --blue: #6fa8dc;
  --panel: rgba(255, 255, 255, 0.03);
  --gap: 10px;
}

* { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: radial-gradient(1200px 800px at 70% -20%, rgba(14,165,233,0.08), transparent 60%),
              linear-gradient(0deg, var(--bg0), var(--bg1));
  color: var(--fg);
  display: grid;
  grid-template-rows: 1fr auto;
}

/* ============================================================
   Layout Grid
   ============================================================ */
#workspace.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  grid-template-areas:
    "term editor"
    "chat mud";
  gap: var(--gap);
  padding: var(--gap);
  min-height: 0;
  height: 100vh;
}

/* ============================================================
   Panels
   ============================================================ */
.panel {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.boxHeader {
  padding: 8px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 2;
}

.boxHeader b { color: var(--cyan); }

.boxFooter {
  padding: 8px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  gap: 8px;
  align-items: center;
  position: sticky;
  bottom: 0;
  z-index: 2;
}

.scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
[hidden] { display: none !important; }

/* ============================================================
   Terminal
   ============================================================ */
#terminalBox { grid-area: term; }

#terminal {
  padding: 16px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.4;
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.4);
}

#terminal::after {
  content: "";
  position: fixed;
  left: 0; right: 0; top: 0; bottom: 0;
  pointer-events: none;
  background: linear-gradient(rgba(255,255,255,0.02), rgba(0,0,0,0.03));
  mix-blend-mode: overlay;
  opacity: 0.35;
}

/* ============================================================
   Input + Command Line
   ============================================================ */
#input {
  border-top: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
}

#cmdline {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

#cmd {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: transparent;
  text-shadow: 0 0 0 #c7c7c7;
  font: inherit;
  line-height: 1.25;
  padding: 0;
  margin: 0;
  caret-color: transparent;
}

#cmd-mirror {
  position: absolute;
  left: 0;
  top: 0;
  visibility: hidden;
  white-space: pre;
  pointer-events: none;
}

#cmd-caret {
  position: absolute;
  left: 0;
  top: 0;
  width: 0.6em;
  height: 1.25em;
  background: #fff;
  animation: blink 1s steps(1) infinite;
  pointer-events: none;
}
@keyframes blink { 50% { opacity: 0; } }

#prompt { color: var(--cyan); letter-spacing: 0.2px; }
#cwd { color: var(--blue); }
#ps1 { color: var(--green); }

/* ============================================================
   Editor
   ============================================================ */
#editorBox { grid-area: editor; }
#editor { height: 100%; }

.CodeMirror {
  height: 100%;
  background: #0f1220;
  color: var(--fg);
  border-top: 1px solid rgba(255,255,255,0.06);
}

.cm-keymap .CodeMirror-cursor { border-left: 2px solid var(--cyan); }

.note { color: var(--muted); font-size: 12px; }

.close-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  padding: 0 6px;
  cursor: pointer;
  border-radius: 4px;
  transition: color 0.2s ease, background 0.2s ease;
}

.close-btn:hover {
  color: var(--red);
  background: rgba(255,255,255,0.05);
}

/* ============================================================
   Chat
   ============================================================ */
#chatPanel { grid-area: chat; }
#chatMessages { white-space: pre-wrap; word-break: break-word; padding: 8px 10px; }
#chatInputBar input#chatInput { flex: 1 1 auto; min-width: 0; }
#chatInputBar button#chatSend { flex: 0 0 auto; }

#chatSend {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
}

#chatFooter,
#chatPanel .chat-footer {
  display: flex;
  gap: 8px;
  align-items: stretch;
  height: var(--prompt-h, 40px);
}

/* ============================================================
   MUD (Placeholder)
   ============================================================ */
#mudBox { grid-area: mud; }

/* ============================================================
   Buttons
   ============================================================ */
button {
  background: var(--panel);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--fg);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}
button:hover { border-color: rgba(255,255,255,0.18); }

.tag { font-size: 12px; color: var(--muted); }

/* ============================================================
   Utility Classes
   ============================================================ */
.muted { color: var(--muted); }
.ok { color: var(--green); }
.err { color: var(--red); }
.dim { opacity: 0.9; }
.glow { text-shadow: 0 0 6px rgba(0,200,255,0.35); }
code { background: rgba(255,255,255,0.03); padding: 2px 4px; border-radius: 4px; }
