/* ==========================================================================
   Plume Instagram — feuille de style
   Univers visuel : fond blanc, gris clair, bleu canard, style Apple sobre.
   (Reproduit d'après le cahier des charges ; à comparer avec Plume réel.)
   Priorité iPhone : champs ≥ 16 px (pas de zoom automatique), boutons ≥ 48 px,
   aucune barre fixe (clavier virtuel), aucun défilement horizontal.
   ========================================================================== */
:root {
  --bg: #ffffff;
  --surface: #f2f4f6;
  --surface-2: #e8ecef;
  --line: #d9dee3;
  --text: #1c1c1e;
  --muted: #5b6670;
  --accent: #0b7a8a; /* bleu canard */
  --accent-press: #096572;
  --accent-soft: #e3f1f3;
  --danger: #b3261e;
  --danger-soft: #fbeae8;
  --warn: #7a4d00;
  --warn-soft: #fff3dc;
  --radius: 12px;
  --radius-lg: 16px;
  --space: 16px;
  --font: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue', system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 17px;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.wrap {
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space);
}

/* ---- En-tête ---------------------------------------------------------- */
.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 20px;
}
h1 {
  margin: 4px 0 0;
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
  letter-spacing: -0.01em;
}
h2 {
  margin: 0 0 8px;
  font-size: 21px;
  line-height: 1.25;
  font-weight: 700;
}
h3 {
  margin: 0;
  font-size: 17px;
  font-weight: 650;
}
p {
  margin: 0 0 12px;
}
.lead {
  color: var(--muted);
}
.hint {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--muted);
}
.hint.error {
  color: var(--danger);
  font-weight: 600;
}
[hidden] {
  display: none !important;
}

/* ---- Champs ------------------------------------------------------------ */
.field {
  margin-bottom: 20px;
}
label,
legend {
  display: block;
  margin-bottom: 8px;
  font-size: 16px;
  font-weight: 600;
  padding: 0;
}
.opt {
  font-weight: 400;
  color: var(--muted);
}
textarea,
input[type='password'],
input[type='text'] {
  display: block;
  width: 100%;
  max-width: 100%;
  font: inherit;
  font-size: 17px; /* ≥ 16 px : évite le zoom automatique d'iOS */
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  padding: 14px;
  min-height: 48px;
  -webkit-appearance: none;
  appearance: none;
  resize: vertical;
}
textarea {
  line-height: 1.45;
  overflow-wrap: anywhere;
}
textarea::placeholder,
input::placeholder {
  color: #8a949d;
}
textarea:focus,
input:focus {
  outline: none;
  background: var(--bg);
  border-color: var(--accent);
}
#devis {
  min-height: 240px;
}
#precision {
  min-height: 92px;
}
fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 20px;
  min-width: 0;
}

/* ---- Choix du format (deux segments) ----------------------------------- */
.segments {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  background: var(--surface);
  border-radius: var(--radius);
}
.segments input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.segments label {
  margin: 0;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 8px 10px;
  border-radius: 9px;
  font-size: 16px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.segments input:checked + label {
  background: var(--bg);
  color: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.segments input:focus-visible + label {
  outline: 3px solid var(--accent);
  outline-offset: 1px;
}

/* ---- Boutons ----------------------------------------------------------- */
button {
  font: inherit;
  font-size: 17px;
  font-weight: 600;
  min-height: 48px;
  padding: 0 18px;
  border-radius: var(--radius);
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
button:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}
.btn-primary {
  background: var(--accent);
  color: #fff;
}
.btn-primary:active {
  background: var(--accent-press);
}
.btn-secondary {
  background: var(--accent-soft);
  color: var(--accent);
}
.btn-quiet {
  background: transparent;
  color: var(--accent);
  padding: 0 10px;
}
.btn-danger {
  background: var(--danger-soft);
  color: var(--danger);
}
button[disabled] {
  opacity: 0.55;
  cursor: default;
}
.btn-block {
  width: 100%;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.actions > button {
  flex: 1 1 140px;
}
.stack > * + * {
  margin-top: 12px;
}

/* ---- Messages ---------------------------------------------------------- */
.msg {
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 16px;
  background: var(--surface);
}
.msg:empty {
  display: none;
}
.msg.error {
  background: var(--danger-soft);
  color: var(--danger);
}
.msg.warn {
  background: var(--warn-soft);
  color: var(--warn);
}
.msg.ok {
  background: var(--accent-soft);
  color: var(--accent-press);
}
.msg .actions {
  margin-top: 10px;
}
.msg button {
  min-height: 44px;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 16px;
}
.panel h3 {
  margin-bottom: 6px;
}
.panel ul {
  margin: 6px 0 0;
  padding-left: 20px;
}
.panel li + li {
  margin-top: 4px;
}
.panel.warn {
  background: var(--warn-soft);
  color: var(--warn);
}

/* ---- Chargement -------------------------------------------------------- */
.loading {
  text-align: center;
  padding: 48px 8px;
}
.spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto 18px;
  border: 4px solid var(--surface-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation: none;
    border-top-color: var(--accent);
    border-right-color: var(--accent);
  }
}

/* ---- Résultats --------------------------------------------------------- */
.results-head {
  margin-bottom: 16px;
}
.card {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 14px;
  margin-bottom: 16px;
  background: var(--bg);
}
.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.chip {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  background: var(--surface);
  color: var(--muted);
}
.chip.regles-ok {
  background: var(--accent-soft);
  color: var(--accent-press);
}
.chip.a-verifier {
  background: var(--warn-soft);
  color: var(--warn);
}
.chip.non-conforme {
  background: var(--danger-soft);
  color: var(--danger);
}
.post {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  min-height: 48px;
}
.card textarea {
  min-height: 220px;
  margin-bottom: 10px;
}
.issues {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  font-size: 14.5px;
}
.issues li {
  padding: 6px 10px;
  border-left: 3px solid var(--line);
  margin-bottom: 4px;
}
.issues li.error {
  border-left-color: var(--danger);
  color: var(--danger);
}
.issues li.warning {
  border-left-color: #c58a1b;
  color: var(--warn);
}
.meta {
  font-size: 13.5px;
  color: var(--muted);
  margin: 0 0 8px;
}
.copy-msg {
  margin: 8px 0 0;
  font-size: 15px;
  min-height: 0;
}
.copy-msg:empty {
  display: none;
}
.copy-msg.ok {
  color: var(--accent-press);
}
.copy-msg.error {
  color: var(--danger);
}
.note {
  font-size: 14.5px;
  color: var(--muted);
  margin: 0 0 16px;
}

/* ---- Mode secours ------------------------------------------------------ */
.promptbox {
  min-height: 200px;
  font-size: 16px; /* jamais < 16 px : sinon iOS zoome à la saisie */
}
ol.steps {
  padding-left: 22px;
  margin: 0 0 16px;
}
ol.steps li + li {
  margin-top: 6px;
}

/* ---- Réglages ---------------------------------------------------------- */
dialog {
  width: min(92vw, 520px);
  max-height: 88vh;
  overflow: auto;
  border: 0;
  border-radius: var(--radius-lg);
  padding: 18px;
  color: var(--text);
  background: var(--bg);
}
dialog::backdrop {
  background: rgba(0, 0, 0, 0.4);
}
.check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin: 0 0 16px;
  font-weight: 400;
}
.check input {
  width: 24px;
  height: 24px;
  margin: 2px 0 0;
  accent-color: var(--accent);
  flex: none;
}

a {
  color: var(--accent);
}
.mt {
  margin-top: 20px;
}
details.more {
  margin: 8px 0 0;
}
details.more summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
}

/* ---- Banc d'essai ------------------------------------------------------ */
.run {
  border: 1.5px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin-bottom: 12px;
}
.run h3 {
  margin-bottom: 4px;
}
.table-wrap {
  max-width: 100%;
  overflow-x: auto;
}
table {
  border-collapse: collapse;
  width: 100%;
  font-size: 14.5px;
}
th,
td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.model-list label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 400;
  font-size: 15px;
  overflow-wrap: anywhere;
}
.model-list input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
  flex: none;
  margin-top: 2px;
}

@media (min-width: 720px) {
  h1 {
    font-size: 28px;
  }
  #devis {
    min-height: 300px;
  }
  .wrap {
    padding: 28px 24px 48px;
  }
}
