/* Putu chat — custom FAB + bottom-sheet, port dari AsisteKulkulFAB/Modal (Expo) */
.putu-fab-wrap {
  position: fixed;
  z-index: 999;
  width: 62px;
  height: 62px;
  right: max(16px, calc(50% - 215px + 16px));
  bottom: 110px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  will-change: transform;
}
.putu-fab-wrap.putu-snapping { transition: transform .28s cubic-bezier(.32, .72, 0, 1); }
.putu-pulse {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  background: rgba(189, 91, 54, .12);
  animation: putu-pulse 1.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes putu-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.06); opacity: .75; }
}
.putu-fab {
  position: relative;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  border: 2.5px solid var(--terracotta, #BD5B36);
  background: #fff;
  padding: 0;
  cursor: grab;
  overflow: visible;
  box-shadow: 0 4px 12px rgba(189, 91, 54, .35);
  display: flex;
  align-items: center;
  justify-content: center;
}
.putu-fab:active { cursor: grabbing; }
.putu-fab img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  pointer-events: none;
}
.putu-fab-fallback {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--terracotta, #BD5B36);
  background: #fff;
  border-radius: 50%;
}
.putu-fab-fallback svg { width: 26px; height: 26px; }
.putu-fab img:not([style*="none"]) + .putu-fab-fallback { display: none; }
.putu-online {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #4CAF50;
  border: 1.5px solid #fff;
  pointer-events: none;
}

/* ---- full-screen sheet ---- */
.putu-root {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  justify-content: center;
  align-items: stretch;
}
.putu-root[hidden] { display: none; }
.putu-backdrop {
  display: none;
}
.putu-sheet {
  position: relative;
  left: auto;
  transform: none;
  bottom: auto;
  width: 100%;
  max-width: 430px;
  height: 100vh;
  height: 100dvh;
  max-height: none;
  background: var(--cream-soft, #FCFAF5);
  border-radius: 0;
  box-shadow: none;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: putu-up .28s cubic-bezier(.32, .72, 0, 1);
}
@keyframes putu-up { from { transform: translateY(24px); opacity: .6; } to { transform: translateY(0); opacity: 1; } }
.putu-handle {
  display: none;
}
.putu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(14px + env(safe-area-inset-top)) 20px 14px;
  border-bottom: 1px solid #E2E8F0;
  flex-shrink: 0;
}
.putu-title-row { display: flex; align-items: center; gap: 6px; }
.putu-title-row strong {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  color: var(--terracotta, #BD5B36);
  letter-spacing: .2px;
}
.putu-ai-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .4px;
  background: var(--sage, #DFE7D8);
  color: var(--sage-text, #455239);
  border-radius: 999px;
  padding: 2px 7px;
}
.putu-subtitle { font-size: 12px; color: #64748B; display: block; margin-top: 2px; }
.putu-close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #F8FAFC;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1E293B;
}
.putu-close svg { width: 18px; height: 18px; }

.putu-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
}
.putu-row { display: flex; margin-bottom: 12px; max-width: 82%; }
.putu-row.ai { align-self: flex-start; align-items: flex-end; gap: 8px; }
.putu-row.user { align-self: flex-end; justify-content: flex-end; }
.putu-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--terracotta, #BD5B36);
  object-fit: cover;
  flex-shrink: 0;
  background: #fff;
}
.putu-col { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.putu-row.user .putu-col { align-items: flex-end; }
.putu-bubble {
  padding: 10px 14px;
  font-size: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.putu-row.ai .putu-bubble {
  background: #fff;
  color: #1E293B;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
.putu-row.user .putu-bubble {
  background: var(--terracotta, #BD5B36);
  color: #fff;
  border-radius: 16px;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 4px rgba(160, 74, 42, .2);
}
.putu-time { font-size: 11px; color: #CBD5E1; margin: 0 2px; }

/* ---- rich text di bubble AI (markdown: bold, italic, list, link, kode) ---- */
.putu-bubble .putu-p { margin: 0 0 6px; }
.putu-bubble .putu-p:last-child { margin-bottom: 0; }
.putu-bubble strong { font-weight: 700; }
.putu-bubble em { font-style: italic; }
.putu-bubble del { text-decoration: line-through; opacity: .7; }
.putu-bubble code.putu-code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12.5px;
  background: rgba(30, 41, 59, .09);
  padding: 1px 6px;
  border-radius: 6px;
}
.putu-bubble pre.putu-pre {
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #1E293B;
  color: #F8FAFC;
  overflow-x: auto;
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre;
}
.putu-bubble pre.putu-pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
}
.putu-bubble ul.putu-list, .putu-bubble ol.putu-list { margin: 6px 0 8px; padding-left: 20px; }
.putu-bubble ul.putu-list:last-child, .putu-bubble ol.putu-list:last-child,
.putu-bubble pre.putu-pre:last-child, .putu-bubble .putu-h:last-child { margin-bottom: 0; }
.putu-bubble li { margin: 3px 0; }
.putu-bubble li::marker { color: var(--terracotta, #BD5B36); font-weight: 700; }
.putu-bubble .putu-h { font-weight: 700; font-size: 14.5px; margin: 8px 0 4px; }
.putu-bubble .putu-h:first-child { margin-top: 0; }
.putu-row.ai .putu-bubble a { color: var(--terracotta-dark, #A04A2A); font-weight: 600; }
.putu-row.user .putu-bubble a { color: #fff; }
.putu-typing {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #fff;
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .06);
}
.putu-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--terracotta, #BD5B36);
  animation: putu-blink 1s ease-in-out infinite;
}
.putu-typing i:nth-child(2) { animation-delay: .2s; }
.putu-typing i:nth-child(3) { animation-delay: .4s; }
@keyframes putu-blink { 0%, 100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }

.putu-dock {
  border-top: 1px solid #E2E8F0;
  background: var(--cream-soft, #FCFAF5);
  padding-bottom: env(safe-area-inset-bottom);
  flex-shrink: 0;
}
.putu-input-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
}
.putu-input-row textarea {
  flex: 1;
  min-height: 44px;
  max-height: 100px;
  resize: none;
  background: #F8FAFC;
  border: 1.2px solid transparent;
  border-radius: 22px;
  padding: 12px 18px;
  font-size: 14px;
  line-height: 1.45;
  color: #1E293B;
  font-family: 'Inter', sans-serif;
}
.putu-input-row textarea:focus { outline: none; border-color: var(--terracotta, #BD5B36); background: #fff; }
.putu-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  flex-shrink: 0;
  background: var(--terracotta, #BD5B36);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 3px 6px rgba(160, 74, 42, .3);
}
.putu-send:disabled { opacity: .45; box-shadow: none; }
.putu-send svg { width: 18px; height: 18px; }

body.putu-open { overflow: hidden; }
body.putu-open .bottomnav { opacity: 0; pointer-events: none; transform: translate(-50%, 100%); }
@media (prefers-reduced-motion: reduce) {
  .putu-pulse, .putu-typing i, .putu-sheet { animation: none; }
}
