:root {
    /* Catppuccin Frappé */
    --base: #303446;
    --mantle: #292c3c;
    --crust: #232634;
    --surface0: #414559;
    --surface1: #51576d;
    --surface2: #626880;
    --overlay0: #737994;
    --overlay1: #838ba7;
    --text: #c6d0f5;
    --subtext0: #a5adce;
    --mauve: #ca9ee6;
    --yellow: #e5c890;
    --green: #a6d189;
    --red: #e78284;

    --font-body: "CaskaydiaCove Nerd Font", "Cascadia Code", "JetBrains Mono", monospace;

    --rail-collapsed: 56px;
    --rail-expanded: 170px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    font-family: var(--font-body);
    background: var(--crust);
    color: var(--text);
}

.app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ================= RAIL ================= */
.rail {
    width: var(--rail-collapsed);
    background: var(--mantle);
    border-right: 1px solid var(--surface0);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding: 10px 8px;
    gap: 6px;
    flex-shrink: 0;
    overflow: hidden;
    transition: width 0.18s ease;
}

.rail.expanded {
    width: var(--rail-expanded);
}

.rail__toggle {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--overlay0);
    font-size: 1rem;
    cursor: pointer;
    margin-bottom: 8px;
}

.rail__toggle:hover {
    background: var(--surface0);
    color: var(--text);
}

.rail__icon {
    display: flex;
    align-items: center;
    gap: 12px;
    height: 36px;
    padding: 0 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--overlay0);
    font-size: 1rem;
    font-family: var(--font-body);
    cursor: pointer;
    white-space: nowrap;
}

.rail__icon:hover {
    background: var(--surface0);
    color: var(--text);
}

.rail__icon.active {
    background: var(--surface1);
    color: var(--mauve);
}

.rail__icon-glyph {
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.rail__icon-label {
    font-size: 0.8rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.rail.expanded .rail__icon-label {
    opacity: 1;
}

/* ================= CONTENT ================= */
.content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* ================= TOPBAR ================= */
.topbar {
    height: 56px;
    background: var(--mantle);
    border-bottom: 1px solid var(--surface0);
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 24px;
    flex-shrink: 0;
}

.topbar__field {
    display: flex;
    flex-direction: column;
    line-height: 1.3;
}

.topbar__field--status {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}

.topbar__label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--overlay0);
}

.topbar__value {
    font-size: 0.85rem;
    color: var(--text);
}

.topbar__code {
    letter-spacing: 0.12em;
    color: var(--yellow);
    font-weight: 600;
    cursor: pointer;
}

.topbar__code:hover {
    text-decoration: underline;
}

.topbar__status {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--red);
    flex-shrink: 0;
}

.topbar__status.connected {
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

.btn-ghost {
    background: transparent;
    border: 1px solid var(--surface1);
    color: var(--subtext0);
    border-radius: 6px;
    padding: 7px 14px;
    font-family: var(--font-body);
    font-size: 0.8rem;
    cursor: pointer;
}

.btn-ghost:hover {
    background: var(--surface0);
    color: var(--text);
}

.btn-save {
    margin-left: auto;
    background: var(--yellow);
    color: var(--crust);
    border: none;
    border-radius: 6px;
    padding: 8px 18px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
}

.btn-save:hover {
    filter: brightness(1.08);
}

.btn-save.saved {
    background: var(--green);
}

/* ================= PANES (Editor view) ================= */
.panes {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    border-right: 1px solid var(--surface0);
}

.pane:last-child {
    border-right: none;
}

.pane__label {
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--overlay0);
    padding: 8px 12px;
    border-bottom: 1px solid var(--surface0);
    flex-shrink: 0;
}

.pane__body {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.pane__lines {
    padding: 10px 8px;
    text-align: right;
    color: var(--overlay0);
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre;
    user-select: none;
    border-right: 1px solid var(--surface0);
}

.pane__code {
    position: relative;
    flex: 1;
    overflow: hidden;
}

.pane__highlight {
    position: absolute;
    inset: 0;
    margin: 0;
    padding: 10px 12px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
    pointer-events: none;
    color: var(--text);
    background: transparent;
}

.pane__input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    resize: none;
    border: none;
    outline: none;
    background: transparent;
    color: transparent;
    caret-color: var(--text);
    font-family: var(--font-body);
    font-size: 0.85rem;
    line-height: 1.5;
    padding: 10px 12px;
    white-space: pre-wrap;
    word-break: break-word;
    overflow: auto;
}

/* ---- ngjyrat e sintaksës (Catppuccin Frappé) ---- */
.tok-key     { color: var(--mauve); }
.tok-str     { color: var(--green); }
.tok-num     { color: var(--peach, #ef9f76); }
.tok-com     { color: var(--overlay0); font-style: italic; }
.tok-fn      { color: var(--blue, #8caaee); }
.tok-punct   { color: var(--subtext0); }
.tok-sel     { color: var(--yellow); }
.tok-prop    { color: var(--blue, #8caaee); }

.pane__input::placeholder {
    color: var(--overlay0);
    font-style: italic;
}

/* ================= REPLACEMENT VIEW ================= */
.replacement {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    text-align: center;
    height: 100%;
    max-width: 600px;
    margin: 0 auto;
    padding-top: 40px;
}

.replacement__title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--mauve);
    margin-bottom: 6px;
}

.replacement__hint {
    font-size: 0.8rem;
    color: var(--overlay0);
    margin-bottom: 20px;
}

.replacement__rows {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.replace-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.replace-row__field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.replace-row__field label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--overlay0);
}

.replace-row__field input {
    background: var(--mantle);
    border: 1px solid var(--surface0);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.85rem;
    padding: 8px 10px;
    outline: none;
}

.replace-row__field input:focus {
    border-color: var(--mauve);
}

/* ---------- path-i i xpath-it të gjetur, nën fushën "Gjej" ---------- */
/* ---------- rreshti i XPath-it: fushat (1 rresht fiks) + path-i poshtë (rresht i vet, qendër) ---------- */
.xpath-row-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.xpath-path-display {
    font-family: monospace;
    font-size: 0.62rem;
    color: var(--overlay0);
    opacity: 0.75;
    text-align: center;
    white-space: nowrap;
    overflow-x: auto;
}

.replace-row__remove {
    align-self: flex-end;
    width: 34px;
    height: 34px;
    border: 1px solid var(--surface0);
    border-radius: 6px;
    background: transparent;
    color: var(--red);
    font-size: 1rem;
    cursor: pointer;
    flex-shrink: 0;
}

.replace-row__remove:hover {
    background: var(--surface0);
}

/* ---------- fusha e numrit "Rasti #" (occurrence) — bosh/0 = të gjitha ---------- */
.replace-row__field--narrow {
    flex: 0 0 74px;
}

.replace-occurrence {
    width: 100%;
    -moz-appearance: auto;
    appearance: auto;
}

.replace-occurrence::placeholder {
    font-size: 0.7rem;
}

.replacement__actions {
    display: flex;
    gap: 12px;
}


/* ================= REFERENCE PANEL (Foto reale / Live DOM / elementet) ================= */
.xr-divider {
    width: 100%;
    max-width: 900px;
    margin: 28px auto 20px;
    border: none;
    border-top: 1px solid var(--surface0);
}

.ref-panel {
    max-width: 900px;
    margin: 0 auto;
    text-align: left;
}

.ref-panel__title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--mauve);
    margin-bottom: 14px;
}

/* ---- kërkimi ---- */
.ref-search {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.ref-search input {
    flex: 1;
    background: var(--mantle);
    border: 1px solid var(--surface0);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.85rem;
    padding: 8px 10px;
    outline: none;
}

.ref-search input:focus {
    border-color: var(--mauve);
}

.ref-occurrence-input {
    flex: 0 0 150px !important;
}

/* ---- rreshti i path-it + shigjetat ---- */
.ref-path-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 10px;
}

.ref-path-input {
    flex: 1;
    font-family: monospace;
    font-size: 0.78rem;
    color: var(--yellow);
    background: var(--mantle);
    border: 1px solid var(--surface0);
    border-radius: 6px;
    padding: 8px 10px;
    outline: none;
}

.ref-path-input:focus {
    border-color: var(--mauve);
}

.ref-arrow {
    width: 32px;
    height: 32px;
    flex-shrink: 0;
    border: 1px solid var(--surface0);
    border-radius: 6px;
    background: transparent;
    color: var(--subtext0);
    cursor: pointer;
    font-size: 0.85rem;
}

.ref-arrow:hover {
    background: var(--surface0);
    color: var(--text);
}

/* ---- statusi ---- */
.refstatus {
    min-height: 18px;
    font-size: 0.78rem;
    color: var(--overlay0);
    margin-bottom: 10px;
}

.refstatus--ok   { color: var(--green); }
.refstatus--bad  { color: var(--red); }
.refstatus--wait { color: var(--yellow); }

/* ---- meta info ---- */
.ref-meta {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 16px;
    font-size: 0.72rem;
}

.ref-meta__item {
    background: var(--mantle);
    border: 1px solid var(--surface0);
    border-radius: 6px;
    padding: 6px 8px;
    overflow: hidden;
}

.ref-meta__item span {
    display: block;
    color: var(--overlay0);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.62rem;
    margin-bottom: 2px;
}

.ref-meta__item b {
    color: var(--text);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.ref-meta__item--wide {
    grid-column: span 4;
}

@media (max-width: 720px) {
    .ref-meta { grid-template-columns: repeat(2, 1fr); }
    .ref-meta__item--wide { grid-column: span 2; }
}

/* ---- trupi: imazhi/live majtas, lista djathtas ---- */
.ref-body {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 18px;
    align-items: start;
}

/* KRITIKE: pa min-width:0, kolonat e grid-it rriten sipas përmbajtjes —
   një rresht tabele 1082px i gjerë e shpërthente layout-in dhe e shtynte
   panelin e parapamjes jashtë ekranit */
.ref-preview,
.ref-items-panel {
    min-width: 0;
    overflow: hidden;
}

@media (max-width: 800px) {
    .ref-body { grid-template-columns: 1fr; }
}

.ref-preview__box {
    position: relative;
    background: var(--mantle);
    border: 1px solid var(--surface0);
    border-radius: 8px;
    min-height: 240px;
    max-height: 420px;
    max-width: 100%;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
}

#ref-live {
    width: 100%;
    min-width: 0;
    min-height: 380px;
    border: none;
    background: #fff;
}

.ref-preview-empty {
    font-size: 0.78rem;
    color: var(--overlay0);
    text-align: center;
    padding: 30px 16px;
}

/* ---- lista e elementeve të editueshme ---- */
.ref-items-panel {
    display: flex;
    flex-direction: column;
    min-height: 240px;
    max-height: 420px;
}

.ref-items__head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.ref-items__head input {
    flex: 1;
    background: var(--mantle);
    border: 1px solid var(--surface0);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.78rem;
    padding: 6px 9px;
    outline: none;
}

.ref-items__head span {
    font-size: 0.7rem;
    color: var(--overlay0);
    white-space: nowrap;
}

.ref-items {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-right: 4px;
}

.refitem__empty {
    font-size: 0.78rem;
    color: var(--overlay0);
    padding: 16px 4px;
    text-align: center;
}

.refitem {
    background: var(--mantle);
    border: 1px solid var(--surface0);
    border-radius: 8px;
    padding: 8px 10px;
}

.refitem--on {
    border-color: var(--mauve);
}

.refitem__head {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 6px;
}

.refitem__kind {
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--surface0);
    color: var(--subtext0);
    flex-shrink: 0;
}

.refitem__kind--text  { color: var(--blue, var(--text)); }
.refitem__kind--image,
.refitem__kind--bg     { color: var(--green); }
.refitem__kind--attr   { color: var(--yellow); }
.refitem__kind--value  { color: var(--mauve); }
.refitem__kind--html   { color: var(--red); }

.refitem__label {
    flex: 1;
    font-size: 0.75rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.refitem__switch {
    position: relative;
    display: inline-block;
    width: 30px;
    height: 17px;
    flex-shrink: 0;
}

.refitem__switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.refitem__switch span {
    position: absolute;
    inset: 0;
    background: var(--surface0);
    border-radius: 17px;
    transition: background 0.15s ease;
}

.refitem__switch span::before {
    content: '';
    position: absolute;
    width: 13px;
    height: 13px;
    left: 2px;
    top: 2px;
    background: var(--text);
    border-radius: 50%;
    transition: transform 0.15s ease;
}

.refitem__switch input:checked + span {
    background: var(--mauve);
}

.refitem__switch input:checked + span::before {
    transform: translateX(13px);
}

.refitem__thumb {
    margin-bottom: 6px;
}

.refitem__thumb img {
    max-width: 100%;
    max-height: 70px;
    border-radius: 4px;
    border: 1px solid var(--surface0);
}

.refitem__orig {
    font-size: 0.72rem;
    color: var(--overlay0);
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.refitem__orig i {
    font-style: italic;
}

.refitem__editor {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.refitem__input {
    flex: 1;
    background: var(--base);
    border: 1px solid var(--surface0);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.78rem;
    padding: 6px 8px;
    outline: none;
    resize: vertical;
}

.refitem__input:focus {
    border-color: var(--mauve);
}

.refitem__blank {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border: 1px solid var(--surface0);
    border-radius: 6px;
    background: transparent;
    color: var(--red);
    cursor: pointer;
}

.refitem__blank:hover {
    background: var(--surface0);
}

.refitem__path {
    font-family: monospace;
    font-size: 0.62rem;
    color: var(--overlay0);
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- ngjyrat për çdo element (tekst / sfond) ---- */
.refitem__colors {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.refitem__colors label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.68rem;
    color: var(--overlay0);
    text-transform: none;
    letter-spacing: 0;
    margin: 0;
}

.refitem__colors input[type="color"] {
    width: 28px;
    height: 22px;
    padding: 0;
    border: 1px solid var(--surface0);
    border-radius: 4px;
    background: transparent;
    cursor: pointer;
}

.refitem__color-clear {
    margin-left: auto;
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    border: 1px solid var(--surface0);
    border-radius: 4px;
    background: transparent;
    color: var(--red);
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1;
}

.refitem__color-clear:hover {
    background: var(--surface0);
}

/* ---- veprimet fund ---- */
.ref-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
}

/* ---- "Krijo të re" + lista e pozicioneve ---- */
.ref-create {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.ref-position {
    background: var(--mantle);
    border: 1px solid var(--surface0);
    border-radius: 6px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.78rem;
    padding: 7px 9px;
    outline: none;
    max-width: 200px;
}

.ref-position:focus {
    border-color: var(--mauve);
}

#ref-create-btn.saved {
    border-color: var(--green);
    color: var(--green);
}

/* ================= KOLONA E RREGULLAVE (RULES) ================= */
.rules {
    width: 260px;
    flex-shrink: 0;
    background: var(--mantle);
    border-right: 1px solid var(--surface0);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rules__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 14px 12px 10px;
}

.rules__title {
    font-size: 0.68rem;
    letter-spacing: 0.06em;
    color: var(--overlay0);
    text-transform: uppercase;
}

.rules__find {
    margin: 0 12px 10px;
    background: var(--base);
    border: 1px solid var(--surface0);
    border-radius: 16px;
    color: var(--text);
    font-family: var(--font-body);
    font-size: 0.76rem;
    padding: 7px 12px;
    outline: none;
}

.rules__find:focus {
    border-color: var(--mauve);
}

.rules__list {
    flex: 1;
    overflow-y: auto;
    padding: 0 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rules__empty {
    font-size: 0.74rem;
    color: var(--overlay0);
    text-align: center;
    padding: 20px 8px;
    line-height: 1.5;
}

/* ---- një rregull ---- */
.rule-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 8px;
    border-radius: 6px;
    cursor: pointer;
}

.rule-row:hover {
    background: var(--surface0);
}

.rule-row--active {
    background: var(--surface0);
    box-shadow: inset 2px 0 0 var(--mauve);
}

.rule-row__main {
    flex: 1;
    min-width: 0;
}

.rule-row__name {
    font-size: 0.8rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rule-row__pattern {
    font-size: 0.66rem;
    color: var(--overlay0);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}

.rule-row__switch {
    position: relative;
    display: inline-block;
    width: 30px;
    height: 17px;
    flex-shrink: 0;
}

.rule-row__switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.rule-row__switch span {
    position: absolute;
    inset: 0;
    background: var(--surface1, var(--surface0));
    border: 1px solid var(--overlay0);
    border-radius: 17px;
    transition: background 0.15s ease;
}

.rule-row__switch span::before {
    content: '';
    position: absolute;
    width: 11px;
    height: 11px;
    left: 2px;
    top: 2px;
    background: var(--overlay0);
    border-radius: 50%;
    transition: transform 0.15s ease, background 0.15s ease;
}

.rule-row__switch input:checked + span {
    background: var(--text);
    border-color: var(--text);
}

.rule-row__switch input:checked + span::before {
    transform: translateX(13px);
    background: var(--mantle);
}

.rule-row__remove {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border: none;
    border-radius: 4px;
    background: transparent;
    color: var(--overlay0);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    opacity: 0;
}

.rule-row:hover .rule-row__remove {
    opacity: 1;
}

.rule-row__remove:hover {
    background: var(--red);
    color: var(--mantle);
}

/* ---- treguesi i rregullit aktiv te topbar ---- */
.topbar__field--rule {
    min-width: 0;
}

.topbar__rule {
    color: var(--mauve);
    font-size: 0.82rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 220px;
    display: block;
}
/* ================= EKRANI I KYÇJES ================= */
/* ================= NGJYROSJA E SINTAKSES ================= */
/* Catppuccin Frappé — variabla, stringje, numra, fjalë kyçe */
.tok-key     { color: #ca9ee6; }              /* fjalë kyçe (const, if...) — mauve */
.tok-string  { color: #a6d189; }              /* stringje — green */
.tok-num     { color: #ef9f76; }              /* numra — peach */
.tok-comment { color: #737994; font-style: italic; } /* komente — overlay */
.tok-fn      { color: #8caaee; }              /* funksione — blue */
.tok-prop    { color: #e5c890; }              /* veti CSS — yellow */
/* ================= APLIKO GJITHÇKA ================= */
.applyall {
    margin: 20px 0 28px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.btn-applyall {
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    background: var(--mauve);
    color: var(--mantle);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    cursor: pointer;
    transition: filter 0.15s ease, background 0.15s ease;
}

.btn-applyall:hover {
    filter: brightness(1.08);
}

.btn-applyall.saved {
    background: var(--green);
}

.applyall__hint {
    font-size: 0.7rem;
    color: var(--overlay0);
    text-align: center;
}

/* ================= PANELE TË SHUMTA REFERENCASH ================= */
#ref-panels .ref-panel {
    margin-bottom: 18px;
}

#ref-panels .ref-panel + .ref-panel {
    border-top: 1px solid var(--surface0);
    padding-top: 18px;
}

.ref-panel__title [data-el="ref-num"] {
    color: var(--overlay0);
    font-weight: 400;
}

.btn-remove-ref {
    background: transparent;
    border: 1px solid var(--surface0);
    border-radius: 6px;
    color: var(--red);
    font-family: var(--font-body);
    font-size: 0.76rem;
    padding: 8px 14px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.btn-remove-ref:hover {
    background: var(--red);
    color: var(--mantle);
    border-color: var(--red);
}

.refadd {
    display: flex;
    justify-content: center;
    margin: 6px 0 18px;
}

.btn-addref {
    padding: 10px 22px;
    border-style: dashed;
}