:root {
  --bg: #0b1220;
  --panel: #111827;
  --bubble-me: #1f2937;
  --bubble-elad: #065f46;
  --bubble-elad-2: #047857;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #10b981;
  --danger: #ef4444;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

.topbar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: max(env(safe-area-inset-top), 10px) 12px 8px;
  background: var(--panel);
  border-bottom: 1px solid #1f2937;
}
.topbar .title { font-weight: 700; font-size: 17px; }

/* day tabs: sticky "היום" on the right, older days scroll to the left */
.days-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.day-chip {
  flex: 0 0 auto;
  background: #1f2937;
  color: var(--muted);
  border: 1px solid #374151;
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 13px;
  white-space: nowrap;
}
.day-chip:active { background: #263143; }
.day-chip.active {
  background: var(--accent);
  color: #052e1f;
  border-color: var(--accent);
  font-weight: 700;
}
.days-scroll {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  flex: 1 1 auto;
  min-width: 0;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.days-scroll::-webkit-scrollbar { display: none; }

/* read-only bar shown when viewing a past day */
.past-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px calc(env(safe-area-inset-bottom) + 12px);
  background: var(--panel);
  border-top: 1px solid #1f2937;
  color: var(--muted);
  font-size: 14px;
}
.past-bar button {
  background: var(--accent);
  color: #052e1f;
  font-weight: 700;
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
}
.past-bar button:active { background: #34d399; }

/* day-swipe transition */
.chat.slide-old { animation: slideOld 0.18s ease-out; }
.chat.slide-new { animation: slideNew 0.18s ease-out; }
@keyframes slideOld { from { opacity: 0.3; transform: translateX(-24px); } to { opacity: 1; transform: none; } }
@keyframes slideNew { from { opacity: 0.3; transform: translateX(24px); } to { opacity: 1; transform: none; } }

.chat {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 12px 4px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  -webkit-overflow-scrolling: touch;
}

.empty {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 24px;
}
.empty-emoji { font-size: 44px; margin-bottom: 8px; }

.msg {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 16px;
  line-height: 1.45;
  font-size: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  animation: pop 0.14s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

.msg.me {
  align-self: flex-start;              /* RTL: user on the right visually via dir */
  background: var(--bubble-me);
  border-bottom-right-radius: 4px;
}
.msg.elad {
  align-self: flex-end;
  background: var(--bubble-elad);
  border-bottom-left-radius: 4px;
}
.msg img {
  display: block;
  max-width: 100%;
  border-radius: 10px;
  margin-bottom: 6px;
}
.msg .cap:empty { display: none; }

.msg.typing {
  align-self: flex-end;
  background: var(--bubble-elad-2);
  color: #d1fae5;
  font-style: italic;
}
.dots::after {
  content: "";
  animation: dots 1.2s steps(4, end) infinite;
}
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }

.error { color: #fecaca; font-size: 13px; align-self: center; text-align: center; }

.composer {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 12px calc(env(safe-area-inset-bottom) + 12px);
  background: var(--panel);
  border-top: 1px solid #1f2937;
}

/* the hero: big camera button */
.cam-big {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  background: var(--accent);
  color: #052e1f;
  border-radius: 16px;
  font-size: 20px;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(16, 185, 129, 0.28);
  transition: transform 0.06s ease, background 0.15s ease;
  user-select: none;
}
.cam-big:active { transform: scale(0.98); background: #34d399; }
.cam-big.loading { opacity: 0.6; pointer-events: none; }
.cam-icon { font-size: 26px; line-height: 1; }

/* optional caption + send */
.caption-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.text {
  flex: 1 1 auto;
  min-width: 0;
  background: #1f2937;
  color: var(--text);
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
}
.text::placeholder { color: #6b7280; }
.text:focus { outline: none; background: #263143; }

.send {
  flex: 0 0 auto;
  background: #1f2937;
  color: var(--accent);
  font-weight: 700;
  border: 1px solid #374151;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 15px;
}
.send:disabled { opacity: 0.45; }
.send:active:not(:disabled) { background: #263143; }
.send.ready { background: var(--accent); color: #052e1f; border-color: var(--accent); }

.mic {
  flex: 0 0 auto;
  width: 46px; height: 46px;
  display: grid; place-items: center;
  font-size: 20px;
  background: #1f2937;
  color: var(--text);
  border: 1px solid #374151;
  border-radius: 12px;
}
.mic:active { background: #263143; }
.mic.listening {
  background: #7f1d1d;
  border-color: var(--danger);
  animation: pulse 1.1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
}

/* pending photo preview bar */
.pending-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #0f2b22;
  border: 1px solid #14532d;
  border-radius: 12px;
  padding: 8px;
}
.pending-thumb {
  width: 48px; height: 48px;
  object-fit: cover;
  border-radius: 8px;
  flex: 0 0 auto;
}
.pending-label {
  flex: 1 1 auto;
  color: #a7f3d0;
  font-size: 14px;
}
.cancel-photo {
  flex: 0 0 auto;
  width: 30px; height: 30px;
  border-radius: 50%;
  background: #1f2937;
  color: #d1d5db;
  border: none;
  font-size: 15px;
  line-height: 1;
}
.cancel-photo:active { background: #374151; }
