/* ─── Interactive tools (assets/js/widgets.js): thick ink frame, ink head,
   red offset shadow, dot-grid output panel ─────────────────────────── */

.w-host + .w-host { margin-top: 32px; }
.w-noscript { border: 1px dashed var(--line-2); padding: 18px; font-family: var(--mono); font-size: .8rem; color: var(--muted); }
.widget { background: var(--white); border: var(--rule-3); box-shadow: var(--shadow); }
.w-head { display: flex; align-items: baseline; gap: 16px; flex-wrap: wrap; padding: 18px 26px; border-bottom: var(--rule-3); background: var(--ink); color: var(--on-color); }
.w-fig { font-family: var(--mono); font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--mark); }
.w-title { font-size: 1.5rem; font-stretch: 105%; color: var(--on-color); }
.w-grid { display: grid; grid-template-columns: minmax(0, .95fr) minmax(0, 1.05fr); }
.w-in { padding: 26px; border-right: var(--rule-3); display: flex; flex-direction: column; gap: 18px; }
.w-out { padding: 26px; background: var(--grid), var(--white); display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.widget .wf, .widget .wr { display: flex; flex-direction: column; gap: 7px; font-size: .82rem; font-weight: 600; }
.widget .wf > span:first-child, .widget .wr > span { font-family: var(--mono); font-size: .72rem; font-weight: 400; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.widget .wr b { color: var(--ink); font-weight: 500; }
.wf-in { display: flex; align-items: center; border: 2px solid var(--ink); background: var(--paper); }
.wf-in i { font-style: normal; font-family: var(--mono); padding: 0 12px; color: var(--muted); }
.wf-in input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 12px 12px 12px 0; font-family: var(--mono); font-size: 1.05rem; }
.wf-in input:first-child { padding-left: 12px; }
.wf-in:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.wf-in input:focus { outline: none; }
.widget input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 24px; background: transparent; }
.widget input[type=range]::-webkit-slider-runnable-track { height: 3px; background: var(--ink); }
.widget input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; margin-top: -7.5px; background: var(--accent); border: 2px solid var(--ink); }
.widget input[type=range]::-moz-range-track { height: 3px; background: var(--ink); }
.widget input[type=range]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 0; background: var(--accent); border: 2px solid var(--ink); }
.seg { display: flex; flex-wrap: wrap; border: 2px solid var(--ink); width: max-content; max-width: 100%; }
.seg button { padding: 9px 14px; font-family: var(--mono); font-size: .82rem; border-left: 2px solid var(--ink); }
.seg button:first-child { border-left: 0; }
.seg button[aria-pressed=true] { background: var(--ink); color: var(--on-color); }
.chips-s { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-s button { padding: 7px 11px; border: 1px solid var(--line-2); font-size: .8rem; font-weight: 500; background: var(--paper); }
.chips-s button:hover { border-color: var(--ink); }
.chips-s button[aria-pressed=true] { background: var(--accent); border-color: var(--accent); color: var(--on-color); }
.w-stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.w-stat.big .w-v { font-family: var(--serif); font-weight: 900; font-stretch: 118%; font-size: clamp(2.4rem, 5vw, 3.6rem); letter-spacing: -.04em; line-height: 1; color: var(--accent); }
.w-v { font-family: var(--mono); font-size: 1.15rem; font-weight: 500; overflow-wrap: anywhere; }
.w-l { font-family: var(--mono); font-size: .68rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.w-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 14px; padding-top: 14px; border-top: 1px dashed var(--line-2); }
.w-cap { font-size: .82rem; color: var(--muted); }
.w-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-family: var(--mono); font-size: .7rem; color: var(--muted); }
.lg { display: inline-block; width: 14px; height: 3px; background: var(--ink); margin-right: -8px; }
.lg.g { background: var(--line-2); }
.lg.n { background: var(--accent); }
.lg.in { background: var(--ink); height: 1px; }
.lg.o { background: var(--mark); height: 8px; border: 1px solid var(--ink); }
.yearbar { display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; height: 90px; }
.yearbar i { position: relative; display: flex; flex-direction: column; justify-content: flex-end; border: 1px solid var(--ink); background: var(--paper); }
.yearbar b { display: block; background: var(--accent); transition: height .4s var(--ease); }
.yearbar s { position: absolute; bottom: -18px; left: 0; right: 0; text-align: center; text-decoration: none; font-family: var(--mono); font-size: .62rem; color: var(--muted); }
.yearbar + .w-cap { margin-top: 12px; }
.stack, .ratio { display: flex; height: 34px; border: var(--rule); }
.stack i, .ratio i { transition: flex .4s var(--ease); }
.stack .s1, .ratio .pr { background: var(--accent); }
.stack .s2 { background: var(--mark); }
.stack .s3 { background: var(--ink); }
.ratio .in { background: var(--mark); }
.stack i + i, .ratio i + i { border-left: var(--rule); }
.chart { width: 100%; height: 170px; border-left: var(--rule); border-bottom: var(--rule); overflow: visible; }
.chart path { fill: none; stroke-width: 2.4; vector-effect: non-scaling-stroke; }
.c-g { stroke: var(--line-2); }
.c-n { stroke: var(--accent); }
.c-in { stroke: var(--ink); stroke-dasharray: 4 4; stroke-width: 1.5; }
.dots { display: grid; grid-template-columns: repeat(20, 1fr); gap: 2px; }
.dots i { aspect-ratio: 1; background: var(--paper-2); border: 1px solid var(--line); }
.dots i.on { background: var(--accent); border-color: var(--accent); }
.dots i.tiny { background: radial-gradient(circle, var(--err) 0 18%, var(--paper-2) 20%); }
.lanes { display: grid; gap: 6px; }
.lane { display: grid; grid-template-columns: 36px 1fr 44px; gap: 8px; align-items: center; font-family: var(--mono); font-size: .72rem; }
.lane i { height: 14px; background: var(--line-2); transition: width .4s var(--ease); }
.lane.you i { background: var(--accent); }
.lane b { font-weight: 500; text-align: right; }
.mag { display: grid; grid-template-columns: repeat(13, minmax(0, 1fr)); gap: 3px; }
.mag i { height: 44px; border: 1px solid var(--ink); background: var(--paper); display: flex; align-items: flex-end; justify-content: center; padding-bottom: 3px; }
.mag i.on { background: var(--accent); }
.mag s { text-decoration: none; font-family: var(--mono); font-size: .58rem; color: var(--muted); }
.mag i.on s { color: var(--on-color); }
.steps3 { display: flex; align-items: flex-end; gap: 14px; height: 120px; padding-top: 20px; }
.steps3 i { position: relative; flex: 1; background: var(--accent); border: var(--rule); transition: height .4s var(--ease); }
.steps3 i:nth-child(2) { background: var(--mark); }
.steps3 i:nth-child(3) { background: var(--ink); }
.steps3 i::after { content: attr(data-l); position: absolute; top: -20px; left: 0; right: 0; text-align: center; font-family: var(--mono); font-size: .7rem; font-style: normal; }
.grid100 { display: grid; grid-template-columns: repeat(20, 1fr); gap: 2px; }
.grid100 i { aspect-ratio: 1; background: var(--paper-2); border: 1px solid var(--line); }
.grid100 i.b { background: var(--ink); border-color: var(--ink); }
.grid100 i.x { background: var(--err); border-color: var(--err); }
.galton { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); }
.galton canvas { width: 100%; height: auto; display: block; background: var(--grid), var(--white); border-right: var(--rule); }
.g-side { padding: 26px; display: flex; flex-direction: column; gap: 18px; }
.g-btns { display: flex; gap: 10px; flex-wrap: wrap; }

@media (max-width: 991.98px) {
  .w-grid, .galton { grid-template-columns: minmax(0, 1fr); }
  .w-in { border-right: 0; border-bottom: var(--rule-3); }
  .galton canvas { border-right: 0; border-bottom: var(--rule); }
}

@media (max-width: 639.98px) {
  .widget { box-shadow: 6px 6px 0 var(--accent); }
  .w-in, .w-out, .g-side { padding: 20px; }
  .w-head { padding: 14px 20px; }
  .seg button { padding: 9px 10px; border-left: 0; border-right: 2px solid var(--ink); }
  .seg button:last-child { border-right: 0; }
  .mag { gap: 2px; }
  .mag s { font-size: .48rem; }
}
