/* Free tools (/tools/…): extra styles on top of app.css. Uses app.css tokens, so dark mode follows html[data-theme]. */
.tool-page .small { font-size: 14px; line-height: 1.5; }
.tool-page .mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; }
.tool-card { margin: 16px 0; padding: 18px; line-height: 1.5; }
.tool-card + .tool-card { margin-top: 12px; }
.tool-card .tool-h { margin: 0 0 12px; font-size: 18px; }
.tool-card .tool-sub { margin: 18px 0 6px; font-size: 15px; }
.tool-card p { margin: 8px 0; }
.tool-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin: 8px 0; }
.tool-row.tight { gap: 8px; align-items: center; }
.tool-row .field { flex: 1 1 150px; min-width: 0; }
.tool-row .field.grow { flex: 3 1 220px; }
.tool-row.tight .field { flex: 0 1 220px; }
.field label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.field > .input, .field > select, .color-row .input { display: block; }
.tool-eq { align-self: center; padding-top: 22px; color: var(--text-3); }
.tool-page input[type="number"] { font-variant-numeric: tabular-nums; }
.tool-page .btn:focus-visible, .tool-page .chip:focus-visible, .tool-page select:focus-visible, .tool-page summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.tool-page .input[aria-invalid="true"] { border-bottom-color: var(--bad); }
.tool-page .chips { margin: 8px 0; }
.tool-page .chip.on { font-weight: 600; }
.tool-page .check input:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Pass/fail lists */
.checks { list-style: none; padding: 0 !important; margin: 10px 0; display: grid; gap: 6px; }
.checks li { margin: 0; line-height: 1.45; }
.checks .pill { min-width: 48px; margin-right: 6px; font-size: 12px; vertical-align: 1px; }
.hints { list-style: none; padding: 0 !important; margin: 10px 0 0; display: grid; gap: 6px; }
.hints li { margin: 0; padding: 8px 12px; border-radius: var(--radius-sm); font-size: 14px; line-height: 1.45; }
.hints li.good { background: var(--good-bg); }
.hints li.mid { background: var(--mid-bg); }
.hints li.bad { background: var(--bad-bg); }

/* Code output */
.tool-page pre.code-out { margin: 6px 0 8px; padding: 12px 14px; max-width: 100%; white-space: pre-wrap; overflow-wrap: anywhere; }
.tool-page pre.code-out code { white-space: inherit; overflow-wrap: inherit; }
.tool-page pre.code-out code { font-size: 13px; }
.code-line { display: flex; gap: 8px; align-items: flex-start; }
.code-line pre { flex: 1; min-width: 0; margin: 0 !important; }

/* Contrast checker */
.cc-fields { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); gap: 10px; align-items: end; }
.color-row { display: flex; gap: 6px; align-items: center; }
.color-row input[type="color"], .mk-color { flex: none; width: 44px; height: 44px; padding: 2px; border: 1px solid var(--stroke-strong); border-radius: var(--radius-sm); background: var(--card); cursor: pointer; }
.color-row .input { height: 44px; font-size: 16px; }
.btn.swap { min-width: 44px; min-height: 44px; padding: 0; font-size: 18px; }
.cc-result { display: flex; flex-wrap: wrap; gap: 4px 16px; align-items: baseline; margin: 10px 0 4px; }
.cc-ratio { font: 700 40px/1.1 var(--font-display); font-variant-numeric: tabular-nums; }
.cc-ratio span + span { font-size: 24px; color: var(--text-2); font-weight: 600; }
.cc-verdict { flex: 1 1 220px; margin: 0 !important; font-weight: 600; }
.cc-preview { border: 1px solid var(--stroke-strong); border-radius: var(--radius); padding: 12px 16px; margin: 12px 0; overflow-wrap: anywhere; }
.cc-preview p { margin: 4px 0; color: inherit; }
.cc-ui { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; font-size: 14px; }
.cc-btn { border: 2px solid; border-radius: 6px; padding: 4px 12px; font-weight: 600; }
.cc-icon { font-size: 22px; line-height: 1; }
.cc-suggest p { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.swatch { display: inline-block; width: 20px; height: 20px; border-radius: 4px; border: 1px solid var(--stroke-strong); vertical-align: middle; }

/* Tap target preview: everything at real CSS size */
.tt-stage { position: relative; border: 1px solid var(--stroke); border-radius: var(--radius); background: var(--card-2); overflow: auto hidden; min-height: 88px; margin: 6px 0; }
.tt-stage i { position: absolute; display: block; box-sizing: border-box; pointer-events: none; }
.tt-stage .tgt { background: var(--accent); border-radius: 4px; opacity: .9; }
.tt-stage .tgt.nb { opacity: .45; }
.tt-stage .tgt.fail { background: var(--bad); }
.tt-stage .g24 { border: 2px solid var(--bad); }
.tt-stage .g44 { border: 2px dashed var(--good); }
.tt-stage .g48 { border: 2px dotted var(--mid); }
.tt-stage .finger { border: 2px solid var(--text-2); background: rgba(128, 128, 128, .10); }
.tt-legend { list-style: none; padding: 0 !important; margin: 6px 0; display: flex; flex-wrap: wrap; gap: 4px 16px; }
.tt-legend li { margin: 0; display: inline-flex; align-items: center; gap: 6px; }
.tt-legend i { display: inline-block; width: 16px; height: 16px; box-sizing: border-box; }
.tt-legend .lg-target { background: var(--accent); border-radius: 3px; }
.tt-legend .lg-24 { border: 1.5px solid var(--bad); border-radius: 50%; }
.tt-legend .lg-44 { border: 1.5px dashed var(--good); }
.tt-legend .lg-48 { border: 1.5px dotted var(--mid); }
.tt-legend .lg-finger { border: 2px solid var(--text-2); border-radius: 50%; background: rgba(128, 128, 128, .12); }

/* Font size calculator */
.fl-table td { vertical-align: middle !important; }
.fl-table td:nth-child(-n+2) { white-space: nowrap; font-variant-numeric: tabular-nums; }
.fl-table tr.fl-edge td { background: var(--accent-soft); }
.fl-sample { line-height: 1.3; white-space: nowrap; }

/* Media query generator */
.mq-picker { margin: 8px 0; border: 1px solid var(--stroke); border-radius: var(--radius); background: var(--card-2); }
.mq-picker > summary { cursor: pointer; padding: 11px 12px; font-weight: 600; line-height: 22px; }
.mq-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; padding: 0 12px 12px; }
.mq-group { border: 0; margin: 0; padding: 0; min-width: 0; }
.mq-group legend { font-weight: 600; padding: 4px 0; }
.mq-dev { display: flex; align-items: flex-start; padding: 4px 0; font-size: 14px; line-height: 1.35; min-height: 32px; }
.mq-dev input { margin-top: 1px; flex: none; }
.mq-dpr { flex: 1 1 220px; min-height: 32px; }
.bp-table td { font-size: 14px; }
.bp-table td:nth-child(-n+2) { min-width: 72px; }
.bp-table td:nth-child(3) { min-width: 140px; }
.tool-page .bp-table th, .tool-page .bp-table td { padding: 8px 8px; }
.bp-table .more { display: inline; }
.bp-table .more summary { display: inline; cursor: pointer; color: var(--accent); }

/* Mockup generator */
.mk-layout { display: grid; grid-template-columns: minmax(0, 300px) minmax(0, 1fr); gap: 20px; align-items: start; }
.mk-controls { display: grid; gap: 12px; min-width: 0; }
.mk-controls .field { min-width: 0; }
.mk-controls .tool-row .field.mk-swatch { flex: none; }
.mk-drop { position: relative; display: grid; gap: 4px; place-items: center; text-align: center; padding: 18px 12px; border: 2px dashed var(--stroke-strong); border-radius: var(--radius); background: var(--card-2); cursor: pointer; }
.mk-drop:hover, .mk-drop.over { border-color: var(--accent); background: var(--accent-soft); }
.mk-drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.mk-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.mk-fs { border: 0; padding: 0; margin: 0; min-width: 0; }
.mk-fs legend { font-size: 14px; font-weight: 600; margin-bottom: 4px; padding: 0; }
.segmented-radio { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--control-stroke); border-radius: var(--radius-sm); background: var(--control); padding: 2px; gap: 2px; }
.segmented-radio label { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 3px; cursor: pointer; min-height: 36px; font-size: 14px; }
.segmented-radio input { accent-color: var(--accent); margin: 0; }
.segmented-radio label:has(input:checked) { background: var(--card); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); font-weight: 600; }
.segmented-radio label:has(input:focus-visible) { outline: 2px solid var(--accent); }
.mk-preview { min-width: 0; display: flex; justify-content: center; align-items: flex-start; padding: 12px; border-radius: var(--radius); border: 1px solid var(--stroke);
  background-color: var(--card-2);
  background-image: linear-gradient(45deg, var(--subtle-hover) 25%, transparent 25%, transparent 75%, var(--subtle-hover) 75%), linear-gradient(45deg, var(--subtle-hover) 25%, transparent 25%, transparent 75%, var(--subtle-hover) 75%);
  background-size: 20px 20px; background-position: 0 0, 10px 10px; }
.mk-preview canvas { display: block; max-width: 100%; max-height: 72vh; width: auto; height: auto; }
.mk-controls .btn.big { width: 100%; }

/* Call to action and footer links */
.tool-cta { margin: 28px 0; padding: 18px 20px; border-radius: var(--radius); background: var(--accent-soft); border: 1px solid var(--stroke); }
.tool-cta p { margin: 0 0 12px; color: var(--text); }
.tool-more { margin-top: 28px; font-size: 14px; color: var(--text-2); }
.tool-cards .guide-card b { font-size: 17px; }

@media (max-width: 760px) {
  .mk-layout { grid-template-columns: minmax(0, 1fr); }
  .mk-preview { order: -1; }
  .mk-preview canvas { max-height: 50vh; }
}
@media (max-width: 480px) {
  .tool-card { padding: 14px 12px; }
  .cc-ratio { font-size: 34px; }
  .cc-fields { gap: 6px; }
  .color-row input[type="color"] { width: 38px; }
  .color-row .input { padding: 0 8px; }
  .tool-cta .btn { width: 100%; white-space: normal; text-align: center; }
}
/* Checkbox and radio labels are the tap target: at least 28px tall (WCAG 2.5.8 asks for 24px). */
.tool-page label.check { min-height: 28px; display: inline-flex; align-items: center; gap: 6px; }
