:root {
  --bg: #f6f4fa;
  --card: #ffffff;
  --ink: #2b2140;
  --muted: #7a7090;
  --accent: #4a2c6b;
  --accent-light: #6d4a97;
  --error: #c0392b;
}

* { box-sizing: border-box; }

/* l'attribut hidden doit gagner même sur les display:flex des classes */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--accent);
  color: #fff;
  padding: 14px 18px;
  padding-top: calc(14px + env(safe-area-inset-top));
}

.topbar-right { display: flex; align-items: center; gap: 6px; }

.burger {
  width: auto;
  background: none;
  border: none;
  color: #fff;
  font-size: 22px;
  padding: 4px 8px;
  line-height: 1;
}
.burger:active { background: rgba(255,255,255,.18); border-radius: 8px; }

.menu {
  position: absolute;
  top: 100%;
  right: 10px;
  z-index: 50;
  min-width: 200px;
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 6px 24px rgba(43,33,64,.25);
  padding: 6px;
}
.menu a {
  display: block;
  padding: 13px 16px;
  border-radius: 10px;
  color: var(--ink);
  text-decoration: none;
  font-weight: 600;
  font-size: 16px;
}
.menu a:active { background: var(--bg); }
.menu .menu-logout {
  border-top: 1px solid #efecf5;
  margin-top: 4px;
  color: var(--muted);
  font-weight: 400;
  font-size: 15px;
}

.brand { font-weight: 700; font-size: 19px; letter-spacing: .3px; color: #fff; text-decoration: none; }

.lang-switch a {
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-weight: 600;
  font-size: 14px;
  padding: 6px 10px;
  border-radius: 8px;
}
.lang-switch a.active { color: #fff; background: rgba(255,255,255,.18); }

.content { max-width: 560px; margin: 0 auto; padding: 18px 16px 40px; }

.card {
  background: var(--card);
  border-radius: 16px;
  padding: 22px 20px;
  margin-bottom: 16px;
  box-shadow: 0 1px 4px rgba(43,33,64,.08);
}

h1 { font-size: 24px; margin: 0 0 10px; }
h2 { font-size: 18px; margin: 0 0 8px; }
.sub { color: var(--muted); margin: 0; line-height: 1.5; }

.soon-card { text-align: center; padding: 40px 20px; }

.login-card { margin-top: 12vh; text-align: center; }
.login-emoji { font-size: 44px; margin-bottom: 6px; }

input[type=password] {
  width: 100%;
  font-size: 18px;
  padding: 14px;
  border: 1.5px solid #d8d2e4;
  border-radius: 12px;
  margin-bottom: 12px;
  background: #fbfaff;
}
input[type=password]:focus { outline: none; border-color: var(--accent-light); }

button {
  width: 100%;
  font-size: 18px;
  font-weight: 600;
  padding: 14px;
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}
button:active { background: var(--accent-light); }

.error { color: var(--error); font-weight: 600; }

.footer-links { text-align: center; }
.footer-links a { color: var(--muted); font-size: 14px; }

/* --- contacts : liste --- */

.search-wrap { position: relative; margin-bottom: 12px; }
.search {
  width: 100%;
  font-size: 17px;
  padding: 12px 42px 12px 14px;
  border: 1.5px solid #d8d2e4;
  border-radius: 12px;
  background: #fff;
  -webkit-appearance: none;
}
.search:focus { outline: none; border-color: var(--accent-light); }
.search::-webkit-search-cancel-button { -webkit-appearance: none; }
.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  background: #d8d2e4;
  color: var(--ink);
  font-size: 16px;
  line-height: 1;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  width: auto;
  font-size: 14px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  background: #e8e2f2;
  color: var(--accent);
}
.chip.active { background: var(--accent); color: #fff; }

.contact-list {
  background: var(--card);
  border-radius: 16px;
  box-shadow: 0 1px 4px rgba(43,33,64,.08);
  overflow: hidden;
  margin-bottom: 16px;
}
.contact-row {
  display: flex;
  align-items: center;
  border-bottom: 1px solid #efecf5;
}
.contact-row:last-child { border-bottom: none; }
.row-main {
  flex: 1;
  min-width: 0;
  padding: 13px 16px;
  text-decoration: none;
  color: var(--ink);
}
.row-name { display: block; font-weight: 600; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-meta { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }
.row-icons { display: flex; gap: 8px; padding-right: 14px; flex-shrink: 0; }

.msg-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
}
.msg-icon svg { width: 18px; height: 18px; }
.msg-icon.big { width: 52px; height: 52px; }
.msg-icon.big svg { width: 26px; height: 26px; }
.msg-icon.wa { background: #25d366; }
.msg-icon.viber { background: #7360f2; }
.msg-icon.tg { background: #229ed9; }

.empty, .empty-card { text-align: center; color: var(--muted); }

.fab {
  position: fixed;
  right: 20px;
  bottom: calc(24px + env(safe-area-inset-bottom));
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 34px;
  font-weight: 300;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(43,33,64,.35);
}
.fab:active { background: var(--accent-light); }

/* --- contacts : fiche --- */

.back-link { margin: 0 0 12px; }
.back-link a { color: var(--muted); text-decoration: none; font-size: 15px; }

.detail-icons { display: flex; gap: 14px; margin-top: 14px; }
.notes-card { background: #fdf8ec; }
.notes-text { margin: 0; line-height: 1.55; white-space: pre-wrap; }
.detail-line { margin: 0 0 10px; }
.detail-label { display: block; color: var(--muted); font-size: 13px; }
.detail-line a { color: var(--accent); }

.btn-secondary {
  display: block;
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  padding: 13px;
  border-radius: 12px;
  background: #e8e2f2;
  color: var(--accent);
  text-decoration: none;
  margin-top: 8px;
}

.btn-danger {
  background: #f6e5e2;
  color: var(--error);
}

.restore-form { padding-right: 12px; }
.btn-restore {
  width: auto;
  font-size: 14px;
  padding: 8px 14px;
  border-radius: 10px;
  background: #e8e2f2;
  color: var(--accent);
}

/* --- contacts : formulaire --- */

.contact-form label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 16px;
}
.contact-form input, .contact-form textarea {
  display: block;
  width: 100%;
  font-size: 17px;
  font-weight: 400;
  color: var(--ink);
  padding: 12px 14px;
  border: 1.5px solid #d8d2e4;
  border-radius: 12px;
  background: #fbfaff;
  margin-top: 6px;
  font-family: inherit;
}
.contact-form input:focus, .contact-form textarea:focus { outline: none; border-color: var(--accent-light); }
.field-hint { display: block; font-weight: 400; font-size: 13px; color: var(--muted); margin-top: 5px; }
.field-hint.warn { color: var(--error); font-weight: 600; }

.channels-block { margin-bottom: 16px; }
.channels-label { display: block; font-size: 14px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.channel-toggles { display: flex; flex-wrap: wrap; gap: 8px; }
.channel-toggle {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  font-weight: 600;
  padding: 9px 14px;
  border-radius: 999px;
  background: #eceaf2;
  color: var(--muted);
  cursor: pointer;
  margin-bottom: 0;
  -webkit-user-select: none;
  user-select: none;
}
.channel-toggle input { display: none; }
.channel-toggle svg { width: 18px; height: 18px; fill: #a8a0ba; }
.channel-toggle:has(input:checked) { color: #fff; }
.channel-toggle:has(input:checked) svg { fill: #fff; }
.channel-toggle.wa:has(input:checked) { background: #25d366; }
.channel-toggle.viber:has(input:checked) { background: #7360f2; }
.channel-toggle.tg:has(input:checked) { background: #229ed9; }
