:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #1d1b16;
  --muted: #6f6a5f;
  --line: #e7e3da;
  --accent: #1f6f5c;
  --accent-ink: #ffffff;
  --user-bubble: #ece8de;
  --danger: #a33a2a;
  --radius: 16px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute must win over any class that sets `display`. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
}

.thread {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Items keep their full height; a long chat scrolls instead of squeezing its cards. */
.thread > * {
  flex-shrink: 0;
}

.welcome {
  margin: auto 0;
  text-align: center;
}

.welcome h2 {
  margin: 0 0 6px;
  font-size: 24px;
  letter-spacing: -0.02em;
}

.welcome p {
  margin: 0 0 20px;
  color: var(--muted);
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.chip {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}

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

.chip.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.message {
  max-width: 88%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user {
  align-self: flex-end;
  background: var(--user-bubble);
  padding: 10px 14px;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
}

.message.assistant {
  align-self: flex-start;
}

.message.error {
  align-self: flex-start;
  color: var(--danger);
}

.message a {
  color: var(--accent);
}

.status {
  align-self: flex-start;
  color: var(--muted);
  font-size: 14px;
  animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
  50% {
    opacity: 0.45;
  }
}

.cards {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 4px;
  scroll-snap-type: x mandatory;
}

.card {
  flex: 0 0 260px;
  scroll-snap-align: start;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.card.wide {
  flex-basis: auto;
  align-self: stretch;
}

.card h3 {
  margin: 0;
  font-size: 16px;
}

.card .meta,
.card .address {
  color: var(--muted);
  font-size: 14px;
}

.card .open {
  color: var(--accent);
}

.card .closed {
  color: var(--danger);
}

.card ol,
.card .recipients {
  margin: 4px 0;
  padding-left: 20px;
  font-size: 15px;
}

.card .label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.sources {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.sources .chip {
  text-decoration: none;
  font-size: 13px;
  padding: 5px 10px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 6px;
}

.actions a,
.actions button.primary {
  flex: 1;
  text-align: center;
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
}

.card .phone {
  font-size: 14px;
  color: var(--accent);
  text-decoration: none;
}

.actions button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 16px;
  padding: 8px 8px 8px 16px;
  margin-bottom: max(16px, env(safe-area-inset-bottom));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
}

.composer textarea {
  flex: 1;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font: inherit;
  color: inherit;
  max-height: 140px;
  padding: 6px 0;
}

.composer button {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 18px;
  cursor: pointer;
}

.composer button:disabled {
  opacity: 0.4;
  cursor: default;
}

.composer button.mic {
  display: grid;
  place-items: center;
  background: transparent;
  color: inherit;
  border: 1px solid var(--line);
}

.composer button.mic.recording {
  background: #c62828;
  border-color: #c62828;
  color: #fff;
}

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rows li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.rows li:last-child {
  border-bottom: 0;
}

.primary-button {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: var(--accent);
  color: var(--accent-ink);
  font: inherit;
  cursor: pointer;
}

.card .details {
  margin: 0;
  padding: 10px;
  background: var(--bg);
  border-radius: 10px;
  font-size: 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.status-note {
  align-self: center;
  color: var(--muted);
  font-size: 14px;
}

.login {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100dvh;
  padding: 16px;
}

.login-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.login-card h1 {
  margin: 0;
  font-size: 22px;
}

.login-card input {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}

.contact-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 0;
}

.contact-form input {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  min-width: 0;
}

.contact-form button {
  grid-column: 1 / -1;
}

.link-button {
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 4px;
}

.login-card .meta {
  margin: 0;
  font-size: 13px;
}

/* ---------- Layout: sidebar + content ---------- */

.shell {
  display: flex;
  height: 100dvh;
}

.sidebar {
  flex: 0 0 240px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow-y: auto;
}

.brand {
  font-size: 18px;
  font-weight: 650;
  padding: 0 8px;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-item {
  text-align: left;
  border: 0;
  background: none;
  border-radius: 10px;
  padding: 9px 12px;
  font: inherit;
  color: var(--ink);
  cursor: pointer;
}

.nav-item:hover {
  background: var(--bg);
}

.nav-item.active {
  background: var(--user-bubble);
  font-weight: 600;
}

.recent {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 4px;
}

.recent .label {
  padding: 4px 8px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.recent ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.recent-chat {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  border-radius: 8px;
  padding: 7px 8px;
  font: inherit;
  font-size: 14px;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-chat.active .recent-title {
  font-weight: 600;
}

/* A chat with something new: a dot and a bolder title, as in a messaging app. */
.unread-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 6px;
  border-radius: 50%;
  background: var(--accent);
}

.unread-dot + .recent-title {
  font-weight: 600;
}

.recent-hint {
  display: block;
  font-size: 12px;
  color: var(--accent);
}

.recent-chat:hover,
.recent-chat.active {
  background: var(--bg);
}

.account {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 0;
  border-top: 1px solid var(--line);
}

.content {
  flex: 1;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.view {
  width: 100%;
  max-width: 760px;
  display: flex;
  flex-direction: column;
  height: 100dvh;
}


.view.page {
  padding: 0 16px 24px;
  overflow-y: auto;
}

.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
}

.view.page .view-header {
  padding: 14px 0 4px;
}

.view-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 650;
}

.rows li.stacked {
  display: block;
  border-bottom: 0;
  padding: 6px 0;
}

/* Narrow screens: the sidebar becomes a bar across the top. */
@media (max-width: 720px) {
  .shell {
    flex-direction: column;
  }

  .sidebar {
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 8px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }

  .nav {
    flex-direction: row;
  }

  .brand,
  .recent,
  #account-name {
    display: none;
  }

  .account {
    border-top: 0;
    padding: 0;
  }

  .view {
    height: auto;
    flex: 1;
    min-height: 0;
  }

  .content {
    min-height: 0;
  }
}

.card .recipients {
  list-style: none;
  padding-left: 0;
}

.card .recipients > li {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}

.card .recipients > li:last-child {
  border-bottom: 0;
}

.card .notes {
  margin: 4px 0;
  padding-left: 18px;
  font-size: 14px;
}

.transcript {
  margin-top: 6px;
  font-size: 14px;
}

.transcript summary {
  cursor: pointer;
  color: var(--accent);
}

.transcript .line {
  padding: 2px 0;
}

.transcript .line.remote {
  color: var(--muted);
}

.section-title {
  margin: 20px 0 4px;
  font-size: 15px;
  font-weight: 650;
}

.preferences-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 0;
}

.preferences-form label {
  font-size: 14px;
  margin-top: 6px;
}

.preferences-form select,
.preferences-form textarea,
.language-choice select {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
  background: var(--surface);
}

.language-choice select {
  padding: 4px 8px;
  font-size: 14px;
}

.call-job > summary {
  cursor: pointer;
  padding: 8px 0;
}

/* ---------- Settings: assistant voice ---------- */

.voice-options {
  display: grid;
  gap: 4px;
}

.voice-option {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.voice-option:last-child {
  border-bottom: 0;
}

.voice-name {
  font-weight: 600;
}

.voice-setup {
  display: grid;
  gap: 12px;
  justify-items: start;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
}

.voice-setup h3 {
  margin: 0;
}

.voice-line {
  margin: 0;
  font-size: 20px;
  line-height: 1.5;
}

.voice-tips {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 6px;
}

.voice-consent {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.voice-record.recording {
  background: #c62828;
}

.voice-problem {
  margin: 0;
  color: #b3261e;
}

.voice-setup audio {
  width: 100%;
}


/* ---------- Chat redesign, 2026-12-03 ---------- */

/* Assistant text is paragraphs and lists, not one pre-formatted block. */
.message.assistant {
  white-space: normal;
}

.message.assistant p,
.message.assistant ul,
.message.assistant ol {
  margin: 0 0 8px;
}

.message.assistant ul,
.message.assistant ol {
  padding-left: 22px;
}

.message.assistant > :last-child {
  margin-bottom: 0;
}

/* A message typed while Marven was replying, waiting for its turn. */
.message.user.queued {
  opacity: 0.55;
}

.message.user.queued::after {
  content: " · queued";
  font-size: 12px;
}

/* An event in the chat that nobody typed: a quiet divider. */
.status-note {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.status-note::before,
.status-note::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--line);
}

/* The right edge fades, hinting that the row of cards scrolls. */
.cards {
  mask-image: linear-gradient(to right, #000 calc(100% - 32px), transparent);
}

.card.closed-place {
  opacity: 0.6;
}

.actions button.primary {
  white-space: nowrap;
}

/* How a job or a call stands, readable at a glance by colour. */
.pill {
  flex: none;
  padding: 2px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--line);
}

.pill.good {
  background: #e3f1ea;
  border-color: #b9dccb;
  color: var(--accent);
}

.pill.warn {
  background: #fbf0d9;
  border-color: #ecd9a8;
  color: #8a6100;
}

.pill.bad {
  background: #f8e5e1;
  border-color: #e9c4bd;
  color: var(--danger);
}

.pill.live {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  animation: pulse 1.4s ease-in-out infinite;
}

.row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* A section folded until asked for: the script, a call's details, the sources. */
.fold,
.sources {
  font-size: 14px;
}

.fold > summary,
.sources > summary {
  cursor: pointer;
  color: var(--accent);
  padding: 4px 0;
}

.sources {
  align-self: flex-start;
  display: block;
}

.sources > summary {
  color: var(--muted);
  font-size: 13px;
}

.source-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-top: 4px;
}

.fold .line {
  padding: 2px 0;
}

.fold .line.remote {
  color: var(--muted);
}

/* ---------- Contacts and Settings: grouped panels, forms that fold away ---------- */

.view.page > .meta,
.panel .meta,
.rows .meta {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.panel {
  margin-top: 14px;
  padding: 16px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.panel > .section-title {
  margin: 0 0 2px;
}

.panel > .meta {
  margin-bottom: 10px;
}

ul.rows.panel {
  padding: 4px 18px;
}

ul.rows.panel:empty {
  display: none;
}

/* A form's buttons sit at its start, sized to their words, never across the page. */
.form-buttons {
  grid-column: 1 / -1;
  display: flex;
  gap: 8px;
}

.preferences-form .primary-button {
  align-self: flex-start;
  margin-top: 6px;
}

.panel .primary-button,
.adder .primary-button {
  padding: 8px 18px;
}

.inline-form {
  display: flex;
  gap: 8px;
}

.inline-form input {
  flex: 1;
  max-width: 320px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font: inherit;
}

/* "Add a ..." opens its form in place; the page stays a list until asked. */
.adder {
  margin-top: 10px;
}

.adder > summary {
  display: inline-block;
  list-style: none;
  cursor: pointer;
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--accent);
  font-size: 14px;
}

.adder > summary::-webkit-details-marker {
  display: none;
}

.adder > summary::before {
  content: "+ ";
}

.adder[open] > summary::before {
  content: "\2212  ";
}

/* Buttons at the end of a list row, such as Edit and Delete. */
.row-buttons {
  display: flex;
  flex: none;
  gap: 6px;
}
