/* Connect craft overlay — Apple deference on the existing Foundations tokens.
   Chrome recedes. Messages and files are the brightest surface. Colour is never
   the only carrier of unread or urgency. Honour reduced motion and reduced
   transparency. */

/* Translucent chrome (subtle: contrast stays on --oparo-text). */
.appbar,
.primary-nav,
.secondary {
  background: color-mix(in srgb, var(--oparo-surface) 86%, transparent);
  backdrop-filter: blur(18px) saturate(1.15);
  -webkit-backdrop-filter: blur(18px) saturate(1.15);
  border-color: color-mix(in srgb, var(--oparo-border) 70%, transparent);
}
.main {
  background: var(--oparo-background);
}
.chan-head {
  background: color-mix(in srgb, var(--oparo-surface) 78%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--oparo-border);
}
.composer {
  background: color-mix(in srgb, var(--oparo-surface) 90%, transparent);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .appbar, .primary-nav, .secondary, .chan-head, .composer {
    background: var(--oparo-surface);
  }
}
@media (prefers-reduced-transparency: reduce) {
  .appbar, .primary-nav, .secondary, .chan-head, .composer {
    background: var(--oparo-surface);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

/* Typography over colour for conversation rows. */
.chan .nm,
.dm-row .nm {
  font-weight: var(--font-weight-regular);
  color: var(--oparo-text);
}
.chan.has-unread .nm,
.dm-row.has-unread .nm {
  font-weight: var(--font-weight-semibold);
}
.chan .badge,
.dm-row .badge {
  display: none;
}
.unread-cue {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--oparo-text-muted);
}
.unread-cue--mention {
  background: var(--oparo-accent);
  transform: rotate(45deg);
  border-radius: 1px;
  width: 7px;
  height: 7px;
}
.unread-cue--urgent {
  width: auto;
  height: auto;
  min-width: var(--oparo-touch-min);
  min-height: calc(var(--oparo-space-5) + 2px);
  padding: 0 var(--oparo-space-2);
  border-radius: var(--oparo-radius-sm);
  background: var(--oparo-status-danger);
  color: var(--oparo-text-on-accent);
  font-size: var(--oparo-font-size-xs);
  font-weight: var(--font-weight-semibold);
  line-height: calc(var(--oparo-space-5) + 2px);
  text-align: center;
}

/* Nav: a mark, not a red count, for ordinary unreads. Activity stays a count
   because it is the notification centre, and the number is also in the name. */
.nav-badge {
  background: var(--oparo-text-muted);
  color: var(--oparo-text-on-accent);
  font-size: 0;
  min-width: 8px;
  width: 8px;
  height: 8px;
  padding: 0;
  top: 10px;
  right: 12px;
}
.nav-btn[data-key="activite"] .nav-badge {
  font-size: 10px;
  min-width: 16px;
  width: auto;
  height: 16px;
  padding: 0 4px;
  background: var(--oparo-accent);
}

.primary-nav .nav-btn[aria-pressed="true"] {
  background: transparent;
  box-shadow: inset 3px 0 0 var(--oparo-accent);
  font-weight: var(--font-weight-semibold);
  color: var(--oparo-text);
}
.chan[aria-selected="true"] {
  background: var(--oparo-surface-selected);
  box-shadow: inset 3px 0 0 var(--oparo-accent);
}

/* Progressive disclosure: formatting lives behind Plus d’actions only.
   Never open on focus-within: that trapped screen reader users in an
   expanded bar they could not close. */
.composer-toolbar-wrap {
  flex: 1 0 100%;
  order: 0;
  margin-bottom: var(--oparo-space-1);
}
.composer-toolbar-wrap[hidden],
.composer-toolbar[hidden] {
  display: none !important;
}
.composer-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
}
.composer-plus { order: 1; }
.composer .field textarea { order: 2; }
.composer .field > .btn-primary { order: 3; }
.composer .field {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--oparo-space-2);
}
@media (prefers-reduced-motion: reduce) {
  .composer-toolbar { transition: none; }
}
.composer-plus {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--oparo-touch-min);
  min-height: var(--oparo-touch-min);
  border: 0;
  border-radius: var(--oparo-radius);
  background: transparent;
  color: var(--oparo-text-muted);
  cursor: pointer;
}
.composer-plus:hover,
.composer-plus:focus-visible {
  color: var(--oparo-text);
  background: var(--oparo-surface-sunken);
}
.composer textarea {
  background: var(--oparo-surface);
  border: 1px solid var(--oparo-border);
  border-radius: var(--oparo-radius);
  color: var(--oparo-text);
}
.composer .hint { display: none; }
.composer:focus-within .hint { display: block; }

.composer-drop {
  display: none;
  position: absolute;
  inset: var(--oparo-space-2);
  border: 2px dashed var(--oparo-accent);
  border-radius: var(--oparo-radius);
  background: color-mix(in srgb, var(--oparo-accent-subtle) 80%, var(--oparo-surface));
  color: var(--oparo-text);
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--oparo-space-4);
  z-index: var(--z-dropdown);
  pointer-events: none;
}
.composer.is-drop-target .composer-drop { display: flex; }

/* Context thread: the CRM record this conversation belongs to. */
.context-thread {
  display: flex;
  align-items: center;
  gap: var(--oparo-space-2);
  margin: 0 var(--oparo-space-4) var(--oparo-space-2);
  padding: var(--oparo-space-2) var(--oparo-space-3);
  border-radius: var(--oparo-radius-sm);
  background: var(--oparo-surface);
  border: 1px solid var(--oparo-border);
  color: var(--oparo-text);
  text-decoration: none;
  font-size: var(--oparo-font-size-sm);
}
.context-thread:hover,
.context-thread:focus-visible {
  border-color: var(--oparo-accent);
}
.context-thread .ct-kind {
  color: var(--oparo-text-muted);
  font-size: var(--oparo-font-size-xs);
  font-weight: var(--font-weight-medium);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Delivery: a quiet echo, not a status colour. */
.msg-delivered {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  margin-left: var(--oparo-space-2);
  color: var(--oparo-text-muted);
  font-size: var(--oparo-font-size-xs);
}
.msg.mine .msg-delivered { color: var(--oparo-status-success); }

.cmd-count {
  font-size: var(--oparo-font-size-xs);
  color: var(--oparo-text-muted);
  margin: var(--oparo-space-2) 0 0;
}

.urgent-confirm-body {
  margin: 0 0 var(--oparo-space-4);
  color: var(--oparo-text);
}
.urgent-confirm-actions {
  display: flex;
  gap: var(--oparo-space-2);
  justify-content: flex-end;
}

.context-thread .ct-name {
  font-weight: var(--font-weight-semibold);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.context-thread .ct-open {
  margin-left: auto;
  color: var(--oparo-text-muted);
  font-size: var(--oparo-font-size-xs);
  display: inline-flex;
  align-items: center;
  gap: var(--oparo-space-1);
  white-space: nowrap;
}

.paro-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--oparo-space-2);
  margin: 0 var(--oparo-space-4) var(--oparo-space-2);
}
.paro-toggle {
  color: var(--oparo-text-muted);
}

.cmd-hint {
  margin: 0 0 var(--oparo-space-2);
  color: var(--oparo-text-muted);
  font-size: var(--oparo-font-size-sm);
}
.cmd-list {
  list-style: none;
  margin: var(--oparo-space-2) 0 0;
  padding: 0;
}
.cmd-option {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  text-align: left;
  cursor: pointer;
  padding: var(--oparo-space-2) var(--oparo-space-3);
  border-radius: var(--oparo-radius-sm);
}
.cmd-option.is-active,
.cmd-option[aria-selected="true"] {
  background: var(--oparo-surface-selected);
}
.cmd-kind {
  font-size: var(--oparo-font-size-xs);
  color: var(--oparo-text-muted);
  font-weight: var(--font-weight-medium);
}

.composer .field .btn-primary {
  min-height: var(--oparo-touch-min);
}

.composer-toolbar .cbar-btn {
  min-width: var(--oparo-touch-min);
  min-height: var(--oparo-touch-min);
  height: auto;
}
.cbar-btn.is-pressed,
.composer-toolbar .cbar-btn[aria-pressed="true"] {
  background: var(--oparo-surface-selected);
  color: var(--oparo-text);
  box-shadow: inset 0 0 0 2px var(--oparo-accent);
}
.cbar-btn-label {
  width: auto;
  min-width: var(--oparo-touch-min);
  min-height: var(--oparo-touch-min);
  height: auto;
  padding: 0 var(--oparo-space-2);
  gap: var(--oparo-space-1);
  font-size: var(--oparo-font-size-sm);
  color: var(--oparo-text);
}
.menu-check {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 1px;
  border: 1px solid var(--oparo-text-muted);
  flex: 0 0 auto;
}
.menu-check.is-on {
  background: var(--oparo-accent);
  border-color: var(--oparo-accent);
}

ul.attach-menu-list,
ul.attach-picker-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.attach-picker-list .att-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: var(--oparo-space-2);
  width: 100%;
  text-align: left;
  cursor: pointer;
  padding: var(--oparo-space-2) var(--oparo-space-3);
  border-radius: var(--oparo-radius-sm);
}
.attach-picker-list .att-row.is-active,
.attach-picker-list .att-row[aria-selected="true"] {
  background: var(--oparo-surface-selected);
}

.composer-attach {
  order: 2;
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--oparo-touch-min);
  min-height: var(--oparo-touch-min);
  border: 0;
  border-radius: var(--oparo-radius);
  background: transparent;
  color: var(--oparo-text-muted);
  cursor: pointer;
}
.composer-attach:hover,
.composer-attach:focus-visible {
  color: var(--oparo-text);
  background: var(--oparo-surface-sunken);
}
.composer .field textarea { order: 3; }
.composer .field > .btn-primary { order: 4; }

.add-menu,
.dialog {
  background: var(--oparo-surface-raised);
}

.file-smart-card {
  display: inline-flex;
  align-items: stretch;
  max-width: 360px;
  border: 1px solid var(--oparo-border);
  border-radius: var(--oparo-radius);
  background: var(--oparo-surface-raised);
}
.file-smart-card-main {
  display: flex;
  align-items: center;
  gap: var(--oparo-space-2);
  min-width: 0;
  flex: 1;
  padding: var(--oparo-space-2) var(--oparo-space-3);
  border: 0;
  background: transparent;
  color: var(--oparo-text);
  cursor: pointer;
  text-align: left;
}
.file-smart-card-main:hover,
.file-smart-card-main:focus-visible {
  background: var(--oparo-surface-sunken);
}
.file-smart-icon {
  display: inline-flex;
  color: var(--oparo-text-muted);
}
.file-smart-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 2px;
}
.file-smart-name {
  font-weight: var(--font-weight-medium);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.file-smart-meta {
  color: var(--oparo-text-muted);
  font-size: var(--oparo-font-size-xs);
}
.file-smart-card .att-remove {
  border: 0;
  background: none;
  cursor: pointer;
  color: var(--oparo-text-muted);
  font-size: 16px;
  line-height: 1;
  padding: 0 var(--oparo-space-2);
}

.files-picker input[type="search"] { width: 100%; margin-bottom: var(--oparo-space-2); }
.quick-look-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--oparo-space-2);
  margin-bottom: var(--oparo-space-3);
}
.quick-look .dv-inline { min-height: 240px; }
