/* Toolbox service pages and their demos. The hero splits paper and the service's field, like
   the AI detail page; demos sit in 2px ink frames on paper. */
.tool-hero-x { background: linear-gradient(90deg, var(--paper) 0 58%, var(--x) 58% 100%); }
.tool-hero-y { background: linear-gradient(90deg, var(--paper) 0 58%, var(--y) 58% 100%); }
.tool-hero-z { background: linear-gradient(90deg, var(--paper) 0 58%, var(--z) 58% 100%); }
[dir='rtl'] .tool-hero-x { background: linear-gradient(270deg, var(--paper) 0 58%, var(--x) 58% 100%); }
[dir='rtl'] .tool-hero-y { background: linear-gradient(270deg, var(--paper) 0 58%, var(--y) 58% 100%); }
[dir='rtl'] .tool-hero-z { background: linear-gradient(270deg, var(--paper) 0 58%, var(--z) 58% 100%); }
.tool-hero-x .fit-stack li::before { border-radius: 0; background: var(--x); }
.tool-hero-y .fit-stack li::before { background: var(--y); }

.tp-two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(28px, 5vw, 72px); }
.tp-two > div { display: grid; gap: 20px; align-content: start; border-top: var(--rule); padding-top: 24px; }
.tp-two h2 { font-size: clamp(1.6rem, 1.3rem + 1.2vw, 2.4rem); }
.tp-list { list-style: none; display: grid; }
.tp-list li { display: grid; grid-template-columns: 14px minmax(0, 1fr); gap: 14px; align-items: baseline; padding-block: 14px; border-bottom: var(--hair); color: var(--ink-2); }
.tp-list li::before { content: ''; width: 12px; height: 12px; background: var(--ink); translate: 0 1px; }
.tp-list-y li::before, .tp-list-z li::before { border-radius: 50%; }
.tp-dl { margin: 0; display: grid; }
.tp-dl div { padding-block: 14px; border-bottom: var(--hair); display: grid; gap: 4px; }
.tp-dl dt { font-weight: 700; }
.tp-dl dd { margin: 0; color: var(--ink-2); }

/* Shared demo frame */
.td { border: var(--rule); background: var(--paper); padding: clamp(16px, 2.4vw, 32px); display: grid; gap: 20px; }
.td-note { font-size: var(--text-xs); color: var(--ink-2); max-width: 70ch; }
.td-replay { justify-self: start; }
.ctl-sm { min-height: 40px; padding: 6px 12px; font-size: var(--text-sm); }
.tool-demo-x .td { box-shadow: inset 0 10px 0 var(--x); padding-top: clamp(26px, 3vw, 42px); }
.tool-demo-y .td { box-shadow: inset 0 10px 0 var(--y); padding-top: clamp(26px, 3vw, 42px); }
.tool-demo-z .td { box-shadow: inset 0 10px 0 var(--z); padding-top: clamp(26px, 3vw, 42px); }

/* 1. Upgrade or rebuild */
.td-upgrade { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; gap: clamp(20px, 3vw, 40px); }
.dq-list { list-style: none; display: grid; border-top: var(--rule); counter-reset: dq; }
.dq-list li { counter-increment: dq; padding-block: 14px; border-bottom: var(--hair); }
.dq-list fieldset { border: 0; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px 20px; align-items: center; }
.dq-list legend { float: inline-start; font-weight: 700; padding: 0; }
.dq-list legend::before { content: counter(dq) '. '; font-family: var(--display); font-weight: 400; }
.dq-opts { display: inline-flex; justify-self: start; border: 2px solid var(--ink); }
.dq-opts label { position: relative; }
.dq-opts label + label { border-inline-start: 2px solid var(--ink); }
.dq-opts input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.dq-opts span { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; min-width: 64px; padding: 6px 14px; font-weight: 700; font-size: var(--text-sm); }
.dq-opts input:checked + span { background: var(--ink); color: var(--paper); }
.dq-opts input:focus-visible + span { outline: 3px solid var(--y); outline-offset: 2px; }
.dq-result { position: sticky; top: 96px; border: var(--rule); padding: 20px; display: grid; gap: 10px; align-content: start; }
.dq-result h3 { font-size: clamp(1.5rem, 1.2rem + 1vw, 2.1rem); }
.dq-label, .dq-why-label { font-size: var(--text-xs); font-weight: 700; color: var(--ink-2); }
.dq-why { list-style: none; display: grid; gap: 6px; }
.dq-why li { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 10px; align-items: baseline; color: var(--ink-2); font-size: var(--text-sm); }
.dq-why li::before { content: ''; width: 10px; height: 10px; background: var(--x); }
.dq-keep { border-top: var(--hair); padding-top: 10px; font-size: var(--text-sm); }
.dq-result[data-win='u'] { box-shadow: inset 0 8px 0 var(--ink); }
.dq-result[data-win='m'], .dq-result[data-win='r'] { box-shadow: inset 0 8px 0 var(--x); }
.dq-result { padding-top: 28px; }

/* 2. Accessibility check */
.ac-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(16px, 2.4vw, 32px); align-items: start; }
.ac-code { margin: 0; background: var(--g-50); border: var(--rule); padding: 16px; overflow-x: auto; font: 0.85rem/1.65 ui-monospace, 'SF Mono', Menlo, monospace; white-space: pre; text-align: left; }
.ac-code:focus-visible { outline: 3px solid var(--y); outline-offset: 2px; }
.ac-report { display: grid; gap: 12px; align-content: start; }
.ac-count { font: 400 var(--h3)/1.2 var(--display); }
.td-a11y[data-state='after'] .ac-count { color: var(--ink); }
.ac-issues { list-style: none; display: grid; border-top: var(--rule); }
.ac-issues li { display: grid; gap: 2px; padding-block: 10px; border-bottom: var(--hair); font-size: var(--text-sm); }
.ac-issues span:last-child { color: var(--ink-2); }
.ac-line { justify-self: start; font-size: var(--text-xs); font-weight: 700; padding: 1px 8px; background: var(--x); color: var(--paper); }
.ac-sr { font-size: var(--text-sm); color: var(--ink-2); }
.ac-sr q { color: var(--ink); font-weight: 700; }

/* 3. Business system */
.biz-rule { background: var(--y-50); border: 2px solid var(--y); padding: 14px 18px; font-weight: 700; }
.biz-grid { display: grid; grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); gap: clamp(16px, 2.4vw, 32px); align-items: start; }
.biz-panel { display: grid; gap: 12px; align-content: start; }
.biz-panel h3 { font-size: var(--h3); }
.biz-scroll { overflow-x: auto; }
.biz-scroll:focus-visible { outline: 3px solid var(--y); outline-offset: 2px; }
.biz-table { width: 100%; border-collapse: collapse; border-top: var(--rule); font-size: var(--text-sm); }
.biz-table th, .biz-table td { text-align: start; padding: 10px 8px; border-bottom: var(--hair); vertical-align: middle; }
.biz-table thead th { font-size: var(--text-xs); color: var(--ink-2); }
.biz-table td:nth-child(2), .biz-table td:nth-child(3) { font-variant-numeric: tabular-nums; }
.biz-table tr.is-low [data-qty] { font-weight: 700; }
.low-tag { display: inline-block; font-size: var(--text-xs); font-weight: 700; padding: 1px 6px; border: 2px solid var(--ink); }
.biz-tasks { list-style: none; display: grid; gap: 8px; }
.biz-tasks li { display: grid; gap: 4px; padding: 12px 14px; background: var(--y); color: var(--paper); }
.biz-tasks li span { font-size: var(--text-sm); opacity: 0.9; }
.biz-tasks .text-link { justify-self: start; color: var(--paper); background: none; border: 0; padding: 0; min-height: 32px; font: inherit; font-weight: 700; text-decoration-color: var(--paper); cursor: pointer; }
.biz-none { color: var(--ink-2); font-size: var(--text-sm); }
.biz-log-title { margin-top: 8px; }
.biz-log { list-style: none; display: grid; border-top: var(--hair); font-size: var(--text-xs); color: var(--ink-2); max-height: 11.5em; overflow: hidden; }
.biz-log li { padding-block: 5px; border-bottom: var(--hair); }

/* 4. Data extraction */
.td-extract { grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); align-items: start; gap: clamp(16px, 2.4vw, 32px); }
.ex-page { border: var(--rule); background: var(--paper); font-size: var(--text-xs); }
.ex-bar { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--g-50); border-bottom: 2px solid var(--ink); }
.ex-bar i { width: 8px; height: 8px; border-radius: 50%; background: var(--g-200); }
.ex-bar span { margin-inline-start: 6px; color: var(--ink-2); }
.ex-title { padding: 10px 12px 0; font-weight: 700; }
.ex-cards { list-style: none; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; padding: 10px 12px 14px; }
.ex-cards li { display: grid; gap: 3px; border: 1px solid var(--g-200); padding: 6px; transition: background-color 200ms var(--ease); }
.ex-cards li.is-read { background: var(--y-50); }
.ex-img { height: 34px; background: var(--g-50); }
.ex-price { font-weight: 700; }
.ex-sku { color: var(--g-500); }
.ex-out { display: grid; gap: 12px; align-content: start; }
.ex-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.ex-scroll { overflow-x: auto; }
.ex-scroll:focus-visible { outline: 3px solid var(--y); outline-offset: 2px; }
.ex-table { width: 100%; border-collapse: collapse; border-top: var(--rule); font-size: var(--text-sm); }
.ex-table th, .ex-table td { text-align: start; padding: 9px 8px; border-bottom: var(--hair); white-space: nowrap; }
.ex-table td:nth-child(2) { white-space: normal; }
.ex-table thead th { font-size: var(--text-xs); color: var(--ink-2); }
.ex-flag { display: inline-block; font-size: var(--text-xs); font-weight: 700; padding: 1px 6px; border: 2px solid var(--ink); }
.ex-miss .ex-flag { background: var(--ink); color: var(--paper); }
.ex-ok .ex-flag { border-color: var(--g-200); color: var(--ink-2); }
.ex-summary { font-size: var(--text-sm); font-weight: 700; }

/* 5. Dashboard */
.dash-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.dash-sample { font-size: var(--text-xs); font-weight: 700; padding: 2px 8px; border: 2px solid var(--ink); }
.dash-tiles { list-style: none; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: var(--rule); border-bottom: var(--rule); }
.dash-tile { display: grid; gap: 6px; align-content: start; padding: 18px clamp(12px, 1.6vw, 20px); }
.dash-tile + .dash-tile { border-inline-start: var(--hair); }
.dt-name { font-size: var(--text-sm); font-weight: 700; }
.dt-val { font: 400 clamp(1.7rem, 1.3rem + 1.4vw, 2.6rem)/1.05 var(--display); font-variant-numeric: tabular-nums; }
.dt-src { font-size: var(--text-xs); color: var(--ink-2); }
.dt-stale { display: grid; grid-template-columns: 12px minmax(0, 1fr); gap: 8px; align-items: baseline; font-size: var(--text-xs); font-weight: 700; }
.dt-stale::before { content: ''; width: 10px; height: 10px; background: var(--z); outline: 2px solid var(--ink); }
.dash-tile.is-stale .dt-val { color: var(--ink-2); }
.dash-chart { margin: 0; display: grid; gap: 12px; }
.dash-chart figcaption { font-weight: 700; font-size: var(--text-sm); }
.dash-bars { list-style: none; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: clamp(6px, 1.2vw, 14px); align-items: end; height: 190px; border-bottom: 2px solid var(--ink); }
.dash-bars li { display: grid; grid-template-rows: auto 1fr; justify-items: center; gap: 4px; height: 100%; position: relative; }
.db-val { font-size: var(--text-xs); font-weight: 700; align-self: end; }
.db-bar { width: 100%; height: var(--h); background: var(--y); align-self: end; transform-origin: bottom; }
.dash-bars li:last-child .db-bar { background: var(--ink); }
.db-wk { position: absolute; bottom: -22px; font-size: var(--text-xs); color: var(--ink-2); }
.dash-chart { padding-bottom: 22px; }
.td-dash.is-counting .db-bar { animation: db-grow 700ms var(--ease) backwards; }
@keyframes db-grow { from { scale: 1 0; } }

/* 6. Chatbot */
.td-bot { grid-template-columns: minmax(0, 7fr) minmax(0, 5fr); align-items: start; gap: clamp(16px, 2.4vw, 32px); }
.bot-frame { border: var(--rule); display: grid; grid-template-rows: auto 1fr; min-height: 360px; }
.bot-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 2px solid var(--ink); font-weight: 700; background: var(--z); }
.bot-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--ink); }
.bot-log { display: grid; gap: 12px; align-content: start; padding: 16px; max-height: 440px; overflow-y: auto; }
.bot-log > div { max-width: 88%; padding: 10px 14px; font-size: var(--text-sm); display: grid; gap: 8px; }
.bot-user { justify-self: end; background: var(--ink); color: var(--paper); }
.bot-bot { justify-self: start; border: 2px solid var(--ink); background: var(--paper); }
.bot-src { font-size: var(--text-xs); font-weight: 700; text-decoration: underline; text-decoration-color: var(--z); text-decoration-thickness: 2px; }
.bot-typing { justify-self: start; border: 2px solid var(--ink); display: inline-flex !important; grid-auto-flow: column; gap: 5px !important; padding: 12px 14px !important; }
.bot-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--ink); animation: bot-dot 900ms ease-in-out infinite; }
.bot-typing i:nth-child(2) { animation-delay: 150ms; }
.bot-typing i:nth-child(3) { animation-delay: 300ms; }
@keyframes bot-dot { 50% { opacity: 0.25; } }
.bot-handed { justify-self: start; font-size: var(--text-xs) !important; font-weight: 700; border: 2px dashed var(--ink); }
.bot-handoff { justify-self: start; }
.bot-side { display: grid; gap: 12px; align-content: start; }
.bot-pick { font-weight: 700; }
.bot-qs { list-style: none; display: grid; border-top: var(--rule); }
.bot-q { width: 100%; text-align: start; min-height: 48px; padding: 10px 4px; background: none; border: 0; border-bottom: var(--hair); font: 700 var(--text-sm)/1.35 var(--text-font); color: var(--ink); cursor: pointer; }
.bot-q:hover { background: var(--g-50); }
.bot-q[aria-pressed='true'] { text-decoration: underline; text-decoration-color: var(--z); text-decoration-thickness: 3px; }

@media (max-width: 980px) {
  .tool-hero-x, .tool-hero-y, .tool-hero-z, [dir='rtl'] .tool-hero-x, [dir='rtl'] .tool-hero-y, [dir='rtl'] .tool-hero-z { background: var(--paper); }
  .tool-hero-x .fit-stack li { background: var(--x); color: var(--paper); }
  .tool-hero-y .fit-stack li { background: var(--y); color: var(--paper); }
  .tool-hero-x .fit-stack li::before, .tool-hero-y .fit-stack li::before { background: var(--paper); }
  .td-upgrade, .ac-grid, .biz-grid, .td-extract, .td-bot, .tp-two { grid-template-columns: minmax(0, 1fr); }
  .dq-result { position: static; }
  .dash-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dash-tile:nth-child(3) { border-inline-start: 0; }
  .dash-tile:nth-child(n + 3) { border-top: var(--hair); }
}
@media (max-width: 680px) {
  .dq-list fieldset { grid-template-columns: minmax(0, 1fr); }
  .ex-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .low-tag { display: table; margin-top: 4px; }
  .biz-table th, .biz-table td { padding-inline: 4px; }
  .dash-tiles { grid-template-columns: minmax(0, 1fr); }
  .dash-tile + .dash-tile { border-inline-start: 0; border-top: var(--hair); }
  .bot-log > div { max-width: 100%; }
}
@media (prefers-reduced-motion: reduce) {
  .bot-typing i, .td-dash.is-counting .db-bar { animation: none; }
}
