.app-body {
  min-height: 100vh;
}

.hidden { display: none !important; }

.gate {
  position: relative;
  z-index: 1;
  max-width: 28rem;
  margin: 0 auto;
  padding: clamp(3rem, 12vh, 6rem) 1.5rem 3rem;
  text-align: center;
}
.gate h1 {
  margin: 1.25rem 0 0.5rem;
  font-family: var(--display);
  font-size: clamp(1.8rem, 5vw, 2.4rem);
  font-weight: 600;
}
.gate-lead { color: var(--muted); margin: 0 0 1.5rem; }
.gate-note { color: var(--muted); font-size: 0.85rem; margin: 1.25rem 0; }
.tg-login { min-height: 48px; display: flex; justify-content: center; }

.gate-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 1.35rem 0 1rem;
  color: var(--muted);
  font-size: 0.85rem;
}
.gate-divider::before,
.gate-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.password-form {
  display: grid;
  gap: 0.65rem;
  text-align: left;
}
.password-form input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 0.85rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
}
.password-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.password-actions .btn,
.password-actions .btn-ghost-block {
  border: 0;
  cursor: pointer;
  width: 100%;
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  background: rgba(15, 20, 18, 0.55);
  backdrop-filter: blur(10px);
}
.side-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}
.profile {
  padding: 0.85rem 0;
  border-bottom: 1px solid var(--line);
}
.user-name { font-weight: 600; }
.user-balance { color: var(--accent); margin-top: 0.25rem; font-weight: 600; }
.small { font-size: 0.85rem; }
.field-label { font-size: 0.8rem; color: var(--muted); }

.select {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
}
.btn-block { width: 100%; border: 0; cursor: pointer; }
.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 999px;
  padding: 0.35rem 0.75rem;
  cursor: pointer;
  font: inherit;
}
.btn-ghost:hover { color: var(--ink); }
.btn-ghost-block {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ink);
}

.chat-main {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-height: 100vh;
}
.chat-head {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.95rem;
}
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}
.msg {
  max-width: min(42rem, 92%);
  padding: 0.9rem 1.1rem;
  border-radius: 1.1rem;
  border: 1px solid var(--line);
  background: var(--card);
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user {
  align-self: flex-end;
  background: rgba(200, 240, 108, 0.12);
}
.msg.assistant { align-self: flex-start; }
.msg.meta {
  align-self: center;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.85rem;
  padding: 0.25rem;
}

.composer {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.25rem 1.25rem;
  border-top: 1px solid var(--line);
  align-items: flex-end;
}
.composer textarea {
  flex: 1;
  resize: none;
  min-height: 2.75rem;
  max-height: 8rem;
  padding: 0.75rem 0.9rem;
  border-radius: 1rem;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  font: inherit;
}
.composer button { border: 0; cursor: pointer; flex-shrink: 0; }

.error {
  color: #ffb4a8;
  font-size: 0.9rem;
  margin: 0 1.25rem 1rem;
  text-align: left;
}
.gate .error { text-align: center; margin: 0.75rem 0; }

@media (max-width: 800px) {
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .chat-main { min-height: 70vh; max-height: none; }
}
