/* Security (sx-) and AI (ai-) pages. Theme variables only. */

/* ---------------- radar */
.sx-radar { position: relative; width: min(100%, 330px); aspect-ratio: 1; margin: 4px auto 0; border-radius: 50%; overflow: hidden;
  background: radial-gradient(circle, rgba(var(--tint), .2), rgba(var(--tint), .04) 60%, transparent 72%); border: 1px solid var(--line-strong); }
.sx-ring { position: absolute; border-radius: 50%; border: 1px solid var(--line); }
.sx-ring.r1 { inset: 12%; } .sx-ring.r2 { inset: 26%; } .sx-ring.r3 { inset: 38%; border-style: dashed; }
.sx-cross { position: absolute; inset: 0; background: linear-gradient(var(--line), var(--line)) 50% 0 / 1px 100% no-repeat, linear-gradient(var(--line), var(--line)) 0 50% / 100% 1px no-repeat; }
.sx-sweep { position: absolute; inset: 0; border-radius: 50%; pointer-events: none; animation: sx-spin 4.5s linear infinite;
  background: conic-gradient(from 0deg, transparent 0 290deg, rgba(var(--tint), .38) 358deg, transparent 360deg); }
.sx-blip { position: absolute; z-index: 2; width: 30px; height: 30px; margin: -15px 0 0 -15px; display: grid; place-items: center; padding: 0; border-radius: 50%; border: 1px solid currentColor;
  background: color-mix(in srgb, var(--solid) 85%, transparent); box-shadow: 0 0 14px -2px currentColor; transition: transform .25s cubic-bezier(.3,2,.4,1), left .8s, top .8s; }
.sx-blip:hover { transform: scale(1.35); }
.sx-blip::after { content: ""; position: absolute; inset: -4px; border-radius: 50%; border: 1px solid currentColor; opacity: 0; animation: ping 3s ease-out infinite; }
.sx-core { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); display: grid; place-items: center; }
.sx-core > * { grid-area: 1 / 1; }
.sx-core .ic { stroke-width: .8; filter: drop-shadow(0 0 10px currentColor); animation: sx-breathe 3.2s ease-in-out infinite; }
.sx-core b { font-size: 1.25rem; font-variant-numeric: tabular-nums; color: var(--fg); }
.sx-formula { text-align: center; margin: 12px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.7; }
.sx-formula b { color: var(--fg); font-size: 1rem; }

/* ---------------- device posture */
.sx-devs { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr)); gap: var(--gap); align-content: start; }
.sx-dev .card-body { display: flex; flex-direction: column; gap: 9px; padding-top: var(--pad); }
.sx-dev .btn { align-self: flex-start; margin-top: auto; }
.sx-dev.sx-focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(var(--tint), .3), var(--shadow); }
.sx-name { min-width: 0; }
.sx-score { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
.sx-score b { font-size: 2rem; letter-spacing: -.035em; font-variant-numeric: tabular-nums; line-height: 1; }
.sx-score small { color: var(--faint); }
.sx-pips { display: flex; flex-wrap: wrap; gap: 4px; }
.sx-pips i { width: 14px; height: 14px; border-radius: 4px; transition: transform .2s cubic-bezier(.3,2,.4,1); }
.sx-pips i:hover { transform: scale(1.5); }
.sx-pips i.pass { background: var(--good); box-shadow: 0 0 8px -2px var(--good); }
.sx-pips i.fail { background: var(--bad); box-shadow: 0 0 8px -1px var(--bad); animation: blink 2.2s ease-in-out infinite; }
.sx-pips i.unk { border: 1px dashed var(--warn); }
.sx-issues { margin: 0; font-size: .76rem; overflow-wrap: anywhere; }

/* ---------------- matrix */
.table-wrap.sx-matrix { max-height: none; }
.sx-matrix td, .sx-matrix thead th:not(:first-child) { text-align: center; }
.sx-matrix thead th:first-child, .sx-matrix tbody th { position: sticky; left: 0; background: var(--solid); text-align: left; }
.sx-matrix thead th:first-child { z-index: 3; }
.sx-matrix tbody th { top: auto; z-index: 1; text-transform: none; letter-spacing: 0; color: var(--muted); padding: 6px 12px; font-size: .8rem; font-weight: 560; border-bottom: 1px solid var(--line); max-width: 150px; }
.sx-cell { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; font: 700 .85rem var(--mono); font-style: normal; border: 1px solid var(--line); transition: transform .2s cubic-bezier(.3,2,.4,1), box-shadow .2s; }
.sx-cell:hover { transform: scale(1.3); box-shadow: 0 0 14px -2px currentColor; }
.sx-cell.pass { color: var(--good); background: color-mix(in srgb, var(--good) 15%, transparent); border-color: color-mix(in srgb, var(--good) 40%, transparent); }
.sx-cell.fail { color: var(--bad); background: color-mix(in srgb, var(--bad) 17%, transparent); border-color: color-mix(in srgb, var(--bad) 55%, transparent); }
.sx-cell.unk { color: var(--warn); border-style: dashed; border-color: color-mix(in srgb, var(--warn) 55%, transparent); }
.sx-cell.na { color: var(--faint); border-color: transparent; }
.sx-legend { display: flex; gap: 14px; flex-wrap: wrap; }
.sx-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.sx-legend .sx-cell { width: 20px; height: 20px; }

/* ---------------- lists */
.sx-rank { display: grid; grid-template-columns: 20px minmax(70px, 130px) 1fr auto; align-items: center; gap: 10px; padding: 7px 6px; border-radius: 9px; cursor: pointer; transition: background .2s, transform .2s; }
.sx-rank:hover { background: var(--field); transform: translateX(3px); }
.sx-rank em { font-style: normal; color: var(--faint); font-family: var(--mono); font-size: .75rem; }
.sx-note { font-size: .78rem; margin: 8px 0; }
.sx-pad .segmented { max-width: 100%; }
.sx-ports { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 7px; max-height: 300px; overflow: auto; padding: 2px; }
.sx-port { display: flex; flex-direction: column; min-width: 0; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--field); transition: transform .2s, border-color .2s; }
.sx-port:hover { transform: translateY(-2px); border-color: var(--accent); }
.sx-port b { font-family: var(--mono); color: var(--accent); }
.sx-port small { color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sx-scroll { max-height: 340px; overflow: auto; overflow-x: hidden; }
.sx-totals { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 8px; }
.sx-totals div { text-align: center; padding: 9px 4px; border-radius: 12px; border: 1px solid var(--line); background: var(--field); }
.sx-totals b { display: block; font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.sx-totals small { color: var(--faint); }
.sx-chips { margin-bottom: 8px; }

/* ---------------- GPU */
.ai-off { opacity: .6; }
.ai-gpu-grid { display: grid; grid-template-columns: 180px minmax(0, 1fr) minmax(0, 1.25fr); gap: 18px; align-items: stretch; }
.ai-tank { position: relative; min-height: 240px; border-radius: 26px; overflow: hidden; border: 1px solid var(--line-strong); background: var(--field);
  box-shadow: inset 0 1px 0 var(--sheen), inset 0 -18px 40px -20px rgba(var(--tint), .5); }
.ai-liquid { position: absolute; left: 0; right: 0; bottom: 0; transition: height 1.2s cubic-bezier(.2,.8,.2,1);
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 65%, transparent), color-mix(in srgb, var(--accent2) 55%, transparent)); box-shadow: 0 0 30px rgba(var(--tint), .5); }
.ai-liquid i { position: absolute; left: -50%; top: -9px; width: 200%; height: 18px; border-radius: 45%; background: color-mix(in srgb, var(--accent) 45%, transparent); animation: ai-wave 5s ease-in-out infinite; }
.ai-liquid i + i { top: -6px; opacity: .6; animation-duration: 7s; animation-direction: reverse; }
.ai-liquid span { position: absolute; bottom: 6px; left: 24%; width: 6px; height: 6px; border-radius: 50%; border: 1px solid var(--sheen); background: var(--sheen); opacity: 0; animation: ai-bubble 4s ease-in infinite; }
.ai-liquid span:nth-of-type(2) { left: 55%; animation-delay: 1.3s; } .ai-liquid span:nth-of-type(3) { left: 76%; animation-delay: 2.6s; }
.ai-tank-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; text-shadow: 0 1px 10px var(--solid); }
.ai-tank-text b { font-size: 2.3rem; letter-spacing: -.035em; font-variant-numeric: tabular-nums; }
.ai-tank-text small { color: var(--fg); }
.ai-gpu-side { display: flex; flex-direction: column; justify-content: space-between; gap: 12px; min-width: 0; }
.ai-rings { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-around; }
.ai-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ai-fact { padding: 7px 11px; border-radius: 12px; border: 1px solid var(--line); background: var(--field); min-width: 0; transition: transform .2s, border-color .2s; }
.ai-fact:hover { transform: translateY(-2px); border-color: var(--accent); }
.ai-fact small { display: block; color: var(--faint); font-size: .72rem; }
.ai-fact b { display: block; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.ai-gpu-chart { display: flex; flex-direction: column; justify-content: flex-end; gap: 10px; min-width: 0; }
@media (max-width: 1500px) { .ai-gpu-grid { grid-template-columns: 180px minmax(0, 1fr); } .ai-gpu-chart { grid-column: 1 / -1; } }
@media (max-width: 640px) { .ai-gpu-grid { grid-template-columns: minmax(0, 1fr); } .ai-tank { min-height: 180px; } }

/* ---------------- models and services */
.ai-loaded .bar { margin-top: 5px; }
.ai-pulse { width: 10px; height: 10px; flex: none; border-radius: 50%; background: var(--accent2); box-shadow: 0 0 12px var(--accent2); animation: blink 1.6s ease-in-out infinite; }
.ai-services { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 100%), 1fr)); gap: 8px; }
.ai-svc { display: flex; align-items: center; gap: 11px; padding: 11px 13px; border-radius: 15px; border: 1px solid var(--line); background: var(--field); min-width: 0; transition: transform .25s cubic-bezier(.3,1.8,.4,1), border-color .2s; }
.ai-svc:hover { transform: scale(1.03); border-color: var(--line-strong); }
.ai-svc div { display: flex; flex-direction: column; min-width: 0; }
.ai-svc b { overflow-wrap: anywhere; } .ai-svc small { color: var(--faint); }
.ai-svc.up { border-color: color-mix(in srgb, var(--good) 35%, transparent); }
.ai-svc.down { border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.ai-models { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(250px, 100%), 1fr)); gap: 10px; }
.ai-model { display: flex; flex-direction: column; gap: 9px; min-width: 0; padding: 13px; border-radius: 16px; border: 1px solid var(--line); background: var(--field); box-shadow: inset 0 1px 0 var(--sheen); transition: transform .3s cubic-bezier(.3,1.6,.4,1), border-color .2s, box-shadow .3s; }
.ai-model:hover { transform: translateY(-3px); border-color: var(--accent); box-shadow: 0 18px 35px -22px rgba(var(--tint), .9), inset 0 1px 0 var(--sheen); }
.ai-model.on { border-color: var(--good); background: color-mix(in srgb, var(--good) 9%, transparent); }
.ai-model-name { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.ai-model-name b { min-width: 0; overflow-wrap: anywhere; font-size: .9rem; }
.ai-size { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 9px; margin-top: auto; }

/* ---------------- chat */
.ai-chat-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 10px; }
.ai-chat-bar .select { width: min(380px, 100%); max-width: 100%; }
.ai-warn { display: flex; align-items: center; gap: 7px; margin: 0; color: var(--warn); font-size: .8rem; min-width: 0; }
.ai-warn .ic { flex: none; }
.ai-log { display: flex; flex-direction: column; gap: 10px; height: min(52vh, 460px); overflow-y: auto; padding: 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--field); }
.ai-hint { margin: auto; max-width: 40ch; text-align: center; color: var(--faint); }
.ai-msg { flex: none; display: flex; flex-direction: column; gap: 4px; max-width: min(78ch, 92%); min-width: 0; padding: 9px 13px; border-radius: 18px; border: 1px solid var(--line); background: color-mix(in srgb, var(--solid) 80%, transparent); animation: pop .3s cubic-bezier(.2,1.35,.35,1); }
.ai-msg.assistant { align-self: flex-start; border-bottom-left-radius: 5px; }
.ai-msg.user { align-self: flex-end; border-bottom-right-radius: 5px; background: rgba(var(--tint), .24); border-color: rgba(var(--tint), .5); }
.ai-msg.streaming { border-color: var(--accent); box-shadow: 0 0 18px -6px var(--accent); }
.ai-msg.failed { border-color: var(--bad); }
.ai-who { color: var(--faint); font-size: .7rem; overflow-wrap: anywhere; }
.ai-text { white-space: pre-wrap; overflow-wrap: anywhere; unicode-bidi: plaintext; }
.ai-msg.streaming .ai-text::after { content: "▍"; color: var(--accent); animation: blink .9s steps(1) infinite; }
.ai-think[hidden] { display: none; }
.ai-think summary { cursor: pointer; color: var(--muted); font-size: .78rem; }
.ai-think pre { margin: 5px 0; max-height: 180px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: var(--muted); font: .76rem/1.5 var(--mono); }
.ai-stats { color: var(--faint); font-size: .72rem; font-family: var(--mono); }
.ai-stats:empty { display: none; }
.ai-compose { display: flex; gap: 8px; align-items: flex-end; margin-top: 10px; }
.ai-compose textarea { flex: 1; min-width: 0; color: var(--fg); unicode-bidi: plaintext; }
.ai-compose .btn { height: 44px; flex: none; }
@media (max-width: 480px) { .ai-compose .btn span { display: none; } .sx-rank { grid-template-columns: 16px minmax(0, 90px) 1fr auto; gap: 7px; } }

@keyframes sx-spin { to { transform: rotate(360deg); } }
@keyframes sx-breathe { 50% { transform: scale(1.07); opacity: .75; } }
@keyframes ai-wave { 50% { transform: translateX(12%) scaleY(.55); } }
@keyframes ai-bubble { 20% { opacity: .8; } 100% { transform: translateY(-150px); opacity: 0; } }
