/* =====================================================================
   CHEST — Thème Obsidienne : coque, barre latérale repliable & barre du haut
   100 % isolé sur html[data-layout="obsidienne"] (aucun impact sur Aurore / Braise).
   Fidèle à la maquette propal-1.html : noir pur #050505, verre fin rayon 20px,
   barre latérale décollée repliable (248px → 76px) avec lentille verticale,
   recherche rapide, état synchro et carte profil ouvrant le menu à droite.
   ===================================================================== */

html[data-layout="obsidienne"] {
  --ob-bg: #050505;
  --ob-ink: var(--ink, #f6f6f7);
  --ob-ink-2: var(--ink-2, #9b9ba1);
  --ob-ink-3: var(--ink-3, #66666e);
  --ob-line: rgba(var(--fg-rgb, 255, 255, 255), .08);
  --ob-edge: rgba(255, 255, 255, .11);
  --ob-glass: linear-gradient(165deg, rgba(255, 255, 255, .055), rgba(255, 255, 255, .018) 40%, rgba(255, 255, 255, .012));
  --ob-hi: inset 1px 1px 0 rgba(255, 255, 255, .12), inset -1px -1px 0 rgba(255, 255, 255, .03);
  --ob-sh: 0 24px 50px -20px rgba(0, 0, 0, .72);
  --ob-r: 20px;
  --ob-r-sm: 12px;
  --ob-ease: cubic-bezier(.16, 1, .3, 1);
  --gl-r: 20px;
  --gl-blur: 26px;
}

html[data-layout="obsidienne"][data-mode="light"] {
  --ob-bg: #f2f2f5;
  --ob-edge: rgba(20, 20, 40, .1);
  --ob-glass: linear-gradient(165deg, rgba(255, 255, 255, .86), rgba(255, 255, 255, .64) 48%, rgba(255, 255, 255, .74));
  --ob-hi: inset 1px 1px 0 rgba(255, 255, 255, .95), inset -1px -1px 0 rgba(20, 20, 40, .04);
  --ob-sh: 0 20px 44px -24px rgba(30, 20, 50, .24);
}

/* ---------- Fond & auras Obsidienne (3 halos doux, jamais derrière le texte principal) ---------- */
html[data-layout="obsidienne"] #chestShell.c2-shell {
  background: var(--ob-bg) !important;
}
html[data-layout="obsidienne"] #chestShell.c2-shell::before {
  right: -120px; top: -180px; left: auto; bottom: auto;
  width: 620px; height: 460px;
  background: radial-gradient(closest-side, rgba(var(--a1-rgb, 252, 18, 131), .24), transparent 72%);
  filter: blur(110px);
}
html[data-layout="obsidienne"] #chestShell.c2-shell::after {
  left: -240px; bottom: -240px; right: auto; top: auto;
  width: 560px; height: 480px;
  background: radial-gradient(closest-side, rgba(var(--a2-rgb, 249, 164, 94), .13), transparent 72%);
  filter: blur(110px);
}
html[data-layout="obsidienne"][data-mode="light"] #chestShell.c2-shell::before,
html[data-layout="obsidienne"][data-mode="light"] #chestShell.c2-shell::after {
  opacity: .38;
}

/* ---------- Barre latérale Obsidienne (bureau >= 901px) ---------- */
@media (min-width: 901px) {
  html[data-layout="obsidienne"] #chestShell.c2-shell {
    gap: 0;
  }

  /* Sidebar flottante en verre fin rayon 20px */
  html[data-layout="obsidienne"] #chestShell > .sb {
    flex: 0 0 248px;
    max-width: 248px;
    margin: 16px 0 16px 16px;
    height: calc(100dvh - 32px);
    min-height: 0 !important;
    padding: 16px 12px 14px;
    gap: 12px;
    border-radius: var(--ob-r);
    border: 1px solid var(--ob-edge);
    background: var(--ob-glass) !important;
    box-shadow: var(--ob-sh), var(--ob-hi);
    -webkit-backdrop-filter: blur(26px) saturate(1.15);
    backdrop-filter: blur(26px) saturate(1.15);
    overflow: visible;
    transition: flex-basis .34s var(--ob-ease), max-width .34s var(--ob-ease), padding .34s var(--ob-ease);
  }
  html[data-layout="obsidienne"] #chestShell > .sb::before {
    content: "";
    position: absolute;
    top: -1px; left: 12%; right: 12%; height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .52), transparent);
    border-radius: 0;
    pointer-events: none;
  }
  html[data-layout="obsidienne"][data-mode="light"] #chestShell > .sb::before {
    background: linear-gradient(90deg, transparent, #fff, transparent);
  }
  html[data-layout="obsidienne"] #chestShell > .sb::after { display: none !important; }

  /* On remplace l'ancienne bosse courbée .sb-tog par le bouton inline propre façon propal-1 */
  html[data-layout="obsidienne"] #chestShell .sb-tog { display: none !important; }

  /* Ligne du haut : marque CHEST + bouton replier */
  html[data-layout="obsidienne"] #chestShell .ob-sb-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 6px;
  }
  html[data-layout="obsidienne"] #chestShell .sb-brand {
    padding: 0 !important;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.03em;
  }
  html[data-layout="obsidienne"] #chestShell .sb-brand img {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    filter: drop-shadow(0 0 8px rgba(var(--a1-rgb, 252, 18, 131), .45));
  }
  html[data-layout="obsidienne"] #chestShell .ob-collapse {
    width: 30px;
    height: 30px;
    flex: none;
    border-radius: 9px;
    border: 0;
    background: transparent;
    color: var(--ob-ink-3);
    display: grid;
    place-items: center;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    transition: color .18s, background-color .18s, transform .14s var(--ob-ease);
  }
  html[data-layout="obsidienne"] #chestShell .ob-collapse svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.65;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  html[data-layout="obsidienne"] #chestShell .ob-collapse:active { transform: scale(.94); }
  @media (hover: hover) and (pointer: fine) {
    html[data-layout="obsidienne"] #chestShell .ob-collapse:hover {
      color: var(--ob-ink);
      background: rgba(var(--fg-rgb, 255, 255, 255), .06);
    }
  }
  html[data-layout="obsidienne"] #chestShell .ob-collapse:focus-visible {
    outline: 2px solid rgba(var(--a1-rgb, 252, 18, 131), .65);
    outline-offset: 2px;
  }

  /* Bouton recherche rapide dans la barre latérale (façon propal-1) */
  html[data-layout="obsidienne"] #chestShell .ob-find {
    display: flex;
    align-items: center;
    gap: 9px;
    height: 38px;
    width: 100%;
    padding: 0 8px 0 11px;
    border-radius: 11px;
    border: 1px solid var(--ob-line);
    background: rgba(0, 0, 0, .24);
    color: var(--ob-ink-3);
    font: 500 13px/1 'Instrument Sans', system-ui, sans-serif;
    cursor: pointer;
    text-align: left;
    touch-action: manipulation;
    user-select: none;
    transition: border-color .18s, color .18s, background-color .18s, transform .14s var(--ob-ease);
  }
  html[data-layout="obsidienne"][data-mode="light"] #chestShell .ob-find {
    background: rgba(20, 20, 40, .035);
  }
  html[data-layout="obsidienne"] #chestShell .ob-find svg {
    width: 15px;
    height: 15px;
    flex: none;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }
  html[data-layout="obsidienne"] #chestShell .ob-find kbd {
    margin-left: auto;
    font: 500 10.5px/1 'Instrument Sans', system-ui, sans-serif;
    padding: 3px 6px;
    border-radius: 6px;
    border: 1px solid var(--ob-line);
    color: var(--ob-ink-3);
    background: rgba(var(--fg-rgb, 255, 255, 255), .02);
  }
  html[data-layout="obsidienne"] #chestShell .ob-find:active { transform: scale(.98); }
  @media (hover: hover) and (pointer: fine) {
    html[data-layout="obsidienne"] #chestShell .ob-find:hover {
      border-color: rgba(var(--fg-rgb, 255, 255, 255), .18);
      color: var(--ob-ink-2);
    }
  }

  /* Navigation + lentille de verre verticale */
  html[data-layout="obsidienne"] #chestShell .sb-nav {
    position: relative;
    padding: 0 !important;
    gap: 2px;
    overflow-y: auto;
    overflow-x: visible;
    scrollbar-width: none;
  }
  html[data-layout="obsidienne"] #chestShell .sb-nav::-webkit-scrollbar { display: none; }
  html[data-layout="obsidienne"] #chestShell .sb-grp {
    padding: 12px 10px 5px;
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ob-ink-3);
  }
  html[data-layout="obsidienne"] #chestShell .sb-grp:first-child { padding-top: 2px; }

  html[data-layout="obsidienne"] #chestShell .ob-lens {
    position: absolute;
    left: 0; top: 0;
    z-index: 0;
    border-radius: 11px;
    opacity: 0;
    pointer-events: none;
    background: rgba(var(--fg-rgb, 255, 255, 255), .05);
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .07);
    transition: transform .26s var(--ob-ease), height .26s var(--ob-ease), opacity .16s ease;
  }
  html[data-layout="obsidienne"] #chestShell .sb-nav .nav-i {
    position: relative;
    z-index: 1;
    padding: 9px 10px !important;
    gap: 11px;
    border-radius: 11px !important;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ob-ink-2);
    background: transparent;
    user-select: none;
    transition: color .16s, background-color .16s, transform .14s var(--ob-ease);
  }
  html[data-layout="obsidienne"] #chestShell .sb-nav .nav-i:active { transform: scale(.98); }
  @media (hover: hover) and (pointer: fine) {
    html[data-layout="obsidienne"] #chestShell .sb-nav .nav-i:hover {
      background: transparent !important;
      color: var(--ob-ink);
    }
  }
  html[data-layout="obsidienne"] #chestShell .sb-nav .nav-i.on {
    color: var(--ob-ink) !important;
    font-weight: 600 !important;
    background: linear-gradient(90deg, rgba(var(--a1-rgb, 252, 18, 131), .16), rgba(var(--a2-rgb, 249, 164, 94), .05)) !important;
    box-shadow: inset 1px 1px 0 rgba(255, 255, 255, .08);
  }
  html[data-layout="obsidienne"] #chestShell .sb-nav .nav-i.on::before {
    left: -12px;
    top: 8px; bottom: 8px;
    height: auto;
    margin-top: 0;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: linear-gradient(180deg, var(--a1, #fc1283), var(--a2, #f9a45e));
    box-shadow: 0 0 12px rgba(var(--a1-rgb, 252, 18, 131), .7);
  }

  /* Pied de barre latérale : statut + carte profil (remplace l'ancien bloc .sb-acc brut) */
  html[data-layout="obsidienne"] #chestShell .sb-acc {
    margin-top: auto;
    padding: 10px 0 0 !important;
    border-top: 1px solid var(--ob-line);
    display: flex;
    flex-direction: column;
    gap: 8px;
  }
  html[data-layout="obsidienne"] #chestShell .sb-acc > .sb-acc__label,
  html[data-layout="obsidienne"] #chestShell .sb-acc > .sb-acc__row,
  html[data-layout="obsidienne"] #chestShell .sb-acc > .sb-out {
    display: none !important;
  }
  html[data-layout="obsidienne"] #chestShell .ob-sync {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    padding: 10px 11px;
    border-radius: 12px;
    background: rgba(var(--green-rgb, 51, 230, 166), .055);
    border: 1px solid rgba(var(--green-rgb, 51, 230, 166), .15);
    font-size: 12px;
    color: var(--ob-ink-2);
    line-height: 1.35;
  }
  html[data-layout="obsidienne"] #chestShell .ob-sync__dot {
    width: 7px;
    height: 7px;
    flex: none;
    margin-top: 4px;
    border-radius: 50%;
    background: var(--green, #33e6a6);
    box-shadow: 0 0 0 3px rgba(var(--green-rgb, 51, 230, 166), .16), 0 0 8px var(--green, #33e6a6);
  }
  html[data-layout="obsidienne"] #chestShell .ob-sync small {
    display: block;
    font-size: 11px;
    color: var(--ob-ink-3);
    margin-top: 1px;
  }
  html[data-layout="obsidienne"] #chestShell .ob-sb-me {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 8px;
    border-radius: 13px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--ob-ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    transition: background-color .16s, border-color .16s, transform .14s var(--ob-ease);
  }
  html[data-layout="obsidienne"] #chestShell .ob-sb-me:active { transform: scale(.98); }
  @media (hover: hover) and (pointer: fine) {
    html[data-layout="obsidienne"] #chestShell .ob-sb-me:hover,
    html[data-layout="obsidienne"] #chestShell .ob-sb-me[aria-expanded="true"] {
      background: rgba(var(--fg-rgb, 255, 255, 255), .045);
      border-color: var(--ob-line);
    }
  }
  html[data-layout="obsidienne"] #chestShell .ob-sb-me__av {
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 10px;
    overflow: hidden;
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, rgba(var(--a1-rgb, 252, 18, 131), .55), rgba(var(--a2-rgb, 249, 164, 94), .4));
    border: 1px solid var(--ob-edge);
  }
  html[data-layout="obsidienne"] #chestShell .ob-sb-me__av img {
    width: 100%; height: 100%; object-fit: cover; display: block;
  }
  html[data-layout="obsidienne"] #chestShell .ob-sb-me__txt {
    min-width: 0;
    flex: 1;
  }
  html[data-layout="obsidienne"] #chestShell .ob-sb-me__txt b {
    display: block;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  html[data-layout="obsidienne"] #chestShell .ob-sb-me__txt small {
    display: block;
    font-size: 11.5px;
    color: var(--ob-ink-3);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  html[data-layout="obsidienne"] #chestShell .ob-sb-me__dots {
    width: 16px;
    height: 16px;
    flex: none;
    color: var(--ob-ink-3);
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
  }

  /* État replié (76px, façon propal-1) */
  html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb {
    flex-basis: 74px;
    max-width: 74px;
    padding: 16px 10px 14px;
  }
  html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb .ob-sb-top {
    flex-direction: column;
    gap: 10px;
    padding: 0;
  }
  html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb .ob-find {
    justify-content: center;
    padding: 0;
    border-color: transparent;
    background: transparent;
  }
  html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb .ob-find span,
  html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb .ob-find kbd,
  html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb .ob-sync,
  html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb .ob-sb-me__txt,
  html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb .ob-sb-me__dots,
  html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb .ob-lens {
    display: none !important;
  }
  html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb .sb-grp {
    height: 1px !important;
    padding: 0 !important;
    margin: 9px 12px !important;
    background: var(--ob-line) !important;
    overflow: hidden;
  }
  html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb .sb-nav {
    overflow: visible;
    gap: 4px;
  }
  html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb .sb-nav .nav-i {
    justify-content: center;
    padding: 10px 0 !important;
    gap: 0;
  }
  html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb .sb-nav .nav-i.on::before {
    left: -10px;
  }
  html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb .ob-sb-me {
    justify-content: center;
    padding: 6px 0;
  }
  /* Infobulles instantanées à droite quand la sidebar est repliée */
  @media (hover: hover) and (pointer: fine) {
    html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb [data-ob-tip] { position: relative; }
    html[data-layout="obsidienne"] #chestShell .sbT:checked ~ .sb [data-ob-tip]:hover::after {
      content: attr(data-ob-tip);
      position: absolute;
      left: calc(100% + 14px);
      top: 50%;
      transform: translateY(-50%);
      white-space: nowrap;
      z-index: 90;
      padding: 6px 10px;
      border-radius: 9px;
      font: 500 12px/1.2 'Instrument Sans', system-ui, sans-serif;
      color: var(--ob-ink);
      background: rgba(18, 16, 20, .96);
      border: 1px solid var(--ob-edge);
      box-shadow: 0 12px 26px rgba(0, 0, 0, .55);
      pointer-events: none;
    }
    html[data-layout="obsidienne"][data-mode="light"] #chestShell .sbT:checked ~ .sb [data-ob-tip]:hover::after {
      background: rgba(255, 255, 255, .96);
      color: #141419;
      box-shadow: 0 10px 24px rgba(20, 20, 40, .18);
    }
  }

  /* ---------- Barre du haut Obsidienne (sobre, alignée au bento, rayon 12px) ---------- */
  html[data-layout="obsidienne"] #chestShell .c2-topbar {
    min-height: 58px !important;
    padding: 14px 28px 6px !important;
    border-bottom: 0 !important;
    background: transparent !important;
  }
  html[data-layout="obsidienne"] #chestShell #crumb {
    font-size: 13px;
    gap: 8px;
  }
  html[data-layout="obsidienne"] #chestShell #crumbCat {
    font-size: 12.5px !important;
    color: var(--ob-ink-3) !important;
    font-weight: 500;
  }
  html[data-layout="obsidienne"] #chestShell #crumbPage {
    font-weight: 600;
    color: var(--ob-ink);
    letter-spacing: -.015em;
  }
  html[data-layout="obsidienne"] #chestShell .c2-search label {
    height: 40px !important;
    width: 260px !important;
    border-radius: 12px !important;
    border: 1px solid var(--ob-edge) !important;
    background: var(--ob-glass) !important;
    box-shadow: var(--ob-hi);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
  }
  html[data-layout="obsidienne"] #chestShell #c2SearchKbd {
    font-family: 'Instrument Sans', system-ui, sans-serif !important;
    font-size: 11px !important;
    border-radius: 7px !important;
    padding: 2px 7px !important;
  }
  html[data-layout="obsidienne"] #chestShell .gl-me {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--ob-edge);
    background: var(--ob-glass);
    box-shadow: var(--ob-hi);
  }
  html[data-layout="obsidienne"] #chestShell .gl-me__av {
    border-radius: 11px;
  }
  html[data-layout="obsidienne"] #chestShell .c2-topbar #c2PageActions {
    flex-wrap: nowrap !important;
    gap: 8px !important;
  }
}

/* Popover profil Obsidienne : verre sombre rayon 16px façon propal-1 */
html[data-layout="obsidienne"] .gl-pop {
  border-radius: 16px;
  border-color: var(--ob-edge);
  background: linear-gradient(165deg, rgba(30, 25, 30, .9), rgba(11, 11, 13, .95));
  box-shadow: 0 32px 76px -22px rgba(0, 0, 0, .88), inset 1px 1px 0 rgba(255, 255, 255, .13);
}
html[data-layout="obsidienne"][data-mode="light"] .gl-pop {
  background: linear-gradient(165deg, rgba(255, 255, 255, .96), rgba(246, 245, 250, .97));
  box-shadow: 0 26px 64px -22px rgba(20, 20, 40, .28), inset 1px 1px 0 #fff;
}
html[data-layout="obsidienne"] .gl-pop .gl-item { border-radius: 10px; }

/* Masquer les ajouts Obsidienne quand on est dans un autre thème */
html:not([data-layout="obsidienne"]) .ob-collapse,
html:not([data-layout="obsidienne"]) .ob-find,
html:not([data-layout="obsidienne"]) .ob-lens,
html:not([data-layout="obsidienne"]) .ob-sync,
html:not([data-layout="obsidienne"]) .ob-sb-me {
  display: none !important;
}
html:not([data-layout="obsidienne"]) .ob-sb-top {
  display: contents;
}

@media (max-width: 900px) {
  html[data-layout="obsidienne"] .ob-collapse,
  html[data-layout="obsidienne"] .ob-find,
  html[data-layout="obsidienne"] .ob-lens,
  html[data-layout="obsidienne"] .ob-sync,
  html[data-layout="obsidienne"] .ob-sb-me {
    display: none !important;
  }
  html[data-layout="obsidienne"] #chestShell.c2-shell > .sb {
    border-radius: 18px 18px 0 0;
    border-top: 1px solid var(--ob-edge);
    background: rgba(10, 10, 12, .92) !important;
  }
  html[data-layout="obsidienne"][data-mode="light"] #chestShell.c2-shell > .sb {
    background: rgba(255, 255, 255, .92) !important;
  }
  html[data-layout="obsidienne"] #chestShell #crumb { flex: 1 1 0% !important; min-width: 0 !important; overflow: hidden !important; text-overflow: ellipsis !important; white-space: nowrap !important; }
  html[data-layout="obsidienne"] #chestShell #c2PageActions { flex: 0 0 auto !important; max-width: none !important; min-width: 0 !important; overflow: visible !important; }
  html[data-layout="obsidienne"] #chestShell #c2PageActions:has([data-cal-pair]) > span:first-child { display: none !important; }
  html[data-layout="obsidienne"] #chestShell #c2PageActions [data-cal-pair] { height: 32px !important; padding: 0 10px !important; font-size: 12px !important; gap: 5px !important; border-radius: 10px !important; }
}

@media (prefers-reduced-motion: reduce) {
  html[data-layout="obsidienne"] #chestShell > .sb,
  html[data-layout="obsidienne"] #chestShell .ob-lens {
    transition: none !important;
  }
}
@media (prefers-reduced-transparency: reduce) {
  html[data-layout="obsidienne"] #chestShell > .sb {
    background: #101013 !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }
}
