/* Ty workspace look (loaded after styles.css; scoped to #ty-app so the rest of the site is unchanged).
   Chat: light, conversational. Data flow: a dark workflow canvas where each agent lights up as the work reaches it. */

/* ---------- Chat ---------- */
#ty-app .ty-pane[data-pane="run"] { background: #F4F3EF; color: var(--midnight); }
#ty-app .chat { gap: 12px; padding-top: 22px; }
#ty-app .chat .row { display: flex; gap: 10px; align-items: flex-start; animation: tyMsgIn .35s var(--ease) both; }
#ty-app .chat .av { flex: none; width: 30px; height: 30px; border-radius: 9px; background: var(--midnight); color: var(--ivory); display: grid; place-items: center; font-family: var(--display); font-weight: 600; font-size: 0.75rem; letter-spacing: -0.02em; position: relative; margin-top: 2px; }
#ty-app .chat .av::after { content: ""; position: absolute; right: -2px; bottom: -2px; width: 9px; height: 9px; border-radius: 50%; background: #6FAE86; border: 2px solid #F4F3EF; }
#ty-app .msg { font-size: 0.9375rem; line-height: 1.6; }
#ty-app .msg.ty { max-width: 560px; background: #FFFFFF; color: #1F2E39; border: 1px solid #E4E3DD; border-radius: 4px 16px 16px 16px; padding: 12px 16px; box-shadow: 0 1px 2px rgba(15,31,43,.05), 0 8px 22px rgba(15,31,43,.05); }
#ty-app .msg.user { background: var(--midnight); color: var(--ivory); border-radius: 16px 4px 16px 16px; padding: 10px 16px; animation: tyMsgIn .3s var(--ease) both; box-shadow: 0 6px 16px rgba(15,31,43,.12); }
#ty-app .msg .q { display: table; font-size: 0.75rem; font-weight: 600; letter-spacing: .02em; color: #3E5546; background: #E3EAE4; border-radius: 999px; padding: 3px 10px; margin-bottom: 8px; }
#ty-app .msg em { font-style: normal; background: #F1EFE8; border-radius: 4px; padding: 0 4px; }
#ty-app .ty-list { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 8px; }
#ty-app .ty-list li { position: relative; padding-left: 18px; }
#ty-app .ty-list li::before { content: ""; position: absolute; left: 2px; top: .62em; width: 7px; height: 7px; border-radius: 2px; background: var(--sage); }
#ty-app .ty-list b { font-weight: 600; color: var(--midnight); }
#ty-app .msg.dots { display: inline-flex; gap: 5px; padding: 14px 16px; }
#ty-app .msg.dots i { width: 7px; height: 7px; border-radius: 50%; background: #9AA6AE; animation: tyDot 1.1s infinite ease-in-out; }
#ty-app .msg.dots i:nth-child(2) { animation-delay: .15s; }
#ty-app .msg.dots i:nth-child(3) { animation-delay: .3s; }
#ty-app .choices { gap: 8px; margin-top: 12px; }
#ty-app .choice { background: #FFFFFF; border: 1px solid #CFD2CB; color: var(--midnight); border-radius: 999px; padding: 8px 16px; font-weight: 500; transition: background .15s, color .15s, border-color .15s, transform .15s; }
#ty-app .choice:hover:not([disabled]) { background: var(--midnight); color: var(--ivory); border-color: var(--midnight); transform: translateY(-1px); }
#ty-app .choice.primary { background: var(--midnight); color: var(--ivory); border-color: var(--midnight); font-weight: 600; }
#ty-app .choice[disabled] { opacity: .4; }
#ty-app .instr input { background: #FFFFFF; border: 1px solid #CFD2CB; color: var(--midnight); border-radius: 999px; padding: 8px 16px; }
#ty-app .instr input::placeholder { color: #8A979F; }
#ty-app .instr input:focus { outline: 2px solid var(--sage); outline-offset: 1px; }
#ty-app .ty-note { margin-top: 10px; font-size: 0.8125rem; color: var(--slate); }
#ty-app .chat .steps { margin-top: 10px; }
#ty-app .chat .step { border-top-color: rgba(15,31,43,.08); }
#ty-app .chat .step .sid { color: #8A979F; }
#ty-app .chat .step .st { color: #8A979F; font-weight: 500; }
#ty-app .chat .step.running .st { color: var(--midnight); }
#ty-app .chat .step.done .st { color: var(--ok); }
#ty-app .chat .step.review .st { color: var(--warn); }
#ty-app .chat .step .log { color: #4F5E68; }
#ty-app .ty-pane[data-pane="run"] .lock-note { background: #FFFFFF; border-top: 1px solid #E4E3DD; color: var(--slate); }
#ty-app .ty-pane[data-pane="run"] .lock-note strong { color: var(--midnight); }
#ty-app .ty-book { color: var(--midnight); font-weight: 600; }
#ty-app .chat .link { color: var(--midnight); }
@keyframes tyMsgIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes tyDot { 0%, 80%, 100% { transform: translateY(0); opacity: .45; } 40% { transform: translateY(-4px); opacity: 1; } }

/* ---------- Data flow ---------- */
#ty-app .ty-pane[data-pane="flow"] { background: #111214; grid-template-rows: auto minmax(240px, 1fr) auto; }
#ty-app .flow { background-color: #111214; background-image: radial-gradient(rgba(255,255,255,.085) 1px, transparent 1.3px); background-size: 22px 22px; }

/* Narration: which agent has the work, and what it is doing */
#ty-app .ty-narrate { position: relative; display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 14px; align-items: start; padding: 16px 20px 14px; background: linear-gradient(180deg, #17191C, #121315); border-bottom: 1px solid rgba(255,255,255,.07); --nr: #9DB0FF; --nr-glow: rgba(120,145,255,.55); }
#ty-app .ty-narrate[data-mode="idle"] { --nr: #7D838A; --nr-glow: rgba(125,131,138,.25); }
#ty-app .ty-narrate[data-mode="review"] { --nr: #F2B35B; --nr-glow: rgba(242,179,91,.5); }
#ty-app .ty-narrate[data-mode="done"] { --nr: #3FE0C5; --nr-glow: rgba(63,224,197,.4); }
#ty-app .ty-narrate[data-mode="success"] { --nr: #3FE0C5; --nr-glow: rgba(63,224,197,.55); }
#ty-app .nr-orb { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: radial-gradient(circle at 50% 50%, #fff 0 18%, var(--nr) 45%, transparent 72%); box-shadow: 0 0 18px var(--nr-glow); margin-top: 2px; }
#ty-app .ty-narrate[data-mode="run"] .nr-orb { animation: nrPulse 1.6s ease-in-out infinite; }
#ty-app .nr-orb i { width: 8px; height: 8px; border-radius: 50%; background: #fff; }
#ty-app .nr-head { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; font-size: 0.75rem; letter-spacing: .02em; }
#ty-app .nr-who { font-weight: 600; color: #F2F2F2; }
#ty-app .nr-step { color: #9AA1A8; }
#ty-app .nr-now { margin: 3px 0 0; font-size: 0.975rem; line-height: 1.45; color: #F4F4F5; }
#ty-app .nr-now.in { animation: tyMsgIn .35s var(--ease) both; }
#ty-app .nr-feed { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 3px; font-size: 0.78rem; color: #8D959C; }
#ty-app .nr-feed:empty { display: none; }
#ty-app .nr-feed li { position: relative; padding-left: 14px; overflow-wrap: anywhere; }
#ty-app .nr-feed li::before { content: ""; position: absolute; left: 0; top: .5em; width: 6px; height: 6px; border-radius: 50%; background: #6B7178; }
#ty-app .nr-feed li.hand::before { background: #9DB0FF; box-shadow: 0 0 6px #9DB0FF; }
#ty-app .nr-feed li.done::before { background: #3FE0C5; }
#ty-app .nr-feed li.review::before { background: #F2B35B; }
#ty-app .nr-feed li:nth-child(n+3) { opacity: .6; }
#ty-app .nr-bar { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: rgba(255,255,255,.05); }
#ty-app .nr-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #FF8A3D, #9DB0FF 55%, #3FE0C5); box-shadow: 0 0 10px rgba(157,176,255,.6); transition: width .6s var(--ease); }
@keyframes nrPulse { 0%, 100% { box-shadow: 0 0 10px var(--nr-glow); } 50% { box-shadow: 0 0 26px var(--nr-glow); } }

/* Nodes: rounded tiles with ports, label and subtitle */
#ty-app .node { z-index: 1; width: 112px; gap: 10px; color: #F2F2F2; --c: #A9B8FF; --g: rgba(140,160,255,.55); --g2: rgba(140,160,255,.18); }
#ty-app .node.role-trigger, #ty-app .node.role-proc { --c: #FF8A3D; --g: rgba(255,138,61,.6); --g2: rgba(255,138,61,.2); }
#ty-app .node.role-gate { --c: #3FE0C5; --g: rgba(63,224,197,.6); --g2: rgba(63,224,197,.2); }
#ty-app .node .box { width: 64px; height: 64px; border-radius: 14px; background: linear-gradient(160deg, #2C2E32, #1D1F22); border: 1.5px solid #4B4E54; box-shadow: inset 0 1px 0 rgba(255,255,255,.06), 0 8px 20px rgba(0,0,0,.45); transition: border-color .3s, box-shadow .3s; }
#ty-app .node .box svg { width: 26px; height: 26px; stroke: #E9EAEC; stroke-width: 1.6; }
#ty-app .node.role-agent .box svg { stroke: #B9B6FF; }
#ty-app .node.role-trigger .box svg, #ty-app .node.role-proc .box svg { stroke: #FF9A55; }
#ty-app .node.role-gate .box svg { stroke: #5FE6CF; }
#ty-app .node .port { position: absolute; top: 50%; width: 9px; height: 9px; margin-top: -4.5px; border-radius: 50%; background: #8A8E94; border: 2px solid #111214; transition: background .3s, box-shadow .3s; }
#ty-app .node .port.in { left: -5.5px; }
#ty-app .node .port.out { right: -5.5px; }
#ty-app .node:first-of-type .port.in, #ty-app .node:last-of-type .port.out { display: none; }
#ty-app .node .label { display: grid; gap: 2px; text-align: center; }
#ty-app .node .label .nm { font-size: 0.78rem; font-weight: 600; line-height: 1.2; color: #F2F2F2; }
#ty-app .node .label .sub { font-size: 0.6875rem; color: #8B9096; }
#ty-app .node .count { top: -9px; right: -10px; background: #2E3136; border: 1px solid #5A5E64; color: #E3E5E8; font-size: 0.65rem; }
#ty-app .node.running .box { border-color: var(--c); box-shadow: 0 0 0 1px var(--c), 0 0 18px 2px var(--g), 0 0 46px 8px var(--g2); animation: nodeGlow 1.3s ease-in-out infinite; }
#ty-app .node.running .box::after { display: none; }
#ty-app .node.running .port { background: var(--c); box-shadow: 0 0 8px var(--c); }
#ty-app .node.done .box { border-color: var(--c); box-shadow: 0 0 14px var(--g2), inset 0 1px 0 rgba(255,255,255,.06); }
#ty-app .node.done .port { background: var(--c); }
/* A step that flagged items keeps its colour; the amber count says items went to review. */
#ty-app .node.review .box { border-color: var(--c); box-shadow: 0 0 14px var(--g2), inset 0 1px 0 rgba(255,255,255,.06); }
#ty-app .node.review .port { background: var(--c); }
#ty-app .node .count:empty { display: none !important; }
#ty-app .node.review .count { background: #F2B35B; color: #1A1408; border-color: #F2B35B; }
#ty-app .node.done .count { background: #2E3136; }
#ty-app .node[aria-pressed="true"] .box { background: linear-gradient(160deg, #3A3D42, #26292D); outline: 1.5px solid rgba(255,255,255,.55); outline-offset: 4px; }
#ty-app .node:focus-visible { outline: none; }
#ty-app .node:focus-visible .box { outline: 2px solid #fff; outline-offset: 4px; }
/* Final gate: a teal burst when the run is released */
#ty-app .node.success .box { border-color: #3FE0C5; box-shadow: 0 0 0 1px #3FE0C5, 0 0 24px rgba(63,224,197,.7); }
#ty-app .node.success .box::before { content: ""; position: absolute; inset: -44px; border-radius: 50%; z-index: -1; background: radial-gradient(circle, rgba(63,224,197,.42) 0 22%, rgba(63,224,197,.14) 46%, transparent 70%); animation: burst 2.6s ease-out infinite; pointer-events: none; }
#ty-app .node.success .box::after { content: ""; display: block; position: absolute; inset: -30px; border-radius: 50%; z-index: -1; background: repeating-conic-gradient(rgba(170,255,240,.38) 0 2deg, transparent 2deg 15deg); -webkit-mask: radial-gradient(circle, transparent 0 38%, #000 40%, transparent 70%); mask: radial-gradient(circle, transparent 0 38%, #000 40%, transparent 70%); animation: spin 14s linear infinite; pointer-events: none; }
@keyframes nodeGlow { 0%, 100% { box-shadow: 0 0 0 1px var(--c), 0 0 14px 1px var(--g), 0 0 34px 4px var(--g2); } 50% { box-shadow: 0 0 0 1px var(--c), 0 0 22px 3px var(--g), 0 0 56px 12px var(--g2); } }
@keyframes burst { 0% { transform: scale(.7); opacity: .9; } 70% { opacity: .5; } 100% { transform: scale(1.15); opacity: 0; } }
@keyframes spin { to { transform: rotate(360deg); } }

/* Wires and the comet that travels along them */
#ty-app .flow .wire { stroke: #4E5257; stroke-width: 1.6; transition: stroke .4s; }
#ty-app .flow .wire.live { stroke: #8D9399; }
#ty-app .flow .wire.flowing.to-agent { stroke: #C7D2FF; filter: drop-shadow(0 0 4px rgba(157,176,255,.8)); }
#ty-app .flow .wire.flowing.to-proc, #ty-app .flow .wire.flowing.to-trigger { stroke: #FFB27A; filter: drop-shadow(0 0 4px rgba(255,138,61,.8)); }
#ty-app .flow .wire.flowing.to-gate { stroke: #7FF0DB; filter: drop-shadow(0 0 4px rgba(63,224,197,.8)); }
#ty-app .flow .comet { fill: #F5F7FF; filter: drop-shadow(0 0 5px #9DB0FF) drop-shadow(0 0 10px rgba(157,176,255,.8)); }
#ty-app .flow .comet.proc, #ty-app .flow .comet.trigger { fill: #FFE6D2; filter: drop-shadow(0 0 5px #FF8A3D) drop-shadow(0 0 10px rgba(255,138,61,.8)); }
#ty-app .flow .comet.gate { fill: #E8FFFA; filter: drop-shadow(0 0 5px #3FE0C5) drop-shadow(0 0 10px rgba(63,224,197,.8)); }
#ty-app .flow .wire-label { fill: #7E858C; font-size: 10.5px; }

/* Inspector */
#ty-app .inspector { background: #0C0D0F; border-top: 1px solid rgba(255,255,255,.07); }
#ty-app .inspector-tabs { border-color: rgba(255,255,255,.18); border-radius: 6px; overflow: hidden; }
#ty-app .inspector-tabs button[aria-selected="true"] { background: #E9EAEC; color: #111214; }
#ty-app .inspector pre { color: #C9CED3; }
