/* LePercoMail : design handoff v2 (papier/crème/encre, Archivo + Bricolage + Plex Mono) */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: #edeae1;
  color: #1b1815;
  font-family: Archivo, "Helvetica Neue", Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: #1b1815; text-decoration: none; border-bottom: 1px solid rgba(27, 24, 21, 0.3); }
a:hover { color: #7a4b28; border-bottom-color: #7a4b28; }
textarea { font-family: inherit; }
textarea::placeholder { color: #a29a8c; }
button { font-family: inherit; }
button:focus { outline: none; }

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 clamp(16px, 4vw, 32px) 56px;
}

/* ─── En-tête ─── */
.site-header {
  width: 100%;
  max-width: 1180px;
  min-height: 68px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid rgba(27, 24, 21, 0.14);
}
.brand { display: flex; align-items: center; gap: 10px; }
.logotype {
  font-family: 'Bricolage Grotesque', Archivo, sans-serif;
  font-size: 19px;
  font-weight: 800;
  letter-spacing: -0.035em;
  color: #1b1815;
}
.header-meta {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #7c7365;
}
.meta-mobile { display: none; }

.main { width: 100%; max-width: 1180px; }

/* ─── Fonction : Réécrire / Répondre ─── */
.kinds {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
  padding-top: clamp(28px, 5vw, 56px);
}
.kind {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  padding: 14px 18px;
  border-radius: 16px;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
  background: #f7f5ef;
  color: #1b1815;
  border: 1px solid rgba(27, 24, 21, 0.16);
}
.kind.selected {
  background: #1b1815;
  color: #f2efe7;
  border-color: #1b1815;
}
.kind-name { font-size: 16px; font-weight: 600; letter-spacing: -0.02em; }
.kind-desc { font-size: 13px; line-height: 1.4; opacity: 0.72; }

/* ─── Réglage ─── */
.tones-section {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 24px 0;
}
.tones-labels {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
}
.label-left {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #7c7365;
}
.label-right {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: #a29a8c;
}

.tones {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}
.tone {
  text-align: left;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  padding: 16px 18px 18px;
  border-radius: 16px;
  transition: background 0.18s, border-color 0.18s, color 0.18s;
  background: #f7f5ef;
  color: #1b1815;
  border: 1px solid rgba(27, 24, 21, 0.16);
}
.tone.selected {
  background: #1b1815;
  color: #f2efe7;
  border-color: #1b1815;
}
.tone-top { display: flex; align-items: center; justify-content: space-between; }
.tone-num {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  opacity: 0.55;
}
.tone-name {
  margin-top: clamp(16px, 3vw, 26px);
  font-size: clamp(19px, 2.4vw, 22px);
  font-weight: 600;
  letter-spacing: -0.025em;
}
.tone-desc { margin-top: 6px; font-size: 14px; line-height: 1.45; opacity: 0.72; }
.tone-gauge {
  margin-top: 20px;
  height: 4px;
  border-radius: 999px;
  background: rgba(27, 24, 21, 0.1);
}
.tone.selected .tone-gauge { background: rgba(242, 239, 231, 0.22); }
.tone-gauge-fill { height: 4px; border-radius: 999px; background: rgba(27, 24, 21, 0.32); }
.tone.selected .tone-gauge-fill { background: #e08b46; }
.tone-active-desc { display: none; }

/* ─── Zone de travail ─── */
.workbench {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  align-items: start;
}

.panel { border-radius: 18px; overflow: hidden; display: flex; flex-direction: column; }
.panel-draft { background: #f7f5ef; border: 1px solid rgba(27, 24, 21, 0.16); }
.panel-result { background: #1b1815; color: #f2efe7; min-height: 320px; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
}
.panel-draft .panel-head { border-bottom: 1px solid rgba(27, 24, 21, 0.12); }
.panel-result .panel-head { border-bottom: 1px solid rgba(242, 239, 231, 0.16); }
.panel-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.title-hint { font-weight: 400; color: #7c7365; }
.char-count { font-family: 'IBM Plex Mono', monospace; font-size: 11px; color: #a29a8c; }

.head-tools { display: flex; align-items: center; gap: 12px; }
.address-toggle {
  display: flex;
  border: 1px solid rgba(27, 24, 21, 0.16);
  border-radius: 999px;
  overflow: hidden;
}
.addr {
  border: none;
  background: transparent;
  padding: 4px 10px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7c7365;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
}
.addr.selected { background: #1b1815; color: #f2efe7; }

#rage-input {
  width: 100%;
  border: none;
  resize: vertical;
  outline: none;
  background: transparent;
  padding: clamp(16px, 3vw, 20px);
  font-size: 16px;
  line-height: 1.62;
  color: #1b1815;
}

.received-wrap { border-bottom: 1px solid rgba(27, 24, 21, 0.12); }
.received-head {
  padding: 12px 20px 0;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #7c7365;
}
#received-input {
  width: 100%;
  border: none;
  resize: vertical;
  outline: none;
  background: transparent;
  padding: 10px clamp(16px, 3vw, 20px) 14px;
  font-size: 15px;
  line-height: 1.55;
  color: #1b1815;
  min-height: 96px;
}

.panel-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  padding: 14px clamp(16px, 3vw, 20px);
  border-top: 1px solid rgba(27, 24, 21, 0.12);
}
.draft-help { font-size: 13px; color: #7c7365; max-width: 26ch; }

.send-btn {
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  transition: transform 0.15s, background 0.18s;
  cursor: pointer;
  background: #7a4b28;
  color: #f7f5ef;
}
.send-btn:hover:not(:disabled) { transform: translateY(-1px); }
.send-btn:disabled {
  background: rgba(27, 24, 21, 0.12);
  color: #a29a8c;
  cursor: default;
}

.result-body {
  padding: 20px;
  font-size: 15.5px;
  line-height: 1.68;
  white-space: pre-wrap;
  flex: 1;
  min-height: 260px;
  color: #f2efe7;
}
.result-body.empty { color: rgba(242, 239, 231, 0.5); }
.panel-tip {
  padding: 14px 20px;
  border-top: 1px solid rgba(242, 239, 231, 0.16);
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: #a8a094;
}

.copy-btn {
  border: 1px solid rgba(242, 239, 231, 0.28);
  background: transparent;
  border-radius: 999px;
  padding: 6px 14px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f2efe7;
  cursor: pointer;
}
.copy-btn:disabled { color: rgba(242, 239, 231, 0.4); cursor: default; }

/* ─── Pied ─── */
.site-footer {
  margin-top: 40px;
  padding-top: 20px;
  border-top: 1px solid rgba(27, 24, 21, 0.14);
  display: flex;
  flex-wrap: wrap;
  gap: 10px 28px;
  justify-content: center;
  align-items: center;
  font-size: 13px;
  color: #7c7365;
}
.footer-brand { color: #1b1815; font-weight: 600; }
.global-count {
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #7c7365;
}

.mobile-cta { display: none; }

/* ─── Gabarit mobile (≤ 430px) ─── */
@media (max-width: 430px) {
  .page { padding: 0 18px 108px; }

  .site-header {
    position: sticky;
    top: 0;
    z-index: 5;
    background: #edeae1;
    min-height: 0;
    padding: 14px 0;
  }
  .brand { gap: 9px; }
  .brand svg { width: 24px; height: 24px; }
  .logotype { font-size: 18px; }
  .header-meta { font-size: 10px; }
  .meta-desktop { display: none; }
  .meta-mobile { display: inline; }

  .kinds { padding-top: 18px; gap: 8px; }
  .kind { padding: 12px 14px; border-radius: 14px; }
  .kind-name { font-size: 14px; }
  .kind-desc { font-size: 12px; }
  .tones-section { padding: 14px 0 0; gap: 10px; }
  .label-left { font-size: 10px; }
  .label-right { display: none; }

  .tones { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .tone {
    height: 88px;
    padding: 0;
    border-radius: 14px;
    align-items: center;
    justify-content: center;
    gap: 6px;
  }
  .tone-top { display: contents; }
  .tone-num, .tone-desc, .tone-gauge { display: none; }
  .tone-cup { width: 26px; height: 26px; stroke-width: 1.5; }
  .tone-name { margin-top: 0; font-size: 14px; font-weight: 600; letter-spacing: -0.02em; }
  .tone-active-desc {
    display: block;
    font-size: 13px;
    line-height: 1.45;
    color: #4b453d;
    min-height: 38px;
  }

  .workbench { grid-template-columns: 1fr; gap: 18px; margin-top: 18px; }
  .panel { border-radius: 16px; }
  .panel-head { padding: 12px 16px; flex-wrap: wrap; gap: 6px; }
  .panel-title { font-size: 13px; }
  .char-count { font-size: 10px; }
  .head-tools { gap: 8px; }
  .addr { padding: 3px 8px; font-size: 9px; }
  #rage-input { padding: 16px; font-size: 16px; line-height: 1.6; resize: none; }
  .panel-foot { border-top: none; padding: 0 16px 14px; }
  .draft-help { font-size: 12.5px; max-width: none; }
  .panel-foot .send-btn { display: none; }

  .panel-result { min-height: 0; }
  .result-body { padding: 16px; font-size: 15px; line-height: 1.65; min-height: 170px; }
  .panel-tip { padding: 12px 16px; font-size: 10px; }

  .site-footer {
    flex-direction: column;
    gap: 4px;
    justify-content: center;
    text-align: center;
    font-size: 12.5px;
    line-height: 1.5;
    border-top: none;
    padding-top: 0;
    margin-top: 0;
  }

  .mobile-cta {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 5;
    padding: 14px 18px 22px;
    background: linear-gradient(to top, #edeae1 62%, rgba(237, 234, 225, 0));
  }
  .mobile-cta .send-btn { width: 100%; min-height: 52px; font-size: 16px; }
}
