/* ============================================ */
/* SRE TOOLKIT - DESIGN SYSTEM                  */
/*                                             */
/* Soft dark is the default: a lifted slate     */
/* rather than near-black, so unchanged lines    */
/* and secondary text stay readable.             */
/* ============================================ */

:root {
    /* Surfaces - deliberately lifted off pure black */
    --bg: #171a21;
    --bg-elevated: #1d212a;
    --card: #222732;
    --card-hover: #2a3040;
    --inset: #1a1e26;

    /* Borders */
    --border: #323a4a;
    --border-strong: #414b60;

    /* Text */
    --text: #e7eaf0;
    --text-muted: #9aa4b8;
    --text-dim: #6f7a8e;

    /* Accent - azure. primary is a fill and carries white text (5.9:1);
       accent-text is the same hue lightened for text on neutral surfaces. */
    --primary: #0369a1;
    --primary-hover: #075985;
    --primary-contrast: #ffffff;
    --primary-soft: rgba(56, 189, 248, 0.16);
    --accent-text: #38bdf8;
    --ring: rgba(56, 189, 248, 0.40);

    /* Status: the plain tones are for fills/borders, the -text tones are for
       text and chips sitting on the soft tints. */
    --success: #34d399;
    --success-text: #34d399;
    --success-soft: rgba(52, 211, 153, 0.14);
    --warning: #fbbf24;
    --warning-text: #fbbf24;
    --warning-fill: #fbbf24;
    --warning-soft: rgba(251, 191, 36, 0.14);
    --danger: #f87171;
    --danger-text: #fb8f8f;
    --danger-fill: #c93a3a;   /* solid button fill: white text needs >=4.5 */
    --danger-soft: rgba(248, 113, 113, 0.14);
    --info: #60a5fa;
    --info-soft: rgba(96, 165, 250, 0.14);

    /* Code / mono surfaces */
    --code-bg: #1a1e26;
    --code-text: #d7dce6;
    --code-border: #2f3644;

    /* Diff */
    --diff-eq-bg: #2b3240;
    --diff-eq-text: #dde3ec;
    --diff-eq-gutter: #9aa5ba;
    --diff-blank-bg: #161a21;
    --diff-add-bg: #12352b;
    --diff-add-text: #6ee7b7;
    --diff-add-gutter: #34d399;
    --diff-del-bg: #3b2028;
    --diff-del-text: #fca5a5;
    --diff-del-gutter: #f87171;

    /* Shape */
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 7px;
    --radius-pill: 999px;

    /* Ambient washes behind the page. Kept under 8% alpha: they are here to
       stop the background reading as a flat slab, not to tint content. */
    --ambient-1: rgba(56, 189, 248, 0.07);
    --ambient-2: rgba(129, 140, 248, 0.06);

    /* Hairline top highlight inside raised surfaces. */
    --inset-highlight: rgba(255, 255, 255, 0.05);

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.28);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.30);
    --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.42);
    --shadow-raised: 0 6px 20px rgba(0, 0, 0, 0.34);

    color-scheme: dark;
}

/* ============================================ */
/* LIGHT MODE                                  */
/* ============================================ */
[data-theme="light"] {
    --bg: #f4f6fa;
    --bg-elevated: #ffffff;
    --card: #ffffff;
    --card-hover: #f7f8fc;
    --inset: #f7f8fc;

    --border: #c8d0de;
    --border-strong: #a3adc2;

    --text: #131722;
    --text-muted: #5b6577;
    --text-dim: #667080;

    --primary: #0369a1;
    --primary-hover: #075985;
    --primary-contrast: #ffffff;
    --primary-soft: rgba(3, 105, 161, 0.10);
    --accent-text: #0369a1;
    --ring: rgba(3, 105, 161, 0.30);

    --success: #047857;
    --success-text: #047857;
    --success-soft: rgba(5, 150, 105, 0.10);
    --warning: #b45309;
    --warning-text: #aa4f09;
    /* Lightened for the hover state: it still carries #1b1f28 text, and the
       default --warning only managed 3.28:1 against it. */
    --warning-fill: #d97706;
    --warning-soft: rgba(180, 83, 9, 0.10);
    --danger: #dc2626;
    --danger-text: #cd2121;
    --danger-fill: #c81e1e;
    --danger-soft: rgba(220, 38, 38, 0.10);
    --info: #2563eb;
    --info-soft: rgba(37, 99, 235, 0.12);

    --code-bg: #f7f8fc;
    --code-text: #1e2430;
    --code-border: #e2e6ef;

    --diff-eq-bg: #ffffff;
    --diff-eq-text: #232936;
    --diff-eq-gutter: #6b7686;
    --diff-blank-bg: #eef1f6;
    --diff-add-bg: #e3f8ec;
    --diff-add-text: #046c4e;
    --diff-add-gutter: #059669;
    --diff-del-bg: #fdeaea;
    --diff-del-text: #a32020;
    --diff-del-gutter: #dc2626;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.06);
    --shadow: 0 2px 8px rgba(16, 24, 40, 0.08);
    --shadow-lg: 0 12px 32px rgba(16, 24, 40, 0.14);
    --shadow-raised: 0 6px 20px rgba(16, 24, 40, 0.10);

    --ambient-1: rgba(3, 105, 161, 0.05);
    --ambient-2: rgba(99, 102, 241, 0.04);
    --inset-highlight: rgba(16, 24, 40, 0.04);

    --radius-pill: 999px;

    color-scheme: light;
}

/* ============================================ */
/* BASE                                        */
/* ============================================ */
* { box-sizing: border-box; }

html, body {
    background-color: var(--bg);
    /* Two soft washes anchored off the top corners. Fixed so the glow stays put
       while the page scrolls instead of sliding with the content. */
    background-image:
        radial-gradient(1100px 620px at 12% -8%, var(--ambient-1), transparent 62%),
        radial-gradient(900px 520px at 92% -4%, var(--ambient-2), transparent 60%);
    background-repeat: no-repeat;
    background-attachment: fixed;
    color: var(--text);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    /* Inter's optional glyphs: nicer 1/l/I, and lining figures everywhere. */
    font-feature-settings: "cv02", "cv03", "cv04", "cv11", "tnum";
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color .2s ease, color .2s ease;
}

/* Reserve the scrollbar gutter so switching to a taller page cannot shift the
   layout sideways. */
html { scrollbar-gutter: stable; }

::selection { background: var(--primary-soft); }

:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

/* ============================================ */
/* LAYOUT                                      */
/* ============================================ */
.container-fluid {
    width: 100%;
    padding: 28px 20px 56px;
    margin: 0 auto;
    max-width: none !important;
}

/* ============================================ */
/* HEADER                                      */
/* ============================================ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

/* The auth cluster is a row of its own. Without this it stays on one line and
   pushes the logout button past the right edge on narrow screens. */
.page-header > .d-flex {
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
}

h1 {
    display: flex;
    align-items: center;
    gap: 18px;
    font-size: 2rem;
    font-weight: 680;
    letter-spacing: -0.025em;
    margin: 0;
    color: var(--text);
}

.logo-tile {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    flex: 0 0 80px;
    border-radius: 20px;
    background:
        radial-gradient(120% 120% at 30% 20%, var(--primary-soft), transparent 70%),
        linear-gradient(145deg, var(--card-hover), var(--bg-elevated));
    border: 1px solid var(--border-strong);
    box-shadow: var(--shadow);
}

.logo-tile img {
    height: 72px;
    width: 72px;
    object-fit: contain;
}

.brand-text small {
    display: block;
    font-size: 0.82rem;
    font-weight: 450;
    color: var(--text-muted);
    letter-spacing: 0;
    margin-top: 2px;
}

/* ============================================ */
/* CARDS                                       */
/* ============================================ */
.card {
    background: var(--card);
    /* Bootstrap sets .card { color: var(--bs-body-color) }, which is #212529 —
       correct on a light card, but 1.03:1 on ours in dark mode. Nothing sets
       it explicitly today, so text added directly inside a card would be
       invisible. Claim the colour for the surface. */
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    /* The inset hairline is what gives the card a lit top edge instead of a
       flat border. */
    box-shadow: var(--shadow-sm), inset 0 1px 0 var(--inset-highlight);
    overflow: hidden;
    margin-bottom: 20px;
    width: 100%;
    transition: border-color .18s ease, box-shadow .18s ease,
                transform .18s ease;
}

.card:hover {
    border-color: var(--border-strong);
    box-shadow: var(--shadow-raised), inset 0 1px 0 var(--inset-highlight);
}

.card-header {
    background: var(--bg-elevated);
    color: var(--text);
    border-bottom: 1px solid var(--border);
    padding: 13px 18px;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 0.01em;
}

/* Row count shown beside an inventory table's title. It starts hidden and is
   revealed once the fetch that renders the table has succeeded, so it never
   displays "0" while the inventory is still loading or when the user is not
   allowed to see it. */
.inventory-count {
    display: inline-block;
    margin-left: 8px;
    padding: 1px 8px;
    border-radius: 10px;
    background: var(--bg-subtle, rgba(127, 127, 127, 0.12));
    border: 1px solid var(--border);
    color: var(--text-muted, inherit);
    font-weight: 600;
    font-size: 12px;
    font-variant-numeric: tabular-nums;
    vertical-align: 1px;
}

.inventory-count[hidden] { display: none; }

/* Active / Expired switch in an inventory card header: a smaller copy of the
   main tab control, so it reads as the same kind of choice one level down. */
.inv-subtabs {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
}

.inv-subtab {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    color: var(--text-muted);
    font-weight: 550;
    font-size: 12.5px;
    padding: 4px 12px;
    cursor: pointer;
    transition: color .18s ease, background-color .18s ease, border-color .18s ease;
}

.inv-subtab:hover { background: var(--card-hover); color: var(--text); }

.inv-subtab.active,
.inv-subtab.active:hover {
    background: var(--primary-soft);
    border-color: var(--ring);
    color: var(--accent-text);
    font-weight: 600;
}

.inv-subtab:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }

/* The count inside a sub-tab sits closer than beside the card title. */
.inv-subtab .inventory-count { margin-left: 6px; padding: 0 6px; font-size: 11px; }

/* Placeholder row for an inventory table with nothing in it. */
.inventory-empty td { text-align: center; padding: 18px; }

/* GitLab and Vault links in the inventories' Location columns. */
.table td a { color: var(--accent-text); text-decoration: none; }
.table td a:hover { text-decoration: underline; }
.table td a:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; border-radius: 2px; }

.card-body {
    padding: 20px;
    width: 100%;
    overflow-x: auto;
}

.card-body p-0 { padding: 0; }

/* ============================================ */
/* FORM CONTROLS                               */
/* ============================================ */
.form-label {
    font-size: 12.5px;
    font-weight: 550;
    color: var(--text-muted);
    margin-bottom: 6px;
    letter-spacing: 0.01em;
}

.form-control {
    background: var(--inset) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: none !important;
    width: 100%;
    padding: 9px 13px;
    font-size: 14px;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}

.form-control:hover { border-color: var(--border-strong) !important; }

.form-control:focus {
    background: var(--card) !important;
    color: var(--text) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px var(--ring) !important;
}

.form-control::placeholder { color: var(--text-dim); }

textarea.form-control {
    resize: vertical;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 12.5px;
    line-height: 1.65;
    width: 100%;
}

.form-control[type="file"] {
    padding: 7px 11px;
    font-size: 13px;
    color: var(--text-muted);
}

.form-control[type="file"]::file-selector-button {
    background: var(--card-hover);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    padding: 5px 12px;
    margin-right: 12px;
    font-size: 13px;
    font-weight: 550;
    cursor: pointer;
    transition: background-color .15s ease;
}

.form-control[type="file"]::file-selector-button:hover {
    background: var(--primary-soft);
    border-color: var(--primary);
}

/* ============================================ */
/* BUTTONS                                     */
/* ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-weight: 560;
    border-radius: var(--radius-sm);
    transition: background-color .15s ease, border-color .15s ease,
                color .15s ease, transform .1s ease;
}

.btn:active { transform: translateY(1px); }

.btn-primary {
    /* background-color is a deliberate fallback under the gradient, so the fill
       is still correct if the image fails, and the worst-case contrast is the
       --primary token the white text was chosen against. */
    background-color: var(--primary);
    background-image: linear-gradient(180deg, var(--primary-hover), var(--primary));
    border: 1px solid var(--primary);
    color: var(--primary-contrast);
    padding: 9px 20px;
    box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    background-image: linear-gradient(180deg, var(--primary), var(--primary-hover));
    border-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.btn-primary:active { transform: translateY(0); }
.btn-primary:focus { box-shadow: 0 0 0 3px var(--ring); }

.btn-secondary,
.btn-outline-secondary {
    background: var(--card-hover);
    border: 1px solid var(--border-strong);
    color: var(--text);
    padding: 9px 20px;
}

.btn-secondary:hover,
.btn-outline-secondary:hover {
    background: var(--bg-elevated);
    border-color: var(--primary);
    color: var(--text);
    transform: translateY(-1px);
}

.btn-outline-info {
    background: transparent;
    border: 1px solid var(--info);
    color: var(--info);
    padding: 5px 13px;
    font-size: 13px;
}

.btn-outline-info:hover { background: var(--info-soft); color: var(--accent-text); }

.btn-danger {
    background: var(--danger-fill);
    border: 1px solid var(--danger-fill);
    color: #fff;
}

.btn-danger:hover { filter: brightness(1.12); }

.btn-warning {
    background: var(--warning-soft);
    border: 1px solid var(--warning);
    /* --warning-text, not --warning: on a light surface --warning over
       --warning-soft only reached 4.38:1. The -text tone is the one chosen for
       text on the soft tint, and is the same value in dark mode. */
    color: var(--warning-text);
    padding: 5px 12px;
    font-size: 12.5px;
    font-weight: 580;
}

/* The hover fill keeps dark text, so the fill has to stay light enough for that
   text to clear AA. In light mode that means a deeper amber than --warning. */
.btn-warning:hover { background: var(--warning-fill); color: #1b1f28; }

.btn-sm { padding: 5px 12px; font-size: 12.5px; }

/* Theme toggle */
.btn-theme {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 15px;
    line-height: 1;
}

.btn-theme:hover {
    background: var(--card-hover);
    border-color: var(--primary);
    color: var(--text);
}

.btn-theme .icon-sun { display: none; }
[data-theme="light"] .btn-theme .icon-sun { display: inline; }
[data-theme="light"] .btn-theme .icon-moon { display: none; }

/* ============================================ */
/* TABLES                                      */
/* ============================================ */
.table {
    width: 100% !important;
    table-layout: fixed;
    margin-bottom: 0;
    border-collapse: separate;
    border-spacing: 0;
    color: var(--text);
    font-size: 13.5px;
}

.table tr:hover td { background: var(--card-hover) !important; }

.table td, .table th {
    padding: 11px 12px;
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
}

.table thead th {
    background: var(--bg-elevated);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table tbody td {
    border-bottom: 1px solid var(--border);
    /* Rows fade between states instead of snapping, which reads as a smoother
       table on a large inventory. */
    transition: background-color .14s ease, color .14s ease;
}
.table tbody tr:last-child td { border-bottom: none; }

/* Bootstrap .table-dark / .table variants must not reintroduce dark surfaces */
.table, .table > :not(caption) > * > * {
    background-color: transparent;
    border-color: var(--border);
    color: var(--text);
}
.table > thead > tr > th {
    background-color: var(--bg-elevated);
    border-bottom-color: var(--border);
    color: var(--text-muted);
}
.table-dark, .table-dark > :not(caption) > * > * {
    --bs-table-bg: transparent;
    --bs-table-color: var(--text);
    --bs-table-border-color: var(--border);
    background-color: transparent;
    color: var(--text);
}

/* ============================================ */
/* EXPIRY STATUS                               */
/* ============================================ */
.table td.expiring-soon,
.table th.expiring-soon,
.expiring-soon {
    color: var(--danger-text) !important;
    font-weight: 650 !important;
}

.table tr:hover td.expiring-soon { color: var(--danger-text) !important; font-weight: 650 !important; }

.expiry-chip {
    display: inline-block;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    background: var(--success-soft);
    color: var(--success-text);
}

.expiry-chip.warn { background: var(--warning-soft); color: var(--warning-text); }
.expiry-chip.crit { background: var(--danger-soft);  color: var(--danger-text); }

/* ============================================ */
/* MULTI-VALUE CELLS                           */
/* ============================================ */
.multi-value-cell {
    padding: 8px !important;
    vertical-align: middle;
    min-width: 150px;
    max-width: 100%;
    overflow: visible !important;
    position: relative;
}

.value-row {
    display: block;
    white-space: normal !important;
    word-break: break-word !important;
    overflow: visible !important;
    text-overflow: clip !important;
    max-width: 100%;
    margin-bottom: 4px;
    text-align: left;
    font-size: 12px;
    line-height: 1.45;
    color: var(--text);
    background-color: transparent;
    padding: 2px 0;
}

.value-row:last-child { margin-bottom: 0; }

.no-data { color: var(--text-muted) !important; font-style: italic; text-align: left; }

.multi-value-cell:hover { overflow-y: auto; max-height: 200px; z-index: 100; cursor: default; }

/* ============================================ */
/* SCROLLBARS                                  */
/* ============================================ */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

.multi-value-cell::-webkit-scrollbar { width: 6px; }
.multi-value-cell::-webkit-scrollbar-track { background: var(--inset); border-radius: 3px; }
.multi-value-cell::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
.multi-value-cell::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* ============================================ */
/* TABLE COLUMN WIDTHS                         */
/* ============================================ */
#certificateTable { table-layout: fixed; width: 100% !important; }

#certificateTable th:nth-child(1),
#certificateTable td:nth-child(1) { width: 14%; min-width: 140px; max-width: 180px; }

#certificateTable th:nth-child(2),
#certificateTable td:nth-child(2) { width: 14%; min-width: 140px; max-width: 180px; }

#certificateTable th:nth-child(3),
#certificateTable td:nth-child(3) { width: 10%; min-width: 100px; }

#certificateTable th:nth-child(4),
#certificateTable td:nth-child(4) { width: 10%; min-width: 100px; }

#certificateTable th:nth-child(5),
#certificateTable td:nth-child(5) { width: 18% !important; min-width: 200px !important; max-width: 350px !important; }

#certificateTable th:nth-child(6),
#certificateTable td:nth-child(6) { width: 25%; min-width: 250px; max-width: 350px; }

#certificateTable th:nth-child(7),
#certificateTable td:nth-child(7) { width: 6%; min-width: 70px; text-align: center; }

#certificateTable th:nth-child(8),
#certificateTable td:nth-child(8) { width: 8%; min-width: 90px; text-align: center; }

#tokenTable th, #tokenTable td { width: 25% !important; min-width: 150px !important; }

#tokenTable th:nth-child(4),
#tokenTable td:nth-child(4) { width: 10% !important; min-width: 80px !important; text-align: center; }

#tokenTable th:nth-child(5),
#tokenTable td:nth-child(5) { width: 10% !important; min-width: 90px !important; text-align: center; }

/* ============================================ */
/* SORTABLE HEADERS                            */
/* ============================================ */
.th-sortable {
    cursor: pointer;
    position: relative;
    user-select: none;
    overflow: visible;      /* keep the sort arrow from being clipped */
    white-space: nowrap;
}
.th-sortable::after { content: " \2195"; color: var(--text-dim); font-size: 0.85em; margin-left: 0.45em; }
.th-sortable:hover { background-color: var(--card-hover) !important; color: var(--text) !important; }
.th-sortable.asc::after { content: " \2191"; color: var(--primary); }
.th-sortable.desc::after { content: " \2193"; color: var(--primary); }

/* ============================================ */
/* NAV TABS - pill segment                     */
/* ============================================ */
/* A segmented control rather than an underlined tab bar. The active item is a
   tinted surface with a hairline ring rather than a solid saturated fill: it
   reads as "selected" without shouting, and the tint is the same accent family
   the rest of the page uses, so contrast stays well clear of AA. */
.nav-tabs {
    border-bottom: none;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    padding: 5px;
    gap: 3px;
    display: flex;
    flex-wrap: wrap;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm), inset 0 1px 0 var(--inset-highlight);
}

.nav-tabs .nav-item { margin: 0; }

/* Pin the inventory tabs to the right edge of the control, so the public tools
   keep one stable left-hand group and the two role-gated tabs sit apart from
   them instead of trailing the list. The auto margin is on the first of the
   pair only: a second one would divide the free space between both items and
   push the second one out past the edge rather than beside its sibling. */
.nav-tabs .nav-item-end { margin-left: auto; }

.nav-tabs .nav-link {
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-pill);
    color: var(--text-muted);
    font-weight: 550;
    font-size: 13.5px;
    padding: 8px 16px;
    /* Lift on hover so the control feels physical. The transform is what makes
       it read as modern rather than static. */
    transition: color .18s ease, background-color .18s ease,
                border-color .18s ease, transform .18s ease,
                box-shadow .18s ease;
}

.nav-tabs .nav-link:hover {
    background: var(--card-hover);
    color: var(--text);
    transform: translateY(-1px);
}

.nav-tabs .nav-link:active { transform: translateY(0); }

.nav-tabs .nav-link.active,
.nav-tabs .nav-link.active:hover {
    background: var(--primary-soft);
    border-color: var(--ring);
    color: var(--accent-text);
    font-weight: 600;
    box-shadow: var(--shadow-sm);
    transform: none;
}

/* ============================================ */
/* ACCORDION                                   */
/* ============================================ */
.accordion { margin-top: 20px; width: 100%; }

.accordion-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm) !important;
    overflow: hidden;
    margin-bottom: 10px;
    width: 100%;
}

.accordion-button {
    background: var(--card);
    color: var(--text);
    font-weight: 570;
    font-size: 14px;
    border: none;
    width: 100%;
    padding: 14px 18px;
}

.accordion-button:not(.collapsed) {
    background: var(--bg-elevated);
    color: var(--text);
}

.accordion-button:focus { box-shadow: none; }
.accordion-button::after { filter: invert(var(--bs-accordion-btn-icon-filter, 0)); }
[data-theme="light"] .accordion-button::after { filter: none; }

.accordion-body {
    background: var(--inset);
    border-top: 1px solid var(--border);
    color: var(--text);
}

/* ============================================ */
/* CODE BLOCKS                                 */
/* ============================================ */
pre {
    background: var(--code-bg) !important;
    color: var(--code-text);
    padding: 15px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--code-border);
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    word-break: break-word;
    margin: 0;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 12.5px;
    line-height: 1.6;
    width: 100%;
}

code {
    color: var(--accent-text);
    background: var(--primary-soft);
    padding: 1px 5px;
    border-radius: 5px;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 0.92em;
}

/* Bootstrap's .form-text resolves --bs-secondary-color against a light body,
   which leaves the hint text nearly invisible on the dark theme. Pin it to the
   themed muted colour so the JSON/YAML notes read the same in both themes. */
.form-text {
    color: var(--text-muted);
}

.form-text code {
    color: var(--accent-text);
    background: var(--primary-soft);
}

/* ============================================ */
/* MODALS                                      */
/* ============================================ */
.modal-content {
    background: var(--card);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    margin: 0 auto;
}

.modal-header, .modal-body, .modal-footer {
    background: transparent;
    border-color: var(--border);
    color: var(--text);
}

.modal-title { font-size: 1.05rem; font-weight: 620; }
.modal-backdrop { background: #0b0d12; }

.bg-dark, .text-white { color: var(--text) !important; }
.bg-dark { background-color: var(--card) !important; }
.bg-dark .form-control, .form-control.bg-dark {
    background: var(--inset) !important;
    color: var(--text) !important;
}

/* ============================================ */
/* BOOTSTRAP OVERRIDES                         */
/* ============================================ */
.navbar, .dropdown-menu { background: var(--card); border-color: var(--border); }
.text-muted { color: var(--text-muted) !important; }

.shadow-sm { box-shadow: var(--shadow-sm) !important; }
.shadow { box-shadow: var(--shadow) !important; }
.shadow-lg { box-shadow: var(--shadow-lg) !important; }

hr { border-color: var(--border); opacity: 1; }

/* ============================================ */
/* DIFF VIEW                                   */
/* ============================================ */
/* One row per visual line, with an independent gutter on each side. */
.dr {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 2px 10px;
    min-height: 22px;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 12.5px;
    line-height: 18px;
    white-space: pre-wrap;
    word-break: break-word;
}

.dr .dg {
    flex: 0 0 44px;
    text-align: right;
    color: var(--diff-eq-gutter);
    user-select: none;
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
}

.dr .dt { flex: 1 1 auto; }

/* Unchanged: lifted surface + bright text, so it is never hard to read. */
.dr.eq { background: var(--diff-eq-bg); }
.dr.eq .dt { color: var(--diff-eq-text); }

/* Filler row where the other side has no line. */
.dr.db { background: var(--diff-blank-bg); }

/* Removed / added */
.dr.del { background: var(--diff-del-bg); }
.dr.del .dt { color: var(--diff-del-text); }
.dr.del .dg { color: var(--diff-del-gutter); }

.dr.ins { background: var(--diff-add-bg); }
.dr.ins .dt { color: var(--diff-add-text); }
.dr.ins .dg { color: var(--diff-add-gutter); }

.diff-pane {
    background: var(--diff-blank-bg);
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 12.5px;
    padding: 6px 0;
    min-height: 120px;
    overflow-x: auto;
}

.diff-split {
    border-right: 1px solid var(--border);
}

@media (max-width: 767px) {
    .diff-split { border-right: none; border-bottom: 1px solid var(--border); }
}

/* ============================================ */
/* NUMBERED VIEW                               */
/* ============================================ */
/* Textarea with a line-number gutter beside it. The textarea does not wrap
   (wrap="off"), so one logical line is exactly one visual row and the numbers
   stay aligned no matter how long a line is. */
.editor {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm, 6px);
    background: var(--code-bg);
    overflow: hidden;
}

.editor .gutter {
    flex: 0 0 auto;
    /* Same fixed height as the textarea and clipped, so a long paste does not
       stretch the editor. The inner block is translated to follow the
       textarea's scroll (see updateGutter). */
    height: 260px;
    max-height: 45vh;
    padding: 10px 8px 10px 10px;
    margin: 0;
    box-sizing: border-box;
    text-align: right;
    color: var(--diff-eq-gutter);
    background: var(--diff-blank-bg);
    border-right: 1px solid var(--border);
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre;
    overflow: hidden;
    user-select: none;
    font-variant-numeric: tabular-nums;
}

.editor .gutter-inner {
    display: block;
    will-change: transform;
}

.editor .gutter-row {
    display: block;
}

/* The line the parser flagged: red wash + red digit, so an error is obvious
   in the editor itself, not only in the output pane. */
.editor .gutter .err {
    color: var(--diff-del-gutter);
    font-weight: 600;
}

.editor textarea.form-control {
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    /* Fixed, taller-than-default box that scrolls internally. The user asked
       for "larger than the default but not that large"; resizing vertically
       was removed so a long paste never grows the pane unbounded. */
    resize: none;
    height: 260px;
    max-height: 45vh;
    padding: 10px 12px;
    font-size: 13px;
    line-height: 1.5;
    white-space: pre;
    overflow: auto;
    box-shadow: none !important;
}

.editor textarea.form-control:focus {
    box-shadow: none !important;
}

/* Reuses the diff row/gutter so a JSON or YAML pane reads like the diff
   viewer. The top-level shape is just the .dr rules; only the scroll box and
   the error highlight are new. */
.numbered {
    background: var(--diff-blank-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 12.5px;
    padding: 6px 0;
    max-height: 420px;
    overflow: auto;
}

/* The line the parser flagged: red wash + red gutter digit, matching the
   removed side of the diff. */
.numbered .dr.err { background: var(--diff-del-bg); }
.numbered .dr.err .dt { color: var(--diff-del-text); }
.numbered .dr.err .dg { color: var(--diff-del-gutter); }

/* A caret placed under the reported column on the error line. */
.numbered .dr .caret {
    color: var(--diff-del-gutter);
    font-weight: 600;
}

/* Clickable error location in the JSON/YAML error panel: the quoted line with
   a caret under the column. Clicking it moves the editor caret to the spot. */
.error-jump {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 10px;
    border: 1px solid var(--diff-del-gutter);
    border-radius: 6px;
    background: var(--diff-del-bg);
    cursor: pointer;
    transition: filter 0.12s ease, box-shadow 0.12s ease;
}

.error-jump:hover {
    filter: brightness(1.12);
    box-shadow: 0 0 0 2px var(--diff-del-gutter);
}
.error-jump:active { filter: brightness(0.95); }
.error-jump:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 2px; }

/* A visible affordance: the whole area is a button, so say so rather than
   relying on the cursor alone. */
.error-jump-hint {
    display: inline-block;
    margin-top: 6px;
    color: var(--diff-del-text);
    font-size: 12px;
    font-weight: 600;
    opacity: 0.9;
}

.error-jump-hint::before { content: "\2192\00a0"; }

.error-loc {
    margin: 0;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    color: var(--diff-del-text);
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 12.5px;
    line-height: 1.5;
    white-space: pre;
    overflow-x: auto;
}

/* ============================================ */
/* EMPTY STATES                                */
/* ============================================ */
/* EMPTY STATES                                */
/* ============================================ */
.empty-state {
    padding: 30px 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13.5px;
}

/* ============================================ */
/* TOASTS                                      */
/*                                         */
/* In-page feedback, replacing window.alert().  */
/* A stack rather than a modal: the user keeps   */
/* their place and can dismiss one message while */
/* another is still there.                      */
/*                                         */
/* Prefixed "sre-" because Bootstrap 5 ships a   */
/* .toast of its own that stays display:none    */
/* until .show is added; sharing the name left   */
/* these messages in the DOM but invisible.      */
/* ============================================ */
/* Centred as a column: the fixed width plus auto side margins puts the stack in
   the middle of the viewport. align-items keeps each toast the same width
   instead of letting the flex column shrink them to their text. */
.sre-toast-stack {
    position: fixed;
    top: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1090;              /* above Bootstrap modals (1055) */
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: min(420px, calc(100vw - 32px));
    pointer-events: none;       /* the stack ignores clicks, not the toasts */
}

.sre-toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 11px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--text-dim);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
    color: var(--text);
    font-size: 13px;
    line-height: 1.45;
    pointer-events: auto;
    animation: toast-in 160ms ease-out;
}

.sre-toast.leaving {
    animation: toast-out 140ms ease-in forwards;
}

/* The dark shadow reads as a smudge on the light surface. */
[data-theme="light"] .sre-toast { box-shadow: 0 8px 24px rgba(19, 23, 34, 0.16); }

.sre-toast-success { border-left-color: var(--success); }
.sre-toast-error   { border-left-color: var(--danger-text); }
.sre-toast-warning { border-left-color: var(--warning); }
.sre-toast-info    { border-left-color: var(--info); }

.sre-toast-icon {
    flex: 0 0 auto;
    font-size: 13px;
    line-height: 1.45;
}

.sre-toast-success .sre-toast-icon { color: var(--success-text); }
.sre-toast-error   .sre-toast-icon { color: var(--danger-text); }
.sre-toast-warning .sre-toast-icon { color: var(--warning-text); }
.sre-toast-info    .sre-toast-icon { color: var(--info); }

.sre-toast-body {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;    /* long API errors wrap instead of widening */
}

.sre-toast-close {
    flex: 0 0 auto;
    background: none;
    border: 0;
    padding: 0 2px;
    color: var(--text-dim);
    font-size: 15px;
    line-height: 1.3;
    cursor: pointer;
}

.sre-toast-close:hover { color: var(--text); }
.sre-toast-close:focus-visible {
    outline: 2px solid var(--ring);
    outline-offset: 2px;
    border-radius: 3px;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: none; }
}

@keyframes toast-out {
    from { opacity: 1; transform: none; }
    to   { opacity: 0; transform: translateY(-6px); }
}

@media (prefers-reduced-motion: reduce) {
    .sre-toast, .sre-toast.leaving { animation: none; }
}

@media (max-width: 575px) {
    /* Drop the centring offset and let the stack span the viewport instead. */
    .sre-toast-stack {
        top: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        width: auto;
    }
}

/* The utility panes carry a fair amount of monospace text; letting long
   unbroken strings wrap stops a pasted token from widening the whole page. */
#jsonTab pre, #textTab pre, #hashTab code, #uuidTab pre,
#timeTab code, #regexTab pre, #passwordTab pre {
    white-space: pre-wrap;
    word-break: break-all;
}

/* ============================================ */
/* REGEX WORKBENCH                             */
/* ============================================ */
/* Match highlights alternate between two tints of the accent so adjacent
   matches stay distinguishable; capture groups take a palette of their own.
   Syntax colours follow the group nesting depth, as on regex101. */
:root {
    --rx-m0: rgba(56, 189, 248, 0.34);
    --rx-m1: rgba(56, 189, 248, 0.18);
    --rx-g0: rgba(52, 211, 153, 0.42);
    --rx-g1: rgba(251, 146, 60, 0.42);
    --rx-g2: rgba(192, 132, 252, 0.42);
    --rx-g3: rgba(244, 114, 182, 0.42);
    --rx-g4: rgba(250, 204, 21, 0.38);
    --rx-g5: rgba(45, 212, 191, 0.42);
    --rx-g6: rgba(248, 113, 113, 0.42);
    --rx-g7: rgba(163, 230, 53, 0.38);
    --rx-d0: #34d399;
    --rx-d1: #fbbf24;
    --rx-d2: #c084fc;
    --rx-d3: #f472b6;
    --rx-class: #38bdf8;
    --rx-set: #fb923c;
    --rx-quant: #60a5fa;
    --rx-anchor: #f87171;
    --rx-esc: #a5b4fc;
    --rx-flag: #2dd4bf;
    --rx-hover-bg: rgba(251, 146, 60, 0.22);
    --rx-hover-ring: #fb923c;
}

[data-theme="light"] {
    --rx-m0: rgba(14, 116, 204, 0.26);
    --rx-m1: rgba(14, 116, 204, 0.13);
    --rx-g0: rgba(16, 185, 129, 0.34);
    --rx-g1: rgba(249, 115, 22, 0.32);
    --rx-g2: rgba(168, 85, 247, 0.30);
    --rx-g3: rgba(236, 72, 153, 0.30);
    --rx-g4: rgba(234, 179, 8, 0.38);
    --rx-g5: rgba(20, 184, 166, 0.32);
    --rx-g6: rgba(239, 68, 68, 0.30);
    --rx-g7: rgba(101, 163, 13, 0.32);
    --rx-d0: #047857;
    --rx-d1: #b45309;
    --rx-d2: #7e22ce;
    --rx-d3: #be185d;
    --rx-class: #0369a1;
    --rx-set: #c2410c;
    --rx-quant: #1d4ed8;
    --rx-anchor: #b91c1c;
    --rx-esc: #4338ca;
    --rx-flag: #0f766e;
    --rx-hover-bg: rgba(234, 88, 12, 0.14);
    --rx-hover-ring: #ea580c;
}


.rx-status { font-size: 12.5px; font-weight: 550; color: var(--text-muted); }
.rx-status.rx-ok, .rx-ok { color: var(--success-text); }
.rx-status.rx-warn { color: var(--warning-text); }
.rx-status.rx-bad, .rx-bad { color: var(--danger-text); }
.rx-muted { color: var(--text-dim); font-weight: 450; }
.rx-hint { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.rx-empty-note { font-size: 12.5px; color: var(--text-dim); }

/* --- Editors: a transparent input over a backdrop of the same metrics --- */
.rx-field {
    position: relative;
    background: var(--inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.rx-field:hover { border-color: var(--border-strong); }
.rx-field:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }

.rx-backdrop,
.rx-field .rx-input {
    margin: 0;
    border: 0;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 13px;
    line-height: 1.6;
    letter-spacing: normal;
    tab-size: 4;
    font-variant-ligatures: none;
}

.rx-backdrop {
    position: absolute;
    inset: 0;
    overflow: hidden;
    color: transparent;
    border-radius: inherit;
}

.rx-field .rx-input {
    position: relative;
    display: block;
    width: 100%;
    background: transparent;
    color: var(--text);
    outline: none;
}
.rx-field .rx-input::placeholder { color: var(--text-dim); }

.rx-line .rx-backdrop,
.rx-line .rx-input { padding: 7px 11px; white-space: pre; }

.rx-area .rx-backdrop,
.rx-area .rx-input {
    padding: 10px 13px;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    word-break: normal;
    /* The same gutter on both layers keeps their wrap width identical
       whether or not the textarea is showing a scrollbar. */
    scrollbar-gutter: stable;
}
.rx-area .rx-input { resize: vertical; min-height: 160px; overflow-y: auto; }

/* The pattern editor holds one pattern per line. Its text is drawn by the
   backdrop, so the syntax colours show; only the caret comes from the
   textarea itself. Lines never wrap: one visual line is one pattern, which is
   what keeps the gutter's per-line results aligned. */
.rx-pattern-field { display: flex; align-items: stretch; --rx-pfs: 15px; }
.rx-pwrap { position: relative; flex: 1; min-width: 0; }
.rx-pattern-field .rx-backdrop,
.rx-pattern-field .rx-input {
    font-size: var(--rx-pfs);
    padding: 10px 12px;
    white-space: pre;
    overflow-wrap: normal;
}
.rx-pattern-field .rx-input {
    min-height: 0;
    resize: vertical;
    overflow-x: auto;
    color: transparent;
    caret-color: var(--text);
}
.rx-pattern-field .rx-backdrop { color: var(--text); }
.rx-pattern-field .rx-input::selection { background: var(--ring); color: transparent; }
#regexReplaceField .rx-backdrop { color: var(--text); }
#regexReplaceField .rx-input { color: transparent; caret-color: var(--text); }
#regexReplaceField .rx-input::selection { background: var(--ring); color: transparent; }

/* Per-line gutter: line number plus that pattern's match count or error. */
.rx-pgutter {
    flex: 0 0 auto;
    min-width: 58px;
    padding: 10px 0;
    overflow: hidden;
    border-right: 1px solid var(--border);
    background: var(--bg-elevated);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    user-select: none;
}
.rx-pg-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    height: calc(var(--rx-pfs) * 1.6);
    padding: 0 7px 0 9px;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 11.5px;
    color: var(--text-dim);
    cursor: pointer;
}
.rx-pg-line.blank { cursor: default; }
.rx-pg-line.active { background: var(--primary-soft); color: var(--accent-text); }
.rx-pg-badge { min-width: 16px; padding: 0 4px; border-radius: var(--radius-pill); text-align: center; font-weight: 650; }
.rx-pg-line.hit .rx-pg-badge { color: var(--success-text); background: var(--success-soft); }
.rx-pg-line.miss .rx-pg-badge { color: var(--text-dim); background: var(--inset); }
.rx-pg-line.err .rx-pg-badge { color: var(--danger-text); background: var(--danger-soft); }

.rx-flavor-select { width: auto; min-width: 190px; font-weight: 600; }

/* Flags are always visible toggles: a popover inside a card is clipped by
   the card's rounded overflow. */
.rx-flagbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.rx-flagbar-label { font-size: 12px; font-weight: 600; color: var(--text-muted); margin-right: 2px; }
.rx-chip {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--inset);
    color: var(--text-muted);
    font-size: 12.5px;
    cursor: pointer;
    user-select: none;
    transition: border-color .15s ease, background-color .15s ease, color .15s ease;
}
.rx-chip input { position: absolute; opacity: 0; width: 0; height: 0; }
.rx-chip b { font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 13px; }
.rx-chip:hover { border-color: var(--border-strong); color: var(--text); }
.rx-chip.on { background: var(--primary-soft); border-color: var(--ring); color: var(--accent-text); }
.rx-chip:focus-within { box-shadow: 0 0 0 3px var(--ring); }
#regexFlavorNote { flex-basis: 100%; }

.rx-t-group { font-weight: 650; }
.rx-d0 { color: var(--rx-d0); }
.rx-d1 { color: var(--rx-d1); }
.rx-d2 { color: var(--rx-d2); }
.rx-d3 { color: var(--rx-d3); }
.rx-t-class, .rx-t-dot { color: var(--rx-class); }
.rx-t-set { color: var(--rx-set); }
.rx-t-quant { color: var(--rx-quant); font-weight: 650; }
.rx-t-anchor, .rx-t-alt { color: var(--rx-anchor); font-weight: 650; }
.rx-t-esc { color: var(--rx-esc); }
.rx-t-flag { color: var(--rx-flag); }
.rx-t-hover {
    background: var(--rx-hover-bg);
    box-shadow: 0 0 0 1px var(--rx-hover-ring);
    border-radius: 2px;
}
.rx-t-pair { background: var(--primary-soft); border-radius: 3px; outline: 1px solid var(--ring); }
.rx-t-bad, .rx-t-err {
    color: var(--danger-text);
    text-decoration: underline wavy var(--danger);
    text-underline-offset: 3px;
}

.rx-error-line {
    display: block;
    width: 100%;
    padding: 1px 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    text-align: left;
    cursor: pointer;
}
.rx-error-line:hover { text-decoration: underline; }
.rx-error {
    margin-top: 8px;
    padding: 7px 11px;
    border-radius: var(--radius-xs);
    background: var(--danger-soft);
    color: var(--danger-text);
    font-size: 12.5px;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

/* --- Segmented mode switch --- */
.rx-seg {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    background: var(--inset);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
}
.rx-seg-btn {
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-size: 12.5px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    cursor: pointer;
}
.rx-seg-btn:hover { color: var(--text); }
.rx-seg-btn.active { background: var(--primary-soft); border-color: var(--ring); color: var(--accent-text); }
.rx-count {
    display: inline-block;
    min-width: 18px;
    padding: 0 5px;
    margin-left: 3px;
    border-radius: var(--radius-pill);
    background: var(--card-hover);
    color: var(--text-muted);
    font-size: 11px;
    text-align: center;
}

/* --- Highlights --- */
.rx-hl { border-radius: 2px; }
.rx-m0 { background: var(--rx-m0); }
.rx-m1 { background: var(--rx-m1); }
.rx-g0 { background: var(--rx-g0); }
.rx-g1 { background: var(--rx-g1); }
.rx-g2 { background: var(--rx-g2); }
.rx-g3 { background: var(--rx-g3); }
.rx-g4 { background: var(--rx-g4); }
.rx-g5 { background: var(--rx-g5); }
.rx-g6 { background: var(--rx-g6); }
.rx-g7 { background: var(--rx-g7); }
.rx-zero { position: relative; }
.rx-zero::after {
    content: "";
    position: absolute;
    left: -1px;
    top: 0;
    height: 1.6em;
    border-left: 2px dotted var(--accent-text);
}

.rx-tip {
    position: fixed;
    z-index: 1080;
    max-width: 360px;
    padding: 8px 11px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xs);
    box-shadow: var(--shadow-lg);
    font-size: 12px;
    line-height: 1.5;
    color: var(--text);
    pointer-events: none;
}
.rx-tip code {
    display: block;
    margin: 2px 0 6px;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--inset);
    white-space: pre-wrap;
    word-break: break-all;
}
.rx-tip code:last-child { margin-bottom: 0; }
/* Inline tokens in a pattern description, as opposed to the block-level
   match values above. */
.rx-tip.rx-tip-desc code { display: inline; margin: 0; padding: 0 4px; }
.rx-tip sub { font-size: 9px; color: var(--success-text); }

/* --- Test case rows --- */
.rx-tests { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; padding: 2px; }
.rx-test {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr) auto 156px 28px;
    gap: 6px;
    align-items: center;
}
.rx-test .rx-expect { font-size: 12px; }
.rx-test-status {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 26px;
    border-radius: var(--radius-xs);
    font-size: 11.5px;
    font-weight: 650;
    color: var(--text-dim);
    background: var(--inset);
    border: 1px solid var(--border);
}
.rx-test-status.hit { color: var(--accent-text); border-color: var(--ring); }
.rx-test-status.ok { color: var(--success-text); background: var(--success-soft); border-color: transparent; }
.rx-test-status.bad { color: var(--danger-text); background: var(--danger-soft); border-color: transparent; }
.rx-test.rx-fail .rx-field { border-color: var(--danger); }
.rx-test.rx-active .rx-test-status { outline: 2px solid var(--ring); }
.rx-test-del {
    border: 0;
    background: transparent;
    color: var(--text-dim);
    font-size: 18px;
    line-height: 1;
    border-radius: var(--radius-xs);
    height: 28px;
    cursor: pointer;
}
.rx-test-del:hover { color: var(--danger-text); background: var(--danger-soft); }
.rx-test-sub {
    grid-column: 2 / 5;
    margin-top: -2px;
    padding-left: 12px;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 12px;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-all;
}

.rx-test-by { display: inline-flex; flex-wrap: wrap; gap: 3px; justify-content: flex-end; min-width: 44px; max-width: 180px; }
.rx-pbadge {
    padding: 1px 6px;
    border-radius: var(--radius-pill);
    background: var(--inset);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}
.rx-pbadge.first { color: var(--success-text); background: var(--success-soft); border-color: transparent; }
.rx-pbadge.active { outline: 2px solid var(--ring); }
.rx-pbadge.none { cursor: default; color: var(--text-dim); }

@media (max-width: 575.98px) {
    .rx-test { grid-template-columns: 28px minmax(0, 1fr) 28px; }
    .rx-test .rx-expect { grid-column: 2; grid-row: 2; }
    .rx-test-by { grid-column: 2; grid-row: 3; justify-content: flex-start; max-width: none; }
    .rx-test-sub { grid-column: 2; }
}

/* --- Output and side panels --- */
.rx-output {
    min-height: 2.6em;
    max-height: 320px;
    overflow: auto;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    background: var(--code-bg);
    border: 1px solid var(--code-border);
    color: var(--code-text);
    font-size: 12.5px;
}
.rx-output:empty::before { content: attr(data-empty); color: var(--text-dim); font-style: italic; }

.rx-side-body { max-height: 460px; overflow-y: auto; }

.rx-mi { margin-bottom: 10px; }
.rx-mi:last-child { margin-bottom: 0; }
.rx-mi-row {
    display: grid;
    grid-template-columns: minmax(80px, auto) 64px minmax(0, 1fr);
    gap: 8px;
    align-items: baseline;
    padding: 3px 6px;
    border-radius: var(--radius-xs);
    font-size: 12.5px;
    cursor: pointer;
}
.rx-mi-row:hover { background: var(--card-hover); }
.rx-mi-head { font-weight: 650; }
.rx-mi-row:not(.rx-mi-head) .rx-mi-label { padding-left: 12px; color: var(--text-muted); }
.rx-mi-pos { color: var(--text-dim); font-family: "JetBrains Mono", ui-monospace, monospace; font-size: 11.5px; }
.rx-mi-val code { color: var(--text); padding: 0 3px; white-space: pre-wrap; word-break: break-all; }
.rx-mi-val i { color: var(--text-dim); }

.rx-ex { display: flex; gap: 8px; align-items: baseline; padding: 3px 0; font-size: 12.5px; border-bottom: 1px dashed var(--border); }
.rx-ex:last-child { border-bottom: 0; }
.rx-ex-tok {
    flex-shrink: 0;
    max-width: 45%;
    padding: 0 4px;
    border-radius: 4px;
    background: var(--inset);
    color: var(--text);
    white-space: pre-wrap;
    word-break: break-all;
}
.rx-ex-text { color: var(--text-muted); }
.rx-k-group { color: var(--rx-d0); }
.rx-k-quant { color: var(--rx-quant); }
.rx-k-anchor, .rx-k-alt { color: var(--rx-anchor); }
.rx-k-class { color: var(--rx-class); }

.rx-details > summary { cursor: pointer; list-style: none; display: flex; justify-content: space-between; }
.rx-details > summary::-webkit-details-marker { display: none; }
.rx-details > summary::after { content: "\25BE"; color: var(--text-dim); transition: transform .15s ease; }
.rx-details:not([open]) > summary { border-bottom: 0; }
.rx-details:not([open]) > summary::after { transform: rotate(-90deg); }

.rx-ref { max-height: 380px; overflow-y: auto; }
.rx-ref-title {
    margin: 10px 0 4px;
    font-size: 11px;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-dim);
}
.rx-ref-title:first-child { margin-top: 0; }
.rx-ref-row {
    display: grid;
    grid-template-columns: 110px minmax(0, 1fr);
    gap: 8px;
    width: 100%;
    padding: 3px 6px;
    border: 0;
    border-radius: var(--radius-xs);
    background: transparent;
    color: var(--text-muted);
    font-size: 12.5px;
    text-align: left;
}
button.rx-ref-row { cursor: pointer; }
button.rx-ref-row:hover { background: var(--card-hover); color: var(--text); }
.rx-ref-row code { color: var(--accent-text); }
.rx-ref-na code { color: var(--danger-text); text-decoration: line-through; }

/* Every test row carries a select, so the browser-default white control is
   themed here; the chevron is drawn in the muted text colour of each theme. */
#regexTab .form-select {
    background-color: var(--inset);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239aa4b8' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
}
#regexTab .form-select:hover { border-color: var(--border-strong); }
#regexTab .form-select:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
#regexTab .form-select option { background: var(--bg-elevated); color: var(--text); }

/* ============================================ */
/* HOME: TOOL TILES                            */
/* ============================================ */
/* The home page lists every tool as a tile; it replaces the old tab strip. */
.home-link {
    display: flex;
    align-items: center;
    gap: 18px;
    color: inherit;
    text-decoration: none;
}
.home-link:hover { color: inherit; text-decoration: none; }

.tile-search {
    max-width: 460px;
    margin: 0 0 8px;
}

.tile-group { margin-top: 26px; }
.tile-group-title {
    font-size: 12px;
    font-weight: 650;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
    margin: 0 0 12px;
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
    gap: 14px;
}

.tool-tile {
    display: flex;
    align-items: center;
    gap: 14px;
    min-height: 92px;
    padding: 16px 18px;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    color: var(--text);
    text-decoration: none;
    transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease, background .12s ease;
}
.tool-tile:hover,
.tool-tile:focus-visible {
    color: var(--text);
    text-decoration: none;
    background: var(--card-hover);
    border-color: var(--primary);
    box-shadow: var(--shadow-raised);
    transform: translateY(-2px);
    outline: none;
}

.tile-icon {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
}
.tile-icon.c-azure  { background: rgba(56, 189, 248, 0.16); color: #38bdf8; }
.tile-icon.c-violet { background: rgba(192, 132, 252, 0.16); color: #c084fc; }
.tile-icon.c-green  { background: rgba(52, 211, 153, 0.16); color: #34d399; }
.tile-icon.c-amber  { background: rgba(251, 191, 36, 0.16); color: #fbbf24; }
.tile-icon.c-teal   { background: rgba(45, 212, 191, 0.16); color: #2dd4bf; }
[data-theme="light"] .tile-icon.c-azure  { background: rgba(3, 105, 161, 0.10); color: #0369a1; }
[data-theme="light"] .tile-icon.c-violet { background: rgba(126, 34, 206, 0.10); color: #7e22ce; }
[data-theme="light"] .tile-icon.c-green  { background: rgba(4, 120, 87, 0.10); color: #047857; }
[data-theme="light"] .tile-icon.c-amber  { background: rgba(180, 83, 9, 0.10); color: #b45309; }
[data-theme="light"] .tile-icon.c-teal   { background: rgba(15, 118, 110, 0.10); color: #0f766e; }

.tile-text { display: flex; flex-direction: column; min-width: 0; }
.tile-name { font-weight: 640; font-size: 15px; }
.tile-desc { color: var(--text-muted); font-size: 13px; line-height: 1.35; margin-top: 2px; }

.tile-hidden { display: none !important; }
.tile-empty { margin-top: 24px; }

/* Back bar above an open tool; hidden on the home page. */
.tool-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
}
html[data-route="/"] .tool-bar { display: none; }
.tool-back {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-pill);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 550;
    text-decoration: none;
    transition: border-color .15s ease, color .15s ease;
}
.tool-back:hover { border-color: var(--primary); color: var(--text); text-decoration: none; }
.tool-bar-title { font-size: 1.15rem; font-weight: 650; color: var(--text); }
