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

:root {
  --bg: #050816;
  --bg-alt: #0b1020;
  --panel: #111827;
  --accent: #22c55e;
  --accent-soft: rgba(34, 197, 94, 0.16);
  --danger: #ef4444;
  --text: #e5e7eb;
  --text-muted: #9ca3af;
  --border: #1f2933;
  --radius-lg: 16px;
  --radius-md: 10px;
  --shadow-soft: 0 18px 45px rgba(0, 0, 0, 0.65);
  --shadow-panel: 0 12px 30px rgba(0, 0, 0, 0.5);
}

html,
body {
  height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "Segoe UI", sans-serif;
  color: var(--text);
  background: radial-gradient(circle at top, #1f2937 0, #020617 50%, #000 100%);
}

body {
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 16px;
}

.app-shell {
  width: 100%;
  max-width: 1100px;
  background: linear-gradient(145deg, #020617, #020617f0);
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.small-shell {
  max-width: 480px;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  background: linear-gradient(
      to right,
      rgba(34, 197, 94, 0.09),
      transparent 40%
    ),
    rgba(15, 23, 42, 0.98);
  backdrop-filter: blur(14px);
}

.top-bar h1 {
  font-size: 1.1rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #f9fafb;
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.safety-pill {
  font-size: 0.7rem;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(34, 197, 94, 0.4);
  background: linear-gradient(
    90deg,
    rgba(34, 197, 94, 0.16),
    rgba(34, 197, 94, 0.06)
  );
  color: #bbf7d0;
  text-wrap: nowrap;
}

.user-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

main {
  padding: 16px;
  flex: 1;
  overflow: auto;
}

.chat-main {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 16px;
  height: calc(100% - 8px);
}

.panel {
  background: radial-gradient(circle at top left, #111827 0, #020617 55%);
  border-radius: 20px;
  padding: 16px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: var(--shadow-panel);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form h2 {
  margin-bottom: 4px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.9rem;
}

input,
textarea,
select {
  background: rgba(15, 23, 42, 0.85);
  border-radius: 10px;
  border: 1px solid rgba(55, 65, 81, 0.85);
  padding: 8px 10px;
  color: var(--text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease,
    background 0.16s ease;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(34, 197, 94, 0.4);
  background: rgba(15, 23, 42, 0.97);
}

textarea {
  resize: vertical;
}

.btn {
  border-radius: 999px;
  border: none;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease, box-shadow 0.12s ease,
    background 0.12s ease, border-color 0.12s ease;
}

.btn.primary {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  color: #022c22;
  box-shadow: 0 10px 25px rgba(34, 197, 94, 0.45);
}

.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(34, 197, 94, 0.55);
}

.btn.secondary {
  background: rgba(15, 23, 42, 0.8);
  color: var(--text);
  border: 1px solid rgba(148, 163, 184, 0.5);
}

.btn.secondary:hover {
  background: rgba(31, 41, 55, 0.95);
}

.btn.danger {
  background: rgba(239, 68, 68, 0.12);
  color: #fecaca;
  border: 1px solid rgba(248, 113, 113, 0.7);
}

.btn.danger:hover {
  background: rgba(239, 68, 68, 0.3);
}

.btn.small {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.btn.full-width {
  width: 100%;
}

.hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.switch-auth {
  text-align: center;
  font-size: 0.85rem;
  margin-top: 6px;
}

.switch-auth a {
  color: #a5b4fc;
}

.status-msg {
  font-size: 0.8rem;
  margin-top: 4px;
}

.status-msg.error {
  color: #fecaca;
}

.status-msg.success {
  color: #bbf7d0;
}

.inline {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

/* Chat layout */

.sidebar {
  background: radial-gradient(circle at top left, #020617 0, #020617 60%);
  border-radius: 18px;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.friends-list {
  list-style: none;
  margin-top: 4px;
  padding: 0;
  flex: 1;
  overflow-y: auto;
}

.friend-item {
  padding: 8px 10px;
  border-radius: 10px;
  margin-bottom: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  cursor: pointer;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid transparent;
  transition: background 0.12s ease, border-color 0.12s ease,
    transform 0.08s ease;
}

.friend-item:hover {
  background: rgba(17, 24, 39, 0.95);
  border-color: rgba(34, 197, 94, 0.45);
  transform: translateY(-1px);
}

.friend-item.active {
  background: linear-gradient(145deg, #16a34a1f, #16a34a3a);
  border-color: rgba(34, 197, 94, 0.9);
}

.friend-name {
  font-size: 0.9rem;
}

.friend-handle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.chat-panel {
  background: radial-gradient(circle at top, #020617 0, #020617 60%);
  border-radius: 18px;
  padding: 12px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.chat-placeholder {
  flex: 1;
  border-radius: 14px;
  border: 1px dashed rgba(148, 163, 184, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.chat-area {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.chat-area.hidden {
  display: none;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.35);
  background: radial-gradient(circle at top left, #020617, #020617f5);
}

.chat-header h2 {
  font-size: 1rem;
}

.chat-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Messages */

.messages {
  flex: 1;
  margin-top: 8px;
  padding: 8px;
  border-radius: 14px;
  background: radial-gradient(circle at top, #020617, #020617f0);
  border: 1px solid rgba(55, 65, 81, 0.9);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.message {
  max-width: 74%;
  padding: 8px 10px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.86rem;
  position: relative;
}

.message.me {
  margin-left: auto;
  background: linear-gradient(145deg, #22c55e, #16a34a);
  color: #022c22;
  border-bottom-right-radius: 4px;
}

.message.other {
  margin-right: auto;
  background: rgba(15, 23, 42, 0.98);
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-bottom-left-radius: 4px;
}

.message-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  opacity: 0.8;
}

.message-sender {
  font-weight: 600;
}

.message-time {
  margin-left: 8px;
}

.message-text {
  white-space: pre-wrap;
  word-wrap: break-word;
}

.typing-indicator {
  font-size: 0.78rem;
  color: var(--text-muted);
  padding: 4px 6px;
  min-height: 18px;
}

/* Message form */

.message-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-top: 6px;
}

#message-input {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
}

/* Profile */

.profile-main {
  max-width: 480px;
  margin: 0 auto;
}

.hidden {
  display: none !important;
}

@media (max-width: 820px) {
  .chat-main {
    grid-template-columns: 1fr;
  }

  .sidebar {
    order: 2;
    max-height: 220px;
  }

  .chat-panel {
    order: 1;
  }

  body {
    padding: 8px;
  }
}

@media (max-width: 480px) {
  .top-bar-right {
    gap: 4px;
  }
  .safety-pill {
    display: none;
  }
}
