/* ===================================================================
   Mes Listes — feuille de style
   Palette "marché" : papier, encre, vert marché, tomate.
   =================================================================== */

:root {
  --papier:   #F7F8F3;
  --papier-2: #EFF1E8;
  --encre:    #232B22;
  --encre-2:  #5C675B;
  --craie:    #DFE4D6;
  --marche:   #2E7D4F;
  --marche-2: #256742;
  --marche-pale: #E2EFE5;
  --tomate:   #C8442E;
  --blanc:    #FFFFFF;
  --ombre:    0 10px 30px rgba(35, 43, 34, 0.14);
  --radius:   14px;
  --safe-b:   env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --papier:   #161B15;
    --papier-2: #1E241D;
    --encre:    #E8ECE4;
    --encre-2:  #9AA596;
    --craie:    #2C342A;
    --marche:   #4CAF7A;
    --marche-2: #5FC08C;
    --marche-pale: #22321F;
    --tomate:   #E5684F;
    --blanc:    #1E241D;
    --ombre:    0 10px 30px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }

/* L'attribut HTML "hidden" doit TOUJOURS gagner, même sur les éléments
   qui définissent leur propre display (ex. .sheet-backdrop en flex). */
[hidden] { display: none !important; }

html { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  background: var(--papier);
  color: var(--encre);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button { font: inherit; color: inherit; }

.view {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 16px calc(96px + var(--safe-b));
}

/* ------------------------------ Boutons ------------------------------ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  border-radius: var(--radius);
  padding: 12px 18px;
  font-weight: 600;
  cursor: pointer;
  min-height: 48px;
  transition: transform .06s ease;
}
.btn:active { transform: scale(.97); }

.btn-primary { background: var(--marche); color: #fff; }
.btn-primary:hover { background: var(--marche-2); }

.btn-ghost {
  background: transparent;
  color: var(--marche);
  border: 1.5px solid var(--craie);
}

.btn-danger { background: transparent; color: var(--tomate); border: 1.5px solid var(--craie); }

.btn-big { width: 100%; font-size: 17px; }

.btn-round {
  width: 48px;
  min-width: 48px;
  padding: 0;
  border-radius: 50%;
  font-size: 26px;
  line-height: 1;
}

.link {
  background: none;
  border: 0;
  padding: 0;
  color: var(--marche);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.iconbtn {
  background: none;
  border: 0;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--encre);
}
.iconbtn:active { background: var(--papier-2); }
.ico { width: 24px; height: 24px; }

:is(button, input, .link):focus-visible {
  outline: 3px solid var(--marche);
  outline-offset: 2px;
}

/* ------------------------------ Connexion ------------------------------ */

.auth-wrap {
  max-width: 400px;
  margin: 0 auto;
  padding-top: clamp(24px, 10vh, 80px);
}

.auth-brand { text-align: center; margin-bottom: 28px; }
.auth-logo { width: 72px; height: 72px; }
.auth-brand h1 { margin: 12px 0 4px; font-size: 30px; letter-spacing: -.02em; }
.auth-sub { margin: 0; color: var(--encre-2); }

.field { margin-bottom: 14px; }
.field label, .field-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--encre-2);
}
.field input {
  width: 100%;
  border: 1.5px solid var(--craie);
  border-radius: var(--radius);
  background: var(--blanc);
  color: var(--encre);
  padding: 13px 14px;
  font-size: 16px;
}
.field input:focus { border-color: var(--marche); outline: none; }

.auth-switch { text-align: center; color: var(--encre-2); margin-top: 18px; }

.bio-hint { text-align: center; color: var(--encre-2); font-size: 14px; margin: 10px 0 0; }

.rule {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--encre-2);
  font-size: 13px;
  margin: 20px 0;
}
.rule::before, .rule::after { content: ""; flex: 1; height: 1px; background: var(--craie); }

/* ------------------------------ Barre de titre ------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 0 10px;
  background: var(--papier);
}
.topbar-title {
  flex: 1;
  margin: 0;
  font-size: 24px;
  letter-spacing: -.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-center { flex: 1; min-width: 0; }
.topbar-center .topbar-title { font-size: 20px; }
.topbar-sub { margin: 0; font-size: 13px; color: var(--encre-2); }

/* ------------------------------ Bannière empreinte ------------------------------ */

.banner {
  background: var(--marche-pale);
  border: 1.5px solid var(--marche);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 14px;
}
.banner p { margin: 0 0 10px; }
.banner-actions { display: flex; gap: 10px; }

/* ------------------------------ Mes listes ------------------------------ */

.lists { list-style: none; margin: 4px 0 0; padding: 0; }

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--craie);
  padding: 16px 2px;
  text-align: left;
  cursor: pointer;
}
.list-row:active { background: var(--papier-2); }

.list-name { font-size: 17px; font-weight: 600; }
.list-meta { font-size: 13.5px; color: var(--encre-2); margin-top: 2px; }

.list-count {
  margin-left: auto;
  min-width: 34px;
  height: 34px;
  padding: 0 8px;
  border-radius: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  background: var(--marche-pale);
  color: var(--marche);
}
.list-count.done { background: var(--papier-2); color: var(--encre-2); }

/* ------------------------------ Onglets ------------------------------ */

.tabs {
  display: flex;
  gap: 6px;
  padding: 2px 0 10px;
  position: sticky;
  top: 58px;            /* sous la topbar */
  z-index: 4;
  background: var(--papier);
}
.tab {
  flex: 1;
  background: none;
  border: 1.5px solid var(--craie);
  border-radius: var(--radius);
  padding: 10px 8px;
  font-weight: 600;
  color: var(--encre-2);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.tab.active {
  border-color: var(--marche);
  background: var(--marche-pale);
  color: var(--marche);
}
.tab-badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--tomate);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ------------------------------ Items ------------------------------ */

.group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 18px 2px 6px;
  font-size: 14px;
  font-weight: 700;
  color: var(--encre-2);
}
.group-head .g-emoji { font-size: 17px; }
.group-head::after { content: ""; flex: 1; height: 1px; background: var(--craie); }

.item-cat {
  flex: none;
  background: var(--papier-2);
  border: 0;
  border-radius: 10px;
  width: 38px;
  height: 38px;
  font-size: 17px;
  cursor: pointer;
}


.items { list-style: none; margin: 4px 0 0; padding: 0; }

.item-row {
  display: flex;
  align-items: center;
  gap: 2px;
  border-bottom: 1px solid var(--craie);
}

.item-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 14px;
  background: none;
  border: 0;
  padding: 14px 2px;
  text-align: left;
  cursor: pointer;
  min-width: 0;
}

.check {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--encre-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, border-color .15s ease;
}
.check svg { width: 16px; height: 16px; opacity: 0; transform: scale(.4); transition: all .18s cubic-bezier(.2, 1.4, .5, 1); }

.item-label {
  font-size: 17px;
  overflow-wrap: anywhere;
  transition: color .15s ease;
}
.item-by { display: block; font-size: 12.5px; color: var(--encre-2); }

.item-row.checked .check { background: var(--marche); border-color: var(--marche); }
.item-row.checked .check svg { opacity: 1; transform: scale(1); }
.item-row.checked .item-label { color: var(--encre-2); text-decoration: line-through; text-decoration-color: var(--marche); }

.item-del {
  background: none;
  border: 0;
  width: 44px;
  height: 44px;
  color: var(--encre-2);
  font-size: 20px;
  cursor: pointer;
  border-radius: 12px;
}
.item-del:active { color: var(--tomate); }

#checked-tools { text-align: center; margin-top: 18px; }

/* ------------------------------ Discussion ------------------------------ */

.chat {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.msg {
  max-width: 82%;
  align-self: flex-start;
  background: var(--blanc);
  border: 1.5px solid var(--craie);
  border-radius: 16px 16px 16px 4px;
  padding: 9px 13px;
  position: relative;
}
.msg.mine {
  align-self: flex-end;
  background: var(--marche-pale);
  border-color: var(--marche);
  border-radius: 16px 16px 4px 16px;
}
.msg-name {
  display: block;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--marche);
  margin-bottom: 2px;
}
.msg-body { overflow-wrap: anywhere; white-space: pre-wrap; }
.msg-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 3px;
}
.msg-time { font-size: 11.5px; color: var(--encre-2); }
.msg-del {
  background: none;
  border: 0;
  padding: 0;
  font-size: 12px;
  color: var(--encre-2);
  cursor: pointer;
}
.msg-del:hover { color: var(--tomate); }

/* ------------------------------ Composer (barre du bas) ------------------------------ */

.composer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  gap: 10px;
  max-width: 560px;
  margin: 0 auto;
  padding: 12px 16px calc(12px + var(--safe-b));
  background: var(--papier);
  border-top: 1px solid var(--craie);
}
.composer input {
  flex: 1;
  border: 1.5px solid var(--craie);
  border-radius: 24px;
  background: var(--blanc);
  color: var(--encre);
  padding: 12px 18px;
  font-size: 16px;
}
.composer input:focus { border-color: var(--marche); outline: none; }

/* ------------------------------ État vide ------------------------------ */

.empty {
  text-align: center;
  color: var(--encre-2);
  margin-top: 56px;
  line-height: 1.6;
}
.empty-small { color: var(--encre-2); font-size: 14px; margin: 6px 0; }

/* ------------------------------ Feuilles (bottom sheets) ------------------------------ */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: rgba(20, 26, 19, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: 100%;
  max-width: 560px;
  max-height: 86vh;
  overflow-y: auto;
  background: var(--papier);
  border-radius: 20px 20px 0 0;
  padding: 18px 18px calc(24px + var(--safe-b));
  box-shadow: var(--ombre);
  animation: sheet-up .22s ease;
}
@keyframes sheet-up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .sheet { animation: none; }
  .check svg, .btn { transition: none; }
}

.sheet-head { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.sheet-head h2 { flex: 1; margin: 0; font-size: 19px; overflow-wrap: anywhere; }
.sheet-subtitle { font-size: 14px; color: var(--encre-2); margin: 22px 0 8px; }

.share-form .btn { width: 100%; }

.seg { display: flex; gap: 8px; }
.seg label { flex: 1; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span {
  display: block;
  text-align: center;
  padding: 11px 8px;
  border: 1.5px solid var(--craie);
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
}
.seg input:checked + span { border-color: var(--marche); background: var(--marche-pale); color: var(--marche); }
.seg input:focus-visible + span { outline: 3px solid var(--marche); outline-offset: 2px; }

.suggest {
  list-style: none;
  margin: 6px 0 0;
  padding: 6px;
  border: 1.5px solid var(--craie);
  border-radius: var(--radius);
  background: var(--blanc);
}
.suggest button {
  width: 100%;
  background: none;
  border: 0;
  text-align: left;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}
.suggest button:hover, .suggest button:focus-visible { background: var(--papier-2); }
.suggest .u { font-weight: 600; }
.suggest .d { color: var(--encre-2); font-size: 14px; }

.members { list-style: none; margin: 0; padding: 0; }
.members li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 0;
  border-bottom: 1px solid var(--craie);
}
.member-name { flex: 1; min-width: 0; }
.member-name .d { display: block; font-size: 13px; color: var(--encre-2); }
.member-role {
  border: 1.5px solid var(--craie);
  background: var(--blanc);
  color: var(--encre);
  border-radius: 10px;
  padding: 7px 8px;
  font-size: 14px;
}
.member-remove { background: none; border: 0; color: var(--tomate); font-size: 18px; width: 40px; height: 40px; cursor: pointer; }

.menu { display: flex; flex-direction: column; gap: 4px; }
.menu-row {
  background: none;
  border: 0;
  border-bottom: 1px solid var(--craie);
  text-align: left;
  padding: 15px 4px;
  font-size: 16px;
  cursor: pointer;
}
.menu-row.danger { color: var(--tomate); }
.menu-row:last-child { border-bottom: 0; }

.settings-id { color: var(--encre-2); margin: 0 0 6px; }
#sheet-settings .btn { width: 100%; margin-top: 10px; }

/* ------------------------------ Toast ------------------------------ */

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(92px + var(--safe-b));
  transform: translateX(-50%);
  z-index: 40;
  background: var(--encre);
  color: var(--papier);
  padding: 11px 18px;
  border-radius: 24px;
  font-size: 15px;
  max-width: calc(100% - 40px);
  box-shadow: var(--ombre);
}
