:root {
  color-scheme: dark;
  --bg: #0a0e11;
  --surface: #141a1f;
  --surface-subtle: #10161b;
  --surface-strong: #1c242b;
  --text: #eaf1f3;
  --muted: #8a97a1;
  --line: #232c33;
  --line-strong: #2f3a42;
  --accent: #2fe0a6;
  --accent-strong: #24c892;
  --accent-soft: rgba(47, 224, 166, 0.13);
  --accent-2: #38d6d6;
  --accent-2-soft: rgba(56, 214, 214, 0.13);
  --success: #35d6a0;
  --success-soft: rgba(53, 214, 160, 0.14);
  --warning: #e0a83a;
  --warning-soft: rgba(224, 168, 58, 0.15);
  --danger: #f26d6d;
  --danger-soft: rgba(242, 109, 109, 0.14);
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 6px 18px rgba(0, 0, 0, 0.35);
  --grad-accent: linear-gradient(100deg, #2fe0a6, #38d6d6);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
}

/* Fond dégradé sur une couche FIXE séparée, peinte UNE seule fois (compositeur).
   Avant : background-attachment:fixed sur <body> → le navigateur repeignait TOUT
   l'écran à CHAQUE frame de scroll (défilement impossible à accélérer) → site
   « 20 fps » partout. Même rendu visuel, coût par frame ≈ 0. */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 380px at 12% -10%, rgba(47, 224, 166, 0.10), rgba(10, 14, 17, 0) 70%),
    radial-gradient(820px 320px at 100% 0%, rgba(56, 214, 214, 0.07), rgba(10, 14, 17, 0) 70%),
    var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--grad-accent);
  color: #06231a;
  cursor: pointer;
  font-weight: 750;
  min-height: 38px;
  padding: 9px 15px;
  box-shadow: 0 4px 16px rgba(47, 224, 166, 0.22);
  transition: filter 0.16s ease, border-color 0.16s ease, box-shadow 0.16s ease, transform 0.16s ease;
}

button:hover {
  filter: brightness(1.07);
  box-shadow: 0 6px 22px rgba(47, 224, 166, 0.34);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  background: #263038;
  color: #6b7680;
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

button.secondary {
  background: var(--surface-strong);
  color: var(--text);
  border-color: var(--line-strong);
  box-shadow: none;
}

button.secondary:hover {
  background: #222b32;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 224, 166, 0.1);
  filter: none;
}

button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
  box-shadow: none;
}

button.ghost:hover {
  background: var(--surface-subtle);
  color: var(--text);
  border-color: var(--line-strong);
  box-shadow: none;
  filter: none;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-subtle);
  color: var(--text);
  padding: 9px 11px;
  outline: none;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.28);
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

textarea {
  min-height: 86px;
  resize: vertical;
  line-height: 1.38;
}

input:focus,
select:focus,
textarea:focus,
.dropzone:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 224, 166, 0.18);
}

h1,
h2,
h3,
p,
figure {
  margin: 0;
}

.app-shell {
  display: flex;
  align-items: flex-start;
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 214px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 16px 12px;
  /* Fond quasi opaque SANS backdrop-filter : le blur(16px) re-floutait le contenu
     derrière la sidebar à CHAQUE frame de scroll (très cher, sidebar toujours visible). */
  background: rgba(14, 19, 24, 0.97);
  border-right: 1px solid var(--line);
  overflow-y: auto;
  z-index: 30;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px 14px;
}

.side-brand .brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: var(--shadow-soft);
}

.side-brand .brand-name {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text);
}

.side-account {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 12px 8px 2px;
  border-top: 1px solid var(--line);
}

.side-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

.side-account .lbl {
  font-size: 12px;
  color: var(--muted);
}

.nav-group {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  opacity: 0.6;
  padding: 13px 11px 4px;
}

.nav-group:first-child {
  padding-top: 4px;
}

.content {
  flex: 1;
  min-width: 0;
  padding: 18px 26px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  margin: -18px -26px 16px;
  padding: 14px 26px 12px;
  /* Idem sidebar : header sticky toujours visible → le blur(16px) coûtait à chaque frame. */
  background: rgba(10, 14, 17, 0.97);
  border-bottom: 1px solid var(--line);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin: 0 0 10px;
}

.brand-block {
  min-width: 0;
}

.eyebrow {
  display: block;
  color: var(--accent);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
  text-transform: uppercase;
}

.topbar h1 {
  font-size: clamp(24px, 3vw, 34px);
  letter-spacing: -0.01em;
  line-height: 1.02;
  background: linear-gradient(92deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.topbar p {
  color: var(--muted);
  margin-top: 5px;
  max-width: 720px;
}

.topbar-metrics {
  display: grid;
  grid-template-columns: 98px minmax(190px, 1fr);
  gap: 8px;
  min-width: 0;
}

.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 8px 10px;
}

.metric strong {
  display: block;
  color: var(--text);
  font-size: 16px;
  line-height: 1.1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
  margin-top: 3px;
  text-transform: uppercase;
}

.metric-wide strong {
  font-size: 13px;
}

.topbar-actions,
.toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}

.topbar-actions {
  justify-content: flex-end;
}

.tabs {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: visible;
}

.tab {
  width: 100%;
  min-width: 0;
  text-align: left;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  font-weight: 650;
  font-size: 13px;
  min-height: 34px;
  padding: 8px 11px;
  box-shadow: none;
}

.tab:hover {
  background: var(--surface-subtle);
  color: var(--text);
  box-shadow: none;
}

.tab.is-active {
  background: var(--accent-soft);
  border-color: transparent;
  color: var(--accent);
  font-weight: 750;
  box-shadow: inset 2px 0 0 var(--accent), 0 0 18px rgba(47, 224, 166, 0.08);
}

.tab-panel {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.tab-panel.is-active {
  display: flex;
}

.panel {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 130px),
    var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-soft), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 18px;
}

.upload-panel {
  display: grid;
  grid-template-columns: minmax(340px, 1fr) minmax(280px, 0.55fr);
  gap: 14px;
  align-items: stretch;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: baseline;
  margin-bottom: 12px;
}

.section-heading h2 {
  font-size: 18px;
  letter-spacing: 0;
}

.section-heading span,
.status,
.empty-state {
  color: var(--muted);
}

.status {
  min-height: 20px;
  flex: 1 1 220px;
  font-weight: 700;
}

.status.is-error {
  color: var(--danger);
}

.dropzone {
  min-height: 172px;
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(47, 224, 166, 0.06), rgba(56, 214, 214, 0.04)),
    var(--surface-subtle);
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 18px;
  text-align: center;
  transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.dropzone strong {
  color: var(--text);
  font-size: 20px;
  letter-spacing: 0;
}

.dropzone span {
  color: var(--muted);
}

.dropzone.is-dragover,
.dropzone:hover {
  background:
    linear-gradient(135deg, rgba(47, 224, 166, 0.12), rgba(56, 214, 214, 0.08)),
    var(--surface-strong);
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(47, 224, 166, 0.12);
}

.dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-panel .toolbar {
  align-content: center;
  align-items: center;
  background: var(--surface-subtle);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.inline-control {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
}

.inline-control select {
  min-width: 190px;
}

.draft-panel[hidden] {
  display: none;
}

.draft-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.draft-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
  padding: 10px;
}

.draft-group-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 12px;
}

.draft-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 48, 43, 0.05);
  padding: 12px;
}

.draft-card.is-invalid {
  border-color: rgba(242, 109, 109, 0.4);
  background: linear-gradient(180deg, var(--surface), var(--danger-soft));
}

.draft-card.is-suspect {
  border-color: rgba(224, 168, 58, 0.45);
  background: linear-gradient(180deg, var(--surface), var(--warning-soft));
}

.draft-card-header,
.draft-badges,
.draft-card-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.draft-card-header {
  justify-content: space-between;
}

.draft-card h3 {
  font-size: 15px;
}

.draft-badges,
.draft-card-actions {
  flex-wrap: wrap;
}

.draft-badge {
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  padding: 5px 8px;
  text-transform: uppercase;
}

.draft-badge.is-ok,
.draft-badge.confidence-high {
  background: var(--success-soft);
  color: var(--success);
}

.draft-badge.confidence-medium {
  background: var(--warning-soft);
  color: var(--warning);
}

.draft-badge.is-error,
.draft-badge.confidence-low {
  background: var(--danger-soft);
  color: var(--danger);
}

.draft-badge.is-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.draft-badge.is-neutral {
  background: var(--surface-subtle);
  color: var(--muted);
}

.draft-thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
}

.draft-thumb {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-subtle);
}

.draft-thumb img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: var(--surface-strong);
}

.draft-thumb figcaption {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 7px;
}

.draft-orientation {
  align-self: flex-start;
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  padding: 4px 7px;
  text-transform: uppercase;
}

.orientation-face {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.orientation-dos {
  background: var(--accent-2-soft);
  color: var(--accent-2);
}

.draft-file-name {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.draft-sequence {
  color: var(--text);
  font-family: "Cascadia Code", Consolas, Monaco, monospace;
  font-size: 11px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.draft-remove,
.draft-card-actions button {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.draft-reason {
  color: var(--muted);
  font-weight: 750;
  overflow-wrap: anywhere;
}

.draft-reason.is-error {
  color: var(--danger);
}

.draft-reason.is-warning {
  color: var(--warning);
}

.settings-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.preset-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.preset-workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.05fr);
  gap: 14px;
}

.preset-preview-card,
.preset-controls-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
  padding: 14px;
}

.preset-preview-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.preset-preview-grid figure {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.preset-preview-grid img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: contain;
  background:
    linear-gradient(45deg, #1c242b 25%, transparent 25%),
    linear-gradient(-45deg, #1c242b 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #1c242b 75%),
    linear-gradient(-45deg, transparent 75%, #1c242b 75%);
  background-color: #10161b;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.preset-preview-grid img.is-empty {
  opacity: 0.35;
}

.preset-preview-grid figcaption {
  color: var(--muted);
  font-size: 12px;
  font-weight: 850;
  padding: 7px 8px;
}

.range-grid {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.range-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px;
}

.range-field span {
  display: flex;
  justify-content: space-between;
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
}

.range-field strong {
  color: var(--accent-strong);
}

.range-field input {
  width: 100%;
  accent-color: var(--accent);
}

.preset-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.settings-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
  padding: 14px;
}

.settings-section .section-heading {
  margin-bottom: 10px;
}

.settings-section .section-heading h2 {
  font-size: 15px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-wide {
  grid-column: span 2;
}

.field label,
.lock-row label {
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  letter-spacing: 0.02em;
}

.lock-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.lock-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 62px;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-subtle);
  padding: 8px;
}

.lock-row textarea {
  min-height: 58px;
}

.lock-button {
  min-width: 62px;
  width: 62px;
  padding: 0;
  background: var(--surface);
  color: var(--muted);
  border-color: var(--line-strong);
  font-size: 12px;
}

.lock-button.is-locked {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.article-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(248px, 1fr));
  gap: 10px;
}

.article-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface);
  box-shadow: 0 8px 22px rgba(31, 48, 43, 0.05);
}

.article-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.article-card h3 {
  font-size: 15px;
}

.badge {
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  padding: 5px 9px;
  text-transform: uppercase;
}

.status-pret .badge {
  color: var(--success);
  background: var(--success-soft);
}

.status-erreur .badge {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-upload .badge,
.status-analyse-ia .badge,
.status-retouche-photo .badge {
  color: var(--warning);
  background: var(--warning-soft);
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.thumbs figure {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface-subtle);
}

.thumbs img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: var(--surface-strong);
}

.thumbs figcaption {
  color: var(--muted);
  font-size: 12px;
  padding: 6px;
  overflow-wrap: anywhere;
}

.thumb-caption {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.thumb-caption-title {
  color: var(--text);
  font-weight: 800;
}

.photo-mode-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.photo-mode-button {
  min-height: 26px;
  padding: 4px 7px;
  font-size: 11px;
  background: var(--surface);
}

.photo-mode-button.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.retouch-note {
  color: var(--warning);
  font-weight: 800;
}

.article-info {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-height: 42px;
}

.article-info p:first-child {
  font-weight: 750;
}

.warning {
  color: var(--warning);
  font-weight: 800;
}

.error {
  color: var(--danger);
  font-weight: 800;
  overflow-wrap: anywhere;
}

.article-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: auto;
}

.control-wrap,
.table-wrap {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

.control-table {
  min-width: 1120px;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

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

.control-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.info-value {
  display: inline-block;
  max-width: 340px;
  border-radius: 8px;
  background: var(--surface-subtle);
  color: var(--text);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.35;
  padding: 5px 8px;
  overflow-wrap: anywhere;
}

.info-value.is-ok {
  background: var(--success-soft);
  color: var(--success);
}

.info-value.is-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.fix-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.fix-button {
  min-height: 30px;
  padding: 5px 8px;
  font-size: 12px;
}

.csv-table {
  min-width: 2500px;
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.csv-table th,
.csv-table td {
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 6px;
  vertical-align: top;
}

.csv-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--surface-strong);
  color: var(--text);
  font-size: 11px;
  font-weight: 850;
  text-align: left;
  white-space: nowrap;
}

.csv-table td:nth-child(2),
.csv-table td:nth-child(3),
.csv-table td:nth-child(18),
.csv-table td:nth-child(19) {
  background: var(--surface-subtle);
}

.csv-table input,
.csv-table textarea {
  min-width: 112px;
  border-color: transparent;
  border-radius: 6px;
  padding: 7px;
}

.csv-table input:focus,
.csv-table textarea:focus {
  border-color: var(--accent);
}

.csv-table .is-invalid input,
.csv-table .is-invalid textarea {
  border-color: rgba(188, 47, 42, 0.6);
  background: var(--danger-soft);
}

.csv-table textarea {
  min-width: 300px;
  min-height: 96px;
  field-sizing: content;
  max-height: 340px;
  line-height: 1.4;
}

/* Mode "colonnes essentielles" : peu de colonnes → le tableau ne doit plus
   forcer 2500px de large, et les champs sont resserrés pour tout voir. */
.csv-table.compact {
  min-width: 0;
}
.csv-table.compact input {
  min-width: 90px;
}
.csv-table.compact textarea {
  min-width: 220px;
  min-height: 60px;
}

.account-fold {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  margin-bottom: 0.7rem;
}
.account-fold > summary {
  cursor: pointer;
  padding: 0.7rem 0.9rem;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  user-select: none;
}
.account-fold > summary::-webkit-details-marker {
  display: none;
}
.account-fold > summary::before {
  content: '▸';
  color: var(--muted);
  font-size: 0.72rem;
  transition: transform 0.15s;
  flex: none;
}
.account-fold[open] > summary::before {
  transform: rotate(90deg);
}
.account-fold .acc-name {
  font-weight: 700;
  color: var(--text);
  font-size: 0.95rem;
}
.account-fold .acc-count {
  font-size: 0.76rem;
  color: var(--muted);
  background: var(--surface-strong);
  padding: 2px 9px;
  border-radius: 999px;
}
.account-fold-body {
  padding: 0 0.6rem 0.6rem;
}

.price-icon-btn {
  width: 34px;
  height: 34px;
  min-height: 0;
  box-shadow: none;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 9px;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.price-icon-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: var(--accent);
}
.price-icon-btn:active {
  transform: translateY(1px);
}
.price-icon-btn.danger {
  background: rgba(239, 68, 68, 0.13);
  border-color: rgba(239, 68, 68, 0.32);
  color: #f87171;
}
.price-icon-btn.danger:hover {
  background: rgba(239, 68, 68, 0.22);
  border-color: rgba(239, 68, 68, 0.5);
}

#promptInput {
  min-height: 440px;
  font-family: "Cascadia Code", Consolas, Monaco, monospace;
  font-size: 13px;
  line-height: 1.5;
}

.ai-log-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}

.ai-log-entry {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  overflow: hidden;
}

.ai-log-entry.is-error {
  border-color: rgba(188, 47, 42, 0.35);
}

.ai-log-entry summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  cursor: pointer;
  padding: 10px 12px;
}

.ai-log-title {
  color: var(--text);
  font-weight: 850;
  overflow-wrap: anywhere;
}

.ai-log-body {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  border-top: 1px solid var(--line);
  background: var(--surface-subtle);
  padding: 10px;
}

.ai-log-block {
  min-width: 0;
}

.ai-log-block h3 {
  color: var(--text);
  font-size: 12px;
  margin-bottom: 5px;
}

.ai-log-block pre {
  max-height: 340px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-family: "Cascadia Code", Consolas, Monaco, monospace;
  font-size: 12px;
  line-height: 1.45;
  margin: 0;
  padding: 9px;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 1180px) {
  .topbar {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

  .upload-panel {
    grid-template-columns: 1fr;
  }

  .preset-workspace {
    grid-template-columns: 1fr;
  }

  .settings-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .ai-log-body {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .app-shell {
    flex-direction: column;
  }

  .sidebar {
    position: static;
    height: auto;
    width: 100%;
    flex-direction: row;
    align-items: center;
    gap: 6px;
    padding: 10px 12px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }

  .sidebar .tabs {
    flex-direction: row;
    flex: 1;
    overflow-x: auto;
  }

  .sidebar .tab {
    width: auto;
    white-space: nowrap;
  }

  .nav-group {
    display: none;
  }

  .side-brand {
    padding: 0 6px 0 0;
    flex-shrink: 0;
  }

  .side-account {
    display: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    max-width: 100vw;
    padding: 0;
    overflow: hidden;
    width: 100%;
  }

  .app-header {
    margin: -12px -12px 12px;
    max-width: 100vw;
    padding: 12px;
    width: 100vw;
  }

  .topbar,
  .tab-panel,
  .panel,
  .upload-panel,
  .brand-block,
  .metric,
  .dropzone,
  .upload-panel .toolbar {
    max-width: 100%;
    min-width: 0;
  }

  .topbar-metrics,
  .settings-grid,
  .lock-grid {
    grid-template-columns: 1fr;
  }

  .field-wide {
    grid-column: auto;
  }

  .topbar-actions,
  .toolbar,
  .draft-actions,
  .inline-control,
  .preset-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions button,
  .toolbar button,
  .draft-actions button,
  .inline-control select,
  .preset-actions button {
    width: 100%;
  }

  .tabs {
    display: flex;
    overflow: visible;
    width: calc(100vw - 24px);
    max-width: calc(100vw - 24px);
  }

  .tab {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    padding-inline: 8px;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
  }

  .panel {
    padding: 12px;
  }

  .section-heading {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .article-list {
    grid-template-columns: 1fr;
  }

  .preset-preview-grid {
    grid-template-columns: 1fr;
  }

  .draft-group-list {
    grid-template-columns: 1fr;
  }

  .draft-card-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .lock-row {
    grid-template-columns: 1fr;
  }

  .lock-button {
    width: 100%;
  }
}

/* ── Bibliothèque : barre de filtres compacte (selects en largeur auto, pas empilés) ── */
#biblioFilterType,
#biblioFilterUsed,
#biblioFilterSource,
#biblioSort {
  width: auto;
  min-width: 128px;
  cursor: pointer;
}
#biblioSearch {
  min-width: 170px;
}
