/* xBOOK | TUT — Color Contrast widget (embed/). Small, self-contained, light. */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/Inter-Regular.subset.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/Inter-SemiBold.subset.woff2') format('woff2'); }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/Inter-Bold.subset.woff2') format('woff2'); }
:root {
  --ink: #14181F; --ink-2: #374151; --muted: #4B5563; --line: #E2E5EA; --line-2: #C8CDD5;
  --surface: #FFFFFF; --surface-2: #F6F7F9; --accent: #0B6E78; --accent-soft: #E3F4F4; --focus: #2457C5;
  --ok: #166534; --ok-bg: #EAF7EE; --mid: #8A4B0B; --mid-bg: #FFF5E5; --bad: #B42318; --bad-bg: #FDEEEC;
  --font: Inter, system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; background: transparent; }
body { container-type: inline-size; margin: 0; font: 400 14px/1.45 var(--font); color: var(--ink); background: transparent; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; margin: -1px; padding: 0; border: 0; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }

.w { min-width: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: grid; gap: 12px; max-width: 880px; margin: 0 auto; }
.w-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.w-brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14px; min-width: 0; }
.w-brand svg { width: 30px; height: 12px; flex: none; }
.w-lang { height: 32px; padding: 0 6px; border: 1px solid var(--line-2); border-radius: 8px; background: var(--surface); font-size: 13px; font-weight: 600; cursor: pointer; }

.w-body { display: grid; gap: 12px; grid-template-columns: minmax(0, 1fr); }
@container (min-width: 600px) { .w-body { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); align-items: stretch; } }

/* preview: the colours being tested */
.w-preview { --w-fg: #1E3A8A; --w-bg: #FFFFFF; background: var(--w-bg); color: var(--w-fg); border-radius: 12px; border: 1px solid rgba(127,127,127,.35); padding: 18px; display: flex; flex-direction: column; justify-content: center; gap: 8px; min-height: 180px; overflow-wrap: anywhere; }
.w-h { margin: 0; font-size: 24px; font-weight: 700; line-height: 1.15; letter-spacing: -.01em; }
.w-p { margin: 0; font-size: 15px; line-height: 1.5; }
.w-pv-row { display: flex; align-items: center; gap: 14px; margin-top: 6px; }
.w-pv-btn { display: inline-block; padding: 8px 16px; border-radius: 999px; background: var(--w-fg); color: var(--w-bg); font-weight: 700; font-size: 14px; }
.w-pv-ic { color: var(--w-fg); flex: none; }

.w-side { display: grid; gap: 10px; align-content: start; min-width: 0; }
.w-colors { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 8px; }
.w-field { min-width: 0; display: grid; gap: 4px; }
.w-lab { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.w-input { display: flex; align-items: center; gap: 6px; border: 1px solid var(--line-2); border-radius: 10px; padding: 4px; background: var(--surface); }
.w-input:focus-within { border-color: var(--focus); box-shadow: 0 0 0 1px var(--focus); }
.w-sw { position: relative; width: 32px; height: 32px; border-radius: 7px; background: var(--c, #fff); box-shadow: inset 0 0 0 1px rgba(20,24,31,.2); flex: none; overflow: hidden; }
.w-sw input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; border: 0; padding: 0; }
.w-sw:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.w-hex { width: 100%; min-width: 0; border: 0; background: transparent; font: 600 14px/1 var(--mono); padding: 6px 4px; text-transform: uppercase; }
.w-hex:focus-visible { outline: none; }
.w-hex[aria-invalid="true"] { color: var(--bad); }
.w-err { margin: 0; font-size: 12px; color: var(--bad); }
.w-swap { width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--ink-2); margin-bottom: 1px; }
.w-swap:hover { background: var(--surface-2); color: var(--ink); }
.w-swap svg { width: 18px; height: 18px; }

.w-result { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: grid; gap: 8px; background: var(--surface-2); }
.w-ratio { display: flex; align-items: center; gap: 10px; }
.w-ri { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 800; flex: none; }
.w-result[data-verdict="AAA"] .w-ri, .w-result[data-verdict="AA"] .w-ri { background: var(--ok); }
.w-result[data-verdict="AAA"] .w-ri::before, .w-result[data-verdict="AA"] .w-ri::before { content: '✓'; }
.w-result[data-verdict="Large"] .w-ri { background: #B45309; } .w-result[data-verdict="Large"] .w-ri::before { content: '!'; }
.w-result[data-verdict="Fail"] .w-ri { background: var(--bad); } .w-result[data-verdict="Fail"] .w-ri::before { content: '✗'; }
.w-ratio-text { margin: 0; display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; }
.w-num { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.w-x { font-size: 16px; color: var(--muted); font-weight: 600; }
.w-verdict { font-weight: 700; }
.w-result[data-verdict="AAA"] .w-verdict, .w-result[data-verdict="AA"] .w-verdict { color: var(--ok); }
.w-result[data-verdict="Large"] .w-verdict { color: var(--mid); }
.w-result[data-verdict="Fail"] .w-verdict { color: var(--bad); }
.w-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.w-table th { text-align: left; font-weight: 600; padding: 3px 8px 3px 0; color: var(--ink-2); }
.w-table td { padding: 3px 0 3px 6px; width: 1%; white-space: nowrap; }
.w-hint { display: block; font-weight: 400; font-size: 11px; color: var(--muted); }
.w-chip { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.w-chip b { font-weight: 800; }
.w-chip::before { font-weight: 800; }
.w-chip[data-pass="true"] { background: var(--ok-bg); color: var(--ok); } .w-chip[data-pass="true"]::before { content: '✓'; }
.w-chip[data-pass="false"] { background: var(--bad-bg); color: var(--bad); } .w-chip[data-pass="false"]::before { content: '✗'; }

.w-suggest { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 8px 10px; border-radius: 10px; background: var(--accent-soft); font-size: 13px; }
.w-sw-sm { width: 20px; height: 20px; border-radius: 5px; }
.w-suggest-text { flex: 1 1 160px; min-width: 0; }
.w-btn { height: 32px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--accent); background: var(--accent); color: #fff; font-weight: 600; font-size: 13px; cursor: pointer; }
.w-btn:hover { background: #095C64; }
.w-status-row { margin: 0; font-size: 12px; color: var(--ink-2); min-height: 0; }
.w-status-row:has(#w-status:empty):has(#w-undo[hidden]) { display: none; }
.w-link { border: 0; background: none; padding: 0 2px; color: var(--accent); font-weight: 600; text-decoration: underline; cursor: pointer; font-size: 12px; }

.w-foot { display: flex; justify-content: space-between; align-items: center; gap: 6px 12px; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 10px; font-size: 12px; }
.w-foot a { color: var(--accent); font-weight: 600; text-decoration: none; }
.w-foot a:hover { text-decoration: underline; }
.w-by { color: var(--muted); }

@container (max-width: 359px) {
  .w { padding: 10px; }
  .w-colors { grid-template-columns: minmax(0, 1fr); }
  .w-swap { justify-self: center; transform: rotate(90deg); }
  .w-num { font-size: 22px; }
  .w-table, .w-table tbody { display: block; }
  .w-table tr { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; padding: 4px 0; border-top: 1px solid var(--line); }
  .w-table tr:first-child { border-top: 0; }
  .w-table th { flex: 1 0 100%; padding: 0; }
  .w-hint { display: inline; }
  .w-table td { padding: 0; width: auto; }
  .w-table td:empty { display: none; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
