/* =========================================================
   Nexalys UI — clean consolidated CSS (same behavior)
   ========================================================= */

/* =============================
   Theme tokens
   ============================= */
:root{
  /* Background */
  --bg-page: #f3f4f6;
  --bg-page-soft: #f8fafc;

  /* Surfaces */
  --card: #ffffff;
  --border: #e2e8f0;

  /* Text */
  --text: #020617;
  --muted: #6b7280;

  /* Brand */
  --brand: #224494;
  --brand-ink: #0b1f3b;
  --brand-soft: #eff6ff;
  --brand-soft-strong: #dbeafe;

    /* Privacy card */
--privacy-card-bg: #ffffff;

  --privacy-card-border: #e0e0e0;

  /* Sidebar */
  --sidebar-w: 150px;
  --sidebar-bg: linear-gradient(180deg, #e4e4e4 0%, #e5e7eb 100%);
  --sidebar-border: var(--border);
  --sidebar-active: var(--brand-soft);
  --sidebar-hover: #f3f4f6;

  /* Chat */
  --lh-chat: 1.35;
  --user-bubble-bg: #e6e6e6;
  --user-bubble-border: #e2e8f0;
  --user-bubble-text: #0f172a;

  /* Radius / shadows */
  --radius-md: 12px;
  --radius-sm: 10px;
  --shadow-1: 0 1px 2px rgba(15, 23, 42, 0.08);
  --shadow-2: 0 8px 30px rgba(15, 23, 42, 0.10);

  /* Fonts */
  --font-ui: "InterVariable","Inter",system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;
  --font-content: "InterVariable","Inter",system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;

  /* Composer sizing (final overrides kept) */
  --composer-min-h: 36px;
  --composer-max-h: 160px;

  /* Ink (composer focus + send hover) */
  --ink: #020617;
  --ink-ring: rgba(2, 6, 23, 0.16);

  /* Floating buttons */
  --fab-size: 30px;
--fab-scale-hover: 1;
  --fab-inset: 2px;

  /* Composer separators (grid version) */
  --composer-sep-color: rgba(15, 23, 42, 0.14);
  --composer-sep-h: 16px;
  --composer-gap-min: 14px;

  /* Feedback colors */
  --ok-soft: #ecfdf3;
  --ok-border: #bbf7d0;
  --ok-ink: #166534;

  --bad-soft: #fef2f2;
  --bad-border: #fecaca;
  --bad-ink: #991b1b;
}

/* =============================
   Base
   ============================= */
html, body{
  height: 100dvh;
  margin: 0;
  padding: 0;
  background: linear-gradient(180deg, var(--bg-page-soft) 0%, var(--bg-page) 160px);
}

body{
  font-family: var(--font-ui);
  font-optical-sizing: auto;
  font-feature-settings: "liga" 1, "calt" 1, "ss01" 1, "cv05" 1;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  letter-spacing: 0.005em;
  color: var(--text);
}

/* Focus visible global */
button:focus-visible,
[role="button"]:focus-visible{
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* Always respect hidden */
[hidden]{ display:none !important; }

/* =============================
   Header
   ============================= */
header.header{
  position: sticky;
  top: 0;
  z-index: 1000;

  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;

  border-bottom: 1px solid var(--border);
  background: radial-gradient(circle at top left, var(--brand-soft), var(--bg-page));
}

.header-left{ display:flex; align-items:center; gap:8px; }
.app-title{ font-weight:600; letter-spacing:.005em; color:var(--brand-ink); }

/* =============================
   App shell
   ============================= */
#app-body{ flex: 1 1 auto; padding: 0; display: block; }

.app-shell{
  height: 100dvh;
  display: flex;
  min-height: 0;
  position: relative;
  background: transparent;
}

/* =============================
   Sidebar + backdrop
   ============================= */
.sidebar{
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);

  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px 8px;

  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 50;

  transform: translateX(0);
  transition: transform 0.18s ease-out, box-shadow 0.18s ease-out;

  box-shadow: 6px 0 20px rgba(15, 23, 42, 0.12), inset -1px 0 0 rgba(255, 255, 255, 0.6);

  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar.collapsed{
  transform: translateX(-100%);
  box-shadow: none;
  pointer-events: none;
}

.sidebar-backdrop{
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.30);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease-out;
  z-index: 40;
}
.app-shell.sidebar-open .sidebar-backdrop{
  opacity: 1;
  pointer-events: auto;
}

.side-top{ display:grid; gap:10px; }

/* Nav */
.sidenav{
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 4px;
}

.nav-btn{
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;

  cursor: pointer;
  color: #1f2937;
  text-align: left;
  font-size: 13px;

  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}

.nav-btn .ico{
  width: 16px;
  height: 16px;
  display: inline-block;
  flex: 0 0 16px;
  color: #4b5563;
}

.nav-btn .label{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn:hover{
  background: var(--sidebar-hover);
  color: var(--brand-ink);
  font-weight: 600;
}
.nav-btn:hover .ico{ color: var(--brand); }

.nav-btn.active{
  background: linear-gradient(135deg, var(--brand-soft), var(--brand-soft-strong));
  border-color: #93c5fd;
  color: var(--brand-ink);
  font-weight: 600;
}
.nav-btn.active .ico{ color: var(--brand); }

/* Groups + chevron accordion */
.nav-group{ margin-top: 6px; }

.nav-parent{ justify-content: space-between; }

.nav-parent .chevron{
  margin-left: auto;
  display: inline-flex;
  width: 14px;
  height: 14px;
  opacity: 0.6;
  transition: transform 0.16s ease, opacity 0.16s ease;
}
.nav-parent[aria-expanded="true"] .chevron{
  transform: rotate(90deg);
  opacity: 1;
}

/* Sub-menu */
.nav-sub{
  display: none;
  flex-direction: column;
  gap: 2px;
  margin-top: 2px;
  padding-left: 14px;
  position: relative;
}
.nav-sub.open{ display:flex; }

.nav-sub::before{
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 4px;
  width: 2px;
  border-radius: 999px;
  background: linear-gradient(to bottom, #e5e7eb, #cbd5f5);
  opacity: 0.9;
}

.nav-sub-btn{
  font-size: 12px;
  padding: 4px 8px 4px 14px;
  border-radius: 999px;
}

.nav-sub-btn.active{
  background: #eff6ff;
  border-color: #bfdbfe;
  color: var(--brand-ink);
  box-shadow: none;
}

/* Sidebar bottom account */
.side-bottom{
  margin-top: auto;
  border-top: 1px dashed var(--sidebar-border);
  padding-top: 10px;
}

.account-card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px;
  box-shadow: var(--shadow-1);

  display: flex;
  flex-direction: column;
  gap: 8px;
}

.account-main{
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.account-avatar{
  width: 26px;
  height: 26px;
  border-radius: 999px;
  background: var(--brand-soft);
  color: var(--brand-ink);

  display: flex;
  align-items: center;
  justify-content: center;

  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.account-text{
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.user-name,
.user-name span{
  font-size: 12px;
  font-weight: 500;
  color: var(--brand-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email,
.user-email span{
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.account-stats{
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px dashed var(--sidebar-border);

  display: flex;
  flex-direction: column;
  gap: 4px;
}

.account-stat{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11px;
}
.stat-label{ color: var(--muted); }
.stat-value{ font-weight: 600; color: var(--brand-ink); }

.plan-badge{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 8px;
  border-radius: 999px;

  font-size: 10px;
  font-weight: 500;
  border: 1px solid #dbeafe;
  background: var(--brand-soft);
  color: var(--brand-ink);
}
.plan-badge::before{
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
}
.plan-badge.plan-free{ background: var(--brand-soft); border-color:#dbeafe; color:var(--brand-ink); }
.plan-badge.plan-pro{ background:#eef2ff; border-color:#c4b5fd; color:#4c1d95; }
.plan-badge.plan-team{ background:#ecfdf3; border-color:#bbf7d0; color:#166534; }

.user-credits{
  font-size: 11px;
  color: var(--brand-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Logout button (white, red icon only) */
.app-shell .btn-logout{
  margin-top: 6px;
  width: 100%;
  justify-content: center;
  font-size: 12px;
  padding-inline: 8px;
  gap: 6px;

  background: #ffffff;
  border-color: #e5e7eb;
  color: var(--brand-ink);
}
.app-shell .btn-logout .ico{
  display: inline-flex;
  width: 14px;
  height: 14px;
  color: #dc2626;
}
.app-shell .btn-logout:hover{
  background: #f9fafb;
  border-color: #e5e7eb;
  color: var(--brand-ink);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
}
.app-shell .btn-logout:hover .ico{ color:#b91c1c; }
.app-shell .btn-logout:active{
  background:#f3f4f6;
  border-color:#e5e7eb;
}

/* =============================
   Main + tabs
   ============================= */
.main{
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  overflow: hidden;
  background: transparent;
}

.tab-panel{
  display: none;
  height: 100%;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}
.tab-panel.active{ display:block; }

#tab-chat{ overflow:hidden; }

#tab-actions,
#tab-history,
#tab-shop-sub,
#tab-shop-pack,
#tab-fact-sub,
#tab-fact-history{
  padding-right: 4px;
}

/* =============================
   Chat
   ============================= */
.chat-wrap{
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.thread{
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px;

  background: linear-gradient(180deg, #ffffff 0%, #fafbfc 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.04);

  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.12) transparent;
}
.thread::-webkit-scrollbar{ width: 5px; }
.thread::-webkit-scrollbar-track{ background: transparent; }
.thread::-webkit-scrollbar-thumb{ background: rgba(0,0,0,0.12); border-radius: 999px; }
.thread::-webkit-scrollbar-thumb:hover{ background: rgba(0,0,0,0.22); }

.msg{
  display: flex;
  gap: 10px;
  margin: 12px 0;
  align-items: flex-start;
  animation: msg-in 0.2s ease-out;
}
.msg.user{ flex-direction: row-reverse; }
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.avatar{
  width: 32px;
  height: 32px;
  border-radius: 50%;

  display: flex;
  align-items: center;
  justify-content: center;

  flex-shrink: 0;
  font-weight: 700;
  font-size: 14px;

  background: #e0edff;
  color: var(--brand-ink);
}

.msg.user .avatar{
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.bubble{
  position: relative;
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;

  background: #ffffff;
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.msg.user .bubble{
  background: linear-gradient(135deg, #e8edf5 0%, #dde3ee 100%);
  color: var(--user-bubble-text);
  border-color: rgba(0,0,0,0.06);
  font-weight: 500;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.meta{
  font-size: 11px;
  opacity: 0.7;
  margin-bottom: 4px;
}

.content{
  white-space: pre-wrap;
  word-break: break-word;
  font-family: var(--font-content);
  letter-spacing: 0.01em;
  line-height: var(--lh-chat);
  font-size: 13px;
}

.thread .content p{ margin: 2px 0; }
.thread .content ul,
.thread .content ol{ margin: 2px 0 2px 18px; }
.thread .content li{ margin: 1px 0; }
.thread .content pre,
.json-box{ line-height: 1.3; margin: 6px 0; }
.thread .content h1,
.thread .content h2,
.thread .content h3{ line-height: 1.2; margin: 8px 0 6px; }

/* Bubble tail */
.msg .bubble::after{
  content: "";
  position: absolute;
  top: 14px;
  left: -6px;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-right: 6px solid var(--border);
}
.msg .bubble::before{
  content: "";
  position: absolute;
  top: 14px;
  left: -7px;
  width: 0;
  height: 0;
  border-top: 7px solid transparent;
  border-bottom: 7px solid transparent;
  border-right: 7px solid #ffffff;
}
.msg.user .bubble::after{
  left: auto;
  right: -6px;
  border-right: 0;
  border-left: 6px solid var(--user-bubble-border);
}
.msg.user .bubble::before{
  left: auto;
  right: -7px;
  border-right: 0;
  border-left: 7px solid var(--user-bubble-bg);
}

/* Hover actions inside bubble */
.msg-actions{
  position: absolute;
  top: 6px;
  right: 6px;
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.bubble:hover .msg-actions{ opacity: 1; }

.msg-actions .icon-btn{
  position: relative;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  opacity: 0.7;
  padding: 2px 4px;
  border-radius: 6px;
}
.msg-actions .icon-btn:hover{
  background: rgba(15,23,42,0.06);
  opacity: 1;
}
.msg.user .msg-actions .icon-btn:hover{
  background: rgba(255,255,255,0.18);
}

/* Server messages */
.msg.server{
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.msg.server .bubble{
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
}
.msg.server .content-plain{
  flex: 1 1 auto;
  width: 100%;
  max-width: 100%;
  margin: 0;
  padding: 10px 14px;

  background: transparent;
  border: none;
  border-radius: 0;

  white-space: pre-wrap;
  word-break: break-word;

  font-family: var(--font-content);
  letter-spacing: 0.01em;
  line-height: var(--lh-chat);
  font-size: 13px;
  font-weight: 450;
}
.msg.server.pending .content-plain{
  color: var(--muted);
  font-style: italic;
}

.msg.server .avatar{
  background: #e5edff;
  color: #1d4ed8;
}
.msg.error .avatar{ background:#fee2e2; color:#991b1b; }
.msg.error .bubble{ background:#fff7f7; border-color:#fecaca; color:#7f1d1d; }

/* Typing indicator */
.typing{ display:inline-flex; align-items:center; gap:6px; }
.dot{
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ca3af;
  display: inline-block;
  animation: blink 1.2s infinite ease-in-out both;
}
.dot:nth-child(2){ animation-delay: 0.2s; }
.dot:nth-child(3){ animation-delay: 0.4s; }
@keyframes blink{
  0%,80%,100%{ opacity: .2; transform: translateY(0); }
  40%{ opacity: 1; transform: translateY(-2px); }
}

/* =============================
   System actions (below server message)
   ============================= */
.sys-actions{
  order: 2;
  align-self: flex-start;

  display: inline-flex;
  gap: 4px;
  margin-top: 6px;
  margin-left: 2px;

  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
}
.msg.server:hover .sys-actions,
.msg.server:focus-within .sys-actions{
  opacity: 1;
  pointer-events: auto;
}

.sys-btn{
  position: relative;
  appearance: none;
  border: 1px solid transparent;
  background: transparent;
  color: #6b7280;
  padding: 4px;
  border-radius: 8px;
  cursor: pointer;
  line-height: 0;
}
.sys-btn:hover{ background:#f3f4f6; color:#111827; }
.sys-btn.active,
.sys-btn[aria-pressed="true"]{
  color: var(--brand-ink);
  background: var(--brand-soft);
  border-color: var(--brand-soft-strong);
}

.sys-more-wrap{ position: relative; display: inline-block; }
.sys-menu{
  position: absolute;
  top: 30px;
  left: 0;

  min-width: 160px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-2);
  padding: 6px;

  display: none;
  z-index: 60;
}
.sys-menu.open{ display:block; }
.sys-menu .sys-menu-item{
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;

  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;

  cursor: pointer;
  color: #111;
  text-align: left;
  font-size: 13px;
}
.sys-menu .sys-menu-item:hover{ background: var(--sidebar-hover); }
.sys-menu .credit{
  pointer-events: none;
  opacity: .6;
  font-weight: 500;
  cursor: default;
}

.sys-tip{
  position: absolute;
  top: -20px;
  left: 50%;
  transform: translateX(-50%);
  background: #020617;
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 6px;
  white-space: nowrap;
  pointer-events: none;
}

/* Chat actions feedback */
@keyframes sys-pop{ 0%{transform:scale(1)} 45%{transform:scale(1.08)} 100%{transform:scale(1)} }
.sys-btn.flash,
.icon-btn.flash{ animation: sys-pop .18s ease-out; }

@keyframes sys-float{
  0%{opacity:0; transform:translate(-50%,2px) scale(.96)}
  18%{opacity:1}
  100%{opacity:0; transform:translate(-50%,-10px) scale(1)}
}
.sys-fx{
  position: absolute;
  left: 50%;
  top: -10px;
  transform: translateX(-50%);

  background: #020617;
  color: #fff;
  font-size: 11px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 20;

  animation: sys-float .9s ease-out forwards;
  box-shadow: 0 10px 30px rgba(2,6,23,.28);
}
.sys-fx.ok{ background: var(--ok-ink); }
.sys-fx.bad{ background: var(--bad-ink); }
.sys-fx.info{ background:#020617; }

/* Copy / like / dislike states */
.sys-btn[data-act="copy"].copied,
.icon-btn[data-act="copy"].copied{
  background: var(--brand);
  border-color: var(--brand-ink);
  color: #fff;
}

.sys-btn[data-act="like"][aria-pressed="true"],
.icon-btn[data-act="like"][aria-pressed="true"]{
  background: var(--ok-soft);
  border-color: var(--ok-border);
  color: var(--ok-ink);
}

.sys-btn[data-act="dislike"][aria-pressed="true"],
.icon-btn[data-act="dislike"][aria-pressed="true"]{
  background: var(--bad-soft);
  border-color: var(--bad-border);
  color: var(--bad-ink);
}

/* =============================
   Composer
   ============================= */
.composer{
  flex: 0 0 auto;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--card);
  box-shadow: var(--shadow-1);
}

.composer-input-wrap{
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1 1 auto;
}

.composer textarea{
  flex: 1 1 auto;
  height: var(--composer-min-h);
  min-height: var(--composer-min-h);
  max-height: var(--composer-max-h);

  resize: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 4px 6px;
  background: #fff;

  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.2) transparent;

  font-size: 13px;
  font-family: var(--font-content);
}
.composer textarea::-webkit-scrollbar{ width: 5px; }
.composer textarea::-webkit-scrollbar-track{ background: transparent; }
.composer textarea::-webkit-scrollbar-thumb{ background: rgba(0,0,0,0.18); border-radius: 999px; }
.composer textarea::-webkit-scrollbar-thumb:hover{ background: rgba(0,0,0,0.3); }

/* Focus: black ring */
.composer:focus-within{
  border-color: rgba(2, 6, 23, 0.35);
  box-shadow: 0 0 0 1px rgba(2, 6, 23, 0.35), 0 0 0 4px var(--ink-ring);
}
.composer textarea:focus-visible{
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink), 0 0 0 4px var(--ink-ring);
  background: #ffffff;
}

/* Footer layout (grid with separators) */
.composer-footer{
  margin-top: 0;
  min-height: 0;

  display: grid;
  grid-template-columns:
    auto
    minmax(var(--composer-gap-min), 1fr)
    auto
    minmax(var(--composer-gap-min), 1fr)
    auto;
  align-items: center;
  column-gap: 0;
}

.composer-gap{
  position: relative;
  align-self: stretch;
  min-width: var(--composer-gap-min);
}
.composer-gap::after{
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 1px;
  height: var(--composer-sep-h);
  background: var(--composer-sep-color);
  pointer-events: none;
}

/* Switch Preview */
.pv-switch{
  justify-self: start;

  display: inline-flex;
  align-items: center;
  gap: 4px;

  padding: 1px 4px;
  border-radius: 999px;
  border: 1px solid transparent;

  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.pv-switch:hover{
  border-color: var(--border);
  background: #f9fafb;
}
.pv-switch input[type="checkbox"]{
  width: 14px;
  height: 14px;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}

/* Credits inline */
.chat-credits-bar{
  justify-self: center;

  font-size: 11px;
  color: var(--muted);

  min-width: 0;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Send button */
.send-btn{
  justify-self: end;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: 24px;
  height: 24px;
  min-width: 24px;
  min-height: 24px;
  padding: 0;

  border-radius: 999px;
  background: #e5e7eb;
  color: #4b5563;
  border: 1px solid #d1d5db;
  box-shadow: none;

  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease, transform .05s ease, box-shadow .15s ease;
}

.send-btn:hover{
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
  box-shadow: 0 4px 10px rgba(2, 6, 23, 0.28);
  transform: translateY(-0.5px);
}
.send-btn:active{
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(2, 6, 23, 0.22);
}
.send-btn:disabled{
  opacity: 0.4;
  cursor: default;
  box-shadow: none;
  transform: none;
}

.send-btn svg{ width:14px; height:14px; }
.send-btn .icon-plane svg{ display:block; }

.send-btn .icon-spin{
  display: none;
  width: 14px;
  height: 14px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-right-color: currentColor;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
.send-btn.sending .icon-plane{ display:none; }
.send-btn.sending .icon-spin{ display:inline-block; }

@keyframes spin{ to { transform: rotate(360deg); } }

/* =============================
   Global buttons + inputs
   ============================= */
.app-shell .btn:not(.send-btn):not(.btn-logout){
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;

  height: 32px;
  padding: 0 12px;
  border-radius: 999px;

  background: #ffffff;
  border: 1px solid #cbd5f5;
  color: var(--brand-ink);

  font-size: 13px;
  font-weight: 500;
  cursor: pointer;

  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .04s ease;
}
.app-shell .btn:not(.send-btn):not(.btn-logout):hover{
  background: #eff6ff;
  border-color: var(--brand);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
  transform: translateY(-0.5px);
}
.app-shell .btn:not(.send-btn):not(.btn-logout):active{
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}

.app-shell .btn-primary:not(.send-btn){
  background: var(--brand);
  border-color: var(--brand-ink);
  color: #ffffff;
}
.app-shell .btn-primary:not(.send-btn):hover{
  background: var(--brand-ink);
  border-color: var(--brand-ink);
}

.app-shell .btn-ghost{
  border-color: transparent;
  background: transparent;
  color: var(--brand);
}

.app-shell .btn-danger{
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}
.app-shell .btn-danger:hover{
  background: #fee2e2;
  border-color: #fecaca;
  color: #991b1b;
  box-shadow: 0 4px 10px rgba(248, 113, 113, 0.25);
}
.app-shell .btn-danger:active{
  background: #fee2e2;
  border-color: #fecaca;
  box-shadow: 0 1px 2px rgba(185, 28, 28, 0.35);
}

/* Inputs */
.app-shell input[type="text"],
.app-shell input[type="email"],
.app-shell input[type="number"],
.app-shell textarea{
  border-radius: 10px;
  border: 1px solid #e5e7eb;
  padding: 6px 9px;
  font-size: 13px;
  background: #f9fafb;
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}
.app-shell input[type="text"]:focus-visible,
.app-shell input[type="email"]:focus-visible,
.app-shell input[type="number"]:focus-visible,
.app-shell textarea:focus-visible{
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 4px rgba(37, 99, 235, 0.13);
  background: #ffffff;
}

/* =============================
   History (list + kebab)
   ============================= */
#tab-history{ position: relative; }

.history-topbar{
  position: sticky;
  top: 0;
  z-index: 40;

  margin: -12px -12px 8px;
  padding: 8px 12px;

  border-bottom: 1px solid var(--border);
  background: rgba(248, 250, 252, 0.82);
  backdrop-filter: blur(10px);
  box-shadow: 0 6px 14px rgba(15, 23, 42, 0.05);
}

.history-topbar-inner{
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;

  max-width: 560px;
  margin: 0 auto;
}

.history-title-block{
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  line-height: 1.05;
}

.history-eyebrow{
  font-size: 10px;
  color: var(--muted);
  font-weight: 650;
  letter-spacing: 0.10em;
  text-transform: uppercase;
}

.history-title{
  margin-top: 1px;
  font-size: 13px;
  font-weight: 650;
  color: var(--brand-ink);
}

.history-actions{
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.history-icon-btn{
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--brand-ink);

  cursor: pointer;
  box-shadow: var(--shadow-1);

  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease, transform .06s ease, color .16s ease;
}
.history-icon-btn:hover{
  background: var(--brand);
  border-color: var(--brand-ink);
  color: #fff;
  box-shadow: var(--shadow-2);
  transform: translateY(-0.5px);
}
.history-icon-btn:active{
  transform: translateY(0);
  box-shadow: var(--shadow-1);
}

.history-icon-btn[data-tip]{ position: relative; }
.history-icon-btn[data-tip]::after{
  content: attr(data-tip);
  position: absolute;
  right: 0;
  top: calc(100% + 8px);

  font-size: 11px;
  color: #fff;
  background: #020617;
  padding: 4px 8px;
  border-radius: 8px;

  white-space: nowrap;
  opacity: 0;
  transform: translateY(-2px);
  pointer-events: none;
  transition: opacity .14s ease, transform .14s ease;
}
.history-icon-btn:hover::after,
.history-icon-btn:focus-visible::after{
  opacity: 1;
  transform: translateY(0);
}

.history-controls{
  display: flex;
  justify-content: center;
  margin-top: 8px;
}

.segmented{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  width: 240px;
}
.segmented .seg-btn{
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #f9fafb;
  cursor: pointer;
  font-size: 13px;
}
.segmented .seg-btn.active{
  background: linear-gradient(135deg, var(--brand-soft), var(--brand-soft-strong));
  color: var(--brand-ink);
  border-color: #93c5fd;
}

.segmented--history{ width: min(280px, 100%); }
.segmented--history .seg-btn{
  height: 28px;
  font-size: 12px;
  border-radius: 999px;
  padding: 0 10px;
}

.history-list{ padding: 10px 2px 0; }

.history-ul{
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.history-item{ position: relative; z-index: 0; }
.history-item.menu-open{ z-index: 1000; }

.hist-row{
  display: flex;
  align-items: center;
  gap: 8px;

  padding: 8px 10px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);

  transition: box-shadow .16s ease, transform .12s ease, border-color .16s ease, background-color .16s ease;
}
.history-item.active .hist-row{
  background: linear-gradient(135deg, var(--brand-soft), #ffffff);
  border-color: #93c5fd;
  box-shadow: 0 6px 18px rgba(34, 68, 148, 0.12);
}

.history-item.active .hist-title{
  color: var(--brand-ink);
  font-weight: 650;
}

.history-item.active .hist-time{
  color: var(--brand-ink);
}
.history-item:hover .hist-row{
  border-color: #cbd5f5;
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}

.hist-open{
  appearance: none;
  border: none;
  background: transparent;

  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;

  padding: 0;
  margin: 0;
  width: 100%;
  text-align: left;
  cursor: pointer;
}

.hist-title{
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hist-time{
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.hist-actions{ position: relative; flex: 0 0 auto; }

.kebab{
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;

  cursor: pointer;
  color: #374151;
}
.kebab:hover{
  background: var(--sidebar-hover);
  border-color: var(--sidebar-border);
}
.kebab svg{ width:16px; height:16px; display:block; }

.menu{
  position: absolute;
  right: 0;
  top: 32px;

  min-width: 160px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-2);
  padding: 6px;

  display: none;
  z-index: 1001;
}
.menu.open{ display:block; }
.menu .menu-item{
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;

  padding: 8px 10px;
  border: none;
  background: transparent;
  border-radius: 8px;

  cursor: pointer;
  color: #111;
  text-align: left;
  font-size: 13px;
}
.menu .menu-item:hover{ background: var(--sidebar-hover); }
.menu .danger{ color:#b00020; }

.history-empty{
  margin-top: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-1);
  padding: 14px 12px;
  text-align: center;
}
.history-empty-title{
  font-weight: 650;
  color: var(--brand-ink);
  margin-bottom: 4px;
}
.history-empty-sub{
  font-size: 12px;
  color: var(--muted);
}

/* =============================
   Preview (modern, clean)
   ============================= */

/* Container list */
.pv-list{
  display: grid;
  gap: 10px;
  max-height: 52vh;
  overflow: auto;
  padding-right: 2px;
}

/* Each step card */
.pv-step{
  position: relative;

  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;

  padding: 12px 12px;
  border-radius: 14px;
  border: 1px solid var(--border);

  background:
    linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);

  transition:
    transform .12s ease,
    box-shadow .16s ease,
    border-color .16s ease,
    background-color .16s ease;
}

/* Left accent bar */
.pv-step::before{
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--brand) 0%, var(--brand-ink) 140%);
  opacity: 0.20;
}

.pv-step:hover{
  border-color: #cbd5f5;
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
  background: #ffffff;
}
.pv-step:hover::before{ opacity: 0.45; }

.pv-head{
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

/* Badge = pill premium, cohérent avec ton design */
.pv-badge{
  flex: 0 0 auto;
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;

  padding: 4px 8px;
  border-radius: 999px;

  background: var(--brand-soft);
  border: 1px solid var(--brand-soft-strong);
  color: var(--brand-ink);
}

/* Title + count */
.pv-title{
  font-weight: 650;
  font-size: 13px;
  color: var(--brand-ink);

  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pv-count{
  margin-left: 8px;
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* Action area */
.pv-actions{
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* Buttons: même vibe que ton UI (pills, clean) */
.pv-actions .pv-run,
.pv-run-all,
.pv-close{
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;

  border: 1px solid #e5e7eb;
  background: #ffffff;
  color: var(--brand-ink);

  font-size: 12px;
  font-weight: 600;
  cursor: pointer;

  transition:
    background-color .16s ease,
    border-color .16s ease,
    box-shadow .16s ease,
    transform .06s ease,
    color .16s ease;
}

.pv-actions .pv-run:hover,
.pv-run-all:hover{
  background: var(--brand-soft);
  border-color: #bfdbfe;
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.08);
  transform: translateY(-0.5px);
}

/* Primary-ish feel for "Run" */
.pv-actions .pv-run{
  background: var(--brand);
  border-color: var(--brand-ink);
  color: #fff;
}
.pv-actions .pv-run:hover{
  background: var(--brand-ink);
  border-color: var(--brand-ink);
}

/* Close = neutral */
.pv-close{
  background: #f9fafb;
  border-color: var(--border);
  color: #111827;
}
.pv-close:hover{
  background: #f3f4f6;
  border-color: #e5e7eb;
}

/* Disabled */
.pv-actions .pv-run[disabled],
.pv-run-all[disabled]{
  opacity: .55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* Responsive: actions go under if narrow */
@media (max-width: 420px){
  .pv-step{
    grid-template-columns: 1fr;
    gap: 10px;
  }
  .pv-actions{
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* Preview CTA under server message */
.pv-cta{
  margin-top: 8px;
  display: flex;
  justify-content: flex-start;
}
.pv-cta .pv-open{
  height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}


/* =============================
   Billing (plans / packs / subscription / history)
   ============================= */
.billing-wrap{
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.billing-head{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
}
.billing-head-main{ display:flex; flex-direction:column; gap:2px; align-items:center; }

.billing-eyebrow{
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}
.billing-title{
  font-size: 15px;
  font-weight: 600;
  color: var(--brand-ink);
}
.billing-note{
  color: var(--muted);
  font-size: 12px;
}

.plan-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  align-items: stretch;
}
@media (min-width: 520px){
  .plan-grid{ grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
}

.plan-card{
  position: relative;
  background: #f9fafb;
  border-radius: 16px;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-left-color: #e5e7eb;

  padding: 14px 14px 12px;
  box-shadow: var(--shadow-1);

  display: flex;
  flex-direction: column;
  gap: 10px;

  overflow: hidden;

  transition: box-shadow 0.16s ease, transform 0.12s ease, border-color 0.16s ease, background-color 0.16s ease, border-left-color 0.16s ease;
}
.plan-card:hover{
  background: #ffffff;
  border-color: #cbd5f5;
  border-left-color: var(--brand);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}

.plan-card--featured{
  background: var(--brand-soft);
  border-color: #bfdbfe;
  border-left-color: var(--brand);
  box-shadow: var(--shadow-2);
}

.plan-card-top{ display:flex; flex-direction:column; gap:4px; }

.plan-name-row{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.plan-name-main{ display:flex; flex-direction:column; gap:2px; }
.plan-name-tags{ display:flex; flex-direction:column; align-items:flex-end; gap:4px; }

.plan-title{
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand-ink);
  letter-spacing: 0;
}
.plan-caption{
  margin: 0;
  font-size: 12px;
  color: var(--muted);
}

.plan-tag{
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 3px 6px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #4b5563;
}
.plan-tag--current{
  background: var(--brand);
  border-color: var(--brand);
  color: #ffffff;
}

.plan-pricing{ display:flex; flex-direction:column; gap:2px; }
.plan-price-row{ display:flex; align-items:baseline; gap:6px; }
.plan-price{
  font-size: 20px;
  font-weight: 700;
  color: var(--brand-ink);
}
.plan-price-unit{ font-size:12px; color:var(--muted); }
.plan-price-usd{ font-size:12px; color:var(--muted); }

.plan-meta{
  font-size: 12px;
  color: var(--muted);
}

.plan-feats{
  margin: 4px 0 0;
  padding: 0;
  list-style: none;

  display: flex;
  flex-direction: column;
  gap: 4px;

  font-size: 12px;
  color: #374151;
}
.plan-feats li{
  position: relative;
  padding-left: 16px;
}
.plan-feats li::before{
  content: "";
  position: absolute;
  left: 0;
  top: 6px;
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--brand);
  opacity: 0.9;
}

.plan-cta-row{ margin-top: 6px; }
.plan-cta{ width:100%; justify-content:center; }

/* Packs */
.pack-card{
  background: var(--brand-soft);
  border: 1px solid #bfdbfe;
  border-left-width: 3px;
  border-left-color: var(--brand);

  box-shadow: var(--shadow-1);
  position: relative;

  transition: background-color .16s ease, border-color .16s ease, border-left-color .16s ease, box-shadow .16s ease, transform .12s ease;
}
.pack-card:hover{
  background: #ffffff;
  border-color: var(--brand);
  border-left-color: var(--brand-ink);
  box-shadow: var(--shadow-2);
  transform: translateY(-2px);
}
.plan-tag--pill{
  background: #e0edff;
  border-color: #bfdbfe;
  color: var(--brand-ink);
  font-size: 11px;
  font-weight: 500;
}
.pack-card .plan-meta{
  color: #0f172a;
  font-size: 12px;
}

/* Subscription layout */
.sub-layout{ display:flex; flex-direction:column; gap:12px; }

.sub-grid{
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 520px){
  .sub-grid{ grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); }
}

.sub-card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-1);

  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sub-card-head{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.sub-card-title{
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--brand-ink);
}
.sub-card-subtitle{
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.sub-badge{
  align-self: flex-start;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #f9fafb;
  color: #4b5563;
}
.sub-badge-ok{ background:#ecfdf3; border-color:#bbf7d0; color:#166534; }
.sub-badge-warn{ background:#fef9c3; border-color:#facc15; color:#92400e; }

.sub-credits-dl{ margin: 4px 0 0; padding: 0; }
.sub-row{
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 12px;
  padding: 2px 0;
}
.sub-row dt{ margin:0; color:var(--muted); }
.sub-row dd{ margin:0; font-weight:500; color:var(--brand-ink); }
.sub-row-total dd{ font-size:13px; font-weight:600; }

.sub-help{ margin-top:6px; font-size:11px; color:var(--muted); }

/* Mon abonnement — CTA buttons */
.sub-actions{
  display: grid;
  gap: 8px;
  margin-top: 10px;
  align-items: stretch;
}
.sub-actions .btn{
  width: 100%;
  height: 34px;
  white-space: nowrap;
  justify-content: center;
}
.sub-actions--2{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sub-actions--3{ grid-template-columns: repeat(3, minmax(0, 1fr)); }

@media (min-width: 521px) and (max-width: 680px){
  .sub-actions--3{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .sub-actions--3 .btn:nth-child(3){ grid-column: 1 / -1; }
}
@media (max-width: 520px){
  .sub-actions--2,
  .sub-actions--3{ grid-template-columns: 1fr; }
}
.sub-actions .btn:disabled{
  opacity: .55;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
}

/* Billing history */
.bh-section{ margin-bottom: 12px; }
.bh-section-head{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.bh-section-title{
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-ink);
}
.bh-section-sub{
  font-size: 11px;
  color: var(--muted);
}
.bh-kind-sub{ background:#dbeafe; border-color:#93c5fd; color:#1d4ed8; }

.bh-list{
  list-style: none;
  margin: 6px 0 4px;
  padding: 0;

  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bh-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f9fafb;
}

.bh-main{
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.bh-title-line{
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.bh-label{
  font-weight: 500;
  color: var(--brand-ink);
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bh-kind{
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 999px;
  border: 1px solid #e5e7eb;
  background: #eef2ff;
  color: #4338ca;
}
.bh-kind-topup{ background:#ecfdf3; border-color:#bbf7d0; color:#166534; }
.bh-kind-usage{ background:#fef9c3; border-color:#facc15; color:#92400e; }

.bh-subline{
  font-size: 11px;
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.bh-source{ white-space: nowrap; }

.bh-amount{
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.bh-amount-plus{ color:#166534; }
.bh-amount-minus{ color:#b91c1c; }

.bh-footnote{
  margin-top: 8px;
  font-size: 11px;
  color: var(--muted);
}

/* Shop pack tab tweak */
#tab-shop-pack .billing-wrap{ gap: 12px; }
#tab-shop-pack .sub-card{
  background: #f1f5f9;
  border-color: #dbeafe;
}

/* =============================
   Modals (legacy + billing)
   ============================= */
.modal-backdrop{
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.18);

  display: flex;
  align-items: center;
  justify-content: center;

  z-index: 9999;
}

.modal-card{
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: min(420px, 90vw);
  padding: 16px;
  box-shadow: var(--shadow-2);
}

.modal-title{ font-weight: 600; margin-bottom: 8px; }
.modal-msg{ color:#444; margin-bottom:12px; }

.modal-input{
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.modal-actions{
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

/* Billing modal overlay */
.modal-backdrop.billing-modal{ background: rgba(15, 23, 42, 0.55); }

.billing-modal-card.billing-modal-card--danger{
  border-top: 3px solid #dc2626;
  box-shadow: 0 18px 45px rgba(0, 0, 0, 0.35);
}
.billing-modal-card--danger .modal-header{
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}
.modal-icon--danger{
  width: 32px;
  height: 32px;
  border-radius: 999px;
  border: 2px solid #b91c1c;
  color: #b91c1c;

  display: flex;
  align-items: center;
  justify-content: center;

  font-weight: 700;
  font-size: 1rem;
}
.billing-modal-card--danger .modal-title{
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #b91c1c;
}
.billing-modal-card--danger .modal-subtitle{
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: #64748b;
}

/* Buttons (danger + ghost) for this modal */
.btn.btn-danger{
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
}
.btn.btn-danger:hover{
  background: #b91c1c;
  border-color: #b91c1c;
}
.btn.btn-ghost{
  background: transparent;
  border-color: transparent;
  color: #0f172a;
}
.btn.btn-ghost:hover{
  background: rgba(15, 23, 42, 0.06);
}

/* =============================
   UI Modals (confirm/prompt) — isolated
   ============================= */
.ui-modal-backdrop{
  position: fixed;
  inset: 0;
  z-index: 9999;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 14px;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(8px);
}

.ui-modal-card{
  width: min(360px, 100%);
  max-height: calc(100dvh - 28px);
  overflow: auto;

  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;

  padding: 14px;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.28);

  font-size: 12px;
  line-height: 1.35;

  opacity: 0;
  transform: translateY(6px) scale(0.985);
  animation: ui-modal-in 0.16s ease-out forwards;
}
@keyframes ui-modal-in{ to { opacity: 1; transform: translateY(0) scale(1); } }

.ui-modal-head{
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.ui-modal-title{
  font-size: 13px;
  font-weight: 650;
  color: var(--brand-ink);
  line-height: 1.2;
}
.ui-modal-x{
  width: 30px;
  height: 30px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: #64748b;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.ui-modal-x:hover{
  background: rgba(15,23,42,0.06);
  color: #0f172a;
}

.ui-modal-msg{ color: #475569; }

.ui-modal-input{
  width: 100%;
  margin-top: 10px;
  height: 34px;
  padding: 6px 10px;
  border-radius: 12px;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  font-size: 12px;
}

.ui-modal-actions{
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}
.ui-modal-card .btn{
  height: 32px;
  padding: 0 12px;
  border-radius: 12px;
  font-size: 12px;
}
.ui-modal-card[data-variant="danger"]{ border-color:#fecaca; }
.ui-modal-card[data-variant="danger"] .ui-modal-title{ color:#991b1b; }

@media (max-width: 380px){
  .ui-modal-backdrop{ padding: 10px; }
  .ui-modal-card{ padding: 12px; border-radius: 14px; }
}

/* =============================
   Floating buttons (toggle + refresh)
   ============================= */
.sidebar-toggle-fab{
  position: fixed;
  z-index: 1200;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  width: var(--fab-size);
  height: var(--fab-size);
  min-width: var(--fab-size);
  min-height: var(--fab-size);

  padding: 0;
  border-radius: 999px;
  border: none;

  background: rgba(15, 23, 42, 0.06);
  color: var(--brand-ink);
  cursor: pointer;

  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(6px);

  transform: translateY(0);
  transition: transform .12s ease, background-color .15s ease, box-shadow .15s ease;
}
.sidebar-toggle-fab:hover,
.sidebar-toggle-fab:focus-visible{
  transform: translateY(-0.5px) scale(var(--fab-scale-hover));
  background: rgba(37, 99, 235, 0.10);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.26);
}
.sidebar-toggle-fab:active{
  transform: translateY(0) scale(calc(var(--fab-scale-hover) - 0.08));
}

/* ── Override: bouton 3 points sans cercle ── */
/* ──────────────────────────────────────────────
   Toggle sidebar — 3 points plus gros, plus à gauche,
   avec hover premium
   ────────────────────────────────────────────── */

#btn-toggle-sidebar.sidebar-toggle-fab{
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 2px);
  left: calc(env(safe-area-inset-left, 0px) - 5px);

  width: 42px;
  height: 42px;
  min-width: 42px;
  min-height: 42px;

  border-radius: 14px;
  border: 1px solid transparent;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;

  color: var(--brand-ink);
  overflow: visible;

  transition:
    transform 0.16s ease,
    background-color 0.16s ease,
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    color 0.16s ease;
}

/* halo subtil derrière */
#btn-toggle-sidebar.sidebar-toggle-fab::before{
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 12px;
  background: rgba(34, 68, 148, 0);
  box-shadow: 0 0 0 rgba(34, 68, 148, 0);
  transition:
    background 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
  z-index: 0;
}

#btn-toggle-sidebar.sidebar-toggle-fab .ico{
  position: relative;
  z-index: 1;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#btn-toggle-sidebar.sidebar-toggle-fab .ico svg{
  width: 24px;
  height: 24px;
  display: block;
}

/* hover / focus : zoom + contour + ombre douce */
#btn-toggle-sidebar.sidebar-toggle-fab:hover,
#btn-toggle-sidebar.sidebar-toggle-fab:focus-visible{
  transform: scale(1.05);
  color: var(--brand);
  border-color: rgba(34, 68, 148, 0.14);
  background: rgba(255, 255, 255, 0.55);
  box-shadow: 0 8px 22px rgba(15, 23, 42, 0.10);
  outline: none;
}

#btn-toggle-sidebar.sidebar-toggle-fab:hover::before,
#btn-toggle-sidebar.sidebar-toggle-fab:focus-visible::before{
  background: rgba(34, 68, 148, 0.08);
  box-shadow:
    0 0 0 1px rgba(34, 68, 148, 0.08),
    0 8px 18px rgba(34, 68, 148, 0.10);
  transform: scale(1.02);
}

#btn-toggle-sidebar.sidebar-toggle-fab:active{
  transform: scale(1.06);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}
.sidebar-toggle-fab .ico{
  width:18px; height:18px; display:flex; align-items:center; justify-content:center;

}



#btn-global-refresh{
  top:   calc(env(safe-area-inset-top, 0px) + var(--fab-inset));
  right: calc(env(safe-area-inset-right, 0px) + 10px);
  left: auto;
}

/* Hide toggle when sidebar open */
.app-shell.sidebar-open #btn-toggle-sidebar{ display: none; }

/* Refresh spin */
#btn-global-refresh.is-refreshing .ico{ animation: cs-refresh-spin 0.8s linear infinite; }
@keyframes cs-refresh-spin{ to { transform: rotate(360deg); } }

/* Visible ONLY on billing pages */
#btn-global-refresh{ display: none; }
.app-shell.show-refresh #btn-global-refresh{
  display: inline-flex;

  top:  calc(env(safe-area-inset-top, 0px) + 12px);
  right: calc(env(safe-area-inset-right, 0px) + 16px);
  left: auto;

  width: 30px;
  height: 30px;
  min-width: 30px;
  min-height: 30px;
}
.app-shell.show-refresh #btn-global-refresh .ico{ width:18px; height:18px; }



/* =============================
   Toasts
   ============================= */
.toast-stack{
  position: fixed;
  right: 12px;
  bottom: 12px;
  z-index: 9999;
  display: grid;
  gap: 8px;
}
.toast{
  background: #020617;
  color: #fff;
  padding: 8px 10px;
  border-radius: 10px;
  box-shadow: var(--shadow-2);
  font-size: 12px;
  opacity: .98;
}
.toast.error{ background:#b91c1c; }
.toast.success{ background:var(--brand-ink); }

/* =============================
   Privacy panel
   ============================= */
.privacy-wrap{
  padding: 14px;
  display: flex;
  justify-content: center;
}

.privacy-card{
  width: 100%;
  max-width: 720px;

  background: var(--privacy-card-bg);
  border: 1px solid var(--privacy-card-border);

  border-radius: 14px;
  padding: 14px;
  box-shadow: var(--shadow-2);
}


.privacy-title{
  font-weight: 700;
  color: var(--brand-ink);
  font-size: 16px;

  /* ✅ centré */
  text-align: center;
  width: 100%;
}


.privacy-subtitle{
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.privacy-toggle-row{
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f9fafb;
}

.privacy-toggle-label{
  font-size: 13px;
  color: #111827;
  font-weight: 600;
}

.privacy-empty{
  font-size: 13px;
}

.privacy-restrict{
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.privacy-section{
  border: 1px solid var(--border);
  border-left: 3px solid #e5e7eb;
  border-radius: 14px;
  padding: 12px;

  background: linear-gradient(180deg, #ffffff 0%, #f9fafb 100%);
  box-shadow: var(--shadow-1);

  transition:
    box-shadow .16s ease,
    transform .12s ease,
    border-color .16s ease,
    background-color .16s ease,
    border-left-color .16s ease;
}

.privacy-section:hover{
  background: #ffffff;
  border-color: #cbd5f5;
  border-left-color: var(--brand);
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}

.privacy-section:focus-within{
  border-color: var(--brand);
  border-left-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 10px 30px rgba(15, 23, 42, 0.12);
}

.privacy-section-title{
  font-weight: 700;
  font-size: 13px;
  color: #111827;
}



.privacy-section-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

/* Icon-only button */
.privacy-icon-btn{
  width: 32px;
  height: 32px;
  min-width: 32px;
  padding: 0;
  border-radius: 999px;
}
.privacy-icon-btn .ico{
  display: inline-flex;
  width: 16px;
  height: 16px;
}
.privacy-icon-btn.is-refreshing .ico{ animation: cs-refresh-spin 0.8s linear infinite; }
.privacy-icon-btn.is-refreshing{ opacity:.85; cursor:progress; }
@media (prefers-reduced-motion: reduce){
  .privacy-icon-btn.is-refreshing .ico{ animation:none; }
}

.privacy-help{
  margin-top: 6px;
  font-size: 12px;
  color: var(--muted);
}

.privacy-warning{
  margin-top: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  font-size: 12px;
}

.privacy-preview{
  margin-top: 8px;
  background: #0b1220;
  color: #e5e7eb;
  border-radius: 12px;
  padding: 10px;
  font-size: 12px;
  overflow: auto;
}

.privacy-foot{
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

/* Privacy rule + selects */
.privacy-rule-row{
  margin-top: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.privacy-select{
  flex: 1;
  min-width: 220px;
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f9fafb;
  padding: 6px 10px;
  font-size: 13px;
}
.privacy-select:focus-visible{
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 4px rgba(37,99,235,.16);
  background: #fff;
}

.privacy-items{
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Rows: sheet | range | X */
/* Rows: sheet | range | X  — "cards" look */


.privacy-item-row:hover{
  background: #ffffff;
  border-color: #bfdbfe;
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}

.privacy-item-row:focus-within{
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 10px 30px rgba(15, 23, 42, 0.12);
  background: #ffffff;
}


.privacy-item-sheet{
  height: 34px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 6px 10px;
  font-size: 13px;
  min-width: 0;
}

.privacy-item-range{
  height: 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 4px 8px;
  font-size: 11px;
  min-width: 0;
  line-height: 1.2;
}


.privacy-item-sheet:focus-visible,
.privacy-item-range:focus-visible{
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 4px rgba(37,99,235,.16);
}

.privacy-item-remove{
  justify-self: end;
  width: 28px;
  height: 28px;
  padding: 0;

  display: inline-flex;
  align-items: center;
  justify-content: center;

  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;

  color: #64748b;
  cursor: pointer;
}
.privacy-item-remove:hover{
  background: rgba(15, 23, 42, 0.06);
  color: #0f172a;
}
.privacy-item-remove:focus-visible{
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}



/* Privacy actions toolbar (centered) */
.privacy-actions{
  margin-top: 10px;

  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: center;

  width: 100%;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}

.privacy-action-btn{
  width: 100%;
  height: 34px;
  justify-content: center;
  gap: 8px;
}
.privacy-action-btn .ico{ display:inline-flex; width:16px; height:16px; }
.privacy-action-btn .label{ white-space:nowrap; }

@media (max-width: 420px){
  .privacy-actions{ grid-template-columns: 1fr; }
}
@media (max-width: 340px){
  .privacy-actions{
    grid-template-columns: auto auto;
    justify-content: center;
  }
  .privacy-action-btn{
    width: 34px;
    padding: 0;
  }
  .privacy-action-btn .label{ display:none; }
}


/* Rows: sheet on top, range below, X on the right (always) */
.privacy-item-row{
  display: grid;
  grid-template-columns: 1fr 32px;
  grid-template-areas:
    "sheet x"
    "range x";
  gap: 8px;
  align-items: center;

  padding: 10px 12px;

  border-radius: 12px;
  border: 1px solid #cbd5f5;
  border-left: 3px solid var(--brand);

  background: linear-gradient(135deg, #ffffff 0%, var(--brand-soft) 140%);
  box-shadow: var(--shadow-1);

  transition:
    box-shadow .16s ease,
    transform .12s ease,
    border-color .16s ease,
    background-color .16s ease;
}

/* Place each control */
.privacy-item-sheet{ grid-area: sheet; }
.privacy-item-range{ grid-area: range; }
.privacy-item-remove{
  grid-area: x;
  justify-self: end;
  align-self: center; /* centré verticalement sur les 2 lignes */
}


/* Save bar + centered save button */
.privacy-savebar{
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;

  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f9fafb;
}

.privacy-save-status{
  font-size: 12px;
  color: var(--muted);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.privacy-save-status.is-dirty{
  color: #92400e;
  font-weight: 600;
}

.privacy-save-row{
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}
.privacy-save-hint{
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  min-height: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Privacy switch */
.privacy-switch{
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
}
.privacy-switch input{
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  pointer-events: none;
}
.privacy-switch-ui{
  width: 44px;
  height: 24px;
  border-radius: 999px;
  background: #e5e7eb;
  border: 1px solid #d1d5db;
  display: inline-flex;
  align-items: center;
  padding: 2px;
  transition: background-color .16s ease, border-color .16s ease, box-shadow .16s ease;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.08);
}
.privacy-switch-ui::after{
  content: "";
  width: 18px;
  height: 18px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(0,0,0,.18);
  transform: translateX(0);
  transition: transform .16s ease;
}
.privacy-switch input:checked + .privacy-switch-ui{
  background: var(--brand);
  border-color: var(--brand-ink);
}
.privacy-switch input:checked + .privacy-switch-ui::after{
  transform: translateX(20px);
}
.privacy-switch input:focus-visible + .privacy-switch-ui{
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* =============================
   Typography “micro texts”
   ============================= */
.sidebar,
.nav-btn,
.btn,
.account-card,
.menu,
.modal-card{
  font-family: var(--font-ui);
}

.msg.server .content-plain{ line-height: var(--lh-chat); }

.muted,
.meta,
.stat-label,
.bh-section-sub,
.user-email,
.chat-credits-bar{
  font-size: 11px;
  letter-spacing: 0.02em;
}

/* =========================================================
   FIX — Chat composer textarea focus must be BLACK (override global blue)
   ========================================================= */
.app-shell .composer:focus-within{
  border-color: rgba(2, 6, 23, 0.35);
  box-shadow: 0 0 0 1px rgba(2, 6, 23, 0.35), 0 0 0 4px var(--ink-ring);
}

.app-shell .composer textarea:focus-visible{
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 1px var(--ink), 0 0 0 4px var(--ink-ring);
  background: #ffffff;
}


/* =========================================================
   Sidebar toggle — "hidden handle" state (collapsed)
   (NOIR en hidden + BLEU PRINCIPAL en hover, PAS de gradient)
   ========================================================= */


/* =========================================================
   Preview steps — +shadow + bouton "Run step" centré + moins flashy
   (à coller en FIN de fichier)
   ========================================================= */

/* 1) Ombre plus premium sur les cartes de steps */
.pv-step{
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.10);
  border-color: #e5e7eb;
}
.pv-step:hover{
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.14);
}

/* 2) Layout: actions sous le titre + centrées */
.pv-step{
  grid-template-columns: 1fr;
  grid-template-areas:
    "head"
    "actions";
}
.pv-head{ grid-area: head; }
.pv-actions{
  grid-area: actions;
  width: 100%;
  justify-content: center;
  padding-top: 2px;
}

/* 3) Bouton Run step moins flashy (plus “soft” que full brand) */
.pv-actions .pv-run{
  background: var(--brand-soft);
  border-color: #bfdbfe;
  color: var(--brand-ink);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}

/* Hover plus discret (pas de gros jump) */
.pv-actions .pv-run:hover{
  background: var(--brand-soft-strong);
  border-color: #93c5fd;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.10);
  transform: none; /* enlève l'effet "flashy" */
}
.pv-actions .pv-run:active{
  transform: none;
  box-shadow: 0 3px 10px rgba(15, 23, 42, 0.10);
}

/* Optionnel: calmer aussi Run all (si tu veux la même vibe) */
.pv-run-all:hover{ transform: none; }


/* ===== Preview modal (isolé, ne touche pas aux autres modales) ===== */
.pv-modal-backdrop{
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(8px);
}

.pv-modal-card{
  width: min(520px, 92vw);
  border-radius: 16px;
  padding: 14px;
  box-shadow: 0 18px 60px rgba(15, 23, 42, 0.28);
}

.pv-modal-head{
  display: grid;
  gap: 8px;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.pv-modal-title-row{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pv-modal-title{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 750;
  color: var(--brand-ink);
  letter-spacing: 0.01em;
}

.pv-modal-badge{
  font-size: 10px;
  font-weight: 650;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--brand-soft-strong);
  background: var(--brand-soft);
  color: var(--brand-ink);
}

.pv-modal-sub{
  font-size: 12px;
  color: var(--muted);
  line-height: 1.35;
}

.pv-modal-hint{
  display: flex;
  align-items: flex-start;
  gap: 8px;

  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f9fafb;

  font-size: 11px;
  color: #334155;
}

.pv-hint-dot{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--brand);
  margin-top: 3px;
  flex: 0 0 auto;
  opacity: 0.95;
}

.pv-modal-x{
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: #64748b;
  cursor: pointer;

  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pv-modal-x:hover{
  background: rgba(15, 23, 42, 0.06);
  color: #0f172a;
}

.pv-modal-actions{
  margin-top: 12px;
}


/* =============================
   Preview guard (subtle red pulse)
   ============================= */

/* animé mais pas flashy */
@keyframes pv-guard-dot {
  0%   { transform: scale(.92); opacity: .78; box-shadow: 0 0 0 0 rgba(220,38,38,.35); }
  60%  { transform: scale(1.00); opacity: 1;   box-shadow: 0 0 0 10px rgba(220,38,38,0); }
  100% { transform: scale(.92); opacity: .78; box-shadow: 0 0 0 0 rgba(220,38,38,0); }
}
@keyframes pv-guard-pulse {
  0%,100% { box-shadow: 0 10px 24px rgba(185,28,28,.12); }
  50%     { box-shadow: 0 10px 24px rgba(185,28,28,.16), 0 0 0 4px rgba(220,38,38,.10); }
}

/* badge flottant */
.pv-guard-fab{
  position: fixed;
  z-index: 10000; /* au-dessus du backdrop */
  top:  calc(env(safe-area-inset-top, 0px) + 12px);
  right: calc(env(safe-area-inset-right, 0px) + 16px);

  height: 30px;
  padding: 0 10px 0 9px;
  border-radius: 999px;

  display: none;              /* par défaut caché */
  align-items: center;
  gap: 8px;

  background: rgba(254,242,242,.92); /* rouge très soft */
  border: 1px solid #fecaca;
  color: #991b1b;

  backdrop-filter: blur(8px);
  box-shadow: 0 10px 24px rgba(185,28,28,.12);
}

.pv-guard-dot{
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #dc2626;
  animation: pv-guard-dot 1.25s ease-in-out infinite;
}

.pv-guard-label{
  font-size: 11px;
  font-weight: 750;
  letter-spacing: .08em;
  text-transform: uppercase;
}

/* visible uniquement quand la preview est ouverte */
.app-shell.pv-open #pv-guard{
  display: inline-flex;
  animation: pv-guard-pulse 2.2s ease-in-out infinite;
}

/* Bonus : petit point rouge aussi dans le titre de la preview modal */
.pv-modal-title::before{
  content:"";
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #dc2626;
  animation: pv-guard-dot 1.25s ease-in-out infinite;
}

/* Accessibilité */
@media (prefers-reduced-motion: reduce){
  .pv-guard-dot,
  .app-shell.pv-open #pv-guard,
  .pv-modal-title::before{
    animation: none !important;
  }
}


/* =========================================================
   OVERRIDE — Preview guard: plus visible + plus "wavy"
   (à coller TOUT EN BAS)
   ========================================================= */

/* Point rouge: plus gros + glow + mouvement wavy */
@keyframes pv-guard-dot{
  0%{
    transform: translateX(0) translateY(0) scale(.88);
    opacity: .60;
    box-shadow:
      0 0 0 0 rgba(220,38,38,.65),
      0 0 10px rgba(220,38,38,.45);
  }
  25%{
    transform: translateX(1px) translateY(-3px) scale(1.02);
    opacity: 1;
    box-shadow:
      0 0 0 14px rgba(220,38,38,0),
      0 0 14px rgba(220,38,38,.55);
  }
  50%{
    transform: translateX(0) translateY(0) scale(.94);
    opacity: .78;
    box-shadow:
      0 0 0 6px rgba(220,38,38,.18),
      0 0 12px rgba(220,38,38,.45);
  }
  75%{
    transform: translateX(-1px) translateY(-3px) scale(1.02);
    opacity: 1;
    box-shadow:
      0 0 0 14px rgba(220,38,38,0),
      0 0 14px rgba(220,38,38,.55);
  }
  100%{
    transform: translateX(0) translateY(0) scale(.88);
    opacity: .60;
    box-shadow:
      0 0 0 0 rgba(220,38,38,.65),
      0 0 10px rgba(220,38,38,.45);
  }
}

/* Badge: pulse + léger wobble (wavy) + halo plus marqué */
@keyframes pv-guard-pulse{
  0%{
    transform: translateY(0) rotate(0deg);
    box-shadow:
      0 10px 24px rgba(185,28,28,.16),
      0 0 0 0 rgba(220,38,38,.00);
  }
  50%{
    transform: translateY(-1px) rotate(-0.8deg);
    box-shadow:
      0 14px 30px rgba(185,28,28,.22),
      0 0 0 6px rgba(220,38,38,.14);
  }
  100%{
    transform: translateY(0) rotate(0deg);
    box-shadow:
      0 10px 24px rgba(185,28,28,.16),
      0 0 0 0 rgba(220,38,38,.00);
  }
}

/* Vague douce dans le badge (overlay animé) */
@keyframes pv-guard-wave{
  0%   { transform: translateX(-16px) translateY(0);   opacity: .55; }
  50%  { transform: translateX(16px)  translateY(-2px); opacity: .85; }
  100% { transform: translateX(-16px) translateY(0);   opacity: .55; }
}

/* Renforce le look + active l’overlay wave */
#pv-guard.pv-guard-fab{
  overflow: hidden;
  isolation: isolate;

  background: rgba(254,242,242,.96);
  border-color: #fca5a5; /* plus visible */
}

/* overlay wavy derrière le texte */
#pv-guard::before{
  content:"";
  position:absolute;
  inset:-18px;
  pointer-events:none;
  z-index:0;

  background:
    radial-gradient(circle at 20% 60%, rgba(220,38,38,.18), transparent 55%),
    radial-gradient(circle at 70% 30%, rgba(220,38,38,.12), transparent 60%),
    radial-gradient(circle at 85% 85%, rgba(220,38,38,.14), transparent 60%);
  opacity: 0;
  transform: translateX(-16px);
}

/* remet le contenu au-dessus */
#pv-guard > *{ position: relative; z-index: 1; }

/* point plus gros + animation un peu plus rapide */
#pv-guard .pv-guard-dot{
  width: 10px;
  height: 10px;
  animation: pv-guard-dot .95s ease-in-out infinite;
}

/* quand preview ouverte: wave + wobble */
.app-shell.pv-open #pv-guard{
  display: inline-flex;
  animation: pv-guard-pulse 1.55s ease-in-out infinite;
}
.app-shell.pv-open #pv-guard::before{
  opacity: 1;
  animation: pv-guard-wave 1.25s ease-in-out infinite;
}

/* Bonus: point rouge aussi plus visible dans le titre de la modale */
.pv-modal-title::before{
  width: 10px;
  height: 10px;
  animation: pv-guard-dot .95s ease-in-out infinite;
  box-shadow: 0 0 12px rgba(220,38,38,.55);
}

/* Accessibilité */
@media (prefers-reduced-motion: reduce){
  #pv-guard .pv-guard-dot,
  .app-shell.pv-open #pv-guard,
  #pv-guard::before,
  .pv-modal-title::before{
    animation: none !important;
  }
}


/* ───────────────────────────────
   Preview modal — Step impact
   ─────────────────────────────── */
.pv-step .pv-impact{
  display:none;
  margin-top:10px;
  padding:10px;
  border:1px solid var(--border);
  border-radius:14px;
  background: rgba(0,0,0,0.03);
}
.pv-step.has-impact .pv-impact{ display:block; }

.pv-impact-h{
  font-size:12px;
  color: var(--muted);
  margin-bottom:8px;
  display:flex;
  align-items:center;
  gap:8px;
}
.pv-impact-h b{ color: var(--text); font-weight:600; }

.pv-impact-chips{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  margin-bottom:8px;
}
.pv-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 10px;
  border-radius:999px;
  border:1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.70);
  font-size:12px;
  line-height:1;
}
.pv-chip-dot{
  width:10px; height:10px;
  border-radius:4px;
  background: var(--pv-dot, #888);
}
.pv-chip-hex{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size:11px;
  opacity:0.75;
}
.pv-chip-flag{
  font-size:11px;
  opacity:0.85;
  padding:2px 6px;
  border-radius:999px;
  background: rgba(0,0,0,0.06);
}

.pv-impact-lines{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.pv-impact-line{
  font-size:12px;
  color: var(--text);
  display:flex;
  gap:8px;
  align-items:flex-start;
}
.pv-impact-line .k{
  min-width:110px;
  color: var(--muted);
}
.pv-impact-line code{
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size:11px;
  padding:2px 6px;
  border-radius:8px;
  background: rgba(0,0,0,0.06);
}

.pv-impact[aria-hidden="true"]{ display:none; }

.pv-impact-sheet{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:6px 0;
  border-top:1px solid var(--border);
}

.pv-impact-sheet-name{
  font-weight:600;
  font-size:12px;
  color:var(--text);
}

.pv-impact-badges{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  justify-content:flex-end;
}

.pv-impact-chip{
  font-size:12px;
  line-height:1;
  padding:5px 8px;
  border-radius:999px;
  border:1px solid var(--border);
  color:var(--text);
  white-space:nowrap;
}

.pv-impact-chip-flag{ opacity:0.85; }
.pv-impact-none{ opacity:0.6; font-size:12px; }


/* Impact panel: un peu plus petit + plus clean */
.pv-impact {
  font-size: 12px;
}

.pv-impact-body {
  font-size: 12px;
}

.pv-impact-sheet-name{
  display:flex;
  align-items:center;
  gap:8px;
  font-weight:600;
}

/* Dot neutre pour les feuilles (pas de couleur par feuille) */
.pv-sheet-dot{
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: transparent;
  border: 1px solid rgba(15, 23, 42, 0.25);
  display: inline-block;
  margin-right: 8px;
  flex: 0 0 10px;
}


/* Chips: ⬛ swatch + label : count */
.pv-impact-badges{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
  justify-content:flex-end;
}

.pv-impact-chip{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 8px;
  border-radius:999px;
  border:1px solid rgba(0,0,0,.08);
  background: rgba(0,0,0,.03);
  font-size: 11px;
  line-height: 1;
}

.pv-chip-swatch{
  width:10px;
  height:10px;
  border-radius:3px;
  flex:0 0 10px;
  /* la couleur / bordure vient de applyPaletteToChip(...) */
}

.pv-chip-label{
  opacity:.85;
}

.pv-chip-sep{
  opacity:.55;
}

.pv-chip-count{
  font-weight:700;
  font-variant-numeric: tabular-nums;
}

.pv-sheet-dot {
  display: none !important;
}


/* ✅ Selected step */
.pv-step.is-selected{
  border-color: rgba(34, 68, 148, 0.55);
  background: linear-gradient(180deg, #ffffff 0%, var(--brand-soft) 120%);
  box-shadow: var(--shadow-2);
  transform: translateY(-1px);
}
.pv-step.is-selected::before{
  opacity: 0.85;
  width: 4px;
}

/* ✅ When one is selected, de-emphasize the others */
.pv-list.has-selection .pv-step:not(.is-selected){
  opacity: 0.72;
  filter: saturate(0.92);
}
.pv-list.has-selection .pv-step:not(.is-selected):hover{
  opacity: 0.92;
  filter: none;
}

/* =============================
   Preview Impact — séparateurs feuilles (plus visibles)
   ============================= */
:root{
  --pv-impact-sep: rgba(2, 6, 23, 0.18);
  --pv-impact-sep-w: 2px;
}

/* On supprime le "gap" pour que la ligne de séparation soit nette */
.pv-step .pv-impact-body{
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* Padding par ligne */
.pv-step .pv-impact-sheet{
  position: relative;
  padding: 10px 0;
}

/* Séparateur ENTRE feuilles (ligne + espace) */
.pv-step .pv-impact-sheet + .pv-impact-sheet{
  margin-top: 6px;
  padding-top: 14px;
}

/* Ligne épaisse (dégradé subtil) */
.pv-step .pv-impact-sheet + .pv-impact-sheet::before{
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: var(--pv-impact-sep-w);
  background: linear-gradient(90deg, transparent, var(--pv-impact-sep), transparent);
}


/* ──────────────────────────────────────────────────────────────
   Session lock overlay (modern)
   ────────────────────────────────────────────────────────────── */
.session-lock {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(17, 24, 39, 0.46);
  backdrop-filter: blur(6px);
}

.session-lock.hidden {
  display: none;
}

.session-lock-card {
  width: min(460px, 100%);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 16px 16px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}

.session-lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--brand-soft-strong);
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-size: 12px;
  font-weight: 600;
}

.session-lock-title {
  margin: 12px 0 6px;
  font-size: 18px;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--brand-ink);
}

.session-lock-desc {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.session-lock-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.02);
  margin-bottom: 14px;
  font-size: 12px;
}

.session-lock-meta .k {
  color: var(--muted);
}

.session-lock-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#btn-session-claim {
  width: 100%;
  border-radius: 12px;
  padding: 10px 12px;
}

/* Optionnel : éviter “scroll behind” si tu veux */
.app-shell.session-locked {
  filter: saturate(0.98);
}


/* ⏳ Session Busy Overlay (snapshot build + upload) */
.session-busy {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.38);
  backdrop-filter: blur(2px);
}

.session-busy.hidden { display: none; }

.session-busy-card {
  width: min(520px, calc(100vw - 32px));
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 16px;
  box-shadow: var(--shadow-2);
}

.session-busy-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.session-busy-spinner {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border-radius: 999px;
  border: 2px solid rgba(0,0,0,0.18);
  border-top-color: var(--brand);
  animation: sessionBusySpin 0.8s linear infinite;
}

@keyframes sessionBusySpin { to { transform: rotate(360deg); } }

.session-busy-phase {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}

.session-busy-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--brand-ink);
  margin-bottom: 6px;
}

.session-busy-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}

/* optionnel : léger “dim” du shell quand busy */
.app-shell.session-busy {
  filter: saturate(0.95);
}


/* =========================================================
   MODERNISATION V2 — Welcome, Textbox, Scroll, History, Sidebar
   ========================================================= */

/* ─── Chat Welcome State ─── */
.chat-welcome {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 0;
  padding: 16px;
  overflow-y: auto;
}

.chat-welcome-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
  width: 100%;
  max-width: 420px;
}

.cw-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
}

.cw-logo {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--brand-soft), var(--brand-soft-strong));
  border: 1px solid #bfdbfe;
  display: grid;
  place-items: center;
  color: var(--brand);
  box-shadow: 0 6px 20px rgba(34, 68, 148, 0.12);
}

.cw-title {
  font-size: 20px;
  font-weight: 750;
  color: var(--brand-ink);
  letter-spacing: -0.02em;
}

.cw-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 20px;
  font-weight: 450;
}

/* Exemples de prompts */
.cw-examples {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  width: 100%;
  margin-bottom: 24px;
}

.cw-example {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.08s;
  line-height: 1.3;
}

.cw-example:hover {
  background: var(--brand-soft);
  border-color: #bfdbfe;
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
}

.cw-example:active {
  transform: translateY(0);
}

.cw-ex-icon {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand);
  display: grid;
  place-items: center;
}

@media (max-width: 380px) {
  .cw-examples {
    grid-template-columns: 1fr;
  }
}

/* Composer centré (welcome) */
.cw-composer-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.cw-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 14px;
  border-radius: 16px;
  border: 1.5px solid var(--border);
  background: var(--card);
  box-shadow: 0 4px 20px rgba(15, 23, 42, 0.06);
  transition: border-color 0.16s, box-shadow 0.16s;
}

.cw-composer:focus-within {
  border-color: rgba(2, 6, 23, 0.35);
  box-shadow: 0 0 0 1px rgba(2, 6, 23, 0.35), 0 0 0 4px var(--ink-ring), 0 8px 30px rgba(15, 23, 42, 0.10);
}

.cw-composer textarea {
  flex: 1 1 auto;
  border: none;
  background: transparent;
  resize: none;
  font-size: 13px;
  font-family: var(--font-ui);
  padding: 8px 0;
  min-height: 20px;
  max-height: 120px;
  line-height: 1.4;
  color: var(--text);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.15) transparent;
}
.cw-composer textarea::-webkit-scrollbar{ width: 5px; }
.cw-composer textarea::-webkit-scrollbar-track{ background: transparent; }
.cw-composer textarea::-webkit-scrollbar-thumb{ background: rgba(0,0,0,0.15); border-radius: 999px; }

.cw-composer textarea:focus-visible {
  outline: none;
  box-shadow: none;
}

.cw-composer textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.cw-composer .send-btn {
  flex: 0 0 auto;
  margin-bottom: 2px;
}

.cw-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 4px;
}

.cw-sep {
  width: 1px;
  height: 14px;
  background: var(--composer-sep-color);
}

/* ─── Active Chat — Textbox Moderne ─── */
#chat-active .composer {
  border-radius: 16px;
  border: 1.5px solid var(--border);
  padding: 6px 8px;
  background: var(--card);
  box-shadow: 0 -2px 20px rgba(15, 23, 42, 0.04);
}

#chat-active .composer:focus-within {
  border-color: rgba(2, 6, 23, 0.35);
  box-shadow: 0 0 0 1px rgba(2, 6, 23, 0.35), 0 0 0 4px var(--ink-ring);
}

#chat-active .composer textarea {
  border: none;
  background: transparent;
  border-radius: 0;
  padding: 6px 4px;
  font-size: 13px;
}

#chat-active .composer textarea:focus-visible {
  outline: none;
  border-color: transparent;
  box-shadow: none;
  background: transparent;
}

#chat-active .composer textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

/* ─── Scroll to Bottom FAB ─── */
.scroll-bottom-fab {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;

  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--muted);
  cursor: pointer;

  display: flex;
  align-items: center;
  justify-content: center;

  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s, transform 0.08s;
  opacity: 0;
  pointer-events: none;
}

.scroll-bottom-fab.visible {
  display: flex;
  opacity: 1;
  pointer-events: auto;
  animation: scroll-fab-in 0.2s ease-out;
}

.scroll-bottom-fab:hover {
  background: var(--brand-soft);
  color: var(--brand);
  border-color: #bfdbfe;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.16);
  transform: translateX(-50%) translateY(-2px);
}

.scroll-bottom-fab:active {
  transform: translateX(-50%) translateY(0);
}

@keyframes scroll-fab-in {
  from { opacity: 0; transform: translateX(-50%) translateY(8px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── Thread modernisé ─── */
#chat-active .thread {
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--card);
  box-shadow: 0 2px 12px rgba(15, 23, 42, 0.03);
}

/* ─── History Page — Modernisé ─── */
#tab-history {
  display: none;
  height: 100%;
  overflow: hidden;
}
#tab-history.active {
  display: flex;
  flex-direction: column;
}

.history-topbar {
  margin: -12px -12px 0;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.95) 0%, rgba(248,250,252,0.92) 100%);
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.04);
  flex: 0 0 auto;
}

.history-topbar-inner {
  max-width: 480px;
}

.history-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.history-eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--brand);
  opacity: 0.8;
}

.history-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 10px;
}

.history-controls {
  margin-top: 10px;
}

.segmented--history {
  width: min(300px, 100%);
  gap: 4px;
  background: #f1f5f9;
  border-radius: 10px;
  padding: 3px;
}

.segmented--history .seg-btn {
  height: 30px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  transition: background-color 0.15s, color 0.15s, box-shadow 0.15s;
}

.segmented--history .seg-btn.active {
  background: var(--card);
  color: var(--brand-ink);
  border: none;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.10);
}

.segmented--history .seg-btn:not(.active):hover {
  color: var(--brand-ink);
  background: rgba(255, 255, 255, 0.5);
}

/* History list — scrollable */
.history-list {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 12px 4px 12px 2px;
}

.history-ul {
  gap: 6px;
}

.hist-row {
  border-radius: 14px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-left: 3px solid transparent;
  background: var(--card);
  transition: all 0.18s ease;
  position: relative;
}

.history-item.active .hist-row {
  background: linear-gradient(135deg, var(--brand-soft) 0%, rgba(219, 234, 254, 0.4) 100%);
  border-color: #bfdbfe;
  border-left-color: var(--brand);
  box-shadow: 0 2px 10px rgba(34, 68, 148, 0.10);
}

.history-item:hover .hist-row {
  border-color: #bfdbfe;
  border-left-color: var(--brand);
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.08);
  transform: translateY(-1px);
  background: #fcfdff;
}

.hist-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-ink);
  line-height: 1.3;
}

.hist-time {
  font-size: 10px;
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  background: #f1f5f9;
  padding: 2px 8px;
  border-radius: 999px;
}

.history-ul {
  gap: 8px;
}

.history-empty {
  border-radius: 16px;
  padding: 24px 16px;
  text-align: center;
  border: 1px dashed var(--border);
  background: rgba(249, 250, 251, 0.5);
}

.history-empty-title {
  font-size: 14px;
  font-weight: 650;
  margin-bottom: 6px;
}

.history-empty-sub {
  font-size: 12px;
  color: var(--muted);
}

/* Kebab menu modernisé */
.kebab {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  transition: background-color 0.12s, border-color 0.12s;
}

.kebab:hover {
  background: var(--brand-soft);
  border-color: #bfdbfe;
  color: var(--brand);
}

.menu {
  border-radius: 12px;
  padding: 4px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.15);
}

.menu .menu-item {
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 500;
  transition: background-color 0.12s;
}

.menu .menu-item:hover {
  background: var(--brand-soft);
}

.menu .danger {
  color: #dc2626;
}

.menu .danger:hover {
  background: #fef2f2;
}

/* ─── Sidebar Account Card — Amélioré ─── */
.side-bottom {
  margin-top: auto;
  padding-top: 8px;
  border-top: none;
}

.account-card {
  background: linear-gradient(135deg, #ffffff 0%, var(--brand-soft) 180%);
  border: 1px solid #dbeafe;
  border-radius: 14px;
  padding: 10px;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
  gap: 8px;
}

.account-main {
  gap: 10px;
}

.account-avatar {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(34, 68, 148, 0.2);
}

.user-name, .user-name span {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-ink);
}

.user-email, .user-email span {
  font-size: 11px;
  color: var(--muted);
}

/* Stats row horizontal */
.account-stats-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px solid rgba(219, 234, 254, 0.6);
}

.account-stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.stat-credits {
  margin-left: auto;
}

.stat-icon {
  display: inline-flex;
  color: var(--muted);
}

.plan-badge {
  font-size: 11px;
  padding: 3px 10px;
  border-radius: 8px;
  font-weight: 600;
}

.app-shell .btn-logout {
  margin-top: 4px;
  border-radius: 10px;
  padding: 6px 8px;
  font-size: 12px;
  background: rgba(255, 255, 255, 0.7);
  border-color: rgba(226, 232, 240, 0.6);
}

.app-shell .btn-logout:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}

.app-shell .btn-logout:hover .ico {
  color: #dc2626;
}

/* Cacher l'ancien layout si présent en fallback */
.account-card .account-stats {
  display: none;
}


/* ═══ Preview V2: Step rows (simplified) ═══ */

.pv-step {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border, #e5e7eb);
  transition: opacity 0.2s ease, background 0.15s ease;
}

.pv-step-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.pv-step-check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 1.5px solid var(--border, #d1d5db);
  color: transparent;
  background: var(--card, #fff);
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.pv-step-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink, #1e293b);
}

.pv-step-ops {
  font-size: 11px;
  color: var(--muted, #94a3b8);
}

/* ── Played state: green check + grayed out ── */
.pv-step--played {
  opacity: 0.55;
  pointer-events: none;
  background: var(--bg-page, #f8fafc);
}

.pv-step--played .pv-step-check {
  border-color: #22c55e;
  background: #22c55e;
  color: #fff;
}

.pv-step--played .pv-run {
  display: none;
}

/* ── Buttons ── */
.btn-sm {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 6px;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border, #d1d5db);
  color: var(--ink, #374151);
}

.btn-outline:hover:not(:disabled) {
  background: var(--brand-soft, #eff6ff);
  border-color: var(--brand, #2563eb);
  color: var(--brand, #2563eb);
}

.btn-outline:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Modal actions spacing ── */
.pv-modal-actions {
  gap: 8px;
}

.pv-modal-actions .pv-reset {
  margin-right: auto; /* Push reset to left, commit+cancel to right */
}


/* ─── Chat Welcome — Rotating Suggestions ─── */
.cw-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-bottom: 24px;
  overflow: hidden;
}

.cw-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  margin-bottom: 24px;
  overflow: hidden;
  position: relative;
}

.cw-sug-line {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  text-align: center;
  padding: 8px 16px;
  border-radius: 10px;
  background: rgba(241, 245, 249, 0.7);
  border: 1px solid rgba(226, 232, 240, 0.5);
  line-height: 1.4;
  user-select: none;
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s ease, max-height 0.45s ease, padding 0.45s ease,
              margin 0.45s ease, border-color 0.4s ease;
  max-height: 60px;
  box-sizing: border-box;
}

/* Item qui sort par le bas */
.cw-sug-line.cw-sug-exit {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: -8px;
  border-color: transparent;
  overflow: hidden;
}

/* Nouvel item qui entre par le haut */
.cw-sug-line.cw-sug-new {
  opacity: 0;
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  border-color: transparent;
  overflow: hidden;
}

.cw-sug-line.cw-sug-new.cw-sug-grow {
  opacity: 1;
  max-height: 60px;
  padding: 8px 16px;
  border-color: rgba(226, 232, 240, 0.5);
}

/* Animation d'entrée initiale */
.cw-sug-line.cw-sug-init {
  animation: cwSugInit 0.5s ease-out forwards;
}

@keyframes cwSugInit {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .cw-sug-line {
    transition: none !important;
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
    max-height: 60px !important;
  }
}

/* ─── Modern Preview CTA Button ─── */
.pv-open-modern {
  display: inline-flex !important;
  align-items: center;
  gap: 4px;
  height: 32px;
  padding: 0 14px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 600;
  background: linear-gradient(135deg, var(--brand-soft), var(--brand-soft-strong));
  border: 1px solid #bfdbfe;
  color: var(--brand-ink);
  cursor: pointer;
  transition: background-color 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.06s ease;
}

.pv-open-modern:hover {
  background: var(--brand-soft-strong);
  border-color: #93c5fd;
  box-shadow: 0 4px 14px rgba(34, 68, 148, 0.15);
  transform: translateY(-0.5px);
}

.pv-open-modern:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(34, 68, 148, 0.12);
}

.pv-open-modern svg {
  color: var(--brand);
}

/* ─── Credits Exhausted Modal ─── */
.credits-modal-card {
  max-width: 380px;
}

.credits-modal-icon {
  font-size: 18px;
  margin-right: 4px;
}

.credits-modal-body {
  font-size: 13px;
  line-height: 1.5;
  color: #475569;
  margin-bottom: 16px;
}

.credits-modal-list {
  margin: 8px 0 0 18px;
  padding: 0;
  font-size: 13px;
  line-height: 1.6;
  color: #334155;
}

.credits-modal-list li {
  margin: 2px 0;
}

.credits-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.credits-modal-btn {
  width: 100%;
  justify-content: center;
  height: 36px;
  font-size: 13px;
  font-weight: 600;
}



/* ──────────────────────────────────────────────
   Chat Welcome rotating suggestions (no layout shift)
   ────────────────────────────────────────────── */
:root{
  --cw-sug-gap: 8px;
  --cw-sug-visible: 3;
  --cw-sug-item-h: 52px; /* JS recalculates to fit the longest phrase */
}

.cw-suggestions{
  position: relative;
  width: 100%;
  margin-bottom: 24px;
  overflow: hidden;

  /* 🔒 empêche le layout global de bouger */
  contain: layout paint;

  /* hauteur FIXE pour 3 items */
  height: calc(
    (var(--cw-sug-visible) * var(--cw-sug-item-h)) +
    ((var(--cw-sug-visible) - 1) * var(--cw-sug-gap))
  );
}

.cw-sug-line{
  position: absolute;
  left: 0;
  right: 0;
  top: 0;

  height: var(--cw-sug-item-h);

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 8px 16px;
  border-radius: 10px;
  background: rgba(241, 245, 249, 0.7);
  border: 1px solid rgba(226, 232, 240, 0.5);

  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.4;
  text-align: center;
  box-sizing: border-box;
  user-select: none;

  will-change: transform, opacity;
  transform: translateY(0px);
  opacity: 1;

  transition: transform 450ms ease, opacity 450ms ease;
}

.cw-sug-line.is-exiting{ opacity: 0; }
.cw-sug-line.is-entering{ opacity: 0; }

@media (prefers-reduced-motion: reduce){
  .cw-sug-line{ transition: none !important; }
}


/* ── Preview Help Button ── */
.pv-modal-help {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1px solid var(--border, #e2e8f0);
  background: transparent;
  color: var(--muted, #64748b);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.pv-modal-help:hover {
  background: var(--brand-soft, #eff3ff);
  color: var(--brand, #224494);
  border-color: var(--brand, #224494);
}

/* ── Preview Help Popup ── */
.pv-help-popup-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100001;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: pvHelpFadeIn 0.2s ease;
}
@keyframes pvHelpFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.pv-help-popup-card {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(15, 23, 42, 0.18);
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  animation: pvHelpSlideUp 0.25s ease;
}
@keyframes pvHelpSlideUp {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.pv-help-popup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px 0;
}
.pv-help-popup-title {
  font-size: 16px;
  font-weight: 700;
  color: #1e293b;
}
.pv-help-popup-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
}
.pv-help-popup-close:hover {
  background: #f1f5f9;
  color: #475569;
}
.pv-help-popup-body {
  padding: 14px 18px 18px;
  font-size: 13px;
  line-height: 1.55;
  color: #475569;
}
.pv-help-popup-body p {
  margin: 0 0 10px;
}
.pv-help-popup-body b {
  color: #1e293b;
}

.pv-modal-title-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ─── Thinking shimmer wave (ChatGPT-like) ─── */

@keyframes shimmer-slide {
  0%   { background-position: 200% center; }
  100% { background-position: -200% center; }
}

@keyframes thinking-fade-in {
  from { opacity: 0; transform: translateY(2px); }
  to   { opacity: 1; transform: translateY(0); }
}

.thinking-shimmer {
  display: inline;
  font-size: 11.5px;
  line-height: 1.5;
  font-weight: 400;
  font-style: italic;
  letter-spacing: 0.01em;
  background: linear-gradient(
    90deg,
    var(--thinking-base, #64748b) 0%,
    var(--thinking-base, #64748b) 35%,
    var(--thinking-highlight, #a8b8cc) 50%,
    var(--thinking-base, #64748b) 65%,
    var(--thinking-base, #64748b) 100%
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: shimmer-slide 2.2s ease-in-out infinite;
}

/* Transition douce quand le texte change */
.thinking-wrapper {
  animation: thinking-fade-in 0.3s ease;
}

/* Le placeholder en mode thinking (remplace les dots) */
.msg.server.pending .content.content-thinking {
  padding: 6px 0;
}


/* =============================
   Onboarding overlay
   ============================= */
.ob-overlay {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(12px);
  padding: 16px;
  animation: ob-fade-in 0.25s ease-out;
}
.ob-overlay.ob-closing {
  animation: ob-fade-out 0.3s ease-in forwards;
}
@keyframes ob-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes ob-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

.ob-container {
  position: relative;
  width: 100%;
  max-width: 400px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 32px 24px 24px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, 0.25);
  text-align: center;
}

/* Steps */
.ob-step {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 0;
  animation: ob-step-in 0.28s ease-out;
}
.ob-step.active {
  display: flex;
}
@keyframes ob-step-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.ob-visual {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ob-visual svg {
  display: block;
}

.ob-title {
  margin: 0 0 10px;
  font-size: 17px;
  font-weight: 700;
  color: var(--brand-ink);
  letter-spacing: -0.01em;
  line-height: 1.25;
}

.ob-text {
  margin: 0 0 6px;
  font-size: 13px;
  color: #475569;
  line-height: 1.55;
}

.ob-hint {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* Profession field */
.ob-field {
  width: 100%;
  margin: 12px 0 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ob-select {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f9fafb;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  appearance: auto;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}
.ob-select:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 4px rgba(37, 99, 235, 0.14);
}

.ob-input-text {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f9fafb;
  font-size: 13px;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
  box-sizing: border-box;
}
.ob-input-text:focus-visible {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand), 0 0 0 4px rgba(37, 99, 235, 0.14);
  background: #fff;
}

/* Practices list */
.ob-practices {
  text-align: left;
  width: 100%;
  margin: 10px 0 0;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #e0edff;
  background: #f8faff;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ob-practice-item {
  font-size: 12px;
  color: #1e3a5f;
  line-height: 1.45;
  padding-left: 20px;
  position: relative;
}
.ob-practice-item::before {
  content: "✓";
  position: absolute;
  left: 0;
  color: var(--brand);
  font-weight: 700;
  font-size: 13px;
}

/* CTA button */
.ob-cta {
  margin-top: 20px;
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 12px;
  background: var(--brand);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.16s ease, box-shadow 0.16s ease, transform 0.06s ease;
  box-shadow: 0 4px 14px rgba(34, 68, 148, 0.28);
}
.ob-cta:hover {
  background: var(--brand-ink);
  box-shadow: 0 8px 22px rgba(34, 68, 148, 0.35);
  transform: translateY(-0.5px);
}
.ob-cta:active {
  transform: translateY(0);
}

/* Skip button */
.ob-skip {
  margin-top: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color 0.15s ease, background-color 0.15s ease;
}
.ob-skip:hover {
  color: var(--brand-ink);
  background: rgba(15, 23, 42, 0.04);
}

/* Progress dots */
.ob-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 24px;
}
.ob-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #e2e8f0;
  cursor: pointer;
  transition: background-color 0.2s ease, width 0.2s ease;
}
.ob-dot.active {
  width: 20px;
  background: var(--brand);
}
.ob-dot.done {
  background: #93c5fd;
}

/* Mobile */
@media (max-width: 420px) {
  .ob-container {
    padding: 24px 18px 20px;
    border-radius: 16px;
  }
  .ob-title {
    font-size: 15px;
  }
}

/* Support button */
.app-shell .btn-support {
  width: 100%;
  justify-content: center;
  font-size: 12px;
  padding-inline: 8px;
  gap: 6px;
  background: #ffffff;
  border-color: #e5e7eb;
  color: var(--brand-ink);
}
.app-shell .btn-support .ico {
  display: inline-flex;
  width: 14px;
  height: 14px;
  color: var(--brand);
}
.app-shell .btn-support:hover {
  background: var(--brand-soft);
  border-color: #bfdbfe;
  color: var(--brand-ink);
  box-shadow: 0 4px 10px rgba(15, 23, 42, 0.06);
}
.app-shell .btn-support:hover .ico {
  color: var(--brand-ink);
}

/* Onboarding field label */
.ob-field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-ink);
  margin-bottom: 4px;
  text-align: left;
}

/* ═══ Code Block: layout, scroll, copy ═══ */
.nx-code-block {
  position: relative;
  border-radius: 8px;
  margin: 8px 0;
  background: #1e1e2e;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
}

.nx-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 10px 2px;
  min-height: 28px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.nx-code-lang {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
}

.nx-code-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  color: rgba(255,255,255,0.35);
  transition: color 0.15s, background 0.15s;
  margin-left: auto;
}
.nx-code-copy:hover {
  color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.08);
}
.nx-code-copy.nx-copied {
  color: #4ade80;
}

.nx-code-block pre {
  margin: 0;
  padding: 12px 14px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.nx-code-block pre code {
  display: block;
  white-space: pre;
  word-break: normal;
  word-wrap: normal;
  color: #cdd6f4;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  tab-size: 2;
}

/* Scrollbar styling */
.nx-code-block pre::-webkit-scrollbar {
  height: 6px;
}
.nx-code-block pre::-webkit-scrollbar-track {
  background: transparent;
}
.nx-code-block pre::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 3px;
}
.nx-code-block pre::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.25);
}

/* ═══ Syntax Highlighting Tokens ═══ */
.nx-hl-kw   { color: #cba6f7; }  /* keywords — purple */
.nx-hl-str  { color: #a6e3a1; }  /* strings — green */
.nx-hl-num  { color: #fab387; }  /* numbers — peach */
.nx-hl-cmt  { color: #6c7086; font-style: italic; }  /* comments — gray */
.nx-hl-fn   { color: #89b4fa; }  /* functions/selectors — blue */
.nx-hl-ref  { color: #f9e2af; }  /* cell refs/variables — yellow */
.nx-hl-key  { color: #89dceb; }  /* JSON keys — teal */
.nx-hl-op   { color: #f38ba8; }  /* operators — red/pink */

/* ═══ Per-language accent on header ═══ */
.nx-lang-json .nx-code-header     { border-bottom-color: rgba(137,220,235,0.25); }
.nx-lang-excel .nx-code-header,
.nx-lang-xlsx .nx-code-header,
.nx-lang-formula .nx-code-header  { border-bottom-color: rgba(30,130,76,0.4); }
.nx-lang-r .nx-code-header        { border-bottom-color: rgba(39,109,195,0.35); }
.nx-lang-python .nx-code-header,
.nx-lang-py .nx-code-header       { border-bottom-color: rgba(255,212,59,0.3); }
.nx-lang-sql .nx-code-header      { border-bottom-color: rgba(233,137,62,0.3); }
.nx-lang-javascript .nx-code-header,
.nx-lang-js .nx-code-header,
.nx-lang-typescript .nx-code-header,
.nx-lang-ts .nx-code-header       { border-bottom-color: rgba(247,223,30,0.25); }
.nx-lang-bash .nx-code-header,
.nx-lang-sh .nx-code-header,
.nx-lang-shell .nx-code-header    { border-bottom-color: rgba(166,227,161,0.25); }
.nx-lang-css .nx-code-header,
.nx-lang-scss .nx-code-header     { border-bottom-color: rgba(137,180,250,0.25); }
.nx-lang-html .nx-code-header,
.nx-lang-xml .nx-code-header      { border-bottom-color: rgba(243,139,168,0.25); }
.nx-lang-yaml .nx-code-header,
.nx-lang-yml .nx-code-header      { border-bottom-color: rgba(249,226,175,0.25); }
.nx-lang-text .nx-code-header     { border-bottom-color: rgba(255,255,255,0.08); }

/* Inline code (backticks) */
.nx-code {
  background: rgba(30,30,46,0.6);
  color: #cba6f7;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 0.9em;
}

/* ===== Fix largeur / wrap global des messages ===== */

.msg,
.msg.server,
.msg .bubble,
.msg .content,
.content-md {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.content-md {
  width: 100%;
  overflow-x: hidden;
}

.content-md .nx-p,
.content-md li,
.content-md p,
.content-md h1,
.content-md h2,
.content-md h3,
.content-md h4,
.content-md td,
.content-md th {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* garder les vrais blocs code non-wrap */
.content-md pre,
.content-md pre code,
.content-md .nx-code-block,
.content-md .nx-code-scroll {
  overflow-wrap: normal;
  word-break: normal;
}

/* ===== Code block corrigé ===== */

.nx-code-block {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
  border-radius: 8px;
  margin: 8px 0;
  background: #1e1e2e;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.5;
}

.nx-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 4px 10px 2px;
  min-height: 28px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.nx-code-lang {
  min-width: 0;
  flex: 1 1 auto;
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nx-code-copy {
  flex: 0 0 auto;
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  cursor: pointer;
  padding: 3px;
  border-radius: 4px;
  color: rgba(255,255,255,0.35);
  transition: color 0.15s, background 0.15s;
  margin-left: auto;
}

.nx-code-copy:hover {
  color: rgba(255,255,255,0.75);
  background: rgba(255,255,255,0.08);
}

.nx-code-copy.nx-copied {
  color: #4ade80;
}

.nx-code-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.nx-code-block pre {
  margin: 0;
  padding: 12px 14px;
  min-width: max-content;
  width: max-content;
}

.nx-code-block pre code {
  display: block;
  white-space: pre;
  color: #cdd6f4;
  font-family: 'SF Mono', 'Fira Code', 'Cascadia Code', 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  tab-size: 2;
}

/* scrollbar visible sur la zone scrollable */
.nx-code-scroll::-webkit-scrollbar {
  height: 8px;
}

.nx-code-scroll::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.05);
}

.nx-code-scroll::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.22);
  border-radius: 999px;
}

.nx-code-scroll::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.32);
}

/* Firefox */
.nx-code-scroll {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.22) rgba(255,255,255,0.05);
}

/* ===== Tables markdown larges ===== */

.nx-table-scroll {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.nx-table-scroll table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
}

.nx-table-scroll::-webkit-scrollbar {
  height: 8px;
}

.nx-table-scroll::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.04);
}

.nx-table-scroll::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.18);
  border-radius: 999px;
}

/* inline code OK, mais ne casse pas la largeur du message */
.nx-code {
  max-width: 100%;
  white-space: normal;
  overflow-wrap: anywhere;
}


/* =============================
   Support page
   ============================= */
.support-wrap {
  padding: 0 2px;
}

.support-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.support-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-ink);
}

.support-new-btn {
  font-size: 12px;
  padding: 6px 14px;
  border-radius: 8px;
}

/* Form */
.support-form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-1);
}

.support-form-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--brand-ink);
  margin-bottom: 12px;
}

.support-field {
  margin-bottom: 10px;
}

.support-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 4px;
}

.support-input,
.support-select,
.support-textarea {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border);
  font-size: 13px;
  font-family: var(--font-ui);
  background: #f9fafb;
  box-sizing: border-box;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.support-input:focus,
.support-select:focus,
.support-textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(34, 68, 148, 0.12);
  background: #fff;
}

.support-textarea {
  resize: vertical;
  min-height: 80px;
}

.support-form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
}

.support-form-error {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  font-size: 12px;
}

.support-form-success {
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #ecfdf3;
  border: 1px solid #bbf7d0;
  color: #166534;
  font-size: 12px;
}

/* Ticket list */
.support-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.support-list-empty {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  padding: 32px 16px;
}

.support-ticket-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.support-ticket-card:hover {
  border-color: var(--brand);
  box-shadow: 0 2px 8px rgba(34, 68, 148, 0.08);
}

.support-ticket-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.support-ticket-subject {
  font-size: 13px;
  font-weight: 600;
  color: var(--brand-ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.support-ticket-status {
  font-size: 10px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.support-ticket-status.status-open {
  background: #eff6ff;
  color: var(--brand);
  border: 1px solid #bfdbfe;
}

.support-ticket-status.status-in_progress {
  background: #fefce8;
  color: #a16207;
  border: 1px solid #fde68a;
}

.support-ticket-status.status-resolved {
  background: #ecfdf3;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.support-ticket-status.status-closed {
  background: #f3f4f6;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}

.support-ticket-bottom {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--muted);
}

.support-ticket-category {
  background: #f3f4f6;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 10px;
}

/* Detail */
.support-back-btn {
  background: none;
  border: none;
  color: var(--brand);
  font-size: 12px;
  cursor: pointer;
  padding: 4px 0;
  margin-bottom: 12px;
  font-family: var(--font-ui);
}

.support-back-btn:hover {
  text-decoration: underline;
}

.support-detail-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: var(--shadow-1);
}

.support-detail-subject {
  font-size: 15px;
  font-weight: 700;
  color: var(--brand-ink);
  margin-bottom: 8px;
}

.support-detail-meta {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 14px;
}

.support-detail-message {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

.support-reply-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--brand-ink);
  margin-top: 16px;
  margin-bottom: 6px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.support-reply-text {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text);
  white-space: pre-wrap;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 8px;
  padding: 10px 12px;
}