/* features.css: Telegram simulator, bot map, site search, review mode (private).
   Colors come from tokens.css. Exception: the five app colors on bot-map node fills (see .bm). */

/* ---------- Telegram simulator ---------- */
.sim {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  margin-inline: auto;
  padding: var(--s3);
  gap: var(--s2);
  background: var(--cream-raised);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  color: var(--ink);
  font-size: var(--fs-s);
  line-height: 1.45;
}
.sim :focus-visible { outline-color: var(--copper-text); }

.sim__bar { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); }
.sim__who { display: flex; align-items: center; gap: var(--s3); min-width: 0; }
.sim__title { font-family: var(--font-display); font-size: var(--fs-body-l); font-weight: 400; letter-spacing: -.01em; white-space: nowrap; }
.sim__pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 var(--s3);
  border: 1px solid var(--copper-text);
  border-radius: var(--r-pill);
  color: var(--copper-text);
  font-size: var(--fs-s);
  font-weight: 600;
  line-height: 1;
}
.sim__reset {
  min-height: 44px;
  min-width: 44px;
  padding: 0 var(--s3);
  border: 0;
  border-radius: var(--r-0);
  background: transparent;
  font-size: var(--fs-s);
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
  cursor: pointer;
}
.sim__reset:hover { color: var(--ink); text-decoration-color: currentColor; }
.sim__note { font-size: var(--fs-s); line-height: 1.4; color: var(--ink-2); }

.sim__log {
  height: 176px;
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  padding: var(--s3);
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--line);
  border-radius: var(--r-0);
  background: var(--cream-2);
}
.sim__msg {
  position: relative;
  max-width: 88%;
  padding: var(--s2) var(--s3);
  border-radius: 18px;
  font-size: var(--fs-s);
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.sim__msg--user { align-self: flex-end; background: var(--copper); color: var(--on-copper); border-bottom-right-radius: var(--s1); }
.sim__msg--bot { align-self: flex-start; background: var(--cream-raised); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: var(--s1); }
.sim__msg--system {
  align-self: center;
  max-width: 100%;
  padding: var(--s1) var(--s3);
  border-radius: var(--r-pill);
  background: var(--pine);
  color: var(--on-pine);
  font-weight: 500;
}
.sim__time { display: block; margin-top: 2px; text-align: right; font-size: var(--fs-s); line-height: 1.2; }
.sim__typing { display: inline-flex; gap: 5px; padding: var(--s3) var(--s4); }
.sim__typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-2); opacity: .35; animation: sim-dot 1s var(--ease-out) infinite; }
.sim__typing i:nth-child(2) { animation-delay: .15s; }
.sim__typing i:nth-child(3) { animation-delay: .3s; }
@keyframes sim-dot { 0%, 100% { opacity: .3; } 40% { opacity: 1; } }

.sim__chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.sim__chip {
  min-height: 44px;
  padding: 0 var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--cream-raised);
  color: var(--ink);
  font-size: var(--fs-s);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background var(--dur-1) var(--ease-out), border-color var(--dur-1) var(--ease-out);
}
.sim__chip:hover { background: var(--cream-2); border-color: var(--ink); }
.sim__chip[aria-disabled="true"], .sim__send[aria-disabled="true"] { opacity: .5; cursor: progress; }

.sim__form { display: flex; gap: var(--s2); }
.sim__input {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 0 var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-0);
  background: var(--cream-raised);
  color: var(--ink);
  font: inherit;
  font-size: var(--fs-body);
}
.sim__input::placeholder { color: var(--ink-2); opacity: 1; }
.sim__send {
  min-height: 44px;
  min-width: 72px;
  padding: 0 var(--s4);
  border: 1px solid var(--copper);
  border-radius: var(--r-0);
  background: var(--copper);
  color: var(--on-copper);
  font-size: var(--fs-s);
  font-weight: 500;
  cursor: pointer;
}
.sim__send:hover { background: var(--copper-on-pine); border-color: var(--copper-on-pine); }

.sim__sheet { border-top: 1px solid var(--line); padding-top: var(--s1); }
.sim__sheet-title { display: flex; align-items: center; min-height: 44px; font-size: var(--fs-s); font-weight: 500; color: var(--ink); text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px; cursor: pointer; }
.sim__sheet[open] .sim__sheet-title { min-height: 36px; }
.sim__table { width: 100%; border-collapse: collapse; font-size: var(--fs-s); line-height: 1.4; }
.sim__table th { text-align: left; font-weight: 500; color: var(--ink-2); padding: 2px var(--s2) 2px 0; }
.sim__table td { padding: 2px var(--s2) 2px 0; border-top: 1px solid var(--line); }
.sim__none { color: var(--ink-2); }
.sim__status { font-weight: 600; }
.sim__status--pending { color: var(--copper-text); }
.sim__status--published { color: var(--ink); }
.sim__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

/* ---------- Bot map ---------- */
.bm {
  --app-tg: #6FB3D2; --app-sheet: #5FAE7E; --app-ai: #9CC1B4; --app-router: #E2B567; --app-tool: #FF9442;
  display: grid;
  grid-template-columns: minmax(0, 7fr) minmax(0, 5fr);
  grid-template-areas: "stage side" "stage detail";
  grid-template-rows: auto 1fr;
  gap: var(--s5) var(--s7);
  align-items: start;
  color: var(--on-pine);
}
.bm__stage { grid-area: stage; background: var(--pine-deep); }
.bm__side { grid-area: side; }
.bm__detail { grid-area: detail; padding-top: var(--s4); border-top: 1px solid var(--line-pine); }
.bm__svg { width: 100%; height: auto; }
.bm__bg { fill: var(--pine-deep); }
.bm__hint { margin-bottom: var(--s3); font-size: var(--fs-s); color: var(--on-pine-2); }
.bm__list { border-top: 1px solid var(--line-pine); }
.bm__list li { border-bottom: 1px solid var(--line-pine); }
.bm__btn {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  width: 100%;
  min-height: 44px;
  padding: var(--s2) var(--s3) var(--s2) var(--s2);
  border: 0;
  border-left: 3px solid transparent;
  background: transparent;
  color: var(--on-pine);
  font-size: var(--fs-s);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.bm__btn-n { color: var(--on-pine-2); font-variant-numeric: tabular-nums lining-nums; }
.bm__btn:hover { background: var(--pine-2); }
.bm__btn[aria-pressed="true"] { border-left-color: var(--copper); background: var(--pine-2); color: var(--copper-on-pine); }
.bm__btn[aria-pressed="true"] .bm__btn-n { color: var(--copper-on-pine); }
.bm :focus-visible { outline-color: var(--copper-on-pine); }
.bm__d-name { font-family: var(--font-display); font-size: var(--fs-body-l); font-weight: 400; color: var(--on-pine); }
.bm__d-row { margin-top: var(--s2); font-size: var(--fs-s); color: var(--on-pine-2); }
.bm__d-row strong { font-weight: 600; color: var(--on-pine); }
.bm__cap { margin-top: var(--s4); font-size: var(--fs-s); color: var(--on-pine-2); max-width: 62ch; }

.bm__wire { fill: none; stroke: var(--on-pine); stroke-opacity: .55; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 1 13; }
.bm__route { cursor: pointer; transition: opacity var(--dur-2) var(--ease-out); }
.has-pick .bm__route { opacity: .38; }
.has-pick .bm__route.is-on { opacity: 1; }
.bm__route.is-on .bm__wire { stroke: var(--copper-on-pine); stroke-opacity: 1; stroke-width: 7; }
.bm__hit { fill: transparent; }
.bm__node--tg { fill: var(--app-tg); }
.bm__node--sheet { fill: var(--app-sheet); }
.bm__node--ai { fill: var(--app-ai); }
.bm__node--router { fill: var(--app-router); }
.bm__node--tool { fill: var(--app-tool); }
.bm__glyph { fill: none; stroke: var(--pine-deep); stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.bm__glyph--fill path { fill: var(--pine-deep); stroke: none; }
.bm__ai { fill: var(--pine-deep); stroke-width: 5; }
.bm__ai--ai { stroke: var(--app-ai); }
.bm__ai--tg { stroke: var(--app-tg); }
.bm__ai--sheet { stroke: var(--app-sheet); }
.bm__ai--router { stroke: var(--app-router); }
.bm__ai--tool { stroke: var(--app-tool); }
.bm__num { fill: var(--on-pine-2); font-family: var(--font-body); font-size: 64px; font-weight: 600; }
.bm__route.is-on .bm__num { fill: var(--copper-on-pine); }
.bm__label { fill: var(--on-pine-2); font-family: var(--font-body); font-size: 46px; font-weight: 500; }
.bm__dot { fill: var(--copper); stroke: var(--on-pine); stroke-width: 5; }

@media (max-width: 899px) {
  .bm { grid-template-columns: minmax(0, 1fr); grid-template-areas: "side" "detail" "stage"; gap: var(--s5); }
  .bm__label { display: none; }
}

/* ---------- Command menu ---------- */
.cmd { position: fixed; inset: 0; z-index: 80; display: flex; align-items: flex-start; justify-content: center; padding: 16vh var(--s4) var(--s4); }
.cmd[hidden] { display: none; }
.cmd__scrim { position: absolute; inset: 0; background: var(--scrim); opacity: 0; transition: opacity var(--dur-2) var(--ease-out); }
.cmd__box {
  position: relative;
  width: min(560px, 100%);
  max-height: 70svh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--r-1);
  background: var(--cream-raised);
  border: 1px solid var(--line-strong);
  color: var(--ink);
  opacity: 0;
  transition: opacity var(--dur-2) var(--ease-out);
}
.cmd.is-open .cmd__scrim, .cmd.is-open .cmd__box { opacity: 1; }
.cmd__top { display: flex; align-items: center; gap: var(--s2); padding: var(--s3) var(--s3) var(--s3) var(--s5); border-bottom: 1px solid var(--line); }
.cmd__input { flex: 1 1 auto; min-width: 0; min-height: 44px; border: 0; background: transparent; color: var(--ink); font: inherit; font-size: var(--fs-body-l); }
.cmd__input::placeholder { color: var(--ink-2); opacity: 1; }
.cmd__input:focus-visible { outline: none; }
.cmd__top:focus-within { box-shadow: inset 0 -2px 0 var(--copper-text); }
.cmd__close {
  min-height: 44px;
  min-width: 44px;
  padding: 0 var(--s3);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-0);
  background: transparent;
  font-size: var(--fs-s);
  font-weight: 500;
  cursor: pointer;
}
.cmd__close:hover { background: var(--cream-2); }
.cmd__list { overflow-y: auto; padding: var(--s2); }
.cmd__opt { display: flex; align-items: center; min-height: 44px; padding: 0 var(--s4); border-radius: var(--r-0); font-size: var(--fs-body); cursor: pointer; }
.cmd__opt[aria-selected="true"] { background: var(--pine); color: var(--on-pine); }
.cmd__empty { padding: var(--s5); color: var(--ink-2); font-size: var(--fs-body); }
.cmd[hidden], .cmd__list[hidden], .cmd__empty[hidden] { display: none; }

/* ---------- Review mode (private; stripped from the public build) ---------- */
.rv-bar { position: fixed; right: max(16px, env(safe-area-inset-right, 0px)); bottom: max(16px, env(safe-area-inset-bottom, 0px)); z-index: 70; display: flex; gap: var(--s2); }
.rv-pill, .rv-btn {
  min-height: 44px;
  padding: 0 var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  background: var(--cream-raised);
  color: var(--ink);
  font-size: var(--fs-s);
  font-weight: 600;
  cursor: pointer;
}
.rv-pill:hover, .rv-btn:hover { background: var(--cream-2); }
.rv-pill[aria-pressed="true"], .rv-btn--solid { background: var(--pine); color: var(--on-pine); border-color: var(--pine); }
.rv-pill[aria-pressed="true"]:hover, .rv-btn--solid:hover { background: var(--pine-deep); }
.rv-pill[hidden], .rv-panel[hidden], .rv-add[hidden] { display: none; }
.rv-count { font-variant-numeric: tabular-nums lining-nums; }

.rv-panel {
  position: fixed;
  top: calc(var(--nav-h) + 16px);
  right: max(16px, env(safe-area-inset-right, 0px));
  bottom: 76px;
  z-index: 70;
  width: min(380px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-strong);
  border-radius: var(--r-1);
  background: var(--cream-raised);
  overflow: hidden;
  color: var(--ink);
}
.rv-panel__head, .rv-panel__foot { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); padding: var(--s3) var(--s4); }
.rv-panel__head { border-bottom: 1px solid var(--line); }
.rv-panel__foot { border-top: 1px solid var(--line); flex-wrap: wrap; }
.rv-panel__title { font-family: var(--font-display); font-size: var(--fs-body-l); font-weight: 400; }
.rv-list { flex: 1 1 auto; overflow-y: auto; padding: 0 var(--s4); }
.rv-empty { padding: var(--s5) 0; color: var(--ink-2); font-size: var(--fs-s); }
.rv-item { display: grid; gap: var(--s1); padding: var(--s4) 0; border-bottom: 1px solid var(--line); font-size: var(--fs-s); line-height: 1.45; }
.rv-item__meta { font-size: var(--fs-s); font-weight: 600; color: var(--copper-text); }
.rv-item__orig { color: var(--ink-2); text-decoration: line-through; text-decoration-color: var(--line-strong); }
.rv-item .rv-btn { justify-self: start; margin-top: var(--s2); }

.rv-add { position: fixed; z-index: 75; min-height: 44px; padding: 0 var(--s4); border: 1px solid var(--line-strong); border-radius: var(--r-pill); background: var(--cream-raised); font-size: var(--fs-s); font-weight: 600; color: var(--ink); cursor: pointer; }
.rv-pop { position: fixed; z-index: 76; width: min(320px, calc(100vw - 16px)); padding: var(--s3); border: 1px solid var(--line-strong); border-radius: var(--r-1); background: var(--cream-raised); }
.rv-pop__text { width: 100%; padding: var(--s3); border: 1px solid var(--line-strong); border-radius: var(--r-0); background: var(--cream-raised); color: var(--ink); font: inherit; font-size: var(--fs-s); resize: vertical; }
.rv-pop__row { display: flex; justify-content: flex-end; gap: var(--s2); margin-top: var(--s2); }

.rv-on main :is(h1, h2, h3, p, li, figcaption, td, dd, dt, small, a, button):not([data-sim] *):hover { outline: 1px dashed var(--copper-text); outline-offset: 3px; cursor: text; }
.rv-on main img:hover { outline: 2px dashed var(--copper-text); outline-offset: 3px; cursor: pointer; }
.rv-on .rv-editing, .rv-editing { outline: 2px solid var(--copper-text); outline-offset: 3px; cursor: text; }
.rv-mark { background: var(--copper); color: inherit; border-radius: var(--r-0); }
.rv-noted { outline: 3px solid var(--copper); outline-offset: 3px; }

@media (prefers-reduced-motion: reduce) {
  .sim__typing i { animation: none; opacity: .7; }
  .cmd__scrim, .cmd__box { transition-duration: 120ms; }
}

/* No-JS fallback inside a sim mount; the script replaces it */
.sim-fallback { margin: 0; max-width: 46ch; color: var(--on-pine); font-size: var(--fs-body); line-height: 1.5; }
