:root {
  --bg: #0b0b0f;
  --bg2: #121218;
  --card: #17171f;
  --border: #262633;
  --text: #ecebf3;
  --muted: #8b8b9e;
  --accent: #7c5cff;
  --accent2: #5345d1;
  --bubble-in: #1f1f2a;
  --bubble-out: #2b2350;
  --green: #00c982;
  --red: #ff5c6c;
}

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

body {
  font-family: 'Segoe UI', system-ui, -apple-system, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #1a1533 0%, var(--bg) 55%);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.hidden { display: none !important; }

/* ── Connect ── */
.connect { width: 100%; max-width: 420px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  text-align: center;
}
.logo, .avatar {
  width: 56px; height: 56px; border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 26px; color: #fff;
  margin: 0 auto 14px;
}
h1 { font-size: 22px; margin-bottom: 6px; }
.sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; line-height: 1.5; }

input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--text);
  padding: 12px 14px;
  font-size: 14px;
  outline: none;
}
input:focus { border-color: var(--accent); }

.primary {
  width: 100%;
  margin-top: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border: none;
  border-radius: 12px;
  color: #fff;
  padding: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.primary:hover { filter: brightness(1.1); }
.primary:disabled { opacity: 0.5; cursor: default; }

.error { color: var(--red); font-size: 12px; margin-top: 10px; }
.hint { color: var(--muted); font-size: 11px; margin-top: 16px; line-height: 1.5; }

/* ── Chat ── */
.chat {
  width: 100%;
  max-width: 640px;
  height: min(85vh, 720px);
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}
.identity { display: flex; align-items: center; gap: 12px; }
.avatar { width: 42px; height: 42px; font-size: 20px; border-radius: 50%; margin: 0; }
.identity strong { display: block; font-size: 15px; }
.status { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); display: inline-block; }
.dot.online { background: var(--green); box-shadow: 0 0 8px var(--green); }
.dot.offline { background: var(--red); }

.ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 10px;
  padding: 7px 12px;
  font-size: 12px;
  cursor: pointer;
}
.ghost:hover { color: var(--text); border-color: var(--muted); }

main {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background:
    radial-gradient(600px 300px at 80% -10%, rgba(124, 92, 255, 0.06), transparent 60%),
    var(--bg2);
}
.msg {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg .time { display: block; font-size: 10px; color: var(--muted); margin-top: 4px; text-align: right; }
.msg.user { align-self: flex-end; background: var(--bubble-out); border-bottom-right-radius: 4px; }
.msg.nya { align-self: flex-start; background: var(--bubble-in); border-bottom-left-radius: 4px; }
.msg.system { align-self: center; background: transparent; color: var(--muted); font-size: 11px; padding: 2px 10px; }

footer {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  background: var(--card);
}
footer input { flex: 1; }
footer .primary { width: auto; margin: 0; padding: 12px 20px; }
