:root {
  --color-bg: #f5f6f8;
  --color-surface: #ffffff;
  --color-text: #1c1e21;
  --color-muted: #6b7280;
  --color-primary: #1f6f50;
  --color-primary-contrast: #ffffff;
  --color-border: #e2e4e8;
  --color-danger: #b3261e;
  --color-warning: #8a5a00;
  --color-warning-bg: #fff6e0;
  --radius: 14px;
  --nav-height: 64px;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
}

body {
  padding-bottom: calc(var(--nav-height) + 16px);
}

a {
  color: var(--color-primary);
  text-decoration: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.app-header h1 {
  font-size: 1.1rem;
  margin: 0;
}

.app-header .logout-form button {
  background: none;
  border: none;
  color: var(--color-muted);
  font-size: 0.95rem;
  padding: 8px;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--nav-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  z-index: 10;
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--color-muted);
  font-size: 0.8rem;
  font-weight: 500;
}

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

.bottom-nav .icon {
  font-size: 1.3rem;
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
}

.card-link {
  display: block;
  color: inherit;
}

.card-title {
  font-weight: 600;
  font-size: 1.05rem;
  margin-bottom: 4px;
}

.card-meta {
  color: var(--color-muted);
  font-size: 0.9rem;
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
}

.badge-ACTIVE { background: #e3f4ea; color: #1f6f50; }
.badge-INACTIVE { background: #eee; color: var(--color-muted); }
.badge-ARCHIVED { background: #f1e6e6; color: var(--color-danger); }

.badge-SAVED { background: #eee; color: var(--color-muted); }
.badge-SHORTLISTED { background: #e3f4ea; color: #1f6f50; }
.badge-VIEWING_PLANNED { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-REJECTED { background: #f1e6e6; color: var(--color-danger); }

.badge-SCHEDULED { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-CANCELLED { background: #f1e6e6; color: var(--color-danger); }
.badge-COMPLETED { background: #e3f4ea; color: #1f6f50; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border-radius: var(--radius);
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  margin-bottom: 10px;
}

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

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-danger {
  background: var(--color-surface);
  color: var(--color-danger);
  border: 1px solid var(--color-danger);
}

.btn-inline {
  width: auto;
  min-height: 40px;
  padding: 0 16px;
}

.search-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

input[type=text], input[type=search], input[type=email], input[type=tel], input[type=password], select, textarea {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  font-size: 1rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: var(--color-surface);
  color: var(--color-text);
}

label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  margin: 14px 0 6px;
}

.filter-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 14px;
}

.filter-pill {
  flex: none;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  color: var(--color-muted);
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}

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

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  gap: 12px;
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: var(--color-muted);
  font-size: 0.9rem;
}

.detail-value {
  font-weight: 500;
  text-align: right;
}

.warning-box {
  background: var(--color-warning-bg);
  color: var(--color-warning);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
  font-size: 0.92rem;
}

.empty-state {
  text-align: center;
  color: var(--color-muted);
  padding: 40px 16px;
}

.messages {
  list-style: none;
  padding: 0;
  margin: 0 0 14px;
}

.messages li {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  font-size: 0.92rem;
}

.form-actions {
  margin-top: 20px;
}

.chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.chat-row {
  display: flex;
}

.chat-row-user {
  justify-content: flex-end;
}

.chat-row-assistant {
  justify-content: flex-start;
}

.chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  white-space: pre-wrap;
  overflow-wrap: break-word;
}

.chat-bubble-user {
  background: var(--color-primary);
  color: var(--color-primary-contrast);
  border-bottom-right-radius: 4px;
}

.chat-bubble-assistant {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 4px;
}

/* Chat UX (Phase 5 refactor): a message bubble appended by JS fades/slides
   in instead of just popping into place. Understated on purpose - short
   duration, small distance. Respects prefers-reduced-motion below. */
.chat-bubble-enter {
  animation: chat-bubble-in 0.18s ease-out;
}

@keyframes chat-bubble-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Thinking indicator: three subtle bouncing dots, shown while a message is
   being processed and removed once the response arrives. */
.chat-thinking {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 14px;
}

.chat-thinking .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  animation: chat-thinking-bounce 1.1s ease-in-out infinite;
}

.chat-thinking .dot:nth-child(2) {
  animation-delay: 0.15s;
}

.chat-thinking .dot:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes chat-thinking-bounce {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 0.9;
    transform: translateY(-3px);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-bubble-enter {
    animation: none;
  }

  .chat-thinking .dot {
    animation: none;
    opacity: 0.6;
  }
}

/* Structured property-search presentation (post-Phase-6 correction): styled
   via CSS instead of visible Markdown (**bold**, * bullets, [label](url)) -
   see assistant/services/rendering.py and
   templates/assistant/_property_search_results.html. */
.chat-property-results {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.chat-property-search-link {
  font-weight: 600;
}

.chat-property-item {
  padding-top: 8px;
  border-top: 1px solid var(--color-border);
}

.chat-property-item:first-of-type {
  padding-top: 0;
  border-top: none;
}

.chat-property-title {
  font-weight: 600;
  margin-bottom: 2px;
}

.chat-property-label {
  font-weight: 600;
}

.chat-bubble a {
  color: inherit;
  text-decoration: underline;
}

/* Voice input (Phase 7A): mic button + recording/transcribing/error status
   row. Progressive enhancement - static/js/assistant_chat.js only unhides
   .mic-btn when MediaRecorder/getUserMedia are actually supported. */
.mic-btn {
  min-width: 48px;
  min-height: 48px;
  flex: 0 0 auto;
  font-size: 1.2rem;
  line-height: 1;
}

.mic-btn-recording {
  background: var(--color-danger);
  color: #fff;
  border-color: var(--color-danger);
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(211, 47, 47, 0.4);
  }
  50% {
    box-shadow: 0 0 0 8px rgba(211, 47, 47, 0);
  }
}

.voice-status {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 0.9rem;
}

.voice-recording-indicator {
  color: var(--color-danger);
  font-weight: 600;
}

.voice-transcribing {
  color: var(--color-muted);
  font-style: italic;
}

.voice-error {
  color: var(--color-danger);
}

.voice-control-btn {
  min-height: 36px;
  padding: 4px 12px;
  font-size: 0.85rem;
}

@media (prefers-reduced-motion: reduce) {
  .mic-btn-recording {
    animation: none;
  }
}

/* Voice output / "Voice replies" (Phase 7B). */
.voice-replies-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--color-muted);
  margin-bottom: 8px;
}

.speaker-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 36px;
  margin-top: 6px;
  margin-left: 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 1rem;
  color: inherit;
  opacity: 0.7;
}

.speaker-btn:hover {
  opacity: 1;
}

.speaker-btn-loading {
  opacity: 0.4;
  cursor: wait;
}

.speaker-btn-playing {
  opacity: 1;
  color: var(--color-primary);
  animation: mic-pulse 1.2s ease-in-out infinite;
}

.speaker-btn-error {
  color: var(--color-danger);
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  .speaker-btn-playing {
    animation: none;
  }
}

@media (min-width: 720px) {
  .bottom-nav {
    max-width: 640px;
    left: 50%;
    transform: translateX(-50%);
    border-radius: var(--radius) var(--radius) 0 0;
    border: 1px solid var(--color-border);
    border-bottom: none;
  }
}
