/* Reset, type, primitives (buttons, inputs, labels, avatars, switches, skeletons). */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: var(--fs-3)/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
a { color: var(--violet); text-decoration: none; }
a:hover { color: var(--violet-hi); }
h1, h2, h3, h4, p { margin: 0; }
:focus-visible { outline: 2px solid var(--violet); outline-offset: 2px; border-radius: var(--r1); }
.num { font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); }
.hide { display: none !important; }

/* Inline monoline icons wherever they sit next to text. */
.btn-ico, .newbtn svg, .attn > svg, .setrow > svg, .notif > svg, .sysbar > svg, .err-inline > svg, .mtop > svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.attn > svg { color: var(--amber); }
.err-inline > svg { color: var(--red); margin-top: 2px; }
.mtop > svg { width: 20px; height: 20px; }

/* Small tracked label, the one surviving mono/uppercase use. */
.lbl { font: var(--fs-0)/1.2 var(--mono); letter-spacing: 0.1em; color: var(--quiet); text-transform: uppercase; }
.lbl.live::before { content: ''; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--green); margin-right: 6px; animation: pulse 2s infinite; vertical-align: 1px; }

/* Text colors */
.up { color: var(--green) !important; }
.dn { color: var(--red) !important; }
.warn { color: var(--amber) !important; }
.muted { color: var(--muted); }
.quiet { color: var(--quiet); }

/* Buttons */
.btn { height: 34px; padding: 0 14px; border-radius: var(--r1); border: 1px solid var(--line2); font-size: var(--fs-2); font-weight: 500; display: inline-flex; align-items: center; gap: 7px; transition: var(--fast); color: var(--body); white-space: nowrap; }
.btn:hover { border-color: var(--muted); color: var(--text); }
.btn.pri { background: var(--text); color: #111; border-color: var(--text); }
.btn.pri:hover { background: var(--violet); border-color: var(--violet); color: #15111f; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--hover); }
.btn.link { border: 0; height: auto; padding: 0; color: var(--violet); font-weight: 400; }
.btn.link:hover { color: var(--violet-hi); background: none; }
.btn.danger { color: var(--red); border-color: rgba(238, 97, 97, 0.35); }
.btn.danger:hover { background: var(--rbg); border-color: var(--red); }
.btn.sm { height: 30px; font-size: var(--fs-1); padding: 0 11px; }
.btn.lg { height: 44px; font-size: var(--fs-3); padding: 0 20px; }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.btn.block { width: 100%; justify-content: center; }
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }

/* Inputs */
.input { width: 100%; height: 44px; background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r1); padding: 0 14px; outline: 0; font-size: 15px; transition: var(--fast); }
.input:focus { border-color: var(--violet); }
.input::placeholder { color: var(--quiet); }
.field label { display: block; margin-bottom: 8px; }
.field .help { margin-top: 6px; font-size: var(--fs-1); color: var(--quiet); }
.field .err { margin-top: 6px; font-size: var(--fs-1); color: var(--red); }
.field.invalid .input { border-color: var(--red); }

/* Switch */
.sw { width: 36px; height: 20px; border-radius: 10px; background: var(--green); position: relative; transition: var(--med); cursor: pointer; flex: none; border: 0; }
.sw::after { content: ''; position: absolute; top: 2px; left: 18px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: var(--med) var(--ease); }
.sw.off { background: var(--line2); }
.sw.off::after { left: 2px; }
.sw.violet { background: var(--violet); }

/* Avatars, generated per agent; identity color from --ac. */
.av { width: 30px; height: 30px; border-radius: var(--r2); position: relative; flex: none; display: grid; place-items: center; background: color-mix(in srgb, var(--ac, var(--violet)) 10%, #141414); border: 1px solid color-mix(in srgb, var(--ac, var(--violet)) 22%, #222); }
.av::before { content: ''; display: block; }
.av.g1::before { width: 12px; height: 12px; border-radius: 50%; border: 3px dotted var(--ac, var(--violet)); }
.av.g2::before { width: 11px; height: 15px; background: var(--ac, var(--green)); clip-path: polygon(50% 0, 100% 100%, 50% 76%, 0 100%); }
.av.g3::before { width: 11px; height: 11px; background: linear-gradient(135deg, var(--ac, var(--pink)), var(--blue)); transform: rotate(45deg); border-radius: 1px; }
.av.g4::before { width: 14px; height: 14px; background: repeating-linear-gradient(90deg, var(--ac, var(--amber)) 0 3px, transparent 3px 5px); }
.av.sm { width: 22px; height: 22px; border-radius: 4px; }
.av.sm::before { transform: scale(0.72); }
.av.sm.g3::before { transform: rotate(45deg) scale(0.72); }
.av.lg { width: 48px; height: 48px; border-radius: 8px; }
.av.lg::before { transform: scale(1.5); }
.av.lg.g3::before { transform: rotate(45deg) scale(1.5); }
.av.xl { width: 72px; height: 72px; border-radius: 10px; }
.av.xl::before { transform: scale(2.2); }
.av.xl.g3::before { transform: rotate(45deg) scale(2.2); }
.av.dim { filter: grayscale(1); opacity: 0.55; }

/* Presence dot */
.dotp { position: absolute; right: -3px; bottom: -3px; width: 9px; height: 9px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg); }
.dotp.idle { background: var(--quiet); }
.dotp.busy { background: var(--violet); animation: pulsev 1.6s infinite; }
.dotp.warn { background: var(--amber); }
.dotp.off { background: var(--line2); }

/* State words */
.state { font: var(--fs-0)/1 var(--mono); letter-spacing: 0.08em; white-space: nowrap; }
.state.think { color: var(--violet); }
.state.watch { color: var(--green); }
.state.rest { color: var(--quiet); }
.state.paused { color: var(--amber); }
.state.stopped { color: var(--muted); }
.state.error { color: var(--red); }

/* Tags */
.tag { font: var(--fs-0)/1 var(--mono); padding: 4px 7px; border-radius: var(--r1); background: var(--raised); color: var(--body); white-space: nowrap; }
.tag.up { background: var(--gbg); }
.tag.dn { background: var(--rbg); }
.tag.violet { background: var(--vbg); color: var(--violet) !important; }
.tag.warn { background: var(--abg); }

/* Thinking dots + spinner */
.dots { display: inline-flex; gap: 3px; }
.dots i { width: 4px; height: 4px; border-radius: 50%; background: var(--violet); animation: think 1.2s infinite; }
.dots i:nth-child(2) { animation-delay: 0.15s; }
.dots i:nth-child(3) { animation-delay: 0.3s; }
.spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--violet); border-right-color: transparent; animation: spin 1s linear infinite; display: inline-block; }

/* Skeletons, unboxed, matching real line lengths */
.sk { position: relative; overflow: hidden; background: var(--raised); border-radius: var(--r1); color: transparent !important; }
.sk::after { content: ''; position: absolute; inset: 0; background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.05), transparent); animation: shimmer 1.6s infinite; }
.sk.line { height: 12px; }
.sk.w40 { width: 40%; } .sk.w60 { width: 60%; } .sk.w80 { width: 80%; }

/* Keyframes */
@keyframes pulse { 50% { box-shadow: 0 0 0 4px rgba(95, 201, 123, 0.15); } }
@keyframes pulsev { 50% { box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.2); } }
@keyframes think { 50% { opacity: 0.15; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes flash { 0% { background: var(--vbg); } 100% { background: transparent; } }
@keyframes tick { 0% { color: var(--green); } 100% { color: inherit; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* Dropdown, replaces native <select>. Same border/radius language as .input; menu is a flat popover. */
.dd { position: relative; display: inline-block; }
.dd.block { display: block; }
.ddbtn { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 10px 0 12px; border: 1px solid var(--line2); border-radius: var(--r1); background: var(--panel); color: var(--text); font-size: 14px; width: 100%; text-align: left; transition: var(--fast); }
.dd.block .ddbtn { height: 44px; }
.dd.sm .ddbtn { height: 30px; font-size: 12.5px; padding: 0 8px 0 10px; background: transparent; border-color: transparent; color: var(--muted); }
.dd.sm .ddbtn:hover { background: var(--hover); color: var(--text); }
.ddbtn:hover { border-color: var(--muted); }
.dd.open .ddbtn { border-color: var(--violet); box-shadow: 0 0 0 3px var(--vbg); }
.dd.sm.open .ddbtn { box-shadow: none; background: var(--hover); color: var(--text); border-color: transparent; }
.ddbtn .ddlabel { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ddbtn small { color: var(--quiet); font-size: 12px; white-space: nowrap; }
.ddbtn > svg:last-child { width: 14px; height: 14px; stroke: var(--muted); fill: none; stroke-width: 2; flex: none; transition: var(--fast); }
.dd.open .ddbtn > svg:last-child { transform: rotate(180deg); }
.ddbtn .av { flex: none; }
.ddmenu { display: none; position: absolute; left: 0; top: calc(100% + 6px); min-width: 100%; max-height: 320px; overflow: auto; background: var(--panel); border: 1px solid var(--line2); border-radius: var(--r2); padding: 4px; z-index: 40; box-shadow: 0 18px 40px -20px rgba(0, 0, 0, 0.6); animation: fade var(--fast) var(--ease) both; }
.dd.open .ddmenu { display: block; }
.dd.sm .ddmenu { left: auto; right: 0; min-width: 200px; }
.ddopt { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: var(--r1); text-align: left; font-size: 13.5px; color: var(--body); white-space: nowrap; }
.ddopt:hover { background: var(--hover); color: var(--text); }
.ddopt span { flex: 1; }
.ddopt small { color: var(--quiet); font-size: 12px; }
.ddopt .ddcheck { width: 14px; height: 14px; stroke: var(--violet); fill: none; stroke-width: 2.2; opacity: 0; flex: none; }
.ddopt.sel { color: var(--text); }
.ddopt.sel .ddcheck { opacity: 1; }
.ddopt .av { flex: none; }
.ddbtn .ddcheck { display: none; }
