/* Styles des fonctionnalités : outil (options, score, diff, export), détecteur, « Votre style », historique. */

/* ---------- Accessibilité commune ---------- */
.tool :is(button, select, textarea, a, input, [tabindex]):focus-visible,
.detector :is(button, textarea, a, mark, [tabindex]):focus-visible,
.feature-page :is(button, a, input, textarea):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}
.tool textarea:focus-visible, .detector textarea:focus-visible { outline-offset: -2px; border-radius: 0; }
.output:focus-visible, .det-text:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- Barre d'options de l'outil ---------- */
.tool-options {
  display: flex; flex-wrap: wrap; align-items: center; gap: .75rem 1.75rem;
  padding: .75rem 1.25rem; border-bottom: 1px solid var(--line); background: #fbf8f1;
}
.opt { display: flex; align-items: center; gap: .6rem; }
.opt[hidden] { display: none; }
.opt-label { font-size: .8rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.opt-link { text-decoration: underline; text-underline-offset: 3px; }

.seg { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 999px; background: var(--card); }
.seg-btn {
  border: 0; background: transparent; border-radius: 999px; padding: .3rem .85rem;
  font: 500 .85rem var(--sans); color: var(--ink-2); cursor: pointer; transition: background .15s, color .15s;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.active { background: var(--accent); color: var(--paper); }

.opt-select {
  font: 500 .88rem var(--sans); color: var(--ink); background: var(--card);
  border: 1px solid var(--line); border-radius: 999px; padding: .35rem 2rem .35rem .85rem;
  appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 15px) 55%, calc(100% - 10px) 55%;
  background-size: 5px 5px; background-repeat: no-repeat;
}
.opt-select:hover { border-color: var(--ink-2); }

/* Interrupteur */
.switch { display: inline-flex; align-items: center; gap: .55rem; cursor: pointer; position: relative; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track {
  width: 36px; height: 20px; border-radius: 999px; background: #d8d1c1; position: relative; flex: none;
  transition: background .2s;
}
.switch-track::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--card); box-shadow: 0 1px 2px rgba(0, 0, 0, .2); transition: transform .2s;
}
.switch input:checked + .switch-track { background: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: .5; }
.switch .opt-label { text-transform: none; letter-spacing: 0; font-size: .9rem; color: var(--ink-2); font-weight: 500; }

/* ---------- Volets ---------- */
.head-actions, .out-actions { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.out-actions { gap: .9rem; }
label.pane-title { cursor: text; }
.tool.is-busy textarea { opacity: .75; }

.score-line {
  display: flex; align-items: center; flex-wrap: wrap; gap: .55rem;
  padding: .65rem 1.25rem; border-top: 1px dashed var(--line); font-size: .9rem;
}
.score-line[hidden] { display: none; }
.score-label { color: var(--ink-2); font-weight: 500; }
.score-chip { font-weight: 600; padding: .12rem .6rem; border-radius: 999px; font-variant-numeric: tabular-nums; }
.score-chip.is-ai { background: #f6e6df; color: var(--danger); }
.score-chip.is-mixed { background: #f7eed9; color: #7a5a1c; }
.score-chip.is-human { background: #e4eee6; color: var(--accent); }
.score-arrow { color: var(--muted); }
.score-help { margin-left: auto; color: var(--muted); }

/* Vue des modifications */
.output.diff-mode { white-space: normal; }
.diff-par { margin: 0 0 1em; white-space: pre-wrap; }
.output ins { text-decoration: none; background: #dcebdf; color: var(--accent); border-radius: 3px; padding: 0 .12em; }
.output del { color: #a0524a; text-decoration: line-through; text-decoration-thickness: 1px; opacity: .75; padding: 0 .1em; }

.tool-note { margin: 0; padding: .7rem 1.25rem; border-top: 1px solid var(--line); display: flex; justify-content: space-between; flex-wrap: wrap; gap: .5rem; }
.tool-note kbd { font: 600 .72rem var(--sans); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 4px; padding: .05rem .35rem; background: var(--card); }
#engine.engine-off { color: var(--danger); }

/* Boutons en chargement (outil, détecteur, formulaires) */
.btn.loading .spinner { display: inline-block; }
#det-go { min-width: 120px; }
.btn-outline .spinner, .btn-ghost .spinner { border-color: rgba(27, 26, 23, .2); border-top-color: var(--ink); }

/* ---------- Détecteur ---------- */
.detector { padding: 0; overflow: hidden; }
.det-grid { display: grid; grid-template-columns: 1.35fr 1fr; }
.det-input { display: flex; flex-direction: column; min-height: 380px; }
.det-result { border-left: 1px solid var(--line); background: #fbf8f1; padding: 1.5rem; display: flex; align-items: center; justify-content: center; }
.det-empty { max-width: 340px; text-align: center; }
.det-empty-title { font-family: var(--serif); font-size: 1.6rem; margin: 0 0 .5rem; }
.det-score { width: 100%; max-width: 360px; text-align: center; }
.det-score[hidden], .det-empty[hidden] { display: none; }
.gauge { height: 10px; border-radius: 999px; background: linear-gradient(90deg, #cfe1d3, #efe1bf 50%, #efcdc2); overflow: hidden; position: relative; }
.gauge-fill { display: block; height: 100%; width: 0; background: var(--ink); opacity: .85; border-radius: inherit; transition: width .6s cubic-bezier(.2, .8, .2, 1); }
.det-number { font-family: var(--serif); font-size: 4.6rem; line-height: 1; margin: 1rem 0 .2rem; font-variant-numeric: tabular-nums; }
.det-unit { font-size: 2rem; margin-left: .1em; color: var(--muted); }
.det-verdict { display: inline-block; font-weight: 600; font-size: .95rem; padding: .25rem .9rem; border-radius: 999px; margin: 0 0 .6rem; }
.lvl-ai .det-verdict { background: #f6e6df; color: var(--danger); }
.lvl-mixed .det-verdict { background: #f7eed9; color: #7a5a1c; }
.lvl-human .det-verdict { background: #e4eee6; color: var(--accent); }
.det-stats { display: grid; grid-template-columns: 1fr auto; gap: .3rem 1rem; margin: 1.25rem 0 0; text-align: left; font-size: .88rem; border-top: 1px solid var(--line); padding-top: 1rem; }
.det-stats dt { color: var(--muted); }
.det-stats dd { margin: 0; font-weight: 500; font-variant-numeric: tabular-nums; }

.det-details { display: grid; grid-template-columns: 1.35fr 1fr; border-top: 1px solid var(--line); }
.det-details[hidden] { display: none; }
.det-text-wrap { padding: 1.25rem; min-width: 0; }
.det-legend { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; margin-bottom: .9rem; }
.legend-swatch { display: inline-block; width: .9em; height: .9em; border-radius: 3px; vertical-align: -.1em; margin-right: .35rem; }
.sw-high { background: #f3d9cf; }
.sw-medium { background: #f6ecd3; }
.sw-mark { background: transparent; border-bottom: 2px solid var(--danger); border-radius: 0; }
.det-text { white-space: pre-wrap; line-height: 1.8; max-height: 520px; overflow-y: auto; font-size: .98rem; }
.det-sent.lvl-high { background: #f8e3db; border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.det-sent.lvl-medium { background: #f8f0dc; border-radius: 3px; box-decoration-break: clone; -webkit-box-decoration-break: clone; }
.det-mark { background: transparent; color: inherit; border-bottom: 2px solid var(--danger); cursor: help; position: relative; }
.det-mark.cat-vocab, .det-mark.cat-triad, .det-mark.cat-dash, .det-mark.cat-emoji { border-bottom-color: var(--gold); }
.det-mark:hover::after, .det-mark:focus::after {
  content: attr(data-tip); position: absolute; left: 0; bottom: calc(100% + 6px); z-index: 5;
  width: max-content; max-width: min(300px, 70vw); white-space: normal;
  background: var(--ink); color: var(--paper); font-size: .8rem; line-height: 1.4; padding: .5rem .65rem; border-radius: 8px;
  box-shadow: var(--shadow); pointer-events: none;
}
.det-signals { border-left: 1px solid var(--line); padding: 1.25rem; background: #fbf8f1; }
.det-h { font-size: 1.4rem; margin-bottom: .75rem; }
.signals { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.signal { display: grid; gap: .15rem; padding: .65rem .8rem; border-radius: 10px; background: var(--card); border: 1px solid var(--line); }
.signal-label { font-weight: 600; font-size: .92rem; }
.signal-detail { font-size: .85rem; color: var(--ink-2); overflow-wrap: anywhere; }
.signal-tag { display: inline-block; font-size: .68rem; letter-spacing: .06em; text-transform: uppercase; padding: .08rem .45rem; border-radius: 999px; margin-right: .3rem; vertical-align: .1em; }
.signal-ai .signal-tag { background: #f6e6df; color: var(--danger); }
.signal-human .signal-tag { background: #e4eee6; color: var(--accent); }
.signal-info .signal-tag { background: var(--paper-2); color: var(--muted); }
.det-cta { margin-top: 1.25rem; }
.det-cta .btn { width: 100%; }

/* ---------- Pages « Votre style » et « Historique » ---------- */
.feature-page .page-title { margin-bottom: .6rem; }
.lead-left { margin: 0 0 2rem; text-align: left; }
.card-title { font-size: 1.6rem; margin-bottom: .4rem; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; }
.upsell { padding: 2.25rem; display: flex; gap: 2rem; align-items: center; justify-content: space-between; background: linear-gradient(135deg, var(--card), #f3efe4); }
.upsell .features { margin-bottom: 0; }

.style-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.style-main { display: grid; gap: 1.5rem; min-width: 0; }
.style-add, .style-list-card, .style-profile { padding: 1.75rem; }
.style-form { margin: 1rem 0 0; }
.style-form textarea {
  font: 1rem/1.65 var(--sans); padding: .8rem .9rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--paper); color: var(--ink); resize: vertical; min-height: 200px;
}
.style-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(31, 59, 45, .12); }
.style-form-foot { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.style-form .btn { margin-top: 0; padding: .62rem 1.25rem; }
.style-add .alert { margin: 1rem 0 0; border: 1px solid #ecd1c6; border-radius: 10px; }
.ok-limit { color: var(--accent); }

.style-list { list-style: none; margin: 1rem 0 0; padding: 0; }
.style-list .empty { padding: 1rem 0; }
.style-item { display: flex; justify-content: space-between; gap: 1rem; padding: 1rem 0; border-top: 1px solid var(--line); }
.style-item.inactive .style-item-main { opacity: .55; }
.style-item-main { min-width: 0; }
.style-item-main p { margin: 0 0 .15rem; }
.style-item-title { font-weight: 600; overflow-wrap: anywhere; }
.style-excerpt { color: var(--ink-2); margin-top: .35rem !important; overflow-wrap: anywhere; }
.style-item-actions { display: flex; flex-direction: column; align-items: flex-end; gap: .6rem; flex: none; }

.style-profile { position: sticky; top: 88px; display: grid; gap: 1rem; }
.profile-list { margin: 0; display: grid; gap: .15rem; }
.profile-list dt { font-size: .75rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--gold); margin-top: .7rem; }
.profile-list dd { margin: 0; color: var(--ink-2); display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.style-profile p { margin: 0; }

.history-settings { padding: 1.5rem 1.75rem; margin: 1.5rem 0; }
.history-settings p { margin: .75rem 0 0; }
.history-settings .alert { margin: 1rem 0 0; border: 1px solid #ecd1c6; border-radius: 10px; }
.switch-lg .switch-track { width: 42px; height: 24px; }
.switch-lg .switch-track::after { width: 18px; height: 18px; }
.switch-lg input:checked + .switch-track::after { transform: translateX(18px); }
.history-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: .75rem; }
.history-head p { margin: 0; }
.danger-link { color: var(--danger); }
.history-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 1rem; }
.history-item { padding: 1.25rem 1.4rem; }
.history-meta { display: flex; flex-wrap: wrap; gap: .4rem .7rem; align-items: center; }
.tag-accent { background: #e4eee6; color: var(--accent); border-color: #cadccd; }
.history-excerpt { margin: .6rem 0 .8rem; color: var(--ink-2); overflow-wrap: anywhere; }
.history-actions { display: flex; flex-wrap: wrap; gap: 1.1rem; }
.history-full { margin-top: 1rem; display: grid; gap: 1rem; }
.history-full[hidden] { display: none; }
.history-block-title { font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; font-size: .72rem; margin: 0 0 .35rem; }
.history-text { white-space: pre-wrap; background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: .9rem 1rem; max-height: 320px; overflow-y: auto; font-size: .95rem; }
.pagination { display: flex; justify-content: space-between; align-items: center; margin-top: 1.5rem; }
.empty-state { padding: 2rem; text-align: center; display: grid; gap: 1rem; justify-items: center; }
.empty-state p { margin: 0; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .det-grid, .det-details, .style-layout { grid-template-columns: 1fr; }
  .det-result { border-left: 0; border-top: 1px solid var(--line); padding: 1.75rem 1.25rem; }
  .det-signals { border-left: 0; border-top: 1px solid var(--line); }
  .det-input { min-height: 300px; }
  .style-profile { position: static; }
  .upsell { flex-direction: column; align-items: flex-start; padding: 1.75rem; }
}
@media (max-width: 600px) {
  .tool-toolbar, .tool-options, .pane-head, .pane-foot, .score-line, .tool-note { padding-left: 1rem; padding-right: 1rem; }
  .tool-options { gap: .75rem 1rem; }
  .opt { flex-wrap: wrap; }
  .modes { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; max-width: 100%; }
  .modes::-webkit-scrollbar { display: none; }
  .mode { flex: none; }
  .tool-toolbar { flex-direction: column; align-items: stretch; }
  .pane-foot { flex-wrap: wrap; }
  .pane-foot .actions { margin-left: auto; }
  .out-actions { gap: .75rem; }
  textarea, .output { padding-left: 1rem; padding-right: 1rem; }
  .det-number { font-size: 3.8rem; }
  .det-text-wrap, .det-signals { padding: 1rem; }
  .style-add, .style-list-card, .style-profile, .history-settings { padding: 1.25rem; }
  .style-item { flex-direction: column; }
  .style-item-actions { flex-direction: row; align-items: center; justify-content: space-between; }
  .kbd-hint { display: none; }
  .score-help { margin-left: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .gauge-fill, .switch-track, .switch-track::after, .seg-btn { transition: none; }
}
