/* CyberAI Academy — floating 錦囊 (embroidery pouch) advisor */
#cyberai-pouch-root {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 99990;
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans TC", sans-serif;
  --pouch-cyan: #00e5ff;
  --pouch-gold: #e8c47a;
  --pouch-panel: rgba(8, 14, 28, 0.94);
  --pouch-border: rgba(0, 229, 255, 0.45);
}
#cyberai-pouch-root * { box-sizing: border-box; }

.pouch-fab {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 2px solid var(--pouch-gold);
  background:
    radial-gradient(circle at 50% 45%, rgba(255,255,255,0.12), transparent 55%),
    linear-gradient(145deg, #1a2740 0%, #0a1220 60%, #061018 100%);
  box-shadow:
    0 0 0 3px rgba(0, 229, 255, 0.15),
    0 8px 28px rgba(0, 0, 0, 0.55),
    0 0 24px rgba(232, 196, 122, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.pouch-fab:hover,
.pouch-fab:focus-visible {
  transform: translateY(-2px) scale(1.04);
  box-shadow:
    0 0 0 3px rgba(0, 229, 255, 0.28),
    0 10px 32px rgba(0, 0, 0, 0.6),
    0 0 32px rgba(232, 196, 122, 0.5);
  outline: none;
}
.pouch-fab[aria-expanded="true"] {
  border-color: var(--pouch-cyan);
}
.pouch-fab-img {
  width: 52px;
  height: auto;
  display: block;
  pointer-events: none;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
  transform-origin: 50% 85%;
  animation: pouch-bob 2.8s ease-in-out infinite;
}
.pouch-fab[aria-expanded="true"] .pouch-fab-img {
  animation: pouch-sway 1.6s ease-in-out infinite;
}
@keyframes pouch-bob {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-5px) rotate(2deg); }
}
@keyframes pouch-sway {
  0%, 100% { transform: translateY(-2px) rotate(-6deg); }
  50% { transform: translateY(-6px) rotate(6deg); }
}
@media (prefers-reduced-motion: reduce) {
  .pouch-fab-img { animation: none !important; }
}
.pouch-fab-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.pouch-panel {
  display: none;
  position: absolute;
  right: 0;
  bottom: 76px;
  width: min(360px, calc(100vw - 1.5rem));
  max-height: min(520px, calc(100vh - 6rem));
  background: var(--pouch-panel);
  border: 1px solid var(--pouch-border);
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(232, 196, 122, 0.12);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  flex-direction: column;
  overflow: hidden;
  color: #e8f4ff;
}
.pouch-panel.is-open {
  display: flex;
}

.pouch-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid rgba(0, 229, 255, 0.2);
  background: linear-gradient(90deg, rgba(232, 196, 122, 0.12), rgba(0, 229, 255, 0.08));
}
.pouch-head h2 {
  margin: 0;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--pouch-gold);
  letter-spacing: 0.02em;
}
.pouch-close {
  background: transparent;
  border: 1px solid rgba(0, 229, 255, 0.35);
  color: var(--pouch-cyan);
  border-radius: 8px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
}
.pouch-close:hover { background: rgba(0, 229, 255, 0.12); }

.pouch-chat {
  flex: 1;
  overflow-y: auto;
  padding: 0.85rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  min-height: 180px;
}
.pouch-msg {
  max-width: 95%;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.pouch-msg.bot {
  align-self: flex-start;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid rgba(0, 229, 255, 0.25);
  color: #d9f7ff;
}
.pouch-msg.user {
  align-self: flex-end;
  background: rgba(232, 196, 122, 0.15);
  border: 1px solid rgba(232, 196, 122, 0.35);
  color: #fff4df;
}
.pouch-results {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.15rem;
}
.pouch-result {
  display: block;
  padding: 0.55rem 0.7rem;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(0, 229, 255, 0.28);
  color: var(--pouch-cyan);
  text-decoration: none;
  font-size: 0.86rem;
  transition: background 0.15s, border-color 0.15s;
}
.pouch-result:hover {
  background: rgba(0, 229, 255, 0.12);
  border-color: var(--pouch-cyan);
  color: #7fffff;
}
.pouch-result small {
  display: block;
  color: rgba(220, 235, 255, 0.72);
  font-size: 0.75rem;
  margin-top: 0.2rem;
  font-weight: 400;
}
.pouch-empty {
  font-size: 0.85rem;
  color: rgba(220, 235, 255, 0.7);
  padding: 0.35rem 0.15rem;
}

.pouch-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0 0.9rem 0.55rem;
}
.pouch-chip {
  border: 1px solid rgba(232, 196, 122, 0.4);
  background: rgba(232, 196, 122, 0.08);
  color: var(--pouch-gold);
  border-radius: 999px;
  padding: 0.28rem 0.65rem;
  font-size: 0.75rem;
  cursor: pointer;
  line-height: 1.2;
}
.pouch-chip:hover {
  background: rgba(0, 229, 255, 0.12);
  border-color: var(--pouch-cyan);
  color: var(--pouch-cyan);
}

.pouch-form {
  display: flex;
  gap: 0.4rem;
  padding: 0.65rem 0.75rem 0.8rem;
  border-top: 1px solid rgba(0, 229, 255, 0.18);
  background: rgba(0, 0, 0, 0.25);
}
.pouch-form input {
  flex: 1;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid rgba(0, 229, 255, 0.35);
  background: rgba(0, 10, 24, 0.85);
  color: #e8f4ff;
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
}
.pouch-form input::placeholder { color: rgba(180, 210, 230, 0.45); }
.pouch-form input:focus {
  outline: none;
  border-color: var(--pouch-cyan);
  box-shadow: 0 0 0 2px rgba(0, 229, 255, 0.2);
}
.pouch-form button[type="submit"] {
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #00c8e0, #0088aa);
  color: #031018;
  font-weight: 700;
  padding: 0 0.9rem;
  cursor: pointer;
  white-space: nowrap;
  font-size: 0.85rem;
}
.pouch-form button[type="submit"]:hover {
  filter: brightness(1.08);
}

@media (max-width: 420px) {
  #cyberai-pouch-root { right: 0.65rem; bottom: 0.65rem; }
  .pouch-fab { width: 64px; height: 64px; }
  .pouch-fab-img { width: 46px; }
  .pouch-panel { bottom: 68px; }
}
