:root {
  --bg: #fff5ea;
  --panel: rgba(255, 253, 249, 0.82);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --text: #231711;
  --muted: #78655d;
  --line: rgba(107, 72, 49, 0.14);
  --accent: #f2682a;
  --accent-strong: #d84d12;
  --gold: #f7b348;
  --violet: #9063ff;
  --cyan: #38bdf8;
  --green: #22c55e;
  --shadow: 0 28px 80px rgba(78, 45, 19, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 194, 122, 0.3), transparent 26%),
    radial-gradient(circle at 90% 10%, rgba(242, 104, 42, 0.18), transparent 22%),
    radial-gradient(circle at 80% 50%, rgba(144, 99, 255, 0.12), transparent 24%),
    linear-gradient(180deg, #fff3e4 0%, #fffaf4 48%, #fff6ec 100%);
}

.assistant-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 20px 28px;
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 900;
  letter-spacing: 0.02em;
}

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

.assistant-shell {
  width: min(1400px, calc(100% - 28px));
  margin: 0 auto 28px;
  display: grid;
  grid-template-columns: 430px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.assistant-left,
.assistant-right,
.workspace-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.premium-card,
.profile-card,
.chat-card {
  border: 1px solid var(--line);
  border-radius: 30px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.avatar-card,
.profile-card,
.chat-card {
  padding: 24px;
}

.avatar-wrap {
  position: relative;
  min-height: 360px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 28px;
  margin-bottom: 18px;
  background:
    radial-gradient(circle at 50% 30%, rgba(247, 179, 72, 0.26), transparent 30%),
    linear-gradient(180deg, rgba(255,255,255,0.74), rgba(255,255,255,0.14));
}

.avatar-aura {
  position: absolute;
  inset: auto;
  border-radius: 999px;
  filter: blur(24px);
  opacity: 0.7;
  animation: orbitAura 10s linear infinite;
}

.aura-a {
  width: 220px;
  height: 220px;
  background: rgba(242, 104, 42, 0.18);
}

.aura-b {
  width: 260px;
  height: 260px;
  background: rgba(247, 179, 72, 0.18);
  animation-direction: reverse;
  animation-duration: 12s;
}

.avatar-wrap[data-role="sales"] {
  background:
    radial-gradient(circle at 50% 30%, rgba(56, 189, 248, 0.24), transparent 30%),
    linear-gradient(180deg, rgba(255,255,255,0.74), rgba(255,255,255,0.14));
}

.avatar-wrap[data-role="sales"] .role-badge,
.avatar-wrap[data-role="sales"] .voice-bars span {
  background: rgba(56, 189, 248, 0.18);
  color: #0f5d7a;
}

.avatar-wrap[data-role="trainer"] {
  background:
    radial-gradient(circle at 50% 30%, rgba(34, 197, 94, 0.24), transparent 30%),
    linear-gradient(180deg, rgba(255,255,255,0.74), rgba(255,255,255,0.14));
}

.avatar-wrap[data-role="support"] {
  background:
    radial-gradient(circle at 50% 30%, rgba(144, 99, 255, 0.22), transparent 30%),
    linear-gradient(180deg, rgba(255,255,255,0.74), rgba(255,255,255,0.14));
}

.avatar-image {
  position: relative;
  z-index: 3;
  width: 190px;
  max-width: 72%;
  filter: drop-shadow(0 28px 34px rgba(242, 104, 42, 0.22));
  animation: floatAvatar 5s ease-in-out infinite;
}

.avatar-role-markers {
  position: absolute;
  left: 22px;
  top: 22px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.avatar-role-tag,
.avatar-role-signal {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.88);
  border: 1px solid rgba(107, 72, 49, 0.12);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.avatar-role-signal {
  background: rgba(242, 104, 42, 0.12);
  color: var(--accent);
}

.pulse {
  position: absolute;
  width: 180px;
  height: 180px;
  border-radius: 999px;
  border: 1px solid rgba(242, 104, 42, 0.18);
  background: radial-gradient(circle, rgba(255, 179, 71, 0.18), rgba(255, 179, 71, 0.02));
  opacity: 0.72;
}

.pulse-a {
  animation: pulseA 4s ease-in-out infinite;
}

.pulse-b {
  animation: pulseB 4s ease-in-out infinite;
}

.voice-bars {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 4;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  height: 40px;
}

.voice-bars span {
  width: 7px;
  height: 12px;
  border-radius: 999px;
  background: rgba(242, 104, 42, 0.28);
  transform-origin: bottom;
}

.avatar-wrap.is-talking .pulse,
.avatar-wrap.is-thinking .pulse {
  opacity: 1;
}

.avatar-wrap.is-talking .voice-bars span {
  background: rgba(242, 104, 42, 0.86);
  animation: voiceBar 0.9s ease-in-out infinite;
}

.avatar-wrap.is-thinking .voice-bars span {
  background: rgba(247, 179, 72, 0.8);
  animation: voiceBar 1.25s ease-in-out infinite;
}

.voice-bars span:nth-child(2) { animation-delay: 0.1s; }
.voice-bars span:nth-child(3) { animation-delay: 0.2s; }
.voice-bars span:nth-child(4) { animation-delay: 0.3s; }
.voice-bars span:nth-child(5) { animation-delay: 0.4s; }

.avatar-overlay {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 4;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(242, 104, 42, 0.12);
}

.overlay-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.role-badge,
.mode-badge,
.inline-badge {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.role-badge {
  background: rgba(242, 104, 42, 0.12);
  color: var(--accent);
}

.mode-badge {
  background: rgba(247, 179, 72, 0.2);
  color: #855500;
}

.inline-badge {
  background: rgba(255, 179, 71, 0.16);
  color: var(--text);
}

.avatar-overlay strong {
  display: block;
  margin-top: 8px;
  font-size: 1.15rem;
}

.avatar-overlay p,
.avatar-copy p:last-child,
.section-title p,
.approval-note p,
.chat-subcopy,
.status-text {
  color: var(--muted);
  line-height: 1.65;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.avatar-copy h1,
.section-title h2,
.chat-head h2,
.workspace-lock h2 {
  margin: 6px 0 10px;
  font-size: clamp(1.8rem, 3vw, 2.25rem);
  line-height: 1.08;
}

.role-selector,
.header-actions,
.profile-actions,
.chat-actions,
.chat-head-actions,
.quick-prompts,
.access-grid,
.status-strip,
.workspace-lock-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.role-chip,
.chip-btn,
.primary-btn,
.ghost-btn,
.prompt-chip {
  border: none;
  border-radius: 999px;
  padding: 12px 18px;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.role-chip,
.chip-btn,
.ghost-btn,
.prompt-chip {
  background: rgba(255, 255, 255, 0.76);
  color: var(--text);
  border: 1px solid rgba(107, 72, 49, 0.1);
}

.role-chip.active,
.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  box-shadow: 0 18px 34px rgba(242, 104, 42, 0.22);
}

.chip-btn.secondary,
.ghost-btn {
  background: rgba(255, 255, 255, 0.88);
}

.small {
  padding: 10px 14px;
}

.primary-btn:hover,
.ghost-btn:hover,
.chip-btn:hover,
.role-chip:hover,
.prompt-chip:hover {
  transform: translateY(-1px);
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.status-strip > div,
.workspace-lock {
  padding: 16px 18px;
  border-radius: 22px;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.status-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.gate-card {
  border-style: dashed;
}

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

.profile-card label,
.chat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.profile-card label {
  margin-bottom: 14px;
}

label span {
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid rgba(107, 72, 49, 0.14);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  padding: 14px 16px;
  font: inherit;
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.approval-note {
  padding: 16px 18px;
  border-radius: 20px;
  background: rgba(242, 104, 42, 0.06);
  border: 1px solid rgba(242, 104, 42, 0.1);
}

.workspace-stack.is-locked .workspace-card {
  opacity: 0.48;
  pointer-events: none;
  filter: grayscale(0.12);
}

.workspace-lock {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.chat-card {
  min-height: calc(100vh - 108px);
  display: flex;
  flex-direction: column;
}

.chat-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.usage-panel {
  padding: 16px 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, rgba(255,255,255,0.92), rgba(255, 242, 228, 0.9));
  margin-bottom: 16px;
}

.usage-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.usage-bar {
  height: 12px;
  margin-top: 12px;
  border-radius: 999px;
  background: rgba(107, 72, 49, 0.08);
  overflow: hidden;
}

.usage-bar span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--gold), var(--accent));
  transition: width 0.25s ease;
}

.quick-prompts {
  margin-bottom: 16px;
}

.chat-ops-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: -4px 0 16px;
}

.prompt-chip.premium-locked {
  opacity: 0.5;
}

.chat-log {
  flex: 1;
  min-height: 420px;
  max-height: calc(100vh - 390px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 8px 2px 18px;
}

.msg {
  max-width: 82%;
  padding: 14px 16px;
  border-radius: 18px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #fff;
  border-bottom-right-radius: 6px;
}

.msg.bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid rgba(107, 72, 49, 0.1);
  border-bottom-left-radius: 6px;
}

.msg.bot.result {
  border-left: 4px solid var(--accent);
}

.avatar-wrap[data-role="sales"] .avatar-role-signal {
  background: rgba(56, 189, 248, 0.16);
  color: #0f5d7a;
}

.avatar-wrap[data-role="trainer"] .avatar-role-signal {
  background: rgba(34, 197, 94, 0.16);
  color: #106b34;
}

.avatar-wrap[data-role="support"] .avatar-role-signal {
  background: rgba(144, 99, 255, 0.14);
  color: #5f39b6;
}

.avatar-wrap.is-talking .avatar-image {
  animation: floatAvatar 1.2s ease-in-out infinite, talkGlow 1.1s ease-in-out infinite;
}

.avatar-wrap.is-thinking .avatar-image {
  animation: floatAvatar 1.8s ease-in-out infinite, thinkGlow 1.6s ease-in-out infinite;
}

.chat-form {
  position: sticky;
  bottom: 0;
  background: linear-gradient(180deg, rgba(255, 248, 239, 0), rgba(255, 248, 239, 0.98) 18%);
  padding-top: 12px;
}

.chat-actions {
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

@keyframes pulseA {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

@keyframes pulseB {
  0%, 100% { transform: scale(0.88); }
  50% { transform: scale(1.06); }
}

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

@keyframes voiceBar {
  0%, 100% { transform: scaleY(0.45); }
  50% { transform: scaleY(1.7); }
}

@keyframes talkGlow {
  0%, 100% { filter: drop-shadow(0 28px 34px rgba(242, 104, 42, 0.22)); }
  50% { filter: drop-shadow(0 28px 42px rgba(242, 104, 42, 0.42)); }
}

@keyframes thinkGlow {
  0%, 100% { filter: drop-shadow(0 28px 34px rgba(247, 179, 72, 0.18)); }
  50% { filter: drop-shadow(0 28px 38px rgba(247, 179, 72, 0.34)); }
}

@keyframes orbitAura {
  from { transform: rotate(0deg) translateX(26px) rotate(0deg); }
  to { transform: rotate(360deg) translateX(26px) rotate(-360deg); }
}

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

  .chat-card {
    min-height: auto;
  }

  .chat-log {
    max-height: none;
    min-height: 320px;
  }
}

@media (max-width: 760px) {
  .assistant-header {
    flex-direction: column;
    align-items: flex-start;
    padding: 18px;
  }

  .assistant-shell {
    width: min(100% - 18px, 1400px);
  }

  .avatar-card,
  .profile-card,
  .chat-card {
    border-radius: 24px;
    padding: 18px;
  }

  .avatar-wrap {
    min-height: 300px;
  }

  .status-strip,
  .access-grid {
    grid-template-columns: 1fr;
  }

  .workspace-lock,
  .chat-head,
  .usage-meta {
    flex-direction: column;
    align-items: flex-start;
  }

  .msg {
    max-width: 100%;
  }
}
