/* Mise en page : un tableau de tâches par groupes, lignes modifiables sur place ; sur téléphone chaque ligne devient une fiche. */
:root {
  --bg: #f3f5f6;
  --surface: #ffffff;
  --line: #dde3e6;
  --fg: #17242a;
  --muted: #5d6c73;
  --accent: #4a4fb5;
  --accent-fg: #ffffff;
  --accent-soft: #e6e7f7;
  --rail: #2f3070; --rail-fg: #cfd0f2; --rail-on: #ffffff; --badge: #c4314b; --badge-fg: #ffffff;
  --todo-bg: #e6eaec;   --todo-fg: #3d4b52;
  --doing-bg: #fde9c2;  --doing-fg: #7a4a00;
  --blocked-bg: #fbdada; --blocked-fg: #8f1d1d;
  --done-bg: #d5efdc;   --done-fg: #17603a;
  --danger: #b3261e;
  --font-display: "Space Grotesk", "Segoe UI", system-ui, sans-serif;
  --font-body: "Inter", "Segoe UI", system-ui, sans-serif;
  --radius: 8px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #11181b; --surface: #1a2327; --line: #2d3a40; --fg: #e8eef0; --muted: #9aaab1;
    --accent: #a3a7ff; --accent-fg: #14153a; --accent-soft: #2b2d58;
    --rail: #1a1b38; --rail-fg: #b9bbe6;
    --todo-bg: #2c373c; --todo-fg: #c9d4d8;
    --doing-bg: #4a3608; --doing-fg: #ffd68a;
    --blocked-bg: #4d1c1c; --blocked-fg: #ffb4b4;
    --done-bg: #173d27; --done-fg: #a6e6bd;
    --danger: #ff8a80;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #11181b; --surface: #1a2327; --line: #2d3a40; --fg: #e8eef0; --muted: #9aaab1;
  --accent: #a3a7ff; --accent-fg: #14153a; --accent-soft: #2b2d58;
    --rail: #1a1b38; --rail-fg: #b9bbe6;
  --todo-bg: #2c373c; --todo-fg: #c9d4d8;
  --doing-bg: #4a3608; --doing-fg: #ffd68a;
  --blocked-bg: #4d1c1c; --blocked-fg: #ffb4b4;
  --done-bg: #173d27; --done-fg: #a6e6bd;
  --danger: #ff8a80;
  color-scheme: dark;
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--fg);
  font-family: var(--font-body); font-size: 15px; line-height: 1.45;
}
html, body { height: 100%; }
.app { display: grid; grid-template-columns: 96px minmax(0, 1fr); min-height: 100%; }
.wrap {
  width: 100%; max-width: 1180px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; min-width: 0;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 24px 48px;
}
.rail { background: var(--rail); color: var(--rail-fg); padding: 12px 8px; padding-left: max(8px, env(safe-area-inset-left, 0px)); }
.rail-in { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 12px); display: flex; flex-direction: column; gap: 4px; }
.rail-btn {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  font: inherit; font-size: .72rem; font-weight: 600; line-height: 1.2; color: var(--rail-fg);
  background: transparent; border: 0; border-radius: 10px; padding: 10px 4px; cursor: pointer;
}
.rail-btn svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.rail-btn:hover { background: rgba(255, 255, 255, .08); }
.rail-btn[aria-pressed="true"] { background: rgba(255, 255, 255, .16); color: var(--rail-on); }
.rail :focus-visible { outline-color: var(--rail-on); }
.badge { position: absolute; top: 4px; right: 12px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--badge); color: var(--badge-fg); font-size: .7rem; line-height: 18px; }
.me { margin-top: 12px; display: flex; flex-direction: column; gap: 4px; font-size: .68rem; text-align: center; }
.me select { width: 100%; font: inherit; font-size: .75rem; font-weight: 600; color: var(--rail-on); background: rgba(255, 255, 255, .12); border: 0; border-radius: 6px; padding: 5px 2px; text-align: center; text-align-last: center; }
.me strong { color: var(--rail-on); font-size: .78rem; overflow-wrap: anywhere; }

#chat { display: grid; grid-template-columns: 210px minmax(0, 1fr); gap: 12px; align-items: start; }
.channels { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.channels h2 { margin: 0; font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.chan-list { display: flex; flex-direction: column; gap: 2px; }
.chan { font: inherit; text-align: left; border: 0; background: transparent; color: var(--fg); padding: 7px 10px; border-radius: 6px; cursor: pointer; overflow-wrap: anywhere; }
.chan:hover { background: var(--bg); }
.chan[aria-pressed="true"] { background: var(--accent-soft); font-weight: 600; }
.chan-form { display: flex; gap: 6px; }
.chan-form input { flex: 1; min-width: 0; font: inherit; font-size: .88rem; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px; }
.convo { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; min-width: 0; }
.convo-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; }
.convo-head strong { font-family: var(--font-display); font-size: 1.05rem; }
.msgs { height: min(60vh, 620px); min-height: 280px; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.day-sep { align-self: center; font-size: .75rem; color: var(--muted); padding: 2px 10px; }
.msg { display: flex; gap: 8px; align-items: flex-start; max-width: min(640px, 92%); }
.msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.avatar { flex: 0 0 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: .85rem; background: var(--accent); color: var(--accent-fg); }
.avatar.av-b { background: var(--done-bg); color: var(--done-fg); }
.bubble { background: var(--bg); border-radius: 8px; padding: 8px 12px; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.msg.mine .bubble { background: var(--accent-soft); }
.msg-head { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; font-size: .8rem; }
.msg-head span { color: var(--muted); font-size: .75rem; font-variant-numeric: tabular-nums; }
.msg-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-text a, .file a, .hint a { color: var(--accent); }
.file { display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--line); background: var(--surface); border-radius: 6px; padding: 8px; }
.file img { max-height: 220px; border-radius: 4px; object-fit: contain; align-self: flex-start; }
.file-row { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: .85rem; }
.file-name { font-weight: 600; overflow-wrap: anywhere; }
.file-size { color: var(--muted); }
.link { font: inherit; font-size: .8rem; color: var(--accent); background: transparent; border: 0; padding: 0; cursor: pointer; text-decoration: underline; align-self: flex-start; }
.link.danger { color: var(--danger); }
.convo .notice { margin: 0 12px 8px; }
.composer { display: flex; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--line); }
.composer textarea { flex: 1; min-width: 0; font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; resize: none; min-height: 40px; max-height: 140px; }

#cal { display: flex; flex-direction: column; gap: 16px; }
.cal-title { font-family: var(--font-display); font-size: 1.1rem; min-width: 150px; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cal-dow { background: var(--surface); padding: 6px 2px; font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); text-align: center; }
.cal-cell { background: var(--surface); min-height: 96px; padding: 4px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-cell.out { background: var(--bg); }
.cal-num { align-self: flex-start; font: inherit; font-size: .8rem; font-variant-numeric: tabular-nums; width: 26px; height: 26px; border-radius: 50%; border: 0; background: transparent; color: var(--fg); cursor: pointer; padding: 0; }
.cal-num:hover { background: var(--accent-soft); }
.cal-cell.today .cal-num { background: var(--accent); color: var(--accent-fg); font-weight: 600; }
.cal-chip { font: inherit; font-size: .74rem; text-align: left; border: 0; border-radius: 4px; padding: 2px 6px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: var(--accent-soft); color: var(--fg); min-width: 0; }
.cal-chip.task { background: var(--doing-bg); color: var(--doing-fg); }
.cal-more { font-size: .7rem; color: var(--muted); padding-left: 4px; }

@media (max-width: 720px) {
  .app { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .rail { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; padding: 6px max(8px, env(safe-area-inset-right, 0px)) 6px max(8px, env(safe-area-inset-left, 0px)); }
  .rail-in { position: static; flex-direction: row; align-items: stretch; }
  .rail-btn { flex: 1 1 0; min-width: 0; padding: 6px 2px; font-size: .64rem; }
  .me { margin-top: 0; flex: 0 0 76px; justify-content: center; }
  #chat { grid-template-columns: minmax(0, 1fr); }
  .chan-list { flex-direction: row; flex-wrap: wrap; }
  .cal-cell { min-height: 54px; padding: 2px; }
  .cal-chip { font-size: 0; height: 7px; padding: 0; }
  .cal-more { display: none; }
}
h1 { font-family: var(--font-display); font-size: 1.7rem; font-weight: 600; margin: 0; text-wrap: balance; }
.top { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 24px; }
.top p { margin: 4px 0 0; color: var(--muted); }
.summary { display: flex; flex-wrap: wrap; gap: 8px; font-variant-numeric: tabular-nums; }
.pill { padding: 4px 10px; border-radius: 999px; font-size: .82rem; font-weight: 600; white-space: nowrap; }
.pill.todo { background: var(--todo-bg); color: var(--todo-fg); }
.pill.doing { background: var(--doing-bg); color: var(--doing-fg); }
.pill.blocked { background: var(--blocked-bg); color: var(--blocked-fg); }
.pill.done { background: var(--done-bg); color: var(--done-fg); }
.pill.late { background: transparent; color: var(--danger); border: 1px solid currentColor; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font: inherit; font-size: .88rem; font-weight: 500; cursor: pointer;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); color: var(--fg);
}
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.spacer { flex: 1 1 auto; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .88rem; cursor: pointer; }
.btn {
  font: inherit; font-size: .88rem; font-weight: 500; cursor: pointer;
  padding: 7px 12px; border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface); color: var(--fg);
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.danger { color: var(--danger); }
.btn:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.notice { padding: 10px 14px; border-radius: var(--radius); background: var(--doing-bg); color: var(--doing-fg); font-size: .9rem; }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

#board { display: flex; flex-direction: column; gap: 24px; }
.group { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.group-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.group-name {
  font-family: var(--font-display); font-size: 1.1rem; font-weight: 600; color: var(--accent);
  background: transparent; border: 1px solid transparent; border-radius: 6px; padding: 2px 6px; margin-left: -6px;
  min-width: 0; flex: 0 1 280px;
}
.group-name:hover, .group-name:focus { border-color: var(--line); background: var(--surface); }
.group-count { color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.group-del { margin-left: auto; padding: 4px 8px; font-size: .8rem; }

.table { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.cols, .row {
  display: grid; align-items: center; gap: 8px;
  grid-template-columns: minmax(0, 1fr) 132px 118px 142px 112px 40px;
  padding: 6px 10px;
}
.cols { font-size: .72rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); padding-block: 8px; }
.row { border-bottom: 1px solid var(--line); }
.row.is-done .t-title { color: var(--muted); text-decoration: line-through; }
.row input, .row select, .add input {
  font: inherit; color: var(--fg); min-width: 0; width: 100%;
  border: 1px solid transparent; border-radius: 6px; background: transparent; padding: 6px 8px;
}
.row input:hover, .row select:hover, .row input:focus, .add input:focus { border-color: var(--line); }
.row select { appearance: none; -webkit-appearance: none; cursor: pointer; text-align: center; text-align-last: center; font-size: .85rem; font-weight: 600; border-radius: 999px; padding: 5px 8px; }
.row select.s-owner { background: var(--accent-soft); color: var(--fg); }
.row select.s-owner[data-v=""] { background: transparent; color: var(--muted); border-color: var(--line); font-weight: 500; }
.row select.s-status[data-v="todo"] { background: var(--todo-bg); color: var(--todo-fg); }
.row select.s-status[data-v="doing"] { background: var(--doing-bg); color: var(--doing-fg); }
.row select.s-status[data-v="blocked"] { background: var(--blocked-bg); color: var(--blocked-fg); }
.row select.s-status[data-v="done"] { background: var(--done-bg); color: var(--done-fg); }
.row select.s-prio { background: transparent; border-color: var(--line); color: var(--fg); font-weight: 500; }
.row select.s-prio[data-v=""] { color: var(--muted); }
.row select.s-prio[data-v="high"] { color: var(--danger); border-color: currentColor; font-weight: 600; }
.row select option { background: var(--surface); color: var(--fg); }
.row input[type="date"] { font-size: .85rem; font-variant-numeric: tabular-nums; }
.row input[type="date"].late { color: var(--danger); font-weight: 600; }
.row .more {
  font: inherit; cursor: pointer; width: 32px; height: 32px; border-radius: 6px;
  border: 1px solid transparent; background: transparent; color: var(--muted); font-weight: 600;
}
.row .more:hover { border-color: var(--line); }
.row .more.has-notes { color: var(--accent); }
.add { display: flex; gap: 8px; padding: 6px 10px; }
.add input { flex: 1 1 auto; }
.add input::placeholder { color: var(--muted); }

dialog {
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--fg);
  padding: 20px; width: min(520px, calc(100vw - 32px));
}
dialog::backdrop { background: rgba(10, 20, 24, .5); }
dialog h2 { font-family: var(--font-display); font-size: 1.15rem; margin: 0 0 14px; text-wrap: balance; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: .8rem; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea {
  font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; width: 100%;
}
.field textarea { min-height: 120px; resize: vertical; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.dialog-actions .left { margin-right: auto; }

.tabs { display: flex; gap: 4px; background: var(--todo-bg); padding: 4px; border-radius: 10px; }
.tab { font: inherit; font-size: .88rem; font-weight: 600; border: 0; background: transparent; color: var(--muted); padding: 6px 12px; border-radius: 7px; cursor: pointer; }
.tab[aria-pressed="true"] { background: var(--surface); color: var(--fg); }
#dash { display: flex; flex-direction: column; gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile b { display: block; font-family: var(--font-display); font-size: 1.9rem; line-height: 1.1; font-variant-numeric: tabular-nums; }
.tile span { color: var(--muted); font-size: .85rem; }
.tile.warn b { color: var(--danger); }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panel h2 { font-family: var(--font-display); font-size: 1rem; margin: 0; }
.dash-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 12px; }
.person { display: grid; grid-template-columns: 150px minmax(0, 1fr); gap: 6px 12px; align-items: center; }
.person .who { font-weight: 600; overflow-wrap: anywhere; }
.person .who small { display: block; font-weight: 400; color: var(--muted); }
.bar { display: flex; height: 26px; border-radius: 6px; overflow: hidden; background: var(--bg); }
.seg { display: flex; align-items: center; justify-content: center; min-width: 22px; font-size: .78rem; font-weight: 600; font-variant-numeric: tabular-nums; }
.seg.todo { background: var(--todo-bg); color: var(--todo-fg); }
.seg.doing { background: var(--doing-bg); color: var(--doing-fg); }
.seg.blocked { background: var(--blocked-bg); color: var(--blocked-fg); }
.seg.done { background: var(--done-bg); color: var(--done-fg); }
.legend { display: flex; flex-wrap: wrap; gap: 6px; }
.items { display: flex; flex-direction: column; }
.item { display: flex; gap: 10px; align-items: baseline; justify-content: space-between; width: 100%; text-align: left; font: inherit; color: var(--fg); background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 8px 2px; cursor: pointer; }
.item:last-child { border-bottom: 0; }
.item .ttl { min-width: 0; overflow-wrap: anywhere; }
.item .meta { color: var(--muted); font-size: .82rem; white-space: nowrap; }
.item .meta.late { color: var(--danger); font-weight: 600; }
.none { color: var(--muted); margin: 0; }
.hint { color: var(--muted); font-size: .82rem; margin: -4px 0 12px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }

@media (max-width: 720px) {
  .person { grid-template-columns: 1fr; }
  .cols { display: none; }
  .row { grid-template-columns: 1fr 1fr 40px; padding: 10px; }
  .row .t-title { grid-column: 1 / -1; font-weight: 500; }
  .row .s-prio { grid-column: 2; }
  .row .more { grid-column: 3; grid-row: 3; }
}
@media (prefers-reduced-motion: no-preference) {
  .chip, .btn, .row input, .row select { transition: border-color .12s, background-color .12s; }
}
