/* ==========================================================================
   CORNER — components.css — briques réutilisables du design system.
   ========================================================================== */

/* ---------- forms ---------- */
.field-row{ display: flex; flex-direction: column; gap: 7px; margin-bottom: var(--sp-4); }
.field-row:last-child{ margin-bottom: 0; }
label{ font-family: var(--font-label); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
input[type=number], input[type=text], input[type=date], textarea, select{
  background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-sm);
  color: var(--paper); font-family: var(--font-body); font-size: 14.5px; padding: 11px 12px; width: 100%;
  transition: border-color var(--dur-fast) var(--ease);
}
input[type=number]{ font-family: var(--font-mono); }
textarea{ resize: vertical; min-height: 64px; }
input:focus, textarea:focus, select:focus{ border-color: var(--line-strong); outline: none; }

/* ---------- buttons ---------- */
button.action{
  padding: 15px 16px; border-radius: var(--r-pill); border: none;
  font-family: var(--font-body); font-weight: 600; font-size: 14px; letter-spacing: .01em; cursor: pointer;
  background: linear-gradient(135deg, var(--ember-2), var(--ember)); color: #fff; width: 100%;
  box-shadow: var(--glow-accent);
  transition: filter var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
button.action:hover{ filter: brightness(1.06); box-shadow: 0 0 52px -6px rgba(139,92,246,0.7); }
button.action:active{ filter: brightness(.94); transform: scale(.98); }
button.action:disabled{ background: var(--surface-2); color: var(--muted); cursor: default; filter: none; box-shadow: none; }
button.action.ghost{ background: transparent; color: var(--paper-dim); border: 1px solid var(--line-strong); box-shadow: none; }
button.action.sm{ width: auto; padding: 11px 18px; }

button.link{
  background: none; border: none; padding: 4px 0; color: var(--paper-dim);
  font-size: 13.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 5px;
}
button.link:hover{ color: var(--paper); }
button.link.muted{ color: var(--muted); font-weight: 500; }
button.link .ic svg{ width: 14px; height: 14px; }

button.chip{
  padding: 8px 14px; border-radius: var(--r-pill); border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 12.5px; cursor: pointer;
  transition: background var(--dur-fast), color var(--dur-fast), border-color var(--dur-fast);
}
button.chip.on{ background: var(--surface-2); border-color: transparent; color: var(--paper); }
.chip-wrap{ display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: var(--sp-4); }

.mood-row{ display: flex; gap: 6px; }
.mood-btn{ flex: 1; padding: 10px 0; background: var(--surface-2); border: 1px solid transparent; border-radius: var(--r-sm); color: var(--muted); font-family: var(--font-mono); font-size: 13px; cursor: pointer; }
.mood-btn.active{ background: var(--accent); border-color: transparent; color: var(--ink); font-weight: 600; }

.toggle{ width: 42px; height: 25px; border-radius: var(--r-pill); background: var(--surface-2); border: none; cursor: pointer; position: relative; flex-shrink: 0; }
.toggle::after{ content: ""; position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: var(--faint); transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease); }
.toggle.on{ background: var(--ember-dim); }
.toggle.on::after{ transform: translateX(17px); background: var(--ember); }

/* ---------- progress ---------- */
.bar-track{ height: 4px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.bar-fill{ height: 100%; border-radius: 99px; background: linear-gradient(90deg, var(--ember), var(--ember-2)); box-shadow: 0 0 10px -1px rgba(139,92,246,0.6); transition: width var(--dur-slow) var(--ease); }

/* ---------- lists / kv ---------- */
.list{ list-style: none; margin: 0; padding: 0; max-height: 260px; overflow-y: auto; }
.list li{ display: flex; justify-content: space-between; gap: var(--sp-3); font-size: 13.5px; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child{ border-top: none; }
.li-date{ font-family: var(--font-mono); color: var(--muted); white-space: nowrap; }
.li-body{ color: var(--paper-dim); flex: 1; text-align: right; }

.kv-row{ display: flex; justify-content: space-between; padding: 11px 0; border-top: 1px solid var(--line); font-size: 13.5px; gap: var(--sp-4); }
.kv-row:first-child{ border-top: none; }
.kv-k{ color: var(--muted); flex-shrink: 0; }
.kv-v{ color: var(--paper-dim); text-align: right; }

/* ---------- settings rows ---------- */
.settings-row{ display: flex; justify-content: space-between; align-items: center; padding: var(--sp-4) 0; border-top: 1px solid var(--line); gap: var(--sp-4); }
.settings-row:first-child{ border-top: none; }
.settings-label{ font-size: 14px; }
.settings-sub{ font-size: 12px; color: var(--muted); margin-top: 2px; }
.danger-btn{ color: var(--ember); }

/* ---------- coach entry + chat ---------- */
.coach-entry{ display: flex; align-items: center; gap: var(--sp-3); width: 100%; text-align: left; background: var(--surface); border: none; border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); cursor: pointer; color: var(--paper); }
.coach-entry .ic{ color: var(--ember); flex-shrink: 0; }
.coach-entry .ic svg{ width: 19px; height: 19px; }
.coach-entry-body{ flex: 1; }
.coach-entry-title{ font-weight: 600; font-size: 14px; }
.coach-entry-sub{ color: var(--muted); font-size: 12.5px; margin-top: 2px; }

.chat-log{ display: flex; flex-direction: column; gap: var(--sp-4); margin-bottom: var(--sp-5); }
.chat-msg{ max-width: 88%; font-size: 14px; line-height: 1.45; }
.chat-msg.user{ align-self: flex-end; background: var(--surface-2); color: var(--paper); padding: 11px 14px; border-radius: 14px 14px 3px 14px; }
.chat-msg.coach{ align-self: flex-start; }
.chat-msg.coach .chat-from{ font-family: var(--font-label); font-size: 10.5px; letter-spacing: .08em; text-transform: uppercase; color: var(--ember); margin-bottom: 5px; }
.chat-msg.coach .chat-text{ color: var(--paper-dim); }
.chat-actions{ display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chat-input-row{ display: flex; gap: 8px; position: sticky; bottom: calc(96px + var(--safe-b)); }
.chat-input-row textarea{ min-height: 44px; max-height: 120px; }
.chat-send{ background: var(--accent); border: none; border-radius: var(--r-sm); width: 44px; flex-shrink: 0; color: var(--ink); cursor: pointer; display: flex; align-items: center; justify-content: center; }
.chat-send .ic svg{ width: 17px; height: 17px; }
.chat-typing{ display: inline-flex; gap: 3px; align-items: center; }
.chat-typing span{ width: 4px; height: 4px; border-radius: 50%; background: var(--muted); animation: dot-pulse 1s infinite ease-in-out; }
.chat-typing span:nth-child(2){ animation-delay: .15s; }
.chat-typing span:nth-child(3){ animation-delay: .3s; }
@keyframes dot-pulse{ 0%,80%,100%{ opacity: .25; } 40%{ opacity: 1; } }

.draft-plan{ background: var(--surface); border-radius: var(--r-lg); padding: var(--sp-4) var(--sp-5); margin-top: 10px; }
.draft-row{ display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--line); font-size: 13px; }
.draft-row:first-child{ border-top: none; }
.draft-k{ color: var(--muted); }
.draft-v{ color: var(--paper-dim); text-align: right; }
.draft-steps{ margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.draft-step{ font-size: 13px; color: var(--paper-dim); padding: 4px 0; display: flex; gap: 8px; }
.draft-step b{ font-family: var(--font-mono); color: var(--muted); font-weight: 400; flex-shrink: 0; }

/* ---------- milestone / action lists ---------- */
.milestone-list, .action-list{ list-style: none; margin: 0; padding: 0; }
.milestone-item, .action-item{ display: flex; align-items: flex-start; gap: var(--sp-3); padding: 12px 0; border-top: 1px solid var(--line); cursor: pointer; min-height: 44px; }
.milestone-list li:first-child, .action-list li:first-child{ border-top: none; }
.step-dot{ width: 17px; height: 17px; border-radius: 50%; border: 1.5px solid var(--line-strong); flex-shrink: 0; margin-top: 1px; display: flex; align-items: center; justify-content: center; color: transparent; }
.milestone-item.done .step-dot, .action-item.done .step-dot{ background: var(--sage); border-color: var(--sage); color: var(--ink); }
.milestone-item.done .step-label, .action-item.done .step-label{ color: var(--faint); text-decoration: line-through; text-decoration-color: var(--line); }
.action-item.habit-off{ opacity: .6; } /* habitude à cadence personnalisée, pas prévue aujourd'hui */
.step-label{ font-size: 14px; flex: 1; }
.step-date{ font-family: var(--font-mono); font-size: 11px; color: var(--muted); flex-shrink: 0; }

/* ---------- tabbar ---------- */
.tabbar{
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: space-around; align-items: center;
  background: rgba(8,8,18,0.78); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--line);
  padding: 9px 4px calc(8px + var(--safe-b));
  max-width: 520px; margin: 0 auto; z-index: 20;
}
.tab{
  background: none; border: none; color: var(--faint); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 5px;
  font-family: var(--font-label); font-size: 9.5px; letter-spacing: .04em; padding: 5px 8px; flex: 1;
  min-height: 44px; transition: color var(--dur-fast) var(--ease);
}
.tab .tab-ic svg{ width: 19px; height: 19px; }
.tab.active{ color: var(--paper); }
.tab.active .tab-ic{ color: var(--accent); filter: drop-shadow(0 0 6px rgba(139,92,246,0.7)); }
.tab-dot{ width: 3px; height: 3px; border-radius: 50%; background: transparent; margin-top: 1px; }
.tab.active .tab-dot{ background: var(--accent); }

/* bouton central "+" — création rapide, jamais un onglet de destination */
.tab-plus{
  background: linear-gradient(135deg, var(--ember-2), var(--ember)); border: none; border-radius: 50%;
  width: 46px; height: 46px; flex: 0 0 46px; margin: -20px 6px 0; box-shadow: var(--glow-accent);
  display: flex; align-items: center; justify-content: center; color: #fff; cursor: pointer;
  transition: transform var(--dur-fast) var(--ease), filter var(--dur-fast) var(--ease);
}
.tab-plus:hover{ filter: brightness(1.08); }
.tab-plus:active{ transform: scale(.94); }
.tab-plus svg{ width: 20px; height: 20px; }

/* ---------- toast ---------- */
.toast{
  position: fixed; left: var(--sp-6); right: var(--sp-6); bottom: calc(96px + var(--safe-b));
  max-width: 472px; margin: 0 auto;
  background: var(--surface-2); border-radius: var(--r-lg);
  padding: var(--sp-5) var(--sp-5); text-align: center; z-index: 50;
  animation: toast-in var(--dur-base) var(--ease);
  border: 1px solid var(--line-strong);
}
@keyframes toast-in{ from{ opacity: 0; transform: translateY(8px); } to{ opacity: 1; transform: none; } }
.toast-title{ font-family: var(--font-display); font-size: 20px; color: var(--paper); margin-bottom: 3px; }
.toast-body{ font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.toast-xp{ font-family: var(--font-mono); font-size: 12.5px; color: var(--sage); margin-top: 7px; }
.toast-rhythm{ font-family: var(--font-mono); font-size: 12px; color: var(--muted); margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--line); }
.toast-rhythm.milestone{ color: var(--flame); font-weight: 600; }

/* ---------- Partager ma progression (Phase G) ---------- */
.share-sheet{
  position: fixed; inset: 0; z-index: 80; background: rgba(3,3,8,0.72);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center; padding: var(--sp-5);
  opacity: 0; transition: opacity var(--dur-base) var(--ease);
}
.share-sheet.in{ opacity: 1; }
.share-sheet-inner{
  position: relative; width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: var(--sp-4);
  transform: scale(.96); transition: transform var(--dur-base) var(--ease);
}
.share-sheet.in .share-sheet-inner{ transform: scale(1); }
.share-sheet-close{
  position: absolute; top: -14px; right: -14px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface-2); border: 1px solid var(--line-strong); color: var(--paper-dim);
  display: flex; align-items: center; justify-content: center; cursor: pointer; z-index: 1;
}
.share-sheet-preview{ border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--shadow); border: 1px solid var(--line); }
.share-sheet-preview img{ display: block; width: 100%; height: auto; }
.share-sheet-actions{ display: flex; flex-direction: column; gap: 10px; align-items: center; }
.share-sheet-actions .action{ width: 100%; }

/* ---------- Parrainage (Réglages, Phase G) ---------- */
.referral-link-box{
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 11px 12px; font-family: var(--font-mono); font-size: 12.5px; color: var(--paper-dim);
  word-break: break-all; margin-bottom: var(--sp-3);
}
.referral-actions{ display: flex; gap: 10px; }
.referral-actions .action{ flex: 1; }
