/* StudyShare · polish v5 : accent Claude, mise en page compacte, sources lisibles */

/* 1. Couleur d'accent (terracotta, comme Claude) */
:root {
  --primary: #c96442;
  --primary-hover: #b0553a;
  --accent: #c96442;
  --blue: #c96442;
  --blue-2: #a94f34;
  --blue-soft: #f7e9e2;
  --focus-ring: 0 0 0 3px rgb(201 100 66 / 22%);
  --radius-control: 12px;
  --radius-surface: 16px;
}
:root[data-theme="dark"] {
  --primary: #e08a6d;
  --primary-hover: #eaa087;
  --accent: #e08a6d;
  --blue: #e08a6d;
  --blue-2: #f0ad93;
  --blue-soft: #3a2a24;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --primary: #e08a6d;
    --primary-hover: #eaa087;
    --accent: #e08a6d;
    --blue: #e08a6d;
    --blue-2: #f0ad93;
    --blue-soft: #3a2a24;
  }
}

/* 2. Boutons et champs */
.btn { min-height: 36px; border-radius: var(--radius-control); font-weight: 600; }
.btn:not(.ghost):not(.danger):not(.red):not(.okb) { background: var(--primary); color: #fff; }
.btn:not(.ghost):not(.danger):not(.red):not(.okb):hover:not(:disabled) { background: var(--primary-hover); }
a { color: var(--primary); }
.in:focus, textarea:focus, select:focus, input:focus { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }

/* 3. Barre laterale plus etroite (ordinateur seulement) */
@media (min-width: 781px) {
  .app, .student-app { grid-template-columns: 236px minmax(0, 1fr); }
  .app.collapsed, .student-app.collapsed { grid-template-columns: 60px minmax(0, 1fr); }
}

/* 4. Panneau de droite (documents, sources, recherche) plus compact */
@media (min-width: 781px) {
  .main.with-panel { grid-template-columns: minmax(0, 1fr) min(460px, 40%); }
  .main.research-open.with-panel { grid-template-columns: minmax(0, 1fr) min(640px, 52%); }
}
.panel { background: var(--bg); }
.panel .p-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--bg); }
.panel .p-head h2 { font-size: 15px; font-weight: 600; margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel .p-body { padding: 14px 16px; }

/* 5. Popover des sources : borne en taille, bouton toujours visible */
.srcpop {
  width: min(320px, calc(100vw - 16px));
  max-width: min(320px, calc(100vw - 16px));
  max-height: min(420px, 70vh);
  overflow-y: auto;
  padding: 12px 14px 14px;
  font-size: 13px;
  line-height: 1.45;
}
.srcpop b { font-size: 13.5px; }
.srcpop .small { font-size: 12px; color: var(--ink-3); }
.srcpop .source-location { font-size: 12px; color: var(--ink-2); margin-top: 4px; }
.srcpop .source-passage { max-height: 140px; overflow-y: auto; margin: 8px 0; padding: 6px 10px; font-size: 12.5px; border-left: 2px solid var(--line-strong); }
.srcpop a { display: block; margin-top: 6px; font-size: 12px; word-break: break-all; }
.srcpop .btn { width: 100%; margin-top: 10px; justify-content: center; }
.srcpop .btn.sm { min-height: 34px; font-size: 13px; }

/* 6. Lisibilite de la conversation */
.m.bot .md { font-size: 15.5px; line-height: 1.7; }
.m.bot .md pre { max-width: 100%; overflow-x: auto; }
.chat-app-frame, .chat-diagram-frame { border-radius: 14px; }

/* v6 : texte selectionnable, copie des codes, edition inline, telechargement des schemas */
.thread, .thread * { -webkit-user-select: text; user-select: text; }
.code-box { position: relative; margin: 10px 0; }
.code-box pre { margin: 0; }
.code-copy { position: absolute; top: 8px; right: 8px; z-index: 1; border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 8px; padding: 3px 9px; font: 500 12px var(--sans); cursor: pointer; }
.code-copy:hover { color: var(--ink); background: var(--soft); }
.artifact-box { margin: 10px 0; }
.artifact-box .chat-diagram-frame { margin: 0; }
.artifact-toolbar { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.inline-edit { width: 100%; max-width: 85%; margin-left: auto; }
.inline-edit-text { min-height: 56px; width: 100%; }
.inline-edit-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }

/* v7 : outils sans bordure ni barre de defilement, fond transparent, formules KaTeX */
.chat-app-frame, .chat-diagram-frame { display: block; width: 100%; height: 240px; border: 0 !important; outline: 0; background: transparent; overflow: hidden; }
.artifact-pending { margin: 12px 0; padding: 14px 16px; border-radius: 12px; font-size: 14px; color: var(--ink-3, #6B6762); background: linear-gradient(90deg, var(--accent-soft, #F6E7DF), var(--blue-soft, #E4EEF7), var(--accent-soft, #F6E7DF)); background-size: 200% 100%; animation: ss-shimmer 2.4s linear infinite; }
@keyframes ss-shimmer { to { background-position: 200% 0; } }
.katex-display { overflow-x: auto; overflow-y: hidden; padding: 4px 0; }
.katex { font-size: 1.06em; }
