/* Open Projects Lab — Espace membre (charte partagée avec la vitrine) */
:root {
  --bg-top: #101624; --bg-bot: #1c283e; --surface: #16213a; --surface-2: #1b2946;
  --line: #2a3a5c; --line-strong: #3a4d78;
  --accent: #38bdac; --accent-2: #63b3ed; --accent-strong: #5fd8c5;
  --text: #eef2f8; --muted: #a7b6cf; --faint: #7f90ad;
  --good: #37c68f; --bad: #e8637a;
  --radius: 16px; --radius-sm: 11px;
  --font: "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Code", Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100dvh; font-family: var(--font); font-size: 17px; line-height: 1.6;
  color: var(--text);
  background:
    radial-gradient(1000px 560px at 80% -10%, rgba(56,189,172,0.10), transparent 60%),
    linear-gradient(168deg, var(--bg-top), var(--bg-bot));
  background-attachment: fixed;
  display: flex; flex-direction: column;
}
a { color: var(--accent-strong); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
h1 { font-size: clamp(1.8rem, 4.5vw, 2.6rem); font-weight: 800; letter-spacing: -0.02em; margin: 0 0 6px; }
.container { width: 100%; max-width: 960px; margin-inline: auto; padding-inline: 22px; }

/* header / footer */
.site-header { border-bottom: 1px solid var(--line); background: rgba(16,22,36,0.72); backdrop-filter: blur(10px); position: sticky; top: 0; z-index: 20; }
.hd { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 14px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.brand:hover { text-decoration: none; }
.nav { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.nav > a:not(.btn) { color: var(--muted); font-size: 0.95rem; }
.nav > a:not(.btn):hover { color: var(--text); text-decoration: none; }
.main { flex: 1; padding-block: clamp(30px, 6vw, 64px); }
.site-footer { border-top: 1px solid var(--line); color: var(--faint); font-size: 0.82rem; font-family: var(--mono); }
.site-footer .container { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; padding-block: 20px; }
.site-footer a { color: var(--faint); }

/* boutons */
.btn { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; font-size: 0.98rem; padding: 11px 20px;
  border-radius: 11px; border: 1px solid transparent; cursor: pointer; transition: transform 0.12s ease, background 0.15s ease, border-color 0.15s ease; }
.btn:hover { transform: translateY(-2px); text-decoration: none; }
.btn-primary { background: var(--accent); color: #06231e; }
.btn-primary:hover { background: #49cebc; }
.btn-ghost { border-color: var(--line-strong); color: var(--text); background: rgba(238,242,248,0.03); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent-strong); }
.btn-block { width: 100%; justify-content: center; }

/* panneau / cartes */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: clamp(26px, 5vw, 40px); }
.panel.center { text-align: center; max-width: 620px; margin-inline: auto; }
.panel.narrow { max-width: 460px; margin-inline: auto; }
.lead { color: var(--muted); font-size: 1.08rem; margin: 10px 0 0; }
.cta { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-top: 26px; }

/* formulaires */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; text-align: left; }
.field label { font-size: 0.88rem; color: var(--muted); font-weight: 600; }
.field input {
  font: inherit; color: var(--text); background: var(--bg-top); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 11px 13px; width: 100%;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.field .hint { font-size: 0.8rem; color: var(--faint); }
.form-foot { margin-top: 8px; font-size: 0.92rem; color: var(--muted); text-align: center; }

/* messages flash */
.flash { border-radius: var(--radius-sm); padding: 12px 16px; margin-bottom: 18px; font-size: 0.95rem; border: 1px solid transparent; }
.flash-success { background: rgba(55,198,143,0.12); border-color: rgba(55,198,143,0.4); color: #bff3dc; }
.flash-error { background: rgba(232,99,122,0.12); border-color: rgba(232,99,122,0.4); color: #f7c9d2; }
.flash-info { background: rgba(56,189,172,0.10); border-color: rgba(56,189,172,0.4); color: #c7efe9; }

.field textarea {
  font: inherit; color: var(--text); background: var(--bg-top); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 11px 13px; width: 100%; resize: vertical; min-height: 76px;
}
.field textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.field input[type=file] { padding: 9px 11px; }

/* profil */
.profile-head { display: flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.avatar-lg { width: 92px; height: 92px; border-radius: 22px; object-fit: cover; border: 1px solid var(--line-strong); flex-shrink: 0; }
.avatar-initials { display: flex; align-items: center; justify-content: center; background: linear-gradient(140deg, var(--accent), var(--accent-2)); color: #06231e; font-size: 2.4rem; font-weight: 800; }
.profile-meta { color: var(--faint); font-family: var(--mono); font-size: 0.82rem; margin: 4px 0 0; }
.profile-bio { color: var(--muted); margin: 10px 0 0; }
.row-form { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 22px; }

.sep { border: none; border-top: 1px solid var(--line); margin: 26px 0; }
.sub { font-size: 1.15rem; font-weight: 700; margin: 0 0 14px; }
.sub.danger { color: var(--bad); }
.badge-warn { font-family: var(--mono); font-size: 0.7rem; letter-spacing: 0.04em; text-transform: uppercase;
  color: #f5c977; background: rgba(220,150,60,0.12); border: 1px solid rgba(220,150,60,0.4); padding: 2px 8px; border-radius: 6px; vertical-align: middle; }
.btn-danger { background: rgba(232,99,122,0.14); border: 1px solid rgba(232,99,122,0.5); color: #f7c9d2; }
.btn-danger:hover { background: rgba(232,99,122,0.24); }

:where(a, button, input):focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* chat */
.chat-panel { max-width: 780px; margin-inline: auto; }
#chat-status { margin: 6px 0 0; }
#chat-status.ok { color: var(--good); }
.messages {
  display: flex; flex-direction: column; gap: 13px; height: 52vh; min-height: 300px; overflow-y: auto;
  padding: 16px; margin: 12px 0 16px; background: var(--bg-top); border: 1px solid var(--line); border-radius: var(--radius);
}
.msg { display: flex; gap: 11px; align-items: flex-start; }
.msg-avatar {
  width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-2)); color: #06231e; font-weight: 800;
}
.msg-body { flex: 1; min-width: 0; }
.msg-head { display: flex; align-items: baseline; gap: 8px; }
.msg-pseudo { font-weight: 700; font-size: 0.92rem; }
.msg-at { font-family: var(--mono); font-size: 0.72rem; color: var(--faint); }
.msg-text { color: var(--muted); overflow-wrap: anywhere; white-space: pre-wrap; }
.msg-del {
  align-self: center; opacity: 0; background: transparent; border: none; color: var(--bad);
  font-size: 1.3rem; line-height: 1; cursor: pointer; padding: 0 6px;
}
.msg:hover .msg-del { opacity: 0.65; }
.msg-del:hover { opacity: 1; }
.chat-form { display: flex; gap: 10px; }
.chat-form input {
  font: inherit; flex: 1; color: var(--text); background: var(--bg-top);
  border: 1px solid var(--line-strong); border-radius: 11px; padding: 12px 14px;
}
.chat-form input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }

/* ===================== App-shell (connecté) ===================== */
.nav-ic, .dash-ic { display: none; }

.app-header { position: sticky; top: 0; z-index: 40; background: rgba(16,22,36,0.82); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.app-header-in { display: flex; align-items: center; justify-content: space-between; height: 60px; max-width: 1440px; margin-inline: auto; padding-inline: 18px; }
.header-right { display: flex; align-items: center; gap: 12px; }

.user-menu { position: relative; }
.user-btn { display: inline-flex; align-items: center; gap: 9px; background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px 4px 4px; cursor: pointer; color: var(--text); }
.user-btn:hover { border-color: var(--line-strong); }
.avatar-xs { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; flex-shrink: 0; }
.avatar-xs.avatar-initial { display: flex; align-items: center; justify-content: center; background: linear-gradient(140deg, var(--accent), var(--accent-2)); color: #06231e; font-weight: 800; font-size: 0.9rem; }
.user-pseudo { font-weight: 600; font-size: 0.92rem; }
.user-btn .chev { color: var(--faint); transition: transform 0.15s ease; }
.user-menu[data-open] .chev { transform: rotate(180deg); }
.user-dropdown { position: absolute; right: 0; top: calc(100% + 8px); min-width: 190px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: 12px; padding: 6px; display: none; flex-direction: column; box-shadow: 0 16px 40px rgba(0,0,0,0.42); }
.user-menu[data-open] .user-dropdown { display: flex; }
.user-dropdown a { padding: 9px 12px; border-radius: 8px; color: var(--muted); font-size: 0.93rem; }
.user-dropdown a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.user-dropdown a.danger { color: #f0a6b3; }

.nav-burger { display: none; flex-direction: column; justify-content: center; gap: 5px; width: 40px; height: 38px; padding: 0 9px; background: transparent; border: 1px solid var(--line); border-radius: 9px; cursor: pointer; }
.nav-burger span { display: block; height: 2px; background: var(--text); border-radius: 2px; }

.app-body { max-width: 1440px; margin-inline: auto; display: grid; grid-template-columns: 210px minmax(0,1fr) 344px; min-height: calc(100dvh - 60px); }
.app-nav { border-right: 1px solid var(--line); padding: 18px 12px; display: flex; flex-direction: column; gap: 3px; position: sticky; top: 60px; align-self: start; }
.app-nav a { display: flex; align-items: center; gap: 10px; padding: 10px 13px; border-radius: 9px; color: var(--muted); font-size: 0.95rem; font-weight: 500; }
.app-nav a:hover { background: var(--surface); color: var(--text); text-decoration: none; }
.app-nav a.active { background: rgba(56,189,172,0.12); color: var(--accent-strong); }

.app-main { padding: 26px 30px; min-width: 0; }
.app-main .page-head { margin-bottom: 22px; }
.app-main .page-head h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); font-weight: 800; }
.app-main .page-head .lead { color: var(--muted); margin: 8px 0 0; max-width: 52ch; }

.app-chat { border-left: 1px solid var(--line); display: flex; flex-direction: column; height: calc(100dvh - 60px); position: sticky; top: 60px; }
.chat-head { display: flex; align-items: center; gap: 9px; padding: 15px 18px; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 0.95rem; }
.chat-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--faint); flex-shrink: 0; }
.chat-dot.on { background: var(--good); }
.app-chat .messages { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 13px; padding: 16px; background: transparent; border: none; border-radius: 0; margin: 0; height: auto; min-height: 0; }
.app-chat .chat-form { padding: 13px 16px; border-top: 1px solid var(--line); gap: 8px; }
.app-chat .chat-form .btn { padding: 11px 15px; }

.dash-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); margin-bottom: 22px; }
.dash-card { display: flex; flex-direction: column; gap: 5px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; color: var(--text); transition: transform 0.14s ease, border-color 0.14s ease; }
.dash-card:hover { transform: translateY(-3px); border-color: var(--accent); text-decoration: none; }
.dash-t { font-weight: 700; font-size: 1.05rem; }
.dash-d { color: var(--muted); font-size: 0.9rem; }
.profile-name { font-size: 1.5rem; font-weight: 800; margin: 0; }

@media (max-width: 1080px) {
  .app-body { grid-template-columns: 200px minmax(0,1fr); }
  .app-chat { grid-column: 1 / -1; border-left: none; border-top: 1px solid var(--line); height: 62vh; position: static; }
}
@media (max-width: 760px) {
  .nav-burger { display: inline-flex; }
  .user-pseudo { display: none; }
  .app-body { grid-template-columns: 1fr; }
  .app-nav { position: fixed; top: 60px; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(16,22,36,0.98); backdrop-filter: blur(12px); border-right: none; padding: 18px; transform: translateX(-100%); transition: transform 0.2s ease; }
  body.app[data-nav] .app-nav { transform: none; }
  .app-main { padding: 20px 18px; }
  .app-chat { height: 72vh; }
}
