/* ============================================================
   MAMOUSSO V39 — nouveau design de l'espace client (d'après la maquette).
   Chargé APRÈS app.css et les feuilles de chaque page : il change les couleurs
   (orange plus vif, fond blanc cassé), passe les titres en Inter gras, rend le
   menu latéral clair (solde de crédits en bas) et ajoute la recherche et le menu
   « Mon compte » de la barre du haut, ainsi que la page « Accueil ».
   Le thème sombre garde ses couleurs, avec le nouvel orange.
   ============================================================ */

:root {
  --ui-bg: #faf9f7;
  --ui-surface: #ffffff;
  --ui-surface-2: #fbfaf8;
  --ui-text: #1c1a18;
  --ui-text-2: #3b3733;
  --ui-muted: #6f6a64;
  --ui-faint: #9d978f;
  --ui-line: #eeebe7;
  --ui-line-strong: #e1dcd5;
  --ui-accent: #e9622f;
  --ui-accent-hover: #d65222;
  --ui-accent-soft: #fdeee6;
  --ui-grad-from: #f4834f;
  --ui-grad-to: #e75a27;
  --ui-ring: 0 0 0 4px rgba(233, 98, 47, .16);
  --ui-glow-1: rgba(246, 146, 100, .16);
  --ui-glow-2: rgba(252, 205, 175, .2);
  --ui-dots: transparent;
  --ui-serif: var(--ui-sans);
  --ui-sidebar: 250px;
  --ui-card-shadow: 0 1px 2px rgba(28, 26, 24, .04), 0 6px 20px -8px rgba(60, 40, 25, .08);
  --ui-hover-shadow: 0 1px 2px rgba(28, 26, 24, .05), 0 14px 30px -12px rgba(60, 40, 25, .16);
  --sh-side-bg: #ffffff;
  --sh-side-line: #f0ece8;
  --sh-side-text: #3b3733;
  --sh-side-muted: #8e8881;
  --sh-side-hover: #f7f4f1;
  --sh-wallet-bg: #fff7f2;
  --sh-wallet-line: #f8e3d7;
  --sh-avatar-from: #f8b08c;
  --sh-avatar-to: #ef7b4b;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ui-accent: #f08a5d;
    --ui-accent-hover: #f59b72;
    --ui-accent-soft: rgba(240, 138, 93, .15);
    --ui-grad-from: #f4834f;
    --ui-grad-to: #e2582a;
    --ui-ring: 0 0 0 4px rgba(240, 138, 93, .24);
    --ui-dots: transparent;
    --sh-side-bg: #201f1d;
    --sh-side-line: #34322f;
    --sh-side-text: #e6e2da;
    --sh-side-muted: #9a958c;
    --sh-side-hover: rgba(255, 255, 255, .05);
    --sh-wallet-bg: rgba(240, 138, 93, .08);
    --sh-wallet-line: rgba(240, 138, 93, .22);
  }
}
:root[data-theme="dark"] {
  --ui-accent: #f08a5d;
  --ui-accent-hover: #f59b72;
  --ui-accent-soft: rgba(240, 138, 93, .15);
  --ui-grad-from: #f4834f;
  --ui-grad-to: #e2582a;
  --ui-ring: 0 0 0 4px rgba(240, 138, 93, .24);
  --ui-dots: transparent;
  --sh-side-bg: #201f1d;
  --sh-side-line: #34322f;
  --sh-side-text: #e6e2da;
  --sh-side-muted: #9a958c;
  --sh-side-hover: rgba(255, 255, 255, .05);
  --sh-wallet-bg: rgba(240, 138, 93, .08);
  --sh-wallet-line: rgba(240, 138, 93, .22);
}

/* ================================================================ titres : Inter gras, comme la maquette */
.appBody h1, .appBody h2, .appBody h3 { font-family: var(--ui-sans); font-weight: 700; letter-spacing: -.022em; }
.appBody .appTopbar .subtitle { font-family: var(--ui-sans); font-weight: 700; letter-spacing: -.025em; font-size: clamp(21px, 2.3vw, 26px); }
.appBody ::selection { background: rgba(233, 98, 47, .2); }

/* ================================================================ menu latéral clair */
.appSidebar {
  color: var(--sh-side-text);
  background: var(--sh-side-bg);
  border-right: 1px solid var(--sh-side-line);
}
.appSidebar::before { display: none; }
.appLegal { margin: 0; padding: 0 10px; color: var(--sh-side-muted); font-size: 12px; line-height: 1.5; }
.appLegal a { color: inherit; text-decoration: none; }
.appLegal a:hover { color: var(--ui-accent); text-decoration: underline; }
/* la colonne du menu garde sa couleur jusqu'en bas des pages longues (le menu lui-même reste collé en haut de l'écran) */
@media (min-width: 901px) {
  .appShell { background: linear-gradient(to right, var(--sh-side-bg) calc(var(--ui-sidebar) - 1px), var(--sh-side-line) calc(var(--ui-sidebar) - 1px), var(--sh-side-line) var(--ui-sidebar), transparent var(--ui-sidebar)); }
}
.appSidebarInner { padding: 22px 14px 16px; }
.appSidebarHead { margin-bottom: 26px; padding: 0 8px; }
.appLogo {
  gap: 9px;
  color: var(--ui-text);
  font-family: var(--ui-sans);
  font-size: 19px;
  font-weight: 800;
  letter-spacing: .01em;
}
.appLogoMark { color: var(--ui-accent); border-radius: 0; box-shadow: none; }
.appSidebarClose { color: var(--sh-side-text); border-color: var(--sh-side-line); background: transparent; }
.appNav { gap: 2px; }
.appNavLabel { margin: 18px 12px 6px; color: var(--sh-side-muted); }
.appNavItem {
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--sh-side-text);
  font-size: 14.5px;
  font-weight: 500;
}
.appNavItem svg { width: 19px; height: 19px; stroke-width: 1.75; opacity: .9; }
.appNavItem:hover { background: var(--sh-side-hover); color: var(--ui-text); }
.appNavItem.isActive { background: var(--ui-accent-soft); color: var(--ui-accent); font-weight: 600; }
.appNavItem.isActive svg { stroke: var(--ui-accent); opacity: 1; }
.appNavItem.isActive::before { display: none; }
.appNavItem:focus-visible { box-shadow: 0 0 0 2px var(--ui-accent); }
.appSidebarFoot { gap: 14px; padding-top: 18px; }

.appWallet {
  display: grid;
  gap: 2px;
  padding: 14px 14px 14px;
  border: 1px solid var(--sh-wallet-line);
  border-radius: 14px;
  background: var(--sh-wallet-bg);
}
.appWallet[hidden] { display: none; }
.appWalletHead { display: flex; align-items: center; gap: 8px; color: var(--ui-text-2); font-size: 13px; font-weight: 600; }
.appWalletIcon { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: var(--ui-accent-soft); color: var(--ui-accent); }
.appWalletIcon svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; }
.appWalletAmount { margin-top: 6px; color: var(--ui-text); font-size: 21px; font-weight: 800; letter-spacing: -.02em; line-height: 1.15; }
.appWalletCredits { color: var(--ui-muted); font-size: 12.5px; }
.appWalletBtn {
  margin-top: 10px;
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, var(--ui-grad-from), var(--ui-grad-to));
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 8px 18px -10px rgba(233, 98, 47, .9);
  transition: filter .2s, transform .2s;
}
.appWalletBtn:hover { filter: brightness(1.05); transform: translateY(-1px); }
.appWalletBtn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--ui-ring), 0 0 0 1px #fff inset; }

/* ================================================================ barre du haut : recherche et « Mon compte » */
.appBody .topbarActions { gap: 10px; }
.appSearch {
  position: relative;
  display: flex;
  align-items: center;
  width: clamp(200px, 26vw, 340px);
  height: 42px;
  padding: 0 12px 0 38px;
  border: 1px solid var(--ui-line);
  border-radius: 12px;
  background: var(--ui-surface);
  box-shadow: var(--ui-btn-shadow);
  transition: border-color .2s, box-shadow .2s;
}
.appSearch:focus-within { border-color: var(--ui-accent); box-shadow: var(--ui-ring); }
.appSearch svg { position: absolute; left: 12px; width: 17px; height: 17px; fill: none; stroke: var(--ui-faint); stroke-width: 2; stroke-linecap: round; }
.appSearch input {
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ui-text);
  font-size: 14px;
}
.appSearch input::placeholder { color: var(--ui-faint); }
.appSearch input::-webkit-search-cancel-button { cursor: pointer; }

.appAccount { position: relative; }
.appAccount > summary {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 42px;
  padding: 0 10px 0 5px;
  border: 1px solid var(--ui-line);
  border-radius: 999px;
  background: var(--ui-surface);
  color: var(--ui-text);
  font-size: 14px;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
  user-select: none;
  box-shadow: var(--ui-btn-shadow);
}
.appAccount > summary::-webkit-details-marker { display: none; }
.appAccount > summary:focus-visible { outline: none; box-shadow: var(--ui-ring); }
.appAccountAvatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--sh-avatar-from), var(--sh-avatar-to));
  color: #fff;
  font-size: 14px;
  font-weight: 700;
}
.appAccountChevron { width: 16px; height: 16px; fill: none; stroke: var(--ui-muted); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: transform .2s; }
.appAccount[open] .appAccountChevron { transform: rotate(180deg); }
.appAccountMenu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 60;
  display: grid;
  min-width: 230px;
  padding: 8px;
  border: 1px solid var(--ui-line);
  border-radius: 14px;
  background: var(--ui-surface);
  box-shadow: 0 18px 40px -16px rgba(28, 26, 24, .28);
}
.appAccountWho { display: grid; padding: 8px 10px 10px; line-height: 1.3; }
.appAccountWho strong { color: var(--ui-text); font-size: 14px; }
.appAccountWho small { color: var(--ui-muted); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appAccountMenu a {
  padding: 9px 10px;
  border-radius: 9px;
  color: var(--ui-text-2);
  font-size: 14px;
  text-decoration: none;
}
.appAccountMenu a:hover, .appAccountMenu a:focus-visible { background: var(--ui-accent-soft); color: var(--ui-accent); outline: none; }
.appAccountMenu hr { width: 100%; margin: 6px 0; border: 0; border-top: 1px solid var(--ui-line); }
.appAccountMenu .appAccountOut { color: var(--ui-danger); }

/* ================================================================ boutons principaux en orange */
.appBody .dbPrimary {
  background: linear-gradient(180deg, var(--ui-grad-from), var(--ui-grad-to));
  box-shadow: 0 10px 22px -12px rgba(233, 98, 47, .85), 0 1px 0 rgba(255, 255, 255, .25) inset;
}

/* ================================================================ page « Accueil » */
.homePage { width: min(1080px, calc(100% - 64px)); }
.homeHero { position: relative; padding: 6px 0 4px; }
.homeBadge {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
  font-size: 13px;
  font-weight: 600;
}
.homeHero h1 {
  margin: 16px 0 12px;
  font-size: clamp(32px, 4.4vw, 46px);
  font-weight: 800;
  line-height: 1.08;
  letter-spacing: -.035em;
}
.homeHero h1 em { font-style: normal; color: var(--ui-accent); }
.homeHero p { max-width: 620px; margin: 0; color: var(--ui-muted); font-size: 16px; line-height: 1.6; }

.homeActions { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; margin: 30px 0 34px; }
.homeAction {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 24px;
  border: 1px solid var(--ui-line);
  border-radius: 18px;
  background: var(--ui-surface);
  box-shadow: var(--ui-card-shadow);
  transition: box-shadow .25s, transform .25s;
}
.homeAction:hover { box-shadow: var(--ui-hover-shadow); transform: translateY(-2px); }
.homeActionIcon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 8px;
  border-radius: 13px;
  background: var(--ui-accent-soft);
  color: var(--ui-accent);
}
.homeActionIcon svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.homeAction h2 { margin: 0; font-size: 19px; }
.homeAction p { flex: 1; margin: 0 0 10px; color: var(--ui-muted); font-size: 14.5px; line-height: 1.55; }
.homeBtn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 18px;
  border-radius: 11px;
  font-size: 14.5px;
  font-weight: 600;
  text-decoration: none;
  transition: filter .2s, transform .2s, background .2s;
}
.homeBtn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.homeBtn:hover { transform: translateY(-1px); }
.homeBtn:focus-visible { outline: none; box-shadow: var(--ui-ring); }
.homeBtnPrimary {
  background: linear-gradient(180deg, var(--ui-grad-from), var(--ui-grad-to));
  color: #fff;
  box-shadow: 0 10px 22px -12px rgba(233, 98, 47, .85);
}
.homeBtnPrimary:hover { filter: brightness(1.05); }
.homeBtnSoft { background: var(--ui-accent-soft); color: var(--ui-accent); }

.homeRecent { padding: 0; }
.homeRecentHead { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.homeRecentHead h2 { margin: 0; font-size: 19px; }
.homeRecentHead a { color: var(--ui-accent); font-size: 14px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.homeRecentHead a svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.homeRecentHead a:hover { text-decoration: underline; }
.homeQuery { margin: -4px 0 12px; color: var(--ui-muted); font-size: 14px; }
.homeQuery a { color: var(--ui-accent); }
.homeList {
  margin: 0;
  padding: 0;
  list-style: none;
  border: 1px solid var(--ui-line);
  border-radius: 16px;
  background: var(--ui-surface);
  box-shadow: var(--ui-card-shadow);
  overflow: hidden;
}
.homeRow {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border-top: 1px solid var(--ui-line);
}
.homeRow:first-child { border-top: 0; }
.homeRowIcon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  background: var(--ui-surface-2);
  border: 1px solid var(--ui-line);
  color: var(--ui-text-2);
}
.homeRowIcon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.homeRowIcon.isAudio { background: var(--ui-accent-soft); border-color: transparent; color: var(--ui-accent); }
.homeRowText { min-width: 0; }
.homeRowText strong { display: block; color: var(--ui-text); font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.homeRowText small { color: var(--ui-muted); font-size: 12.5px; }
.homeStatus {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  background: var(--ui-ok-soft);
  color: var(--ui-ok);
}
.homeStatus::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.homeStatus.isBusy { background: var(--ui-info-soft); color: var(--ui-info); }
.homeStatus.isError { background: var(--ui-danger-soft); color: var(--ui-danger); }
.homeStatus.isMuted { background: var(--ui-surface-2); color: var(--ui-muted); }
.homeBar { display: block; width: 120px; height: 6px; margin-top: 6px; border-radius: 999px; background: var(--ui-line); overflow: hidden; }
.homeBar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--ui-grad-from), var(--ui-grad-to)); }
.homeOpen {
  padding: 8px 14px;
  border: 1px solid var(--ui-line-strong);
  border-radius: 10px;
  background: var(--ui-surface);
  color: var(--ui-text);
  font-size: 13.5px;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color .2s, color .2s;
}
.homeOpen:hover, .homeOpen:focus-visible { border-color: var(--ui-accent); color: var(--ui-accent); outline: none; }
.homeEmpty { padding: 30px 20px; color: var(--ui-muted); text-align: center; font-size: 14.5px; }
.homeEmpty a { color: var(--ui-accent); font-weight: 600; }

.homeFeatures { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 14px; margin-top: 30px; }
.homeFeature {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 16px;
  border: 1px solid var(--ui-line);
  border-radius: 14px;
  background: var(--ui-surface);
}
.homeFeature svg { width: 26px; height: 26px; flex: none; fill: none; stroke: var(--ui-accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.homeFeature strong { display: block; color: var(--ui-text); font-size: 14.5px; }
.homeFeature small { color: var(--ui-muted); font-size: 13px; line-height: 1.45; }

/* ================================================================ écrans moyens et petits */
@media (max-width: 1180px) {
  .appSearch { width: clamp(170px, 22vw, 260px); }
  .appAccountLabel { display: none; }
}
@media (max-width: 960px) {
  .appBody .appTopbar .topbarActions .appSearch { order: 3; flex: 1 1 100%; width: auto; }
}
@media (max-width: 640px) {
  .homePage { width: calc(100% - 24px); }
  .homeRow { grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; padding: 12px; }
  .homeRow .homeStatus { display: none; }
  .homeRowIcon { width: 36px; height: 36px; }
  .homeAction { padding: 20px; }
}

/* ordre dans la barre du haut : recherche d'abord, « Mon compte » en dernier */
.appBody .topbarActions .appSearch { order: -1; }
.appBody .topbarActions .appAccount { order: 99; }

/* la barre du haut passe au-dessus du contenu de la page : le menu « Mon compte » ouvert n'est plus recouvert
   (son animation d'entrée en fait un contexte d'empilement ; reste sous le menu latéral du téléphone, z-index 39-40) */
.appBody .appTopbar { position: relative; z-index: 30; }

/* ================================================================ V72 : confort sur téléphone et accessibilité */
/* le titre de la page dans la barre du haut est un vrai titre de niveau 1 */
.appBody .appTopbar h1.subtitle { margin: 0; }
/* le message d'état (« service indisponible ») prend sa propre ligne, en entier : il ne pousse plus la barre hors de l'écran */
.appBody .appTopbar .topbarActions { flex-wrap: wrap; }
@media (max-width: 900px) {
  /* la recherche reste sur la ligne des boutons et prend la place libre */
  .appBody .appTopbar .topbarActions .appSearch { flex: 1 1 0; min-width: 0; width: auto; }
  .appBody .appTopbar .topbarActions .pill { flex: 1 1 100%; }
}
.appBody .appTopbar .topbarActions .pill {
  order: 100;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
  height: auto;
  min-height: 42px;
  padding-top: 8px;
  padding-bottom: 8px;
  white-space: normal;
  line-height: 1.35;
}
/* boutons assez grands pour le doigt */
.appBody .appSearch, .appBody .appAccount > summary { height: 44px; box-sizing: border-box; }
.appBody .appTopbar .mxThemeToggle, .appBody .appTopbar .appThemeToggle { flex: none; width: 44px; height: 44px; }
.appWalletBtn { min-height: 44px; display: grid; place-items: center; box-sizing: border-box; }
.appAccountMenu a { min-height: 44px; display: flex; align-items: center; box-sizing: border-box; }
/* lien « Aller au contenu » : visible seulement au clavier */
.appSkip {
  position: fixed;
  left: 12px;
  top: -80px;
  z-index: 200;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--ui-text);
  color: var(--ui-bg, #fff);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.appSkip:focus { top: 12px; outline: 2px solid var(--ui-accent); outline-offset: 2px; }
main:focus { outline: none; }
