* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%;
  background: #ffffff; color: #1a1a1e;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior-y: none;
}
#app {
  display: flex; flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

#topbar {
  padding: 12px 16px calc(12px + env(safe-area-inset-top, 0px)) 16px;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  border-bottom: 1px solid #ececef;
  display: flex; align-items: baseline; gap: 10px; flex-shrink: 0;
  background: #ffffff;
}
.logo { font-weight: 800; letter-spacing: 1px; color: #ff4785; }
.subtitle { font-size: 12.5px; color: #8a8d98; }

#password-gate {
  flex: 1; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.gate-box {
  background: #fafafc; border: 1px solid #ececef; border-radius: 16px;
  padding: 28px 24px; width: 100%; max-width: 320px; text-align: center;
  box-shadow: 0 2px 16px rgba(0,0,0,0.04);
}
.gate-box h2 { margin: 0 0 6px; color: #1a1a1e; }
.gate-box p { color: #8a8d98; font-size: 13px; margin: 0 0 16px; }
.gate-box input {
  width: 100%; padding: 12px 14px; border-radius: 10px; border: 1px solid #ddd;
  background: #ffffff; color: #1a1a1e; margin-bottom: 10px; font-size: 16px;
}
.gate-box button {
  width: 100%; padding: 12px; border-radius: 10px; border: none;
  background: #ff4785; color: white; font-weight: 600; cursor: pointer; font-size: 15px;
}
.error-text { color: #e0245e; font-size: 12px; min-height: 16px; }

#chat {
  flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 16px; display: flex; flex-direction: column; gap: 14px;
}
.hidden { display: none !important; }

.msg { max-width: 82%; padding: 11px 14px; border-radius: 16px; line-height: 1.45; font-size: 14.5px; word-wrap: break-word; }
.msg.user { align-self: flex-end; background: #ff4785; color: white; border-bottom-right-radius: 4px; }
.msg.assistant { align-self: flex-start; background: #f4f4f6; color: #1a1a1e; border: 1px solid #ececef; border-bottom-left-radius: 4px; }

.msg img.thumb { width: 60px; height: 60px; object-fit: cover; border-radius: 8px; margin: 3px; }
.thumbs-row { display: flex; flex-wrap: wrap; margin-bottom: 6px; }

.spinner {
  display: inline-block; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid #ddd; border-top-color: #ff4785; animation: spin 0.8s linear infinite;
  margin-right: 8px; vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

.roteiro-box { margin-top: 10px; font-size: 13px; color: #55575e; border-top: 1px solid #e4e4e8; padding-top: 8px; }
.roteiro-box b { color: #1a1a1e; }
.roteiro-box ul { margin: 6px 0; padding-left: 18px; }

video.result { width: 100%; max-width: 260px; border-radius: 12px; margin-top: 4px; display: block; background: #000; }
.download-link {
  display: inline-block; margin-top: 8px; padding: 9px 16px; background: #ff4785;
  color: white; text-decoration: none; border-radius: 20px; font-size: 13px; font-weight: 600;
}

#composer {
  border-top: 1px solid #ececef; padding: 10px 12px;
  padding-bottom: max(10px, env(safe-area-inset-bottom, 0px));
  flex-shrink: 0; background: #ffffff;
}
#preview-row { display: flex; gap: 6px; margin-bottom: 8px; flex-wrap: wrap; }
#preview-row img { width: 46px; height: 46px; object-fit: cover; border-radius: 8px; border: 1px solid #ddd; }
#composer-row { display: flex; align-items: center; gap: 8px; }
.attach-btn {
  font-size: 20px; cursor: pointer; width: 42px; height: 42px; min-width: 42px; border-radius: 50%;
  background: #f4f4f6; border: 1px solid #ececef; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#caption-input {
  flex: 1; min-width: 0; padding: 11px 14px; border-radius: 22px; border: 1px solid #ddd;
  background: #fafafc; color: #1a1a1e; font-size: 16px;
}
#send-btn {
  padding: 11px 16px; border-radius: 22px; border: none; background: #ff4785;
  color: white; font-weight: 600; cursor: pointer; flex-shrink: 0; font-size: 14.5px;
}
#send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 480px) {
  .msg { max-width: 88%; }
  video.result { max-width: 100%; }
}
