:root {
  --bg: #f4f6f8;
  --card: #ffffff;
  --accent: #2e7d32;
  --accent-dark: #1b5e20;
  --border: #dfe3e8;
  --text: #1f2933;
  --muted: #6b7280;
  --danger: #c62828;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: 90px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  padding: 14px 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
header h1 { font-size: 1.3rem; margin: 0; }

.header-title { display: flex; flex-direction: row; align-items: center; gap: 8px; min-width: 0; }
.desc-btn {
  flex: 0 0 auto;
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  font-size: 1rem;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}
.desc-btn:hover { background: rgba(255, 255, 255, 0.3); }
.active-list {
  font-size: 1.3rem;
  color: #fff;
  font-weight: 700;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
  user-select: none;
}
.active-list:hover { text-decoration: underline; }

/* Menu déroulant de bascule entre listes */
.list-switcher {
  position: fixed;
  z-index: 50;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.25);
  padding: 6px;
  min-width: 210px;
  max-height: 60vh;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.switch-item {
  text-align: left;
  border: none;
  background: transparent;
  padding: 8px 10px;
  border-radius: 7px;
  cursor: pointer;
  font-size: 0.92rem;
  white-space: nowrap;
}
.switch-item:hover { background: #f0f2f4; }
.switch-item.active { font-weight: 700; color: var(--accent-dark); }
.switch-sep { height: 1px; background: var(--border); margin: 4px 2px; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.user-btn {
  max-width: 160px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}
.user-btn:hover { background: rgba(255, 255, 255, 0.26); }

/* Listes enregistrées */
.active-banner { font-size: 0.9rem; padding: 6px 0; }
.active-banner .pill { background: #eef3ee; border: 1px solid var(--border); border-radius: 12px; padding: 2px 8px; color: var(--accent-dark); font-weight: 600; }
.lists-container { display: flex; flex-direction: column; gap: 10px; max-height: 45vh; overflow: auto; }
.list-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.list-card.active { border-color: var(--accent); background: #f6fff6; }
.list-card-head { display: flex; align-items: center; gap: 8px; }
.list-card-head .lname { flex: 1; font-weight: 600; }
.list-card-head .badge-active { font-size: 0.72rem; background: var(--accent); color: #fff; border-radius: 10px; padding: 1px 7px; }
.list-card-head .list-color { width: 28px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 5px; cursor: pointer; flex: 0 0 auto; background: none; }
.list-card-meta { color: var(--muted); font-size: 0.82rem; margin: 2px 0 6px; }

.icon-btn {
  background: rgba(255, 255, 255, 0.18);
  border: none;
  color: #fff;
  font-size: 1.2rem;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.3); }

main {
  margin: 18px auto;
  padding: 0 14px;
}

.scrape-row { flex-wrap: wrap; }
.scrape-row input[type="url"] {
  flex: 1 1 300px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}
.scrape-row #scrapeStatus { flex: 1 1 100%; }
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}
.row:last-child { margin-bottom: 0; }

input[type="text"], input[type="number"] {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  flex: 1;
  min-width: 0;
}
input.qty { flex: 0 0 80px; text-align: center; }
input.amount { flex: 0 0 90px; }
.unit-select {
  flex: 0 0 auto;
  padding: 9px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
}
.item-amount { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.item-amount input { width: 64px; text-align: center; padding: 6px; }
.item-amount .unit-select { padding: 6px; }

button {
  font-size: 0.95rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #fff;
  padding: 10px 14px;
  cursor: pointer;
}
button:hover { background: #f0f2f4; }

button.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  font-weight: 600;
}
button.primary:hover { background: var(--accent-dark); }

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 14px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  color: var(--muted);
}
.file-label:hover { border-color: var(--accent); color: var(--accent); }

.preview {
  width: 48px;
  height: 48px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
}

/* ----- Disposition scindée : liste | aperçu ----- */
.split {
  display: flex;
  align-items: stretch;
  gap: 0;
  min-height: 50vh;
}
.pane { min-width: 0; }
.pane-list { flex: 1 1 50%; }
.pane-preview {
  flex: 0 0 25%;
  width: 25%;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
/* ----- Colonne des mini-listes (à gauche) ----- */
.pane-mini {
  flex: 0 0 25%;
  width: 25%;
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin-right: 12px;
  align-self: flex-start;
}
.mini-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: #eef3ee;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 0.9rem; color: var(--accent-dark);
}
.mini-list {
  list-style: none; padding: 6px; margin: 0; overflow: visible;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 6px;
  align-content: flex-start;
}
.mini-item {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 8px;
  background: #fff;
}
.mini-item:hover { border-color: var(--accent); }
.mini-item.mini-drop { box-shadow: inset 0 3px 0 0 var(--accent); }
.mini-top { display: flex; align-items: flex-start; gap: 4px; }
.mini-handle { flex: 0 0 auto; cursor: grab; color: var(--muted); user-select: none; font-size: 1rem; line-height: 1.2; }
.mini-handle:active { cursor: grabbing; }
.mini-item-main { cursor: pointer; user-select: none; flex: 1 1 auto; min-width: 0; }
.mini-item .mini-name { display: block; font-weight: 600; font-size: 0.92rem; word-break: break-word; }
.mini-item .mini-count { display: block; color: var(--muted); font-size: 0.75rem; }
.mini-actions { display: flex; gap: 2px; margin-top: 4px; flex-wrap: wrap; align-items: center; }

/* Au repos : seul le nom (et le fond) ; au survol : poignée, nombre et icônes. */
.mini-item .mini-handle,
.mini-item .mini-actions,
.mini-item .mini-count { display: none; }
.mini-item:hover .mini-handle { display: inline; }
.mini-item:hover .mini-actions { display: flex; }
.mini-item:hover .mini-count { display: block; }

/* Image de fond : pleinement visible au repos, voilée au survol pour la lisibilité. */
.mini-item.has-bg-img {
  background-image: var(--mini-bg);
  background-size: cover;
  background-position: center;
  min-height: 81px;
}
.mini-item.has-bg-img:hover {
  background-image: linear-gradient(rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0.85)), var(--mini-bg);
}
.mini-item.has-bg-img .mini-name {
  display: inline-block;
  background: rgba(255, 255, 255, 0.75);
  border-radius: 4px;
  padding: 0 4px;
}
.mini-item.has-bg-img:hover .mini-name { background: none; padding: 0; }
/* Icône note : estompée quand il n'y a pas de note, pleine quand il y en a une. */
.mini-note-btn { opacity: 0.3; filter: grayscale(0.6); }
.mini-note-btn.has-note { opacity: 1; filter: none; }
.mini-actions .mini-btn { font-size: 0.85rem; padding: 1px 5px; }
.mini-empty { color: var(--muted); font-size: 0.82rem; padding: 8px 12px; margin: 0; }

.divider {
  flex: 0 0 10px;
  cursor: col-resize;
  position: relative;
}
.divider::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; left: 4px;
  width: 2px;
  background: var(--border);
  border-radius: 2px;
}
.divider:hover::before { background: var(--accent); }

.preview-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: #eef3ee;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 0.9rem; color: var(--accent-dark);
}
.mini-btn {
  border: none; background: transparent; cursor: pointer; font-size: 1rem; padding: 2px 6px;
}
.mini-btn:hover { background: rgba(0,0,0,0.06); border-radius: 6px; }
.md-preview {
  padding: 12px 16px;
  overflow: auto;
  font-size: 0.92rem;
  line-height: 1.5;
}
.md-preview h1 { font-size: 1.3rem; margin: 0 0 6px; }
.md-preview h2 {
  font-size: 1.05rem;
  margin: 14px 0 6px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px;
  color: var(--accent-dark);
}
.md-preview h2 .store-ico { width: 22px; height: 22px; object-fit: cover; border-radius: 5px; }
.md-preview .meta { color: var(--muted); font-style: italic; font-size: 0.82rem; margin-bottom: 10px; }
.md-preview ul { list-style: none; padding: 0; margin: 0; }
.md-preview li { margin: 4px 0; display: flex; align-items: center; gap: 6px; }
.md-preview li .md-li-text { flex: 1 1 auto; min-width: 0; }
.md-ctrls { flex: 0 0 auto; margin-left: auto; display: inline-flex; align-items: center; gap: 3px; }
.md-qty {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--accent-dark);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  border-radius: 6px;
}
.md-qty:hover { background: #eef3ee; }
.md-del {
  flex: 0 0 auto;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.15rem;
  line-height: 1;
  padding: 1px 7px;
  border-radius: 6px;
}
.md-del:hover { background: #fdecea; color: var(--danger); }
.md-preview img { max-width: 90px; max-height: 70px; border-radius: 6px; display: block; margin: 4px 0 8px 22px; }
.md-preview .done { color: var(--muted); text-decoration: line-through; }
.md-preview p { margin: 6px 0; }
.md-preview h3 { font-size: 0.98rem; margin: 10px 0 4px; color: var(--accent-dark); }
.md-preview a { color: var(--accent-dark); }
/* Listes de la description : avec marqueurs (la liste de courses, elle, reste sans puce) */
.md-preview ul.md-doc { list-style: disc; padding-left: 20px; margin: 4px 0; }
.md-preview ol.md-doc { list-style: decimal; padding-left: 22px; margin: 4px 0; }
.md-preview ul.md-doc li, .md-preview ol.md-doc li { display: list-item; margin: 2px 0; }

/* Éditeur WYSIWYG de description */
#descDlg { max-width: 560px; }
.wysiwyg-toolbar { display: flex; flex-wrap: wrap; gap: 4px; }
.wysiwyg-toolbar button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
}
.wysiwyg-toolbar button:hover { background: #eef3ee; }
.wysiwyg {
  min-height: 160px;
  max-height: 45vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  background: #fff;
}
.wysiwyg:focus { outline: none; border-color: var(--accent); }
.wysiwyg-label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--muted); margin: 8px 0 4px; }
#descField2 { margin-top: 4px; }
.wysiwyg h2 { font-size: 1.1rem; margin: 8px 0 4px; }
.wysiwyg h3 { font-size: 1rem; margin: 8px 0 4px; }
.wysiwyg ul, .wysiwyg ol { padding-left: 22px; margin: 4px 0; }
.wysiwyg p { margin: 6px 0; }

.list-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.search {
  flex: 1 1 160px;
  min-width: 120px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
}
.list-tools .store-select { max-width: 160px; }
.view-btn {
  white-space: nowrap;
  background: #eef3ee;
  border-color: var(--border);
  font-weight: 600;
  color: var(--accent-dark);
}

/* Glisser-déposer (vue à plat) */
.item.draggable { cursor: grab; }
.item .drag-handle {
  flex: 0 0 auto;
  cursor: grab;
  color: var(--muted);
  font-size: 1.1rem;
  padding: 0 2px;
  user-select: none;
}
.item.dragging { opacity: 0.45; }
.item.drop-before { box-shadow: 0 -3px 0 0 var(--accent); }
.item.drop-after { box-shadow: 0 3px 0 0 var(--accent); }

/* ----- Sections de catégories dans la liste ----- */
.cat-section { margin-bottom: 6px; }
.cat-header {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 4px;
  cursor: pointer;
  font-weight: 600;
  color: var(--accent-dark);
  border-bottom: 1px solid var(--border);
  user-select: none;
}
.cat-header .twisty { width: 14px; display: inline-block; transition: transform 0.15s; color: var(--muted); }
.cat-header.collapsed .twisty { transform: rotate(-90deg); }
.cat-header .count { color: var(--muted); font-weight: 400; font-size: 0.85rem; }
.cat-dot { width: 11px; height: 11px; border-radius: 50%; display: inline-block; flex: 0 0 auto; border: 1px solid rgba(0,0,0,0.25); }
/* Liseré (contour) optionnel sur le texte, réglé par catégorie */
.cat-header.has-stroke span:not(.twisty):not(.cat-dot):not(.count) {
  text-shadow:
    -1px -1px 0 var(--stroke-color), 1px -1px 0 var(--stroke-color),
    -1px  1px 0 var(--stroke-color), 1px  1px 0 var(--stroke-color),
    0 0 2px var(--stroke-color);
}
.cat-body { padding-left: 8px; border-left: 2px solid var(--border); margin: 6px 0 6px 6px; }
.cat-body.hidden { display: none; }

.list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }

.item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
/* Deuxième rangée de contrôles (quantité, magasin, catégorie) */
.item-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  flex: 1 1 100%;
  padding-left: 34px;
}
.item.checked { opacity: 0.55; }
.item.checked .item-name { text-decoration: line-through; }

/* Produit en réserve (quantité 0) : présent dans le catalogue, hors liste de courses */
.item.inactive { background: #f7f7f5; border-style: dashed; }
.item.inactive .item-name { color: var(--muted); }
.reserve-badge {
  display: inline-block;
  margin-left: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  color: #8a6d00;
  background: #fff4d6;
  border: 1px solid #f0e0a8;
  border-radius: 10px;
  padding: 1px 7px;
  vertical-align: middle;
}

.item-check { width: 22px; height: 22px; flex: 0 0 auto; cursor: pointer; }

.item-thumb {
  width: 52px; height: 52px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid var(--border);
  flex: 0 0 auto;
  cursor: pointer;
  background: #fafafa;
}
#imgPreview {
  position: fixed;
  z-index: 2000;
  display: none;
  pointer-events: none;
  background: #fff;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}
#imgPreview img {
  display: block;
  max-width: 512px;
  max-height: 512px;
  width: auto;
  height: auto;
  border-radius: 6px;
}
.item-thumb.placeholder {
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-size: 1.4rem;
}

.item-main { flex: 1; min-width: 0; }
.item-name {
  font-weight: 600;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  cursor: text;
}
.item-name:hover { border-color: var(--border); background: #fafafa; }
.item-name:focus { outline: none; border-color: var(--accent); background: #f6fff6; }

.item-qty {
  display: flex; align-items: center; gap: 4px; flex: 0 0 auto;
}
.item-qty input {
  width: 58px; text-align: center; padding: 6px; flex: 0 0 58px;
}

.item-price {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  margin-left: auto;
  color: var(--text);
  font-weight: 600;
}
.item-price input {
  width: 72px;
  text-align: right;
  padding: 6px;
  flex: 0 0 auto;
}
.item-price .price-sub { font-size: 0.8rem; color: var(--muted); font-weight: 400; white-space: nowrap; }

.item-del {
  flex: 0 0 auto;
  color: var(--danger);
  border-color: transparent;
  font-size: 1.1rem;
  padding: 6px 10px;
}
.item-del:hover { background: #fdecea; }

.empty { text-align: center; color: var(--muted); margin-top: 30px; }

/* Sélecteur de magasin */
select.store-select {
  padding: 9px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  background: #fff;
  max-width: 130px;
}
.item-store {
  display: flex;
  align-items: center;
  gap: 5px;
  flex: 0 0 auto;
}
.item-store .store-icon {
  width: 26px; height: 26px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.item-store select.store-select { max-width: 110px; }

/* Liste des magasins (fenêtre) */
.store-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.store-row {
  display: flex; align-items: center; gap: 10px;
  border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px;
}
.store-row .store-icon {
  width: 40px; height: 40px; object-fit: cover; border-radius: 8px;
  border: 1px solid var(--border); cursor: pointer; background: #fafafa;
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.store-row .store-name { flex: 1; font-weight: 600; }
.store-add { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.store-add input[type="text"] { flex: 1; min-width: 120px; }

/* Arbre des catégories (fenêtre de gestion) */
.tree-tools { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.group-tree { max-height: 50vh; overflow: auto; border: 1px solid var(--border); border-radius: 10px; padding: 8px; }
.group-node { }
.group-row {
  display: flex; align-items: center; gap: 6px;
  padding: 4px 6px; border-radius: 6px;
}
.group-row:hover { background: #f3f5f7; }
.group-handle { flex: 0 0 auto; cursor: grab; color: var(--muted); font-size: 1.05rem; padding: 0 2px; user-select: none; }
.group-handle:active { cursor: grabbing; }
.group-row.drop-before { box-shadow: inset 0 3px 0 0 var(--accent); }
.group-row.drop-after { box-shadow: inset 0 -3px 0 0 var(--accent); }
.group-row.drop-inside { background: #e3f3e3; outline: 2px dashed var(--accent); outline-offset: -2px; }
.group-row .gname { flex: 1; padding: 2px 4px; border: 1px solid transparent; border-radius: 5px; cursor: text; }
.group-row .gname:focus { outline: none; border-color: var(--accent); background: #f6fff6; }
.cat-color { width: 28px; height: 26px; padding: 0; border: 1px solid var(--border); border-radius: 5px; cursor: pointer; flex: 0 0 auto; background: none; }
.cat-color:disabled { opacity: 0.4; cursor: not-allowed; }
.stroke-ctl { display: inline-flex; align-items: center; gap: 3px; flex: 0 0 auto; cursor: pointer; }
.stroke-ctl input[type="checkbox"] { margin: 0; cursor: pointer; }
.stroke-ctl .stroke-lbl { font-size: 0.78rem; color: var(--muted); }
.group-row .mini-btn { font-size: 0.95rem; }
.group-children { margin-left: 16px; border-left: 2px solid var(--border); padding-left: 6px; }
.group-empty { color: var(--muted); font-size: 0.9rem; padding: 6px; }

/* Fenêtre Scrapers */
#scrapersDlg { max-width: 640px; }
#addDlg { max-width: 640px; }
.rules-help { font-size: 0.84rem; color: var(--muted); }
.rules-help summary { cursor: pointer; font-weight: 600; }
.rules-help ul { margin: 6px 0 0; padding-left: 18px; }
.rules-help code { background: #eef1f3; padding: 1px 5px; border-radius: 4px; }
.scrapers-list { display: flex; flex-direction: column; gap: 10px; max-height: 42vh; overflow: auto; }
.scraper-card { border: 1px solid var(--border); border-radius: 10px; padding: 10px; }
.scraper-card.disabled { opacity: 0.55; }
.scraper-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.scraper-head .sc-name { flex: 1 1 auto; font-weight: 600; }
.scraper-head .sc-match { flex: 1 1 auto; }
.scraper-head input[type="text"] { padding: 6px 8px; font-size: 0.9rem; }
.sc-rule { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.sc-rule span { flex: 0 0 52px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.sc-rule input { flex: 1 1 auto; padding: 6px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 0.85rem; font-family: ui-monospace, monospace; }
.scraper-add { display: flex; gap: 8px; flex-wrap: wrap; }
.scraper-add input { flex: 1 1 140px; }
.scraper-test { border-top: 1px solid var(--border); padding-top: 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.scraper-test input[type="url"] { flex: 1 1 240px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; }
.scraper-test-result { flex: 1 1 100%; font-size: 0.88rem; }
.scraper-test-result.ok { color: var(--text); }
.scraper-test-result.err { color: var(--danger); }
.scraper-test-result img { max-width: 120px; max-height: 120px; border-radius: 8px; border: 1px solid var(--border); margin-top: 6px; display: block; }
.bookmarklet-box { border-top: 1px solid var(--border); padding-top: 10px; font-size: 0.88rem; }
.bookmarklet-box summary { cursor: pointer; font-weight: 600; color: var(--accent-dark); }
.bookmarklet-row { margin: 10px 0; }
.bookmarklet-link {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  text-decoration: none;
  padding: 10px 16px;
  border-radius: 8px;
  cursor: grab;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.bookmarklet-link:hover { background: var(--accent-dark); }

@media (max-width: 760px) {
  .split { flex-direction: column; }
  .pane-preview { flex-basis: auto; width: 100% !important; max-height: 45vh; }
  .pane-mini { flex-basis: auto; width: 100% !important; margin-right: 0; max-height: 35vh; }
  .pane-mini .mini-list { overflow: auto; }
  .divider { display: none; }
}

.export-bar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  justify-content: center;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.06);
}
.danger-btn {
  background: #fff;
  color: var(--danger);
  border: 1px solid #f0c4c0;
  font-weight: 600;
}
.danger-btn:hover { background: #fdecea; }
.status { color: var(--muted); font-size: 0.9rem; }
.status.ok { color: var(--accent); }
.status.err { color: var(--danger); }

dialog {
  border: none;
  border-radius: 14px;
  padding: 0;
  max-width: 460px;
  width: 92%;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.settings { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.settings h2 { margin: 0; }
.settings label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 0.95rem; }
.settings input { font-weight: 400; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }
.hint code { background: #eef1f3; padding: 1px 5px; border-radius: 4px; }
.dlg-actions { display: flex; justify-content: flex-end; gap: 10px; }

.users-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.users-list li { padding: 6px 10px; border: 1px solid var(--border); border-radius: 8px; display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.users-list li.offline { opacity: 0.65; }
.chat-btn { position: relative; }
#cfgUsersList li { flex-direction: row; align-items: center; justify-content: space-between; }

.user-row { position: relative; padding-right: 28px; }
.user-del {
  position: absolute; top: 4px; right: 4px;
  width: 20px; height: 20px; padding: 0; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; color: var(--muted);
  border-radius: 50%; cursor: pointer; font-size: 0.85rem;
}
.user-del:hover { background: #fdecea; color: var(--danger); }

.unread-badge {
  display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 6px;
  border-radius: 9px; background: #e0432b; color: #fff; font-size: 0.75rem;
  line-height: 18px; text-align: center; font-weight: 700;
}

.user-btn.has-unread { position: relative; }
.user-btn.has-unread::after {
  content: ''; position: absolute; top: 2px; right: 2px;
  width: 9px; height: 9px; border-radius: 50%; background: #e0432b;
  border: 1px solid var(--card, #fff);
}

.chat-dlg { width: 360px; max-width: 90vw; }
.chat-messages {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 320px; overflow-y: auto; padding: 8px;
  border: 1px solid var(--border); border-radius: 8px; background: #f7f8f9;
}
.chat-msg { max-width: 80%; padding: 6px 10px; border-radius: 10px; word-wrap: break-word; white-space: pre-wrap; }
.chat-msg.theirs { align-self: flex-start; background: #e9ecef; }
.chat-msg.mine { align-self: flex-end; background: var(--accent, #2e7d32); color: #fff; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input { flex: 1; }

@media (max-width: 520px) {
  .item-thumb { width: 44px; height: 44px; }
  .item-qty input { flex-basis: 40px; width: 40px; }
}
