* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100vh; /* Фіксуємо висоту на весь екран */
  background: #010810; color: #00c8e8;
  font-family: 'Share Tech Mono', monospace; 
  overflow: hidden; /* Забороняємо скрол всієї сторінки */
}

@keyframes scanline { 0% { transform: translateY(-60px); } 100% { transform: translateY(100vh); } }
@keyframes blink-cur { 0%,49% { opacity: 1; } 50%,100% { opacity: 0; } }
@keyframes fadein { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: none; } }
@keyframes glow-breathe { 0%,100% { filter: drop-shadow(0 0 8px rgba(0,200,232,.35)); } 50% { filter: drop-shadow(0 0 22px rgba(0,200,232,.7)); } }
@keyframes pulse-dot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

.cursor { animation: blink-cur 1s step-end infinite; }
.msg-enter { animation: fadein .28s ease; }

input, button { font-family: 'Share Tech Mono', monospace; }

.grid-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image: linear-gradient(rgba(0,80,120,.04) 1px, transparent 1px), linear-gradient(90deg, rgba(0,80,120,.04) 1px, transparent 1px);
  background-size: 40px 40px;
}
.scanline {
  position: fixed; top: 0; left: 0; right: 0; height: 40px; z-index: 50; pointer-events: none;
  background: linear-gradient(transparent, rgba(0,180,220,.04), transparent);
  animation: scanline 9s linear infinite;
}

.view {
  position: absolute; inset: 0; z-index: 1;
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.3s ease;
}

.hidden { display: none !important; }

.panel {
  background: rgba(2,14,28,0.96); border: 1px solid #0a3050; backdrop-filter: blur(12px);
}
.login-panel { border-radius: 12px; padding: 40px 44px; width: 380px; text-align: center; position: relative; z-index: 1; }

.title-vt { font-family: 'VT323', monospace; font-size: clamp(20px, 4vw, 30px); letter-spacing: 0.25em; color: #00d4ff; line-height: 1; }
.subtitle { font-size: 10px; color: #1a5a6a; letter-spacing: 0.18em; }

.p03-input {
  background: transparent; border: 1px solid #0a3050; color: #00c8e8;
  padding: 9px 13px; font-size: 13px; outline: none; letter-spacing: 0.05em; border-radius: 3px; width: 100%;
}
.p03-btn {
  background: transparent; border: 1px solid #00c8e8; color: #00c8e8;
  padding: 8px 18px; font-size: 13px; cursor: pointer; letter-spacing: 0.12em; border-radius: 3px; transition: background .15s;
}
.p03-btn:hover:not(:disabled) { background: rgba(0,200,232,.1); }
.p03-btn.inactive { border-color: #0a3050; color: #1a5060; }
.p03-btn:disabled { border-color: #0a3050; color: #1a5060; cursor: not-allowed; }
.w-100 { width: 100%; }

/* Layout чату */
.chat-layout { 
  display: grid; 
  grid-template-rows: 48px 1fr 64px; /* Жорстко фіксуємо середню частину */
  grid-template-columns: 1fr; 
  height: 100vh;
  width: 100vw;
  transition: grid-template-columns 0.3s ease;
}

.sidebar-open {
  grid-template-columns: 1fr 264px;
}

.header { grid-column: 1/-1; display: flex; align-items: center; gap: 16px; padding: 0 18px; border-bottom: 1px solid #0a3050; z-index: 10; position: relative; }
.footer { grid-column: 1/-1; display: flex; align-items: center; gap: 10px; padding: 0 16px; border-top: 1px solid #0a3050; z-index: 10; position: relative; }

#main-content-area {
  grid-row: 2;
  grid-column: 1;
  display: flex;
  overflow: hidden; /* Не даємо контейнеру розширюватись */
  height: 100%;
}

/* СКРОЛ ТА ПОВЗУНОК ДЛЯ ЧАТУ */
#chat-messages {
  flex: 1;
  height: 100%;
  overflow-y: auto !important; /* Вмикаємо прокрутку */
  overflow-x: hidden;
  padding: 20px 24px; 
  display: flex; 
  flex-direction: column; 
  gap: 14px;
  scroll-behavior: smooth;
}

/* Стилізація скролбару (Chrome, Edge, Safari) */
#chat-messages::-webkit-scrollbar {
  width: 8px;
}
#chat-messages::-webkit-scrollbar-track {
  background: #010810;
  border-left: 1px solid #0a3050;
}
#chat-messages::-webkit-scrollbar-thumb {
  background: #0a3050;
  border: 1px solid #00c8e8;
}
#chat-messages::-webkit-scrollbar-thumb:hover {
  background: #00c8e8;
}

#diagram-panel {
  width: 0;
  overflow-y: auto;
  opacity: 0;
  border-left: none;
  transition: all 0.3s ease;
  background: rgba(2,14,28,0.96);
}

.sidebar { 
  grid-row: 2; 
  grid-column: 2; 
  border-left: 1px solid #0a3050; 
  display: none; 
  flex-direction: column; 
  overflow-y: auto; 
  background: #010810;
}

.sidebar-open .sidebar {
  display: flex;
  opacity: 1;
}

.dot { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: #00c8e8; animation: pulse-dot 2s infinite; flex-shrink: 0; }
.header-btn { background: transparent; border: 1px solid #0a3050; color: #3a8090; font-size: 13px; padding: 3px 10px; cursor: pointer; border-radius: 3px; }
.header-btn:hover { background: rgba(0,200,232,.08); }

.msg-box { padding: 9px 14px; max-width: 85%; font-size: 13px; line-height: 1.75; border-radius: 3px; white-space: pre-wrap; word-break: break-word; }
.msg-user { align-self: flex-end; background: rgba(0,40,80,.45); border: 1px solid #0a4060; color: #7dd4f0; }
.msg-bot { align-self: flex-start; background: rgba(0,18,38,.6); border: 1px solid #062040; color: #00c8e8; }

.side-section { padding: 13px 16px; border-bottom: 1px solid #0a3050; }
.side-label { font-size: 9px; color: #0a4050; letter-spacing: 0.2em; margin-bottom: 9px; }