:root {
  --bg: #0b0f14;
  --panel: #121a24;
  --panel2: #182231;
  --text: #e8eef6;
  --muted: #8b9bb0;
  --j: #5b9fd4;
  --j-bg: rgba(91, 159, 212, 0.12);
  --m: #d4a574;
  --m-bg: rgba(212, 165, 116, 0.12);
  --line: rgba(255, 255, 255, 0.08);
  --accent: #7c9cff;
  --danger: #ff7b7b;
  --ok: #6dcaa0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(91, 159, 212, 0.15), transparent 50%),
    radial-gradient(900px 500px at 100% 0%, rgba(212, 165, 116, 0.12), transparent 45%),
    var(--bg);
  color: var(--text);
}

.screen {
  min-height: 100%;
  display: flex;
  flex-direction: column;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.gate-card {
  width: min(400px, 92vw);
  margin: auto;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--accent);
  font-size: 0.85rem;
  margin-bottom: 8px;
}
.brand-sm {
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--accent);
  font-size: 0.75rem;
}

h1 {
  font-size: 1.55rem;
  margin: 0 0 8px;
  font-weight: 650;
}
.sub { color: var(--muted); margin: 0 0 22px; line-height: 1.45; }

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
}
input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--text);
  font-size: 1rem;
  margin-bottom: 14px;
  outline: none;
}
input:focus { border-color: rgba(124, 156, 255, 0.55); }

button {
  width: 100%;
  padding: 12px 16px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(180deg, #8aa6ff, #6b86e8);
  color: #0b1020;
  font-weight: 650;
  font-size: 0.95rem;
  cursor: pointer;
}
button:hover { filter: brightness(1.05); }
button.ghost {
  width: auto;
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  padding: 8px 12px;
  font-weight: 500;
}
button.ghost:hover { color: var(--text); border-color: rgba(255,255,255,0.18); }

.err { color: var(--danger); font-size: 0.85rem; margin: 12px 0 0; }

#app { max-width: 820px; margin: 0 auto; padding: 16px 16px 0; height: 100%; }

.top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 8px 4px 14px;
  border-bottom: 1px solid var(--line);
}
.turn {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}
.turn strong { color: var(--text); font-weight: 600; }

.log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 4px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 50vh;
}

.msg {
  max-width: min(560px, 92%);
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  line-height: 1.45;
  animation: in 0.2s ease;
}
@keyframes in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
.msg.j {
  align-self: flex-start;
  background: var(--j-bg);
  border-color: rgba(91, 159, 212, 0.25);
}
.msg.m {
  align-self: flex-end;
  background: var(--m-bg);
  border-color: rgba(212, 165, 116, 0.28);
}
.msg .who {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.msg.j .who { color: var(--j); }
.msg.m .who { color: var(--m); }
.msg .body {
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.95rem;
}
.msg .ts {
  margin-top: 8px;
  font-size: 0.7rem;
  color: var(--muted);
}

.empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 40px 16px;
  max-width: 320px;
  line-height: 1.5;
}

.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px 16px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.78rem;
}
.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 0 rgba(109, 202, 160, 0.5);
  animation: pulse 2s infinite;
}
.dot.err { background: var(--danger); animation: none; }
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(109, 202, 160, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(109, 202, 160, 0); }
  100% { box-shadow: 0 0 0 0 rgba(109, 202, 160, 0); }
}

@media (max-width: 560px) {
  .msg { max-width: 95%; }
}
