/* Tuteur et espace parent. Les couleurs viennent de palette.css (rôles --c-*), les bases de style.css.
   Une page blanche ; le rose accueille, l'azur explique, le miel souligne, la terre cuite agit. */

/* --- Mise en page du chat */

.t-app {
  display: grid;
  grid-template-columns: 256px minmax(0, 1fr);
  height: 100dvh;
  background: var(--c-page);
}

.t-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px 16px;
  background: var(--c-surface-subtle);
  border-right: 1px solid var(--c-line);
  overflow-y: auto;
}

.t-side-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.t-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}

.t-brand h1,
.t-brand .t-brand-name {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* La marque : un carré terre cuite et son initiale. */
.t-mark {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--c-action);
  color: var(--c-on-action);
  font-size: 17px;
  font-weight: 600;
  line-height: 1;
}

/* « Fermer » n'existe que dans le panneau du petit écran (plus précis que .t-bar-btn, défini plus bas). */
.t-side .t-side-close {
  display: none;
}

.t-new {
  width: 100%;
  min-height: 44px;
}

.t-section-title {
  padding: 0 4px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.t-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.t-convs {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.t-conv {
  min-height: 40px;
  padding: 8px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--c-ink);
  font-size: 15px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.t-conv:hover:not(:disabled) {
  background: var(--c-welcome-bg);
}

.t-conv[aria-current="true"] {
  background: var(--c-welcome-bg);
  box-shadow: inset 3px 0 0 var(--c-action);
  color: var(--c-action);
  font-weight: 600;
}

.t-muted-small {
  padding: 0 4px;
  font-size: 13px;
  color: var(--c-muted);
}

/* « Ce que je travaille » : le nom, l'accompagnement en mots, ses réussites sans aide. Aucune note. */
.t-work {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.t-work-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 0 4px;
  font-size: 13px;
}

.t-work-item .t-work-name {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 15px;
  color: var(--c-ink);
}

.t-work-item .t-work-subject,
.t-work-mode,
.t-work-start {
  color: var(--c-muted);
}

.t-work-item .t-work-subject {
  flex: none;
  font-size: 13px;
}

.t-work-success {
  color: var(--c-success);
  font-weight: 500;
}

/* --- Quota d'IA : sa jauge (sans montant) et celle du parent */

.t-quota {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 0 4px;
  font-size: 13px;
}

.t-quota .row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.t-quota .sub,
.t-quota-note {
  color: var(--c-muted);
}

.t-quota-bar {
  height: 6px;
  border-radius: 3px;
  background: var(--c-line);
  overflow: hidden;
}

/* Une jauge qui se remplit en bleu : un repère, pas une récompense ni une alarme. */
.t-quota-fill {
  height: 100%;
  background: var(--c-info);
}

.t-quota.bientot .t-quota-fill,
.t-quota.atteint .t-quota-fill {
  background: var(--c-emphasis-ink);
}

.banner.quota {
  background: var(--c-note-bg);
  color: var(--c-emphasis-ink);
}

.t-budget {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
}

.t-budget label {
  font-weight: 600;
}

.t-budget input {
  width: 7em;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--c-control-border);
  border-radius: 10px;
  background: var(--c-surface);
  color: var(--c-ink);
}

.t-side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  padding-top: 12px;
  border-top: 1px solid var(--c-line);
}

.t-side-foot a,
.t-side-foot button {
  display: flex;
  align-items: center;
  min-height: 40px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--c-action);
  font-size: 14px;
  text-align: left;
  text-decoration: none;
}

.t-side-foot a:hover,
.t-side-foot button:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Barre du haut sur petit écran : Menu, Sevrage, Nouvelle conversation. Masquée sur ordinateur. */
.t-mobilebar {
  display: none;
}

.t-bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--c-action);
  font-size: 15px;
  font-weight: 500;
}

.t-bar-btn:hover:not(:disabled) {
  background: var(--c-welcome-bg);
}

.t-backdrop {
  display: none;
}

.t-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100dvh;
}

.t-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 10px clamp(16px, 4vw, 32px);
  border-bottom: 1px solid var(--c-line);
}

.t-head h2 {
  font-size: 17px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.t-mode {
  flex: none;
  font-size: 13px;
  color: var(--c-muted);
}

.t-mode.demo {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--c-note-bg);
  color: var(--c-emphasis-ink);
  font-weight: 600;
}

.t-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 24px clamp(16px, 4vw, 32px);
}

.t-thread-inner {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
}

/* --- Messages */

.t-msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.t-msg.user {
  align-items: flex-end;
}

.t-bubble {
  max-width: min(680px, 100%);
  padding: 14px 18px;
  border-radius: 18px;
  font-size: 17px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.t-msg.user .t-bubble {
  max-width: min(560px, 88%);
  background: var(--c-welcome-bg);
  color: var(--c-ink);
  border-bottom-right-radius: 6px;
  white-space: pre-wrap;
}

.t-msg.assistant .t-bubble {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-bottom-left-radius: 6px;
}

/* Exemples et reprises guidées : tout le message sur azur. */
.t-msg.assistant.explain .t-bubble {
  background: var(--c-explanation-bg);
  border-color: var(--c-explanation-line);
  color: var(--c-explanation-ink);
}

.t-bubble > * + * {
  margin-top: 10px;
}

.t-bubble ul,
.t-bubble ol {
  padding-left: 22px;
  list-style: revert;
}

.t-bubble li + li {
  margin-top: 4px;
}

.t-bubble code {
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--c-surface-subtle);
  font: 0.9em ui-monospace, SFMono-Regular, Menlo, monospace;
}

.t-bubble pre {
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--c-surface-subtle);
  overflow-x: auto;
}

.t-bubble pre code {
  padding: 0;
  background: none;
}

/* Une seule indication par réponse, et la compétence. */
.t-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.t-label {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--c-surface-subtle);
  color: var(--c-muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.4;
}

.t-label.reprise {
  background: var(--c-note-bg);
  color: var(--c-emphasis-ink);
}

.t-label.progress {
  background: var(--c-success-bg);
  color: var(--c-success);
}

.t-label.skill {
  font-weight: 500;
}

/* --- Dessins du tuteur (public/visuels.js), sur fond blanc même dans un message azur */

.v-figure {
  --v0: var(--c-figure-1);
  --v1: var(--c-figure-3);
  --v2: var(--c-figure-2);
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
}

.t-msg.explain .v-figure {
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--c-surface);
  color: var(--c-ink);
}

.v-svg {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
}

/* Un liseré couleur de fond garde le texte lisible quand une ligne passe dessous. */
.v-svg text {
  fill: var(--c-ink);
  font-family: var(--font);
  paint-order: stroke;
  stroke: var(--c-surface);
  stroke-width: 3px;
  stroke-linejoin: round;
}

.v-svg .v-muted {
  fill: var(--c-muted);
}

.v-svg .v-col {
  fill: currentColor;
}

.v-svg .v-on {
  fill: var(--c-surface);
  stroke: none;
}

.v-svg .v-now-text {
  fill: var(--c-figure-1);
}

.v-c0 {
  color: var(--v0);
}

.v-c1 {
  color: var(--v1);
}

.v-c2 {
  color: var(--v2);
}

.v-axis {
  stroke: var(--c-muted);
}

.v-axis-head,
.v-dot,
.v-frame {
  fill: var(--c-muted);
}

.v-grid {
  stroke: var(--c-line);
}

.v-part {
  stroke: var(--c-muted);
}

.v-outline,
.v-measure {
  stroke: var(--c-ink);
  stroke-width: 2;
}

.v-dash {
  stroke: var(--c-muted);
  stroke-width: 1.5;
  stroke-dasharray: 5 4;
}

.v-guide {
  stroke: currentColor;
  stroke-opacity: 0.45;
  stroke-dasharray: 3 3;
}

.v-now {
  stroke: var(--c-figure-1);
  stroke-width: 2;
  stroke-dasharray: 6 4;
}

.v-figure figcaption {
  font-size: 14px;
  color: var(--c-muted);
}

.v-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 8px;
  max-width: 480px;
}

.v-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  border: 1px solid var(--c-line);
  border-radius: 12px;
  background: var(--c-surface);
  color: var(--c-ink);
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
}

.v-emoji {
  font-size: 34px;
  line-height: 1.15;
}

.v-note {
  font-size: 14px;
  font-style: italic;
  color: var(--c-muted);
}

.t-typing {
  display: inline-flex;
  gap: 4px;
  padding: 6px 0;
}

.t-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  animation: t-blink 1.2s infinite ease-in-out;
}

.t-typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.t-typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes t-blink {
  50% {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  .t-typing span {
    animation: none;
    opacity: 0.7;
  }
}

/* --- Accueil d'une conversation vide : une zone rose, trois intentions */

.t-welcome {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 4vh;
  padding: clamp(20px, 4vw, 32px);
  border-radius: 20px;
  background: var(--c-welcome-bg);
}

.t-welcome h3 {
  font-size: clamp(24px, 3vw, 30px);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.t-welcome p {
  color: var(--c-body);
  max-width: 56ch;
}

.t-intents {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.t-intents .btn {
  min-height: 44px;
  border-color: var(--c-welcome-line);
}

.t-welcome .t-ai-note {
  font-size: 14px;
  color: var(--c-muted);
}

details.hint summary {
  cursor: pointer;
}

details.hint[open] summary {
  margin-bottom: 6px;
}

details.hint p + p {
  margin-top: 6px;
}

.t-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--c-action);
  font: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* --- Zone de saisie : Envoyer, puis la reprise en miel, l'indice, et les autres aides repliées */

.t-composer-wrap {
  padding: 12px clamp(16px, 4vw, 32px) 16px;
  border-top: 1px solid var(--c-line);
  background: var(--c-page);
}

.t-composer {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 760px;
  margin: 0 auto;
}

.t-input {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 8px 8px 8px 16px;
  border: 1px solid var(--c-control-border);
  border-radius: 16px;
  background: var(--c-surface);
}

.t-input:focus-within {
  outline: 2px solid var(--c-focus);
  outline-offset: 1px;
}

.t-input textarea {
  flex: 1;
  max-height: 200px;
  padding: 8px 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 17px;
  line-height: 1.5;
  resize: none;
}

.t-input .btn {
  min-height: 44px;
  padding: 10px 18px;
}

.t-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.btn.emphasis {
  background: var(--c-emphasis-bg);
  border-color: var(--c-emphasis-bg);
  color: var(--c-emphasis-ink);
}

.btn.emphasis:hover:not(:disabled) {
  background: var(--c-emphasis-hover);
  border-color: var(--c-emphasis-hover);
}

.t-actions .btn {
  min-height: 44px;
}

.t-more-toggle {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: none;
  color: var(--c-action);
  font-weight: 600;
}

.t-more-toggle:hover:not(:disabled) {
  background: var(--c-welcome-bg);
}

.t-more-toggle:disabled,
.t-bar-btn:disabled,
.t-intents .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.t-actions .spacer {
  flex: 1;
}

.t-hint {
  font-size: 13px;
  color: var(--c-muted);
}

.t-more {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--c-line);
  border-radius: 14px;
  background: var(--c-surface-subtle);
}

.t-more .btn {
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-height: 52px;
  text-align: left;
}

.t-btn-sub {
  font-size: 12px;
  font-weight: 400;
  color: var(--c-muted);
}

.btn:disabled .t-btn-sub {
  color: inherit;
}

/* --- Guide */

.t-dialog {
  max-width: 560px;
  padding: 24px;
  border: 1px solid var(--c-line);
  border-radius: 20px;
  background: var(--c-surface);
  color: var(--c-ink);
  box-shadow: var(--shadow);
}

.t-dialog::backdrop {
  background: var(--c-backdrop);
}

.t-dialog h2 {
  margin-bottom: 12px;
  font-size: 22px;
  font-weight: 600;
  line-height: 1.2;
}

.t-guide {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 18px;
  padding-left: 20px;
  list-style: disc;
}

/* --- Configuration et espace parent */

.t-page {
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 40px clamp(16px, 4vw, 32px) 80px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* La page du code d'accès (en ligne) : un seul champ, une colonne étroite. */
.t-page.t-access {
  max-width: 480px;
}

.t-page h1 {
  font-size: clamp(26px, 4vw, 32px);
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.01em;
}

.t-card {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: clamp(16px, 3vw, 24px);
  border: 1px solid var(--c-line);
  border-radius: 18px;
  background: var(--c-surface);
}

.t-card h2 {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.2;
}

.t-card .stat {
  border-color: var(--c-line);
  border-radius: 14px;
}

.t-card .stat .v {
  font-weight: 600;
}

.t-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
}

.t-checks label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

.t-checks input {
  accent-color: var(--c-action);
}

.field input[type="password"] {
  width: 100%;
  min-height: 44px;
  padding: 12px 14px;
  border: 1px solid var(--c-control-border);
  border-radius: 12px;
  background: var(--c-surface);
  letter-spacing: 0.2em;
}

.field input[type="password"]:focus {
  outline: 2px solid var(--c-focus);
  outline-offset: 0;
  border-color: transparent;
}

.t-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.t-alert {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--c-note-bg);
  color: var(--c-ink);
}

.t-alert.urgent {
  background: var(--c-danger-bg);
}

.t-alert.seen {
  background: var(--c-surface-subtle);
  color: var(--c-muted);
}

.t-alert .note {
  flex: 1 1 260px;
}

.t-label.watch {
  background: var(--c-note-bg);
  color: var(--c-emphasis-ink);
}

.t-label.urgent {
  background: var(--c-danger);
  color: var(--c-danger-bg);
}

.t-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.t-table th,
.t-table td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--c-line);
  text-align: left;
  vertical-align: top;
}

.t-table th {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--c-muted);
}

.t-table select {
  min-height: 40px;
  padding: 4px 8px;
  border: 1px solid var(--c-control-border);
  border-radius: 10px;
  background: var(--c-surface);
  color: var(--c-ink);
  font: inherit;
}

.t-table-wrap {
  overflow-x: auto;
}

/* --- Petits écrans (et zoom à 200 %) : un menu rend les conversations, ce qu'elle travaille et le quota */

@media (max-width: 820px) {
  .t-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .t-mobilebar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 8px;
    border-bottom: 1px solid var(--c-line);
    background: var(--c-page);
  }

  .t-mobilebar .t-brand-name {
    font-size: 17px;
    font-weight: 600;
  }

  .t-side {
    display: none;
  }

  .t-app.menu-open .t-side {
    display: flex;
    position: fixed;
    z-index: 30;
    inset: 0 auto 0 0;
    width: min(340px, 88vw);
    box-shadow: var(--shadow);
  }

  .t-app.menu-open .t-backdrop {
    display: block;
    position: fixed;
    z-index: 20;
    inset: 0;
    background: var(--c-backdrop);
  }

  .t-side .t-side-close {
    display: inline-flex;
  }

  .t-main {
    height: auto;
  }

  .t-head {
    min-height: 0;
    padding: 8px 16px;
  }

  .t-head h2 {
    font-size: 15px;
  }

  .t-thread {
    padding: 16px;
  }

  .t-composer-wrap {
    padding: 10px 16px 12px;
  }

  /* La reprise prend toute la ligne : c'est l'aide qu'on veut voir en premier. */
  .t-actions .btn.emphasis {
    flex: 1 1 100%;
  }

  .t-hint {
    display: none;
  }

  .t-bubble {
    font-size: 16px;
  }
}

@media (max-width: 640px) {
  /* Espace parent : une compétence par bloc, avec les intitulés, plutôt que six colonnes minuscules. */
  .t-table.t-skills thead {
    display: none;
  }

  .t-table.t-skills,
  .t-table.t-skills tbody {
    display: block;
    width: 100%;
  }

  .t-table.t-skills td > * {
    min-width: 0;
    max-width: 65%;
  }

  .t-table.t-skills tr {
    display: block;
    padding: 6px 0;
    border-bottom: 1px solid var(--c-line);
  }

  .t-table.t-skills td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 6px 0;
    border: 0;
    text-align: right;
    overflow-wrap: anywhere;
  }

  .t-table.t-skills td::before {
    content: attr(data-label);
    flex: none;
    font-size: 12px;
    font-weight: 600;
    color: var(--c-muted);
    text-align: left;
  }
}

/* Liens habillés en boutons (« Retour au tuteur », « Configurer ») */
a.btn {
  color: var(--c-ink);
  text-decoration: none;
}

a.btn.primary {
  color: var(--c-on-action);
}
