:root {
  --bg: #0c0e14;
  --surface: #141824;
  --surface2: #1c2130;
  --border: rgba(255, 255, 255, 0.08);
  --text: #e8eaf0;
  --muted: #8b93a7;
  --accent: #818cf8;
  --radius: 14px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  font-family: "DM Sans", system-ui, sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: radial-gradient(1200px 600px at 20% -10%, #1e1b4b33, transparent),
    radial-gradient(900px 500px at 90% 10%, #0f766e22, transparent), var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

#app {
  min-height: 100vh;
}

.panel.gate {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.gate-inner {
  width: min(420px, 100%);
  background: linear-gradient(160deg, var(--surface), var(--surface2));
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  padding: 32px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-bottom: 28px;
}

.logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: conic-gradient(from 210deg, #6366f1, #22d3ee, #a855f7, #6366f1);
  flex-shrink: 0;
}

.logo.sm {
  width: 28px;
  height: 28px;
  border-radius: 9px;
}

.brand h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.join-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.join-form label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-top: 6px;
}

.join-form input,
.join-form select {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  font: inherit;
}

.join-form input:focus,
.join-form select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn {
  border: none;
  border-radius: 11px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn:active {
  transform: scale(0.98);
}

.btn.primary {
  margin-top: 12px;
  background: linear-gradient(135deg, #6366f1, #7c3aed);
  color: #fff;
}

.btn.primary:hover {
  filter: brightness(1.06);
}

.hint {
  margin-top: 20px;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.5;
}

.hint a {
  color: var(--accent);
}

.hint code {
  font-size: 0.85em;
  background: rgba(0, 0, 0, 0.35);
  padding: 2px 6px;
  border-radius: 6px;
}

/* Chat layout */
.chat {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

@media (max-width: 820px) {
  .chat {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-height: 100dvh;
  }
  .main {
    flex: 1 1 auto;
    min-width: 0;
  }
  .sidebar {
    flex-shrink: 0;
    flex-direction: row;
    flex-wrap: wrap;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .room-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    width: 100%;
    max-height: none;
  }
  .room-list li {
    flex: 1 1 auto;
  }
}

.sidebar {
  background: rgba(12, 14, 20, 0.92);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(10px);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-note {
  margin: 0;
  padding: 12px 16px 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

.room-list {
  list-style: none;
  margin: 0;
  padding: 12px;
  flex: 1;
  overflow: auto;
}

.room-list button {
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.room-list button:hover {
  background: rgba(255, 255, 255, 0.04);
}

.room-list button.active {
  background: rgba(99, 102, 241, 0.18);
  border-color: rgba(99, 102, 241, 0.35);
}

.me {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.avatar {
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--av, #6366f1);
  flex-shrink: 0;
}

.me-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.linkish {
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  padding: 0;
  cursor: pointer;
  text-decoration: underline;
}

.linkish:hover {
  color: var(--text);
}

.main {
  display: flex;
  flex-direction: column;
  overflow: visible;
  background: rgba(20, 24, 36, 0.55);
}

.chat-scroll {
  flex: 0 0 auto;
  overflow: visible;
  min-height: auto;
}

.main-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.main-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.sub {
  margin: 6px 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 52ch;
}

.badge {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 6px 10px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.ok {
  background: rgba(34, 197, 94, 0.15);
  color: #4ade80;
  border: 1px solid rgba(34, 197, 94, 0.35);
}

.badge.warn {
  background: rgba(234, 179, 8, 0.15);
  color: #facc15;
  border: 1px solid rgba(234, 179, 8, 0.35);
}

.messages {
  padding: 20px 24px 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  max-width: min(720px, 92%);
  align-self: flex-start;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px 12px;
  animation: in 0.22s ease;
  position: relative;
}

.msg-quote {
  margin: 0 0 5px;
  padding: 4px 8px 4px 6px;
  border-left: 2px solid rgba(129, 140, 248, 0.75);
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.2);
  max-width: 100%;
}

.msg-quote-author {
  display: block;
  color: #a5b4fc;
  font-weight: 600;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-quote-text {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.28;
  word-break: break-word;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.msg-reply-btn {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.32);
  color: var(--text);
  font-size: 0.85rem;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
  opacity: 0.85;
}

.msg-reply-btn:active {
  opacity: 1;
  transform: scale(0.96);
}

/* Karşı taraf: sol, teal vurgulu baloncuk */
.msg--other .bubble-av {
  grid-column: 1;
  grid-row: 1;
}

.msg--other .bubble {
  grid-column: 2;
  grid-row: 1;
  background: rgba(13, 148, 136, 0.22);
  border-color: rgba(45, 212, 191, 0.4);
  border-radius: 14px 14px 14px 6px;
}

.msg--other .msg-meta {
  grid-column: 2;
  grid-row: 2;
}

/* Ben: sağ, mor / gönderilen stil */
.msg--own {
  align-self: flex-end;
  grid-template-columns: 1fr auto;
}

.msg--own .bubble-av {
  grid-column: 2;
  grid-row: 1;
}

.msg--own .bubble {
  grid-column: 1;
  grid-row: 1;
  background: linear-gradient(145deg, rgba(99, 102, 241, 0.42), rgba(67, 56, 202, 0.32));
  border-color: rgba(165, 180, 252, 0.45);
  border-radius: 14px 14px 6px 14px;
}

.msg--own .msg-meta {
  grid-column: 1;
  grid-row: 2;
  text-align: right;
  justify-self: end;
}

@keyframes in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.msg .bubble-av {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: var(--mc);
  align-self: end;
}

.msg .bubble {
  position: relative;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px 14px 14px 6px;
  padding: 0px 30px 0px 0px;
  line-height: 0.7;
  white-space: pre-wrap;
  word-break: break-word;
}

.msg .bubble:has(.msg-quote) {
  padding-top: 6px;
  padding-bottom: 7px;
  padding-right: 32px;
}

.msg-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: -4px;
}

.msg-meta strong {
  color: var(--text);
  font-weight: 600;
}

.reply-preview {
  flex-shrink: 0;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 16px;
  margin: 0;
  border-top: 1px solid var(--border);
  background: rgba(99, 102, 241, 0.12);
}

.reply-preview-main {
  flex: 1;
  min-width: 0;
}

.reply-preview-label {
  display: block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 4px;
}

.reply-preview-main strong {
  display: block;
  font-size: 0.88rem;
  margin-bottom: 4px;
}

.reply-preview-main p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.35;
  max-height: 2.7em;
  overflow: hidden;
}

.reply-preview-cancel {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
}

.typing-line {
  margin: 0;
  padding: 6px 24px 12px;
  min-height: 1.25rem;
  font-size: 0.84rem;
  color: var(--muted);
  font-style: italic;
}

.typing-line:not(.hidden)::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: typing-dot 1s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes typing-dot {
  0%,
  100% {
    opacity: 0.35;
    transform: scale(0.9);
  }
  50% {
    opacity: 1;
    transform: scale(1);
  }
}

.composer {
  flex-shrink: 0;
  margin-top: auto;
  position: sticky;
  bottom: 0;
  z-index: 20;
  display: flex;
  gap: 12px;
  align-items: flex-end;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(12, 14, 20, 0.98);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
}

.composer textarea {
  flex: 1;
  min-height: 48px;
  max-height: 160px;
  resize: none;
  padding: 14px 16px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  font: inherit;
  line-height: 1.4;
}

@media (max-width: 820px) {
  .composer textarea {
    font-size: 16px;
  }
}

.composer textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.send {
  padding-inline: 22px;
  min-height: 48px;
}

.err-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #7f1d1d;
  color: #fecaca;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  z-index: 50;
  max-width: min(90vw, 420px);
  text-align: center;
}
