/* =========================================================================
   D4 Manifeste — Styles
   Palette fixe définie dans le CDC. Pas de dépendance externe.
   ========================================================================= */

:root {
  --c-accent: #1d9e75;
  --c-accent-dark: #17805f;
  --c-stable: #639922;
  --c-en-travail: #ef9f27;
  --c-a-revoir: #e24b4a;
  --c-archive: #9c9c99;
  --c-bg: #f8f8f6;
  --c-surface: #ffffff;
  --c-text: #1a1a18;
  --c-text-soft: #6b6b68;
  --c-border: rgba(0, 0, 0, 0.1);
  --c-border-strong: rgba(0, 0, 0, 0.18);
  --c-hover: rgba(0, 0, 0, 0.04);
  --c-active: rgba(29, 158, 117, 0.1);

  --col-left-w: 240px;
  --col-right-w: 320px;
  --header-h: 48px;
  --mobile-nav-h: 56px;

  --radius: 6px;
  --radius-sm: 4px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Ubuntu,
    Roboto, Helvetica, Arial, sans-serif;
  --font-mono: "SF Mono", Menlo, Monaco, Consolas, "Courier New", monospace;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ---------- Reset minimal ---------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
}
button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}
input,
textarea,
select {
  font: inherit;
  color: inherit;
}
a {
  color: var(--c-accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
.hidden {
  display: none !important;
}
.mobile-only {
  display: none;
}

/* =========================================================================
   ÉCRAN DE CONFIGURATION
   ========================================================================= */
.config-screen {
  position: fixed;
  inset: 0;
  background: var(--c-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px;
  overflow-y: auto;
}
.config-box {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: 8px;
  padding: 32px;
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-md);
}
.config-box h1 {
  font-size: 20px;
  margin-bottom: 12px;
}
.config-intro {
  color: var(--c-text-soft);
  margin-bottom: 24px;
  font-size: 13px;
}
#config-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
#config-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  font-weight: 500;
}
#config-form input {
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  font-size: 13px;
}
#config-form input:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.15);
}
#config-form code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--c-hover);
  padding: 1px 4px;
  border-radius: 3px;
}
.config-actions {
  margin-top: 8px;
}
#cfg-submit {
  background: var(--c-accent);
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  width: 100%;
}
#cfg-submit:hover {
  background: var(--c-accent-dark);
}
#cfg-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.config-status {
  font-size: 12px;
  margin-top: 8px;
  min-height: 18px;
}
.config-status.error {
  color: var(--c-a-revoir);
}
.config-status.ok {
  color: var(--c-stable);
}

/* =========================================================================
   APP LAYOUT — 3 colonnes
   ========================================================================= */
.app {
  display: flex;
  flex-direction: column;
  height: 100vh; /* fallback navigateurs anciens */
  height: 100dvh; /* dynamic viewport : s'ajuste à la barre Safari iOS */
}

/* Header */
.app-header {
  height: var(--header-h);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 16px;
  flex-shrink: 0;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: var(--col-left-w);
}
.logo {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  object-fit: contain;
}
/* Mode toggle Manifeste / Actions */
.mode-toggle {
  display: flex;
  background: var(--c-hover);
  border-radius: var(--radius-sm);
  padding: 2px;
}
.mode-btn {
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 3px;
  color: var(--c-text-soft);
  transition: background 0.15s, color 0.15s;
}
.mode-btn:hover { color: var(--c-text); }
.mode-btn.active {
  background: var(--c-surface);
  color: var(--c-accent-dark);
  box-shadow: var(--shadow-sm);
}

/* Wrappers de contenu par mode — doivent rester des flex containers pour le scroll */
.manifeste-content,
.actions-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  min-height: 0;
}
[data-mode="manifeste"] .actions-content { display: none !important; }
[data-mode="actions"] .manifeste-content { display: none !important; }
.header-center {
  flex: 1;
  overflow: hidden;
}
.active-section-title {
  color: var(--c-text-soft);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.save-indicator {
  font-size: 12px;
  color: var(--c-text-soft);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--c-hover);
}
.save-indicator.saving {
  color: var(--c-en-travail);
}
.save-indicator.saved {
  color: var(--c-stable);
}
.save-indicator.error {
  color: var(--c-a-revoir);
}
.btn-icon {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: var(--c-text-soft);
}
.btn-icon:hover {
  background: var(--c-hover);
  color: var(--c-text);
}

/* Body — 3 cols */
.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ========== Resize handles ========== */
.resize-handle {
  width: 8px;
  margin: 0 -3px;
  cursor: col-resize;
  background: transparent;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
  transition: background 0.15s;
}
.resize-handle:hover,
.resize-handle.dragging {
  background: var(--c-accent);
  opacity: 0.4;
}
.resize-handle.dragging { opacity: 0.6; }

/* ========== Colonne gauche : TOC ========== */
.col-left {
  width: var(--col-left-w);
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}
.toc-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
#toc-search {
  padding: 6px 8px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
  font-size: 12px;
  width: 100%;
}
#toc-search:focus {
  outline: none;
  border-color: var(--c-accent);
}
.toc-filters {
  display: flex;
  gap: 4px;
}
.filter-btn {
  padding: 3px 8px;
  font-size: 11px;
  border-radius: var(--radius-sm);
  color: var(--c-text-soft);
}
.filter-btn:hover {
  background: var(--c-hover);
}
.filter-btn.active {
  background: var(--c-active);
  color: var(--c-accent-dark);
  font-weight: 500;
}

.toc-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}
.toc-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  font-size: 13px;
  cursor: pointer;
  position: relative;
  color: var(--c-text);
  border-left: 2px solid transparent;
}
.toc-item:hover {
  background: var(--c-hover);
}
.toc-item.active {
  background: var(--c-active);
  border-left-color: var(--c-accent);
  font-weight: 500;
}
.toc-item.n1 {
  font-weight: 600;
  font-size: 13px;
  margin-top: 6px;
}
.toc-item.n2 {
  padding-left: 24px;
  font-size: 12.5px;
}
.toc-item.n3 {
  padding-left: 36px;
  font-size: 12px;
  color: var(--c-text-soft);
}
.toc-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--c-stable);
  flex-shrink: 0;
}
.toc-status-dot.stable {
  background: var(--c-stable);
}
.toc-status-dot.en_travail {
  background: var(--c-en-travail);
}
.toc-status-dot.a_revoir {
  background: var(--c-a-revoir);
}
.toc-status-dot.archive {
  background: var(--c-archive);
}
.toc-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  background: var(--c-hover);
  color: var(--c-text-soft);
  flex-shrink: 0;
}
.toc-item.archived {
  opacity: 0.5;
}
.toc-rename-input {
  flex: 1;
  padding: 2px 6px;
  border: 1px solid var(--c-accent);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 12.5px;
  background: var(--c-surface);
  min-width: 0;
}
.toc-rename-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.15);
}

.toc-footer {
  padding: 10px 12px;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}
.btn-add {
  width: 100%;
  padding: 6px 8px;
  font-size: 12px;
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--radius-sm);
  color: var(--c-text-soft);
}
.btn-add:hover {
  background: var(--c-hover);
  color: var(--c-text);
  border-color: var(--c-accent);
}

/* ========== Colonne centrale : Espace de travail ========== */
.col-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--c-bg);
}
.tabs {
  display: flex;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  padding: 0 12px;
  flex-shrink: 0;
}
.tab-btn {
  padding: 10px 14px;
  font-size: 13px;
  color: var(--c-text-soft);
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.tab-btn:hover {
  color: var(--c-text);
}
.tab-btn.active {
  color: var(--c-accent-dark);
  border-bottom-color: var(--c-accent);
  font-weight: 500;
}
.tab-count {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  background: var(--c-hover);
  color: var(--c-text-soft);
}
.tab-panel {
  display: none;
  flex: 1;
  overflow: hidden;
}
.tab-panel.active {
  display: flex;
  flex-direction: column;
}

/* Éditeur markdown */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
  min-height: 42px;
}
.toolbar-md-buttons {
  display: flex;
  gap: 4px;
  align-items: center;
}
.editor-btn {
  min-width: 28px;
  height: 28px;
  padding: 0 8px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--c-text-soft);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.editor-btn:hover {
  background: var(--c-hover);
  color: var(--c-text);
}
.toolbar-spacer {
  flex: 1;
}

/* Bouton bascule lecture/édition */
.btn-toggle-mode {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--c-accent-dark);
  background: var(--c-active);
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}
.btn-toggle-mode:hover {
  background: var(--c-accent);
  color: white;
}
.btn-toggle-mode .icon { font-size: 13px; }
.btn-toggle-mode .label { white-space: nowrap; }

/* Split : 2 modes — read (HTML plein) vs edit (split MD+HTML) */
.editor-split {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
}
.editor-split.read-mode {
  grid-template-columns: 1fr;
}
.editor-split.read-mode #editor-textarea {
  display: none;
}
.editor-split.read-mode .editor-preview {
  background: var(--c-surface);
  padding: 28px 40px;
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
}
/* En mode lecture : masquer la toolbar markdown (garder le bouton bascule) */
.editor-toolbar.read .toolbar-md-buttons {
  display: none;
}
#editor-textarea {
  padding: 20px 24px;
  border: none;
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  resize: none;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.65;
  color: var(--c-text);
  outline: none;
  overflow-y: auto;
}
.editor-preview {
  padding: 20px 28px;
  overflow-y: auto;
  background: var(--c-bg);
}

/* En-tête de section affichée en haut du preview (mode lecture) */
.section-preview-header {
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--c-border);
}
.preview-section-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--c-text);
  line-height: 1.25;
  margin: 0;
  letter-spacing: -0.3px;
}
.section-preview-header.n1 .preview-section-title {
  font-size: 28px;
  color: var(--c-accent-dark);
}
.section-preview-header.n2 .preview-section-title {
  font-size: 22px;
}
.section-preview-header.n3 .preview-section-title {
  font-size: 18px;
  color: var(--c-text-soft);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.preview-empty-hint {
  margin-top: 12px;
  padding: 14px 16px;
  background: var(--c-bg);
  border: 1px dashed var(--c-border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--c-text-soft);
  font-style: italic;
}

/* Rendu markdown */
.markdown-body {
  font-size: 14px;
  line-height: 1.65;
  color: var(--c-text);
}
.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  margin: 1.2em 0 0.5em;
  line-height: 1.3;
  font-weight: 600;
}
.markdown-body h1 {
  font-size: 22px;
}
.markdown-body h2 {
  font-size: 18px;
}
.markdown-body h3 {
  font-size: 15px;
  color: var(--c-text-soft);
}
.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child {
  margin-top: 0;
}
.markdown-body p {
  margin: 0.75em 0;
}
.markdown-body ul,
.markdown-body ol {
  padding-left: 22px;
  margin: 0.5em 0;
}
.markdown-body li {
  margin: 0.2em 0;
}
.markdown-body blockquote {
  border-left: 3px solid var(--c-accent);
  background: var(--c-hover);
  padding: 8px 14px;
  margin: 0.8em 0;
  color: var(--c-text-soft);
  font-style: italic;
}
.markdown-body code {
  font-family: var(--font-mono);
  font-size: 12.5px;
  background: var(--c-hover);
  padding: 1px 5px;
  border-radius: 3px;
}
.markdown-body pre {
  background: var(--c-hover);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  margin: 0.8em 0;
}
.markdown-body pre code {
  background: none;
  padding: 0;
}
.markdown-body hr {
  border: none;
  border-top: 1px solid var(--c-border);
  margin: 1.2em 0;
}
.markdown-body strong {
  font-weight: 600;
}
.markdown-body em {
  font-style: italic;
}
.markdown-body table {
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 13px;
  width: auto;
  max-width: 100%;
}
.markdown-body th,
.markdown-body td {
  border: 1px solid var(--c-border-strong);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
}
.markdown-body th {
  background: var(--c-hover);
  font-weight: 600;
}
.markdown-body tr:nth-child(even) td {
  background: var(--c-bg);
}

.placeholder {
  padding: 40px;
  text-align: center;
  color: var(--c-text-soft);
  font-size: 14px;
}

/* ========== Colonne droite : IA ========== */
.col-right {
  width: var(--col-right-w);
  background: var(--c-surface);
  border-left: 1px solid var(--c-border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.ai-header {
  padding: 10px 14px;
  border-bottom: 1px solid var(--c-border);
  font-weight: 600;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.ai-intro {
  font-size: 12px;
  color: var(--c-text-soft);
  text-align: center;
  padding: 20px 10px;
  font-style: italic;
}
/* Liste des tâches proposées par l'IA dans la modale */
.task-proposal-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
}
.task-proposal-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.task-proposal-row:hover {
  background: var(--c-hover);
  border-color: var(--c-border-strong);
}
.task-proposal-row input[type="checkbox"] {
  margin-top: 2px;
  cursor: pointer;
  accent-color: var(--c-accent);
}
.task-proposal-info {
  flex: 1;
  min-width: 0;
}
.task-proposal-label {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
  color: var(--c-text);
}
.task-proposal-desc {
  font-size: 11.5px;
  color: var(--c-text-soft);
  margin-top: 2px;
  line-height: 1.4;
}

.ai-persist-header {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--c-text-soft);
  padding: 4px 8px;
  text-align: center;
  border-bottom: 1px dashed var(--c-border);
  margin-bottom: 6px;
}
.ai-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 100%;
}
.ai-msg-user {
  align-items: flex-end;
}
.ai-msg-assistant {
  align-items: flex-start;
}
.ai-bubble {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 92%;
  word-wrap: break-word;
}
.ai-msg-user .ai-bubble {
  background: var(--c-active);
  color: var(--c-text);
  border-bottom-right-radius: 3px;
}
.ai-msg-assistant .ai-bubble {
  background: var(--c-hover);
  color: var(--c-text);
  border-bottom-left-radius: 3px;
}
.ai-msg-assistant .ai-bubble :first-child { margin-top: 0; }
.ai-msg-assistant .ai-bubble :last-child { margin-bottom: 0; }
.ai-msg-assistant .ai-bubble p { margin: 0.4em 0; font-size: 13px; }
.ai-msg-assistant .ai-bubble h1,
.ai-msg-assistant .ai-bubble h2,
.ai-msg-assistant .ai-bubble h3 { font-size: 13px; margin: 0.6em 0 0.3em; }
.ai-msg-assistant .ai-bubble ul,
.ai-msg-assistant .ai-bubble ol { padding-left: 18px; }
.ai-msg-actions {
  padding-left: 4px;
}
.ai-action-btn {
  font-size: 11px;
  color: var(--c-text-soft);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--c-border);
}
.ai-action-btn:hover {
  background: var(--c-hover);
  color: var(--c-accent-dark);
  border-color: var(--c-accent);
}

.ai-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 14px;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
}
.ai-chip {
  padding: 4px 9px;
  font-size: 11px;
  color: var(--c-accent-dark);
  background: var(--c-active);
  border-radius: 12px;
  white-space: nowrap;
}
.ai-chip:hover {
  background: var(--c-accent);
  color: white;
}

.ai-input-zone {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
  background: var(--c-surface);
}
#ai-input {
  flex: 1;
  padding: 6px 8px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  resize: none;
  font-size: 13px;
  background: var(--c-bg);
}
#ai-input:focus {
  outline: none;
  border-color: var(--c-accent);
}

/* =========================================================================
   BOUTONS GÉNÉRIQUES
   ========================================================================= */
.btn-primary {
  background: var(--c-accent);
  color: white;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
}
.btn-primary:hover {
  background: var(--c-accent-dark);
}
.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  color: var(--c-text);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}
.btn-secondary:hover {
  background: var(--c-hover);
  border-color: var(--c-border-strong);
}
.btn-icon-sm {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-sm);
  color: var(--c-text-soft);
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.btn-icon-sm:hover {
  background: var(--c-hover);
  color: var(--c-a-revoir);
}

/* =========================================================================
   ONGLETS TÂCHES / PROJETS — CRUD
   ========================================================================= */
.crud-header {
  padding: 12px 16px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
.crud-header-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.crud-header-row #tache-quick-add { flex: 1; }

#tache-quick-add {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
  font-size: 13px;
}
#tache-quick-add:focus {
  outline: none;
  border-color: var(--c-accent);
}
.crud-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.empty {
  padding: 30px 16px;
  text-align: center;
  color: var(--c-text-soft);
  font-size: 13px;
}

.crud-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  transition: opacity 0.15s;
}
.crud-item.done {
  opacity: 0.55;
}
.crud-item.done .crud-label {
  text-decoration: line-through;
}
.crud-label {
  flex: 1;
  font-size: 13px;
  cursor: text;
}
.inline-edit {
  flex: 1;
  padding: 4px 6px;
  border: 1px solid var(--c-accent);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--c-surface);
  font-family: inherit;
}
.inline-edit:focus {
  outline: none;
}

/* Chips de statut / priorité */
.statut-chip {
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 10px;
  background: var(--c-hover);
  color: var(--c-text-soft);
  white-space: nowrap;
  flex-shrink: 0;
}
.statut-chip:hover { filter: brightness(0.95); }
.statut-chip.statut-a_faire { background: #e8e8e5; color: #58584f; }
.statut-chip.statut-en_cours { background: #fdf0d6; color: #a06e0f; }
.statut-chip.statut-termine { background: #e0ecce; color: #3d6611; }
.statut-chip.statut-bloque { background: #fde0e0; color: #a13333; }
.statut-chip.statut-a_specifier { background: #e8e8e5; color: #58584f; }
.statut-chip.statut-en_pause { background: #e8dffb; color: #5c3d98; }

.prio-chip {
  font-size: 11px;
  padding: 3px 7px;
  border-radius: 10px;
  background: var(--c-hover);
  color: var(--c-text-soft);
  flex-shrink: 0;
}
.prio-chip.prio-haute { background: #fde0e0; color: #a13333; font-weight: 500; }
.prio-chip.prio-basse { color: #9c9c99; }

/* Cartes projets */
.projet-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-left: 3px solid var(--c-accent);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.projet-card.statut-termine { border-left-color: var(--c-stable); opacity: 0.7; }
.projet-card.statut-en_pause { border-left-color: #8a6fc7; }
.projet-card.statut-a_specifier { border-left-color: var(--c-border-strong); }
.projet-head {
  display: flex;
  align-items: center;
  gap: 8px;
}
.projet-title {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  cursor: text;
}
.projet-desc {
  font-size: 12px;
  color: var(--c-text-soft);
  line-height: 1.45;
  cursor: text;
  white-space: pre-wrap;
}
.projet-link {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--c-accent);
  text-decoration: none;
}

/* =========================================================================
   ONGLET GÉNÉRER
   ========================================================================= */
.generer-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px;
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border);
  flex-shrink: 0;
}
.generer-controls label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 500;
  color: var(--c-text);
}
.generer-controls select,
.generer-controls textarea {
  padding: 6px 8px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}
.generer-controls select:focus,
.generer-controls textarea:focus {
  outline: none;
  border-color: var(--c-accent);
}
#btn-generer {
  align-self: flex-start;
}
.generer-result {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px;
}
.generer-actions {
  display: flex;
  gap: 8px;
  padding: 10px 20px;
  border-top: 1px solid var(--c-border);
  background: var(--c-surface);
  flex-shrink: 0;
}

/* =========================================================================
   TOASTS
   ========================================================================= */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
  max-width: 380px;
}
.toast {
  background: var(--c-text);
  color: white;
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: auto;
  cursor: pointer;
}
.toast.visible {
  opacity: 1;
  transform: translateY(0);
}
.toast-success { background: var(--c-stable); }
.toast-error { background: var(--c-a-revoir); }
.toast-warn { background: var(--c-en-travail); }
.toast-info { background: var(--c-text); }

/* =========================================================================
   MODALS
   ========================================================================= */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1500;
  padding: 20px;
  opacity: 0;
  transition: opacity 0.15s;
}
.modal-backdrop.visible {
  display: flex;
  opacity: 1;
}
.modal {
  background: var(--c-surface);
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  max-width: 440px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: modalIn 0.15s ease-out;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-10px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-title {
  padding: 16px 20px 8px;
  font-size: 15px;
  font-weight: 600;
}
.modal-body {
  padding: 8px 20px 16px;
  font-size: 13px;
  color: var(--c-text);
  line-height: 1.5;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--c-border);
  background: var(--c-bg);
  border-radius: 0 0 10px 10px;
}

.form-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.form-field label {
  font-size: 12px;
  font-weight: 500;
  color: var(--c-text);
}
.form-field input,
.form-field textarea,
.form-field select {
  padding: 7px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-surface);
  font-size: 13px;
  font-family: inherit;
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.15);
}
.form-field textarea {
  resize: vertical;
  min-height: 60px;
}

/* Menu d'actions */
.modal-menu .modal-title {
  padding-bottom: 4px;
}
.action-menu {
  display: flex;
  flex-direction: column;
  padding: 4px 8px 12px;
}
.action-item {
  text-align: left;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--c-text);
}
.action-item:hover {
  background: var(--c-hover);
}
.action-item.danger {
  color: var(--c-a-revoir);
}
.action-item.danger:hover {
  background: rgba(226, 75, 74, 0.08);
}

/* =========================================================================
   AIDE RACCOURCIS
   ========================================================================= */
.shortcut-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.shortcut-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
}
/* =========================================================================
   FOOTER — navigation sections + actions globales
   ========================================================================= */
.app-footer {
  height: 52px;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  padding: 0 8px;
  gap: 8px;
}

/* Boutons nav prev/next */
.nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  min-width: 0;
  color: var(--c-text-soft);
  border-radius: var(--radius-sm);
  max-width: 320px;
  transition: background 0.15s, color 0.15s;
}
.nav-btn:hover:not(:disabled) {
  background: var(--c-hover);
  color: var(--c-text);
}
.nav-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}
.nav-prev { justify-content: flex-start; text-align: left; }
.nav-next { justify-content: flex-end; text-align: right; }
.nav-arrow {
  font-size: 18px;
  line-height: 1;
  color: var(--c-accent);
  flex-shrink: 0;
}
.nav-btn:disabled .nav-arrow { color: var(--c-text-soft); }
.nav-label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  overflow: hidden;
}
.nav-next .nav-label { align-items: flex-end; }
.nav-hint {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--c-text-soft);
  font-weight: 500;
}
.nav-title {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--c-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.nav-btn:disabled .nav-title { color: var(--c-text-soft); }

/* Actions globales au centre */
.footer-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
  border-left: 1px solid var(--c-border);
  border-right: 1px solid var(--c-border);
  flex-shrink: 0;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  background: var(--c-surface);
  border: 1px solid var(--c-border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--c-text);
  margin: 0 1px;
}

/* ========== Navigation mobile ========== */
.mobile-nav {
  display: none;
}

/* =========================================================================
   RESPONSIVE
   ========================================================================= */

/* =========================================================================
   MODE ACTIONS — LISTE TÂCHES (volet gauche)
   ========================================================================= */
.tasks-header {
  padding: 10px 12px;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
}
#tasks-search {
  padding: 6px 8px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
  font-size: 12px;
  width: 100%;
}
#tasks-search:focus { outline: none; border-color: var(--c-accent); }
#tasks-filter-statut {
  padding: 4px 8px;
  font-size: 11px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  background: var(--c-bg);
}
.tasks-global-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px 0;
}
.tasks-footer {
  padding: 8px 12px;
  border-top: 1px solid var(--c-border);
  flex-shrink: 0;
  display: flex;
  gap: 6px;
}
.tasks-footer .btn-add { flex: 1; }

/* Groupes de priorité */
.prio-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 4px;
  margin-top: 4px;
}
.prio-group-header:first-child { margin-top: 0; }
.prio-group-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--c-text-soft);
}
.prio-group-header.prio-haute .prio-group-label { color: var(--c-a-revoir); }
.prio-group-count {
  font-size: 10px;
  color: var(--c-text-soft);
  background: var(--c-hover);
  padding: 1px 6px;
  border-radius: 8px;
}

/* Label de section dans la liste */
.task-section-label {
  padding: 4px 14px 2px;
  font-size: 10px;
  color: var(--c-text-soft);
}
.task-section-label .crumb-parent { color: var(--c-archive); }
.task-section-label .crumb-current { color: var(--c-text-soft); font-weight: 500; }
.task-section-label .crumb-sep { color: var(--c-border-strong); margin: 0 3px; }

/* Items tâche dans la liste */
.task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background 0.1s;
}
.task-item:hover { background: var(--c-hover); }
.task-item.active {
  background: var(--c-active);
  border-left-color: var(--c-accent);
}
.task-item.statut-termine {
  opacity: 0.5;
}
.task-item.statut-termine .task-item-label {
  text-decoration: line-through;
}
.task-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.task-status-dot.a_faire { background: #c8c8c2; }
.task-status-dot.en_cours { background: var(--c-en-travail); }
.task-status-dot.termine { background: var(--c-stable); }
.task-status-dot.bloque { background: var(--c-a-revoir); }
.task-item-label {
  font-size: 12.5px;
  color: var(--c-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================================
   MODE ACTIONS — DÉTAIL TÂCHE (volet central)
   ========================================================================= */
.task-detail {
  padding: 24px 28px;
  max-width: 700px;
  margin: 0 auto;
}
.task-detail-breadcrumb {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  color: var(--c-text-soft);
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.task-detail-breadcrumb .crumb-parent { color: var(--c-archive); }
.task-detail-breadcrumb .crumb-current { color: var(--c-text-soft); font-weight: 500; }
.task-detail-breadcrumb .crumb-sep { color: var(--c-border-strong); margin: 0 3px; }
.btn-goto-section {
  font-size: 11px;
  color: var(--c-accent);
  padding: 2px 8px;
  border: 1px solid var(--c-accent);
  border-radius: var(--radius-sm);
  margin-left: auto;
}
.btn-goto-section:hover { background: var(--c-active); }

.task-detail-field {
  margin-bottom: 14px;
}
.task-detail-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--c-text-soft);
  margin-bottom: 5px;
}
.task-detail-field input,
.task-detail-field textarea,
.task-detail-field select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--c-border);
  border-radius: var(--radius-sm);
  font: inherit;
  font-size: 14px;
  background: var(--c-surface);
}
.task-detail-field input:focus,
.task-detail-field textarea:focus,
.task-detail-field select:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 0 3px rgba(29, 158, 117, 0.12);
}
.task-title-input {
  font-size: 18px !important;
  font-weight: 600;
  line-height: 1.35 !important;
  min-height: auto !important;
  resize: none;
  overflow-wrap: break-word;
  word-wrap: break-word;
  field-sizing: content; /* CSS natif : textarea s'ajuste au contenu (Safari 17.4+) */
}
.task-detail-field textarea {
  resize: vertical;
  min-height: 80px;
  font-size: 13px;
  line-height: 1.5;
}
.task-detail-row {
  display: flex;
  gap: 14px;
}
.task-detail-row .task-detail-field { flex: 1; }
.task-detail-actions {
  margin: 18px 0;
  padding-top: 14px;
  border-top: 1px solid var(--c-border);
}

/* Tâches sœurs */
.task-detail-siblings {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--c-border);
}
.siblings-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--c-text-soft);
  margin-bottom: 10px;
}
.siblings-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}
.sibling-task {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  cursor: pointer;
  color: var(--c-text);
}
.sibling-task:hover { background: var(--c-hover); }
.sibling-task.done {
  opacity: 0.5;
  text-decoration: line-through;
}
.empty-small {
  font-size: 12px;
  color: var(--c-text-soft);
  font-style: italic;
  padding: 4px 0;
}

/* Tablette : masquer colonne droite, rendre TOC repliable */
@media (max-width: 1024px) {
  .resize-handle { display: none; }
  .col-right {
    display: none;
  }
}

/* Mobile : layout à 1 colonne, nav en bas */
@media (max-width: 768px) {
  :root {
    --col-left-w: 100%;
  }
  .header-left {
    min-width: auto;
  }
  .header-center {
    display: none;
  }
  .app-body {
    position: relative;
  }
  .col-left,
  .col-center,
  .col-right {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    /* réserve la place du footer fixé + safe-area iPhone (home indicator) */
    bottom: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
    width: 100%;
    border: none;
    display: none;
  }
  .col-left.mobile-active,
  .col-center.mobile-active,
  .col-right.mobile-active {
    display: flex;
  }
  /* Sur mobile : l'app-footer desktop est caché, tout passe dans mobile-nav */
  .app-footer { display: none; }
  .mobile-only { display: inline-flex !important; }
  .mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: calc(var(--mobile-nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: var(--c-surface);
    border-top: 1px solid var(--c-border);
    z-index: 100;
  }
  .mobile-nav-btn {
    flex: 1;
    font-size: 20px;
    color: var(--c-text-soft);
    min-width: 0;
  }
  .mobile-nav-btn.active {
    color: var(--c-accent);
  }
  /* Flèches prev/next aux extrémités de la mobile-nav */
  .mobile-nav-btn.nav-edge {
    font-size: 28px;
    font-weight: 400;
    color: var(--c-accent);
    line-height: 1;
  }
  .mobile-nav-btn.nav-edge:disabled {
    opacity: 0.25;
    color: var(--c-text-soft);
  }
  .mobile-nav-btn.nav-edge:active:not(:disabled) {
    background: var(--c-active);
  }
  /* Éditeur mobile : une seule colonne, texte OU rendu selon le mode */
  .editor-split {
    grid-template-columns: 1fr;
  }
  #editor-textarea {
    border-right: none;
    padding: 16px 20px;
  }
  /* Mode Lecture : rendu HTML plein, textarea masqué (comportement normal) */
  /* Mode Édition : textarea pleine largeur, preview masqué */
  .editor-split:not(.read-mode) .editor-preview {
    display: none;
  }
  .editor-split:not(.read-mode) #editor-textarea {
    display: block;
  }
}
