:root {
  --bg: #050713;
  --panel: rgba(8, 13, 32, .72);
  --panel-strong: rgba(11, 18, 43, .92);
  --line: rgba(110, 246, 255, .22);
  --text: #eef7ff;
  --muted: #8fa5bf;
  --cyan: #69f7ff;
  --violet: #7c5cff;
  --pink: #ff4fd8;
  --green: #6dffb2;
  --red: #ff6b83;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--text); font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; }
button, input, textarea { font: inherit; }
a { color: inherit; }
.hidden { display: none !important; }

.space-bg { position: fixed; inset: 0; z-index: -2; overflow: hidden; background: radial-gradient(circle at 20% 15%, rgba(124,92,255,.25), transparent 28%), radial-gradient(circle at 80% 8%, rgba(105,247,255,.18), transparent 30%), linear-gradient(135deg, #03040b 0%, #06091c 50%, #090414 100%); }
.grid-layer { position: absolute; inset: 0; background-image: linear-gradient(rgba(105,247,255,.07) 1px, transparent 1px), linear-gradient(90deg, rgba(105,247,255,.07) 1px, transparent 1px); background-size: 42px 42px; mask-image: linear-gradient(to bottom, rgba(0,0,0,.9), rgba(0,0,0,.2)); animation: gridMove 18s linear infinite; }
.orb { position: absolute; border-radius: 999px; filter: blur(25px); opacity: .55; }
.orb-a { width: 260px; height: 260px; background: var(--violet); left: -80px; top: 30%; animation: float 7s ease-in-out infinite alternate; }
.orb-b { width: 220px; height: 220px; background: var(--cyan); right: -70px; bottom: 10%; animation: float 9s ease-in-out infinite alternate-reverse; }
@keyframes gridMove { from { transform: translateY(0); } to { transform: translateY(42px); } }
@keyframes float { from { transform: translateY(-20px) scale(1); } to { transform: translateY(20px) scale(1.08); } }

.shell { width: min(1120px, calc(100% - 28px)); margin: 0 auto; padding: 24px 0 44px; }
.login-card, .app { min-height: calc(100vh - 48px); }
.login-card { display: grid; align-content: center; gap: 26px; max-width: 580px; margin: 0 auto; }
.brand-block { display: flex; align-items: center; gap: 20px; padding: 28px; border: 1px solid var(--line); border-radius: 28px; background: var(--panel); box-shadow: 0 0 60px rgba(105,247,255,.08); backdrop-filter: blur(18px); }
.logo-xl { width: 94px; height: 94px; filter: drop-shadow(0 0 18px rgba(105,247,255,.55)); }
.logo { width: 52px; height: 52px; filter: drop-shadow(0 0 12px rgba(105,247,255,.45)); }
.eyebrow, .panel-label { margin: 0 0 6px; letter-spacing: .2em; text-transform: uppercase; color: var(--cyan); font-size: 12px; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(28px, 5vw, 48px); margin-bottom: 8px; }
.subtle, .hint, .msg { color: var(--muted); }
.login-form { display: grid; gap: 12px; padding: 24px; border: 1px solid var(--line); border-radius: 24px; background: var(--panel-strong); }
label { color: var(--muted); }
input, textarea { width: 100%; border: 1px solid rgba(105,247,255,.2); border-radius: 16px; background: rgba(0, 0, 0, .28); color: var(--text); outline: none; padding: 14px 16px; transition: .2s ease; }
textarea { resize: vertical; min-height: 110px; }
input:focus, textarea:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(105,247,255,.08); }
button { border: 0; border-radius: 16px; padding: 14px 18px; cursor: pointer; color: #041018; background: linear-gradient(135deg, var(--cyan), var(--violet)); font-weight: 800; box-shadow: 0 12px 32px rgba(105,247,255,.15); transition: transform .18s ease, filter .18s ease; }
button:hover { transform: translateY(-1px); filter: brightness(1.08); }
button:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.ghost { background: rgba(255,255,255,.06); color: var(--text); border: 1px solid rgba(255,255,255,.12); box-shadow: none; }
.small { padding: 10px 12px; border-radius: 12px; font-size: 13px; }

.topbar { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 26px; background: var(--panel); backdrop-filter: blur(18px); }
.brand-inline { display: flex; align-items: center; gap: 14px; }
.brand-inline h1 { font-size: 24px; margin-bottom: 0; }

.visitor-panel, .hero, .chat-card { margin-top: 18px; border: 1px solid var(--line); border-radius: 28px; background: var(--panel); backdrop-filter: blur(18px); box-shadow: 0 20px 70px rgba(0,0,0,.25); }
.visitor-panel { display: flex; justify-content: space-between; gap: 18px; align-items: center; padding: 20px 22px; }
.visitor-panel h2 { margin: 0; font-size: clamp(20px, 4vw, 34px); }
.visitor-meta { display: grid; gap: 8px; justify-items: end; color: var(--muted); }

.hero { display: grid; grid-template-columns: 1fr 180px; gap: 24px; align-items: center; padding: 28px; overflow: hidden; }
.hero h2 { font-size: clamp(28px, 6vw, 64px); margin-bottom: 12px; letter-spacing: -.05em; }
.hero p { color: var(--muted); font-size: 17px; line-height: 1.7; }
.pulse-core { position: relative; width: 150px; height: 150px; justify-self: center; }
.pulse-core span { position: absolute; inset: 0; border-radius: 999px; border: 1px solid var(--cyan); animation: pulse 2.7s infinite; }
.pulse-core span:nth-child(2) { inset: 28px; border-color: var(--violet); animation-delay: .35s; }
.pulse-core span:nth-child(3) { inset: 56px; background: radial-gradient(circle, var(--cyan), transparent 65%); border: 0; box-shadow: 0 0 30px rgba(105,247,255,.7); animation-delay: .7s; }
@keyframes pulse { 0% { transform: scale(.85); opacity: .9; } 100% { transform: scale(1.18); opacity: .15; } }

.provider-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 18px; }
.provider-card { text-align: left; padding: 18px; min-height: 126px; border: 1px solid rgba(105,247,255,.18); border-radius: 22px; background: linear-gradient(135deg, rgba(255,255,255,.08), rgba(255,255,255,.03)); color: var(--text); box-shadow: none; }
.provider-card.active { border-color: var(--cyan); box-shadow: 0 0 35px rgba(105,247,255,.14); }
.provider-card strong { display: block; margin-bottom: 8px; font-size: 18px; }
.provider-card small { color: var(--muted); word-break: break-word; }
.badge { display: inline-flex; gap: 6px; align-items: center; margin-top: 12px; padding: 6px 9px; border-radius: 999px; background: rgba(255,255,255,.08); color: var(--green); font-size: 12px; }
.badge.off { color: var(--red); }

.chat-card { padding: 18px; }
.chat-head { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding-bottom: 14px; border-bottom: 1px solid rgba(255,255,255,.08); }
.chat-head h3 { margin: 0 0 8px; font-size: 24px; }
.status-dot { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.chat-log { min-height: 330px; max-height: 55vh; overflow-y: auto; padding: 18px 2px; display: grid; gap: 14px; }
.bubble { width: fit-content; max-width: min(820px, 88%); padding: 14px 16px; border-radius: 18px; white-space: pre-wrap; line-height: 1.65; border: 1px solid rgba(255,255,255,.08); }
.bubble.user { justify-self: end; background: linear-gradient(135deg, rgba(105,247,255,.22), rgba(124,92,255,.18)); }
.bubble.assistant { justify-self: start; background: rgba(255,255,255,.06); }
.bubble.system { justify-self: center; color: var(--muted); background: rgba(255,255,255,.04); text-align: center; }
.bubble.error { justify-self: center; color: #ffd4dc; border-color: rgba(255,107,131,.35); background: rgba(255,107,131,.1); }
.chat-form { display: grid; grid-template-columns: 1fr 120px; gap: 12px; align-items: stretch; }
.chat-form button { height: 100%; }
.hint { margin: 12px 4px 0; font-size: 13px; }

@media (max-width: 860px) {
  .provider-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: 1fr; }
  .pulse-core { display: none; }
}
@media (max-width: 620px) {
  .shell { width: min(100% - 18px, 1120px); padding-top: 10px; }
  .topbar, .visitor-panel, .chat-head { align-items: flex-start; flex-direction: column; }
  .provider-grid { grid-template-columns: 1fr; }
  .chat-form { grid-template-columns: 1fr; }
  .brand-block { flex-direction: column; text-align: center; }
  .visitor-meta { justify-items: start; }
}
