*, *::before, *::after { box-sizing: border-box; }

/* overflow-x volontairement laissé à "visible" ici : le régler sur html/body casse
   position: sticky pour tous les descendants (topbar, sidebar) dans les navigateurs
   basés sur Chromium. */
html, body { max-width: 100%; }

::selection {
  background: var(--color-accent);
  color: #fff;
}

html {
  scrollbar-color: var(--color-border-strong) transparent;
}
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--color-border-strong);
  border-radius: var(--radius-full);
  border: 2px solid var(--color-bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--color-text-faint); }

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, p { margin: 0; }

code, pre, .mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

a {
  color: var(--color-accent-ink);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}
a:hover { color: var(--color-accent-hover); }

/* Shell */

.app-shell, .simple-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: stretch;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 40;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-bg);
}

.topbar__inner {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-4);
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.page-body {
  display: flex;
  align-items: flex-start;
  gap: var(--space-8);
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 var(--space-6);
}

.page-body > main {
  flex: 1;
  min-width: 0;
}

#app-rail-root, .app-rail-root { display: contents; }

.topbar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  font-weight: 650;
  letter-spacing: -0.01em;
}

.topbar__mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--color-accent);
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
}
.topbar__mark svg { width: 15px; height: 15px; }

.cover-mark {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--color-accent);
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
}
.cover-mark svg { width: 15px; height: 15px; }
.cover-mark--lg { width: 48px; height: 48px; border-radius: var(--radius-md); }
.cover-mark--lg svg { width: 26px; height: 26px; }
.cover-mark--sm { width: 18px; height: 18px; border-radius: 5px; box-shadow: none; }
.cover-mark--sm svg { width: 10px; height: 10px; }

.topbar__brand-subtitle {
  font-size: var(--text-sm);
  font-weight: 400;
  color: var(--color-text-faint);
  letter-spacing: normal;
}
.topbar__brand-subtitle::before {
  content: "·";
  margin-right: var(--space-2);
}

.topbar__user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
  flex-shrink: 0;
}

.topbar__search {
  position: relative;
  flex: 1;
  max-width: 420px;
  min-width: 0;
  margin-left: 80px; /* ≈ largeur sidebar (288px) + espacement (32px) */
}
.topbar__search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-faint);
  pointer-events: none;
}
.topbar__search input {
  height: 40px;
  width: 100%;
  padding: 0 var(--space-3) 0 36px;
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  font-size: var(--text-sm);
  font-family: var(--font-sans);
  color: var(--color-text);
}
.topbar__search input::placeholder { color: var(--color-text-faint); }
.topbar__search input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px var(--color-surface-accent);
}
.topbar__write { height: 40px; flex-shrink: 0; }

.topbar__user-name {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.avatar {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-full);
  background: var(--color-surface-accent);
  color: var(--color-accent-ink);
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.01em;
  font-weight: 600;
  flex-shrink: 0;
}
.avatar--lg { width: 44px; height: 44px; font-size: 13px; }

/* Menu compte (clic sur l'avatar) */

.account-menu { position: relative; }

.account-trigger {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  cursor: pointer;
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
  border-radius: var(--radius-full);
  transition: border-color 120ms var(--ease-out);
}
.account-trigger:hover { border-color: var(--color-accent); }
.account-trigger__name { font-size: var(--text-sm); font-weight: 550; color: var(--color-text); white-space: nowrap; }
.account-trigger__chevron { color: var(--color-text-faint); flex-shrink: 0; }

.account-panel {
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  width: 260px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  padding: var(--space-2);
  z-index: 60;
}

.account-panel__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3) var(--space-3);
}
.account-panel__name { font-weight: 650; font-size: var(--text-sm); }
.account-panel__email { font-size: var(--text-xs); color: var(--color-text-faint); }

.account-panel__divider { height: 1px; background: var(--color-border); margin: var(--space-1) 0; }

.account-panel__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 550;
  color: var(--color-text);
  text-decoration: none;
  cursor: pointer;
  text-align: left;
}
.account-panel__item:hover { background: var(--color-surface-sunk); color: var(--color-text); }
.account-panel__item--danger { color: var(--color-error); }
.account-panel__item--danger:hover { background: rgba(176, 0, 32, 0.08); color: var(--color-error); }
.account-panel__item:disabled { color: var(--color-text-faint); cursor: not-allowed; }
.account-panel__item:disabled:hover { background: transparent; }

.app-sidebar {
  width: 288px;
  flex-shrink: 0;
  position: sticky;
  top: 64px;
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: var(--space-5) 0 var(--space-6);
}

.app-sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--color-text);
  margin-bottom: var(--space-5);
}

.app-sidebar__nav { display: flex; flex-direction: column; gap: 2px; margin-bottom: var(--space-5); }
.app-sidebar__navitem {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  font-weight: 550;
  font-size: var(--text-base);
  text-decoration: none;
}
.app-sidebar__navitem:hover { background: var(--color-surface-sunk); color: var(--color-text); }
.app-sidebar__navitem--active { background: var(--color-surface-accent); color: var(--color-accent-ink); font-weight: 650; }
.app-sidebar__navitem svg { flex-shrink: 0; }

.app-sidebar__section { margin-bottom: var(--space-5); }

.notif-bell { position: relative; }

.notif-bell__trigger {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  border-radius: var(--radius-full);
  color: var(--color-text-muted);
  cursor: pointer;
  box-shadow: var(--shadow-xs);
}
.notif-bell__trigger:hover { color: var(--color-text); }
.notif-bell__trigger[aria-expanded="true"] { color: var(--color-text); background: var(--color-surface-sunk); }

.notif-bell__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border-radius: var(--radius-full);
  background: var(--color-error);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}

.notif-bell__panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  width: 320px;
  max-width: 85vw;
  max-height: 420px;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px) scale(.98);
  pointer-events: none;
  transition: opacity .5s cubic-bezier(.4, 0, .2, 1), transform .5s cubic-bezier(.4, 0, .2, 1);
}
.notif-bell__panel--open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; transition-delay: .15s; }

.notif-bell__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  font-weight: 650;
  font-size: var(--text-sm);
}

.notif-bell__mark-all {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-accent-ink);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 0;
}
.notif-bell__mark-all:hover { color: var(--color-accent-hover); }

.notif-bell__list {
  overflow-y: auto;
}

.notif-bell__item {
  display: block;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-border);
  text-decoration: none;
  color: var(--color-text);
}
.notif-bell__item:hover { background: var(--color-surface-sunk); }
.notif-bell__item--unread { background: var(--color-surface-accent); }
.notif-bell__item--unread:hover { background: var(--color-surface-accent); filter: brightness(0.97); }

.notif-bell__item-text {
  font-size: var(--text-sm);
  line-height: 1.4;
}
.notif-bell__item-message {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  font-style: italic;
  margin-top: var(--space-1);
}
.notif-bell__item-time {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  margin-top: var(--space-1);
}

.notif-bell__empty {
  padding: var(--space-5) var(--space-4);
  font-size: var(--text-sm);
  color: var(--color-text-faint);
  text-align: center;
}

.post-card__top-right {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
}

.post-menu { position: relative; }

.post-menu__trigger {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  cursor: pointer;
}
.post-menu__trigger:hover { background: var(--color-surface-sunk); color: var(--color-text); }
.post-menu__trigger[aria-expanded="true"] { background: var(--color-surface-sunk); color: var(--color-text); }

.post-menu__panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 20;
  min-width: 220px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-popover);
  padding: var(--space-2);
}

.post-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 550;
  color: var(--color-text);
  cursor: pointer;
  text-align: left;
}
.post-menu__item:hover { background: var(--color-surface-sunk); }
.post-menu__item--danger { color: var(--color-error); }
.post-menu__item--danger:hover { background: rgba(176, 0, 32, 0.08); color: var(--color-error); }

.post-menu__toast {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 21;
  background: var(--color-accent-ink);
  color: #fff;
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-popover);
  white-space: nowrap;
}

.sidebar__label {
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--color-text-faint);
  text-transform: uppercase;
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
}

@keyframes contentFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.feed {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: var(--space-8) 0 var(--space-12);
  animation: contentFadeIn .4s cubic-bezier(.4, 0, .2, 1);
  transition: opacity .28s cubic-bezier(.4, 0, .2, 1), transform .28s cubic-bezier(.4, 0, .2, 1);
}

.content-leaving { opacity: 0 !important; transform: translateY(-6px); }

.app-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-12);
  padding-top: var(--space-5);
  border-top: 1px solid var(--color-border);
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}
.app-footer__sep { color: var(--color-border-strong); }
@media (max-width: 780px) {
  .app-footer { margin-top: var(--space-8); }
}

.feed__inner {
  max-width: 48rem;
  /* margin: 0 auto; */
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
}

#feed-inner {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.feed__empty {
  text-align: center;
  color: var(--color-text-muted);
  padding: var(--space-12) var(--space-4);
  font-size: var(--text-base);
}

/* Accueil personnalisé du fil */

.greeting__title {
  font-size: var(--text-xl);
  font-weight: 650;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-1);
}

.greeting__subtitle {
  color: var(--color-text-muted);
  font-size: var(--text-base);
  margin-bottom: var(--space-5);
}

/* Résultats de recherche (affichés sur le fil) */

.search-results__header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-1);
}

.search-results__communities {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.search-result-community {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-sm);
  font-weight: 550;
  text-decoration: none;
  transition: all 120ms var(--ease-out);
}
.search-result-community:hover { background: var(--color-surface-sunk); color: var(--color-text); }
.search-result-community__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-accent);
  flex-shrink: 0;
}

.greeting__prompt {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-4) var(--space-5);
  text-decoration: none;
  color: var(--color-text);
  margin-bottom: var(--space-6);
  transition: box-shadow 160ms var(--ease-out);
}
.greeting__prompt:hover { box-shadow: var(--shadow-card-hover); color: var(--color-text); }

.greeting__prompt-text {
  flex: 1;
  color: var(--color-text-faint);
  font-size: var(--text-base);
}

/* Menu mobile (hamburger + tiroir + barre basse) */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--color-text);
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--color-surface-sunk); }

/* Barre de navigation principale (verticale desktop / bas mobile) */

.app-rail { display: none; }

.app-rail__item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: var(--space-2) 2px;
  border: none;
  border-left: 3px solid transparent;
  background: none;
  border-radius: 0;
  color: var(--color-text-muted);
  text-decoration: none;
  font-family: var(--font-sans);
  cursor: pointer;
  transition-property: color, background-color, border-color;
  transition-timing-function: cubic-bezier(.4, 0, .2, 1);
  transition-duration: .15s;
}
.app-rail__item:hover { color: var(--color-text); background: var(--color-surface-sunk); }
.app-rail__item--active { border-left-color: var(--color-see-more); color: #3d3d3d; }
.app-rail__item--active:hover { background: none; }
.app-rail__label { font-size: 10px; font-weight: 600; line-height: 1.2; text-align: center; }

.notif-bell--rail { width: 100%; display: none; }
.notif-bell--rail .notif-bell__trigger {
  position: relative;
  width: 100%;
  height: auto;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-2) 2px;
  border: none;
  border-left: 3px solid transparent;
  background: none;
  border-radius: 0;
  box-shadow: none;
  color: var(--color-text-muted);
  transition-property: color, background-color, border-color;
  transition-timing-function: cubic-bezier(.4, 0, .2, 1);
  transition-duration: .15s;
}
.notif-bell--rail .notif-bell__trigger:hover { color: var(--color-text); background: var(--color-surface-sunk); }
.notif-bell--rail .notif-bell__trigger[aria-expanded="true"] { border-left-color: var(--color-see-more); color: #3d3d3d; background: none; }
.notif-bell--rail .notif-bell__badge { top: 2px; right: 14px; }
.notif-bell--rail .notif-bell__panel { top: var(--space-2); left: calc(100% + 8px); }

/* Panneau "Communautés" (ouvert depuis la barre de navigation) */

.community-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(46, 44, 38, 0.25);
  z-index: 44;
  opacity: 0;
  pointer-events: none;
  transition: opacity .55s cubic-bezier(.4, 0, .2, 1);
}
.community-panel-backdrop--open { opacity: 1; pointer-events: auto; transition-delay: .15s; }

.community-panel {
  position: fixed;
  top: 0;
  bottom: 0;
  left: 72px;
  width: 300px;
  max-width: calc(100vw - 72px);
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  box-shadow: var(--shadow-popover);
  z-index: 45;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateX(-14px);
  pointer-events: none;
  transition: opacity .6s cubic-bezier(.4, 0, .2, 1), transform .6s cubic-bezier(.4, 0, .2, 1);
}
.community-panel--open {
  opacity: 1;
  transform: translateX(0);
  transition-delay: .1s;
  pointer-events: auto;
}

.community-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4);
  border-bottom: 1px solid var(--color-border);
  font-weight: 650;
  font-size: var(--text-md);
}

.community-panel__explore {
  margin-left: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-accent-ink);
  text-decoration: none;
}
.community-panel__explore:hover { color: var(--color-accent-hover); }

.community-panel__close {
  background: none; border: none; cursor: pointer; color: var(--color-text-faint);
  display: flex; padding: var(--space-1);
}
.community-panel__close:hover { color: var(--color-text); }

.community-panel__body {
  padding: var(--space-4);
  overflow-y: auto;
}

.community-panel__loading {
  font-size: var(--text-sm);
  color: var(--color-text-faint);
}

/* Community list (sidebar nav) */

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

.community-list__item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  text-align: left;
  padding: var(--space-2) var(--space-3);
  border: none;
  background: transparent;
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  transition: background-color 120ms var(--ease-out);
}
.community-list__item:hover { background: var(--color-surface-sunk); color: var(--color-text); }
.community-list__item--active {
  background: var(--color-surface-accent);
  color: var(--color-accent-ink);
  font-weight: 600;
}
.community-list__item--pending { color: var(--color-text-faint); cursor: default; }
.community-list__item--pending:hover { background: transparent; }

.community-list__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.community-list__icon { color: var(--color-text-faint); flex-shrink: 0; display: flex; }
.community-list__item--active .community-list__icon { color: var(--color-accent-ink); }

.community-list__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.community-list__thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  object-fit: cover;
  flex-shrink: 0;
}
.community-list__thumb--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-accent-ink), var(--color-see-more));
  color: #fff;
}
.community-list__item--pending .community-list__thumb { opacity: 0.6; }

.community-list__text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.community-list__meta {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.community-list__role {
  flex-shrink: 0;
}

.community-list__pending-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid var(--color-text-faint);
  flex-shrink: 0;
}

.community-list__lock {
  color: var(--color-text-faint);
  flex-shrink: 0;
  display: flex;
}
.community-list__lock svg { width: 13px; height: 13px; }
.community-list__item--active .community-list__lock { color: var(--color-accent-ink); }

.community-list__create {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  color: var(--color-accent-ink);
  font-weight: 600;
  font-size: var(--text-base);
  text-decoration: none;
  border-radius: var(--radius-sm);
}
.community-list__create:hover { background: var(--color-surface-sunk); color: var(--color-accent-ink); }

/* Post card */

.post-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-5) var(--space-6);
  transition: box-shadow 160ms var(--ease-out);
}
.post-card:hover { box-shadow: var(--shadow-card-hover); }

.post-card__header {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-bottom: var(--space-3);
}

.post-card__top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.post-card__sub-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding-left: calc(34px + var(--space-2));
}

.post-card__author {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.post-card__author-name {
  font-weight: 600;
  font-size: var(--text-sm);
}

.post-card__job-title {
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.post-card__meta {
  color: var(--color-text-faint);
  font-size: var(--text-xs);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-shrink: 0;
  margin-left: auto;
}

.post-card__pin {
  margin-bottom: var(--space-3);
}
.post-card__pin svg { margin-right: 2px; vertical-align: -1px; }

.post-card__footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.post-card__last-reply {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.post-card__edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  color: var(--color-text-faint);
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.post-card__edit:hover { background: var(--color-surface-sunk); color: var(--color-accent-ink); }
.post-card__edit--delete:hover { background: rgba(176, 0, 32, 0.08); color: var(--color-error); }
.post-card__edit:disabled { opacity: 0.5; cursor: not-allowed; }

.post-card__title {
  font-size: var(--text-md);
  font-weight: 650;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-2);
}

.post-card__body {
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--color-text);
}
.post-card__body p { margin: 0 0 var(--space-3); }
.post-card__body p:last-child { margin-bottom: 0; }

.post-card__excerpt {
  position: relative;
}

.post-card__body--clamp {
  max-height: 8.3em;
  overflow: hidden;
}

.post-card__fade {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2.6em;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--color-surface));
  pointer-events: none;
}

.post-card__see-more {
  position: absolute;
  right: 0;
  bottom: 0;
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding-left: var(--space-2);
  background: var(--color-surface);
  color: var(--color-see-more);
  font-size: var(--text-sm);
  font-weight: 600;
}

.post-card--clickable { cursor: pointer; }
.post-card--clickable .post-card__comments,
.post-card--clickable .attachment-chip,
.post-card--clickable .post-card__edit { cursor: auto; }
.post-card__body a { color: var(--color-accent-ink); }
.post-card__body img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: var(--space-2) 0 var(--space-3);
  display: block;
}
.post-card__body h2, .editor-field .ql-editor h2 {
  font-size: var(--text-lg);
  font-weight: 650;
  letter-spacing: -0.01em;
  margin: var(--space-5) 0 var(--space-2);
}
.post-card__body h2:first-child, .editor-field .ql-editor h2:first-child { margin-top: 0; }
.post-card__body h3, .editor-field .ql-editor h3 {
  font-size: var(--text-md);
  font-weight: 650;
  margin: var(--space-4) 0 var(--space-2);
}
.post-card__body h3:first-child, .editor-field .ql-editor h3:first-child { margin-top: 0; }

.post-card__attachments {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-4);
}

.attachment-chip {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunk);
  text-decoration: none;
  color: var(--color-text);
  transition: border-color 120ms var(--ease-out), background-color 120ms var(--ease-out);
}
.attachment-chip:hover {
  background: var(--color-surface-accent);
  border-color: var(--color-accent);
  color: var(--color-text);
}
.attachment-chip__icon { color: var(--color-text-muted); display: flex; flex-shrink: 0; }
.attachment-chip__icon svg { width: 15px; height: 15px; }
.attachment-chip__name {
  flex: 1;
  font-size: var(--text-sm);
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.attachment-chip__size { font-size: var(--text-xs); color: var(--color-text-faint); flex-shrink: 0; }
.attachment-chip__download { color: var(--color-text-faint); display: flex; flex-shrink: 0; }
.attachment-chip:hover .attachment-chip__download { color: var(--color-accent-ink); }

/* Commentaires */

.post-card__comments {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-border);
}

.comment-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 550;
  padding: var(--space-1) var(--space-2);
  margin-left: calc(var(--space-2) * -1);
  border-radius: var(--radius-sm);
}
.comment-toggle:hover { background: var(--color-surface-sunk); color: var(--color-text); }

.comment-panel { margin-top: var(--space-4); }
.comment-panel__loading { color: var(--color-text-faint); font-size: var(--text-sm); }

.comment-list { display: flex; flex-direction: column; gap: var(--space-4); margin-bottom: var(--space-4); }

.comment-item {
  display: flex;
  gap: var(--space-3);
  position: relative;
}
.comment-item__body { flex: 1; }
.comment-item__head { display: flex; align-items: baseline; gap: var(--space-2); margin-bottom: 2px; }
.comment-item__author { font-weight: 600; font-size: var(--text-sm); }
.comment-item__time { font-size: var(--text-xs); color: var(--color-text-faint); }
.comment-item__text { margin: 0; font-size: var(--text-sm); line-height: 1.55; white-space: pre-wrap; }
.comment-item__delete {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-faint);
  padding: 4px;
  border-radius: var(--radius-sm);
  align-self: flex-start;
  opacity: 0;
  transition: opacity 120ms var(--ease-out);
}
.comment-item:hover .comment-item__delete { opacity: 1; }
.comment-item__delete:hover { color: var(--color-error); background: var(--color-surface-sunk); }

.comment-form { display: flex; gap: var(--space-2); align-items: flex-end; }
.comment-form__input { resize: none; min-height: 38px; max-height: 160px; }

.avatar--sm { width: 28px; height: 28px; font-size: 9px; flex-shrink: 0; }

/* Écran détail communauté */

.community-detail { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--space-6); }

.community-header__cover {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-radius: var(--radius-lg);
  margin-bottom: var(--space-4);
}
.community-header__cover--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-accent-ink), var(--color-see-more));
}

.community-access {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}
.community-access__icon { color: var(--color-text-muted); flex-shrink: 0; margin-top: 2px; }
.community-access__icon svg { width: 18px; height: 18px; display: block; }
.community-access__title { font-weight: 650; font-size: var(--text-sm); }
.community-access__desc { color: var(--color-text-muted); font-size: var(--text-sm); margin-top: 2px; }

.request-item { padding: var(--space-3) 0; border-top: 1px solid var(--color-border); }
.request-item:first-of-type { border-top: none; padding-top: 0; }
.request-item .request-row { padding: 0; border-top: none; }
.request-row__message {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  font-style: italic;
  margin-top: var(--space-2);
  padding-left: 44px;
}

.community-header { display: flex; flex-direction: column; gap: var(--space-3); }
.community-header__top { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-4); flex-wrap: wrap; }
.community-header__top > *:first-child { flex: 1 1 260px; min-width: 0; }
.community-header__actions { flex-wrap: wrap; }
.community-header__title-row { display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap; }
.community-header__name { font-size: var(--text-xl); font-weight: 650; letter-spacing: -0.01em; }
.community-header__desc { color: var(--color-text-muted); font-size: var(--text-base); max-width: 60ch; }
.community-header__meta { display: flex; align-items: center; gap: var(--space-2); color: var(--color-text-faint); font-size: var(--text-sm); }
.community-header__actions { display: flex; align-items: center; gap: var(--space-2); flex-shrink: 0; }

.lock-icon { display: inline-flex; }
.lock-icon svg { width: 11px; height: 11px; }

.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); padding: var(--space-5) var(--space-6); }
.card__title { font-size: var(--text-sm); font-weight: 650; margin-bottom: var(--space-4); display: flex; align-items: center; gap: var(--space-2); }
.card__title svg { width: 15px; height: 15px; flex-shrink: 0; }

.request-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) 0; border-top: 1px solid var(--color-border); }
.request-row:first-of-type { border-top: none; padding-top: 0; }
.request-row__name { font-weight: 600; font-size: var(--text-sm); }
.request-row__sub { font-size: var(--text-xs); color: var(--color-text-faint); }
.request-row__actions { margin-left: auto; display: flex; gap: var(--space-2); }

.members-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-1) var(--space-4); }
.member-row { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-2) 0; }
.member-row__name { font-size: var(--text-sm); font-weight: 550; }
.member-row__role { font-size: var(--text-xs); color: var(--color-text-faint); }

.detail-main {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: var(--space-8) 0 var(--space-12);
  animation: contentFadeIn .4s cubic-bezier(.4, 0, .2, 1);
  transition: opacity .28s cubic-bezier(.4, 0, .2, 1), transform .28s cubic-bezier(.4, 0, .2, 1);
}



/* Badge */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: 650;
  background: var(--color-surface-accent);
  color: var(--color-accent-ink);
  white-space: nowrap;
}

/* Buttons & inputs */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-xl);
  border: 1px solid transparent;
  background: var(--color-accent);
  color: #fff;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow-card);
  text-decoration: none;
  transition: background-color 120ms var(--ease-out), transform 120ms var(--ease-out);
}
.btn:hover { background: var(--color-accent-hover);color: #fff; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn--sm { height: 32px; padding: 0 var(--space-3); font-size: var(--text-xs); border-radius: var(--radius-full); }

.status-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: 40px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-xl);
  border: 1px solid var(--color-border);
  background: var(--color-surface-sunk);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
}
.status-pill--block { width: 100%; }

.btn--secondary {
  background: var(--color-surface);
  color: var(--color-text);
  border-color: var(--color-border-strong);
}
.btn--secondary:hover { background: var(--color-surface-sunk); }

.btn--ghost {
  background: transparent;
  color: var(--color-text-muted);
  border-color: transparent;
}
.btn--ghost:hover { background: var(--color-surface-sunk); color: var(--color-text); }

.input, textarea.input {
  width: 100%;
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-strong);
  background: var(--color-surface);
  color: var(--color-text);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  transition: border-color 120ms var(--ease-out);
}
/* Dropzone & file list (création / édition de post) */

.dropzone {
  border: 1.5px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  padding: var(--space-8) var(--space-4);
  text-align: center;
  cursor: pointer;
  transition: border-color 120ms var(--ease-out), background-color 120ms var(--ease-out);
}
.dropzone:hover, .dropzone--drag { border-color: var(--color-accent); background: var(--color-surface-accent); }
.dropzone__icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--color-surface-sunk);
  display: grid;
  place-items: center;
  margin: 0 auto var(--space-3);
  color: var(--color-text-muted);
}
.dropzone__icon svg { width: 16px; height: 16px; }
.dropzone__label { font-weight: 600; font-size: var(--text-sm); }
.dropzone__hint { font-size: var(--text-xs); color: var(--color-text-faint); margin-top: var(--space-1); }

.file-list { display: flex; flex-direction: column; gap: var(--space-2); margin-top: var(--space-3); }
.file-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-sunk);
  font-size: var(--text-sm);
}
.file-item__icon { color: var(--color-text-muted); display: flex; flex-shrink: 0; }
.file-item__icon svg { width: 14px; height: 14px; }
.file-item__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-item__size { color: var(--color-text-faint); font-size: var(--text-xs); }
.file-item__remove {
  background: none; border: none; cursor: pointer; color: var(--color-text-faint);
  display: flex; padding: 2px;
}
.file-item__remove:hover { color: var(--color-error); }

/* Dialogue d'insertion de lien (éditeur riche) */

.link-dialog-overlay {
  position: fixed;
  inset: 0;
  background: var(--color-text);
  background: rgba(46, 44, 38, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.link-dialog {
  width: 100%;
  max-width: 380px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
}

.link-dialog__title {
  font-size: var(--text-md);
  font-weight: 650;
  letter-spacing: -0.01em;
  margin-bottom: var(--space-4);
}

.link-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-5);
}

.input::placeholder { color: var(--color-text-faint); }
.input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(27, 41, 63, 0.15);
}

/* Dialogue de transfert vers un collègue */

.share-dialog {
  width: 100%;
  max-width: 440px;
  max-height: 85vh;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-popover);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overflow-y: auto;
}

.share-dialog__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.share-dialog__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-1);
}

.share-dialog__close {
  background: none; border: none; cursor: pointer; color: var(--color-text-faint);
  font-size: 1.3rem; line-height: 1; padding: 0 2px; flex-shrink: 0;
}
.share-dialog__close:hover { color: var(--color-text); }

.share-dialog__hint {
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.share-dialog__selected {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.share-dialog__selected:empty { display: none; }

.share-dialog__chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--color-surface-accent);
  color: var(--color-accent-ink);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
}
.share-dialog__chip button {
  background: none; border: none; cursor: pointer; color: inherit;
  font-size: 0.9rem; line-height: 1; padding: 0;
}

.share-dialog__results {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 200px;
  overflow-y: auto;
}

.share-dialog__result {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: var(--space-2);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-family: var(--font-sans);
}
.share-dialog__result:hover { background: var(--color-surface-sunk); }
.share-dialog__result--selected { background: var(--color-surface-accent); }

.share-dialog__result-name {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text);
}
.share-dialog__result-job {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-text-faint);
}

.share-dialog__empty {
  font-size: var(--text-sm);
  color: var(--color-text-faint);
  padding: var(--space-2);
}

.share-dialog__message {
  resize: vertical;
  min-height: 44px;
  font-family: var(--font-sans);
}

.share-dialog__actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.share-dialog__tabs {
  display: flex;
  gap: 2px;
  background: var(--color-surface-sunk);
  border-radius: var(--radius-full);
  padding: 3px;
}

.share-dialog__tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  background: none;
  border: none;
  border-radius: var(--radius-full);
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
}
.share-dialog__tab:hover { color: var(--color-text); }
.share-dialog__tab--active {
  color: var(--color-text);
  background: var(--color-surface);
  box-shadow: var(--shadow-xs);
}

.share-dialog__panel {
  flex-direction: column;
  gap: var(--space-3);
}
.share-dialog__panel:not([hidden]) { display: flex; }

.share-dialog__link-row {
  display: flex;
  gap: var(--space-2);
}
.share-dialog__link-row .input { flex: 1; min-width: 0; }
.share-dialog__link-row .btn { flex-shrink: 0; }


/* Ajustements mobile (regroupés en fin de fichier pour gagner la cascade) */
@media (max-width: 780px) {
  .topbar__brand-subtitle { display: none; }

  body { padding-left: 0; padding-bottom: 60px; }

  .app-sidebar { display: none; }

  .page-body { display: block; }

  .feed { padding: var(--space-5) var(--space-4) var(--space-8); }

  .topbar { padding: 0 var(--space-4); }
  .topbar__user-name { display: none; }
  .account-trigger__name { display: none; }
  .topbar__user > .notif-bell { display: none; }
  .topbar__search { display: none; }
  .app-shell .topbar__search {
    display: block;
    margin-left: var(--space-2);
    max-width: none;
    min-width: 0;
    flex: 1 1 0%;
  }
  .app-shell .topbar__write { margin-left: 0; }
  .app-shell .topbar__brand-name { display: none; }
  .app-shell .topbar__brand { gap: 0; }
  .topbar__write span { display: none; }
  .topbar__write { padding: 0 var(--space-3); margin-left: auto; }
  .topbar__user { gap: var(--space-2); margin-left: var(--space-2); }

  .account-trigger { padding: 4px 6px 4px 4px; gap: 2px; }
  .avatar { width: 38px; height: 38px; font-size: 12px; }

  .app-rail {
    display: flex;
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    height: 60px;
    flex-direction: row;
    justify-content: space-around;
    align-items: stretch;
    padding: var(--space-1) 0 max(var(--space-1), env(safe-area-inset-bottom));
    background: var(--color-surface);
    border-right: none;
    border-top: 1px solid var(--color-border);
    z-index: 50;
    overflow: visible;
  }
  .app-rail__item, .notif-bell--rail { width: auto; flex: 1; }
  .notif-bell--rail { display: flex; }
  .app-rail__item, .notif-bell--rail .notif-bell__trigger { border-left: none; border-top: 3px solid transparent; }
  .app-rail__item--active, .notif-bell--rail .notif-bell__trigger[aria-expanded="true"] { border-top-color: var(--color-see-more); }

  .community-panel-backdrop { z-index: 44; }
  .community-panel {
    top: auto;
    left: 0;
    right: 0;
    bottom: 60px;
    width: auto;
    max-width: 100%;
    max-height: 65vh;
    border-right: none;
    border-top: 1px solid var(--color-border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    transform: translateY(16px);
  }
  .community-panel--open { transform: translateY(0); }
  .notif-bell--rail .notif-bell__panel {
    top: auto;
    left: auto;
    right: 0;
    bottom: calc(100% + 8px);
    transform: translateY(6px) scale(.98);
  }
  .notif-bell--rail .notif-bell__panel.notif-bell__panel--open { transform: translateY(0) scale(1); }

  .detail-main { padding: var(--space-5) var(--space-4) var(--space-8); }
  .community-header__top { flex-direction: column; align-items: stretch; }
  .community-header__actions { width: 100%; }
  .community-header__actions .btn { flex: 1; justify-content: center; }
  .members-grid { grid-template-columns: 1fr; }
  .request-row { flex-wrap: wrap; }
  .request-row__actions { margin-left: 0; width: 100%; justify-content: flex-end; margin-top: var(--space-2); }

  .link-dialog-overlay { padding: var(--space-4); }
  .share-dialog, .link-dialog { max-width: 100%; }
}
