/* Майстер апарата ланцюжком (етап 2б, T-0299) — packages/ui/apparatus-wizard.js; той самий
   вигляд беруть малі майстри речей (thing-wizard.js).
   Вікно на весь крок: ліворуч питання, праворуч те, що вже пораховано; на телефоні
   результат — смугою під питанням (згортка, головне видно завжди). Підключає скрипт майстра, коли його відкривають. */
.aw {
  width: min(1040px, calc(100vw - 24px)); height: min(92vh, 780px); max-width: none; max-height: none;
  padding: 0; border: 1px solid var(--border-gold); border-radius: var(--radius-md);
  background: var(--surface); color: var(--text); box-shadow: var(--shadow-lift); overflow: hidden;
}
.aw::backdrop { background: rgba(27, 77, 62, .4); }
.aw[open] { animation: aw-in 200ms cubic-bezier(.23, 1, .32, 1); }
@keyframes aw-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@media (prefers-reduced-motion: reduce) { .aw[open] { animation: none; } }
.aw-in { display: flex; flex-direction: column; height: 100%; }

.aw-head { display: flex; align-items: flex-start; gap: 12px; padding: 14px 18px 10px; border-bottom: 1px solid rgba(var(--green-rgb), .12); }
.aw-head > div { flex: 1; }
.aw-head h2 { margin: 0; color: var(--green); font-size: 1.15rem; }
.aw-of { margin: 0 0 2px; color: var(--hint); font-size: var(--fs-caption); letter-spacing: .02em; }
.aw-x { min-width: 44px; min-height: 44px; }

/* Смуга кроків: усі кроки клікабельні (повторне відкриття — з будь-якого). */
.aw-steps { padding: 8px 14px; border-bottom: 1px solid rgba(var(--green-rgb), .12); }
.aw-steps ol { display: flex; gap: 4px; margin: 0; padding: 0; list-style: none; }
.aw-steps li { flex: 1 1 0; min-width: 0; }
.aw-go { display: flex; align-items: center; gap: 6px; width: 100%; min-height: 40px; padding: 4px 8px; border: 0; border-radius: var(--radius-sm);
  background: transparent; color: var(--hint); font: 500 var(--fs-small) var(--font); cursor: pointer; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: background-color var(--transition), color var(--transition); }
.aw-go span { flex: none; display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1px solid currentColor; font-size: .75rem; }
.aw-go:hover { background: rgba(var(--green-rgb), .06); color: var(--text); }
.aw-go.is-done { color: var(--success); }
.aw-go[aria-current="step"] { background: rgba(var(--green-rgb), .1); color: var(--green); font-weight: 700; }
.aw-go[aria-current="step"] span { background: var(--green); border-color: var(--green); color: #fff; }
.aw-go:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.aw-body { flex: 1; min-height: 0; overflow: auto; display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
.aw-q { padding: 18px 22px 22px; }
.aw-q h3 { margin: 0 0 4px; font-size: 1.25rem; color: var(--text); }
.aw-q h3:focus { outline: none; }
.aw-hint { margin: 0 0 14px; color: var(--hint); font-size: var(--fs-small); }
.aw-label { margin: 0 0 6px; font-weight: 600; font-size: var(--fs-small); }
.aw-field { margin-bottom: 16px; }
.aw-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: flex-end; }
.aw-row + .aw-row { margin-top: 10px; }
.aw-row > .aw-label { align-self: center; margin: 0 4px 0 0; }
.aw-box { margin: 0 0 12px; padding: 10px 14px 14px; border: 1px solid rgba(var(--green-rgb), .16); border-radius: var(--radius); }
.aw-box legend { padding: 0 6px; font-weight: 700; }
.aw-box .btn-sm { margin-top: 10px; }
.aw-pair { display: inline-flex; gap: 8px; align-items: flex-end; margin-right: 8px; }
.aw .chip { min-height: 40px; }
.aw-idk { border-style: dashed; }
.aw-idk.active { border-style: solid; }

.aw-num { display: grid; gap: 4px; font-size: var(--fs-small); font-weight: 600; }
.aw-unit { display: inline-flex; align-items: center; gap: 6px; }
.aw-unit .input { width: 7.5rem; padding: 8px 10px; }
.aw-unit i { font-style: normal; font-weight: 500; color: var(--hint); }
.aw-num:has(#aw-title) { margin-bottom: 14px; }
.aw-num:has(#aw-title) .input { width: min(28rem, 100%); }
.aw-num:has(#aw-title) .aw-unit { display: flex; }

/* Результат: широкий екран — розгорнута панель праворуч. */
.aw-res { align-self: stretch; padding: 18px 22px; background: rgba(var(--green-rgb), .04); border-left: 1px solid rgba(var(--green-rgb), .12); }
.aw-res > summary { list-style: none; cursor: default; }
.aw-res > summary::-webkit-details-marker { display: none; }
.aw-res-h { display: block; margin-bottom: 8px; color: var(--hint); font-size: var(--fs-caption); text-transform: uppercase; letter-spacing: .06em; }
.aw-big { display: block; margin-bottom: 12px; font: 700 1.3rem/1.25 var(--font-display); color: var(--text); }
.aw-res h4 { margin: 14px 0 8px; color: var(--hint); font-size: var(--fs-caption); text-transform: uppercase; letter-spacing: .06em; }
.aw-res p { margin: 0 0 8px; }
.aw-list { margin: 0 0 10px; padding-left: 1.1rem; }
.aw-est { color: var(--hint); font-style: italic; }
.aw-ok { color: var(--success); }
.aw-sum { font-weight: 600; }

.aw-check { margin: 8px 0 0; padding: 8px 10px; border-radius: var(--radius-sm); font-size: var(--fs-small); }
.aw-warn { background: rgba(var(--gold-rgb), .16); color: var(--text); }
.aw-danger { background: rgba(var(--danger-rgb), .1); color: var(--danger); }
.aw-check.aw-ok { background: rgba(var(--green-rgb), .07); }
.aw-note { margin: 0; padding: 0 18px; color: var(--green); font-size: var(--fs-small); }
.aw-note:empty { display: none; }
.aw-note:not(:empty) { padding: 8px 18px 0; }
.aw-foot { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 18px 14px; border-top: 1px solid rgba(var(--green-rgb), .12); }
.aw-sp { flex: 1; }

/* Телефон і вузьке вікно: питання, під ним смуга результату; кроки — номерами. */
@media (max-width: 720px) {
  .aw { width: 100vw; height: 100dvh; border-radius: 0; border: 0; }
  .aw-body { grid-template-columns: 1fr; }
  .aw-q { padding: 14px 16px; }
  /* Смуга результату прилипає до низу: головне видно, хоч би яке довге питання. */
  .aw-res { position: sticky; bottom: 0; padding: 10px 16px 12px; border-left: 0; border-top: 1px solid rgba(var(--green-rgb), .16);
    background: var(--surface); box-shadow: 0 -6px 16px rgba(27, 77, 62, .08); }
  .aw-res[open] { max-height: 60dvh; overflow: auto; }
  .aw-res > summary { cursor: pointer; display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; }
  .aw-res > summary::after { content: '▾'; margin-left: auto; color: var(--hint); }
  .aw-res[open] > summary::after { content: '▴'; }
  .aw-res-h { margin: 0; flex-basis: 100%; }
  .aw-big { margin: 0; font-size: 1.05rem; flex: 1; }
  .aw-steps { padding: 6px 10px; }
  .aw-go { justify-content: center; padding: 4px; }
  .aw-go:not([aria-current="step"]) { font-size: 0; gap: 0; }
  .aw-go span { font-size: .75rem; }
  .aw-steps li:has([aria-current="step"]) { flex: 3 1 0; }
  .aw-foot { padding: 8px 12px 12px; }
  .aw-foot .btn { min-height: 44px; }
  /* «Пропустити» — окремим рядком над «Назад / Далі», а не третім рядком кнопок. */
  .aw-foot [data-act="skip"] { order: -1; flex-basis: 100%; }
  .aw-unit .input { width: 6rem; }
}
/* Головне кроку — для скрінрідера, коли відповідь змінила результат. */
.aw-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Ланцюжок (етап 2б): речі збірки картками, «Взяти з Комори» переліком, креслення збірки.
   Тап по речі — світяться місця, куди вона стає; цілі ≥ 44 px і в переліку під кресленням,
   тож креслення — підказка оком, а не єдиний спосіб (тап, клавіатура, скрінрідер). */
.aw-things { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin: 0 0 14px; padding: 0; list-style: none; }
.aw-thing { display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 6px 6px 10px;
  border: 1px solid rgba(var(--green-rgb), .18); border-radius: var(--radius); background: var(--surface); }
.aw-thing-pic { flex: none; display: grid; place-items: center; width: 44px; height: 44px; color: var(--green); }
.aw-thing-pic svg { width: 44px; height: 44px; }
.aw-thing-pic .tw-draw { width: 52px; height: 52px; }
.aw-thing-t { flex: 1; min-width: 0; display: grid; }
.aw-thing-t b, .aw-thing-t small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.aw-thing-t small { color: var(--hint); font-size: var(--fs-caption); }
.aw-thing .icon-btn { min-width: 44px; min-height: 44px; }
.aw-empty { padding: 10px 12px; border: 1px dashed rgba(var(--green-rgb), .25); border-radius: var(--radius); }
.aw-acts .btn { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; }
.aw-take { display: grid; gap: 6px; margin: 12px 0 0; padding: 0; list-style: none; max-width: 32rem; }
.aw-hit { display: flex; align-items: center; gap: 10px; width: 100%; min-height: 44px; padding: 6px 10px;
  border: 1px solid rgba(var(--green-rgb), .18); border-radius: var(--radius-sm); background: var(--surface); color: var(--text);
  font: inherit; font-size: var(--fs-small); text-align: left; cursor: pointer; transition: border-color var(--transition), background-color var(--transition); }
.aw-hit > span { display: grid; min-width: 0; }
.aw-hit small { color: var(--hint); font-size: var(--fs-caption); }
.aw-hit.active { border-color: var(--green); background: rgba(var(--green-rgb), .08); box-shadow: inset 0 0 0 1px var(--green); }
.aw-hit:disabled { cursor: not-allowed; opacity: .7; border-style: dashed; }
.aw-hit:focus-visible { outline: none; box-shadow: var(--focus-ring); }
@media (hover: hover) and (pointer: fine) { .aw-hit:not(:disabled):hover { border-color: var(--green); } }
.aw-tchip { display: inline-flex; align-items: center; gap: 6px; }
.aw-tchip .ico, .aw-tchip-i { width: 20px; height: 20px; flex: none; }
.aw-tchip i { font-style: normal; font-size: var(--fs-caption); color: var(--hint); }
.aw-tchip.aw-loose { border-style: dashed; }
.aw-tchip.active i { color: inherit; }
.aw-where { margin-top: 14px; }

/* Обгортка креслення збірки; саме креслення (.as-*) — у cellar.css. */
.aw-scene { margin: 0 0 14px; padding: 8px; border: 1px solid rgba(var(--green-rgb), .12); border-radius: var(--radius); background: rgba(var(--green-rgb), .03); }
.aw-scene-s { margin: 0 0 10px; }
.aw-scene-s .as-draw { max-height: 240px; }
@media (max-width: 720px) {
  .aw-things { grid-template-columns: 1fr; }
  .aw-scene .as-draw { max-height: 46dvh; }
  .aw-scene-s .as-draw { max-height: 22dvh; }
  /* На телефоні кнопка — лише значок: «Нова ємність» і «Взяти з Комори» з текстом лише для скрінрідера. */
  .aw-acts .btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
  .aw-acts .btn { min-width: 48px; justify-content: center; }
}
