/* FLUXBOT chat app: Projects (E4). The sidebar section (#projectsMount), the project page (#projectView, in the chat
   area while .main.proj-view), the top-bar chip (#projectChipMount) and the project dialogs (#projModal).
   Dark + light themes via the style.css tokens; prefers-reduced-motion and body.fx-off stop the motion;
   body.no-projects hides it all for members. Touch targets are at least 40–44 px on phones. */

body.no-projects #projectsMount, body.no-projects .proj-chip, body.no-projects .proj-page { display: none !important; }

/* ---------- the colour tile (emoji on a soft tint with a ring in the project's colour) ---------- */
.proj-tile {
  --proj-c: #1e90ff;
  display: inline-grid; place-items: center; flex: none; width: 28px; height: 28px; border-radius: 9px;
  font-size: 15px; line-height: 1; background: color-mix(in srgb, var(--proj-c) 16%, transparent);
  box-shadow: inset 0 0 0 1.5px var(--proj-c);
}
.proj-tile.sm { width: 24px; height: 24px; border-radius: 7px; font-size: 13px; }
.proj-tile.lg { width: 56px; height: 56px; border-radius: 16px; font-size: 28px; box-shadow: inset 0 0 0 2px var(--proj-c), 0 8px 26px -12px var(--proj-c); }

/* ---------- sidebar ---------- */
.proj-sec { padding: 4px 0 2px; }
.proj-head { display: flex; align-items: center; gap: 2px; padding: 8px 4px 4px 2px; }
.proj-toggle {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; height: 30px; padding: 0 8px; border-radius: 8px;
  font-size: 12px; font-weight: 600; color: var(--dim); text-align: left;
}
.proj-toggle:hover { color: var(--text); background: var(--hover); }
.proj-toggle svg { width: 14px; height: 14px; flex: none; transition: transform .2s; }
.proj-toggle[aria-expanded="true"] svg { transform: rotate(90deg); }
.proj-add { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: var(--muted); flex: none; }
.proj-add:hover { color: var(--text); background: var(--hover); }
.proj-add svg { width: 17px; height: 17px; }
.proj-list { list-style: none; margin: 0; padding: 0; }
.proj-row { display: flex; align-items: center; gap: 2px; border-radius: 10px; padding-right: 2px; }
.proj-row:hover { background: var(--hover); }
.proj-row.active { background: var(--active); box-shadow: inset 2px 0 0 var(--flux-cyan); }
.proj-open { flex: 1; min-width: 0; display: flex; align-items: center; gap: 9px; height: 38px; padding: 0 6px 0 8px; border-radius: 10px; text-align: left; font-size: 14px; }
.proj-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-count { flex: none; font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.proj-exp, .proj-more { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; color: var(--dim); flex: none; }
.proj-exp:hover, .proj-more:hover { color: var(--text); background: var(--hover); }
.proj-exp svg { width: 14px; height: 14px; transition: transform .2s; }
.proj-exp.open svg { transform: rotate(90deg); }
.proj-more svg { width: 16px; height: 16px; }
.proj-more { opacity: 0; }
.proj-row:hover .proj-more, .proj-row.active .proj-more, .proj-more:focus-visible { opacity: 1; }
.proj-chats { padding: 2px 0 6px 20px; margin-left: 12px; border-left: 1px solid var(--border); }
.proj-pin-emoji { flex: none; margin-right: 6px; font-size: 13px; line-height: 1; }
#projectsMount .proj-pin-emoji { display: none; } /* it's already under its project there */
.proj-chats .chat-item { font-size: 13.5px; }
.proj-all { display: block; width: 100%; text-align: left; font-size: 12.5px; color: var(--accent); padding: 6px 10px; border-radius: 8px; }
.proj-all:hover { background: var(--hover); }
[data-theme="light"] .proj-all { color: #0a52c4; }

/* ---------- top-bar chip ---------- */
.proj-chip {
  --proj-c: #1e90ff;
  display: inline-flex; align-items: center; gap: 6px; height: 34px; max-width: min(34vw, 220px); padding: 0 6px 0 9px; margin-right: 2px;
  border-radius: 999px; font-size: 13.5px; font-weight: 600; color: var(--text); flex: 0 1 auto; min-width: 0;
  background: color-mix(in srgb, var(--proj-c) 12%, transparent); border: 1px solid color-mix(in srgb, var(--proj-c) 55%, transparent);
}
.proj-chip:hover { background: color-mix(in srgb, var(--proj-c) 22%, transparent); }
.proj-chip-emoji { flex: none; font-size: 14px; }
.proj-chip-name { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-chip-chev { display: grid; flex: none; color: var(--dim); }
.proj-chip-chev svg { width: 13px; height: 13px; }
@media (max-width: 400px) { .proj-chip-name { display: none; } .proj-chip { padding: 0 4px 0 8px; } }

/* ---------- the project page ---------- */
.main.proj-view .dock .personas, .main.proj-view .dock .suggest { display: none; }
.proj-page { padding: 18px 0 28px; animation: projIn .2s ease-out; }
.proj-page.proj-drop { outline: 2px dashed var(--accent); outline-offset: 6px; border-radius: 16px; }
@keyframes projIn { from { opacity: 0; transform: translateY(6px); } }
.proj-hero { display: flex; align-items: center; gap: 16px; }
.proj-hero-tile { border-radius: 18px; flex: none; }
.proj-hero-tile:hover .proj-tile { filter: brightness(1.08); }
.proj-hero-text { min-width: 0; }
.proj-title { font-size: 26px; font-weight: 700; letter-spacing: -.01em; line-height: 1.2; margin: 0; }
.proj-rename { font: inherit; color: inherit; text-align: left; border-radius: 8px; padding: 0 4px; margin-left: -4px; max-width: 100%; overflow-wrap: anywhere; }
.proj-rename:hover { background: var(--hover); }
.proj-sub { margin-top: 2px; font-size: 13.5px; color: var(--muted); }
.proj-hint { margin: 14px 0 0; font-size: 13.5px; color: var(--muted); }
.proj-tabs { display: flex; gap: 4px; margin: 18px 0 14px; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.proj-tabs::-webkit-scrollbar { display: none; }
.proj-tab { flex: 1 0 auto; height: 36px; padding: 0 14px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.proj-tab:hover { color: var(--text); }
.proj-tab[aria-selected="true"] { color: var(--text); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.proj-panel:focus-visible { outline-offset: 4px; border-radius: 8px; }
.proj-empty { padding: 18px 4px; color: var(--muted); font-size: 14px; }
.proj-label { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.proj-help { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.proj-note { margin-top: 12px; font-size: 12.5px; color: var(--dim); }
.proj-actions { display: flex; align-items: center; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.proj-spacer { flex: 1; }
.proj-count-live { font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; }
.proj-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* chats tab */
.proj-chatlist { display: grid; gap: 2px; }
.proj-crow { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 6px 10px; border-radius: 10px; text-align: left; }
.proj-crow:hover { background: var(--hover); }
.proj-crow-ico { display: grid; color: var(--dim); flex: none; }
.proj-crow-ico svg { width: 17px; height: 17px; }
.proj-crow-title { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.proj-crow-time { flex: none; font-size: 12px; color: var(--dim); }

/* instructions tab */
.proj-instr { margin-top: 8px; min-height: 180px; font-size: 14px; }

/* files tab */
.proj-files-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.proj-file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.proj-addfiles { cursor: pointer; }
.proj-addfiles svg { width: 16px; height: 16px; }
.proj-addfiles.is-disabled { opacity: .45; cursor: not-allowed; pointer-events: none; }
.proj-file-input:focus-visible + .proj-addfiles { outline: 2px solid var(--accent); outline-offset: 2px; }
.proj-meter { margin: 14px 0 10px; }
.proj-bar { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.proj-bar-fill { display: block; height: 100%; border-radius: inherit; background: var(--grad); }
.proj-meter-text { margin-top: 6px; font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; }
.proj-files { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.proj-file { display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 12px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.proj-file-ico { display: grid; color: var(--accent); flex: none; }
.proj-file-ico svg { width: 20px; height: 20px; }
.proj-file-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.proj-file-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-file-sub { font-size: 12px; color: var(--muted); }
.proj-file-acts { display: flex; gap: 6px; flex: none; }
.proj-file.is-reading .proj-file-sub, .proj-file.is-uploading .proj-file-sub { color: var(--accent); }
.proj-added { color: var(--ok); font-weight: 600; }
.proj-file.is-error { border-color: var(--danger); background: var(--danger-soft); }
.proj-file.is-error .proj-file-sub { color: var(--danger); white-space: normal; }
.proj-dismiss { width: 32px; height: 32px; }
.proj-dismiss svg { width: 16px; height: 16px; }

/* settings tab */
.proj-field { margin-bottom: 16px; }
.proj-select { max-width: 360px; height: 42px; background: var(--bg); }
.proj-switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); }
.proj-switch-text { display: flex; flex-direction: column; cursor: pointer; }
.proj-switch-text .proj-label { margin-bottom: 2px; }
.proj-set-acts .btn svg, .proj-danger .btn svg { width: 15px; height: 15px; }
.proj-danger { margin-top: 22px; padding-top: 16px; border-top: 1px solid var(--border); display: grid; gap: 10px; justify-items: start; }

/* loading skeleton */
.proj-skel { display: grid; gap: 10px; padding: 8px 0; justify-items: start; }
.proj-skel-line { width: 100%; height: 44px; border-radius: 12px; background: linear-gradient(90deg, var(--surface) 0%, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: projShimmer 1.3s ease-in-out infinite; }
.proj-skel-line:nth-child(2) { width: 82%; }
.proj-skel-line:nth-child(3) { width: 64%; }
@keyframes projShimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }

/* ---------- dialogs ---------- */
.proj-form { display: grid; gap: 14px; }
.proj-form .input { height: 42px; }
.proj-form-row { display: flex; gap: 14px; align-items: flex-start; }
.proj-form-tile { margin-top: 26px; }
.proj-emoji, .proj-colors, .proj-choices { border: 0; margin: 0; padding: 0; min-width: 0; }
.proj-emoji { flex: 1; }
.proj-emoji-grid { display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
.proj-emo { height: 40px; border-radius: 9px; font-size: 19px; line-height: 1; display: grid; place-items: center; }
.proj-emo:hover { background: var(--hover); }
.proj-emo.on { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); }
.proj-emo-own { margin-top: 8px; height: 38px !important; font-size: 14px; }
.proj-colors { display: flex; flex-wrap: wrap; gap: 8px; }
.proj-colors legend { width: 100%; }
.proj-swatch { position: relative; width: 40px; height: 40px; display: grid; place-items: center; cursor: pointer; border-radius: 50%; }
.proj-swatch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.proj-swatch-dot { width: 28px; height: 28px; border-radius: 50%; background: var(--proj-c); box-shadow: 0 0 0 2px var(--bg); pointer-events: none; }
.proj-swatch input:checked + .proj-swatch-dot { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.proj-swatch input:focus-visible + .proj-swatch-dot { outline: 2px solid var(--accent); outline-offset: 4px; }
.proj-form-err { min-height: 18px; font-size: 13px; color: var(--danger); }
.proj-form-err:empty { min-height: 0; }
.proj-confirm { font-size: 14px; color: var(--text); }
.proj-choices { display: grid; gap: 6px; margin-top: 12px; }
.proj-choice { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border); cursor: pointer; font-size: 14px; }
.proj-choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.proj-choice input { accent-color: var(--accent); width: 18px; height: 18px; }
.proj-pick { display: grid; gap: 4px; }
.proj-pick-row { display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 10px; border-radius: 10px; text-align: left; font-size: 14px; }
.proj-pick-row:hover { background: var(--hover); }
.proj-pick-row.on { background: var(--active); font-weight: 600; }
.proj-pick-row svg { width: 18px; height: 18px; color: var(--muted); flex: none; margin: 0 3px; }
.proj-pick-row span:last-child { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proj-filetext { margin-top: 10px; max-height: 55vh; overflow: auto; padding: 12px 14px; border-radius: 10px; background: var(--code-bg); border: 1px solid var(--border); white-space: pre-wrap; overflow-wrap: anywhere; font-family: 'JetBrains Mono', ui-monospace, Consolas, monospace; font-size: 12.5px; line-height: 1.55; user-select: text; }
#projModal .modal { max-width: 460px; }

/* ---------- phones ---------- */
@media (max-width: 768px) {
  .proj-open { height: 44px; }
  .proj-exp, .proj-more { width: 36px; height: 36px; opacity: 1; }
  .proj-add { width: 36px; height: 36px; }
  .proj-page { padding-top: 10px; }
  .proj-hero { gap: 12px; }
  .proj-tile.lg { width: 48px; height: 48px; font-size: 24px; border-radius: 14px; }
  .proj-title { font-size: 22px; }
  .proj-tab { height: 40px; flex: 0 0 auto; }
  .proj-file { flex-wrap: wrap; }
  .proj-file-acts { width: 100%; justify-content: flex-end; }
  .proj-file-acts .btn { height: 36px; }
  .proj-emoji-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .proj-form-tile { display: none; }
}

/* ---------- motion ---------- */
body.fx-off .proj-page, body.fx-off .proj-skel-line { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .proj-page, .proj-skel-line { animation: none !important; }
  .proj-toggle svg, .proj-exp svg { transition: none; }
}
