:root{
  --bg: #f4f7fb;
  --panel: #ffffff;
  --border: #e2e7f0;
  --text: #1b2333;
  --muted: #5a6475;
  --accent: #2f6bff;
  --bubble-user: linear-gradient(180deg, #3c7bff, #2f6bff);
  --bubble-bot: #f1f4f9;
  --bubble-system: #f7f9fc;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, "Apple Color Emoji","Segoe UI Emoji";
  background: radial-gradient(1200px 800px at 18% 0%, rgba(61,123,255,.10), transparent 55%),
              radial-gradient(1000px 700px at 90% 12%, rgba(66,160,255,.08), transparent 55%),
              var(--bg);
  color: var(--text);
}

a{ color: inherit; text-decoration:none; }
.link{ color: var(--accent); }
.muted{ color: var(--muted); }

.topbar{
  position: sticky;
  top:0;
  z-index:20;
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 8px 24px rgba(24,32,51,.06);
}
.topbar-inner{
  max-width: 1100px;
  margin:0 auto;
  padding: 14px 16px;
  display:flex;
  align-items:center;
  justify-content:space-between;
}
.brand{
  font-weight: 700;
  letter-spacing: .2px;
}
.topbar-right{
  display:flex;
  gap: 12px;
  align-items:center;
}
.user-pill{
  padding: 6px 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
}

.page{
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 16px 90px 16px;
}

.card{
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
}

.footer{
  position: fixed;
  left:0;
  right:0;
  bottom:0;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,.86);
  backdrop-filter: blur(18px);
}
.footer-inner{
  max-width: 1100px;
  margin:0 auto;
  padding: 10px 16px;
  display:flex;
  justify-content:space-between;
  align-items:center;
}

.form-row{
  display:flex;
  gap: 10px;
  align-items:center;
}
input[type="email"], input[type="text"], textarea{
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  outline: none;
}
input::placeholder, textarea::placeholder{ color: rgba(90,100,117,.6); }

.btn{
  border: 1px solid var(--border);
  background: #f6f8fc;
  color: var(--text);
  padding: 11px 14px;
  border-radius: 12px;
  cursor:pointer;
}
.btn-primary{
  border: 1px solid rgba(47,107,255,.45);
  background: rgba(47,107,255,.12);
}
.btn-danger{
  border: 1px solid rgba(226,74,74,.4);
  background: rgba(226,74,74,.12);
}
.btn:disabled{ opacity:.6; cursor:not-allowed; }

.chat-shell{
  height: calc(100vh - 170px);
  min-height: 520px;
  display:flex;
  flex-direction:column;
  gap: 12px;
}
.chat-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap: 10px;
}
.chat-title-row{
  display:flex;
  align-items:center;
  gap: 10px;
}
.coach-pay{
  display:flex;
  justify-content:flex-end;
  margin-left: auto;
  max-width: 0;
  max-height: 0;
  opacity: 0;
  transform: translateY(-8px);
  overflow: hidden;
  transition: max-width 220ms ease, max-height 220ms ease, opacity 220ms ease, transform 220ms ease;
  pointer-events: none;
  white-space: nowrap;
}
.coach-pay.visible{
  max-width: 320px;
  max-height: 80px;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.status-pill.small{
  padding: 4px 8px;
  font-size: 12px;
}
.btn-coach{
  position: relative;
  overflow: hidden;
  background: rgba(79,140,255,.22);
  border: 1px solid rgba(79,140,255,.7);
  box-shadow: 0 10px 30px rgba(79,140,255,.10);
}
.btn-coach:hover{
  background: rgba(79,140,255,.30);
}

.btn-coach.shine::after{
  content: "";
  position: absolute;
  inset: -40% -60%;
  background: linear-gradient(120deg, transparent 35%, rgba(255,255,255,.55) 50%, transparent 65%);
  transform: translateX(-60%) rotate(10deg);
  animation: coachShine 900ms ease-out 1;
  pointer-events: none;
  opacity: .9;
}

@keyframes coachShine{
  0% { transform: translateX(-70%) rotate(10deg); opacity: 0; }
  20% { opacity: .95; }
  100% { transform: translateX(70%) rotate(10deg); opacity: 0; }
}

@media (prefers-reduced-motion: reduce){
  .btn-coach.shine::after{ animation: none; }
}
.status-pill{
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f4f7fb;
  color: var(--muted);
  font-size: 13px;
}
.chat-list{
  flex:1;
  overflow:auto;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: #f8fafc;
}
.typing-indicator{
  display:inline-flex;
  align-items:center;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 160ms ease;
}
.typing-indicator.visible{
  opacity: 1;
  visibility: visible;
}
.typing-bubble{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background: var(--bubble-bot);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  min-width: 112px;
  white-space: nowrap;
}
.msg.typing .bubble{
  display:inline-flex;
  align-items:center;
  gap: 6px;
  padding: 6px 10px;
  font-size: 12px;
  white-space: nowrap;
}
.msg.typing .msg-meta{
  display:none;
}
.typing-dots{
  display:inline-flex;
  gap: 3px;
}
.typing-dots span{
  width: 4px;
  height: 4px;
  border-radius: 999px;
  background: rgba(27,35,51,.45);
  animation: typingPulse 1.2s infinite;
}
.typing-dots span:nth-child(2){ animation-delay: .2s; }
.typing-dots span:nth-child(3){ animation-delay: .4s; }

@keyframes typingPulse{
  0%, 80%, 100% { opacity: .2; transform: translateY(0); }
  40% { opacity: .9; transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce){
  .typing-dots span{ animation: none; }
}
.msg{
  display:flex;
  margin: 10px 0;
}
.msg .bubble{
  max-width: 78%;
  padding: 10px 12px;
  border-radius: 16px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-break: break-word;
  border: 1px solid transparent;
}
.msg.user{ justify-content:flex-end; }
.msg.user .bubble{
  background: var(--bubble-user);
  color: #fff;
}
.msg.bot .bubble,
.msg.agent .bubble{
  background: var(--bubble-bot);
  border-color: var(--border);
}
.msg.system{ justify-content:center; }
.msg.system .bubble{
  background: var(--bubble-system);
  border-color: var(--border);
  color: var(--muted);
  max-width: 90%;
  text-align:center;
}
.msg-meta{
  margin-top: 6px;
  font-size: 12px;
  color: rgba(27,35,51,.45);
}
.chat-input{
  display:flex;
  gap: 10px;
  align-items:flex-end;
}
.chat-input textarea{
  resize:none;
  height: 46px;
  min-height: 46px;
  max-height: 160px;
}

.table{
  width:100%;
  border-collapse: collapse;
}
.table th, .table td{
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
  text-align:left;
  color: var(--text);
}
.table th{ color: var(--muted); font-weight:600; }
.tag{
  display:inline-block;
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f4f7fb;
  color: var(--muted);
  font-size: 12px;
}
