/* Shared kgweb shell — kgilles-style fixed header + header auth slot */
:root {
  --site-header-h: 4.5rem;
  --console-brand: #0050d7;
  --dialog-ok: #003087;
  --dialog-cancel: #0039a8;
  --kweb-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  margin: 0;
  font-family: var(--kweb-font);
  color: #1a1f36;
  line-height: 1.5;
  background: #f4f6fb;
}

button,
input,
select,
textarea {
  font: inherit;
}

body.shell-has-header {
  padding-top: var(--site-header-h);
  padding-bottom: 3.25rem;
}

#kwebShellMount {
  position: relative;
  z-index: 1100;
}

.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1100;
  background: #fff;
  border-bottom: 1px solid #d8deea;
  padding: 1rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-sizing: border-box;
  min-height: var(--site-header-h);
  overflow: visible;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font: inherit;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
}

.site-brand img {
  width: 48px;
  height: 48px;
  pointer-events: none;
}

.site-brand .site-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.site-brand-cluster {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  position: relative;
}

.session-fields-wrap {
  position: relative;
  flex: 0 0 auto;
}

.session-fields-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--console-brand, #3b5bdb);
  cursor: pointer;
}

.session-fields-btn:hover,
.session-fields-btn[aria-expanded="true"] {
  background: #eef2ff;
}

.session-fields-btn svg {
  width: 1.15rem;
  height: 1.15rem;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.session-fields-panel {
  position: fixed;
  top: calc(var(--site-header-h) - 0.35rem);
  left: max(1rem, env(safe-area-inset-left, 0px));
  z-index: 1200;
  width: min(52rem, calc(100vw - 2rem));
  max-height: calc(100vh - var(--site-header-h) + 0.35rem - 0.75rem);
  overflow: auto;
  padding: 1.1rem 1.25rem 1.25rem;
  border: 1px solid #d8deea;
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 10px 28px rgba(20, 30, 60, 0.12);
  box-sizing: border-box;
}

.session-fields-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.65rem;
}

.session-fields-panel-head strong {
  font-size: 0.92rem;
  font-weight: 600;
  color: #1f2a44;
}

.session-fields-close {
  border: none;
  background: transparent;
  color: #667085;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  padding: 0.1rem 0.25rem;
  border-radius: 4px;
}

.session-fields-close:hover {
  background: #f2f4f8;
  color: #1f2a44;
}

.session-fields-empty {
  margin: 0;
  color: #667085;
  font-size: 0.9rem;
}

.session-fields-list {
  margin: 0;
  display: grid;
  gap: 0.45rem;
}

.session-fields-row {
  display: grid;
  grid-template-columns: minmax(7rem, 32%) 1fr;
  gap: 0.75rem;
  align-items: start;
  padding: 0.45rem 0;
  border-top: 1px solid #eef1f6;
}

.session-fields-row:first-child {
  border-top: none;
  padding-top: 0;
}

.session-fields-row dt {
  margin: 0;
  font-size: 0.86rem;
  font-weight: 600;
  color: #667085;
  word-break: break-word;
}

.session-fields-row dd {
  margin: 0;
  font-size: 0.92rem;
  color: #1f2a44;
  word-break: break-word;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.session-fields-blank {
  color: #98a2b3;
  font-family: inherit;
}

.session-fields-row[data-group="meta"] dt,
.session-fields-row[data-group="application"] dt {
  color: #3b5bdb;
}

.header-brand-sep {
  display: inline-block;
  width: 1px;
  height: 1.75rem;
  background: #d8deea;
  margin: 0 0.15rem;
}

.header-partner-logo {
  display: block;
  height: 1.35rem;
  width: auto;
  max-width: min(11rem, 36vw);
  object-fit: contain;
}

.header-get-app-qr {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  line-height: 0;
  border-radius: 0.25rem;
}

.header-get-app-qr img {
  width: 44px;
  height: 44px;
  display: block;
  background: #fff;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-shrink: 0;
  overflow: visible;
}

.site-nav {
  flex: 1 1 auto;
  min-width: 0;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
  padding-right: 0.5rem;
}

.site-nav a.nav-icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  color: var(--console-brand);
  text-decoration: none;
  border-radius: 8px;
}

.site-nav a.nav-icon-link:hover {
  background: #eef2ff;
}

.site-nav a.nav-icon-link.active {
  background: #e8eeff;
  box-shadow: inset 0 0 0 1px #c7d4ff;
}

.site-nav a.nav-icon-link .nav-icon {
  width: 1.25rem;
  height: 1.25rem;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.site-brand-cluster .personae-ws-dot {
  flex: 0 0 auto;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #d64545;
  box-shadow: 0 0 0 1px rgba(214, 69, 69, 0.25);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}
.site-brand-cluster .personae-ws-dot.is-connecting {
  background: #e0a84a;
  box-shadow: 0 0 0 1px rgba(224, 168, 74, 0.25);
}
.site-brand-cluster .personae-ws-dot.is-connected {
  background: #2f9e6b;
  box-shadow: 0 0 0 1px rgba(47, 158, 107, 0.25);
}

.header-auth {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 0 0 auto;
  overflow: visible;
}

.lang-switch-mount {
  display: flex;
  align-items: center;
}

.lang-switch {
  display: inline-flex;
  border: 1px solid #d8deea;
  border-radius: 999px;
  overflow: hidden;
  background: #fff;
}

.lang-btn {
  border: none;
  background: transparent;
  color: #5c6378;
  font: 600 0.6875rem/1 system-ui, sans-serif;
  letter-spacing: 0.04em;
  padding: 0.35rem 0.55rem;
  cursor: pointer;
}

.lang-btn:hover {
  color: var(--console-brand);
}

.lang-btn.active {
  background: #eef3ff;
  color: var(--console-brand);
}

.header-login-btn {
  font: 400 0.875rem/1.2 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #5c6378;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem 0.75rem;
  white-space: nowrap;
}

.header-login-btn:hover {
  color: var(--console-brand);
}

.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-overlay.hidden {
  display: none;
}

.login-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 31, 54, 0.45);
}

.login-overlay-panel {
  position: relative;
  z-index: 1;
  width: min(100%, 720px);
  min-height: 320px;
  background: #f4f6fb;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(26, 31, 54, 0.2);
  overflow: visible;
}

.login-overlay-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  z-index: 2;
  width: 2rem;
  height: 2rem;
  border: none;
  border-radius: 999px;
  background: #fff;
  color: #5c6378;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.login-overlay-close:hover {
  color: var(--console-brand);
}

.login-overlay-auth {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
  width: 100%;
}

@media (max-width: 640px) {
  .login-overlay {
    padding: 0.5rem;
    align-items: flex-start;
    overflow-y: auto;
  }
  .login-overlay-panel {
    width: 100%;
    max-width: 480px;
    min-height: 0;
    margin: auto 0;
    border-radius: 12px;
    overflow: visible;
  }
  .login-overlay-auth {
    min-height: 0;
    width: 100%;
  }
  .login-overlay-auth .kie-la-auth-iframe-wrap,
  .login-overlay-auth .kie-la-auth-iframe {
    width: 100% !important;
    max-width: 100%;
  }
}

.login-overlay-auth-min {
  display: none !important;
}

.kweb-confirm {
  position: fixed;
  inset: 0;
  z-index: 2100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  overflow-y: auto;
}

.kweb-confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 31, 54, 0.45);
}

.kweb-confirm-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(100%, 30rem);
  max-height: min(90vh, 40rem);
  overflow: hidden;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(26, 31, 54, 0.22);
}

.kweb-confirm-header {
  background: var(--console-brand);
  color: #fff;
  padding: 1.1rem 1.25rem;
}

.kweb-confirm-title {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 700;
}

.kweb-confirm-body {
  padding: 1.15rem 1.25rem 1.25rem;
  overflow-y: auto;
  min-height: 0;
}

.kweb-confirm-message {
  margin: 0 0 1.15rem;
  color: #1a1f36;
  font-size: 0.95rem;
  line-height: 1.55;
  hyphens: none;
  overflow-wrap: break-word;
}

.kweb-confirm-list {
  margin: 0 0 1.15rem;
  padding-left: 1.2rem;
  color: #1a1f36;
  font-size: 0.95rem;
  line-height: 1.55;
  hyphens: none;
  overflow-wrap: break-word;
}

.kweb-confirm-list li + li {
  margin-top: 0.45rem;
}

.kweb-confirm-ok,
.kweb-confirm-cancel {
  display: block;
  width: 100%;
  border: none;
  border-radius: 10px;
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  min-height: 2.75rem;
}

.kweb-confirm-ok {
  background: var(--dialog-ok);
  color: #fff;
}

.kweb-confirm-cancel {
  margin-top: 0.5rem;
  background: var(--dialog-cancel);
  color: #fff;
}

.kweb-avatar-picker-panel {
  max-width: 26rem;
}

.kweb-avatar-preview-wrap {
  position: relative;
  width: 13.5rem;
  height: 13.5rem;
  margin: 0 auto 0.75rem;
}

.kweb-avatar-preview {
  width: 13.5rem;
  height: 13.5rem;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid #d7deea;
  background: linear-gradient(180deg, #eef3ff 0%, #dce8fa 100%);
  display: block;
  cursor: pointer;
}

.kweb-avatar-preview--empty {
  background: linear-gradient(180deg, #eef3ff 0%, #dce8fa 100%);
}

.kweb-avatar-preview-busy {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 3px solid rgba(26, 92, 255, 0.2);
  border-top-color: #1a5cff;
  animation: kweb-avatar-spin 0.8s linear infinite;
}

@keyframes kweb-avatar-spin {
  to {
    transform: rotate(360deg);
  }
}

.kweb-avatar-index {
  text-align: center;
  color: #5b677a;
  font-size: 0.9rem;
  margin: 0 0 0.85rem;
}

.kweb-avatar-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  justify-content: center;
  margin-bottom: 0.7rem;
}

.kweb-avatar-chip {
  border: 1px solid #d7deea;
  background: #fff;
  color: #1a2333;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}

.kweb-avatar-chip.active {
  background: #1a5cff;
  border-color: #1a5cff;
  color: #fff;
}

.kweb-avatar-age {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin: 0.35rem 0 0.85rem;
  font-size: 0.95rem;
}

.kweb-avatar-age input {
  width: 4.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #d7deea;
  border-radius: 0.45rem;
  font: inherit;
}

.kweb-avatar-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 0.4rem;
}

.personae-field-row input[readonly],
.personae-meta-inputs input[readonly] {
  color: #5c6378;
  cursor: default;
}

.site-footer {
  position: fixed;
  z-index: 80;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5rem;
  border-top: 1px solid #d8deea;
  padding: 0.45rem 0;
  text-align: center;
  font-size: 0.8125rem;
  color: #5c6378;
  background: #fff;
  box-shadow: 0 -1px 0 #d8deea;
  white-space: nowrap;
}

.site-footer p {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  padding: 0;
  color: #14203a;
  text-align: left;
  font: 600 0.8125rem/1.2 system-ui, sans-serif;
  white-space: nowrap;
}

.site-footer a {
  color: #5c6378;
}

.site-footer a:hover {
  color: var(--console-brand);
}

.site-footer-nav {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 0.35rem 1rem;
  margin: 0;
  white-space: nowrap;
}

.site-footer-nav a {
  font-size: 0.8125rem;
  text-decoration: none;
}

body.shell-footer-embed {
  margin: 0;
  background: #fff;
  overflow: hidden;
}

body.shell-footer-embed .site-footer {
  position: relative;
  height: 40px;
  min-height: 40px;
  box-sizing: border-box;
}

.header-auth-slot {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  min-width: 4.5rem;
  min-height: 2.25rem;
  overflow: visible;
  position: relative;
  z-index: 2;
}

.login-fallback {
  font: 400 0.875rem/1.2 system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  color: #5c6378;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.35rem 0.5rem;
  white-space: nowrap;
}

.login-fallback:hover {
  color: var(--console-brand);
}

.session-user {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-width: 0;
  max-width: min(16rem, 42vw);
}

.session-avatar,
.session-avatar-initial {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1px solid #d8deea;
  background: #e8eeff;
}

.session-avatar {
  object-fit: cover;
  background: #f4f6fb;
}

.session-avatar-initial {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--console-brand, #3b5bdb);
  line-height: 1;
  user-select: none;
}

.session-avatar-initial[hidden] {
  display: none !important;
}

.session-user .status,
.header-auth .status {
  font-size: 0.875rem;
  color: #5c6378;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.header-auth .logout {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  margin: 0;
  color: var(--console-brand);
  background: none;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

/* Author display must not override HTML hidden (login vs logout exclusivity). */
.header-auth .logout[hidden],
.header-login-btn[hidden] {
  display: none !important;
}

.header-auth .logout svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.85;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.header-auth .logout:hover {
  background: #eef2ff;
}

@media (max-width: 860px) {
  .site-footer {
    justify-content: flex-end;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
  }

  .site-footer-nav {
    justify-content: flex-end;
  }

  /* Keep copyright (left) + « Informations légales » only. */
  .site-footer-nav a:not(:first-child) {
    display: none;
  }

  :root {
    --site-header-h: 6.75rem;
  }

  .site-header {
    flex-wrap: wrap;
    align-items: center;
    padding: 0.65rem 0.85rem 0.55rem;
    gap: 0.45rem 0.75rem;
    min-height: var(--site-header-h);
  }

  .site-brand .site-title {
    font-size: 1.05rem;
  }

  .session-fields-panel {
    left: 0.75rem;
    right: 0.75rem;
    width: auto;
    max-height: calc(100vh - var(--site-header-h) + 0.35rem - 0.5rem);
  }

  .site-nav {
    order: 3;
    flex: 1 1 100%;
    width: 100%;
    margin-left: 0;
    padding-right: 0;
    justify-content: flex-start;
    gap: 0.25rem;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
  }

  .site-nav a.nav-icon-link {
    width: 2rem;
    height: 2rem;
  }

  .header-auth {
    margin-left: auto;
    gap: 0.5rem;
  }

  .session-user {
    max-width: min(11rem, 46vw);
    gap: 0.4rem;
  }

  .session-avatar,
  .session-avatar-initial {
    width: 32px;
    height: 32px;
  }

  .session-avatar-initial {
    font-size: 0.9rem;
  }

  .session-user .status,
  .header-auth .status {
    max-width: 7.5rem;
  }

  .header-auth .logout {
    width: 2rem;
    height: 2rem;
  }
}

.shell-main.shell-locked {
  visibility: hidden;
  pointer-events: none;
  min-height: 40vh;
}

.auth-gate {
  max-width: 36rem;
  margin: 3rem auto;
  padding: 1.5rem;
  text-align: center;
  color: #5c6378;
  font-size: 1rem;
  line-height: 1.5;
}

.auth-gate.hidden {
  display: none;
}
