/* KKRI Brain : correctifs d'interface (audit) */
:root { --faint: #6f7285; }
.page-title:empty::before, .blk-text:empty::before { color: #8a8ea0 !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.page-title:focus-visible, .blk-text:focus-visible, .input:focus-visible { outline: none; }
kbd { font: 11px var(--font); color: var(--faint); background: #fff; border: 1px solid var(--line); border-radius: 4px; padding: 0 5px; margin-left: 6px; }
.btn.primary kbd { background: rgba(255,255,255,.18); border-color: transparent; color: #fff; }

/* Indicateur d'enregistrement */
.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); padding: 3px 8px; border-radius: 6px; white-space: nowrap; }
.sync::before { content: ''; width: 8px; height: 8px; border-radius: 50%; background: #00c875; }
.sync.saving::before { background: #fdab3d; }
.sync.error, .sync.offline { color: #df2f4a; background: #fdecee; font-weight: 600; }
.sync.error::before, .sync.offline::before { background: #df2f4a; }

/* En-tête compact des bases de données */
.page.wide .page-head { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 12px; padding-top: 18px; }
.page.wide .page-head > .cover, .page.wide .page-head > .page-head-acts { grid-column: 1 / -1; }
.page.wide .page-icon { font-size: 34px; width: 48px; height: 48px; margin: 0; }
.page.wide .page-head.has-cover .page-icon { margin-top: -24px; }
.page.wide .page-icon.none { display: none; }
.page.wide .page-title { font-size: 30px; padding: 4px 0; }
.page.wide .page-head-acts { order: -1; min-height: 0; margin: 0 0 4px; }

/* Accueil : agenda */
.home-acts { display: flex; gap: 8px; flex-wrap: wrap; margin: 14px 0 6px; }
.ag { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: #fff; }
.ag-row { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-bottom: 1px solid var(--line); cursor: pointer; }
.ag-row:last-child { border-bottom: 0; }
.ag-row:hover { background: var(--bg-soft); }
.ag-check { width: 18px; height: 18px; border: 2px solid var(--line-strong); border-radius: 50%; flex: none; }
.ag-check:hover { border-color: #00c875; background: #e6f9f1; }
.ag-t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.ag-db { font-size: 12.5px; color: var(--muted); background: var(--bg-soft); border-radius: 6px; padding: 1px 8px; white-space: nowrap; }
.ag-date { font-size: 13px; color: var(--muted); min-width: 92px; text-align: right; white-space: nowrap; }
.ag-date.late { color: #df2f4a; font-weight: 600; }
.ag-date.today { color: var(--accent); font-weight: 600; }
.ag-empty { color: var(--muted); padding: 14px; border: 1px dashed var(--line-strong); border-radius: 10px; }
.recent { display: flex; flex-wrap: wrap; gap: 8px; }
.rc { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 280px; }
.rc span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc:hover { border-color: var(--line-strong); box-shadow: var(--shadow-card); }

/* Capture rapide */
.capture .cap-hint { font-size: 12px; color: var(--muted); margin: 8px 0 4px; }
.cap-list { max-height: 220px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.cap-item { display: flex; align-items: center; gap: 8px; padding: 5px 4px; color: var(--text); }
.cap-item .ic { color: #00c875; }
.cap-item span:nth-child(2) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cap-due { font-size: 12px; color: var(--accent); font-weight: 600; }

/* Bouton flottant (mobile) */
.fab { display: none; position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; box-shadow: 0 8px 24px rgba(97, 97, 255, .45); z-index: 600; place-items: center; }

/* Démarrage impossible */
.boot-err { position: fixed; inset: 0; background: var(--bg-soft); display: grid; place-items: center; z-index: 2000; padding: 20px; }
.boot-box { background: #fff; border-radius: 14px; box-shadow: var(--shadow-pop); padding: 28px; max-width: 440px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.boot-box .muted { color: var(--faint); font-size: 13px; }

@media (max-width: 820px) {
  #app:not(.sb-open) #sidebar { box-shadow: none; }
  .fab { display: grid; }
  .crumb:not(.cur), .crumb-sep { display: none; }
  .crumb.cur { max-width: 60vw; }
  .ag-db { display: none; }
  .ag-date { min-width: 0; }
  .icon-btn { min-width: 36px; min-height: 36px; }
  .home h1 { padding-top: 24px; }
}

/* ---------- Contre-audit : fiche, tactile, finitions ---------- */
.prop-row { align-items: center; }
.prop-label { min-height: 34px; padding: 4px 8px; }
.prop-val { min-height: 34px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; padding: 4px 8px; border-radius: 6px; cursor: pointer; }
.prop-val:hover { background: var(--bg-hover); }
.prop-val:empty::before, .prop-val > .empty:only-child { content: 'Vide'; color: #8a8ea0; }
.peek-db { display: inline-flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 6px; color: var(--muted); font-size: 13px; max-width: 220px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.peek-db:hover { background: var(--bg-hover); color: var(--text); }
.peek-bar .icon-btn[disabled] { opacity: .35; pointer-events: none; }

.s-ico { width: 24px; flex: none; display: grid; place-items: center; }
.s-item mark { background: #fff3c4; color: inherit; border-radius: 3px; padding: 0 1px; }

.sb-link.on { background: var(--accent-soft); color: var(--accent-dark); font-weight: 600; }
.trash-row .btn.danger-soft { background: #fff; color: var(--danger); border-color: #f3c3cb; }
.trash-row .btn.danger-soft:hover { background: #fdecee; }

.tri-acts { display: flex; gap: 2px; flex: none; }
.tri-acts .btn { padding: 2px 8px; font-size: 12.5px; }

.first-run { align-items: flex-start; }
.first-run p { color: var(--muted); margin: -6px 0 2px; }
.fr-opt { width: 100%; text-align: left; border: 1px solid var(--line-strong); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; background: #fff; }
.fr-opt:hover { border-color: var(--accent); background: var(--accent-soft); }
.fr-opt span { color: var(--muted); font-size: 13px; }

.boot-load { position: fixed; inset: 0; display: flex; flex-direction: column; gap: 14px; align-items: center; justify-content: center; background: var(--bg); z-index: 850; color: var(--muted); }
.boot-load .sb-logo { width: 44px; height: 44px; font-size: 22px; border-radius: 12px; animation: kpulse 1.2s ease-in-out infinite; }
@keyframes kpulse { 50% { transform: scale(.88); opacity: .7; } }

.capture > div:nth-of-type(1) { flex-wrap: wrap; }
.capture .input { flex: 1 1 220px; }

/* Appareils tactiles : cibles de 40 px, actions visibles sans survol */
@media (hover: none) {
  kbd { display: none; }
  .sb-acts { display: flex; }
  .sb-item { height: 40px; }
  .sb-chev { width: 32px; height: 32px; }
  .sb-link { min-height: 40px; }
  .ag-check { width: 26px; height: 26px; }
  .ag-row { min-height: 48px; }
  .icon-btn { min-width: 40px; min-height: 40px; }
}
@media (max-width: 820px) {
  .home-acts .btn.primary { display: none; } /* le bouton flottant fait la capture */
  .tri-acts .btn:nth-child(3) { display: none; }
  .toast { white-space: nowrap; bottom: calc(88px + env(safe-area-inset-bottom)) !important; max-width: calc(100vw - 32px); overflow: hidden; text-overflow: ellipsis; }
  .cover { height: 120px; }
  .page-head { padding-top: 10px; }
  .capture .input { flex: 1 1 100%; font-size: 16px; }
  .peek-bar .btn .lbl { display: none; }
  .peek { width: 100vw; }
}

/* ---------- Validation finale : design ---------- */
.flt-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 4px; }
.flt-presets .chip { cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.board .col { flex: 1 1 0; min-width: 220px; max-width: 340px; }
.peek-pos { font-size: 12px; color: var(--muted); padding: 0 4px; white-space: nowrap; }
.peek-on, .peek-on > .td { background: rgba(97, 97, 255, .08) !important; }
@media (min-width: 1200px) { .peek-back { background: rgba(50, 51, 56, .12); } }
/* Le bouton flottant s'efface dès qu'un menu, une fiche ou une saisie est ouverte */
body:has(.popup, .peek, .overlay) .fab, body:has(.editor [contenteditable]:focus) .fab, body:has(.page-title:focus) .fab { display: none; }
@media (hover: none) {
  .blk-ctrl { display: none; } /* poignées : menu du bloc par appui long */
  .ag-check { position: relative; }
  .ag-check::before { content: ''; position: absolute; inset: -9px; }
}
@media (max-width: 600px) {
  #view { padding-bottom: 96px; }
  .ag-row { flex-wrap: wrap; row-gap: 6px; }
  .ag-row .ag-t { flex: 1 1 calc(100% - 50px); white-space: normal; }
  .tri-acts { flex: 1 1 100%; padding-left: 38px; gap: 6px; }
  .tri-acts .btn { min-height: 36px; padding: 4px 12px; border: 1px solid var(--line); }
  .tri-acts .btn:nth-child(3) { display: inline-flex; }
}
