/* Home desk layers. Sits under the strategies card. */
#hd-layers {
    --hl-l1: #5d6f7c;
    --hl-l2: #13707f;
    --hl-l3: #6d4fc2;
    --hl-ok: #2f8f5b;
    --hl-bad: #c0453b;
    --hl-amber: #b7791f;
    --hl-ink: var(--hd-fg);
    --hl-ink2: var(--hd-muted);
    --hl-ink3: var(--hd-muted);
    --hl-line: var(--hd-line);
    --hl-card: var(--hd-panel);
    --hl-tile: var(--hd-sunk);
    --hl-teal: var(--hd-accent);
    --hl-sig-bg: color-mix(in srgb, var(--hl-l2) 7%, var(--hl-tile));
    --hl-ops-bg: color-mix(in srgb, var(--hl-amber) 9%, var(--hl-tile));
    --hl-res-bg: color-mix(in srgb, var(--hl-l3) 8%, var(--hl-tile));
}

html[data-theme="light"] #hd-layers {
    --hl-sig-bg: color-mix(in srgb, var(--hl-l2) 5%, #fff);
    --hl-ops-bg: color-mix(in srgb, var(--hl-amber) 6%, #fff);
    --hl-res-bg: color-mix(in srgb, var(--hl-l3) 5%, #fff);
}

html[data-theme="dark"] #hd-layers {
    --hl-l1: #9fb0ba;
    --hl-l2: #4fb3c3;
    --hl-l3: #ad95f2;
    --hl-ok: #5cc489;
    --hl-bad: #ec7a70;
    --hl-amber: #e0b15a;
}

#home-desk .hd-layers {
    display: block;
}

.hl-stack {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 210px;
    gap: 16px;
    align-items: start;
}

.hl-layers {
    display: grid;
    gap: 0;
    min-width: 0;
}

.hl-layer {
    border-top: 3px solid var(--hl-lc, var(--hl-line));
}

.hl-l3 { --hl-lc: var(--hl-l3); }
.hl-l2 { --hl-lc: var(--hl-l2); }
.hl-l1 { --hl-lc: var(--hl-l1); }

.hl-stale-age {
    display: block;
    width: 100%;
    font: 500 10px var(--font-mono);
    color: var(--hl-amber);
    letter-spacing: 0.02em;
    margin-top: 4px;
}

.hl-agg.hl-stale .hl-pic {
    opacity: 0.92;
}

.hl-head {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.hl-lv {
    font: 600 11px var(--font-mono);
    letter-spacing: 0.06em;
    color: var(--hl-card);
    padding: 6px 7px;
    border-radius: 5px;
}

.hl-lv3 { background: var(--hl-l3); }
.hl-lv2 { background: var(--hl-l2); }
.hl-lv1 { background: var(--hl-l1); }

.hl-lt { flex: 1; min-width: 200px; }
.hl-lt h2 { font-size: 15px; margin: 0; }
.hl-lt p { margin: 2px 0 0; font-size: 11.5px; color: var(--hl-ink2); max-width: 60ch; }

.hl-tot { display: flex; gap: 16px; }
.hl-tot div { text-align: right; }
.hl-tot b { display: block; font-size: 19px; font-weight: 500; font-variant-numeric: tabular-nums; }
.hl-tot span { font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--hl-ink3); }
.hl-tot .hl-ok { color: var(--hl-ok); }
.hl-tot .hl-bad { color: var(--hl-bad); }

.hl-pipe {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 34px;
    padding-left: 22px;
}

.hl-flow {
    position: relative;
    width: 14px;
    height: 34px;
}

.hl-flow::before {
    content: "";
    position: absolute;
    left: 6px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--hl-line);
    border-radius: 1px;
}

.hl-flow i {
    position: absolute;
    left: 4px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--hl-teal);
    animation: hl-rise 1.8s linear infinite;
    opacity: 0;
}

.hl-flow i:nth-child(2) { animation-delay: 0.6s; }
.hl-flow i:nth-child(3) { animation-delay: 1.2s; }

@keyframes hl-rise {
    0% { top: 30px; opacity: 0; }
    20% { opacity: 1; }
    80% { opacity: 1; }
    100% { top: -2px; opacity: 0; }
}

.hl-pipe span.hl-pl {
    font: 500 10px var(--font-mono);
    color: var(--hl-ink3);
    letter-spacing: 0.04em;
}

.hl-botgrid {
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-template-rows: auto auto auto auto;
    column-gap: 0;
    position: relative;
}

.hl-dbg {
    background: var(--hl-tile);
    border-radius: 8px;
    z-index: 0;
}

.hl-sig { background: var(--hl-sig-bg); }
.hl-sigA { margin-right: 4px; border-radius: 8px 8px 8px 0; }
.hl-sigB { margin-right: 4px; border-radius: 0 0 8px 8px; position: relative; }
.hl-sigB::after {
    content: "";
    position: absolute;
    z-index: 1;
    top: 0;
    right: 0;
    width: 8px;
    height: 8px;
    transform: translate(4px, 0);
    background: radial-gradient(circle at 0 0, var(--hl-sig-bg) 8px, transparent 8px);
    pointer-events: none;
}
.hl-ops { margin: 0; background: var(--hl-ops-bg); }
.hl-res { margin-top: 4px; background: var(--hl-res-bg); }

.hl-dh {
    position: relative;
    z-index: 1;
    padding: 10px 10px 8px;
    min-width: 0;
}

.hl-dh h3 { margin: 0 0 2px; font-size: 12.5px; font-weight: 600; }
.hl-dh1 { padding-top: 14px; }

.hl-tnum { display: flex; align-items: baseline; gap: 4px 6px; flex-wrap: wrap; }
.hl-tnum b { font-size: 16px; font-weight: 500; color: var(--hl-l2); font-variant-numeric: tabular-nums; }
.hl-tnum span { font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--hl-ink2); margin-right: 6px; }

.hl-botgrid .hl-bot { position: relative; z-index: 1; margin: 0 5px 10px; }
.hl-bot.hl-in-signal { background: var(--hl-sig-bg); border-color: var(--hl-sig-bg); }
.hl-bot.hl-in-operations { background: var(--hl-ops-bg); border-color: var(--hl-ops-bg); }
.hl-bot.hl-in-research { background: var(--hl-res-bg); border-color: var(--hl-res-bg); }

.hl-bot {
    display: grid;
    justify-items: center;
    text-align: center;
    gap: 1px;
    background: var(--hl-tile);
    border: 1px solid var(--hl-line);
    border-radius: 6px;
    padding: 6px 4px 8px;
    cursor: default;
    min-width: 0;
    transition: opacity 0.15s, border-color 0.15s;
}

.hl-bot canvas.hl-face { width: 56px; height: 56px; display: block; }
.hl-bn { font-size: 11px; font-weight: 600; max-width: 100%; line-height: 1.2; overflow-wrap: anywhere; }
.hl-bk { font-size: 10px; color: var(--hl-ink3); }
.hl-bk b { font-size: 15px; font-weight: 600; color: var(--hl-ink); font-variant-numeric: tabular-nums; }
.hl-bs { font: 400 9.5px var(--font-mono); color: var(--hl-ink3); }

.hl-bst {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font: 700 8.5px var(--font-sans);
    letter-spacing: 0.08em;
    text-transform: uppercase;
    margin-top: 4px;
    filter: saturate(1.35) brightness(0.82);
}

.hl-bst canvas { width: 13px; height: 13px; display: block; }
.hl-bot.hl-ping { border-color: var(--hl-l3); box-shadow: 0 0 0 3px color-mix(in srgb, var(--hl-l3) 18%, transparent); }

.hl-aggs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
    grid-auto-flow: row dense;
}

.hl-agg, .hl-cat {
    cursor: pointer;
    transform-origin: center;
    transition: opacity 0.15s, border-color 0.15s, transform 0.17s ease-in;
}

.hl-agg {
    background: var(--hl-tile);
    border: 1px solid var(--hl-line);
    border-radius: 6px;
    padding: 10px;
    display: grid;
    gap: 6px;
}

.hl-ah, .hl-ch { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.hl-an, .hl-cn { font-size: 12.5px; font-weight: 600; }
.hl-cn { font-size: 12px; font-weight: 500; }
.hl-ae, .hl-ae b { font: 600 15px var(--font-sans); color: var(--hl-l2); font-variant-numeric: tabular-nums; }
.hl-ae small { font: 400 9px var(--font-mono); color: var(--hl-ink3); margin-left: 3px; }

.hl-agg canvas.hl-pic {
    width: 100%;
    height: auto;
    aspect-ratio: 400 / 240;
    display: block;
    background: var(--hl-card);
    border: 1px solid var(--hl-line);
    border-radius: 4px;
}

.hl-af {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 2px;
    width: 100%;
    font: 400 9.5px var(--font-mono);
    color: var(--hl-ink3);
}

.hl-fd { display: inline-flex; align-items: center; gap: 2px; }
.hl-fd i {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--hl-dc, var(--hl-ink3));
    opacity: 0.18;
    transition: opacity 0.45s;
}

.hl-fd i.hl-on { opacity: 0.8; }
.hl-fd.hl-pulse i.hl-on { opacity: 1; }

.hl-kin { margin-left: auto; font: 400 10px var(--font-mono); color: var(--hl-ink3); }
.hl-kin b { font: 600 12px var(--font-mono); color: var(--hl-ink); font-variant-numeric: tabular-nums; margin-right: 1px; }

.hl-cats {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-items: start;
    grid-auto-flow: row dense;
}

.hl-cat {
    background: var(--hl-tile);
    border: 1px solid var(--hl-line);
    border-radius: 6px;
    padding: 9px 10px;
    display: grid;
    gap: 6px;
}

.hl-cv { font: 400 10.5px var(--font-mono); color: var(--hl-ink3); white-space: nowrap; }
.hl-cv b { color: var(--hl-ok); font-weight: 600; }
.hl-cv em { color: var(--hl-bad); font-style: normal; font-weight: 600; }

.hl-sq { display: flex; flex-wrap: wrap; gap: 3px; }
.hl-sq i, .hl-sl li i {
    width: 9px;
    height: 9px;
    border-radius: 2px;
    background: var(--hl-ok);
    display: inline-block;
}

.hl-sq i.hl-off, .hl-sl li.hl-off i {
    background: transparent;
    box-shadow: inset 0 0 0 1.5px var(--hl-bad);
}

.hl-agg.hl-turning, .hl-cat.hl-turning { transform: perspective(700px) rotateY(90deg); }
.hl-agg.hl-landing, .hl-cat.hl-landing { transform: perspective(700px) rotateY(-90deg); transition: none; }

.hl-cf, .hl-cb { display: grid; gap: 6px; }
.hl-cb { display: none; }
.hl-agg.hl-flipped .hl-cf, .hl-cat.hl-flipped .hl-cf { display: none; }
.hl-agg.hl-flipped .hl-cb, .hl-cat.hl-flipped .hl-cb { display: grid; }
.hl-agg.hl-flipped { background: var(--hl-card); border-color: var(--hl-l2); grid-column: 1 / -1; }
.hl-cat.hl-flipped { background: var(--hl-card); border-color: var(--hl-l1); grid-column: 1 / -1; }
.hl-agg.hl-flipped .hl-sl, .hl-cat.hl-flipped .hl-sl { columns: 4; }
.hl-agg .hl-sl li i { background: var(--hl-l2); width: 7px; height: 7px; }

.hl-sl {
    list-style: none;
    margin: 0;
    padding: 0;
    columns: 2;
    column-gap: 12px;
    font-size: 11px;
    color: var(--hl-ink2);
}

.hl-sl li { display: flex; align-items: center; gap: 6px; padding: 2px 0; break-inside: avoid; }
.hl-sl li.hl-off { color: var(--hl-ink3); }

.hl-layers.hl-linking .hl-bot,
.hl-layers.hl-linking .hl-agg,
.hl-layers.hl-linking .hl-cat { opacity: 0.32; }

.hl-layers.hl-linking .hl-lit { opacity: 1; border-color: var(--hl-l3); }
.hl-layers.hl-linking .hl-lit.hl-agg { border-color: var(--hl-l2); }
.hl-layers.hl-linking .hl-lit.hl-cat { border-color: var(--hl-l1); }

.hl-rail { position: sticky; top: calc(env(safe-area-inset-top, 0px) + 12px); }
.hl-rhead { margin-bottom: 8px; }
.hl-rhead h2 { margin: 0; font-size: 15px; }

.hl-tools { display: grid; gap: 8px; }

.hl-tool {
    background: var(--hl-tile);
    border: 1px solid var(--hl-line);
    border-radius: 6px;
    padding: 9px 10px;
    display: grid;
    gap: 4px;
}

.hl-th { display: flex; align-items: center; gap: 7px; font-size: 12px; font-weight: 600; }
.hl-th svg { color: var(--hl-teal); flex: none; }
.hl-tv { display: flex; gap: 14px; }
.hl-tv div b { display: block; font-size: 17px; font-weight: 500; font-variant-numeric: tabular-nums; }
.hl-tv div span { font-size: 9px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--hl-ink3); }
.hl-tool p { margin: 0; font-size: 10.5px; color: var(--hl-ink3); line-height: 1.4; }
.hl-rail-n { font-size: 10.5px; color: var(--hl-ink3); margin: 10px 2px 0; }

@media (max-width: 980px) {
    .hl-aggs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 780px) {
    .hl-stack { grid-template-columns: 1fr; }
    .hl-rail { position: static; }
    .hl-tools { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .hl-cats { grid-template-columns: 1fr; }
    .hl-tot { width: 100%; justify-content: flex-start; }
    .hl-tot div { text-align: left; }
    .hl-agg.hl-flipped .hl-sl, .hl-cat.hl-flipped .hl-sl { columns: 2; }
}

@media (max-width: 700px) {
    .hl-botgrid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 0; }
    .hl-dbg { display: none; }
    .hl-dh { grid-area: auto !important; grid-column: 1 / -1 !important; padding: 8px 2px 2px; }
    .hl-botgrid .hl-bot { grid-column: auto !important; grid-row: auto !important; margin: 0 3px; }
}

@media (prefers-reduced-motion: reduce) {
    .hl-flow i { animation: none; opacity: 1; top: 14px; }
    .hl-agg, .hl-cat, .hl-bot { transition: none; }
}
