/* ===== Base ===== */
:root {
  --bg: #f1f5f9;
  --panel: #ffffff;
  --column: #e8edf3;
  --ink: #1e293b;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --border: #d7dee8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }
.container { max-width: 960px; margin: 0 auto; padding: 1.5rem 1rem; width: 100%; }
.board-main { padding: 1rem; overflow-x: auto; }

h1 { font-size: 1.4rem; margin: 0 0 .5rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0; }
h4 { font-size: .85rem; margin: 0 0 .5rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }

a { color: var(--accent); }
.muted { color: var(--muted); }
code { background: #eef2f7; padding: .1em .35em; border-radius: 4px; font-size: .95em; }

.site-footer {
  text-align: center; padding: .8rem; font-size: .8rem; color: var(--muted);
}
.site-footer a { color: var(--muted); }

/* ===== Boutons, formulaires ===== */
.btn {
  display: inline-block; border: none; cursor: pointer; text-decoration: none;
  background: var(--accent); color: var(--accent-ink);
  padding: .5rem .9rem; border-radius: 8px; font-size: .9rem; font-weight: 600;
}
.btn:hover { filter: brightness(1.1); }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); }
.icon-btn {
  border: none; background: transparent; cursor: pointer; color: var(--muted);
  font-size: .9rem; padding: .2rem .4rem; border-radius: 6px;
}
.icon-btn:hover { background: rgba(0,0,0,.07); color: var(--ink); }

input, textarea, select {
  font: inherit; color: inherit;
  padding: .5rem .6rem; border: 1px solid var(--border); border-radius: 8px;
  background: var(--panel); width: 100%;
}
textarea { resize: vertical; }
label { font-size: .85rem; font-weight: 600; display: block; }
.stack { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }
.inline-form { display: flex; gap: .5rem; align-items: center; }
.inline-form input { flex: 1; }
.inline-fields { display: flex; gap: 1rem; flex-wrap: wrap; }
.inline-fields label { flex: 1; min-width: 200px; }
.inline { display: inline; }
.grow { flex: 1; }
.code-area, .code-input { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }

/* ===== Messages ===== */
.msg { padding: .6rem .9rem; border-radius: 8px; font-size: .9rem; }
.msg-error { background: #fee2e2; color: #991b1b; }
.msg-warning { background: #fef3c7; color: #92400e; }
.msg-success { background: #dcfce7; color: #166534; }

/* ===== Écrans d'accès ===== */
.join-card {
  max-width: 400px; margin: 8vh auto 0; background: var(--panel);
  padding: 2rem; border-radius: var(--radius); box-shadow: var(--shadow);
  text-align: center;
}
.join-card .code-input { text-align: center; font-size: 1.2rem; letter-spacing: .15em; }
.pin-input { letter-spacing: .5em; }
.who-grid { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin: 1rem 0; }
.btn-who { font-size: 1rem; }

/* ===== Panneaux (dashboard, snippets) ===== */
.panel {
  background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 1rem 1.25rem; margin-bottom: 1rem;
}
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; }
.board-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.board-tile { display: flex; flex-direction: column; }
.board-tile.archived { opacity: .6; }
.board-tile-sub { margin: .1rem 0 .5rem; }
.board-tile-actions { margin-top: auto; padding-top: .3rem; }
.dash-section { margin-bottom: 1.8rem; }
.dash-section-title { font-size: 1.05rem; margin: 0 0 .8rem; padding-bottom: .35rem; border-bottom: 2px solid var(--border); }
.member-chips { display: flex; flex-wrap: wrap; gap: .3rem; margin: 0 0 .7rem; }
.chip-name { background: var(--column); color: var(--ink); border-radius: 999px; padding: .12rem .55rem; font-size: .78rem; }
.chip-name.inactive { opacity: .55; text-decoration: line-through; }
.board-tile-empty { margin: 0 0 .7rem; }
.access-code { font-size: 1.3rem; letter-spacing: .12em; }
.member-table { width: 100%; border-collapse: collapse; font-size: .9rem; margin-bottom: 1rem; }
.member-table th, .member-table td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--border); }
.member-table tr.inactive td { opacity: .5; }
.row-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.pin-recap { background: #fef9c3; border: 1px solid #fde047; border-radius: 8px; padding: .75rem 1rem; margin-bottom: 1rem; }
.pin-recap table { border-collapse: collapse; }
.pin-recap td, .pin-recap th { padding: .2rem .8rem .2rem 0; text-align: left; }
.pin-flash { background: #fef9c3; padding: .1rem .4rem; border-radius: 6px; font-size: .85rem; }
.activity-line { margin: .25rem 0; font-size: .9rem; }
.danger-zone { border: 1px solid #fecaca; }
.badge {
  display: inline-block; background: var(--column); color: var(--muted);
  border-radius: 999px; padding: .15rem .6rem; font-size: .78rem; font-weight: 600;
}
.badge-prof { background: var(--accent); color: var(--accent-ink); }

/* ===== En-tête de tableau ===== */
.board-header {
  display: flex; justify-content: space-between; align-items: center; gap: 1rem;
  padding: .6rem 1rem; background: var(--panel); box-shadow: var(--shadow);
}
.board-header-left, .board-header-right { display: flex; align-items: center; gap: .8rem; }
.tabs { display: flex; gap: .2rem; }
.tab { padding: .3rem .7rem; border-radius: 8px; text-decoration: none; color: var(--muted); font-size: .9rem; }
.tab.active { background: var(--column); color: var(--ink); font-weight: 600; }

/* ===== Colonnes et cartes ===== */
.columns {
  display: flex; gap: .8rem; align-items: flex-start; min-height: 70vh;
}
.column {
  background: var(--column); border-radius: var(--radius); padding: .5rem;
  width: 280px; flex-shrink: 0; display: flex; flex-direction: column; gap: .5rem;
}
.column-add { background: transparent; border: 2px dashed var(--border); }
.column-add summary { cursor: pointer; color: var(--muted); font-size: .9rem; padding: .3rem; list-style: none; }
.column-header { display: flex; align-items: center; gap: .4rem; padding: .2rem .3rem; cursor: grab; }
.column-header h3 { flex: 1; cursor: pointer; font-size: .95rem; padding: .15rem .3rem; border-radius: 6px; }
.column-header h3:hover { background: rgba(0,0,0,.06); }
.column-header .count { color: var(--muted); font-size: .8rem; }
.cards { display: flex; flex-direction: column; gap: .5rem; min-height: 8px; }
.card-item {
  background: var(--panel); border-radius: 8px; box-shadow: var(--shadow);
  padding: .55rem .65rem; cursor: pointer;
}
.card-item:hover { outline: 2px solid var(--accent); outline-offset: -1px; }
.sortable-ghost { opacity: .4; }
.card-title { margin: 0; font-size: .9rem; overflow-wrap: anywhere; }
.card-labels { display: flex; flex-wrap: wrap; gap: .25rem; margin-bottom: .35rem; }
.label-pill {
  color: #fff; font-size: .68rem; font-weight: 700; padding: .1rem .5rem;
  border-radius: 999px; white-space: nowrap;
}
.card-meta { display: flex; align-items: center; gap: .5rem; margin-top: .45rem; font-size: .75rem; color: var(--muted); }
.card-meta .spacer { flex: 1; }
.avatar {
  background: var(--accent); color: var(--accent-ink); font-size: .68rem; font-weight: 700;
  border-radius: 50%; width: 1.5rem; height: 1.5rem; display: inline-flex;
  align-items: center; justify-content: center; text-transform: uppercase;
}
.card-add summary { cursor: pointer; color: var(--muted); font-size: .85rem; padding: .2rem .3rem; list-style: none; }
.card-add summary:hover { color: var(--ink); }

/* ===== Modale carte ===== */
dialog#modal {
  border: none; border-radius: 14px; box-shadow: 0 12px 44px rgba(15,23,42,.32);
  padding: 0; width: min(1180px, 95vw); max-height: 90vh; overflow: hidden;
}
dialog#modal::backdrop { background: rgba(15, 23, 42, .5); }
.modal-inner {
  display: flex; flex-direction: column;
  padding: 1.1rem 1.3rem 0; max-height: 90vh; overflow: hidden;
}
.modal-header { flex: 0 0 auto; display: flex; align-items: flex-start; gap: .5rem; }
.modal-title {
  font-size: 1.25rem; font-weight: 800; border-color: transparent; background: transparent;
  padding: .2rem .35rem;
}
.modal-title:hover { background: var(--column); }
.modal-title:focus { background: var(--panel); border-color: var(--accent); }
.modal-close { font-size: 1.05rem; }
.modal-sub { flex: 0 0 auto; margin: .1rem 0 1rem .4rem; font-size: .82rem; }

/* Chaque colonne défile indépendamment ; l'en-tête reste fixe en haut */
.modal-grid {
  flex: 1 1 auto; min-height: 0;
  display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 0;
}
.modal-main { min-width: 0; min-height: 0; overflow-y: auto; padding: 0 1.6rem 1.2rem 0; }
.modal-aside {
  min-width: 0; min-height: 0; overflow-y: auto;
  border-left: 1px solid var(--border); padding: 0 0 1.2rem 1.5rem;
}
.aside-title { margin-bottom: .7rem; }
/* Écrans moyens : colonnes de largeurs égales, pour que la zone de gauche
   ne devienne jamais plus étroite que celle des commentaires */
@media (max-width: 960px) {
  .modal-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
}
@media (max-width: 760px) {
  /* En pile (mobile) : on revient à un défilement unique de la carte */
  .modal-inner { display: block; overflow-y: auto; padding-bottom: 1.4rem; }
  .modal-grid { grid-template-columns: 1fr; }
  .modal-main, .modal-aside { overflow: visible; min-height: 0; }
  .modal-main { padding: 0; }
  .modal-aside {
    border-left: none; border-top: 1px solid var(--border);
    padding: 1rem 0 0; margin-top: .5rem;
  }
}

/* Encadrés de section */
.box {
  border: 1px solid var(--border); border-radius: 12px; background: var(--panel);
  padding: .85rem 1rem; margin-bottom: 1rem;
}
.box-head { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .55rem; }
.box-head h4 { margin: 0; }
.small { font-size: .85rem; }
.empty-hint {
  border: none; background: var(--column); color: var(--muted); cursor: pointer;
  text-align: left; width: 100%; padding: .5rem .7rem; border-radius: 8px; font-size: .88rem;
}
.empty-hint:hover { background: #dde5ef; }

/* Bloc méta (membres / étiquettes / échéance) */
.meta-row { display: flex; flex-wrap: wrap; gap: .9rem 1.6rem; margin-bottom: 1rem; }
.meta-block { display: flex; flex-direction: column; gap: .35rem; }
.meta-label { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.meta-inline { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; min-height: 1.9rem; }
.avatar-row { display: inline-flex; gap: .25rem; }
.pill-row { display: inline-flex; flex-wrap: wrap; gap: .3rem; }
.due-input { width: auto; padding: .35rem .5rem; }

/* Popovers (details) */
.pop { position: relative; }
.pop > summary { list-style: none; cursor: pointer; }
.pop > summary::-webkit-details-marker { display: none; }
.mini-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 1.7rem; height: 1.7rem; border-radius: 7px; border: 1px dashed var(--border);
  background: var(--column); color: var(--muted); font-size: 1.05rem; line-height: 1;
}
.mini-btn:hover { color: var(--ink); border-color: var(--muted); }
.pop-panel {
  position: absolute; z-index: 40; top: calc(100% + 5px); left: 0;
  width: 260px; max-height: 340px; overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 10px 28px rgba(15,23,42,.2); padding: .7rem;
}
.pop-right .pop-panel { left: auto; right: 0; }
.pop-title { font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); text-align: center; margin-bottom: .5rem; }
.picker-row {
  display: flex; align-items: center; gap: .5rem; width: 100%; text-align: left;
  border: none; background: transparent; cursor: pointer; padding: .3rem; border-radius: 8px;
}
.picker-row:hover { background: var(--column); }
.picker-swatch { flex: 1; }
.picker-avatar { display: flex; align-items: center; gap: .5rem; flex: 1; }
.picker-check { color: var(--accent); font-weight: 800; }
.pop-add { display: flex; flex-direction: column; gap: .4rem; margin-top: .6rem; border-top: 1px solid var(--border); padding-top: .6rem; }

/* Code lié */
.code-link { display: flex; align-items: center; gap: .5rem; padding: .4rem .5rem; border-radius: 8px; text-decoration: none; color: var(--ink); }
.code-link:hover { background: var(--column); }
.code-link-title { flex: 1; overflow-wrap: anywhere; }

/* Checklists */
.checklist { margin-top: 1rem; }
.checklist:first-of-type { margin-top: .3rem; }
.checklist-head { display: flex; align-items: center; gap: .4rem; }
.cl-title-wrap { display: inline-flex; align-items: center; gap: .4rem; flex: 1; min-width: 0; }
.cl-icon { color: var(--muted); }
.cl-title { cursor: pointer; padding: .1rem .35rem; border-radius: 6px; }
.cl-title:hover { background: var(--column); }
.cl-progress { display: flex; align-items: center; gap: .5rem; margin: .45rem 0; }
.cl-percent { font-size: .72rem; color: var(--muted); width: 2.6rem; }
.cl-bar { flex: 1; height: 8px; background: var(--column); border-radius: 999px; overflow: hidden; }
.cl-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .2s ease; }
.cl-bar-fill.full { background: #0ea472; }
.cl-items { list-style: none; padding: 0; margin: .3rem 0 0; display: flex; flex-direction: column; }
.cl-item { display: flex; align-items: center; gap: .5rem; padding: .2rem; border-radius: 6px; }
.cl-item:hover { background: var(--column); }
.cl-item:hover .cl-del { opacity: 1; }
.cl-check { border: none; background: transparent; cursor: pointer; font-size: 1.1rem; line-height: 1; color: var(--accent); padding: 0; }
.cl-item.done .cl-text { text-decoration: line-through; color: var(--muted); }
.cl-text { flex: 1; cursor: pointer; font-size: .9rem; padding: .2rem .25rem; border-radius: 4px; overflow-wrap: anywhere; }
.cl-text:hover { background: #dde5ef; }
.cl-del { opacity: 0; }
.cl-add { display: flex; gap: .4rem; margin-top: .5rem; }
.cl-add input { flex: 1; }
.cl-edit { display: flex; gap: .4rem; align-items: center; width: 100%; }
.cl-edit input { flex: 1; }

/* Commentaires (colonne de droite, compacts) */
.comment-form { display: flex; flex-direction: column; gap: .4rem; margin-bottom: .9rem; }
.comment-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .7rem; }
.comment { display: flex; gap: .5rem; }
.comment-avatar { flex-shrink: 0; }
.comment-body { flex: 1; min-width: 0; }
.comment-head { display: flex; align-items: center; gap: .4rem; font-size: .8rem; margin-bottom: .2rem; }
.comment-head .cmt-del { margin-left: auto; }
.md-comment { font-size: .88rem; background: var(--panel); border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; }
.comment-empty { padding: .2rem 0; }

/* ===== Markdown et code ===== */
.md { font-size: .92rem; line-height: 1.5; overflow-wrap: anywhere; }
.md p { margin: .4rem 0; }
.md pre { margin: .5rem 0; }
.codehilite { position: relative; border-radius: 8px; overflow: auto; }
.codehilite pre { margin: 0; padding: .75rem 1rem; font-size: .85rem; }
.code-copy {
  position: absolute; top: .4rem; right: .4rem; font-size: .72rem;
  border: none; border-radius: 6px; padding: .2rem .5rem; cursor: pointer;
  background: rgba(255,255,255,.85); color: var(--ink);
}
.snippet-code .codehilite pre { font-size: .9rem; }
.snippet-tile h3 a { text-decoration: none; color: var(--ink); }

/* Description repliable */
.md-wrap { position: relative; }
.md-wrap.collapsed .md {
  max-height: 8.5em; overflow: hidden;
  -webkit-mask-image: linear-gradient(#000 60%, transparent);
  mask-image: linear-gradient(#000 60%, transparent);
}
.md-toggle { margin-top: .5rem; border: none; background: transparent; color: var(--accent); font-weight: 600; cursor: pointer; font-size: .85rem; padding: 0; }
.md-toggle:hover { text-decoration: underline; }

/* Badge checklist terminée sur la carte */
.meta-done { color: #0ea472; font-weight: 600; }

/* ===== Barres de défilement fines ===== */
* { scrollbar-width: thin; scrollbar-color: #c3ccd8 transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #c3ccd8; border-radius: 8px; }
::-webkit-scrollbar-thumb:hover { background: #a8b3c2; }
::-webkit-scrollbar-track { background: transparent; }

/* ===== Divers ===== */
.prose { background: var(--panel); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.5rem 2rem; }
.prose li { margin: .3rem 0; }
details > summary::-webkit-details-marker { display: none; }
