/* dorakuai homepage chat recommender */
.chat-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 45;
  width: 54px;
  height: 54px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent, #7c6cf0) 88%, #fff), var(--accent, #7c6cf0));
  box-shadow: 0 10px 28px rgba(36, 40, 70, 0.28);
  display: grid;
  place-items: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.chat-fab:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 14px 32px rgba(36, 40, 70, 0.34);
}
.chat-fab[aria-expanded="true"] {
  background: color-mix(in srgb, var(--text, #111) 88%, var(--accent, #7c6cf0));
}
.chat-fab svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
html[data-theme="dark"] .chat-fab {
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
}

.chat-panel {
  position: fixed;
  right: 22px;
  bottom: 88px;
  z-index: 46;
  width: min(380px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  border: 1px solid var(--line, #d8dbe7);
  background: color-mix(in srgb, var(--panel, #fff) 94%, var(--accent, #7c6cf0) 6%);
  box-shadow: 0 18px 48px rgba(24, 28, 48, 0.22);
  overflow: hidden;
}
.chat-panel[hidden] {
  display: none !important;
}
html[data-theme="dark"] .chat-panel {
  background: color-mix(in srgb, var(--panel, #161922) 92%, var(--accent, #7c6cf0) 8%);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.5);
  border-color: color-mix(in srgb, var(--line, #333) 80%, var(--accent) 20%);
}

.chat-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--line, #d8dbe7);
}
.chat-panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.chat-panel-head p {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted, #6b7280);
}
.chat-panel-close {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--text, #111);
  font-size: 20px;
  cursor: pointer;
}
.chat-panel-close:hover {
  background: color-mix(in srgb, var(--accent, #7c6cf0) 14%, transparent);
}

.chat-panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.chat-mode-btn {
  border: 1px solid color-mix(in srgb, var(--accent, #7c6cf0) 40%, var(--line, #ddd));
  background: color-mix(in srgb, var(--accent, #7c6cf0) 12%, transparent);
  color: var(--text, #111);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.chat-mode-btn:hover {
  border-color: var(--accent, #7c6cf0);
}
html[data-theme="dark"] .chat-mode-btn {
  color: #e8eaef;
}

.chat-guide-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat-guide-pane[hidden],
.chat-deep-pane[hidden] {
  display: none !important;
}
.chat-deep-pane {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel-elevated, #fff);
}
.chat-deep-pane iframe {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
}
.chat-bubble {
  max-width: 92%;
  padding: 10px 12px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--accent, #7c6cf0);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: color-mix(in srgb, var(--panel-elevated, #fff) 88%, var(--accent, #7c6cf0) 12%);
  border: 1px solid color-mix(in srgb, var(--line, #ddd) 70%, transparent);
  border-bottom-left-radius: 4px;
}
html[data-theme="dark"] .chat-bubble.assistant {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.1);
}
.chat-bubble.muted {
  align-self: center;
  background: transparent;
  color: var(--muted, #6b7280);
  font-size: 12px;
  padding: 4px;
}

.chat-recs {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 2px;
  align-self: stretch;
}
.chat-rec-card {
  display: block;
  text-align: left;
  text-decoration: none;
  color: inherit;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line, #d8dbe7);
  background: var(--panel-elevated, #fff);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.chat-rec-card:hover {
  border-color: var(--accent, #7c6cf0);
  transform: translateY(-1px);
}
html[data-theme="dark"] .chat-rec-card {
  background: rgba(20, 24, 34, 0.9);
}
.chat-rec-meta {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.chat-rec-meta span {
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent, #7c6cf0) 16%, transparent);
  color: var(--accent, #7c6cf0);
}
.chat-rec-card strong {
  display: block;
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 4px;
}
.chat-rec-card p {
  margin: 0;
  font-size: 12px;
  color: var(--muted, #6b7280);
  line-height: 1.45;
}

.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line, #d8dbe7);
  background: color-mix(in srgb, var(--panel, #fff) 80%, transparent);
}
.chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 12px 10px;
}
.chat-chip {
  border: 1px solid color-mix(in srgb, var(--accent, #7c6cf0) 35%, var(--line, #ddd));
  background: color-mix(in srgb, var(--accent, #7c6cf0) 10%, transparent);
  color: var(--text, #111);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.chat-chip:hover {
  border-color: var(--accent, #7c6cf0);
  background: color-mix(in srgb, var(--accent, #7c6cf0) 18%, transparent);
}
html[data-theme="dark"] .chat-chip {
  color: #e8eaef;
}
.chat-compose textarea {
  resize: none;
  min-height: 44px;
  max-height: 96px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line, #d8dbe7);
  background: var(--panel-elevated, #fff);
  color: var(--text, #111);
  font: inherit;
  font-size: 13.5px;
  line-height: 1.4;
}
html[data-theme="dark"] .chat-compose textarea {
  background: rgba(12, 14, 20, 0.7);
}
.chat-compose button[type="submit"] {
  align-self: end;
  height: 44px;
  min-width: 72px;
  border: 0;
  border-radius: 12px;
  padding: 0 14px;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: var(--accent, #7c6cf0);
}
.chat-compose button[type="submit"]:disabled {
  opacity: 0.55;
  cursor: wait;
}

@media (max-width: 620px) {
  .chat-fab {
    right: 14px;
    bottom: 14px;
    width: 50px;
    height: 50px;
  }
  .chat-panel {
    right: 10px;
    left: 10px;
    width: auto;
    bottom: 72px;
    height: min(70vh, 520px);
  }
  /* Avoid clash with back-top */
  .back-top {
    right: 14px;
    bottom: 72px;
  }
}
