:root {
  --ink: #f8fbff;
  --muted: rgba(232, 241, 255, 0.72);
  --gold: #f8d46a;
  --gold-2: #d7a341;
  --blue: #1456c8;
  --blue-dark: #07142f;
  --panel: rgba(7, 20, 47, 0.78);
  --line: rgba(248, 212, 106, 0.26);
  --danger: #ff6678;
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -10%, rgba(248, 212, 106, 0.38), transparent 32%),
    radial-gradient(circle at 90% 18%, rgba(57, 139, 255, 0.36), transparent 34%),
    linear-gradient(160deg, #07142f 0%, #0b2760 48%, #061125 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(115deg, transparent 0 42%, rgba(248, 212, 106, 0.12) 42% 43%, transparent 43% 100%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.05) 0 1px, transparent 1px 82px);
}

a { color: inherit; }

.shell {
  position: relative;
  z-index: 1;
  width: min(460px, calc(100% - 28px));
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-content: center;
  padding: 18px 0 24px;
}

.app {
  min-height: min(740px, calc(100vh - 36px));
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.38), inset 0 1px 0 rgba(255, 255, 255, 0.14);
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.header {
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(248, 212, 106, 0.18);
}

.avatar {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  color: #09204d;
  font-weight: 900;
  background: linear-gradient(135deg, #fff4b8, var(--gold) 48%, var(--gold-2));
  box-shadow: 0 12px 28px rgba(248, 212, 106, 0.24);
}

h1 {
  margin: 0 0 4px;
  font-size: 20px;
  line-height: 1.2;
  letter-spacing: 0;
}

.sub {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
}

.status::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #23e58d;
  box-shadow: 0 0 14px #23e58d;
}

.messages {
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.msg {
  width: fit-content;
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 8px;
  line-height: 1.5;
  font-size: 15px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.1);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.agent {
  color: #09204d;
  background: linear-gradient(135deg, #fff4b8, var(--gold));
  border-color: transparent;
}

.msg.visitor {
  margin-left: auto;
  background: linear-gradient(135deg, #1c6ee8, #0d3c91);
}

.meta {
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.58);
  font-size: 11px;
}

.agent .msg.agent .meta {
  color: rgba(9, 32, 77, 0.6);
}

.composer {
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 88px;
  gap: 10px;
  border-top: 1px solid rgba(248, 212, 106, 0.18);
}

input, textarea, button, select {
  font: inherit;
}

input, textarea, select {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(248, 212, 106, 0.26);
  border-radius: 8px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
  outline: none;
  padding: 0 12px;
}

textarea {
  min-height: 72px;
  padding: 12px;
  resize: vertical;
}

button, .button {
  border: 0;
  border-radius: 8px;
  color: #09204d;
  background: linear-gradient(135deg, #fff4b8, var(--gold) 52%, var(--gold-2));
  font-weight: 900;
  cursor: pointer;
  text-decoration: none;
}

button.secondary, .button.secondary {
  color: var(--ink);
  border: 1px solid rgba(248, 212, 106, 0.28);
  background: rgba(255, 255, 255, 0.1);
}

button.danger {
  color: #ffffff;
  background: linear-gradient(135deg, #ff6678, #b51f38);
}

.login {
  padding: 16px;
  display: grid;
  gap: 12px;
  border-bottom: 1px solid rgba(248, 212, 106, 0.18);
}

.login-title {
  margin: 0;
  color: var(--gold);
  font-size: 16px;
  font-weight: 900;
}

.helper {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.toolbar {
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  border-bottom: 1px solid rgba(248, 212, 106, 0.18);
}

.chip {
  min-height: 34px;
  padding: 0 10px;
  font-size: 13px;
}

.agent-layout {
  width: min(1100px, calc(100% - 28px));
}

.agent-app {
  min-height: min(790px, calc(100vh - 36px));
  grid-template-columns: 320px 1fr;
  grid-template-rows: 1fr;
  display: grid;
}

.sessions {
  border-right: 1px solid rgba(248, 212, 106, 0.18);
  overflow: auto;
}

.session-head {
  padding: 16px;
  border-bottom: 1px solid rgba(248, 212, 106, 0.18);
}

.session-filter {
  margin-top: 12px;
}

.session {
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
  color: var(--ink);
  text-align: left;
  background: transparent;
}

.session.active {
  background: rgba(248, 212, 106, 0.14);
}

.session strong {
  display: block;
  margin-bottom: 4px;
}

.session small {
  display: block;
  margin-top: 5px;
  color: rgba(232, 241, 255, 0.58);
}

.unread {
  display: inline-flex;
  min-width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
  border-radius: 999px;
  color: #09204d;
  background: var(--gold);
  font-size: 12px;
}

.closed {
  color: rgba(232, 241, 255, 0.58);
}

.chat-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
}

.details {
  padding: 12px 16px;
  display: grid;
  gap: 5px;
  border-bottom: 1px solid rgba(248, 212, 106, 0.18);
  color: var(--muted);
  font-size: 13px;
}

.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.hidden {
  display: none !important;
}

@media (max-width: 760px) {
  .agent-layout { width: min(460px, calc(100% - 28px)); }
  .agent-app {
    display: block;
    min-height: auto;
  }
  .sessions {
    max-height: 270px;
    border-right: 0;
    border-bottom: 1px solid rgba(248, 212, 106, 0.18);
  }
  .chat-panel {
    min-height: 540px;
  }
  .composer {
    grid-template-columns: 1fr 78px;
  }
}
