/* Shape catalog page (app/catalog.html, D-130 / D-170). Tokens from brand.css only; desk sizes (D-157). */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-family: var(--font); background: var(--bg); color: var(--ink); }
header {
  background: var(--nav); color: var(--on-nav); padding: 12px 20px; display: flex; gap: 16px;
  align-items: center; justify-content: space-between; flex-wrap: wrap;
}
header h1 { margin: 0; font-size: 1.15rem; }
header .who { font-size: .85rem; font-weight: 650; display: flex; gap: 14px; align-items: center; }
header a { color: var(--on-nav); }
#gate { max-width: 560px; margin: 40px auto; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); font-weight: 650; }
.ce { display: grid; grid-template-columns: 320px minmax(0, 1fr) 360px; gap: 16px; padding: 16px; align-items: start; }
@media (max-width: 1180px) { .ce { grid-template-columns: 300px minmax(0, 1fr); } .ce-side { grid-column: 1 / -1; } }
@media (max-width: 760px) { .ce { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--r-md); padding: 14px; }
.card h2 { margin: 0 0 10px; font-size: var(--fs-16); }
.card h3 { margin: 14px 0 6px; font-size: var(--fs-14); color: var(--ink-2); }
input, select { font: inherit; }
.field { display: grid; gap: 4px; margin-bottom: 10px; }
.field label { font-size: var(--fs-14); font-weight: 650; color: var(--ink-2); }
.field input, .field select { min-height: var(--ctl-desk); padding: 6px 10px; border: 1px solid var(--line-field); border-radius: var(--r-sm, 8px); background: var(--surface); color: var(--ink); }
.req { color: var(--bad); }
.check { display: flex; gap: 8px; align-items: center; margin: 6px 0; font-weight: 600; }
.check input { width: 18px; height: 18px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* list — tools are not ui.css .search (that class is one input, with a field border) */
.ce-list-tools { display: grid; gap: var(--space-4); margin-bottom: var(--space-4); }
.ce-list-filters { display: grid; gap: var(--space-2); }
.ce-list-tools input,
.ce-list-tools select {
  min-height: var(--ctl-desk); padding: 6px 10px;
  border: 1px solid var(--line-field); border-radius: var(--r-sm, 8px);
  background: var(--surface); color: var(--ink);
}
.ce-list-tools .btn { width: 100%; min-height: var(--ctl-desk); }
.shapes { max-height: calc(100vh - 290px); min-height: 240px; overflow: auto; display: grid; gap: 6px; padding: 2px; }
.shape-row { display: grid; grid-template-columns: 100px 1fr; gap: 12px; align-items: center; min-height: 64px; text-align: start; padding: 8px 10px; border: 1px solid var(--line); border-inline-start: 4px solid transparent; border-radius: 8px; background: var(--surface); cursor: pointer; color: var(--ink); font: inherit; }
.shape-row:hover { background: var(--surface-2); border-color: var(--line-strong); }
.shape-row:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.shape-row.on { border: 2px solid var(--accent); border-inline-start-width: 6px; background: var(--accent-soft); padding: 7px 9px; }
.shape-row .th { height: 52px; display: flex; align-items: center; justify-content: center; background: var(--surface); border-radius: 6px; }
.shape-row .th svg { max-width: 96px; max-height: 52px; }
.shape-row .code { font-weight: 800; font-size: var(--fs-16); }
.shape-row .name { font-size: var(--fs-14); color: var(--ink-2); }
.badge { display: inline-block; font-size: 13px; font-weight: 700; padding: 1px 8px; border-radius: 10px; margin-inline-start: 6px; border: 1px solid currentColor; }
.badge.edited { background: var(--info-soft); color: var(--info); }
.badge.new { background: var(--ok-soft); color: var(--ok); }
.badge.hidden { background: var(--surface); color: var(--ink-2); }
.count { font-size: var(--fs-14); color: var(--muted); margin: 8px 0 0; }

/* canvas */
.tools { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.tools label { font-size: var(--fs-14); font-weight: 650; display: flex; gap: 4px; align-items: center; }
.tools select { min-height: 36px; border: 1px solid var(--line-field); border-radius: 8px; background: var(--surface); color: var(--ink); }
.stage { position: relative; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); touch-action: none; }
.stage svg { display: block; width: 100%; height: 440px; user-select: none; }
/* The drawing grid (D-170): its own tokens, so it is visible in light and dark and not solid black in high contrast. */
.g-line { stroke: var(--grid-line); stroke-width: 1; }
.g-line.major { stroke: var(--grid-line-major); stroke-width: 1.4; }
.leg { stroke: var(--ink); stroke-width: 6; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.leg.on { stroke: var(--accent); }
.leg-hit { stroke: transparent; stroke-width: 22; fill: none; cursor: pointer; }
.preview { stroke: var(--accent); stroke-width: 4; stroke-dasharray: 8 6; fill: none; }
.pt { fill: var(--surface); stroke: var(--ink); stroke-width: 2; }
.pt.start { fill: var(--ink); }
.pt.end { fill: var(--accent); stroke: var(--accent); }
.lab rect { fill: var(--surface); stroke: var(--line-strong); }
.lab.on rect { fill: var(--accent-soft); stroke: var(--accent); }
.lab text { font: 700 13px var(--font); fill: var(--ink); text-anchor: middle; direction: ltr; }
.hint { margin: 8px 0 0; font-size: var(--fs-14); color: var(--muted); }
.hint.warn { color: var(--warn); font-weight: 700; }
.static-draw { min-height: 300px; display: flex; align-items: center; justify-content: center; padding: 20px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); }
.static-note { margin: 0 0 8px; padding: 8px 12px; border-radius: 8px; background: var(--info-soft); color: var(--info); font-weight: 700; font-size: var(--fs-14); }
.static-draw svg { max-width: 100%; max-height: 360px; }

/* tables */
table.t { width: 100%; border-collapse: collapse; font-size: var(--fs-14); }
table.t th { text-align: start; font-weight: 700; color: var(--ink-2); padding: 6px 4px; border-bottom: 1px solid var(--line-strong); }
table.t td { padding: 4px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.t tr.on td { background: var(--accent-soft); }
table.t input, table.t select { width: 100%; min-height: 36px; padding: 3px 6px; border: 1px solid var(--line-field); border-radius: 6px; background: var(--surface); color: var(--ink); }
table.t input.num { width: 76px; direction: ltr; text-align: center; }
.letter { font-weight: 800; direction: ltr; display: inline-block; min-width: 18px; }
.x { border: none; background: none; color: var(--bad); font-weight: 800; cursor: pointer; font-size: 16px; }

/* checks + print */
.msgs { display: grid; gap: 4px; margin: 8px 0; }
.msg { font-size: var(--fs-14); padding: 6px 8px; border-radius: 6px; line-height: 1.4; }
.msg.err { background: var(--bad-soft); color: var(--bad); font-weight: 700; }
.msg.warn { background: var(--warn-bg); color: var(--warn); }
.msg.ok { background: var(--ok-soft); color: var(--ok); font-weight: 700; }
.tag-frame { width: 105mm; max-width: 100%; aspect-ratio: 105 / 74; border: 1px dashed var(--line-strong); background: #fff; display: flex; align-items: center; justify-content: center; padding: 3mm; margin-top: 6px; }
.tag-frame svg { max-width: 100%; max-height: 100%; }
.tag-card { width: 100%; aspect-ratio: 105 / 74.25; border: 1px dashed var(--line-strong); background: #fff; margin-top: 6px; overflow: hidden; position: relative; }
.tag-card iframe { position: absolute; top: 0; inset-inline-start: 0; width: 105mm; height: 74.25mm; border: 0; transform-origin: top right; background: #fff; }
/* Swap view (D-150): the tag and sheet take the big middle pane, the drawing goes small. */
.print-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.print-head h3 { margin: 0; }
.print-slot:empty { display: none; }
.print-slot { margin-bottom: 12px; }
@media (min-width: 1181px) { .ce.swapped { grid-template-columns: 220px minmax(0, 1fr) 280px; } }
.ce.swapped .print-slot .tag-card { max-width: 820px; margin-inline: auto; }
.ce.swapped .print-slot .sheet-frame { height: 240px; }
.ce.swapped .ce-canvas #svg { max-height: 240px; }
.lay-bar { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin: 6px 0 4px; }
.lay-bar .btn { min-height: 36px; padding: 2px 10px; }
.lay-bar .btn[aria-pressed="true"] { background: var(--ink); color: var(--on-ink); border-color: var(--ink); }
.lay-scale { min-width: 3.4em; text-align: center; font-weight: 700; }
.lay-help { font-size: .8rem; color: var(--muted); margin: 4px 0 8px; }
.sheet-frame svg .print-num { cursor: grab; }
.sheet-frame { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 6px; margin-top: 6px; height: 110px; display: flex; align-items: center; justify-content: center; }
.sheet-frame svg { max-width: 100%; max-height: 100%; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.status { min-height: 1.4em; font-size: var(--fs-14); font-weight: 700; margin-top: 8px; }
.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }

/* tabs (D-170): צורות = the shape editor, עריכה = tags of all shapes */
.cat-tabs { display: flex; gap: 4px; padding: 12px 16px 0; border-bottom: 1px solid var(--line-strong); background: var(--bg); }
.cat-tab {
  min-height: var(--ctl-desk); padding: 6px 22px; border: 1px solid transparent; border-bottom: 0; border-radius: 8px 8px 0 0;
  background: none; color: var(--ink-2); font: inherit; font-weight: 700; font-size: var(--fs-16); cursor: pointer; margin-bottom: -1px;
}
.cat-tab:hover { background: var(--surface-2); color: var(--ink); }
.cat-tab[aria-selected="true"] { background: var(--surface); color: var(--ink); border-color: var(--line-strong); box-shadow: inset 0 3px 0 var(--accent); }
.cat-tab:focus-visible { outline: 3px solid var(--accent); outline-offset: -3px; }

/* processing tags (D-169): one button per tag, cycles automatic → כן → לא → automatic */
.fab-box { margin: 8px 0 4px; }
.fab-box h3 { margin: 8px 0 6px; }
.fab-toggles { display: flex; gap: 6px; flex-wrap: wrap; }
.fab-t {
  display: inline-flex; align-items: center; gap: 6px; min-height: var(--ctl-desk); padding: 4px 12px;
  border: 1px solid var(--line-field); border-radius: 8px; background: var(--surface); color: var(--ink);
  font: inherit; font-size: var(--fs-14); font-weight: 700; cursor: pointer;
}
.fab-t:hover { background: var(--surface-2); }
.fab-t:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.fab-t .fab-v { font-weight: 800; }
.fab-t .fab-src { font-size: 13px; font-weight: 600; color: var(--muted); }
.fab-t.is-auto { border-style: dashed; color: var(--ink-2); }
.fab-t.is-auto .fab-v { color: var(--muted); }
.fab-t.is-on { background: var(--ok-soft); border: 2px solid var(--ok); padding-inline: 11px; }
.fab-t.is-on .fab-v { color: var(--ok); }
.fab-t.is-off { background: var(--bad-soft); border: 2px solid var(--bad); padding-inline: 11px; }
.fab-t.is-off .fab-v { color: var(--bad); }
.fab-t.is-off .fab-name { text-decoration: line-through; }

/* the עריכה tab */
.fab-tab { margin: 16px; }
.fab-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 10px; }
.fab-bar input[type="search"], .fab-bar select {
  min-height: var(--ctl-desk); padding: 6px 10px; border: 1px solid var(--line-field); border-radius: 8px; background: var(--surface); color: var(--ink); font: inherit;
}
.fab-bar input[type="search"] { width: 240px; flex: 0 0 240px; margin: 0; }
.fab-bar select { width: auto; flex: 0 0 auto; min-width: 180px; margin: 0; }
.fab-bar .check { margin: 0; }
.fab-bar .grow { flex: 1 1 auto; }
.fab-count { font-size: var(--fs-14); color: var(--muted); font-weight: 600; }
.fab-pending { font-size: var(--fs-14); font-weight: 700; color: var(--ink); }
.fab-help { margin: 0 0 10px; font-size: var(--fs-14); color: var(--muted); }
.fab-scroll { max-height: calc(100vh - 300px); min-height: 260px; overflow: auto; border: 1px solid var(--line-strong); border-radius: 8px; }
table.fab-table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-14); }
table.fab-table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface-2); text-align: start; font-weight: 700; color: var(--ink-2);
  padding: 8px; border-bottom: 1px solid var(--line-strong);
}
table.fab-table td { padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; background: var(--surface); }
table.fab-table tr:hover td { background: var(--surface-2); }
table.fab-table tr.is-dirty td { background: var(--accent-soft); }
table.fab-table tr.is-dirty td:first-child { box-shadow: inset -4px 0 0 var(--accent); }
table.fab-table .c-code { font-weight: 800; font-size: var(--fs-16); white-space: nowrap; }
table.fab-table .c-th { width: 110px; }
table.fab-table .c-th .th { width: 100px; height: 52px; display: flex; align-items: center; justify-content: center; }
table.fab-table .c-th svg { max-width: 100px; max-height: 52px; }
table.fab-table .c-name { min-width: 160px; }
table.fab-table .c-cat { display: block; font-size: 13px; color: var(--muted); }
table.fab-table .c-lay { font-size: 13px; color: var(--ink-2); min-width: 120px; }
.dirty-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-inline-end: 6px; vertical-align: middle; }

/* code taken (D-170): no silent overwrite */
.taken-dlg { border: 2px solid var(--bad); border-radius: 16px; padding: 0; max-width: 460px; width: calc(100% - 32px); background: var(--surface); color: var(--ink); box-shadow: var(--sh-3, 0 20px 50px rgba(0,0,0,.2)); }
.taken-dlg::backdrop { background: var(--scrim); }
.taken-dlg .taken-in { padding: 20px; }
.taken-dlg h2 { margin: 0 0 10px; font-size: var(--fs-18, 1.1rem); color: var(--bad); }
.taken-dlg p { margin: 0 0 8px; padding: 10px 12px; border-radius: 8px; background: var(--bad-soft); color: var(--bad); font-weight: 700; line-height: 1.5; }
.taken-acts { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
