/* Rotinas (rt-) e Trilhas (tr-), e as peças do demo do herói que vivem fora da janela. */

.demo-hint { max-width: 820px; margin: 14px auto 0; text-align: center; font-size: 13px; font-weight: 600; color: var(--ink3); line-height: 1.55; text-wrap: pretty; }
.demo-hint b { color: var(--ink2); }
.demo-nojs { padding: 40px; text-align: center; font-weight: 700; color: var(--ink2); }
.d-chip.is-bad { color: var(--bad); background: #FBE9E7; border-color: #F3C4BE; }

/* interruptor (o mesmo do app) */
.toggle-ui { position: relative; width: 34px; height: 20px; flex: none; border-radius: var(--r-pill); background: var(--line2); transition: background .18s; }
.toggle-ui::after { content: ''; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px #0003; transition: translate .18s var(--ease); }
input:checked + .toggle-ui { background: var(--pink); }
input:checked + .toggle-ui::after { translate: 14px 0; }
input:focus-visible + .toggle-ui { outline: 2px solid var(--pink); outline-offset: 2px; }
.rt-sw, .tr-opt { display: inline-flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 750; cursor: pointer; user-select: none; }
.rt-sw input, .tr-opt input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tr-opt input:disabled + .toggle-ui { opacity: .5; }

/* ---------- rotinas ---------- */
.rt-card { background: var(--surface); border: 1px solid var(--line2); border-radius: var(--r-md); box-shadow: var(--shadow-card); overflow: hidden; }

/* ---------- trilhas ---------- */
.tr { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: stretch; }
.tr-stage { min-width: 0; background: var(--bg); border: 1px solid var(--line2); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-card); display: flex; flex-direction: column; }
.tr-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 10px 12px 10px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.tr-title { display: flex; align-items: center; gap: 8px; font-size: 13.5px; margin-right: auto; }
.tr-title > .ic { color: var(--pink); }
.tr-title strong { font-weight: 800; }
.tr-acts { display: flex; gap: 6px; }
.tr-fit { position: relative; flex: 1; overflow: hidden; background-image: radial-gradient(circle, #cbc9c3 1.1px, transparent 1.4px); background-size: 24px 24px; padding: 18px 0; }
.tr-fit.is-scroll { overflow-x: auto; }
.tr-fit > div { margin: 0 auto; }
.tr-canvas { position: relative; transform-origin: 0 0; }
.tr-edges { position: absolute; inset: 0; overflow: visible; }
.tr-e { fill: none; stroke: #B9B6BE; stroke-width: 2; transition: stroke .2s; }
.tr-e.is-done { stroke: #8FCBA8; }
.tr-e.is-on { stroke: var(--pink); stroke-width: 2.5; stroke-dasharray: 7 6; animation: d-dash .9s linear infinite; }
.tr-el { font: 800 11px var(--sans); fill: var(--ink3); paint-order: stroke; stroke: var(--bg); stroke-width: 4px; }
.tr-el.is-on { fill: var(--pink-ink); }
.tr-n { position: absolute; display: flex; flex-direction: column; gap: 3px; min-height: 92px; padding: 9px 11px 10px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line2); box-shadow: 0 1px 2px #29222c12, 0 8px 20px #29222c0f; transition: box-shadow .2s, border-color .2s; }
.tr-nh { display: flex; align-items: center; gap: 7px; }
.tr-nh img { width: 22px; height: 22px; border-radius: 50%; }
.tr-ic { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: var(--raised); color: var(--ink2); }
.tr-ic .ic { width: 13px; height: 13px; }
.tr-nh small { font-size: 10.5px; font-weight: 800; color: var(--ink3); text-transform: uppercase; letter-spacing: .04em; }
.tr-n .tr-st { margin-left: auto; width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line2); position: relative; }
.tr-n strong { font-size: 13.5px; font-weight: 800; line-height: 1.25; }
.tr-n strong.is-mono { font: 500 13px var(--mono); }
.tr-sub { font-size: 11.5px; font-weight: 650; color: var(--ink3); }
.tr-trigger .tr-ic { background: var(--pink-soft); color: var(--pink-ink); }
.tr-condition .tr-ic { background: #FDF3DD; color: var(--warn); }
.tr-command .tr-ic { background: #222124; color: #fff; }
.tr-n[data-st="run"] { border-color: var(--pink); box-shadow: 0 0 0 3px #fc3b7f2e, 0 10px 24px #29222c1a; }
.tr-n[data-st="run"] .tr-st { border: 0; border-radius: 3px; width: 9px; height: 9px; margin-right: 2px; background: var(--pink); animation: pulse 1.1s infinite; }
.tr-n[data-st="run"] .tr-sub { color: var(--pink-ink); }
.tr-n[data-st="ok"] .tr-st { border: 0; background: var(--ok); }
.tr-n[data-st="ok"] .tr-st::after { content: ''; position: absolute; left: 4.5px; top: 3px; width: 3.5px; height: 6px; border: 2px solid #fff; border-top: 0; border-left: 0; rotate: 45deg; }
.tr-n[data-st="ok"] .tr-sub { color: var(--ok-ink); }
.tr-n[data-st="bad"] { border-color: #F3C4BE; }
.tr-n[data-st="bad"] .tr-st { border: 0; background: var(--bad); }
.tr-n[data-st="bad"] .tr-st::after { content: '!'; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font: 900 10px var(--sans); }
.tr-n[data-st="bad"] .tr-sub { color: var(--bad); }
.tr-n[data-st="wait"] { border-color: #E8C57A; box-shadow: 0 0 0 3px #f0ca8159, 0 10px 24px #29222c1a; }
.tr-n[data-st="wait"] .tr-st { border-color: #C99A2E; border-style: dashed; animation: spin 2.4s linear infinite; }
.tr-n[data-st="wait"] .tr-sub { color: var(--warn); }
@keyframes spin { to { rotate: 360deg; } }
.tr-ap { display: flex; gap: 6px; margin-top: 6px; }
.tr-ap .btn { min-height: 26px; padding: 0 9px; font-size: 11.5px; }
.tr-ap .btn:disabled { opacity: .45; cursor: default; filter: none; }
.tr-from { position: absolute; left: 50%; bottom: -13px; translate: -50% 0; display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: var(--r-pill); border: 1px solid var(--stroke); background: var(--surface); font: 750 10.5px var(--sans); color: var(--ink2); white-space: nowrap; cursor: pointer; box-shadow: 0 2px 6px #29222c1a; opacity: 0; transition: opacity .15s; }
.tr-from .ic { width: 10px; height: 10px; }
.tr-n:hover .tr-from:not([hidden]), .tr-from:focus-visible { opacity: 1; }
.tr-from[hidden] { display: none; }
.tr-side { display: flex; flex-direction: column; min-height: 0; max-height: 520px; background: #19181B; border-radius: var(--r-md); overflow: hidden; color: #E9E7EE; box-shadow: var(--shadow-card); }
.tr-log-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; border-bottom: 1px solid #2E2D33; font-size: 13px; }
.tr-log-h span { font-size: 11.5px; font-weight: 700; color: #9C99A6; }
.tr-log { flex: 1; min-height: 240px; overflow-y: auto; overscroll-behavior: contain; padding: 8px 6px 10px; display: flex; flex-direction: column; gap: 2px; scrollbar-width: thin; scrollbar-color: #3a3940 transparent; }
.tr-log li { display: grid; grid-template-columns: 52px minmax(0, 1fr); gap: 2px 8px; padding: 6px 8px; border-radius: 8px; font-size: 12px; line-height: 1.5; font-weight: 550; animation: d-in .25s var(--ease); }
.tr-log li.tr-empty { display: block; color: #9C99A6; font-weight: 600; animation: none; }
.tr-log li.tr-empty b { color: #fff; }
.tr-log time { font: 400 10.5px/1.9 var(--mono); color: #77747F; }
.tr-log span img { width: 16px; height: 16px; border-radius: 50%; vertical-align: -3px; margin-right: 5px; }
.tr-log code { font: 400 11px var(--mono); color: #FF9CC0; }
.tr-log b { color: #fff; }
.tr-log pre { grid-column: 2; margin: 4px 0 2px; padding: 7px 9px; border-radius: 8px; background: #0F0F11; font: 400 10.5px/1.6 var(--mono); color: #CFCCD6; white-space: pre-wrap; word-break: break-word; }
.tr-l-ok { background: #1F3A2B66; }
.tr-l-bad { background: #4A1F1C66; }
.tr-l-wait { background: #4A3A1466; }
.tr-result { display: flex; gap: 10px; align-items: flex-start; margin: 0 10px 10px; padding: 11px 12px; border-radius: 12px; font-size: 12.5px; font-weight: 650; line-height: 1.5; }
.tr-result .ic { width: 18px; height: 18px; flex: none; padding: 3px; border-radius: 50%; color: #fff; }
.tr-result.is-ok { background: #1F3A2B; color: #D9F2E2; }
.tr-result.is-ok .ic { background: var(--ok); }
.tr-result.is-bad { background: #4A1F1C; color: #F7D9D5; }
.tr-result.is-bad .ic { background: var(--bad); }

@media (max-width: 1020px) {
  .tr { grid-template-columns: 1fr; }
  .tr-side { max-height: 420px; }
}
@media (max-width: 720px) {
  .rt-body { grid-template-columns: 1fr; }
  .rt-list { border-right: 0; border-bottom: 1px solid var(--line); }
  .rt-detail { padding: 14px; }
  .tr-top { gap: 10px; }
  .tr-from { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .tr-e.is-on, .tr-n[data-st="wait"] .tr-st { animation: none; }
}

/* Rotinas: a conversa com a Luna (live.js). */
.rt-card { display: flex; flex-direction: column; height: 540px; }
.rc-feed { flex: 1; min-height: 0; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; background: var(--chat); scroll-behavior: smooth; }
.rc-msg { display: flex; gap: 10px; animation: d-in .35s var(--ease); }
.rc-face { width: 30px; height: 30px; border-radius: 50%; flex: none; }
.rc-body { min-width: 0; flex: 1; }
.rc-body > b { display: block; font-size: 13px; font-weight: 800; margin-bottom: 3px; }
.rc-body > p { font-size: 14px; line-height: 1.5; color: var(--ink); margin: 0 0 8px; }
.rc-me { margin-left: auto; max-width: 82%; padding: 10px 14px; border-radius: 18px 18px 4px 18px; background: var(--ink); color: #fff; font-size: 14px; line-height: 1.45; }
.rc-think { display: flex; align-items: center; height: 22px; }
.rc-card { margin: 4px 0 10px; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line2); }
.rc-card strong { display: block; font-size: 15px; font-weight: 800; }
.rc-when { display: block; margin-top: 2px; font-size: 13px; font-weight: 650; color: var(--pink-ink); }
.rc-card ol { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 8px; }
.rc-card li { display: flex; align-items: center; gap: 9px; font-size: 13.5px; color: var(--ink2); }
.rc-card li .rc-face { width: 24px; height: 24px; }
.rc-card li b { color: var(--ink); }
.rc-status { align-items: center; }
.rc-status p { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 650; color: var(--ink2); }
.rc-post { flex-direction: column; gap: 6px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.rc-in { font-size: 12px; font-weight: 750; color: var(--ink3); }
.rc-row { display: flex; gap: 10px; }
.rc-row .rc-body > p { margin: 0; }
.rc-compose { display: flex; align-items: center; gap: 10px; margin: 0; padding: 10px 12px 10px 16px; border-top: 1px solid var(--line); background: var(--surface); }
.rc-field { flex: 1; min-height: 22px; font-size: 14px; color: var(--ink); }
.rc-field:empty::before { content: 'Escreva para a Luna…'; color: var(--ink3); }
.rc-send { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--pink); color: #fff; flex: none; }
.rc-send .ic { width: 16px; height: 16px; }
.rc-try { margin: 16px 0 8px; font-size: 13px; font-weight: 750; color: var(--ink3); }
.rc-asks { display: flex; flex-wrap: wrap; gap: 8px; }
.rc-asks button { height: 34px; padding: 0 14px; border-radius: var(--r-pill); border: 1px solid var(--stroke); background: var(--surface); font: 750 13px var(--sans); color: var(--ink2); cursor: pointer; }
.rc-asks button:hover { color: var(--ink); border-color: var(--line2); }
.rc-asks button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
