/* Задания из js/widgets.js: порядок, пары, группы, выбор нескольких, число, двоичные разряды,
   таблица истинности, пропуски. Цвета — переменные из style.css (светлая и тёмная тема там же). */

.widget { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; margin: 0 -6px; padding: 0 6px; display: flex; flex-direction: column; }
.wg { display: flex; flex-direction: column; min-width: 0; margin: auto 0; padding-bottom: 4px; }
.wg h2.wg-q { margin: 0 0 8px; font-size: 22px; line-height: 1.2; font-weight: 800; }
.wg .q-art { margin-bottom: 10px; }
.wg-how { margin: 0 0 12px; color: var(--muted); font-size: 14px; line-height: 1.35; }
.wg-body { min-width: 0; }
.wg-check { margin-top: 14px; }
.wg-check[hidden] { display: none; }
.wg .why { min-height: 2.6em; margin-top: 10px; }
.wg-sub { margin: 14px 0 6px; color: var(--muted); font-size: 12px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; }
.wg-t { min-width: 0; overflow-wrap: anywhere; }

:where(.wg button:not(.btn)) { font-family: inherit; color: var(--text); -webkit-tap-highlight-color: transparent; }
.wg button:focus-visible, .wg select:focus-visible, .wg input:focus-visible { outline: 3px solid var(--on); outline-offset: 2px; }
.wg-done .wg-body button, .wg-done .wg-body select { cursor: default; }

/* пометки: неверное и незаполненное */
.wg .wg-bad { border-color: var(--bad) !important; background: var(--panel-bad) !important; }
.wg .wg-miss { border-style: dashed !important; border-color: var(--line-2) !important; }

/* ---------- order ---------- */
.wg-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.wg-row {
  display: flex; align-items: center; gap: 10px; min-height: 56px; padding: 6px 6px 6px 12px;
  border: 1.5px solid var(--line); border-radius: 16px; background: var(--panel); font-size: 16px; font-weight: 700; line-height: 1.25;
}
.wg-row .wg-t { flex: 1 1 auto; }
.wg-n { flex: none; width: 26px; height: 26px; border-radius: 50%; background: var(--panel-2); color: var(--muted); font-size: 13px; font-weight: 800; display: flex; align-items: center; justify-content: center; }
.wg-mv { flex: none; display: flex; gap: 4px; }
.wg-ic {
  width: 44px; height: 44px; border-radius: 12px; border: 1.5px solid var(--line); background: var(--panel-2);
  font-size: 20px; font-weight: 800; line-height: 1; cursor: pointer; padding: 0;
}
.wg-ic:active { background: var(--panel-3); }
.wg-ic[disabled] { opacity: .3; cursor: default; }
.wg-done .wg-row { border-color: var(--ok); }
.wg-done .wg-mv { visibility: hidden; }

/* ---------- match ---------- */
.wg-pairs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.wg-left {
  width: 100%; min-height: 56px; padding: 8px 14px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--panel);
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left; cursor: pointer; font-size: 16px; font-weight: 700; line-height: 1.25;
}
.wg-left.wg-act { border-color: var(--on); background: var(--panel-on); }
.wg-slot { color: var(--on-text); font-size: 15px; font-weight: 700; overflow-wrap: anywhere; }
.wg-slot::before { content: '→ '; color: var(--muted); }
.wg-slot.wg-empty { color: var(--muted); }
.wg-done .wg-left { border-color: var(--ok); }

.wg-pool { display: flex; flex-wrap: wrap; gap: 8px; }
.wg-chip {
  max-width: 100%; min-height: 44px; padding: 8px 14px; border-radius: 22px; border: 1.5px solid var(--line-2); background: var(--panel-2);
  font-size: 15px; font-weight: 700; line-height: 1.25; text-align: left; cursor: pointer; overflow-wrap: anywhere;
}
.wg-chip:active { background: var(--panel-3); }
.wg-chip.wg-used { opacity: .45; border-style: dashed; }
.wg-chip.wg-act { border-color: var(--on); background: var(--on-soft); box-shadow: 0 0 0 2px var(--on-soft); }

/* ---------- sort ---------- */
.wg-unsorted { min-height: 48px; }
.wg-unsorted.wg-empty::after { content: '✓'; color: var(--ok); font-weight: 800; font-size: 20px; padding: 8px 4px; }
.wg-buckets { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-top: 14px; }
.wg-bucket { min-width: 0; border: 1.5px dashed var(--line-2); border-radius: 18px; padding: 6px; background: var(--inset); display: flex; flex-direction: column; gap: 6px; }
.wg-target {
  width: 100%; min-height: 48px; padding: 8px 12px; border-radius: 13px; border: 1.5px solid var(--line); background: var(--panel);
  display: flex; align-items: center; justify-content: space-between; gap: 8px; text-align: left; cursor: pointer; font-size: 15px; font-weight: 800; line-height: 1.2;
}
.wg-target span { min-width: 0; overflow-wrap: anywhere; }
.wg-target b { flex: none; color: var(--muted); font-size: 13px; }
.wg-target:active { background: var(--panel-3); }
.wg-in { display: flex; flex-wrap: wrap; gap: 6px; min-height: 8px; }
.wg-in .wg-chip { font-size: 14px; min-height: 40px; padding: 6px 12px; }
.wg-done .wg-bucket { border-color: var(--ok); }

/* ---------- pick ---------- */
.wg-opt[aria-pressed="true"] { border-color: var(--on); background: var(--panel-on); }
.wg-opt[aria-pressed="true"]::before { content: '✓ '; color: var(--on-text); }
.wg-opt.wrong[aria-pressed="true"] { border-color: var(--bad); background: var(--panel-bad); }

/* ---------- number ---------- */
.wg-numrow { display: flex; align-items: center; gap: 10px; }
.wg-input {
  flex: 1 1 auto; min-width: 0; width: 100%; max-width: 260px; height: 56px; padding: 0 16px; border-radius: 16px;
  border: 1.5px solid var(--line-2); background: var(--panel); color: var(--text);
  font: inherit; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums;
  -webkit-user-select: text; user-select: text;
}
.wg-input:focus { border-color: var(--on); outline: none; }
.wg-input.wg-bad { border-color: var(--bad); background: var(--panel-bad); }
.wg-input.wg-good { border-color: var(--ok); }
.wg-unit { color: var(--muted); font-size: 17px; font-weight: 800; }

/* ---------- bits ---------- */
.wg-bits { display: grid; gap: 6px; }
.wg-bit {
  min-width: 0; height: 68px; padding: 4px 0; border-radius: 14px; border: 1.5px solid var(--line-2); background: var(--inset);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; cursor: pointer;
}
.wg-w { color: var(--muted); font-size: 12px; font-weight: 800; font-variant-numeric: tabular-nums; }
.wg-b { font: 800 24px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted); }
.wg-bit[aria-pressed="true"] { border-color: var(--on); background: var(--on-soft); }
.wg-bit[aria-pressed="true"] .wg-b { color: var(--on-text); }
.wg-dec { margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 16px; font-weight: 700; }
.wg-dec b { color: var(--text); font-size: 24px; font-variant-numeric: tabular-nums; }
.wg-done .wg-bit[aria-pressed="true"] { border-color: var(--ok); }

/* ---------- truth ---------- */
.wg-tt { margin: 0; table-layout: fixed; }
.wg-tt th { overflow-wrap: anywhere; font-size: 13px; }
.wg-tt td { padding: 3px 4px; }
.wg-tt td.wg-td { padding: 3px 4px; }
.wg-cell {
  width: 100%; min-width: 40px; height: 44px; border-radius: 10px; border: 1.5px solid var(--line-2); background: var(--panel);
  font: 800 18px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted); cursor: pointer; padding: 0;
}
.wg-cell.wg-unset { color: var(--line-2); border-style: dashed; }
.wg-cell.wg-one { color: var(--on-text); border-color: var(--on); background: var(--on-soft); }
.wg-done .wg-cell { border-color: var(--ok); border-style: solid; }

/* ---------- fill ---------- */
.wg-text { margin: 0; font-size: 17px; line-height: 2.3; color: var(--text-2); overflow-wrap: anywhere; }
.wg-sel {
  max-width: 100%; min-height: 44px; margin: 0 2px; padding: 6px 10px; border-radius: 12px; vertical-align: middle;
  border: 1.5px solid var(--on); background: var(--panel); color: var(--text); font: inherit; font-size: 16px; font-weight: 800; cursor: pointer;
}
.wg-done .wg-sel { border-color: var(--ok); opacity: 1; }

@media (hover: hover) {
  .wg-ic:not([disabled]):hover, .wg-chip:not([disabled]):hover, .wg-target:not([disabled]):hover,
  .wg-left:not([disabled]):hover, .wg-bit:not([disabled]):hover, .wg-cell:not([disabled]):hover { background: var(--panel-3); }
}
@media (min-width: 768px) {
  .wg h2.wg-q { font-size: 27px; }
  .wg-check { max-width: 380px; align-self: center; }
  .wg-bit { height: 76px; }
}
@media (max-height: 700px) and (max-width: 959px) {
  .wg h2.wg-q { font-size: 19px; margin-bottom: 6px; }
  .wg-how { margin-bottom: 8px; font-size: 13px; }
  .wg-row, .wg-left { min-height: 50px; }
  .wg .why { min-height: 2.2em; margin-top: 8px; font-size: 14px; }
}
