/* Hailey — global styles. Bootstrap 5.3 dark theme is the baseline. */

:root {
    --hailey-bg:        #0f0c29;
    --hailey-bg-2:      #1a1a2e;
    --hailey-panel:     #16162a;
    --hailey-accent:    #a29bfe;
    --hailey-accent-2: #6c5ce7;
    --hailey-pink:      #fd79a8;
    --hailey-text:      #e9ecef;
    --hailey-muted:     #8a8aa8;
    --hailey-border:    #2a2a44;
}

html, body { height: 100%; }
body {
    background: linear-gradient(135deg, #0f0c29, #1a1530 60%, #14132a);
    color: var(--hailey-text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.hailey-navbar {
    background: rgba(15, 12, 41, 0.85);
    backdrop-filter: blur(8px);
    border-color: var(--hailey-border) !important;
    /* backdrop-filter makes this a stacking context; keep it (and its avatar
       dropdown) above main.hailey-wide's z-index:1 on the wide/glass pages. */
    position: relative;
    z-index: 1030;
}

.hailey-logo-dot {
    display: inline-block; width: 14px; height: 14px; border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, var(--hailey-accent), var(--hailey-accent-2));
    box-shadow: 0 0 10px rgba(162,155,254,.6);
}

.hailey-brand-logo {
    height: 40px; width: auto; display: block;
    filter: drop-shadow(0 0 10px rgba(162,155,254,.28));
}

.hailey-avatar {
    display: inline-flex; align-items: center; justify-content: center;
    width: 30px; height: 30px; border-radius: 50%;
    background: linear-gradient(135deg, var(--hailey-accent), var(--hailey-accent-2));
    color: #fff; font-weight: 600; font-size: .9rem;
}
.hailey-avatar-btn { background: transparent; border: 1px solid var(--hailey-border); }
.hailey-avatar-btn:hover { background: rgba(255,255,255,.04); }

/* Auth pages */
.hailey-auth-shell {
    min-height: calc(100vh - 60px);
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-start;
    padding: clamp(2rem, 8vh, 8rem) 1rem 2rem;
}
.hailey-auth-card {
    width: 100%; max-width: 420px;
    background: rgba(22, 22, 42, .85);
    border: 1px solid var(--hailey-border);
    border-radius: 14px; padding: 2rem;
    box-shadow: 0 10px 40px rgba(0,0,0,.4);
}

/* Chat layout */
.hailey-app {
    display: grid;
    grid-template-columns: 280px 1fr;
    height: calc(100vh - 60px);
    overflow: hidden;
}
.hailey-sidebar {
    background: rgba(15, 12, 41, .6);
    border-right: 1px solid var(--hailey-border);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.hailey-sidebar-head { padding: .75rem; border-bottom: 1px solid var(--hailey-border); }
.hailey-chats { flex: 1 1 auto; overflow-y: auto; padding: .5rem; }

.hailey-chat-row {
    position: relative;
    display: flex; align-items: stretch;
    border-radius: 8px;
}
.hailey-chat-row:hover, .hailey-chat-row.active { background: rgba(255,255,255,.04); }
.hailey-chat-row.active { background: rgba(162,155,254,.15); }
.hailey-chat-row.active .hailey-chat-item { color: #fff; }

.hailey-chat-item {
    flex: 1 1 auto; min-width: 0;
    display: block; padding: .5rem .5rem .5rem .75rem; border-radius: 8px;
    color: var(--hailey-text); text-decoration: none; font-size: .9rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.hailey-chat-item:hover { color: var(--hailey-text); }

.hailey-chat-menu { flex: 0 0 auto; display: flex; align-items: center; }
.hailey-chat-menu-btn {
    background: transparent; color: var(--hailey-muted); border: none;
    padding: 0 .5rem; line-height: 1; font-size: 1.1rem;
    opacity: 0; transition: opacity .15s, color .15s;
}
.hailey-chat-row:hover .hailey-chat-menu-btn,
.hailey-chat-menu-btn:focus,
.hailey-chat-menu.show .hailey-chat-menu-btn {
    opacity: 1;
}
.hailey-chat-menu-btn:hover { color: #fff; background: rgba(255,255,255,.06); border-radius: 6px; }
@media (hover: none) {
    /* On touch devices keep the menu visible since there's no hover */
    .hailey-chat-menu-btn { opacity: .6; }
}

.hailey-main {
    display: flex; flex-direction: column;
    overflow: hidden; height: 100%;
}

.hailey-chat-header {
    border-bottom: 1px solid var(--hailey-border);
    background: rgba(15, 12, 41, .4);
    padding: .5rem 1rem;
}
.hailey-chat-header-inner {
    max-width: 820px; margin: 0 auto;
}
.hailey-tags {
    display: flex; flex-wrap: wrap; gap: .35rem; align-items: center;
}
.hailey-tag {
    display: inline-flex; align-items: center;
    background: rgba(162,155,254,.12);
    border: 1px solid rgba(162,155,254,.25);
    border-radius: 999px;
    font-size: .8rem;
    padding: 2px 2px 2px 10px;
    gap: .25rem;
}
.hailey-tag-name {
    color: var(--hailey-accent); text-decoration: none;
}
.hailey-tag-name:hover { color: #fff; }
.hailey-tag-remove {
    background: transparent; border: none; color: var(--hailey-muted);
    line-height: 1; padding: 0 6px; border-radius: 999px;
    font-size: 1rem;
}
.hailey-tag-remove:hover { background: rgba(255, 90, 120, .2); color: #fff; }
.hailey-tag-add { gap: .25rem; }
.hailey-tag-add input { width: 110px; font-size: .8rem; height: 26px; padding: 0 8px;
    background: rgba(22,22,42,.6); color: var(--hailey-text); border-color: var(--hailey-border); }
.hailey-tag-add input:focus { border-color: var(--hailey-accent); box-shadow: none; }

.hailey-system-chip {
    display: inline-flex; align-items: center; gap: .5rem;
    background: rgba(255, 159, 67, .08);
    border: 1px solid rgba(255, 159, 67, .35);
    border-radius: 10px;
    padding: 4px 4px 4px 10px;
    margin-bottom: .35rem;
    max-width: 100%;
    font-size: .82rem;
}
.hailey-system-label {
    font-size: .65rem; font-weight: 700; letter-spacing: .04em;
    text-transform: uppercase; color: #ffb86b;
    padding: 1px 6px; background: rgba(255,159,67,.18); border-radius: 999px;
}
.hailey-system-text {
    color: var(--hailey-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    min-width: 0;
}
.hailey-system-clear {
    background: transparent; border: none; color: var(--hailey-muted);
    line-height: 1; padding: 0 6px; border-radius: 999px; font-size: 1rem;
}
.hailey-system-clear:hover { background: rgba(255, 90, 120, .2); color: #fff; }

/* Header tool toggle (web search) */
.hailey-toolset { margin-right: .35rem; }
.hailey-tool-toggle {
    display: inline-flex; align-items: center; gap: .35rem;
    background: rgba(255,255,255,.04);
    border: 1px solid var(--hailey-border);
    color: var(--hailey-muted);
    padding: 4px 10px; border-radius: 999px;
    font-size: .78rem; font-weight: 500;
    transition: background .15s, color .15s, border-color .15s;
}
.hailey-tool-toggle:hover { background: rgba(255,255,255,.08); color: var(--hailey-text); }
.hailey-tool-toggle.is-on {
    background: rgba(108,231,162,.15);
    border-color: rgba(108,231,162,.4);
    color: #6ce7a2;
}
.hailey-tool-state { opacity: .7; font-size: .7em; text-transform: uppercase; letter-spacing: .04em; }

/* In-message tool status pill (during streaming) */
.hailey-tool-status {
    display: inline-flex; align-items: center; gap: .4rem;
    margin-bottom: .5rem;
    padding: 4px 10px; border-radius: 999px;
    background: rgba(108,231,162,.10);
    border: 1px solid rgba(108,231,162,.25);
    color: #6ce7a2; font-size: .78rem;
}
.hailey-tool-status.is-done {
    background: rgba(108,231,162,.18);
}
.hailey-tool-status .hailey-typing-dot { background: #6ce7a2; }
.hailey-tool-sources {
    margin-left: .5rem; color: var(--hailey-muted); font-size: .72rem;
}
.hailey-tool-sources summary { cursor: pointer; outline: none; }
.hailey-tool-sources ol { margin: .25rem 0 0 1.25rem; padding: 0; }
.hailey-tool-sources a { color: var(--hailey-accent); }
.hailey-tool-sources a:hover { color: #fff; }

/* File chips in chat header */
.hailey-file-add-btn { gap: .25rem; }
.hailey-file-chip {
    display: inline-flex; align-items: center; gap: .35rem;
    background: rgba(108, 162, 231, .10);
    border: 1px solid rgba(108, 162, 231, .30);
    border-radius: 999px;
    padding: 2px 2px 2px 8px;
    font-size: .78rem;
    max-width: 280px;
}
.hailey-file-chip.is-pending { opacity: .7; }
.hailey-file-chip.is-error {
    background: rgba(255, 90, 120, .12);
    border-color: rgba(255, 90, 120, .35);
}
.hailey-file-chip-link {
    display: inline-flex; align-items: center; gap: .35rem;
    color: var(--hailey-text); text-decoration: none;
    min-width: 0;
}
.hailey-file-chip-link:hover .hailey-file-name { color: var(--hailey-accent); }
.hailey-file-name {
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    max-width: 180px;
}
.hailey-file-mode {
    font-size: .58rem; font-weight: 700; letter-spacing: .04em;
    padding: 1px 5px; border-radius: 999px;
    background: rgba(108, 162, 231, .25); color: #9bc6ff;
}
.hailey-file-mode.is-pending { background: rgba(255, 255, 255, .12); color: var(--hailey-muted); }
.hailey-file-mode.is-error   { background: rgba(255, 90, 120, .25); color: #ffb0b8; }

.hailey-mode-group .btn { font-size: .8rem; padding: .35rem .8rem; }

/* Image generation */
.hailey-gen-card { overflow: hidden; }
.hailey-gen-thumb {
    width: 100%; aspect-ratio: 1 / 1; object-fit: cover;
    background: #0b0b1a;
    transition: opacity .2s;
}
.hailey-gen-thumb:hover { opacity: .9; }
.hailey-img-bubble {
    display: block; max-width: 100%; border-radius: 10px;
    margin: .5rem 0; border: 1px solid var(--hailey-border);
    background: #0b0b1a;
}
.hailey-imagine-meta {
    font-size: .72rem; color: var(--hailey-muted); margin-top: .35rem;
}
.hailey-imagine-meta code { color: var(--hailey-accent); }

.hailey-slash-badge-system {
    background: rgba(255,159,67,.18) !important;
    color: #ffb86b !important;
}
.hailey-messages {
    flex: 1 1 auto; overflow-y: auto; padding: 1.5rem;
    scroll-behavior: smooth;
}
/* When the chat has no messages, anchor the welcome state toward the upper-third — true center
   reads as "too low" once the composer + chat header eat into the visible area. */
.hailey-messages.is-empty {
    display: flex; flex-direction: column;
    align-items: center; justify-content: flex-start;
    padding: clamp(2rem, 10vh, 8rem) 1rem 1rem;
}
.hailey-msg { max-width: 820px; margin: 0 auto 1.25rem; }
.hailey-msg-role {
    font-size: .75rem; text-transform: uppercase; letter-spacing: 1px;
    color: var(--hailey-muted); margin-bottom: .35rem;
}
.hailey-msg-body {
    background: var(--hailey-panel); border: 1px solid var(--hailey-border);
    border-radius: 12px; padding: 1rem 1.25rem; line-height: 1.6;
    overflow-wrap: anywhere;
}
.hailey-msg-user .hailey-msg-body { background: rgba(108,92,231,.15); border-color: rgba(162,155,254,.25); }
.hailey-msg-body pre {
    background: #0b0b1a; border: 1px solid var(--hailey-border);
    border-radius: 8px; padding: .85rem; overflow-x: auto;
}
.hailey-msg-body code:not(pre code) {
    background: rgba(255,255,255,.06); padding: .1em .35em;
    border-radius: 4px; font-size: .9em;
}
.hailey-msg-body p { margin: 0 0 .65rem; }
.hailey-msg-body p:last-child { margin-bottom: 0; }
.hailey-msg-body table {
    border-collapse: collapse; margin: .5rem 0;
}
.hailey-msg-body table th, .hailey-msg-body table td {
    border: 1px solid var(--hailey-border); padding: .35rem .6rem;
}

.hailey-composer {
    border-top: 1px solid var(--hailey-border);
    background: rgba(15, 12, 41, .6);
    padding: 1rem;
}
.hailey-composer-inner { max-width: 820px; margin: 0 auto; position: relative; }

.hailey-slash-popup {
    position: absolute;
    left: 0; right: 0; bottom: calc(100% + 0.5rem);
    z-index: 20;
    background: var(--hailey-panel);
    border: 1px solid var(--hailey-border);
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,.5);
    overflow: hidden;
    max-height: 360px; display: flex; flex-direction: column;
}
.hailey-slash-popup ul {
    list-style: none; margin: 0; padding: .25rem;
    overflow-y: auto; flex: 1 1 auto;
}
.hailey-slash-popup li {
    padding: .5rem .75rem; border-radius: 6px; cursor: pointer;
}
.hailey-slash-popup li:hover,
.hailey-slash-popup li.active {
    background: rgba(162,155,254,.18);
}
.hailey-slash-title {
    color: var(--hailey-text); font-weight: 500; font-size: .92rem;
    display: flex; align-items: center; gap: .4rem;
}
.hailey-slash-preview {
    color: var(--hailey-muted); font-size: .78rem; margin-top: .15rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}
.hailey-slash-badge {
    font-size: .65rem; padding: 1px 6px; border-radius: 999px;
    background: rgba(253,121,168,.18); color: var(--hailey-pink);
    text-transform: uppercase; letter-spacing: .04em;
}
.hailey-slash-hint {
    padding: .35rem .75rem; font-size: .7rem; color: var(--hailey-muted);
    border-top: 1px solid var(--hailey-border);
    background: rgba(0,0,0,.2);
}
.hailey-composer textarea {
    background: var(--hailey-panel); color: var(--hailey-text);
    border: 1px solid var(--hailey-border); border-radius: 12px;
    resize: none; min-height: 56px; max-height: 240px;
}
.hailey-composer textarea:focus { border-color: var(--hailey-accent); box-shadow: 0 0 0 .2rem rgba(162,155,254,.15); }

.hailey-preset-menu {
    min-width: 320px; max-width: 480px; max-height: 60vh; overflow-y: auto;
}
.hailey-preset-menu .dropdown-item { white-space: normal; }
.hailey-preset-menu .dropdown-item .text-truncate { max-width: 380px; }
.hailey-preset-picker .dropdown-toggle { white-space: nowrap; }

.hailey-typing-dot {
    display: inline-block; width: 6px; height: 6px; border-radius: 50%;
    background: var(--hailey-accent); margin-right: 4px;
    animation: hailey-blink 1.2s infinite ease-in-out;
}
.hailey-typing-dot:nth-child(2) { animation-delay: .15s; }
.hailey-typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes hailey-blink {
    0%, 80%, 100% { opacity: .25; transform: scale(.8); }
    40%           { opacity: 1;   transform: scale(1); }
}

.hailey-empty {
    text-align: center; color: var(--hailey-muted);
    padding: 1rem;
    max-width: 520px;
}
.hailey-empty h2 { color: var(--hailey-text); font-weight: 700; }
.hailey-empty .accent {
    background: linear-gradient(90deg, var(--hailey-accent), var(--hailey-pink));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

@media (max-width: 768px) {
    .hailey-app { grid-template-columns: 1fr; }
    .hailey-sidebar { display: none; }
    .hailey-sidebar.is-open {
        display: flex; position: fixed; inset: 60px 0 0 0; z-index: 1040;
        width: 100%; background: var(--hailey-bg);
    }
}

/* ---- Jobs ------------------------------------------------------------- */
.hailey-jobs { max-width: 1100px; }
.jobs-metric { font-size: .82rem; color: var(--hailey-muted); }
.jobs-metric-n { font-weight: 700; color: var(--hailey-text); font-size: 1.05rem; }
.jobs-metric-hailey { color: var(--hailey-accent); }

.jobs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; }

.job-card {
    background: rgba(22,22,42,.7); border: 1px solid var(--hailey-border);
    border-radius: 14px; padding: 1rem 1.1rem; position: relative; overflow: hidden;
}
.job-card-hailey { border-color: rgba(162,155,254,.4); box-shadow: 0 0 0 1px rgba(162,155,254,.12), 0 10px 30px rgba(108,92,231,.12); }
.job-card-hailey::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
    background: linear-gradient(180deg, var(--hailey-accent), var(--hailey-accent-2));
}
.job-card-head { display: flex; align-items: center; gap: .5rem; margin-bottom: .55rem; flex-wrap: wrap; }
.job-origin { font-size: .68rem; letter-spacing: .04em; padding: .15rem .5rem; border-radius: 999px; font-weight: 600; }
.job-origin-hailey { color: #fff; background: linear-gradient(135deg, var(--hailey-accent), var(--hailey-accent-2)); }
.job-origin-user { color: var(--hailey-text); background: rgba(255,255,255,.08); border: 1px solid var(--hailey-border); }
.job-status { font-size: .62rem; text-transform: uppercase; letter-spacing: .06em; }
.job-lock { font-size: .85rem; }
.job-pending { font-size: .66rem; color: var(--hailey-accent); margin-left: auto; }

.job-title { font-size: 1.02rem; font-weight: 600; margin: 0 0 .35rem; }
.job-desc { font-size: .82rem; color: var(--hailey-muted); margin: 0 0 .65rem; line-height: 1.4; }
.job-meta { display: flex; flex-wrap: wrap; gap: .4rem .9rem; font-size: .72rem; color: var(--hailey-muted); margin-bottom: .8rem; }
.job-meta-item { white-space: nowrap; }
.job-actions { display: flex; gap: .4rem; }

.jobs-proposals { border: 1px solid rgba(162,155,254,.35); border-radius: 14px; padding: .9rem 1rem; background: rgba(108,92,231,.07); }
.jobs-proposals-head { font-size: .78rem; font-weight: 600; color: var(--hailey-accent); margin-bottom: .7rem; }
.job-proposal { display: flex; gap: 1rem; align-items: flex-start; padding: .6rem 0; border-top: 1px solid rgba(255,255,255,.05); }
.job-proposal:first-of-type { border-top: 0; }
.job-proposal-body { flex: 1 1 auto; min-width: 0; }
.job-proposal-title { font-size: .86rem; margin-bottom: .25rem; }
.job-proposal-why { font-size: .78rem; color: var(--hailey-muted); margin: 0 0 .4rem; }
.job-proposal-diff { list-style: none; margin: 0; padding: 0; font-size: .76rem; }
.job-proposal-diff li { padding: .1rem 0; color: var(--hailey-text); }
.job-proposal-diff .k { display: inline-block; min-width: 64px; color: var(--hailey-muted); font-family: 'JetBrains Mono', monospace; font-size: .68rem; }
.job-proposal-actions { display: flex; flex-direction: column; gap: .35rem; flex: none; }

.jobs-empty { border: 1px dashed var(--hailey-border); border-radius: 14px; padding: 2rem; text-align: center; }
.jobs-modal { background: var(--hailey-panel); border: 1px solid var(--hailey-border); }

/* ---- Critical failure alert (red header + bar) ------------------------ */
.hailey-navbar.hailey-alarm {
    background: linear-gradient(90deg, rgba(120,12,20,.95), rgba(80,8,14,.95)) !important;
    border-color: rgba(255,70,70,.6) !important;
    animation: hailey-alarm-pulse 1.1s ease-in-out infinite;
}
@keyframes hailey-alarm-pulse {
    0%, 100% { box-shadow: 0 0 0 rgba(255,40,40,0); }
    50%      { box-shadow: 0 2px 26px rgba(255,40,40,.55); }
}
.hailey-navbar.hailey-alarm .navbar-brand,
.hailey-navbar.hailey-alarm .btn-outline-light { color: #fff !important; }
.hailey-navbar.hailey-alarm .hailey-brand-logo { filter: drop-shadow(0 0 10px rgba(255,80,80,.8)); }

.hailey-alert-bar {
    display: flex; align-items: center; gap: .75rem;
    padding: .5rem 1rem; font-size: .85rem; color: #fff;
    background: linear-gradient(90deg, #c0392b, #8e1f17);
    border-bottom: 1px solid rgba(255,120,120,.5);
    box-shadow: 0 4px 18px rgba(192,57,43,.4);
    animation: hailey-alert-in .25s ease;
}
@keyframes hailey-alert-in { from { transform: translateY(-100%); opacity: 0; } }
.hailey-alert-icon { font-size: 1.05rem; animation: hailey-alarm-pulse 1.1s ease-in-out infinite; }
.hailey-alert-msg { font-weight: 600; }
.hailey-alert-link { color: #ffe3e3; text-decoration: underline; font-weight: 600; }
.hailey-alert-link:hover { color: #fff; }
.hailey-alert-mute {
    margin-left: auto; background: rgba(0,0,0,.25); color: #fff;
    border: 1px solid rgba(255,255,255,.35); border-radius: 8px;
    padding: .2rem .65rem; font-size: .78rem; cursor: pointer;
}
.hailey-alert-mute:hover { background: rgba(0,0,0,.45); }

/* ---- Voice controls (chat composer) ----------------------------------- */
.hailey-voice-btn { line-height: 1; padding: .25rem .5rem; }
#hailey-mic.is-listening {
    color: #fff; background: rgba(253,121,168,.25); border-color: var(--hailey-pink);
    animation: hailey-mic-pulse 1.1s ease-in-out infinite;
}
@keyframes hailey-mic-pulse {
    0%,100% { box-shadow: 0 0 0 rgba(253,121,168,0); }
    50%     { box-shadow: 0 0 0 5px rgba(253,121,168,.25); }
}
#hailey-speak.is-on {
    color: #6ce7a2; border-color: rgba(108,231,162,.5); background: rgba(108,231,162,.12);
}

/* ---- Jobs data-tier status strip -------------------------------------- */
.jobs-tiers { display: flex; flex-wrap: wrap; gap: .5rem; margin: -.5rem 0 1.25rem; }
.tier {
    display: inline-flex; align-items: center; gap: .4rem;
    font-size: .72rem; color: var(--hailey-text);
    background: rgba(22,22,42,.6); border: 1px solid var(--hailey-border);
    border-radius: 999px; padding: .25rem .7rem;
}
.tier-sub { color: var(--hailey-muted); }
.tier-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.tier-up .tier-dot   { background: #4ade80; box-shadow: 0 0 8px rgba(74,222,128,.7); }
.tier-down .tier-dot { background: #f87171; box-shadow: 0 0 8px rgba(248,113,113,.7); }
.tier-down { opacity: .8; }

/* ---- Full-width "enveloping" dashboard pages -------------------------- */
/* Pages opt in with <main class="hailey-wide py-4">. Hailey fills the whole
   viewport and the layout sweeps open on load instead of snapping wide. */
main.hailey-wide {
    width: 100%;
    max-width: 100%;
    margin-inline: auto;
    padding-inline: clamp(1rem, 3vw, 2.75rem);
    transform-origin: center top;
    animation: hailey-envelop .55s cubic-bezier(.16, .84, .44, 1) both;
}
@keyframes hailey-envelop {
    from { opacity: 0; transform: scaleX(.93) translateY(8px); }
    to   { opacity: 1; transform: none; }
}

/* Cards/sections rise into place; the top metric row staggers for flair. */
.hailey-wide .card { animation: hailey-rise .5s cubic-bezier(.16, .84, .44, 1) both; }
@keyframes hailey-rise {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: none; }
}
.hailey-wide .row.g-3 > .col:nth-child(1) .card { animation-delay: .06s; }
.hailey-wide .row.g-3 > .col:nth-child(2) .card { animation-delay: .12s; }
.hailey-wide .row.g-3 > .col:nth-child(3) .card { animation-delay: .18s; }
.hailey-wide .row.g-3 > .col:nth-child(4) .card { animation-delay: .24s; }
.hailey-wide .row.g-3 > .col:nth-child(5) .card { animation-delay: .30s; }
.hailey-wide .row.g-4  .card,
.hailey-wide .row.g-3 + .row .card { animation-delay: .34s; }


/* ============================================================
   Enveloping pages — technical animated background + glassmorphism
   Scoped via :has(main.hailey-wide) so only opted-in pages get it.
   ============================================================ */

/* Technical dot-matrix field — two layers drift diagonally at different speeds
   (parallax). Dots, not lines, so it never collides with table gridlines. */
body:has(main.hailey-wide)::before {
    content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
    background-image:
        radial-gradient(rgba(162,155,254,.45) 1.3px, transparent 1.7px),
        radial-gradient(rgba(253,121,168,.30) 1.1px, transparent 1.5px);
    background-size: 40px 40px, 96px 96px;
    background-position: 0 0, 12px 12px;
    opacity: .47;
    -webkit-mask-image: radial-gradient(140% 105% at 50% -5%, #000 45%, transparent 100%);
            mask-image: radial-gradient(140% 105% at 50% -5%, #000 45%, transparent 100%);
    animation: hailey-dots-drift 16s ease-in-out infinite;
}
/* Wander the two layers around in different directions (parallax) and loop seamlessly. */
@keyframes hailey-dots-drift {
    0%   { background-position:   0px   0px,  12px  12px; }
    20%  { background-position:  44px  18px,  96px  44px; }
    40%  { background-position:  22px  52px,  40px 104px; }
    60%  { background-position: -28px  40px, -48px  72px; }
    80%  { background-position: -16px -20px, -32px -28px; }
    100% { background-position:   0px   0px,  12px  12px; }
}

/* Drifting accent glow blobs — depth + motion behind the glass. */
body:has(main.hailey-wide)::after {
    content: ""; position: fixed; inset: -25%; z-index: -1; pointer-events: none;
    background:
        radial-gradient(38% 38% at 18% 22%, rgba(162,155,254,.20), transparent 70%),
        radial-gradient(34% 34% at 84% 26%, rgba(253,121,168,.16), transparent 70%),
        radial-gradient(44% 44% at 62% 90%, rgba(108,231,162,.11), transparent 70%);
    filter: blur(28px);
    animation: hailey-aurora 32s ease-in-out infinite alternate;
}
@keyframes hailey-aurora {
    0%   { transform: translate3d(0, 0, 0)        scale(1);    }
    50%  { transform: translate3d(2.5%, -2%, 0)   scale(1.09); }
    100% { transform: translate3d(-2%, 1.5%, 0)   scale(1.05); }
}

/* Keep content above the fixed background layers. */
main.hailey-wide { position: relative; z-index: 1; }

/* Glassmorphism — translucent frosted boxes so the background reads through. */
.hailey-wide .card {
    background-color: rgba(20, 20, 38, .5) !important;    /* beat Bootstrap .bg-dark */
    border: 1px solid rgba(162, 155, 254, .18) !important; /* beat .border-secondary */
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    box-shadow: 0 8px 32px rgba(0, 0, 0, .33), inset 0 1px 0 rgba(255, 255, 255, .05);
    transition: border-color .2s ease, transform .2s ease, box-shadow .2s ease;
}
.hailey-wide .card:hover {
    border-color: rgba(162, 155, 254, .38) !important;
    box-shadow: 0 10px 38px rgba(0, 0, 0, .42), inset 0 1px 0 rgba(255, 255, 255, .07);
}
/* Roomier left/right breathing room inside glass cards (responsive). */
.hailey-wide .card > .card-body { padding-inline: clamp(1.25rem, 1.6vw, 2rem); }
/* Breathing room around buttons in cards — but keep grouped/input-group
   buttons flush (radio toggles, the Copy-beside-input, etc.). */
.hailey-wide .card-body .btn:not(.btn-group *):not(.input-group *) {
    margin-block: .25rem;
    margin-inline: .15rem;
}
/* Let tables show the glass behind them instead of an opaque dark fill. */
.hailey-wide .table-dark { --bs-table-bg: transparent; }
.hailey-wide .table { --bs-table-bg: transparent; }

/* Dynamic table density (server sets the class via tbl_density()) — sparse
   tables breathe, dense tables stay compact. Smooth so re-renders ease. */
.table.tbl-roomy  > :not(caption) > * > * { padding-top: 1.15rem;  padding-bottom: 1.15rem; }
.table.tbl-comfy  > :not(caption) > * > * { padding-top: .72rem;   padding-bottom: .72rem;  }
.table.tbl-normal > :not(caption) > * > * { padding-top: .45rem;   padding-bottom: .45rem;  }
.table.tbl-tight  > :not(caption) > * > * { padding-top: .18rem;   padding-bottom: .18rem;  }
.table[class*="tbl-"] > :not(caption) > * > * { transition: padding .2s ease; }

/* NOTE: no prefers-reduced-motion guard here by request — the animated
   technical background is a required part of the Hailey experience and
   plays regardless of the OS "reduce motion" setting. */
