/* ============================================================================
   Threadlinqs SecOS — desktop-OS shell visual layer.
   Every rule is html[data-secos]-scoped (or a secos-owned element): with the
   flag off this stylesheet is inert, so prod/dev rendering is untouched.
   Design language: Signal (violet family, zero-radius, JetBrains Mono for
   data/labels, Bricolage for display). Circles remain the sanctioned round
   exception (start button, pins).
   ========================================================================== */

/* ── §1 boot splash ───────────────────────────────────────────────────────── */
.secos-splash {
    position: fixed; inset: 0; z-index: 9501;
    display: grid; place-items: center;
    background:
        radial-gradient(80% 90% at 8% 100%, color-mix(in oklab, var(--violet, #7c3aed) 14%, transparent) 0%, transparent 60%),
        #08070c;
    opacity: 1; transition: opacity .32s ease;
}
.secos-splash--out { opacity: 0; pointer-events: none; }
.secos-splash-inner { text-align: center; transform: translateY(-4vh); }
.secos-splash-mark {
    font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: 44px;
    color: var(--violet-bright, #9e74f6); letter-spacing: -2px; margin-bottom: 18px;
}
.secos-splash-name {
    font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 22px;
    color: #f5f2fb; letter-spacing: .04em;
}
.secos-splash-name span { color: var(--violet-bright, #9e74f6); }
.secos-splash-sub {
    font-family: 'JetBrains Mono', monospace; font-size: 11px; letter-spacing: .22em;
    color: rgba(245, 242, 251, .45); margin-top: 8px;
}
.secos-splash-bar {
    width: 220px; height: 2px; margin: 26px auto 0;
    background: rgba(158, 116, 246, .18); overflow: hidden;
}
.secos-splash-bar i {
    display: block; height: 100%; width: 100%;
    background: var(--violet-bright, #9e74f6);
    transform: translateX(-100%);
    animation: secosBoot 1.05s cubic-bezier(.5, .1, .3, 1) forwards;
}
@keyframes secosBoot {
    0%   { transform: translateX(-100%); }
    55%  { transform: translateX(-38%); }
    100% { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
    .secos-splash { display: none; }
}

/* ── §1b OS menu bar ──────────────────────────────────────────────────────────
   The Signal topbar becomes the SecOS menu bar: raised above the window band
   (600) + taskbar (670) so it and its dropdowns (bell, Ask) always paint over
   apps. .app-container/.sig-main create no stacking contexts (verified), so
   this competes directly in the root context. */
html[data-secos] .sig-tb { position: relative; z-index: 740; }
/* DESKTOP: the header bar is REMOVED entirely — the wire + 24h stats are desktop
   widgets, the bell is adopted into the taskbar tray (stealNotifBell), Ask lives
   in the taskbar search. Windows reclaim the top 64px (wm.js top:0). We hide via
   CSS display:none, NEVER DOM-remove #tbRight: relocate() (app.js) unconditionally
   hides #statsBar, so a missing #tbRight would strand the bell + Ask forever. */
@media (min-width: 769px) {
    html[data-secos] .sig-tb { display: none !important; }
}
/* MOBILE: no taskbar/tray → the bell must stay in the topbar; keep .sig-tb but
   drop the (redundant) ticker. */
@media (max-width: 768px) {
    html[data-secos] #tbTicker { display: none !important; }
}

/* ── §2 desktop layer ─────────────────────────────────────────────────────── */
html[data-secos] .secos-desk {
    position: fixed; inset: 0; z-index: 2;   /* above static .app-container, below windows (400) */
}
.secos-wall { position: absolute; inset: 0; width: 100%; height: 100%; }

/* live signal pulses — pure CSS, absent under reduced-motion */
.secos-pulse {
    position: absolute; width: 6px; height: 6px; border-radius: 50%;
    background: var(--violet-bright, #9e74f6);
    opacity: .0;
    animation: secosPulse 7s ease-in-out infinite;
}
.secos-pulse--0 { left: 18%; top: 26%; animation-delay: 0s; }
.secos-pulse--1 { left: 71%; top: 62%; animation-delay: 2.3s; }
.secos-pulse--2 { left: 46%; top: 14%; animation-delay: 4.6s; }
@keyframes secosPulse {
    0%, 100% { opacity: 0; box-shadow: 0 0 0 0 rgba(158, 116, 246, .3); }
    12%      { opacity: .55; }
    30%      { opacity: 0; box-shadow: 0 0 0 26px rgba(158, 116, 246, 0); }
}

/* ── §2b desktop icons — grouped app frames ──────────────────────────────── */
/* top: 24px — header removed (was 84 = 64 header + 20 margin), now just a margin */
.secos-icons {
    position: absolute; top: 24px; left: 18px; bottom: 68px;
    display: flex; flex-direction: column; flex-wrap: wrap;
    align-content: flex-start; gap: 22px 22px;
    max-width: 62vw;
}
.secos-group {
    position: relative;
    border: 1px solid color-mix(in oklab, var(--violet, #7c3aed) 26%, var(--line-2, #2a2733));
    background: color-mix(in oklab, var(--bg-1, #111016) 24%, transparent);
    padding: 16px 10px 6px;
}
.secos-group-title {
    position: absolute; top: -8px; left: 10px;
    padding: 0 8px;
    font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 600;
    letter-spacing: .12em; color: var(--violet-bright, #9e74f6);
    background: var(--bg, #0a0a0a);
    line-height: 16px;
}
html[data-theme="light"] .secos-group { background: color-mix(in oklab, #ffffff 30%, transparent); }
html[data-theme="light"] .secos-group-title { background: #f4f2fa; }
.secos-group-row { display: flex; flex-wrap: wrap; gap: 2px; max-width: 440px; }
.secos-icon {
    width: 96px; padding: 10px 4px 8px;
    display: flex; flex-direction: column; align-items: center; gap: 7px;
    background: transparent; border: 1px solid transparent; cursor: pointer;
    font-family: 'JetBrains Mono', monospace;
    transition: background .14s, border-color .14s;
}
.secos-icon:hover { background: color-mix(in oklab, var(--violet, #7c3aed) 9%, transparent); }
.secos-icon[aria-pressed="true"] {
    background: color-mix(in oklab, var(--violet, #7c3aed) 15%, transparent);
    border-color: color-mix(in oklab, var(--violet, #7c3aed) 45%, transparent);
}
.secos-icon-img {
    width: 46px; height: 46px; display: grid; place-items: center;
    background: color-mix(in oklab, var(--bg-1, #111016) 82%, transparent);
    border: 1px solid var(--line-2, #2a2733);
    box-shadow: 0 10px 22px -14px rgba(0, 0, 0, .6);
}
.secos-icon:hover .secos-icon-img { border-color: color-mix(in oklab, var(--violet, #7c3aed) 55%, var(--line-2, #2a2733)); }
.secos-icon-img img { display: block; opacity: .92; }
.secos-icon-label {
    font-size: 10px; letter-spacing: .03em; line-height: 1.35;
    color: var(--ink-2, #b9b3c9); text-align: center;
    /* full names, never redacted: wrap up to two lines */
    max-width: 96px; white-space: normal; word-break: break-word;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    text-shadow: 0 1px 6px rgba(0, 0, 0, .5);
}
html[data-theme="light"] .secos-icon-label { text-shadow: 0 1px 6px rgba(255, 255, 255, .6); color: #4a4460; }
.secos-icon[aria-pressed="true"] .secos-icon-label,
.secos-icon:hover .secos-icon-label { color: var(--ink, #efecf6); }
html[data-theme="light"] .secos-icon:hover .secos-icon-label,
html[data-theme="light"] .secos-icon[aria-pressed="true"] .secos-icon-label { color: #1a1526; }

/* ── §2c desktop widgets (top-right) ─────────────────────────────────────── */
.secos-widgets {
    position: absolute; top: 24px; right: 26px; text-align: right;  /* header removed */
    font-family: 'JetBrains Mono', monospace; pointer-events: none;
    user-select: none;
}
.secos-w-clock {
    font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800;
    font-size: 64px; line-height: 1; letter-spacing: -1px;
    color: color-mix(in oklab, var(--ink, #efecf6) 82%, transparent);
}
.secos-w-date { font-size: 12px; letter-spacing: .14em; color: var(--ink-2, #b9b3c9); margin-top: 8px; }
.secos-w-brand { font-size: 10px; letter-spacing: .26em; color: color-mix(in oklab, var(--violet-bright, #9e74f6) 75%, transparent); margin-top: 14px; }
.secos-w-stats { font-size: 11px; letter-spacing: .08em; color: var(--ink-3, #6f6a7f); margin-top: 6px; }

/* the intel wire: live dot + age + one-line headline under the clock */
.secos-w-wire {
    display: flex; align-items: center; gap: 7px; justify-content: flex-end;
    margin-top: 16px; max-width: 340px; margin-left: auto;
}
.secos-wire-dot {
    width: 7px; height: 7px; border-radius: 50%; flex: none;
    background: var(--mint, #6ee7b7);
    animation: secosWirePulse 2.4s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .secos-wire-dot { animation: none; } }
@keyframes secosWirePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(110, 231, 183, .45); }
    55%      { box-shadow: 0 0 0 6px rgba(110, 231, 183, 0); }
}
.secos-wire-age { font-size: 10px; color: var(--ink-3, #6f6a7f); flex: none; }
.secos-wire-text {
    font-size: 11px; color: var(--ink-2, #b9b3c9);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* last-24h briefing numbers (daily-debrief parity) */
.secos-w-brief { margin-top: 14px; }
.secos-brief-head { font-size: 9.5px; letter-spacing: .22em; color: var(--ink-3, #6f6a7f); margin-bottom: 6px; }
.secos-brief-row {
    display: flex; align-items: baseline; justify-content: flex-end; gap: 8px;
    line-height: 1.8;
}
.secos-brief-row b {
    font-family: 'Bricolage Grotesque', sans-serif; font-weight: 800; font-size: 18px;
    color: color-mix(in oklab, var(--ink, #efecf6) 88%, transparent);
}
.secos-brief-row span { font-size: 10.5px; color: var(--ink-3, #6f6a7f); letter-spacing: .04em; }

@media (max-width: 1100px) { .secos-widgets { display: none; } }

/* ── §3 taskbar ───────────────────────────────────────────────────────────────
   48px glass bar. z 670: above windows (400-600) + wm toast (650), below the
   switcher (690), cnc chrome (697) and menu bar (740). The C&C circle is JS-
   pinned over the start slot at the bar's left edge. */
html[data-secos] .secos-bar {
    position: fixed; left: 0; right: 0; bottom: 0; height: 48px; z-index: 670;
    display: flex; align-items: center; gap: 10px;
    padding: 0 14px 0 0;
    background: color-mix(in oklab, var(--bg-1, #111016) 78%, transparent);
    -webkit-backdrop-filter: blur(18px) saturate(1.3);
    backdrop-filter: blur(18px) saturate(1.3);
    border-top: 1px solid color-mix(in oklab, var(--violet, #7c3aed) 22%, var(--line-2, #2a2733));
    box-shadow: 0 -12px 30px -18px rgba(0, 0, 0, .55);
    font-family: 'JetBrains Mono', monospace;
}
html[data-secos][data-theme="light"] .secos-bar,
html[data-theme="light"][data-secos] .secos-bar {
    background: color-mix(in oklab, #ffffff 82%, transparent);
    box-shadow: 0 -12px 30px -22px rgba(40, 20, 90, .35);
}
.secos-bar-startslot { width: 74px; height: 100%; flex: none; }

/* pinned quick-launch circles (search now; feed pins in a later phase) */
.secos-bar-pins { display: flex; align-items: center; gap: 8px; flex: none; }
.secos-bar-pin {
    width: 34px; height: 34px; border-radius: 50%;
    display: grid; place-items: center; cursor: pointer;
    background: var(--bg-2, #17151e); color: var(--ink-2, #b9b3c9);
    border: 1px solid var(--line-2, #2a2733);
    transition: border-color .15s, color .15s, filter .15s;
}
.secos-bar-pin:hover { border-color: var(--violet-bright, #9e74f6); color: var(--ink, #efecf6); filter: brightness(1.12); }

/* running windows */
.secos-bar-tabs {
    display: flex; align-items: center; gap: 6px;
    flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none;
    height: 100%; padding: 7px 2px;
}
.secos-bar-tabs::-webkit-scrollbar { display: none; }
.secos-tab {
    display: flex; align-items: center; gap: 8px;
    height: 34px; padding: 0 14px 0 11px; max-width: 220px; flex: none;
    background: transparent; border: 1px solid transparent;
    color: var(--ink-2, #b9b3c9); font-family: inherit; font-size: 11.5px;
    letter-spacing: .02em; cursor: pointer;
    transition: background .15s, border-color .15s, color .15s;
}
.secos-tab:hover { background: color-mix(in oklab, var(--violet, #7c3aed) 10%, transparent); color: var(--ink, #efecf6); }
.secos-tab[aria-current="true"] {
    background: color-mix(in oklab, var(--violet, #7c3aed) 16%, transparent);
    border-color: color-mix(in oklab, var(--violet, #7c3aed) 45%, transparent);
    color: var(--ink, #efecf6);
    box-shadow: inset 0 -2px 0 var(--violet-bright, #9e74f6);
}
.secos-tab[data-minimized="true"] { opacity: .55; }
.secos-tab[data-minimized="true"]:hover { opacity: .9; }
.secos-tab-dot {
    width: 6px; height: 6px; border-radius: 50%; flex: none;
    background: var(--violet-bright, #9e74f6);
}
.secos-tab[data-minimized="true"] .secos-tab-dot { background: var(--ink-3, #6f6a7f); }
.secos-tab-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* tray */
.secos-bar-tray { display: flex; align-items: center; gap: 10px; flex: none; }
.secos-tray-btn {
    width: 30px; height: 30px; display: grid; place-items: center;
    background: transparent; border: 1px solid transparent; cursor: pointer;
    color: var(--ink-2, #b9b3c9);
    transition: color .15s, border-color .15s;
}
.secos-tray-btn:hover { color: var(--ink, #efecf6); border-color: var(--line-2, #2a2733); }
.secos-clock {
    font-size: 11px; letter-spacing: .06em; color: var(--ink-2, #b9b3c9);
    padding: 0 2px; white-space: nowrap;
}
.secos-tray-btn--desk { border-left: 1px solid var(--line-2, #2a2733); }

/* notification bell adopted into the tray: dropdown becomes a drop-UP */
html[data-secos] .secos-bar-tray .notif-wrap { display: inline-flex !important; position: relative; }
html[data-secos] .secos-bar-tray .notif-panel {
    top: auto !important; bottom: calc(100% + 10px); right: 0; left: auto;
    margin-top: 0;
}

/* pinned feed circles (mirror the dock circles: shortname + color + unread) */
.secos-bar-pin--feed {
    position: relative;
    font-family: 'JetBrains Mono', monospace; font-size: 10px; font-weight: 700;
    letter-spacing: .02em; color: var(--ink, #efecf6);
}
.secos-bar-pin--feed[data-color="rose"]     { border-color: var(--cnc-c-rose, #fb6f84); }
.secos-bar-pin--feed[data-color="peach"]    { border-color: var(--cnc-c-peach, #fdba74); }
.secos-bar-pin--feed[data-color="lavender"] { border-color: var(--cnc-c-lavender, #c4b5fd); }
.secos-bar-pin--feed[data-color="mint"]     { border-color: var(--cnc-c-mint, #6ee7b7); }
.secos-bar-pin--feed[data-color="sky"]      { border-color: var(--cnc-c-sky, #7dd3fc); }
.secos-bar-pin--feed[data-color="yellow"]   { border-color: var(--cnc-c-yellow, #f2c94c); }
.secos-pin-badge {
    position: absolute; top: -4px; right: -6px;
    min-width: 15px; height: 15px; padding: 0 3px;
    display: grid; place-items: center; border-radius: 8px;
    background: var(--violet-bright, #9e74f6); color: #fff;
    font-size: 8.5px; font-style: normal; font-weight: 700; line-height: 1;
}

/* ── §4 the Threat Feed app window ────────────────────────────────────────────
   #mainContent keeps being its own scroller (safest for scrollTop-dependent
   feed code); the window body just hosts it. Mirrors the .sig-main twin rules
   styles.css:19601/:27217 for the windowed parent. */
html[data-secos] .tl-win-body.secos-feedwin { overflow: hidden; padding: 0; }
html[data-secos] .tl-win-body > .main-content {
    margin-left: 0 !important;
    min-height: 0 !important;
    height: 100%;
    overflow-y: auto;
    background: var(--bg) !important;
    gap: 0;
    padding-top: 0 !important;
}

/* ── §4b OS identity + context menu + About ──────────────────────────────── */
html[data-secos] .secos-brandchip {
    display: inline-flex; align-items: center; gap: 7px;
    margin-right: 14px; padding: 0 4px;
    font-family: 'JetBrains Mono', monospace; font-size: 11.5px;
    color: var(--ink-2, #b9b3c9); white-space: nowrap; flex: none;
}
html[data-secos] .secos-brandchip b { color: var(--violet-bright, #9e74f6); font-weight: 700; }
html[data-secos] .secos-brandchip i {
    font-style: normal; font-size: 8.5px; letter-spacing: .18em;
    padding: 2px 6px; border: 1px solid var(--line-2, #2a2733);
    color: var(--ink-3, #6f6a7f);
}
html[data-secos] .secos-ctx {
    position: fixed; z-index: 800; min-width: 190px;
    background: color-mix(in oklab, var(--bg-1, #111016) 92%, transparent);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    border: 1px solid color-mix(in oklab, var(--violet, #7c3aed) 35%, var(--line-2, #2a2733));
    box-shadow: 0 18px 44px -18px rgba(0, 0, 0, .65);
    padding: 4px;
}
html[data-secos] .secos-ctx-item {
    display: block; width: 100%; text-align: left;
    padding: 8px 12px; cursor: pointer;
    background: transparent; border: 0;
    font-family: 'JetBrains Mono', monospace; font-size: 11.5px;
    color: var(--ink-2, #b9b3c9);
}
html[data-secos] .secos-ctx-item:hover {
    background: color-mix(in oklab, var(--violet, #7c3aed) 18%, transparent);
    color: var(--ink, #efecf6);
}
.secos-about { padding: 26px 26px 18px; font-family: 'JetBrains Mono', monospace; text-align: center; }
.secos-about-mark { font-size: 38px; font-weight: 700; color: var(--violet-bright, #9e74f6); letter-spacing: -2px; }
.secos-about-name { font-family: 'Bricolage Grotesque', sans-serif; font-weight: 700; font-size: 17px; color: var(--ink, #efecf6); margin-top: 10px; }
.secos-about-name span { color: var(--violet-bright, #9e74f6); }
.secos-about-sub { font-size: 9.5px; letter-spacing: .22em; color: var(--ink-3, #6f6a7f); margin-top: 5px; }
.secos-about-rows { margin: 20px auto 0; max-width: 250px; text-align: left; }
.secos-about-rows div { display: flex; justify-content: space-between; padding: 5px 0; border-bottom: 1px dashed var(--line-2, #2a2733); }
.secos-about-rows span { font-size: 10.5px; color: var(--ink-3, #6f6a7f); }
.secos-about-rows b { font-size: 11px; color: var(--ink, #efecf6); font-weight: 600; }
.secos-about-foot { margin-top: 20px; font-size: 8.5px; letter-spacing: .2em; color: var(--ink-3, #6f6a7f); }

/* ── §5 Settings app ─────────────────────────────────────────────────────── */
.secos-settings { padding: 22px 24px; font-family: 'JetBrains Mono', monospace; }
.secos-set-h { font-size: 11px; letter-spacing: .2em; color: var(--violet-bright, #9e74f6); margin-bottom: 20px; }
.secos-set-group { margin-bottom: 20px; }
.secos-set-label { font-size: 10.5px; letter-spacing: .1em; color: var(--ink-3, #6f6a7f); margin-bottom: 8px; text-transform: uppercase; }
.secos-set-row { display: flex; gap: 8px; flex-wrap: wrap; }
.secos-set-row button {
    padding: 8px 16px; cursor: pointer; font-family: inherit; font-size: 11.5px;
    background: var(--bg-2, #17151e); color: var(--ink-2, #b9b3c9);
    border: 1px solid var(--line-2, #2a2733);
    transition: border-color .15s, color .15s, background .15s;
}
.secos-set-row button:hover { border-color: var(--violet-bright, #9e74f6); color: var(--ink, #efecf6); }
.secos-set-row button[aria-pressed="true"] {
    background: color-mix(in oklab, var(--violet, #7c3aed) 20%, var(--bg-2, #17151e));
    border-color: var(--violet-bright, #9e74f6); color: var(--ink, #efecf6);
}
.secos-set-foot { margin-top: 26px; font-size: 10px; letter-spacing: .08em; color: var(--ink-3, #6f6a7f); }

/* ── §6 window open animation + focus depth (paint-only, reduced-motion aware) */
html[data-secos] .tl-win { animation: secosWinIn .18s ease-out; transition: filter .16s ease; }
html[data-secos] .tl-win:not(.tl-focused):not([data-fullscreen="true"]) {
    filter: brightness(.93) saturate(.94);
}
/* bottom-zone snap preview reads as a "drop to minimize" chip, not a tile */
html[data-secos] .tl-snap-preview[data-zone="bottom"] {
    border-style: dashed;
    background: color-mix(in oklab, var(--violet, #7c3aed) 20%, transparent);
}
@keyframes secosWinIn { from { opacity: 0; scale: .975; } }
@media (prefers-reduced-motion: reduce) {
    html[data-secos] .tl-win { animation: none; }
    .secos-pulse { display: none; }
}

/* ── §7 mobile: desktop becomes a launch grid ─────────────────────────────── */
@media (max-width: 768px) {
    html[data-secos] .secos-bar { display: none; }
    .secos-icons {
        top: 74px; left: 10px; right: 10px; bottom: 84px;
        display: grid; grid-template-columns: repeat(3, 1fr);
        align-content: start; gap: 8px; overflow-y: auto;
    }
    .secos-icon { width: auto; }
}
