:root {
  --bg: #f5f5f4;
  --surface: #ffffff;
  --border: #e2e2df;
  --text: #1c1c1a;
  --text-muted: #6b6b66;
  --accent: #2f6f4f;
  --accent-contrast: #ffffff;
  --bubble-user: #2f6f4f;
  --bubble-user-text: #ffffff;
  --bubble-assistant: #eeeeec;
  --bubble-assistant-text: #1c1c1a;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17181a;
    --surface: #1f2023;
    --border: #2e2f33;
    --text: #f0f0ee;
    --text-muted: #9a9a96;
    --accent: #4caf7d;
    --accent-contrast: #0b1210;
    --bubble-user: #4caf7d;
    --bubble-user-text: #0b1210;
    --bubble-assistant: #2a2b2f;
    --bubble-assistant-text: #f0f0ee;
  }
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.layout {
  max-width: 960px;
  margin: 0 auto;
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  padding: 1.25rem 1rem 0.5rem;
}

.topbar h1 {
  font-size: 1.25rem;
  margin: 0;
}

.topbar-time {
  margin-left: auto;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.badge {
  font-size: 0.7rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.1rem 0.5rem;
}

.content {
  flex: 1;
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 1rem;
  padding: 0.5rem 1rem 1rem;
  min-height: 0;
}

.sidebar {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  overflow-y: auto;
}

/* Calendar */
.cal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
}

.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.cal-title {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

.cal-nav {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text);
  font-size: 1.2rem;
  line-height: 1;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
}

.cal-nav:hover {
  background: var(--border);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  text-align: center;
}

.cal-dow {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0.25rem 0;
}

.cal-day {
  font-size: 0.8rem;
  padding: 0.3rem 0;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text);
  background: none;
  border: none;
  font-family: inherit;
}

.cal-day:hover:not(.today) {
  background: var(--border);
}

.cal-day.today {
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
}

.cal-day.selected:not(.today) {
  box-shadow: inset 0 0 0 1.5px var(--accent);
  font-weight: 600;
}

.cal-day.other-month {
  color: var(--text-muted);
  /* Nothing to click on a day outside the month; don't imply otherwise. */
  cursor: default;
}

.chat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.message {
  max-width: 80%;
  padding: 0.55rem 0.8rem;
  border-radius: 10px;
  line-height: 1.4;
  font-size: 0.92rem;
  white-space: pre-wrap;
}

.message.user {
  align-self: flex-end;
  background: var(--bubble-user);
  color: var(--bubble-user-text);
}

.message.assistant {
  align-self: flex-start;
  background: var(--bubble-assistant);
  color: var(--bubble-assistant-text);
}

/* Suggested prompts */
.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 0.75rem 0.25rem;
}

.chip {
  font-family: inherit;
  font-size: 0.78rem;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}

.chip:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--accent);
}

.chip:disabled {
  opacity: 0.5;
  cursor: default;
}

/* "Thinking" bubble. A Cohere round trip plus calendar reads is 1-3 seconds,
   during which the UI used to look frozen. */
.message.thinking {
  display: flex;
  gap: 0.25rem;
  align-items: center;
  padding: 0.7rem 0.8rem;
}

.message.thinking span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.2s infinite ease-in-out both;
}

.message.thinking span:nth-child(2) { animation-delay: 0.18s; }
.message.thinking span:nth-child(3) { animation-delay: 0.36s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* Someone who has asked not to see motion still needs to know it's working. */
@media (prefers-reduced-motion: reduce) {
  .message.thinking span {
    animation: none;
    opacity: 0.6;
  }
}

.chat-input {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--border);
}

.chat-input input {
  flex: 1;
  padding: 0.6rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 0.95rem;
}

.chat-input input:disabled {
  opacity: 0.6;
}

.chat-input button {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: var(--accent-contrast);
  font-weight: 600;
  cursor: pointer;
}

.chat-input button:disabled {
  opacity: 0.6;
  cursor: default;
}

.preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem;
  overflow-y: auto;
}

.preview h2 {
  font-size: 0.95rem;
  margin: 0 0 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.preview-day {
  margin-bottom: 1rem;
}

.preview-day h3 {
  font-size: 0.85rem;
  margin: 0 0 0.4rem;
}

.preview-event {
  font-size: 0.82rem;
  color: var(--text-muted);
  padding: 0.25rem 0;
  border-top: 1px solid var(--border);
}

.preview-event:first-of-type {
  border-top: none;
}

.preview-event .time {
  color: var(--text);
  font-weight: 600;
  margin-right: 0.4rem;
}

/* Already over. Keeps the eye on what's left of the day. */
.preview-event.past {
  opacity: 0.45;
}

.preview-event.past .time {
  font-weight: 400;
}

.preview-now {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  color: var(--accent);
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0.25rem 0;
}

.preview-now::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--accent);
  opacity: 0.5;
}

.preview-event a {
  color: inherit;
  text-decoration: none;
}

.preview-event a:hover {
  text-decoration: underline;
}

.loading {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.retry-btn {
  font-family: inherit;
  font-size: 0.8rem;
  margin-top: 0.5rem;
  padding: 0.3rem 0.7rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
}

.retry-btn:hover {
  border-color: var(--accent);
}

/* First paint, before /api/auth/status decides which panel to show. */
.boot {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 2rem 1rem;
}

.boot-spinner {
  width: 1.5rem;
  height: 1.5rem;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .boot-spinner {
    animation-duration: 2.4s;
  }
}

.hidden {
  display: none !important;
}

.welcome {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.welcome-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2rem;
  max-width: 360px;
  text-align: center;
}

.welcome-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
}

.welcome-card p {
  margin: 0 0 1.25rem;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.google-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.6rem 1.1rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  cursor: pointer;
}

.google-btn:hover {
  background: var(--border);
}

.welcome-note {
  margin: 1rem 0 0 !important;
  font-size: 0.78rem !important;
}

/* ---------------------------------------------------------------------------
   Narrow screens.

   This block has to stay at the end of the file. A media query adds no
   specificity, so `.chat { height: 100% }` above beat the responsive height
   when this sat near the top -- the chat panel collapsed to its content on a
   phone regardless of what was set here.
   --------------------------------------------------------------------------- */
@media (max-width: 720px) {
  html, body {
    height: auto;
  }

  .layout {
    height: auto;
    min-height: 100vh;
  }

  .content {
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
  }

  .chat {
    /* The chat is the product. Single-column put the sidebar first, so a phone
       user landed on a month grid and had to scroll past it to reach the input. */
    order: -1;
    height: 70vh;
  }

  /* "Fri, Aug 7, 12:41 AM EDT" alongside the title and badge wrapped the header
     onto three lines at 390px. */
  .topbar {
    flex-wrap: wrap;
    row-gap: 0.25rem;
  }

  .topbar-time {
    font-size: 0.8rem;
  }
}

/* Coming-soon holding page */
.soon-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0 0 0.5rem !important;
  font-size: 0.78rem !important;
  font-weight: 600;
  color: var(--accent) !important;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.soon-dot {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--accent);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@media (prefers-reduced-motion: reduce) {
  .soon-dot { animation: none; }
}

/* A button, not an <a>: it reveals the sign-in card rather than navigating. */
.linklike {
  font-family: inherit;
  font-size: inherit;
  color: var(--text-muted);
  background: none;
  border: none;
  padding: 0;
  text-decoration: underline;
  cursor: pointer;
}

.linklike:hover {
  color: var(--text);
}
