/* chat.css */
#chatFab{
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 54px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  font-size: 22px;
  box-shadow: var(--shadow);
  border: 1px solid color-mix(in oklab, var(--border) 60%, var(--accent) 40%);
  cursor: pointer;
  user-select: none;
  z-index: 9999;
}

.chat{
  position: fixed;
  right: 18px;
  bottom: 82px;
  width: min(360px, calc(100vw - 36px));
  height: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 9999;
  backdrop-filter: blur(10px);
}

.chat.hidden{ display:none; }

.chat-header{
  display:flex;
  align-items:center;
  gap: 10px;
  padding: 12px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 75%, transparent);
}

.chat-avatar{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: color-mix(in oklab, var(--accent) 20%, transparent);
  border: 1px solid color-mix(in oklab, var(--accent) 35%, var(--border));
  font-size: 18px;
}

.chat-title{ font-weight: 950; }
.chat-sub{ font-size: 12px; color: var(--muted); margin-top: -2px; }

.chat-close{
  margin-left:auto;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  width: 34px;
  height: 34px;
  cursor: pointer;
}

.chat-body{
  padding: 12px;
  overflow: auto;
  display:flex;
  flex-direction:column;
  gap: 10px;
  flex:1;
}

.bubble{
  max-width: 85%;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 70%, transparent);
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  white-space: pre-line;
}

.bubble.helper{
  border-top-left-radius: 6px;
  background: color-mix(in oklab, var(--accent) 14%, transparent);
}

.bubble.me{
  margin-left:auto;
  border-top-right-radius: 6px;
  background: color-mix(in oklab, var(--accent2) 14%, transparent);
}

.meta{
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.chat-form{
  display:flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 80%, transparent);
}

#chatInput{
  flex:1;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
}

[data-theme="light"] #chatInput{
  background:#fff;
  color:#000;
}

.chat-send{
  padding: 10px 12px;
  border-radius: 14px;
  border: 0;
  font-weight: 900;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  cursor:pointer;
}

.chat-footnote{
  padding: 8px 10px 12px;
  font-size: 11px;
  color: var(--muted);
  border-top: 1px dashed var(--border);
  background: color-mix(in oklab, var(--bg) 85%, transparent);
}

.chat-handoff{
  margin-top: 12px;
}

.chat-handoff-box{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px;
}

.chat-handoff-box strong{
  display: block;
  margin-bottom: 8px;
  color: var(--text);
}

.chat-handoff-box input,
.chat-handoff-box select,
.chat-handoff-box textarea{
  width: 100%;
  box-sizing: border-box;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  outline: none;
}

[data-theme="light"] .chat-handoff-box input,
[data-theme="light"] .chat-handoff-box select,
[data-theme="light"] .chat-handoff-box textarea{
  background: #fff;
  color: #000;
}

.chat-handoff-box button{
  margin-top: 10px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color: white;
  cursor: pointer;
  font-weight: 900;
}