:root {
  --cyan: #00e5ff;
  --cyan-dim: #00e5ff44;
  --cyan-glow: #00e5ff22;
  --red: #ff1744;
  --bg: #050810;
  --bg2: #080d1a;
  --surface: #0c1220;
  --border: #00e5ff1a;
  --text: #c8eeff;
  --text-dim: #5a8a9f;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

/* ---- BOOT / INTRO SCREEN ---- */
#boot-screen {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.5s ease;
}

#boot-screen.boot-fade-out {
  opacity: 0;
}

.boot-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1.2rem;
  transform: translateX(-15%);
}

.boot-row {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}

#boot-canvas {
  width: 220px;
  height: 220px;
  display: block;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* Three.js Canvas */
#three-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

/* Grid background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(var(--border) 1px, transparent 1px),
    linear-gradient(90deg, var(--border) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Radial glow center */
body::after {
  content: '';
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 800px;
  height: 800px;
  background: radial-gradient(ellipse, #00e5ff08 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
}

/* ---- HEADER ---- */
header {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, #050810 0%, transparent 100%);
}

.logo {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-hex {
  width: 40px;
  height: 40px;
  position: relative;
  animation: pulse-hex 3s ease-in-out infinite;
}

@keyframes pulse-hex {
  0%, 100% { filter: drop-shadow(0 0 6px var(--cyan)); }
  50% { filter: drop-shadow(0 0 18px var(--cyan)); }
}

.logo-text {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 1.6rem;
  letter-spacing: 0.25em;
  color: var(--cyan);
  text-shadow: 0 0 30px var(--cyan);
}

.logo-sub {
  font-size: 0.6rem;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #00ff88;
  margin-right: 6px;
  box-shadow: 0 0 8px #00ff88;
  animation: blink 2s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.status-dot.offline {
  background: var(--red);
  box-shadow: 0 0 8px var(--red);
}

/* ---- SIDEBAR TOGGLE (hamburger, mobile/tablet only) ---- */
.sidebar-toggle-btn {
  display: none;
  background: transparent;
  border: 1px solid var(--cyan-dim);
  color: var(--cyan);
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
  margin-right: 1rem;
}

.sidebar-toggle-btn:hover {
  background: var(--cyan-glow);
  border-color: var(--cyan);
}

/* ---- SIDEBAR BACKDROP (mobile/tablet only) ---- */
#sidebar-backdrop {
  display: none;
}

/* ---- MAIN LAYOUT ---- */
main {
  flex: 1;
  display: flex;
  gap: 0;
  overflow: hidden;
  position: relative;
  z-index: 10;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: 200px;
  border-right: 1px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  flex-shrink: 0;
}

.sidebar-section h3 {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.55rem;
  letter-spacing: 0.2em;
  color: var(--text-dim);
  margin-bottom: 0.8rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: var(--text-dim);
  margin-bottom: 0.4rem;
}

.stat-val {
  color: var(--cyan);
}

.sidebar-btn {
  width: 100%;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  padding: 0.5rem 0.8rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
  margin-bottom: 0.4rem;
}

.sidebar-btn:hover {
  border-color: var(--cyan-dim);
  color: var(--cyan);
  background: var(--cyan-glow);
}

.sidebar-btn.danger:hover {
  border-color: var(--red);
  color: var(--red);
  background: #ff174411;
}

.sidebar-btn.confirm-armed {
  border-color: var(--red);
  color: var(--red);
  background: #ff174422;
  animation: confirm-pulse 0.6s ease-in-out infinite;
}

@keyframes confirm-pulse {
  0%, 100% { box-shadow: 0 0 4px #ff174455; }
  50% { box-shadow: 0 0 14px #ff1744aa; }
}

/* ---- SIDEBAR GIF ---- */
.sidebar-gif {
  width: 100%;
  display: block;
  border: 1px solid var(--border);
  border-radius: 2px;
  opacity: 0.85;
}

/* ---- PORTFOLIO LINK ---- */
.portfolio-text {
  font-size: 0.7rem;
  color: var(--text-dim);
  line-height: 1.5;
  margin-bottom: 0.8rem;
}

.portfolio-btn {
  display: block;
  text-align: center;
  text-decoration: none;
}

/* ---- CHAT AREA ---- */
.chat-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#chat-box {
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  scroll-behavior: smooth;
}

#chat-box::-webkit-scrollbar { width: 4px; }
#chat-box::-webkit-scrollbar-track { background: transparent; }
#chat-box::-webkit-scrollbar-thumb { background: var(--cyan-dim); border-radius: 2px; }

/* ---- MESSAGES ---- */
.msg {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  animation: msg-in 0.3s ease-out;
  max-width: 80%;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.axon { align-self: flex-start; align-items: flex-start; }

.msg-label {
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: var(--text-dim);
}

.msg.axon .msg-label { color: var(--cyan); opacity: 0.7; }

.msg-bubble {
  padding: 0.7rem 1rem;
  border-radius: 2px;
  font-size: 0.85rem;
  line-height: 1.6;
}

.msg-bubble p {
  margin: 0 0 0.6rem 0;
}

.msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg-bubble a {
  color: var(--cyan);
  text-decoration: underline;
  text-decoration-color: var(--cyan-dim);
}

.msg-bubble a:hover {
  text-decoration-color: var(--cyan);
}

.axon-highlight {
  background: var(--cyan-glow);
  color: var(--cyan);
  padding: 0.05rem 0.3rem;
  border-radius: 2px;
}

/* ---- FENCED CODE BLOCKS ---- */
.code-block {
  margin: 0.6rem 0;
  background: var(--bg);
  border: 1px solid var(--cyan-dim);
  border-radius: 4px;
  overflow: hidden;
}

.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.35rem 0.7rem;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
}

.code-lang {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.6rem;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  text-transform: uppercase;
}

.copy-code-btn {
  background: transparent;
  border: 1px solid var(--cyan-dim);
  color: var(--cyan);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.6rem;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.6rem;
  cursor: pointer;
  transition: all 0.2s;
}

.copy-code-btn:hover {
  background: var(--cyan-glow);
  border-color: var(--cyan);
}

.code-block pre {
  margin: 0;
  padding: 0.7rem;
  overflow-x: auto;
}

.code-block code {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  color: var(--text);
  white-space: pre;
  background: none;
  padding: 0;
  border-radius: 0;
}

.msg.user .msg-bubble {
  background: #0d1a2e;
  border: 1px solid #00e5ff33;
  color: #e0f4ff;
  border-right: 3px solid var(--cyan);
}

.msg.axon .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-left: 3px solid var(--cyan);
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 0.7rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--cyan);
  width: fit-content;
}

/* Search indicator */
.search-indicator {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 0.7rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid #00ff88;
  width: fit-content;
  color: var(--cyan);
  opacity: 0.6;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
}

.search-indicator .search-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--cyan);
  border-radius: 50%;
  position: relative;
  animation: search-pulse 1.5s ease-in-out infinite;
}

.search-indicator .search-icon::after {
  content: '';
  position: absolute;
  bottom: -4px;
  right: -4px;
  width: 6px;
  height: 2px;
  background: var(--cyan);
  transform: rotate(45deg);
}

@keyframes search-pulse {
  0%, 100% { opacity: 0.4; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}

.search-indicator .search-dots span {
  animation: search-dot-blink 1.4s ease-in-out infinite;
}

.search-indicator .search-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.search-indicator .search-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes search-dot-blink {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

.typing-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  animation: typing 1.2s ease-in-out infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
  0%, 100% { opacity: 0.2; transform: scale(0.8); }
  50% { opacity: 1; transform: scale(1.2); }
}

/* Boot message */
.boot-msg {
  align-self: flex-start;
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 0.05em;
  padding: 1rem 0;
  border-left: 2px solid var(--border);
  padding-left: 1rem;
}

.boot-msg span { color: var(--cyan); }

/* ---- INPUT AREA ---- */
.input-area {
  border-top: 1px solid var(--border);
  padding: 1rem 2rem;
  background: linear-gradient(0deg, var(--bg) 0%, transparent 100%);
}

.input-row {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 0.6rem 1rem;
  transition: border-color 0.2s;
}

.input-row:focus-within {
  border-color: var(--cyan-dim);
  box-shadow: 0 0 20px var(--cyan-glow);
}

.input-prefix {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.7rem;
  color: var(--cyan);
  opacity: 0.6;
  white-space: nowrap;
}

#user-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.9rem;
  outline: none;
  caret-color: var(--cyan);
}

#user-input::placeholder { color: var(--text-dim); opacity: 0.5; }

#send-btn {
  background: transparent;
  border: 1px solid var(--cyan-dim);
  color: var(--cyan);
  font-family: 'Orbitron', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

#send-btn:hover {
  background: var(--cyan-glow);
  border-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-glow);
}

#send-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* VOL button */
#vol-btn {
  background: transparent;
  border: 1px solid var(--cyan-dim);
  color: var(--cyan);
  font-family: 'Orbitron', sans-serif;
  font-size: 0.65rem;
  letter-spacing: 0.15em;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  transition: all 0.3s ease;
  white-space: nowrap;
  flex-shrink: 0;
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

#vol-btn:hover {
  background: var(--cyan-glow);
  border-color: var(--cyan);
  box-shadow: 0 0 12px var(--cyan-glow);
}

#vol-btn.active {
  color: #00ff88;
  border-color: #00ff88;
  box-shadow: 0 0 12px #00ff8866;
}

.vol-arcs {
  display: none;
  gap: 2px;
  align-items: center;
  margin-left: 2px;
}

#vol-btn:not(.active) .vol-arcs {
  display: inline-flex;
}

.vol-arc {
  width: 3px;
  height: 10px;
  border-radius: 2px;
  background: #00ff88;
  opacity: 0.3;
}

.vol-arc:nth-child(1) {
  height: 6px;
  animation: vol-arc-pulse 0.8s ease-in-out infinite;
}

.vol-arc:nth-child(2) {
  height: 10px;
  animation: vol-arc-pulse 0.8s ease-in-out infinite 0.15s;
}

.vol-arc:nth-child(3) {
  height: 14px;
  animation: vol-arc-pulse 0.8s ease-in-out infinite 0.3s;
}

@keyframes vol-arc-pulse {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

/* Hover-to-speak button on AXON messages */
.msg.axon .msg-bubble {
  position: relative;
}

.speak-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: var(--surface);
  border: 1px solid var(--cyan-dim);
  color: var(--cyan);
  font-size: 0.6rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 5;
  padding: 0;
  line-height: 1;
}

.msg.axon .msg-bubble:hover .speak-btn {
  opacity: 1;
}

.speak-btn:hover {
  background: var(--cyan-glow);
  border-color: var(--cyan);
}

.speak-btn.speaking {
  color: #00ff88;
  border-color: #00ff88;
}

/* ---- CORNER DECORATIONS ---- */
.corner {
  position: fixed;
  width: 20px;
  height: 20px;
  z-index: 100;
  opacity: 0.4;
}
.corner-tl { top: 8px; left: 8px; border-top: 2px solid var(--cyan); border-left: 2px solid var(--cyan); }
.corner-tr { top: 8px; right: 8px; border-top: 2px solid var(--cyan); border-right: 2px solid var(--cyan); }
.corner-bl { bottom: 8px; left: 8px; border-bottom: 2px solid var(--cyan); border-left: 2px solid var(--cyan); }
.corner-br { bottom: 8px; right: 8px; border-bottom: 2px solid var(--cyan); border-right: 2px solid var(--cyan); }

/* Scan line */
@keyframes scan {
  from { top: -2px; }
  to   { top: 100vh; }
}
.scanline {
  position: fixed;
  left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--cyan-glow), transparent);
  z-index: 200;
  pointer-events: none;
  animation: scan 8s linear infinite;
}

/* ============================================
   RESPONSIVE — TABLET (<=1024px)
   Sidebar becomes a slide-in overlay drawer.
   ============================================ */
@media (max-width: 1024px) {
  .sidebar-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .header-model {
    display: none;
  }

  header {
    padding: 1rem 1.25rem;
  }

  .header-right {
    gap: 1rem;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    width: 240px;
    max-width: 80vw;
    background: var(--bg);
    z-index: 400;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  #sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 399;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
  }

  #sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ============================================
   RESPONSIVE — MOBILE (<768px)
   ============================================ */
@media (max-width: 767px) {
  .logo-sub {
    display: none;
  }

  .logo-text {
    font-size: 1.3rem;
  }

  header {
    padding: 0.75rem 1rem;
  }

  .header-right {
    gap: 0.7rem;
    font-size: 0.6rem;
  }

  #chat-box {
    padding: 1rem;
  }

  .msg {
    max-width: 90%;
  }

  .input-area {
    padding: 0.75rem;
  }

  .input-row {
    gap: 0.5rem;
    padding: 0.5rem 0.7rem;
  }

  .input-prefix {
    display: none;
  }

  #user-input {
    /* 16px min prevents iOS Safari auto-zoom on focus */
    font-size: 1rem;
    min-width: 0;
  }

  #send-btn,
  #vol-btn {
    padding: 0.5rem 0.6rem;
    font-size: 0.6rem;
  }

  .vol-arcs {
    display: none !important;
  }

  /* Boot screen: stack instead of side-by-side, drop the left-shift so nothing clips */
  .boot-stack {
    transform: none;
    align-items: center;
    max-width: 90vw;
  }

  .boot-row {
    flex-direction: column;
    gap: 1rem;
  }

  #boot-canvas {
    width: 150px;
    height: 150px;
  }

  .boot-msg {
    font-size: 0.7rem;
  }
}
