/*
 * By-laws editor, change editor, before and after, and pop ups.
 * Shared by manage and the Notices site (which serves this same file), so
 * every colour comes from the host site's tokens with a fallback.
 */
.bl-ed, .blc, .bl-modal, .bl-diff {
    --bl-bg: var(--bg-input, #1a1a2e);
    --bl-card: var(--bg-card, #2a2a4a);
    --bl-line: var(--border-color, #3a3a5a);
    --bl-text: var(--text-primary, #f0f0f0);
    --bl-muted: var(--text-muted, #9a9abf);
    --bl-accent: var(--color-lime, var(--color-primary, #32cd32));
    --bl-danger: var(--color-error, var(--color-danger, #ff6b6b));
    --bl-del: rgba(255, 107, 107, 0.18);
    --bl-ins: rgba(50, 205, 50, 0.18);
}

/* ── Formatting editor ── */
.bl-ed { border: 1px solid var(--bl-line); border-radius: 8px; background: var(--bl-bg); position: relative; min-width: 0; }
.bl-ed-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px; border-bottom: 1px solid var(--bl-line); background: var(--bl-card); border-radius: 8px 8px 0 0; position: sticky; top: 0; z-index: 2; }
.bl-ed-btn { display: inline-flex; align-items: center; gap: 3px; min-width: 32px; height: 32px; padding: 0 6px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--bl-text); cursor: pointer; font-size: 0.85rem; }
.bl-ed-btn:hover:not(:disabled), .bl-ed-btn:focus-visible { border-color: var(--bl-line); background: rgba(255, 255, 255, 0.06); outline: none; }
.bl-ed-btn.on { background: rgba(50, 205, 50, 0.2); border-color: var(--bl-accent); }
.bl-ed-btn:disabled { opacity: 0.35; cursor: default; }
.bl-ed-btn-text { font-size: 0.7rem; }
.bl-ed-sep { width: 1px; margin: 4px 3px; background: var(--bl-line); }
.bl-ed-area { min-height: 160px; max-height: 55vh; overflow-y: auto; padding: 10px 12px; color: var(--bl-text); line-height: 1.55; outline: none; word-wrap: break-word; }
.bl-ed-area:focus { box-shadow: inset 0 0 0 2px rgba(50, 205, 50, 0.35); border-radius: 0 0 8px 8px; }
.bl-ed-area p { margin: 0 0 0.6em; }
.bl-ed-area ul, .bl-ed-area ol { margin: 0 0 0.6em; padding-left: 1.6em; }
.bl-ed-area table, .bl-body table { border-collapse: collapse; width: 100%; margin: 0.4em 0 0.8em; }
.bl-ed-area td, .bl-ed-area th, .bl-body td, .bl-body th { border: 1px solid var(--bl-line, var(--border-color)); padding: 4px 6px; vertical-align: top; text-align: left; }
.bl-ed-area th, .bl-body th { background: rgba(255, 255, 255, 0.05); }
.bl-ed-area .bl-center, .bl-body .bl-center { text-align: center; }
.bl-ed-area .bl-right, .bl-body .bl-right { text-align: right; }
.bl-ed-area span.bl-ref { display: inline-block; padding: 0 6px; border-radius: 10px; background: rgba(77, 168, 218, 0.22); color: var(--bl-text); font-weight: 600; cursor: default; user-select: all; }
.bl-ed-pop { position: absolute; top: 46px; left: 8px; right: 8px; max-width: 460px; z-index: 5; background: var(--bl-card); border: 1px solid var(--bl-line); border-radius: 8px; padding: 10px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5); }
.bl-ed-pop[hidden] { display: none; }
.bl-ed-pop-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; color: var(--bl-text); }
.bl-ed-pop-x { border: 0; background: transparent; color: var(--bl-text); font-size: 1.1rem; cursor: pointer; width: 32px; height: 32px; }
.bl-ed-pop-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; color: var(--bl-muted); }
.bl-ed-pop-row input, .bl-ed-pop-search { background: var(--bl-bg); color: var(--bl-text); border: 1px solid var(--bl-line); border-radius: 6px; padding: 6px 8px; }
.bl-ed-pop-row input { width: 64px; }
.bl-ed-pop-search { width: 100%; box-sizing: border-box; margin-bottom: 6px; }
.bl-ed-pop-help { font-size: 0.8rem; color: var(--bl-muted); margin-bottom: 6px; }
.bl-ed-pop-list { max-height: 240px; overflow-y: auto; }
.bl-ed-pop-item { display: flex; gap: 8px; width: 100%; text-align: left; padding: 6px; border: 0; border-radius: 6px; background: transparent; color: var(--bl-text); cursor: pointer; }
.bl-ed-pop-item:hover, .bl-ed-pop-item:focus-visible { background: rgba(255, 255, 255, 0.07); outline: none; }
.bl-ed-pop-num { min-width: 48px; font-weight: 700; color: var(--bl-accent); }
.bl-ed-check { display: block; color: var(--bl-muted); margin-bottom: 8px; }

/* ── Before and after ── */
.bl-diff { border: 1px solid var(--bl-line); border-left: 4px solid var(--bl-muted); border-radius: 6px; padding: 8px 10px; margin: 0 0 8px; background: rgba(255, 255, 255, 0.02); color: var(--bl-text); }
.bl-diff-added { border-left-color: var(--bl-accent); }
.bl-diff-removed { border-left-color: var(--bl-danger); }
.bl-diff-changed, .bl-diff-formatting { border-left-color: #4da8da; }
.bl-diff-moved, .bl-diff-renumbered { border-left-color: #ffb347; }
.bl-diff-title { font-weight: 700; margin-bottom: 4px; }
.bl-diff-meta { font-size: 0.8rem; color: var(--bl-muted); margin-bottom: 4px; }
.bl-diff-head { font-weight: 600; margin-bottom: 4px; }
.bl-diff-body { line-height: 1.55; white-space: normal; word-wrap: break-word; }
.bl-diff del, del.bl-del { background: var(--bl-del); color: inherit; text-decoration: line-through; text-decoration-thickness: 2px; }
.bl-diff ins, ins.bl-ins { background: var(--bl-ins); color: inherit; text-decoration: underline; text-decoration-thickness: 2px; }

/* ── Change editor ── */
.blc { color: var(--bl-text); }
.blc-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.blc .card { background: var(--bl-card); border: 1px solid var(--bl-line); border-radius: 10px; margin-bottom: 16px; min-width: 0; }
.blc .card-header { padding: 12px 14px; border-bottom: 1px solid var(--bl-line); }
.blc .card-title { margin: 0; font-size: 1rem; }
.blc .card-body { padding: 12px 14px; }
.blc-find { width: 100%; box-sizing: border-box; margin-bottom: 8px; }
.blc-list { max-height: 70vh; overflow-y: auto; }
.blc-row { border-bottom: 1px solid var(--bl-line); padding: 6px 2px; }
.blc-row-head { display: flex; gap: 8px; align-items: baseline; min-width: 0; }
.blc-num { min-width: 52px; font-weight: 700; color: var(--bl-accent); flex: 0 0 auto; }
.blc-head { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.blc-l1 { background: rgba(255, 255, 255, 0.04); }
.blc-l1 .blc-head { font-weight: 700; }
.blc-l3 { padding-left: 14px; }
.blc-l4 { padding-left: 28px; }
.blc-mark { font-size: 0.7rem; padding: 1px 6px; border-radius: 8px; background: rgba(77, 168, 218, 0.25); text-transform: uppercase; letter-spacing: 0.5px; }
.blc-added .blc-mark { background: var(--bl-ins); }
.blc-moved .blc-mark { background: rgba(255, 179, 71, 0.3); }
.blc-acts { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0 0 60px; }
.blc .btn { display: inline-flex; align-items: center; gap: 4px; }
.blc .btn-xs { padding: 3px 8px; font-size: 0.75rem; min-height: 28px; }
.blc .btn-ghost { background: transparent; border: 1px solid var(--bl-line); color: var(--bl-text); border-radius: 6px; cursor: pointer; }
.blc .btn-ghost:hover { background: rgba(255, 255, 255, 0.06); }
.blc .blc-danger { color: var(--bl-danger); }
.blc-edit-list { margin: 0; padding-left: 1.4em; }
.blc-edit-list li { margin-bottom: 6px; }
.blc-edit-list li .btn { margin-left: 6px; }
.blc-problems { border: 1px solid var(--bl-danger); background: rgba(255, 107, 107, 0.1); border-radius: 6px; padding: 8px 10px; margin-bottom: 10px; }
.blc-problems p { margin: 0 0 4px; }
.blc-passmark { margin: 0 0 10px; }
.blc-renum, .blc-motion { margin-top: 10px; }
.blc-renum summary, .blc-motion summary { cursor: pointer; font-weight: 600; }
.blc-motion pre { white-space: pre-wrap; font-family: inherit; background: var(--bl-bg); border: 1px solid var(--bl-line); border-radius: 6px; padding: 8px; }
.blc .text-muted { color: var(--bl-muted); }

/* ── Pop ups: close only on the X ── */
body.bl-modal-open { overflow: hidden; }
.bl-modal { position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, 0.65); display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; overflow-y: auto; }
.bl-modal-box { width: 760px; max-width: 100%; background: var(--bl-card); color: var(--bl-text); border: 1px solid var(--bl-line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); min-width: 0; }
.bl-modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--bl-line); }
.bl-modal-head h3 { margin: 0; font-size: 1.05rem; min-width: 0; overflow-wrap: anywhere; }
.bl-modal-x { flex: 0 0 auto; width: 38px; height: 38px; border: 1px solid var(--bl-line); border-radius: 8px; background: transparent; color: var(--bl-text); font-size: 1.1rem; cursor: pointer; }
.bl-modal-body { padding: 14px 16px; }
.bl-modal-body .form-group { margin-bottom: 12px; }
.bl-modal-body label { display: block; margin-bottom: 4px; font-weight: 600; }
.bl-modal-body .form-control { width: 100%; box-sizing: border-box; }
.bl-modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--bl-line); }
.bl-modal-foot:empty { display: none; }
.bl-modal .bl-check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }

@media (max-width: 900px) {
    .blc-cols { grid-template-columns: minmax(0, 1fr); }
    .blc-list { max-height: 50vh; }
}
@media (max-width: 480px) {
    .blc-acts { margin-left: 0; }
    .bl-modal { padding: 8px; }
    .bl-ed-btn { min-width: 30px; height: 30px; padding: 0 4px; }
}
