/* ── Claire v2 — Journal + Conversation ─────────────── */
/* Mobile-first · Single page · No dashboard ············ */

@import url('https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Inter:wght@400;500;600&family=JetBrains+Mono:wght@400&display=swap');

/* ── Tokens ─────────────────────────────────────────── */
:root {
  --bg:        #faf8f4;
  --bg2:       #f2efe8;
  --surface:   #ffffff;
  --ink:       #1a1714;
  --ink2:      #3d362e;
  --ink3:      #6b6055;
  --ink4:      #9a8e80;
  --ink5:      #c4b9aa;
  --accent:    #c67a2e;
  --accent2:   #a85f18;
  --accent-bg: #fef6ed;
  --urgent:    #c0392b;
  --urgent-bg: #fdf0ee;
  --ok:        #27864a;
  --ok-bg:     #eef8f1;
  --info:      #2c6fbb;
  --info-bg:   #edf4fd;
  --border:    #e8e2d8;
  --shadow-sm: 0 1px 3px rgba(26,23,20,.06);
  --shadow-md: 0 4px 12px rgba(26,23,20,.08);
  --shadow-lg: 0 8px 30px rgba(26,23,20,.12);
  --r:         12px;
  --r-lg:      20px;
  --r-pill:    50px;
  --ease:      cubic-bezier(.4, 0, .2, 1);

  /* Privacy badge */
  --shield:    #2c6fbb;
  --shield-bg: #edf4fd;
}

/* ── Reset ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--ink2);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

/* ── Auth screen ────────────────────────────────────── */
#auth-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 20px;
  background: var(--bg);
  overflow-y: auto;
}
.auth-hero {
  text-align: center;
  padding-top: max(48px, 8dvh);
  margin-bottom: 32px;
}
.auth-logo {
  font-family: 'Libre Baskerville', serif;
  font-size: 2.8rem;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: -.02em;
}
.ai {
  color: var(--accent);
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: .02em;
}
.auth-subtitle {
  font-size: .88rem;
  font-weight: 500;
  color: var(--accent2);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-top: 4px;
}
.auth-pitch {
  font-size: .95rem;
  color: var(--ink3);
  margin-top: 16px;
  line-height: 1.55;
  max-width: 320px;
}
.auth-pitch strong { color: var(--ink); }

/* Auth card */
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-md);
}
.auth-card-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 20px;
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.auth-field { display: flex; flex-direction: column; gap: 6px; }
.auth-field-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--ink3);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.auth-input {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  background: var(--bg);
  font-size: 1rem;
  transition: border-color .2s var(--ease), box-shadow .2s;
}
.auth-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.auth-btn {
  width: 100%;
  padding: 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--r);
  font-weight: 600;
  font-size: 1rem;
  transition: all .2s var(--ease);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}
.auth-btn:hover { background: var(--ink2); }
.auth-btn:active { transform: scale(.98); }
.auth-error {
  color: var(--urgent);
  font-size: .85rem;
  text-align: center;
  min-height: 10px;
}

/* Features */
.auth-features {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 32px;
}
.auth-feature {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  transition: box-shadow .2s;
}
.auth-feature:hover { box-shadow: var(--shadow-sm); }
.auth-feature-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent2);
  flex-shrink: 0;
}
.auth-feature-title {
  font-weight: 600;
  font-size: .88rem;
  color: var(--ink);
}
.auth-feature-desc {
  font-size: .78rem;
  color: var(--ink4);
  margin-top: 1px;
}

/* Footer */
.auth-footer {
  margin-top: 28px;
  margin-bottom: 32px;
}
.auth-footer-link {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--shield);
  font-size: .82rem;
  font-weight: 500;
  text-decoration: none;
  transition: opacity .2s;
}
.auth-footer-link:hover { opacity: .7; }

/* ── App container ──────────────────────────────────── */
#app-screen { display: none; min-height: 100dvh; }
#app-screen.active { display: flex; flex-direction: column; }

/* ── Top bar (minimal) ──────────────────────────────── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-name {
  font-family: 'Libre Baskerville', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
}
.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}
.topbar-btn {
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background .2s;
  color: var(--ink3);
}
.topbar-btn:hover { background: var(--bg2); }
.privacy-badge {
  font-size: .7rem;
  font-weight: 600;
  color: var(--shield);
  background: var(--shield-bg);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  display: flex;
  align-items: center;
  gap: 4px;
  letter-spacing: .02em;
}

/* ── Journal ────────────────────────────────────────── */
.journal {
  flex: 1;
  padding: 0 20px 140px;
  max-width: 640px;
  margin: 0 auto;
  width: 100%;
}
.journal-greeting {
  font-family: 'Libre Baskerville', serif;
  font-size: 1.6rem;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.35;
  margin-bottom: 24px;
  padding-top: 8px;
}
.journal-greeting em {
  font-style: italic;
  color: var(--accent2);
}
.journal-section {
  margin-bottom: 28px;
}
.journal-section-title {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink4);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.journal-text {
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink2);
}
.journal-text p { margin-bottom: 12px; }
.journal-text p:last-child { margin-bottom: 0; }

/* ── Action cards (inline in journal) ───────────────── */
.action-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 16px;
  margin: 12px 0;
  transition: box-shadow .2s var(--ease), border-color .2s;
}
.action-card:hover {
  box-shadow: var(--shadow-sm);
}
.action-card.urgent {
  border-left: 3.5px solid var(--urgent);
  background: var(--urgent-bg);
}
.action-card.waiting {
  border-left: 3.5px solid var(--accent);
  background: var(--accent-bg);
}
.action-card.info {
  border-left: 3.5px solid var(--info);
  background: var(--info-bg);
}
.action-card-from {
  font-weight: 600;
  font-size: .9rem;
  color: var(--ink);
  margin-bottom: 2px;
}
.action-card-delay {
  font-size: .78rem;
  color: var(--ink4);
  margin-bottom: 8px;
}
.action-card-summary {
  font-size: .92rem;
  color: var(--ink2);
  line-height: 1.55;
  margin-bottom: 12px;
}
.action-card-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.action-btn {
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-size: .82rem;
  font-weight: 600;
  transition: all .2s var(--ease);
}
.action-btn.primary {
  background: var(--ink);
  color: var(--bg);
}
.action-btn.primary:active { opacity: .85; }
.action-btn.secondary {
  background: var(--bg2);
  color: var(--ink2);
}
.action-btn.secondary:hover { background: var(--border); }
.action-btn.ghost {
  color: var(--ink4);
  padding: 8px 12px;
}
.action-btn.ghost:hover { color: var(--ink2); }

/* Card done state */
.action-card.done {
  opacity: .5;
  transform: scale(.98);
  pointer-events: none;
  transition: all .4s var(--ease);
}

/* ── Quick actions bar ──────────────────────────────── */
.quick-actions {
  display: flex;
  gap: 8px;
  margin: 20px 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.quick-actions::-webkit-scrollbar { display: none; }
.quick-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r-pill);
  font-size: .82rem;
  font-weight: 600;
  color: var(--ink2);
  white-space: nowrap;
  transition: all .2s var(--ease);
  flex-shrink: 0;
}
.quick-btn:hover { border-color: var(--accent); color: var(--accent2); }
.quick-btn:active { transform: scale(.96); }
.quick-icon { font-size: 1rem; }

/* ── Suggestion card ───────────────────────────────── */
.suggestion-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--accent-bg);
  border: 1.5px solid var(--accent);
  border-radius: var(--r);
  margin: 8px 0;
}
.suggestion-icon { font-size: 1.2rem; }
.suggestion-text {
  flex: 1;
  font-size: .9rem;
  color: var(--ink2);
  min-width: 200px;
}
.suggestion-btn {
  padding: 8px 18px;
  background: var(--accent);
  color: white;
  border-radius: var(--r-pill);
  font-size: .82rem;
  font-weight: 600;
  transition: opacity .2s;
}
.suggestion-btn:active { opacity: .8; }

/* ── Streak badge ──────────────────────────────────── */
.streak-badge {
  text-align: center;
  font-size: .8rem;
  font-weight: 600;
  color: var(--accent2);
  padding: 8px 0;
  letter-spacing: .03em;
}

/* ── Weekly teaser ─────────────────────────────────── */
.weekly-teaser {
  text-align: center;
  margin: 20px 0;
}
.weekly-btn {
  padding: 12px 24px;
  background: var(--bg2);
  border: 1.5px solid var(--border);
  color: var(--ink2);
  border-radius: var(--r-pill);
  font-size: .85rem;
  font-weight: 600;
  transition: all .2s;
}
.weekly-btn:hover { border-color: var(--accent); color: var(--accent2); }

/* ── Event rows (calendar) ──────────────────────────── */
.event-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg2);
}
.event-row:last-child { border-bottom: none; }
.event-row.event-past { opacity: .5; }
.event-time {
  font-weight: 600;
  font-size: .88rem;
  color: var(--info);
  min-width: 50px;
  flex-shrink: 0;
}
.event-detail { flex: 1; }
.event-title {
  font-size: .92rem;
  font-weight: 500;
  color: var(--ink);
  display: block;
}
.event-location {
  font-size: .78rem;
  color: var(--ink4);
  display: block;
  margin-top: 2px;
}

/* ── Overdue items ─────────────────────────────────── */
.overdue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  font-size: .9rem;
  color: var(--ink2);
  border-bottom: 1px solid var(--bg2);
}
.overdue-item:last-child { border-bottom: none; }
.overdue-days {
  font-size: .75rem;
  font-weight: 600;
  color: var(--urgent);
  background: var(--urgent-bg);
  padding: 2px 8px;
  border-radius: var(--r-pill);
  flex-shrink: 0;
}

/* ── Unfinished tasks ──────────────────────────────── */
.unfinished-task {
  padding: 12px 0;
  border-bottom: 1px solid var(--bg2);
}
.unfinished-task:last-child { border-bottom: none; }
.unfinished-title {
  font-size: .9rem;
  color: var(--ink2);
  display: block;
  margin-bottom: 8px;
}
.unfinished-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ── Handled items ──────────────────────────────────── */
.handled-list .handled-item {
  color: var(--ink4);
  font-size: .88rem;
  padding: 4px 0;
  text-decoration: line-through;
  text-decoration-color: var(--ink5);
}

/* ── Separator ──────────────────────────────────────── */
.journal-sep {
  border: none;
  height: 1px;
  background: var(--border);
  margin: 28px 0;
}

/* ── Sign-off ───────────────────────────────────────── */
.journal-signoff {
  font-family: 'Libre Baskerville', serif;
  font-style: italic;
  color: var(--ink3);
  font-size: 1rem;
  line-height: 1.5;
  margin-top: 20px;
}

/* ── Skeleton loading ──────────────────────────────── */
.skeleton {
  background: linear-gradient(90deg, var(--bg2,#f2efe8) 25%, var(--border,#e8e2d8) 50%, var(--bg2,#f2efe8) 75%);
  background-size: 200% 100%;
  animation: sk-pulse 1.5s ease-in-out infinite;
  border-radius: 8px;
}
@keyframes sk-pulse { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-line { height: 14px; margin-bottom: 10px; border-radius: 4px; }
.skeleton-line.short { width: 60%; }
.skeleton-line.medium { width: 80%; }
.skeleton-card { height: 72px; margin-bottom: 12px; }

/* ── Loading states ─────────────────────────────────── */
.journal-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--ink4);
  gap: 16px;
}
.journal-loading-text {
  font-family: 'Libre Baskerville', serif;
  font-style: italic;
  font-size: 1rem;
}
@keyframes dot-pulse {
  0%, 80%, 100% { opacity: .3; }
  40% { opacity: 1; }
}
.loading-dots span {
  animation: dot-pulse 1.4s infinite both;
  font-size: 1.4rem;
  color: var(--accent);
}
.loading-dots span:nth-child(2) { animation-delay: .2s; }
.loading-dots span:nth-child(3) { animation-delay: .4s; }

/* ── Chat bar (bottom, always visible) ──────────────── */
.chat-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 200;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  box-shadow: 0 -2px 10px rgba(26,23,20,.06);
}
.chat-input-wrap {
  flex: 1;
  position: relative;
}
.chat-input {
  width: 100%;
  padding: 12px 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-pill);
  background: var(--bg);
  font-size: .95rem;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color .2s;
}
.chat-input:focus {
  outline: none;
  border-color: var(--accent);
}
.chat-input::placeholder { color: var(--ink5); }
.chat-send {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .2s;
}
.chat-send:active { background: var(--ink2); }
.chat-send:disabled { background: var(--ink5); }
.chat-voice {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--bg2);
  color: var(--ink3);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .2s;
}
.chat-voice:active { transform: scale(1.15); }
.chat-voice.recording {
  background: var(--urgent);
  color: white;
  transform: scale(1.2);
  animation: pulse-rec 1s infinite;
}
@keyframes pulse-rec {
  0%, 100% { box-shadow: 0 0 0 0 rgba(192,57,43,.4); }
  50% { box-shadow: 0 0 0 12px rgba(192,57,43,0); }
}
/* Voice pending indicator */
.voice-pending {
  background: var(--bg2) !important;
  color: var(--ink4) !important;
  border-bottom-right-radius: 18px !important;
}

/* ── Chat backdrop (tap to close) ──────────── */
.chat-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.25);
  z-index: 198;
  -webkit-tap-highlight-color: transparent;
}
.chat-backdrop.open { display: block; }

/* ── Chat drag handle (swipe down to close) ──────────── */
.chat-drag-handle {
  display: flex;
  justify-content: center;
  padding: 6px 0 2px;
  cursor: grab;
  flex-shrink: 0;
}
.chat-drag-handle span {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
}

/* ── Chat conversation (expands above bar) ──────────── */
.chat-conversation {
  position: fixed;
  bottom: 72px;
  left: 0;
  right: 0;
  max-height: 60dvh;
  overflow-y: auto;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 16px;
  z-index: 199;
  display: none;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 -4px 20px rgba(26,23,20,.1);
}
.chat-conversation.open { display: flex; }
.chat-close-btn {
  position: sticky;
  top: 0;
  align-self: flex-end;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text);
  z-index: 10;
  flex-shrink: 0;
  transition: background 0.15s;
  box-shadow: 0 2px 8px rgba(0,0,0,.12);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.chat-close-btn:hover, .chat-close-btn:active { background: var(--border); color: var(--text); }

.chat-msg {
  max-width: 85%;
  padding: 10px 16px;
  border-radius: 18px;
  font-size: .92rem;
  line-height: 1.5;
  animation: msg-in .3s var(--ease);
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-msg.user {
  align-self: flex-end;
  background: var(--ink);
  color: var(--bg);
  border-bottom-right-radius: 6px;
}
.chat-msg.claire {
  align-self: flex-start;
  background: var(--bg2);
  color: var(--ink2);
  border-bottom-left-radius: 6px;
}
/* ── Chat action bubbles ────────────────────────────── */
.chat-action-bubble {
  margin-top: 10px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: .85rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  animation: msg-in .3s var(--ease);
}
.chat-action-bubble.draft { border-left: 3px solid var(--accent); }
.chat-action-bubble.event { border-left: 3px solid var(--info); }
.chat-action-bubble.task { border-left: 3px solid var(--ok); }
.chat-action-bubble.archive { border-left: 3px solid var(--ink4); }
.cab-icon { font-size: 1.1rem; }
.cab-label { font-weight: 600; color: var(--ink); }
.cab-detail { font-size: .8rem; color: var(--ink4); width: 100%; }
.cab-buttons {
  width: 100%;
  display: flex;
  gap: 8px;
  margin-top: 6px;
}
.cab-btn {
  padding: 6px 14px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--r-pill);
  font-size: .78rem;
  font-weight: 600;
  transition: opacity .2s;
}
.cab-btn:active { opacity: .8; }

/* Chat msg rich content */
.chat-msg code {
  background: rgba(0,0,0,.06);
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'JetBrains Mono', monospace;
  font-size: .85em;
}
.chat-msg ul {
  padding-left: 18px;
  margin: 6px 0;
}
.chat-msg li {
  margin-bottom: 3px;
}
.chat-typing {
  align-self: flex-start;
  padding: 10px 18px;
  background: var(--bg2);
  border-radius: 18px;
  display: none;
}
.chat-typing.visible { display: block; }
.chat-typing .loading-dots span { font-size: 1rem; }

/* ── Privacy modal ──────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(26,23,20,.5);
  z-index: 500;
  display: none;
  align-items: flex-end;
  justify-content: center;
  cursor: pointer; /* iOS needs this for click events on non-interactive elements */
  -webkit-tap-highlight-color: transparent;
}
.modal-overlay.open { display: flex; }
.modal-sheet { cursor: default; } /* prevent close when tapping inside sheet */
.modal-sheet {
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  width: 100%;
  max-width: 640px;
  max-height: 85dvh;
  overflow-y: auto;
  padding: 24px 20px 40px;
  animation: sheet-up .3s var(--ease);
}
@keyframes sheet-up {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  margin-bottom: 16px;
}
.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--ink5);
  border-radius: 2px;
}
.modal-x {
  position: absolute;
  right: -4px;
  top: -8px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: var(--ink4);
  border-radius: 50%;
  transition: background .2s;
}
.modal-x:hover { background: var(--bg2); }
.modal-title {
  font-family: 'Libre Baskerville', serif;
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 16px;
}
.modal-text {
  font-size: .92rem;
  line-height: 1.7;
  color: var(--ink2);
}
.modal-text h3 {
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  margin: 20px 0 8px;
}
.modal-text p { margin-bottom: 12px; }
.modal-text ul { padding-left: 20px; margin-bottom: 12px; }
.modal-text li { margin-bottom: 6px; }
.modal-close {
  display: block;
  margin: 24px auto 0;
  padding: 12px 32px;
  background: var(--ink);
  color: var(--bg);
  border-radius: var(--r-pill);
  font-weight: 600;
}

/* ── AI Transparency logs ───────────────────────────── */
.ai-logs-stats {
  display: flex;
  gap: 12px;
  margin: 16px 0;
  flex-wrap: wrap;
}
.ai-stat {
  flex: 1;
  min-width: 100px;
  background: var(--bg2);
  border-radius: var(--r);
  padding: 14px;
  text-align: center;
}
.ai-stat-num {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--ink);
  font-family: 'Libre Baskerville', serif;
}
.ai-stat-label {
  font-size: .72rem;
  color: var(--ink4);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-top: 2px;
}
.ai-logs-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 16px 0;
  max-height: 50dvh;
  overflow-y: auto;
}
.ai-log-item {
  padding: 12px;
  background: var(--bg2);
  border-radius: var(--r);
  font-size: .85rem;
}
.ai-log-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}
.ai-log-purpose {
  font-weight: 600;
  color: var(--ink);
  font-size: .82rem;
}
.ai-log-time {
  font-size: .75rem;
  color: var(--ink4);
}
.ai-log-model {
  font-size: .75rem;
  color: var(--ink4);
  margin-bottom: 6px;
}
.ai-log-preview {
  font-size: .78rem;
  color: var(--ink3);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 80px;
  overflow: hidden;
  cursor: pointer;
  transition: max-height .3s var(--ease);
}
.ai-log-preview.expanded {
  max-height: none;
}
.ai-log-expand {
  font-size: .72rem;
  color: var(--accent);
  font-weight: 600;
  margin-top: 4px;
  cursor: pointer;
}

/* ── Toast ──────────────────────────────────────────── */
.toast {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-80px);
  background: var(--ink);
  color: var(--bg);
  padding: 12px 24px;
  border-radius: var(--r-pill);
  font-size: .88rem;
  font-weight: 500;
  z-index: 999;
  transition: transform .3s var(--ease);
  white-space: nowrap;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
}

/* ── Account page ───────────────────────────────────── */
.acct-section {
  margin-bottom: 20px;
}
.acct-label {
  display: block;
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--ink4);
  margin-bottom: 8px;
}
.acct-tone-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tone-chip {
  padding: 8px 16px;
  border-radius: var(--r-pill);
  font-size: .85rem;
  font-weight: 500;
  background: var(--bg2);
  color: var(--ink2);
  border: 1.5px solid transparent;
  transition: all .2s var(--ease);
}
.tone-chip.active {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.tone-chip:hover:not(.active) {
  border-color: var(--ink4);
}
.acct-tz {
  font-size: .92rem;
  color: var(--ink2);
  padding: 10px 0;
}
.acct-save-btn {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: white;
  border-radius: var(--r);
  font-weight: 600;
  font-size: 1rem;
  transition: opacity .2s;
  margin-top: 8px;
}
.acct-save-btn:active { opacity: .85; }
.acct-logout-btn {
  width: 100%;
  padding: 14px;
  background: var(--bg2);
  color: var(--ink3);
  border-radius: var(--r);
  font-weight: 600;
  font-size: .95rem;
  transition: all .2s;
}
.acct-logout-btn:hover { background: var(--border); color: var(--ink); }
.acct-mail-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.acct-mail-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--bg2);
  border-radius: var(--r);
}
.acct-mail-info {
  display: flex;
  flex-direction: column;
}
.acct-mail-label {
  font-weight: 600;
  font-size: .9rem;
  color: var(--ink);
}
.acct-mail-email {
  font-size: .8rem;
  color: var(--ink4);
}
.acct-mail-remove {
  color: var(--urgent);
  font-size: .8rem;
  font-weight: 600;
  padding: 6px 12px;
}

/* ── Connectors grid ────────────────────────────────── */
.connectors-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.connector-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--bg2);
  border-radius: var(--r);
  transition: background .2s;
}
.connector-item:hover { background: var(--border); }
.connector-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.connector-icon.google { background: #edf4fd; }
.connector-icon.apple { background: #f2f2f2; }
.connector-icon.notion { background: #f5f5f5; }
.connector-icon.slack { background: #f0e8f8; }
.connector-icon.whatsapp { background: #e8f5e9; }
.connector-icon.telegram { background: #e3f2fd; }
.connector-icon.todoist { background: #fce4ec; }
.connector-icon.trello { background: #e3f2fd; }
.connector-icon.drive { background: #fff8e1; }
.connector-icon.dropbox { background: #e3f2fd; }
.connector-icon.stripe { background: #ede7f6; }
.connector-icon.qonto { background: #f5f5f5; }
.connector-icon.pennylane { background: #e8f5e9; }
.connector-icon.calendly { background: #e3f2fd; }
.connector-icon.ical { background: #fff3e0; }
.connector-info {
  flex: 1;
  min-width: 0;
}
.connector-name {
  font-weight: 600;
  font-size: .88rem;
  color: var(--ink);
}
.connector-desc {
  font-size: .75rem;
  color: var(--ink4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.connector-status {
  flex-shrink: 0;
  font-size: .75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--r-pill);
}
.connector-status.connected {
  background: var(--ok-bg);
  color: var(--ok);
}
.connector-status.available {
  background: var(--ink);
  color: var(--bg);
  cursor: pointer;
}
.connector-status.soon {
  background: var(--bg);
  color: var(--ink5);
  border: 1px solid var(--border);
}
.connector-status.disconnect {
  background: none;
  color: var(--urgent);
  cursor: pointer;
  font-size: .72rem;
}

/* ── Onboarding interview ───────────────────────────── */
.onboarding-exchange {
  margin-bottom: 24px;
}
.onboarding-claire {
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--ink2);
  padding: 16px 18px;
  background: var(--bg2);
  border-radius: 18px 18px 18px 4px;
  margin-bottom: 10px;
  max-width: 90%;
}
.onboarding-user {
  font-size: 1rem;
  line-height: 1.55;
  color: var(--bg);
  background: var(--ink);
  padding: 12px 18px;
  border-radius: 18px 18px 4px 18px;
  margin-left: auto;
  max-width: 80%;
  width: fit-content;
  text-align: right;
}
.onboarding-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 20px;
}
.onboarding-progress {
  font-size: .78rem;
  color: var(--ink5);
  letter-spacing: .04em;
}
.onboarding-skip {
  font-size: .82rem;
  color: var(--ink4);
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--r-pill);
  transition: color .2s;
}
.onboarding-skip:hover { color: var(--ink2); }
.onboarding-current {
  animation: msg-in .4s var(--ease);
}

/* ── Mail help block ────────────────────────────────── */
.mail-help {
  margin-top: 14px;
  padding: 18px 18px;
  background: var(--urgent-bg);
  border: 2px solid var(--urgent);
  border-radius: var(--r);
  font-size: .9rem;
  line-height: 1.7;
  color: var(--ink);
  animation: msg-in .3s var(--ease);
}
.mail-help strong { color: var(--urgent); }
.mail-help a { color: var(--accent2); text-decoration: underline; font-weight: 600; }

/* ── Setup cards (onboarding connect) ───────────────── */
.setup-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 16px 0;
}
.setup-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 12px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  transition: all .2s var(--ease);
  cursor: pointer;
}
.setup-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}
.setup-card.active {
  border-color: var(--accent);
  background: var(--accent-bg);
}
.setup-card-icon { font-size: 1.6rem; }
.setup-card-name {
  font-weight: 600;
  font-size: .88rem;
  color: var(--ink);
}
.setup-card-desc {
  font-size: .72rem;
  color: var(--ink4);
}
.setup-form {
  margin: 16px 0;
  animation: msg-in .3s var(--ease);
}
.setup-form .auth-input {
  margin-bottom: 0;
}

/* ── Utilities ──────────────────────────────────────── */
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ── Responsive: desktop boost ──────────────────────── */
@media (min-width: 640px) {
  .journal { padding: 0 32px 140px; }
  .topbar { padding: 20px 32px 16px; }
  .journal-greeting { font-size: 1.8rem; }
  .chat-bar { padding: 16px 32px; }
  .chat-conversation { bottom: 80px; border-radius: var(--r-lg) var(--r-lg) 0 0; }
  .modal-overlay { align-items: center; }
  .modal-sheet { border-radius: var(--r-lg); max-height: 80dvh; }
}

/* ── Dark theme ──────────────────────────────────────── */
[data-theme="dark"] {
  --bg:        #1a1612;
  --bg2:       #221e19;
  --surface:   #2d2822;
  --ink:       #e8dfd4;
  --ink2:      #c9bfb2;
  --ink3:      #9a8e80;
  --ink4:      #7a6f62;
  --ink5:      #4a4139;
  --accent:    #d4a853;
  --accent2:   #e0b860;
  --accent-bg: #2d2518;
  --urgent:    #e05050;
  --urgent-bg: #2d1f1f;
  --ok:        #3aad5c;
  --ok-bg:     #1f2d22;
  --info:      #5a9fd4;
  --info-bg:   #1c2530;
  --border:    #3a342c;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.2);
  --shadow-md: 0 4px 12px rgba(0,0,0,.3);
  --shadow-lg: 0 8px 30px rgba(0,0,0,.4);

  --shield:    #5a9fd4;
  --shield-bg: #1c2530;
}
[data-theme="dark"] body { background: var(--bg, #1a1612); }
[data-theme="dark"] input, [data-theme="dark"] textarea, [data-theme="dark"] select {
  background: var(--surface, #2d2822); color: var(--text, #e8dfd4); border-color: var(--border, #3a342c);
}

/* ── Theme toggle button ─────────────────────────────── */
.theme-toggle {
  position: fixed; bottom: 16px; left: 16px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 1px solid var(--border, #e0d5c8); background: var(--surface, #fff);
  cursor: pointer; font-size: 18px; z-index: 100; transition: background 0.2s;
}
.theme-toggle:hover { opacity: 0.8; }

/* ── Connection status bar ───────────────────────────── */
.conn-status { position: fixed; top: 0; left: 0; right: 0; text-align: center; padding: 6px; font-size: .75rem; font-weight: 600; z-index: 350; transition: transform 0.3s; }
.conn-offline { background: #e05050; color: #fff; transform: translateY(0); }
.conn-online { transform: translateY(-100%); display: none; }
