/* Customer environment (/account), conversations (project page, account,
   admin) and the admin inbox. Builds on the tokens and portal-* components in
   styles.css; loaded only on those pages.

   THESIS: one desk per customer. Projects read as lines of work with their
   state in words, conversations read as a chat transcript in which the site's
   own mails sit as folded letters. Refuses the KPI-tile dashboard.
   OWN-WORLD: the project page's world: #F7F8FA ground, white sheets with a
   1px inset edge and a soft shadow, General Sans headings over DM Sans, one
   blue for actions and the customer's own words, status as tinted pills.
   STORY: see what needs me, see where each project stands, ask Mickey.
   FIRST VIEWPORT: greeting and "Nieuwe opdracht" on one line; a blue-ringed
   "Actie nodig" sheet only when something waits; projects (2/3) beside
   messages, Mickey and the live delivery time (1/3).
   FORM: extension of the incumbent portal surface, no new world. */

/* ============ Shell ============ */
.acc-body {
  min-height: 100vh;
}

.acc-top {
  display: flex;
  align-items: center;
  gap: 24px;
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px 24px;
}

.acc-logo {
  flex-shrink: 0;
  line-height: 0;
}

.acc-nav {
  display: flex;
  gap: 2px;
  margin: 0 auto;
  padding: 4px;
  border-radius: 999px;
  background: var(--surface-muted);
  box-shadow: inset 0 0 0 1px var(--border);
}

.acc-nav a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s var(--ease), background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.acc-nav a:hover {
  color: var(--ink);
}

.acc-nav a[aria-current="page"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-xs);
}

.acc-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.acc-user {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  min-width: 0;
}

.acc-email {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.acc-user form {
  margin: 0;
}

.acc-logout {
  padding: 7px 12px;
  border-radius: 8px;
  background: none;
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.acc-logout:hover {
  background: var(--surface-muted);
  color: var(--ink);
}

.acc {
  max-width: 1160px;
  margin: 0 auto;
  padding: 16px 24px 96px;
}

.acc p {
  margin-bottom: 0;
}

/* The landing page gives every <section> big padding and a white ground; here
   a section is only structure (zero specificity, so component classes win) */
:where(.acc) section {
  padding: 0;
  background: none;
}

.acc-flash {
  max-width: 440px;
  margin: 24px auto 0 !important;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
  text-align: center;
  color: var(--ink);
}

/* ============ Login ============ */
.acc-login {
  display: grid;
  justify-items: center;
  gap: 28px;
  padding: 6vh 0 0;
}

.acc-login-card {
  display: grid;
  gap: 14px;
  width: 100%;
  max-width: 440px;
  padding: 36px;
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-md);
}

.acc-login-card .service-eyebrow {
  margin: 0;
}

.acc-login-card h1 {
  font-size: 2rem;
  letter-spacing: -0.03em;
  line-height: 1.15;
}

.acc-login-card strong {
  color: var(--ink);
  font-weight: 600;
  overflow-wrap: anywhere;
}

.acc-login-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.acc-login-icon svg {
  width: 24px;
  height: 24px;
}

.acc-login-form {
  display: grid;
  gap: 14px;
  margin-top: 6px;
}

.acc-login-form .btn-primary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
}

.acc-code {
  font-size: 1.4rem !important;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.acc-login-note {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.acc-login-inside {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
  width: 100%;
  max-width: 720px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.acc-login-inside li {
  display: grid;
  gap: 2px;
  padding-top: 14px;
  border-top: 1px solid var(--border-strong);
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.acc-login-inside strong {
  color: var(--ink);
  font-weight: 600;
}

/* ============ Page heads and sections ============ */
.acc-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
  margin: 12px 0 28px;
}

.acc-head .service-eyebrow {
  margin-bottom: 8px;
}

.acc-head h1 {
  font-size: 2.4rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin-bottom: 6px;
}

.acc-head p {
  max-width: 62ch;
}

.acc-head .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.acc-head .btn-primary:hover svg,
.acc-side .btn-secondary:hover svg,
.acc-contact .btn-secondary:hover svg {
  transform: none;
}

.acc-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  font-size: 1.15rem;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.acc-count {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
}

.acc-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.acc-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.acc-main {
  min-width: 0;
}

.acc-side {
  display: grid;
  gap: 16px;
}

.acc-side .portal-card p {
  font-size: 0.9rem;
}

.acc-side-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.acc-side-head .portal-side-title {
  margin-bottom: 0 !important;
}

.acc-side-head .text-link {
  font-size: 0.88rem;
}

.acc-side-btn {
  display: flex !important;
  justify-content: center;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 14px;
}

.acc-empty {
  display: grid;
  justify-items: start;
  gap: 14px;
  color: var(--text-secondary);
}

.acc-empty .btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.acc-fine {
  font-size: 0.84rem;
}

/* ============ Action needed ============ */
.acc-actions {
  margin-bottom: 32px;
  padding: 20px 20px 12px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1.5px var(--primary), var(--shadow-md);
}

.acc-actions .acc-section-title {
  margin-bottom: 8px;
  padding: 0 4px;
}

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

.acc-actions li + li {
  border-top: 1px solid var(--border);
}

.acc-action {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 4px;
  color: inherit;
  text-decoration: none;
}

.acc-action-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.acc-action-text {
  display: grid;
  min-width: 0;
}

.acc-action-text strong {
  font-weight: 600;
  color: var(--ink);
}

.acc-action-text small {
  font-size: 0.86rem;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.acc-action-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--primary-soft);
  color: var(--primary-hover);
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease);
}

.acc-action-cta svg {
  width: 16px;
  height: 16px;
  transition: transform 0.25s var(--ease);
}

.acc-action:hover .acc-action-cta {
  background: var(--primary);
  color: #fff;
}

.acc-action:hover .acc-action-cta svg {
  transform: translateX(2px);
}

/* ============ Tabs ============ */
.acc-tabs {
  display: flex;
  gap: 4px;
}

.acc-tabs a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-decoration: none;
}

.acc-tabs a:hover {
  color: var(--ink);
}

.acc-tabs a[aria-current="page"] {
  background: var(--ink);
  color: #fff;
}

.acc-tabs span {
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
}

/* ============ Projects ============ */
.acc-projects {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.acc-project {
  display: grid;
  gap: 14px;
  padding: 18px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-xs);
  color: inherit;
  text-decoration: none;
  transition: box-shadow 0.2s var(--ease);
}

.acc-project:hover {
  box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-sm);
}

.acc-project-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.acc-project-name {
  display: grid;
  min-width: 0;
}

.acc-project-name strong {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.acc-project-name small {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.acc-state {
  flex-shrink: 0;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

.acc-state--action { background: var(--primary); color: #fff; }
.acc-state--busy { background: var(--primary-soft); color: var(--primary-hover); }
.acc-state--wait { background: rgba(245, 158, 11, 0.14); color: #B45309; }
.acc-state--done { background: rgba(34, 197, 94, 0.14); color: #15803D; }
.acc-state--stopped { background: rgba(239, 68, 68, 0.1); color: #B91C1C; }

.acc-progress {
  display: block;
  height: 4px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.acc-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--primary);
}

.acc-project:has(.acc-state--done) .acc-progress span {
  background: var(--success);
}

.acc-project-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.acc-project-foot > span:first-child {
  flex: 1;
  min-width: 0;
}

.acc-unread {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--primary-hover);
  white-space: nowrap;
}

.acc-unread svg {
  width: 15px;
  height: 15px;
}

.acc-project-go {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  color: var(--text-muted);
  transition: background-color 0.2s var(--ease), color 0.2s var(--ease), transform 0.25s var(--ease);
}

.acc-project-go svg {
  width: 16px;
  height: 16px;
}

.acc-project:hover .acc-project-go {
  background: var(--surface-muted);
  color: var(--ink);
  transform: translateX(2px);
}

/* ============ Conversation lists ============ */
.acc-threads {
  display: grid;
  margin: 0;
  padding: 0;
  list-style: none;
}

.acc-main .acc-threads {
  gap: 8px;
}

.acc-thread {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: background-color 0.2s var(--ease), box-shadow 0.2s var(--ease);
}

.acc-main .acc-thread {
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-xs);
}

.acc-main .acc-thread:hover {
  box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-sm);
}

.acc-threads--compact .acc-thread {
  gap: 12px;
  margin: 0 -10px;
  padding: 10px;
  border-radius: 12px;
}

.acc-threads--compact .acc-thread:hover {
  background: var(--surface-muted);
}

.acc-thread-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.acc-thread-icon svg {
  width: 18px;
  height: 18px;
}

.acc-thread.is-unread .acc-thread-icon {
  background: var(--primary-soft);
  color: var(--primary-hover);
}

.acc-thread-text {
  display: grid;
  min-width: 0;
}

.acc-thread-text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--ink);
}

.acc-thread.is-unread .acc-thread-text strong {
  font-weight: 600;
}

.acc-thread-text small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.acc-thread.is-unread .acc-thread-text small {
  color: var(--text-secondary);
}

.acc-thread-meta {
  display: grid;
  justify-items: end;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ============ Contact and live delivery time ============ */
.acc-contact {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 14px;
}

.acc-contact-photo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 0 0 4px var(--primary-soft);
}

.acc-contact .delivery-response-title {
  margin: 0;
}

.acc-contact-actions {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}

.acc-contact-actions .btn-secondary {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-variant-numeric: tabular-nums;
}

.acc-contact-actions .text-link {
  justify-self: center;
  font-size: 0.9rem;
}

.acc-live h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.acc-live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
  animation: accLive 2.4s ease-out infinite;
}

@keyframes accLive {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.45); }
  70%, 100% { box-shadow: 0 0 0 8px rgba(16, 185, 129, 0); }
}

.acc-live ul {
  display: grid;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.acc-live li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px dashed var(--border);
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.acc-live li:first-child {
  border-top: 0;
}

.acc-live strong {
  font-weight: 600;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ============ New message form (account) ============ */
.acc-new {
  display: grid;
  gap: 14px;
  scroll-margin-top: 24px;
}

.acc-new .portal-side-title {
  margin-bottom: 0 !important;
}

.acc-new .btn-primary {
  justify-self: start;
}

/* ============ Files ============ */
.acc-files {
  margin-bottom: 16px;
}

.acc-files-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}

.acc-files-head h2 {
  margin: 0 0 2px;
  font-size: 1.15rem;
  letter-spacing: -0.015em;
}

.acc-files-head .text-link {
  flex-shrink: 0;
  font-size: 0.9rem;
}

.acc-files ul {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.acc-files .final-file {
  background: var(--surface-muted);
  box-shadow: none;
}

.acc-files .final-file small {
  display: block;
  font-size: 0.8rem;
  font-weight: 400;
  color: var(--text-muted);
}

.acc-files > p {
  margin-top: 12px;
}

/* ============ Conversation page (account) ============ */
.acc-back {
  margin: 12px 0 18px;
}

.acc-chat-page {
  max-width: 820px;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border), var(--shadow-sm);
}

.acc-chat-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}

.acc-chat-head img {
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
}

.acc-chat-head h1 {
  margin: 0 0 2px;
  font-size: 1.3rem;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

.acc-chat-head p {
  font-size: 0.88rem;
}

.acc-chat-page .cv {
  padding: 0 24px 20px;
}

.acc-chat-page .cv-list {
  height: max(360px, calc(100vh - 380px));
  max-height: none;
}

/* A short conversation sits at the bottom, next to where you type */
.acc-chat-page .cv-list::before {
  content: '';
  flex: 1 0 0;
}

/* ============ Project page additions ============ */
/* .portal-top a styles the logo link; these are plain text links */
.portal-top .portal-top-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1.3;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-secondary);
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s var(--ease);
}

.portal-top .portal-top-link:hover {
  color: var(--ink);
}

.portal-top > a:first-child {
  flex-shrink: 0;
}

/* Phones: the logo keeps its place; the phone number becomes just its icon */
@media (max-width: 600px) {
  .portal-top-right {
    gap: 12px;
  }

  .portal-top .portal-call {
    padding: 8px;
  }

  /* visually hidden, still read out as the link's name */
  .portal-top .portal-call span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

/* Narrow phones: the logo leads back to all projects (for the owner), so the text link can go */
@media (max-width: 480px) {
  .portal-top > a:first-child img {
    height: 24px;
    width: auto;
  }

  .portal-top .portal-top-link:first-child {
    display: none;
  }
}

.portal-chat {
  padding: 0;
  scroll-margin-top: 16px;
  overflow: hidden;
}

.portal-chat-head {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 22px 24px 18px;
  border-bottom: 1px solid var(--border);
}

.portal-chat-head img {
  flex-shrink: 0;
  border-radius: 50%;
  object-fit: cover;
}

.portal-chat-head h2 {
  margin: 0 0 4px !important;
  font-size: 1.3rem !important;
  line-height: 1.25;
}

.portal-chat-head p {
  margin: 0;
  font-size: 0.9rem;
  max-width: 60ch;
}

.portal-chat .cv {
  padding: 0 24px 20px;
}

/* ============ Conversation (shared) ============ */
.cv {
  display: grid;
  gap: 10px;
}

.cv-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 560px;
  margin: 0;
  padding: 16px 6px 8px 2px;
  list-style: none;
  overflow-y: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
  scroll-padding-bottom: 12px;
}

.cv-day {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 12px 0 6px;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-muted);
}

.cv-day::before,
.cv-day::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.cv-day:first-child {
  margin-top: 0;
}

.cv-day span::first-letter {
  text-transform: uppercase;
}

.cv-empty {
  margin: auto 0;
  padding: 28px 16px;
  text-align: center;
  font-size: 0.92rem;
  color: var(--text-muted);
}

/* A chat message */
.cv-msg {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: end;
  gap: 10px;
  margin-top: 8px;
}

.cv-msg.is-own {
  grid-template-columns: minmax(0, 1fr);
  justify-items: end;
}

.cv-msg.is-follow {
  margin-top: 0;
}

.cv-msg.is-follow .cv-meta {
  display: none;
}

.cv-msg.is-follow .cv-avatar {
  visibility: hidden;
}

.cv-avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-muted);
  box-shadow: inset 0 0 0 1px var(--border);
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  overflow: hidden;
}

.cv-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cv-stack {
  display: grid;
  justify-items: start;
  gap: 4px;
  min-width: 0;
  max-width: min(580px, 88%);
}

.cv-msg.is-own .cv-stack {
  justify-items: end;
}

.cv-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 0 4px !important;
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.cv-meta strong {
  font-weight: 600;
  color: var(--text-secondary);
}

.cv-via {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--surface-muted);
  font-size: 0.72rem;
  font-weight: 500;
}

.cv-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  border-bottom-left-radius: 6px;
  background: var(--surface-muted);
  color: var(--ink);
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.cv-msg.is-own .cv-bubble {
  border-bottom-left-radius: 18px;
  border-bottom-right-radius: 6px;
  background: var(--primary);
  color: #fff;
}

.cv-bubble a {
  color: var(--primary-hover);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.cv-msg.is-own .cv-bubble a {
  color: #fff;
}

.cv-msg.is-new .cv-stack {
  animation: bubbleIn 0.35s var(--ease) both;
}

.cv-msg.is-new.is-own .cv-stack {
  transform-origin: bottom right;
}

.cv-files {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.cv-files a,
.cv-files span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-radius: 12px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--ink);
  text-decoration: none;
}

.cv-files a:hover {
  box-shadow: inset 0 0 0 1px var(--primary);
}

.cv-files span span {
  display: inline;
  padding: 0;
  box-shadow: none;
  background: none;
}

.cv-files svg {
  flex-shrink: 0;
  width: 15px;
  height: 15px;
  color: var(--text-muted);
}

.cv-files small {
  font-weight: 400;
  color: var(--text-muted);
}

.cv-full {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.cv-full summary {
  cursor: pointer;
  padding: 0 4px;
}

.cv-full summary:hover {
  color: var(--ink);
}

.cv-full div {
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--surface-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--text-secondary);
}

.cv-seen {
  align-self: flex-end;
  margin: -2px 4px 0;
  font-size: 0.74rem;
  color: var(--text-muted);
}

/* A mail the site sent: a folded letter in the transcript */
.cv-mail {
  margin: 8px 0 2px;
}

.cv-mail details {
  border-radius: 14px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

.cv-mail details[open] {
  box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-sm);
}

.cv-mail summary {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  cursor: pointer;
  list-style: none;
}

.cv-mail summary::-webkit-details-marker {
  display: none;
}

.cv-mail summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
  border-radius: 14px;
}

.cv-mail-icon {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--surface-muted);
  color: var(--text-secondary);
}

.cv-mail-icon svg {
  width: 17px;
  height: 17px;
}

.cv-mail-text {
  display: grid;
  min-width: 0;
}

.cv-mail-text small {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.cv-mail-text strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink);
}

.cv-mail details[open] .cv-mail-text strong {
  white-space: normal;
}

.cv-mail-toggle {
  width: 9px;
  height: 9px;
  margin-right: 4px;
  border-right: 2px solid var(--text-muted);
  border-bottom: 2px solid var(--text-muted);
  transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.2s var(--ease);
}

.cv-mail details[open] .cv-mail-toggle {
  transform: rotate(225deg) translate(-2px, -2px);
}

.cv-mail-body {
  margin: 0 14px 14px 58px;
  padding-top: 12px;
  border-top: 1px dashed var(--border-strong);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
  line-height: 1.55;
  color: var(--text-secondary);
}

.cv-mail-body a {
  color: var(--primary-hover);
}

/* Writing */
.cv-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 8px;
  padding: 6px 6px 6px 16px;
  border-radius: 22px;
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border-strong);
  transition: box-shadow 0.2s var(--ease);
}

.cv-form:focus-within {
  box-shadow: inset 0 0 0 1.5px var(--primary), 0 0 0 4px rgba(59, 130, 246, 0.14);
}

.cv-form textarea {
  display: block;
  width: 100%;
  min-height: 40px;
  max-height: 200px;
  padding: 9px 0;
  border: 0;
  background: none;
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  color: var(--ink);
  resize: none;
  outline: none;
}

.cv-form textarea::placeholder {
  color: var(--text-muted);
}

.cv-send {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.3), 0 6px 14px -6px rgba(37, 99, 235, 0.55);
}

.cv-send:hover {
  background: var(--primary-hover);
}

.cv-send:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

.cv-send:disabled {
  background: var(--border-strong);
  box-shadow: none;
  cursor: default;
}

.cv-send svg {
  width: 18px;
  height: 18px;
}

.cv-form.is-sending .cv-send svg {
  animation: cvSend 0.8s var(--ease) infinite;
}

@keyframes cvSend {
  50% { transform: translateY(-3px); }
}

.cv-error {
  margin: 0 !important;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(239, 68, 68, 0.08);
  color: #B91C1C;
  font-size: 0.86rem;
}

.cv-note {
  margin: 0 4px !important;
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ============ Admin: inbox and chat ============ */
.admin .cv-list {
  max-height: 600px;
}

.admin-chat-card h2 {
  display: flex;
  align-items: center;
  gap: 10px;
}

.admin-chat-open {
  margin-left: auto;
  font-family: var(--font-body);
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--primary);
  text-decoration: none;
}

.admin-chat-open:hover {
  text-decoration: underline;
}

.admin-chat-setup {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

.admin-chat-setup strong {
  color: var(--ink);
}

.admin-chat-setup code {
  padding: 1px 6px;
  border-radius: 6px;
  background: var(--surface-muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

.admin-threads {
  padding: 8px;
}

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

.admin-threads li + li {
  border-top: 1px solid var(--border);
}

.admin-thread {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}

.admin-thread:hover {
  background: var(--surface-muted);
}

.admin-thread-avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--surface-muted);
  box-shadow: inset 0 0 0 1px var(--border);
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--text-secondary);
}

.admin-thread.is-unread .admin-thread-avatar {
  background: var(--primary);
  box-shadow: none;
  color: #fff;
}

.admin-thread-text {
  display: grid;
  min-width: 0;
}

.admin-thread-text > * {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-thread-text strong {
  font-weight: 500;
  color: var(--ink);
}

.admin-thread.is-unread .admin-thread-text strong {
  font-weight: 600;
}

.admin-thread-text span {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.admin-thread-text small {
  font-size: 0.84rem;
  color: var(--text-muted);
}

.admin-thread-meta {
  display: grid;
  justify-items: end;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.admin-live {
  color: #047857;
  font-weight: 600;
}

.admin-mini-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-mini-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  font-size: 0.9rem;
}

.admin-mini-list a {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ink);
  text-decoration: none;
}

.admin-mini-list a:hover {
  color: var(--primary);
}

.admin-mini-list small {
  flex-shrink: 0;
  color: var(--text-muted);
}

.admin-narrow-wide {
  max-width: 640px;
}

.admin-narrow-wide .field {
  margin-bottom: 14px;
}

.message-actions form {
  margin: 0;
}

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .acc-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .acc-top {
    flex-wrap: wrap;
    gap: 12px 16px;
    padding: 16px;
  }

  .acc-user {
    margin-left: auto;
  }

  .acc-email {
    display: none;
  }

  .acc-nav {
    order: 3;
    width: 100%;
    margin: 0;
  }

  .acc-nav a {
    flex: 1;
    justify-content: center;
    padding: 8px 10px;
  }

  .acc {
    padding: 8px 16px 72px;
  }

  .acc-head {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 22px;
  }

  .acc-head h1 {
    font-size: 2rem;
  }

  .acc-head .btn-primary {
    justify-content: center;
  }

  .acc-section-head {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .acc-actions {
    padding: 16px 14px 8px;
  }

  .acc-action {
    grid-template-columns: auto minmax(0, 1fr);
    padding: 12px 2px;
  }

  .acc-action-cta {
    grid-column: 2;
    justify-self: start;
  }

  .acc-project {
    padding: 16px;
  }

  .acc-project-top {
    flex-direction: column;
    gap: 8px;
  }

  .acc-login {
    padding-top: 2vh;
  }

  .acc-login-card {
    padding: 26px 22px;
  }

  .acc-login-inside {
    grid-template-columns: 1fr;
    gap: 14px;
    max-width: 440px;
  }

  .acc-chat-head,
  .portal-chat-head {
    padding: 16px;
  }

  .acc-chat-page .cv,
  .portal-chat .cv {
    padding: 0 12px 14px;
  }

  .acc-chat-page .cv-list {
    height: max(320px, calc(100svh - 330px));
  }

  .cv-stack {
    max-width: 92%;
  }

  .cv-mail-body {
    margin-left: 14px;
  }

  .admin-thread {
    padding: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .acc-live-dot,
  .cv-msg.is-new .cv-stack,
  .cv-form.is-sending .cv-send svg {
    animation: none;
  }
}
