*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  /* ОСНОВНОЙ ФОН */
  --bg-gradient: linear-gradient(180deg, #DDE2EE 0%, #FFFFFF 100%);

  /* ПАНЕЛИ */
  --bg-panel: rgba(255, 255, 255, 0.55);

  /* ТЕКСТ */
  --text-main: #0b0f19;
  --text-muted: #6b7280;

  /* ДРУГОЕ */
  --divider: rgba(0, 0, 0, 0.08);
  --shadow-soft: 0 18px 40px rgba(15, 23, 42, 0.18);
}

body {
  margin: 0;
  height: 100vh;
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-gradient);
  color: var(--text-main);
}

/* ЛЕЙАУТ */

.layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* SIDEBAR */

.sidebar {
  width: 260px;
  background: #ffffff;
  color: #111827;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 22px;
  padding: 24px 24px 32px;
  border-right: 1px solid var(--divider);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 600;
}

.logo-img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.sidebar-beta {
  margin-top: 48px;
}

.beta-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.sidebar-beta p {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #6b7280;
}

.sidebar-bottom {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #9ca3af;
}

.sidebar-chats{ margin-top: 22px; display:flex; flex-direction:column; gap:12px; }
.chats-head{ display:flex; align-items:center; justify-content:space-between; }
.chats-title{ font-size:11px; letter-spacing:.18em; text-transform:uppercase; color:#6b7280; font-weight:700; }
.chats-new{ width:28px; height:28px; border-radius:10px; border:0; background:#111827; color:#fff; cursor:pointer; }

.chat-list{ display:flex; flex-direction:column; gap:8px; max-height: 52vh; overflow:auto; padding-right: 6px; }
.chat-item{ text-align:left; border:0; cursor:pointer; padding:10px 12px; border-radius:12px; background:rgba(17,24,39,.06); color:#111827; font-size:13px; }
.chat-item.active{ background:rgba(17,24,39,.12); }

.sidebar-footer{ margin-top:auto; padding-top:16px; }
.sidebar-auth-btn{ width:100%; border:0; border-radius:12px; padding:10px 12px; cursor:pointer; background:#111827; color:#fff; font-size:13px; }
.sidebar-user{ display:flex; align-items:center; gap:10px; }
.avatar{ width:34px; height:34px; border-radius:999px; overflow:hidden; background:rgba(17,24,39,.1); display:flex; align-items:center; justify-content:center; color:#111827; font-weight:700; }
.avatar img{ width:100%; height:100%; object-fit:cover; }
.user-meta{ display:flex; flex-direction:column; gap:4px; }
.user-name{ font-size:12px; color:#111827; font-weight:700; }
.user-logout{ border:0; background:transparent; padding:0; cursor:pointer; font-size:12px; color:#6b7280; text-align:left; }

/* MAIN */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* TOPBAR */

.topbar {
  height: 56px;
  padding: 0 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--divider);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: #6b7280;
  backdrop-filter: blur(6px);
}

/* CANVAS */

.canvas {
  position: relative;
  flex: 1;
  padding: 32px 72px 24px;
  overflow: visible;
}

/* НАПРАВЛЯЮЩИЕ */

.grid-line {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 1px;
  opacity: 0;
  pointer-events: none;
}

.grid-line-left {
  left: 32%;
}

.grid-line-right {
  right: 10%;
}

/* ЧАТ */

.chat-shell {
  position: relative;
  z-index: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* GALEN */

.galen-block {
  margin-top: 80px;
  text-align: center;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
  opacity: 0.9;
}

.galen-avatar img {
  width: 160px;
  height: 160px;
  object-fit: contain;
  filter: drop-shadow(0 18px 40px rgba(15, 23, 42, 0.35));
  animation: galen-float 6s ease-in-out infinite;
}

.galen-phrase {
  margin-top: 16px;
  font-size: 14px;
  color: #4b5563;
}

/* СООБЩЕНИЯ */

.chat-messages {
  margin-top: 40px;
  width: 100%;
  max-width: 820px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 32px;
  overflow-y: auto;
}

.msg {
  max-width: 78%;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  white-space: pre-wrap;
  animation: msg-pop 0.16s ease-out;
}

/* USER */

.msg.user {
  margin-left: auto;
  background: #ffffff;
  color: #111827;
  padding: 12px 16px;
  border-radius: 18px;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.18);
}

/* GALEN */

.msg.bot {
  margin-right: auto;
  background: transparent;
  color: #0b0f19;
  padding: 0;
}

/* SYSTEM */

.msg.system {
  margin: 0 auto;
  background: transparent;
  color: #6b7280;
  font-size: 12px;
}

/* LOADER */

.msg.loading {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dots {
  display: inline-flex;
  gap: 3px;
}

.dots span {
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: #9ca3af;
  animation: dots 0.9s infinite ease-in-out;
}

.dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.dots span:nth-child(3) {
  animation-delay: 0.3s;
}

/* INPUT */

.input-bar {
  padding: 0 72px 32px;
}

.input-pill {
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  background: #ffffff;
  border-radius: 999px;
  box-shadow: var(--shadow-soft);
  padding: 4px 6px 4px 20px;
}

.input-pill input {
  flex: 1;
  border: none;
  outline: none;
  padding: 10px 0;
  font-size: 15px;
  background: transparent;
  color: #111827;
}

.input-pill input::placeholder {
  color: #9ca3af;
}

.input-pill button {
  border: none;
  cursor: pointer;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111827;
  color: #ffffff;
  font-size: 18px;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}

.input-pill button:hover {
  transform: translateX(2px) translateY(-1px);
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.35);
}

.input-pill button:disabled {
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
  transform: none;
}

/* АНИМАЦИИ */

@keyframes galen-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes msg-pop {
  from {
    transform: scale(0.96) translateY(4px);
    opacity: 0;
  }
  to {
    transform: scale(1) translateY(0);
    opacity: 1;
  }
}

@keyframes dots {
  0%, 80%, 100% {
    transform: scale(0.7);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* АДАПТИВ */

@media (max-width: 1024px) {
  .sidebar {
    display: none;
  }

  .canvas {
    padding: 24px 20px 20px;
  }

  .input-bar {
    padding: 0 20px 20px;
  }

  .grid-line-left {
    left: 25%;
  }

  .grid-line-right {
    right: 6%;
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 0 16px;
    font-size: 10px;
  }

  .galen-block {
    margin-top: 40px;
  }

  .chat-messages {
    max-width: 100%;
  }

  .input-pill {
    max-width: 100%;
    padding-left: 16px;
  }

  .msg {
    max-width: 90%;
  }
}
