/* ============================================================
   DESIGN SYSTEM — Us App
   ============================================================ */

:root {
  --bg: #FAF8F5;
  --primary: #8B4A4A;
  --secondary: #4A6B8B;
  --text: #2C2C2C;
  --muted: #7A7A7A;
  --card: #FFFFFF;
  --border: #E8E2DC;
  --jose-bg: #F2E0DC;
  --jose-text: #8B4A4A;
  --vivian-bg: #DCE4F2;
  --vivian-text: #4A6B8B;
  --ai-bg: #F9F6F2;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.1);
  --radius-card: 16px;
  --radius-btn: 12px;
  --radius-input: 10px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-height: 72px;
  --header-height: 56px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overscroll-behavior: none;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

input, textarea, select, button {
  font-family: inherit;
  font-size: inherit;
}

/* Native-app feel: suppress text selection + the iOS long-press callout
   across the app (so a custom long-press menu can take over), but keep
   selection working inside real text fields. */
.app, .login-screen {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
input, textarea, [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}
/* Remove the 300ms tap delay / double-tap zoom on interactive elements. */
button,
.message-bubble,
.resource-card,
.memory-card,
.milestone-card {
  touch-action: manipulation;
}

/* ============================================================
   LOGIN SCREEN
   ============================================================ */

.login-screen {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}

.login-card {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 40px 32px;
  width: 100%;
  max-width: 360px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.login-logo {
  margin-bottom: 12px;
}

.login-title {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  margin: 0 0 6px;
  letter-spacing: -0.5px;
}

.login-subtitle {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 28px;
}

.login-form {
  text-align: left;
}

.login-error {
  background: #fdf2f2;
  color: #c0392b;
  border: 1px solid #f5c6c6;
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 12px;
}

/* ============================================================
   APP LAYOUT
   ============================================================ */

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  /* Total height = content height + the iOS status-bar inset so the header
     content isn't squished up under the notch in standalone PWA mode. */
  height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
  padding: 0 20px;
  padding-top: env(safe-area-inset-top, 0px);
  background: var(--card);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.app-header-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.logout-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.logout-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.app-main {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.tab-content {
  display: none;
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
}

/* ============================================================
   BOTTOM NAV
   ============================================================ */

.bottom-nav {
  display: flex;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 8px 4px;
  transition: color 0.15s ease;
  font-size: 11px;
  font-weight: 500;
}

.nav-btn.active {
  color: var(--primary);
}

.nav-btn svg {
  transition: transform 0.15s ease;
}

.nav-btn.active svg {
  stroke: var(--primary);
}

/* ============================================================
   FORMS & INPUTS
   ============================================================ */

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="file"],
textarea,
select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  padding: 11px 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s ease;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
  border-color: var(--primary);
  background: var(--card);
}

input[type="file"] {
  padding: 10px 12px;
  cursor: pointer;
  font-size: 13px;
}

textarea {
  resize: vertical;
  min-height: 80px;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237A7A7A' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ============================================================
   BUTTONS
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-btn);
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: #7a3f3f;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-ghost {
  background: none;
  color: var(--muted);
  border: 1.5px solid var(--border);
}

.btn-ghost:hover {
  border-color: var(--text);
  color: var(--text);
}

.btn-full {
  width: 100%;
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================================
   MODALS
   ============================================================ */

/* Respect the [hidden] attribute even when an element sets its own
   display (e.g. .lightbox/.modal use display:flex). Without this,
   author display rules override the UA [hidden] rule and overlays
   stay permanently visible on top of the app. */
[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  opacity: 0;
  animation: fadeIn 0.2s ease forwards;
}

.modal {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--card);
  border-radius: 20px 20px 0 0;
  z-index: 101;
  max-height: 90dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--safe-bottom);
  transform: translateY(100%);
  animation: slideUp 0.3s ease forwards;
}

@keyframes slideUp {
  to { transform: translateY(0); }
}

@keyframes fadeIn {
  to { opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-body {
  padding: 20px 24px 24px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

.modal-actions .btn {
  flex: 1;
}

/* ============================================================
   CHAT TAB
   ============================================================ */

.chat-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
}

.chat-input-area {
  flex-shrink: 0;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
}

.mode-toggle {
  display: flex;
  align-items: center;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 3px;
  margin-bottom: 10px;
  width: fit-content;
}

.mode-toggle-btn {
  background: none;
  border: none;
  border-radius: 16px;
  padding: 5px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all 0.2s ease;
}

.mode-toggle-btn.active {
  background: var(--primary);
  color: white;
}

.together-banner {
  background: #fef9f0;
  border: 1px solid #f0d9a0;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: #7a5a00;
  margin-bottom: 8px;
  text-align: center;
}

.chat-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.chat-input {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  padding: 11px 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  resize: none;
  max-height: 120px;
  min-height: 44px;
  font-size: 15px;
  line-height: 1.5;
  transition: border-color 0.15s ease;
  overflow-y: auto;
}

.chat-input:focus {
  border-color: var(--primary);
  background: var(--card);
}

.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}

.send-btn:hover { background: #7a3f3f; }
.send-btn:active { transform: scale(0.95); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.send-btn svg {
  stroke: white;
}

/* ============================================================
   MESSAGE BUBBLES
   ============================================================ */

.message-group {
  display: flex;
  flex-direction: column;
  margin-bottom: 4px;
}

.message-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 3px;
  padding: 0 4px;
}

.message-jose .message-label { text-align: right; }
.message-vivian .message-label { text-align: left; }
.message-ai .message-label { text-align: center; }
.message-together .message-label { text-align: left; }

.message-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.6;
  word-break: break-word;
  white-space: pre-wrap;
}

.message-jose {
  align-items: flex-end;
}

.message-jose .message-bubble {
  background: var(--jose-bg);
  color: var(--jose-text);
  border-bottom-right-radius: 4px;
}

.message-vivian {
  align-items: flex-start;
}

.message-vivian .message-bubble {
  background: var(--vivian-bg);
  color: var(--vivian-text);
  border-bottom-left-radius: 4px;
}

.message-ai {
  align-items: center;
}

.message-ai .message-bubble {
  background: var(--ai-bg);
  color: var(--text);
  border-left: 3px solid var(--primary);
  border-radius: 12px;
  max-width: 94%;
  font-size: 14px;
}

.message-timestamp {
  font-size: 10px;
  color: var(--muted);
  margin-top: 3px;
  padding: 0 4px;
}

.message-jose .message-timestamp { text-align: right; }
.message-ai .message-timestamp { text-align: center; }

/* Pending together bubble */
.message-pending .message-bubble {
  background: transparent;
  border: 2px dashed var(--border);
  color: var(--muted);
  animation: pulse-border 2s infinite;
}

.pending-label {
  font-size: 11px;
  color: var(--muted);
  font-style: italic;
  margin-top: 3px;
}

@keyframes pulse-border {
  0%, 100% { border-color: var(--border); opacity: 0.8; }
  50% { border-color: var(--primary); opacity: 1; }
}

/* ============================================================
   RESOURCES TAB
   ============================================================ */

.tab-inner {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}

.tab-toolbar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.tab-toolbar-title {
  font-size: 16px;
  font-weight: 600;
}

.resource-card {
  background: var(--card);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.resource-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.resource-icon.pdf { background: #fde8e8; }
.resource-icon.image { background: #e8f0fd; }
.resource-icon.text { background: #e8fde8; }
.resource-icon.default { background: #f0e8fd; }

.resource-info {
  flex: 1;
  min-width: 0;
}

.resource-title {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resource-meta {
  font-size: 12px;
  color: var(--muted);
  margin-top: 2px;
}

.resource-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  flex-shrink: 0;
  transition: color 0.15s ease;
}

.resource-delete:hover { color: #c0392b; }

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  color: var(--muted);
  gap: 8px;
}

.empty-state svg {
  opacity: 0.3;
  margin-bottom: 8px;
}

.empty-state p {
  margin: 0;
  font-size: 14px;
}

/* ============================================================
   MEMORY WALL TAB
   ============================================================ */

.memory-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  padding: 16px;
}

.memory-card {
  background: var(--card);
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.memory-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.memory-card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
}

.memory-card-body {
  padding: 8px 10px 10px;
}

.memory-caption {
  font-size: 13px;
  color: var(--text);
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.memory-meta {
  font-size: 11px;
  color: var(--muted);
}

.fab {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  right: 20px;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(139,74,74,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 50;
}

.fab:hover { background: #7a3f3f; transform: scale(1.06); }
.fab:active { transform: scale(0.96); }

/* Lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox img {
  max-width: 100%;
  max-height: 75dvh;
  object-fit: contain;
  border-radius: 12px;
}

.lightbox-caption {
  color: rgba(255,255,255,0.8);
  font-size: 14px;
  margin-top: 16px;
  text-align: center;
  max-width: 400px;
}

.lightbox-close {
  position: absolute;
  top: 20px;
  right: 20px;
  background: rgba(255,255,255,0.15);
  border: none;
  color: white;
  font-size: 24px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-preview {
  margin-top: 10px;
  border-radius: 10px;
  overflow: hidden;
}

.image-preview img {
  width: 100%;
  max-height: 200px;
  object-fit: cover;
  display: block;
}

/* ============================================================
   HISTORY TAB
   ============================================================ */

.history-toolbar {
  flex-shrink: 0;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
}

.history-search {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  padding: 9px 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-size: 14px;
  margin-bottom: 10px;
}

.history-search:focus { border-color: var(--primary); }

.filter-pills {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 2px;
}

.filter-pill {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.filter-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.history-thread {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   UTILITIES
   ============================================================ */

.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Prevent content from being hidden behind things */
.chat-thread { padding-bottom: 8px; }

/* Smooth tab transitions */
.tab-content {
  transition: opacity 0.15s ease;
}

/* ============================================================
   HEADER ACTIONS (settings + chat icons)
   ============================================================ */

.header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.header-icon-btn:hover { background: var(--bg); color: var(--text); }
.header-icon-btn:active { transform: scale(0.9); }
#settings-btn { color: var(--text); }

/* date input styled like the rest */
input[type="date"] {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  padding: 11px 14px;
  background: var(--bg);
  color: var(--text);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease;
}
input[type="date"]:focus { border-color: var(--primary); background: var(--card); }

/* ============================================================
   TYPING BUBBLES (iMessage style)
   ============================================================ */

.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  border-radius: 18px;
  background: var(--ai-bg);
  width: fit-content;
  border-left: 3px solid var(--primary);
}
.message-jose .typing-bubble { background: var(--jose-bg); border-left: none; }
.message-vivian .typing-bubble { background: var(--vivian-bg); border-left: none; }
.message-jose .typing-group { align-items: flex-end; }
.message-vivian .typing-group { align-items: flex-start; }

.typing-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.5;
  animation: typingBounce 1.3s infinite ease-in-out;
}
.typing-dot:nth-child(2) { animation-delay: 0.18s; }
.typing-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 0.9; }
}

.message-group {
  animation: msgIn 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ============================================================
   REACTIONS
   ============================================================ */

.reaction-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.message-jose .reaction-row { justify-content: flex-end; }
.message-vivian .reaction-row { justify-content: flex-start; }
.message-ai .reaction-row { justify-content: center; }

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 13px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.1s ease, border-color 0.15s ease;
}
.reaction-pill:active { transform: scale(0.9); }
.reaction-pill.mine { border-color: var(--primary); background: var(--bg); }
.reaction-count { font-size: 11px; color: var(--muted); font-weight: 600; }

/* ============================================================
   CONTEXT MENU (long-press)
   ============================================================ */

.context-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.18);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  z-index: 200;
  animation: fadeIn 0.18s ease forwards;
  opacity: 0;
}

.msg-context-menu {
  position: fixed;
  z-index: 201;
  background: var(--card);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  min-width: 200px;
  animation: ctxIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  transform-origin: top left;
}
@keyframes ctxIn {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.reaction-bar {
  display: flex;
  gap: 2px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  justify-content: space-between;
}
.reaction-choice {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  transition: transform 0.12s ease, background 0.12s ease;
}
.reaction-choice:hover { background: var(--bg); transform: scale(1.18); }
.reaction-choice:active { transform: scale(0.95); }

.context-actions { padding: 6px; }
.context-action {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: none;
  border: none;
  padding: 11px 12px;
  font-size: 15px;
  color: var(--text);
  cursor: pointer;
  border-radius: 10px;
  text-align: left;
}
.context-action:hover { background: var(--bg); }
.context-action:active { background: var(--border); }
.context-action.danger { color: #C0392B; }
.context-action svg { flex-shrink: 0; }

/* ============================================================
   IN-CHAT SEARCH (full-screen overlay)
   ============================================================ */

.chat-search-overlay {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 16px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  padding-bottom: calc(12px + var(--safe-bottom));
  animation: searchIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
@keyframes searchIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-search-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.chat-search-back {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.15s ease;
}
.chat-search-back:active { background: var(--border); }
.chat-search-input {
  flex: 1;
  min-width: 0;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-input);
  padding: 10px 14px;
  background: var(--card);
  color: var(--text);
  outline: none;
}
.chat-search-input:focus { border-color: var(--primary); background: var(--card); }
.chat-search-results {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.search-result {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}
.search-result-head {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.search-result-body {
  font-size: 14px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* ============================================================
   MILESTONES (timeline)
   ============================================================ */

.milestones-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  -webkit-overflow-scrolling: touch;
}
.timeline {
  position: relative;
  padding-left: 8px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 13px;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: var(--border);
}
.milestone-card {
  position: relative;
  display: flex;
  gap: 16px;
  padding-bottom: 18px;
}
.milestone-dot {
  position: relative;
  z-index: 1;
  flex-shrink: 0;
  width: 12px;
  height: 12px;
  margin-top: 6px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--bg);
}
.milestone-content {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.milestone-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.milestone-date {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.milestone-delete {
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.milestone-delete:hover { background: var(--bg); color: #C0392B; }
.milestone-title {
  font-size: 16px;
  font-weight: 600;
  margin: 6px 0 0;
  color: var(--text);
}
.milestone-description {
  font-size: 14px;
  color: var(--text);
  margin: 6px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}
.milestone-by {
  display: inline-block;
  margin-top: 8px;
  font-size: 12px;
  color: var(--muted);
}
.empty-state span {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

/* ============================================================
   SETTINGS MODAL
   ============================================================ */

.settings-avatar-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}
.settings-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: var(--primary);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 26px;
  font-weight: 600;
  flex-shrink: 0;
}
.settings-avatar.has-image { color: transparent; }
.settings-avatar-meta { display: flex; flex-direction: column; gap: 6px; }
.settings-name { font-size: 17px; font-weight: 600; }
.avatar-upload-btn {
  display: inline-block;
  font-size: 13px;
  color: var(--primary);
  cursor: pointer;
  font-weight: 500;
}
.accent-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.accent-swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  position: relative;
  transition: transform 0.12s ease;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.4);
}
.accent-swatch:active { transform: scale(0.9); }
.accent-swatch.selected {
  box-shadow: 0 0 0 2px var(--card), 0 0 0 4px currentColor;
}
.accent-swatch.selected::after {
  content: '';
  position: absolute;
  inset: 0;
  margin: auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255,255,255,0.9);
}
.settings-footer {
  border-top: 1px solid var(--border);
  padding: 16px 24px 24px;
  margin-top: 8px;
}
