* { margin:0; padding:0; box-sizing:border-box; -webkit-tap-highlight-color:transparent; }
html, body { height:100%; overflow:hidden; }
body {
  font-family: 'Roboto', -apple-system, system-ui, sans-serif;
  display:flex; flex-direction:column;
  height: 100vh;
  height: 100dvh;
  background: #c6ddb8;
}

/* HEADER */
.header {
  position: relative;
  flex-shrink: 0;
  z-index: 10;
  box-shadow: 0 1px 2px rgba(0,0,0,0.15);
  background: #f7f8fa;
}
.header::before {
  content: '';
  position: absolute;
  top: -100px; left: 0; right: 0; height: 100px;
  background: #f7f8fa;
  z-index: -1;
}
.header-img {
  display: block;
  width: 100%;
  height: auto;
}
.header-overlay {
  position: absolute;
  left: 128px;
  bottom: 8px;
  pointer-events: none;
}
.header-overlay .subtitle {
  color: #a0b4bf;
  font-size: 14px;
  font-weight: 500;
  font-family: 'Roboto', -apple-system, system-ui, sans-serif;
  background: transparent;
  padding: 0;
}

/* CHAT AREA */
.chat-area {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

/* Telegram animated wallpaper — 3 layers */
.chat-bg {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 100vh;
  height: 100lvh;
  z-index: -2;
  overflow: hidden;
}
/* Layer 1: green blurred background */
.chat-bg-base {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url('green_bg.png') center/cover no-repeat;
}
/* Layer 2: animated gradient blobs */
.chat-bg-gradient {
  position: absolute;
  top: -20%; left: -20%; right: -20%; bottom: -20%;
  will-change: transform;
  z-index: 1;
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.6;
  will-change: transform;
  transition: transform 0.3s ease-out;
}
.blob-1 { width: 45%; height: 40%; top: 10%; left: 5%; background: rgba(142,220,160,0.7); }
.blob-2 { width: 40%; height: 45%; top: 5%; right: 5%; background: rgba(110,200,180,0.6); }
.blob-3 { width: 50%; height: 35%; bottom: 15%; left: 15%; background: rgba(170,225,140,0.5); }
.blob-4 { width: 35%; height: 40%; bottom: 10%; right: 10%; background: rgba(130,210,175,0.5); }
/* Layer 3: doodle abstractions */
.chat-bg-pattern {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url('abstractions.png') center/cover no-repeat;
  opacity: 0.35;
  z-index: 3;
}
/* Static bg — ON TOP of everything */
.chat-bg-static {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: url('bg.jpg') center/cover no-repeat;
  z-index: 10;
  display: none;
}
.chat-bg.mode-static .chat-bg-static { display: block; }
.chat-bg.mode-bg15 .chat-bg-static { display: block; background-image: url('bg15.jpg'); }
.chat-bg-DISABLED::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  opacity: 0;
  background-image:
    /* Row 1 */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 20 20'%3E%3Cpath d='M2 8L10 4L18 8L10 12Z' fill='%23446e8a'/%3E%3Cpath d='M10 12L18 8V14L10 18Z' fill='%23446e8a'/%3E%3C/svg%3E"),
    /* Paper plane */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 18 18'%3E%3Ccircle cx='9' cy='9' r='6' stroke='%23446e8a' stroke-width='1.5' fill='none'/%3E%3Ccircle cx='9' cy='9' r='2' fill='%23446e8a'/%3E%3C/svg%3E"),
    /* Lock */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='18' viewBox='0 0 14 18'%3E%3Crect x='1' y='8' width='12' height='9' rx='2' fill='%23446e8a'/%3E%3Cpath d='M4 8V5a3 3 0 016 0v3' stroke='%23446e8a' stroke-width='1.5' fill='none'/%3E%3C/svg%3E"),
    /* Star */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 18 18'%3E%3Cpath d='M9 1l2.5 5 5.5.8-4 3.9.9 5.3L9 13.5 4.1 16l.9-5.3-4-3.9 5.5-.8z' fill='%23446e8a'/%3E%3C/svg%3E"),
    /* Heart */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16'%3E%3Cpath d='M8 14s-5.5-3.5-5.5-7A3.5 3.5 0 018 4.5 3.5 3.5 0 0113.5 7C13.5 10.5 8 14 8 14z' fill='%23446e8a'/%3E%3C/svg%3E"),
    /* Bell */
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='18' viewBox='0 0 16 18'%3E%3Cpath d='M8 1a5 5 0 00-5 5v4l-2 2v1h14v-1l-2-2V6a5 5 0 00-5-5zm0 16a2 2 0 002-2H6a2 2 0 002 2z' fill='%23446e8a'/%3E%3C/svg%3E");
  background-position:
    30px 20px,
    130px 45px,
    230px 30px,
    80px 80px,
    180px 95px,
    280px 75px;
  background-size:
    20px 20px,
    18px 18px,
    14px 18px,
    18px 18px,
    16px 16px,
    16px 18px;
  background-repeat: repeat;
  /* Create a tiled pattern using a single repeating tile */
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200' viewBox='0 0 200 200'%3E%3Cg fill='%23446e8a'%3E%3Cpath d='M25 15l8-4 8 4-8 4z'/%3E%3Cpath d='M33 15l8 4v6l-8 4z' opacity='.7'/%3E%3Ccircle cx='90' cy='25' r='6' fill='none' stroke='%23446e8a' stroke-width='1.5'/%3E%3Ccircle cx='90' cy='25' r='2'/%3E%3Cpath d='M150 12l2.5 5 5.5.8-4 3.9.9 5.3-4.9-2.5-4.9 2.5.9-5.3-4-3.9 5.5-.8z'/%3E%3Crect x='17' y='65' width='10' height='8' rx='1.5'/%3E%3Cpath d='M20 65v-3a3 3 0 016 0v3' fill='none' stroke='%23446e8a' stroke-width='1.3'/%3E%3Cpath d='M80 70s-4-2.5-4-5.5a3 3 0 016 0 3 3 0 016 0c0 3-4 5.5-4 5.5z'/%3E%3Cpath d='M140 55l6-3 6 3-6 3z'/%3E%3Cpath d='M146 55l6 3v5l-6 3z' opacity='.7'/%3E%3Cpath d='M50 110l8-4 8 4-8 4z'/%3E%3Cpath d='M58 110l8 4v6l-8 4z' opacity='.7'/%3E%3Ccircle cx='120' cy='100' r='6' fill='none' stroke='%23446e8a' stroke-width='1.5'/%3E%3Ccircle cx='120' cy='100' r='2'/%3E%3Cpath d='M175 105l2.5 5 5.5.8-4 3.9.9 5.3-4.9-2.5-4.9 2.5.9-5.3-4-3.9 5.5-.8z'/%3E%3Crect x='35' y='150' width='10' height='8' rx='1.5'/%3E%3Cpath d='M38 150v-3a3 3 0 016 0v3' fill='none' stroke='%23446e8a' stroke-width='1.3'/%3E%3Cpath d='M100 160s-4-2.5-4-5.5a3 3 0 016 0 3 3 0 016 0c0 3-4 5.5-4 5.5z'/%3E%3Cpath d='M165 145l6-3 6 3-6 3z'/%3E%3Cpath d='M171 145l6 3v5l-6 3z' opacity='.7'/%3E%3Cpath d='M10 180l2.5 5 5.5.8-4 3.9.9 5.3-4.9-2.5-4.9 2.5.9-5.3-4-3.9 5.5-.8z'/%3E%3Ccircle cx='75' cy='185' r='5' fill='none' stroke='%23446e8a' stroke-width='1.3'/%3E%3Ccircle cx='75' cy='185' r='1.5'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 200px 200px;
  background-position: 0 0;
}

.messages-container {
  padding: 4px 0 70px;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
  z-index: 1;
}

/* SERVICE MESSAGE - pinned under header */
/* SERVICE MESSAGE - full-width bar under header */
.service-msg-pinned {
  text-align: center;
  padding: 6px 4px 4px;
  position: sticky;
  top: 0;
  z-index: 8;
  background: transparent;
}
.service-msg-pinned span {
  background: #fff;
  color: #697880;
  font-size: 13px;
  font-weight: 400;
  padding: 6px 20px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
  width: 100%;
  justify-content: center;
}
.service-msg-pinned .bot-icon {
  flex-shrink: 0;
}

/* MESSAGE ROW */
.msg-row {
  display: flex;
  padding: 1px 8px;
  max-width: 100%;
}
.msg-row.out { justify-content: flex-end; }
.msg-row.in { justify-content: flex-start; }
.msg-row.gap-top { padding-top: 4px; }

/* BUBBLE */
.bubble {
  max-width: 78%;
  width: fit-content;
  padding: 5px 8px 5px 11px;
  position: relative;
  word-wrap: break-word;
  line-height: 1.35;
  font-size: 16px;
  color: #000;
}
.bubble.out-bubble {
  background: #efffde;
  border-radius: 12px 12px 4px 12px;
  margin-right: 2px;
}
.bubble.out-bubble.tail {
  border-radius: 12px 12px 4px 12px;
}
.bubble.in-bubble {
  background: #fff;
  border-radius: 12px 12px 12px 4px;
  margin-left: 2px;
}
.bubble.in-bubble.tail {
  border-radius: 12px 12px 12px 4px;
}

/* TAIL shapes */
.bubble.out-bubble.tail {
  border-bottom-right-radius: 0;
  margin-right: 8px;
}
.bubble.out-bubble.tail::before {
  content: '';
  position: absolute;
  right: -8px;
  bottom: 0;
  width: 8px;
  height: 14px;
  background: #efffde;
  clip-path: path('M0,3 Q0,9 4,13 Q6,14 8,14 L0,14 Z');
}
.bubble.in-bubble.tail {
  border-bottom-left-radius: 0;
  margin-left: 8px;
}
.bubble.in-bubble.tail::before {
  content: '';
  position: absolute;
  left: -8px;
  bottom: 0;
  width: 8px;
  height: 14px;
  background: #fff;
  clip-path: path('M8,3 Q8,9 4,13 Q2,14 0,14 L8,14 Z');
}

/* Message meta (time + checks) — always bottom-right */
.bubble::after {
  content: '';
  display: inline-block;
  width: 3px;
  height: 0;
  vertical-align: baseline;
  font-size: 0;
  line-height: 0;
}
.bubble.out-bubble::after {
  width: 3px;
}
.msg-meta {
  float: right;
  margin-top: 0px;
  display: flex;
  align-items: center;
  gap: 3px;
  height: 16px;
  position: relative;
  top: 4px;
  margin-left: 6px;
}
.msg-time {
  font-size: 12px;
  white-space: nowrap;
}
.bubble.out-bubble .msg-time { color: #70b15c; }
.bubble.in-bubble .msg-time { color: #a1aab3; }

.msg-checks {
  display: inline-flex;
  align-items: center;
}
.msg-checks svg {
  width: 16px; height: 11px;
}

/* Command link style */
.cmd-link {
  color: #3b8abf;
  text-decoration: none;
  font-size: 16px;
}

/* Image bubble */
.bubble.img-bubble {
  padding: 3px 3px 5px 3px;
}
.bubble-image {
  border-radius: 10px;
  overflow: hidden;
  max-width: 180px;
}
.bubble-image img {
  max-width: 100%;
  display: block;
}
.screenshot-placeholder {
  width: 260px;
  height: 180px;
  background: #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  font-size: 15px;
  font-weight: 500;
}
.img-meta {
  padding: 2px 7px 0;
}

/* INPUT PANEL - floating */
.input-panel-wrap {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 4px 8px 8px;
  z-index: 20;
}
.input-panel-wrap img {
  filter: drop-shadow(0 0 1px #f7f8fa) drop-shadow(0 0 1px #f7f8fa) drop-shadow(0 0 1px #f7f8fa);
}
.input-panel {
  background: #fff;
  display: flex;
  align-items: flex-end;
  border-radius: 22px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
  overflow: hidden;
}
.input-panel .emoji-btn {
  width: 44px; height: 44px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink: 0;
  cursor: pointer;
}
.input-panel .emoji-btn svg { width:24px; height:24px; fill:#8e959b; }
.input-panel .input-field {
  flex: 1;
  border: none;
  outline: none;
  font-family: 'Roboto', -apple-system, system-ui, sans-serif;
  font-size: 16px;
  color: #000;
  padding: 10px 4px;
  line-height: 1.25;
  min-height: 44px;
  resize: none;
  background: transparent;
}
.input-panel .input-field::placeholder { color: #a4adb5; }
.input-panel .attach-btn,
.input-panel .mic-btn {
  width: 44px; height: 44px;
  display:flex; align-items:center; justify-content:center;
  flex-shrink: 0;
  cursor: pointer;
}
.input-panel .attach-btn svg,
.input-panel .mic-btn svg { width:24px; height:24px; fill:#8e959b; }

/* ADD MENU */
.add-menu {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%) scale(0.9) translateY(10px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  z-index: 100;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  width: calc(100% - 24px);
  max-width: 340px;
  padding: 12px;
}
.add-menu.show {
  opacity: 1;
  transform: translateX(-50%) scale(1) translateY(0);
}
.am-top-row {
  display: flex; gap: 10px; margin-bottom: 10px;
}
.am-big-btn {
  flex: 1; padding: 14px 8px; border-radius: 12px; text-align: center;
  cursor: pointer; transition: transform 0.1s;
}
.am-big-btn:active { transform: scale(0.95); }
.am-in {
  background: linear-gradient(135deg, #fff 0%, #f0f4f8 100%);
  border: 1.5px solid #e0e6ed;
}
.am-out {
  background: linear-gradient(135deg, #efffde 0%, #d4f5c0 100%);
  border: 1.5px solid #c5e8b0;
}
.am-icon {
  font-size: 22px; font-weight: 700; margin-bottom: 4px;
}
.am-in .am-icon { color: #5b9bd5; }
.am-out .am-icon { color: #6ab04c; }
.am-label {
  font-size: 13px; font-weight: 500; color: #444;
}
.am-grid {
  display: flex; gap: 8px;
}
.am-grid-btn {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 10px 4px; border-radius: 10px; background: #f7f8fa;
  cursor: pointer; transition: background 0.1s, transform 0.1s;
  border: 1px solid #eee;
}
.am-grid-btn:active { background: #e8eaed; transform: scale(0.95); }
.am-grid-icon { font-size: 20px; margin-bottom: 3px; }
.am-grid-text { font-size: 11px; color: #666; font-weight: 500; }

/* MSG CONTEXT MENU */
.msg-menu {
  position: absolute;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 100;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.15s ease;
}
.msg-menu.show { opacity: 1; }
.msg-menu-item {
  padding: 12px 24px;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}
.msg-menu-item.delete { color: #e53935; }
.msg-menu-item.cancel { color: #555; }
.msg-menu-item:active { background: #f5f5f5; }

/* HEADER MENU */
.header-menu {
  position: fixed;
  top: 50px;
  right: 8px;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  z-index: 100;
  overflow: hidden;
  opacity: 0;
  transition: opacity 0.15s ease;
  min-width: 200px;
}
.header-menu.show { opacity: 1; }
.header-menu-item {
  padding: 14px 20px;
  font-size: 15px;
  color: #222;
  cursor: pointer;
  border-bottom: 0.5px solid #eee;
}
.header-menu-item:last-child { border-bottom: none; }
.header-menu-item:active { background: #f0f0f0; }

/* DATE SEPARATOR */
.date-separator {
  text-align: center;
  padding: 8px 0;
}
.date-separator span {
  background: rgba(0,0,0,0.12);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 16px;
}

/* FILE BUBBLE */
.file-bubble { padding: 8px 10px 6px !important; }
.file-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.file-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  flex-shrink: 0;
}
.file-info { flex: 1; min-width: 0; }
.file-name {
  font-size: 14px;
  font-weight: 500;
  color: #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.file-size {
  font-size: 12px;
  color: #70b15c;
  margin-top: 2px;
}

/* VOICE BUBBLE */
.voice-bubble { padding: 8px 10px 6px !important; }
.voice-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.voice-play {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #6cb556;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
  cursor: pointer;
}
.voice-wave { flex: 1; overflow: hidden; }
.voice-dur {
  font-size: 12px;
  color: #70b15c;
  flex-shrink: 0;
}

/* SUBTITLE EDITOR POPUP */
.subtitle-editor {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  z-index: 200;
  padding: 16px 20px;
  min-width: 220px;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  text-align: center;
}
.subtitle-editor.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}
.se-title {
  font-size: 15px;
  font-weight: 500;
  color: #333;
  margin-bottom: 10px;
}
.se-input {
  width: 100%;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 15px;
  font-family: 'Roboto', -apple-system, system-ui, sans-serif;
  outline: none;
  text-align: center;
  margin-bottom: 10px;
}
.se-input:focus { border-color: #35AADC; }
.se-label {
  font-size: 12px;
  color: #999;
  margin-bottom: 6px;
}
.se-arrows {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin-bottom: 8px;
}
.se-row {
  display: flex;
  gap: 4px;
  align-items: center;
}
.se-btn {
  width: 40px;
  height: 40px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #f5f5f5;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-user-select: none;
  user-select: none;
}
.se-btn:active { background: #e0e0e0; }
.se-btn.se-ok {
  background: #35AADC;
  color: #fff;
  border-color: #35AADC;
  font-size: 14px;
  font-weight: 600;
}
.se-pos {
  font-size: 11px;
  color: #aaa;
  font-family: monospace;
}

/* Scrollbar */
.chat-area::-webkit-scrollbar { width:3px; }
.chat-area::-webkit-scrollbar-thumb { background:rgba(0,0,0,0.15); border-radius:2px; }

/* TIME EDITOR */
.time-editor {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  border-radius: 16px;
  padding: 20px 24px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.25);
  z-index: 9999;
  text-align: center;
}
.te-title { font-size: 14px; color: #888; margin-bottom: 12px; }
.te-controls { display: flex; align-items: center; justify-content: center; gap: 8px; }
.te-col { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.te-btn {
  width: 44px; height: 36px;
  border: none; background: #f0f0f0;
  border-radius: 8px; font-size: 18px;
  cursor: pointer; color: #333;
  display: flex; align-items: center; justify-content: center;
}
.te-btn:active { background: #ddd; }
.te-val { font-size: 32px; font-weight: 500; color: #222; min-width: 50px; }
.te-colon { font-size: 32px; font-weight: 500; color: #222; margin: 0 2px; padding-bottom: 4px; }
.te-actions { display: flex; gap: 10px; margin-top: 16px; justify-content: center; }
.te-ok, .te-cancel {
  padding: 8px 24px; border: none; border-radius: 8px;
  font-size: 14px; cursor: pointer;
}
.te-ok { background: #4CAF50; color: #fff; }
.te-cancel { background: #f0f0f0; color: #333; }
.te-ok:active { background: #388E3C; }
.te-cancel:active { background: #ddd; }

/* DELETE BUTTON */
.msg-delete-btn {
  position: absolute;
  right: -75px;
  top: 50%;
  transform: translateY(-50%);
  background: #e53935;
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 10px;
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  cursor: pointer;
  z-index: 10;
}
.msg-delete-btn:active { background: #c62828; }

/* TIME SLIDERS */
.te-sliders { margin-top: 14px; padding: 0 4px; }
.te-slider-row {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.te-slider-label { font-size: 12px; color: #888; min-width: 32px; text-align: right; }
.te-range {
  flex: 1; height: 4px; -webkit-appearance: none; appearance: none;
  background: #e0e0e0; border-radius: 2px; outline: none;
}
.te-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 22px; height: 22px; border-radius: 50%;
  background: #4CAF50; border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2); cursor: pointer;
}

/* DRAG REORDER */
.drag-hint {
  text-align: center; font-size: 12px; color: #4CAF50;
  padding: 4px; font-weight: 500; animation: pulse 1s infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }
.drag-clone {
  position: fixed; left: 0; z-index: 9999;
  opacity: 0.85; transform: scale(1.02);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  pointer-events: none;
}

/* INLINE MSG TOOLBAR */
.msg-toolbar {
  position: absolute; top: -38px; left: 50%; transform: translateX(-50%) scale(0.8);
  display: flex; gap: 4px; background: #fff; padding: 4px 6px;
  border-radius: 20px; box-shadow: 0 2px 12px rgba(0,0,0,0.15);
  z-index: 100; opacity: 0; transition: all 0.15s ease;
}
.msg-toolbar.show { opacity: 1; transform: translateX(-50%) scale(1); }
.mt-btn-icon {
  width: 32px; height: 32px; border: none; border-radius: 50%;
  font-size: 14px; display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform 0.1s;
}
.mt-btn-icon:active { transform: scale(0.85); }
.mt-up { background: #E3F2FD; }
.mt-down { background: #E3F2FD; }
.mt-edit { background: #FFF3E0; }
.mt-time { background: #F3E5F5; }
.mt-mass { background: #E8F5E9; }
.mt-reload { background: #ECEFF1; }
.mt-dup { background: #E0F7FA; }
.mt-swap { background: #FFF8E1; }
.mt-date { background: #FCE4EC; }

/* DRAFT MESSAGE */
.draft-row {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 10px; justify-content: center;
}
.draft-bubble {
  flex: 1; max-width: 70%;
  background: #f5f5f5; border: 2px dashed #ccc;
  border-radius: 16px; padding: 10px 14px;
  font-size: 16px; line-height: 1.35; color: #222;
  outline: none; min-height: 24px;
  transition: border-color 0.2s;
}
.draft-bubble:focus { border-color: #5b9bd5; }
.draft-bubble:empty::before {
  content: attr(data-placeholder);
  color: #aaa; pointer-events: none;
}
.draft-send-btn {
  width: 40px; height: 40px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; font-weight: 700; cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  flex-shrink: 0;
}
.draft-send-btn:active { transform: scale(0.9); }
.draft-send-in {
  background: linear-gradient(135deg, #fff, #e8f0fe);
  color: #5b9bd5; border: 1.5px solid #d0dfef;
}
.draft-send-out {
  background: linear-gradient(135deg, #efffde, #d4f5c0);
  color: #4a9e3f; border: 1.5px solid #bfe0a8;
}

/* FAB OVERLAY on input image */
.fab-overlay {
  position: absolute; top: -50px; left: 50%;
  transform: translateX(-50%) scale(0.7);
  display: flex; gap: 12px;
  opacity: 0; transition: opacity 0.2s, transform 0.2s;
  z-index: 50; pointer-events: none;
}
.fab-overlay.show {
  opacity: 1; transform: translateX(-50%) scale(1);
  pointer-events: auto;
}
.fab-btn {
  width: 44px; height: 44px; border-radius: 50%;
  background: #fff; box-shadow: 0 3px 12px rgba(0,0,0,0.2);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  border: 1px solid #eee;
}
.fab-btn:active { transform: scale(0.88); background: #f0f0f0; }

/* BG SETTINGS — left sidebar */
.bg-settings {
  position: fixed;
  top: 82px; left: 0; bottom: 58px;
  width: 48px;
  background: rgba(20,20,20,0.82);
  backdrop-filter: blur(14px);
  border-radius: 0 14px 14px 0;
  box-shadow: 4px 0 20px rgba(0,0,0,0.25);
  z-index: 200;
  display: flex;
  opacity: 0;
  transform: translateX(-48px);
  transition: opacity 0.2s, transform 0.2s, width 0.2s ease;
  overflow: hidden;
}
.bg-settings.show {
  opacity: 1;
  transform: translateX(0);
}
.bg-settings.expanded {
  width: 210px;
}
.bgs-icons {
  width: 48px;
  min-width: 48px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
}
.bgs-icon-btn {
  width: 40px; height: 40px;
  border: none; border-radius: 8px;
  background: transparent;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
  padding: 0;
}
.bgs-icon-btn:active { transform: scale(0.9); }
.bgs-icon-btn.active { background: #4CAF50; color: #fff; }
.bgs-icon-btn svg { width: 20px; height: 20px; }
.bgs-close-btn {
  margin-top: auto;
  background: rgba(229,57,53,0.8) !important;
  color: #fff !important;
}
.bgs-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 8px 8px 0;
  display: none;
  border-left: 1px solid rgba(255,255,255,0.1);
}
.bg-settings.expanded .bgs-content { display: block; }
.bgs-panel { display: none; }
.bgs-panel.active { display: block; }
.bgs-row {
  margin-bottom: 8px;
}
.bgs-row-label {
  display: block;
  font-size: 10px;
  color: rgba(255,255,255,0.6);
  margin-bottom: 3px;
}
.bgs-row-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}
.bgs-color {
  width: 34px; height: 28px;
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
  -webkit-appearance: none;
}
.bgs-range {
  flex: 1; height: 3px;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
}
.bgs-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #4CAF50;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}
.bgs-val {
  font-size: 11px;
  color: #4CAF50;
  min-width: 30px;
  text-align: right;
  font-weight: 700;
}
.bgs-reset-btn {
  padding: 3px 6px;
  border-radius: 4px;
  border: none;
  background: rgba(255,255,255,0.15);
  font-size: 10px;
  color: #ccc;
  cursor: pointer;
  width: 100%;
  margin-top: 4px;
}
.bgs-mode-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
}
.bgs-mode-btn {
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
  padding: 6px 2px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.7);
  font-size: 9px;
  cursor: pointer;
  transition: all 0.12s;
}
.bgs-mode-btn.active {
  background: #4CAF50;
  color: #fff;
  border-color: #4CAF50;
}
.bgs-mode-btn svg { width: 18px; height: 18px; }

.mt-up5 { background: #BBDEFB; }
.mt-down5 { background: #BBDEFB; }

/* INPUT REPLACE — replaces PNG */
.input-replace {
  padding: 6px 8px;
  background: #f7f8fa;
}
.ir-top {
  display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.ir-field {
  flex: 1; background: #fff; border: 1.5px solid #ddd; border-radius: 20px;
  padding: 8px 14px; font-size: 15px; line-height: 1.35; color: #222;
  outline: none; min-height: 20px; max-height: 120px; overflow-y: auto;
}
.ir-field:focus { border-color: #5b9bd5; }
.ir-field:empty::before {
  content: attr(data-placeholder); color: #aaa; pointer-events: none;
}
.ir-send-btn {
  width: 36px; height: 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; cursor: pointer; flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,0.12); transition: transform 0.1s;
}
.ir-send-btn:active { transform: scale(0.9); }
.ir-send-in { background: #fff; color: #5b9bd5; border: 1px solid #d0dfef; }
.ir-send-out { background: #efffde; color: #4a9e3f; border: 1px solid #bfe0a8; }
.ir-tools {
  display: flex; justify-content: center; gap: 8px;
}
.ir-tool-btn {
  width: 38px; height: 38px; border-radius: 50%; background: #fff;
  border: 1px solid #eee; display: flex; align-items: center;
  justify-content: center; font-size: 18px; cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08); transition: transform 0.1s;
}
.ir-tool-btn:active { transform: scale(0.9); background: #f0f0f0; }

/* UPDATE TOAST */
.update-toast {
  position: fixed; top: 80px; left: 50%; transform: translateX(-50%) translateY(-20px);
  background: #333; color: #fff; padding: 10px 20px; border-radius: 20px;
  font-size: 13px; font-weight: 500; z-index: 300;
  opacity: 0; transition: opacity 0.3s, transform 0.3s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.update-toast.show {
  opacity: 1; transform: translateX(-50%) translateY(0);
}

.bgs-eye-btn { margin-top: auto; }
