:root {
  color-scheme: light;
  --bg: #f6f3ff;
  --panel: rgba(255, 255, 255, 0.84);
  --panel-solid: #ffffff;
  --panel-soft: #f7f4ff;
  --text: #171427;
  --muted: #69627b;
  --line: rgba(104, 91, 143, 0.18);
  --primary: #7c3aed;
  --primary-dark: #5b21b6;
  --accent: #06b6d4;
  --warm: #f59e0b;
  --danger: #c2410c;
  --success: #15803d;
  --sidebar: rgba(28, 23, 47, 0.88);
  --shadow: 0 24px 70px rgba(50, 38, 95, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 10% 10%, rgba(124, 58, 237, 0.16), transparent 32%),
    radial-gradient(circle at 92% 8%, rgba(6, 182, 212, 0.16), transparent 28%),
    linear-gradient(135deg, #fbfaff 0%, #f5f0ff 46%, #edf9fb 100%);
  color: var(--text);
  font-family: Arial, "Microsoft YaHei", sans-serif;
}

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

button {
  border: 0;
  border-radius: 8px;
  min-height: 42px;
  padding: 0 16px;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(124, 58, 237, 0.22);
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.03);
  box-shadow: 0 16px 34px rgba(124, 58, 237, 0.28);
}

button:active {
  transform: translateY(0);
}

button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.secondary,
.ghost {
  background: rgba(255, 255, 255, 0.78);
  color: #35285b;
  border: 1px solid var(--line);
  box-shadow: none;
}

.secondary:hover,
.ghost:hover {
  background: #ffffff;
  box-shadow: 0 12px 26px rgba(50, 38, 95, 0.12);
}

.hidden {
  display: none !important;
}

.ambient {
  position: fixed;
  pointer-events: none;
  z-index: 0;
  border-radius: 999px;
  filter: blur(18px);
  opacity: 0.5;
  animation: floatGlow 8s ease-in-out infinite alternate;
}

.ambient-one {
  width: 230px;
  height: 230px;
  left: 280px;
  top: 52px;
  background: rgba(124, 58, 237, 0.18);
}

.ambient-two {
  width: 260px;
  height: 260px;
  right: 70px;
  bottom: 40px;
  background: rgba(6, 182, 212, 0.16);
  animation-delay: -2s;
}

.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  grid-template-columns: 276px 1fr;
}

.sidebar {
  margin: 18px 0 18px 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 18px;
  background: var(--sidebar);
  color: #fff;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  animation: slideIn 520ms ease both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.13);
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #fef3c7, #67e8f9 48%, #a78bfa);
  color: #27154d;
  font-size: 22px;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(124, 58, 237, 0.28);
  animation: pulseMark 3.6s ease-in-out infinite;
}

.brand strong,
.brand span {
  display: block;
}

.brand strong {
  font-size: 17px;
}

.brand span {
  margin-top: 4px;
  color: #d7d1e8;
  font-size: 13px;
}

.nav {
  display: grid;
  align-content: start;
  gap: 9px;
  padding-top: 20px;
}

.nav-item {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  color: #e7e1f7;
  box-shadow: none;
}

.nav-item:hover,
.nav-item.active {
  background: rgba(255, 255, 255, 0.13);
  color: #fff;
}

.account {
  border-top: 1px solid rgba(255, 255, 255, 0.13);
  padding-top: 16px;
  display: grid;
  gap: 10px;
  color: #eee9fb;
  font-size: 14px;
}

.main {
  min-width: 0;
  display: grid;
}

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

.auth-card,
.panel,
.messages,
.composer {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-card {
  width: min(460px, 100%);
  border-radius: 22px;
  padding: 30px;
  animation: riseIn 560ms ease both;
}

.auth-badge,
.eyebrow {
  width: fit-content;
  color: var(--primary-dark);
  background: rgba(124, 58, 237, 0.1);
  border: 1px solid rgba(124, 58, 237, 0.15);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 900;
  margin-bottom: 12px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: 0;
}

h2 {
  font-size: 19px;
}

p {
  color: var(--muted);
  line-height: 1.7;
  margin-top: 8px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 24px 0 18px;
  padding: 5px;
  background: rgba(111, 96, 152, 0.08);
  border: 1px solid var(--line);
  border-radius: 12px;
}

.auth-tab {
  background: transparent;
  color: #51446f;
  box-shadow: none;
}

.auth-tab.active {
  background: #fff;
  color: var(--primary-dark);
  box-shadow: 0 10px 24px rgba(50, 38, 95, 0.12);
}

.stack {
  display: grid;
  gap: 14px;
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  font-weight: 800;
  color: #3e335b;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  padding: 12px 13px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  background: #fff;
  border-color: rgba(124, 58, 237, 0.55);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.13);
}

.hint,
.message {
  color: var(--muted);
  font-size: 14px;
}

.hint {
  margin-top: 18px;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--success);
}

.page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: 28px;
  gap: 18px;
  animation: fadeIn 360ms ease both;
}

.chat-layout {
  height: 100vh;
  min-height: 720px;
  grid-template-rows: auto minmax(420px, 1fr) auto auto;
  overflow: hidden;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 4px 2px 0;
}

.messages {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px;
  border-radius: 22px;
}

.chat-layout .messages {
  min-height: clamp(420px, calc(100vh - 320px), 760px);
  max-height: calc(100vh - 300px);
}

.messages::-webkit-scrollbar {
  width: 12px;
}

.messages::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.48);
  border-radius: 999px;
}

.messages::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.48), rgba(6, 182, 212, 0.48));
  border: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
}

.messages::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.68), rgba(6, 182, 212, 0.68));
}

.messages {
  scrollbar-width: thin;
  scrollbar-color: rgba(124, 58, 237, 0.55) rgba(255, 255, 255, 0.45);
}

.skill-strip {
  display: grid;
  grid-template-columns: minmax(220px, 340px) 1fr;
  gap: 14px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 14px 34px rgba(50, 38, 95, 0.1);
}

.chat-layout .skill-strip {
  padding: 10px 14px;
}

.skill-strip label {
  margin: 0;
}

#skillDescription {
  color: var(--muted);
  line-height: 1.6;
  font-size: 14px;
  padding-bottom: 10px;
}

.empty {
  margin: auto;
  display: grid;
  place-items: center;
  gap: 8px;
  color: var(--muted);
  text-align: center;
  animation: breathe 2.8s ease-in-out infinite;
}

.empty strong {
  color: var(--text);
  font-size: 22px;
}

.empty span {
  font-size: 14px;
}

.bubble {
  width: fit-content;
  max-width: min(780px, 86%);
  border-radius: 18px;
  padding: 13px 15px;
  line-height: 1.75;
  white-space: pre-wrap;
  animation: bubbleIn 260ms ease both;
}

.bubble.user {
  align-self: flex-end;
  border-bottom-right-radius: 7px;
  background: linear-gradient(135deg, #7c3aed, #06b6d4);
  color: #fff;
  box-shadow: 0 14px 28px rgba(91, 33, 182, 0.18);
}

.bubble.assistant {
  align-self: flex-start;
  border-bottom-left-radius: 7px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid var(--line);
}

.bubble.pending {
  position: relative;
  color: #5b4d77;
  animation: bubbleIn 260ms ease both, pendingPulse 1.2s ease-in-out infinite;
}

.composer {
  display: grid;
  gap: 10px;
  align-items: end;
  border-radius: 20px;
  padding: 13px;
}

.chat-layout .composer {
  position: sticky;
  bottom: 0;
}

.composer-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: end;
}

.composer textarea {
  min-height: 46px;
  max-height: 160px;
  border: 0;
  box-shadow: none;
  padding: 11px 6px;
  background: transparent;
}

.icon-upload {
  min-height: 42px;
  display: grid;
  place-items: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  color: #35285b;
  cursor: pointer;
  font-weight: 800;
}

.icon-upload input {
  display: none;
}

.upload-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.66);
}

.upload-preview img,
.message-image {
  display: block;
  max-width: 220px;
  max-height: 160px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--line);
}

.message-image {
  margin-bottom: 8px;
}

.admin-grid {
  display: grid;
  grid-template-columns: minmax(360px, 530px) 1fr;
  gap: 18px;
  align-items: start;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}

.metric-card {
  min-height: 112px;
  display: grid;
  align-content: center;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 16px 40px rgba(50, 38, 95, 0.12);
  animation: riseIn 460ms ease both;
}

.metric-card span {
  color: var(--muted);
  font-size: 14px;
}

.metric-card strong {
  color: var(--text);
  font-size: 28px;
  line-height: 1;
}

.panel {
  padding: 22px;
  border-radius: 20px;
  animation: riseIn 460ms ease both;
}

.users-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.user-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.62);
  transition: transform 160ms ease, background 160ms ease;
}

.user-row:hover {
  transform: translateY(-1px);
  background: #fff;
}

.user-row span {
  color: var(--muted);
}

.table-list {
  display: grid;
  gap: 9px;
  margin-top: 16px;
}

.table-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  align-items: center;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.64);
  color: #3e335b;
  font-size: 14px;
  transition: transform 160ms ease, background 160ms ease;
}

.table-row:hover {
  transform: translateY(-1px);
  background: #fff;
}

.table-empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 12px;
  color: var(--muted);
  text-align: center;
}

.actions-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.check-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
}

.check-row input {
  width: 18px;
  height: 18px;
}

.mini-btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 13px;
}

@keyframes riseIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-18px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes bubbleIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes pendingPulse {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(124, 58, 237, 0);
  }
  50% {
    box-shadow: 0 0 0 5px rgba(124, 58, 237, 0.08);
  }
}

@keyframes breathe {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@keyframes pulseMark {
  0%,
  100% {
    transform: rotate(0deg) scale(1);
  }
  50% {
    transform: rotate(-2deg) scale(1.04);
  }
}

@keyframes floatGlow {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(22px, -18px, 0) scale(1.06);
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    margin: 12px;
    min-height: auto;
  }

  .admin-grid {
    grid-template-columns: 1fr;
  }

  .metric-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .skill-strip {
    grid-template-columns: 1fr;
  }

  .chat-layout {
    height: auto;
    min-height: calc(100vh - 24px);
    grid-template-rows: auto minmax(420px, 1fr) auto auto;
    overflow: visible;
  }

  .chat-layout .messages {
    min-height: 52vh;
    max-height: 58vh;
  }
}

@media (max-width: 560px) {
  .page,
  .auth-page {
    padding: 12px;
  }

  .page-header {
    display: grid;
  }

  .composer {
    grid-template-columns: 1fr;
  }

  .composer-row {
    grid-template-columns: 1fr;
  }

  .chat-layout {
    gap: 12px;
  }

  .chat-layout .messages {
    min-height: 56vh;
    max-height: 60vh;
    padding: 16px;
  }

  h1 {
    font-size: 25px;
  }

  .auth-tabs,
  .metric-grid {
    grid-template-columns: 1fr;
  }
}
