/* Tool Kit — app-like layout for the free tool pages.
 *
 * Markup is written statically by scripts/sitelib/toolkit.py:
 *   .tk-app[data-tk=A|B|C] > .tk-q (progress + the tool's own form)
 *                           > aside.tk-r (mascot header + the tool's result + extras + actions)
 * Hub colours arrive inline on .tk-app (--hub-tint / --hub-ink). Everything here
 * is scoped under .tk-app, so the tool's own CSS keeps owning its meters, lists
 * and stats; this only restyles the shell, the option chips and the headline.
 */

.tk-app {
    --tk-line: #ece4d6;
    --tk-soft: #f4efe6;
    --tk-card: #fff;
    --tk-ink: var(--ink, #26221d);
    --tk-ink-2: var(--ink-2, #6f665a);
    --tk-ink-3: var(--ink-3, #a39886);
    --tk-spring: cubic-bezier(.3, 1.6, .5, 1);
    --tk-pad: 22px;
    /* the tool's peek pill picks this up */
    --tool-peek-bg: var(--hub-ink);
    display: grid;
    gap: 22px;
    align-items: start;
    font-family: var(--font-ui, 'Plus Jakarta Sans', system-ui, sans-serif);
    color: var(--tk-ink);
}

/* The tool's root used to be the beige box; the kit's two cards replace it. */
:has(> .tk-app) {
    background: none !important;
    padding: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
}

.tk-q,
.tk-r {
    min-width: 0;
    background: var(--tk-card);
    border-radius: 22px;
    box-shadow: 0 1px 0 var(--rule, #ebe2d2), 0 14px 30px rgba(70, 45, 20, .07);
}

.tk-q { padding: 18px var(--tk-pad) 8px; }

@media (min-width: 960px) {
    .tk-app {
        grid-template-columns: 1.15fr .85fr;
        /* break out of the tool's 760px reading column, up to the site's 1040 */
        margin-inline: calc((100% - min(1040px, 100vw - 48px)) / 2);
    }
    .tk-r {
        position: sticky;
        top: 84px;
        max-height: calc(100vh - 100px);
        overflow: auto;
        overscroll-behavior: contain;
        scrollbar-width: thin;
    }
    /* D/E: calculators and generators can run long (a month table, a prompt
       list, a template). The column still sticks, but grows with its answer
       instead of scrolling inside itself. */
    .tk-app:is([data-tk="D"], [data-tk="E"]) .tk-r {
        max-height: none;
        overflow: visible;
    }
    /* F (data-tk-wide): the answer is a picture (a phone sign, a row per
       photo) and needs the width, so it sits under the form. */
    .tk-app[data-tk-wide] { grid-template-columns: minmax(0, 1fr); }
    .tk-app[data-tk-wide] .tk-r {
        position: static;
        max-height: none;
        overflow: visible;
    }
}

/* A tool's own wide visual that lives next to its result (life-in-weeks'
   week grid) spans the whole app under both columns, as a card. */
.tk-app > :not(.tk-q, .tk-r) {
    grid-column: 1 / -1;
    min-width: 0;
    margin: 0;
}
.tk-app > :not(.tk-q, .tk-r)[hidden] { display: none; }

/* ---------------------------------------------------------------- progress */
.tk-progress {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 4px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--tk-ink-3);
}

.tk-progress-bar {
    flex: 1;
    height: 6px;
    border-radius: 99px;
    background: #efe9df;
    overflow: hidden;
}

.tk-progress-bar i {
    display: block;
    height: 100%;
    border-radius: 99px;
    background: var(--hub-ink);
    transition: width .4s var(--tk-spring);
}

.tk-progress-count { min-width: 3ch; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------- questions */
.tk-q form {
    display: block;
    counter-reset: tkq;
    gap: 0;
}

.tk-q form > fieldset,
.tk-q form > div {
    margin: 0;
    padding: 16px 0;
    border: 0;
    border-bottom: 1px dashed var(--tk-line);
    min-width: 0;
}

.tk-q form > :last-child { border-bottom: 0; }
.tk-q form > [hidden] { display: none; }

.tk-q legend {
    display: block;
    width: 100%;
    float: left;                  /* lets the legend sit inside the padding box like a heading */
    padding: 0;
    margin: 0 0 12px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -.01em;
    color: var(--tk-ink);
}

.tk-q legend + * { clear: both; }

.tk-q legend::before {
    counter-increment: tkq;
    content: counter(tkq);
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    margin: 0 10px 0 0;
    border-radius: 99px;
    background: var(--tk-ink);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    vertical-align: 2px;
}

.tk-app[data-tk-numbered] .tk-q legend::before { content: none; }

/* -------------------------------------------------------------------- tiles */
.tk-q :is([class*="-options"], [class*="-radios"]) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(112px, 1fr));
    gap: 10px;
}

.tk-q :is([class*="-options"], [class*="-radios"]) label {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 0;
    margin: 0;
    padding: 14px 12px 12px;
    border: 2px solid var(--tk-line);
    border-radius: 16px;
    background: #fffdf9;
    color: var(--tk-ink);
    font-size: 13.5px;
    font-weight: 600;
    line-height: 1.3;
    text-align: center;
    text-wrap: balance;
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform .25s var(--tk-spring), border-color .2s, background-color .2s, box-shadow .2s;
}

/* Tools that drew their own radio dot or tick box: the tile's check badge replaces it. */
.tk-q :is([class*="-options"], [class*="-radios"]) label::before,
.tk-q :is([class*="-options"], [class*="-radios"]) input:checked + label::before { content: none; }

.tk-ic {
    display: block;
    font-size: 28px;
    line-height: 1;
    transition: transform .35s var(--tk-spring);
}

/* Long sentences read better as rows: icon left, text left. */
.tk-q [class*="-options-stack"] { grid-template-columns: 1fr; }
.tk-q [class*="-options-stack"] label,
.tk-q fieldset:has(input[type="checkbox"]) :is([class*="-options"], [class*="-radios"]) label {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 40px 12px 14px;
    text-align: left;
    text-wrap: pretty;
}

.tk-q [class*="-options-stack"] .tk-ic,
.tk-q fieldset:has(input[type="checkbox"]) .tk-ic { flex: none; font-size: 24px; }

.tk-q fieldset:has(input[type="checkbox"]) :is([class*="-options"], [class*="-radios"]) {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

@media (hover: hover) {
    .tk-q :is([class*="-options"], [class*="-radios"]) label:hover {
        transform: translateY(-3px);
        border-color: color-mix(in srgb, var(--hub-ink) 35%, var(--tk-line));
        color: var(--tk-ink);
    }
}

.tk-q :is([class*="-options"], [class*="-radios"]) label:active { transform: scale(.97); scale: 1; }

.tk-q :is([class*="-options"], [class*="-radios"]) input:checked + label {
    border-color: var(--hub-ink);
    background: var(--hub-tint);
    color: var(--tk-ink);
    box-shadow: 0 6px 14px color-mix(in srgb, var(--hub-ink) 22%, transparent);
}

.tk-q :is([class*="-options"], [class*="-radios"]) input:checked + label .tk-ic { transform: scale(1.15) rotate(-6deg); }

.tk-q :is([class*="-options"], [class*="-radios"]) input:checked + label::after {
    content: "\2713";
    position: absolute;
    top: 6px;
    right: 8px;
    left: auto;
    margin: 0;
    border: 0;
    transform: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--hub-ink);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    line-height: 18px;
    text-align: center;
}

.tk-q [class*="-options-stack"] input:checked + label::after,
.tk-q fieldset:has(input[type="checkbox"]) input:checked + label::after {
    top: 50%;
    right: 12px;
    margin-top: -9px;
}

.tk-q :is([class*="-options"], [class*="-radios"]) input:focus-visible + label {
    outline: 3px solid var(--hub-ink);
    outline-offset: 2px;
}

/* Hints under a question stay small and quiet. */
.tk-q [class*="-hint"] {
    margin-top: 10px;
    font-size: 12.5px;
    line-height: 1.5;
    color: var(--tk-ink-2);
}

/* Questions whose options are sentences (toolkit.py: data-tk-rows lists them,
   by fieldset position) read as rows like -options-stack; short tick-boxes
   (data-tk-tiles, e.g. file formats) stay compact tiles. */
.tk-app[data-tk-rows~="1"] .tk-q form > fieldset:nth-of-type(1) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-rows~="2"] .tk-q form > fieldset:nth-of-type(2) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-rows~="3"] .tk-q form > fieldset:nth-of-type(3) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-rows~="4"] .tk-q form > fieldset:nth-of-type(4) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-rows~="5"] .tk-q form > fieldset:nth-of-type(5) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-rows~="6"] .tk-q form > fieldset:nth-of-type(6) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-rows~="7"] .tk-q form > fieldset:nth-of-type(7) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-rows~="8"] .tk-q form > fieldset:nth-of-type(8) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-rows~="9"] .tk-q form > fieldset:nth-of-type(9) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-rows~="10"] .tk-q form > fieldset:nth-of-type(10) :is([class*="-options"], [class*="-radios"]) {
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}

.tk-app[data-tk-rows~="1"] .tk-q form > fieldset:nth-of-type(1) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-rows~="2"] .tk-q form > fieldset:nth-of-type(2) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-rows~="3"] .tk-q form > fieldset:nth-of-type(3) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-rows~="4"] .tk-q form > fieldset:nth-of-type(4) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-rows~="5"] .tk-q form > fieldset:nth-of-type(5) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-rows~="6"] .tk-q form > fieldset:nth-of-type(6) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-rows~="7"] .tk-q form > fieldset:nth-of-type(7) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-rows~="8"] .tk-q form > fieldset:nth-of-type(8) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-rows~="9"] .tk-q form > fieldset:nth-of-type(9) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-rows~="10"] .tk-q form > fieldset:nth-of-type(10) :is([class*="-options"], [class*="-radios"]) label {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 40px 12px 14px;
    text-align: left;
    text-wrap: pretty;
}

.tk-app[data-tk-rows~="1"] .tk-q form > fieldset:nth-of-type(1) .tk-ic,
.tk-app[data-tk-rows~="2"] .tk-q form > fieldset:nth-of-type(2) .tk-ic,
.tk-app[data-tk-rows~="3"] .tk-q form > fieldset:nth-of-type(3) .tk-ic,
.tk-app[data-tk-rows~="4"] .tk-q form > fieldset:nth-of-type(4) .tk-ic,
.tk-app[data-tk-rows~="5"] .tk-q form > fieldset:nth-of-type(5) .tk-ic,
.tk-app[data-tk-rows~="6"] .tk-q form > fieldset:nth-of-type(6) .tk-ic,
.tk-app[data-tk-rows~="7"] .tk-q form > fieldset:nth-of-type(7) .tk-ic,
.tk-app[data-tk-rows~="8"] .tk-q form > fieldset:nth-of-type(8) .tk-ic,
.tk-app[data-tk-rows~="9"] .tk-q form > fieldset:nth-of-type(9) .tk-ic,
.tk-app[data-tk-rows~="10"] .tk-q form > fieldset:nth-of-type(10) .tk-ic { flex: none; font-size: 24px; }

.tk-app[data-tk-rows~="1"] .tk-q form > fieldset:nth-of-type(1) input:checked + label::after,
.tk-app[data-tk-rows~="2"] .tk-q form > fieldset:nth-of-type(2) input:checked + label::after,
.tk-app[data-tk-rows~="3"] .tk-q form > fieldset:nth-of-type(3) input:checked + label::after,
.tk-app[data-tk-rows~="4"] .tk-q form > fieldset:nth-of-type(4) input:checked + label::after,
.tk-app[data-tk-rows~="5"] .tk-q form > fieldset:nth-of-type(5) input:checked + label::after,
.tk-app[data-tk-rows~="6"] .tk-q form > fieldset:nth-of-type(6) input:checked + label::after,
.tk-app[data-tk-rows~="7"] .tk-q form > fieldset:nth-of-type(7) input:checked + label::after,
.tk-app[data-tk-rows~="8"] .tk-q form > fieldset:nth-of-type(8) input:checked + label::after,
.tk-app[data-tk-rows~="9"] .tk-q form > fieldset:nth-of-type(9) input:checked + label::after,
.tk-app[data-tk-rows~="10"] .tk-q form > fieldset:nth-of-type(10) input:checked + label::after {
    top: 50%;
    right: 12px;
    margin-top: -9px;
}

.tk-app[data-tk-tiles~="1"] .tk-q form > fieldset:nth-of-type(1) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-tiles~="2"] .tk-q form > fieldset:nth-of-type(2) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-tiles~="3"] .tk-q form > fieldset:nth-of-type(3) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-tiles~="4"] .tk-q form > fieldset:nth-of-type(4) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-tiles~="5"] .tk-q form > fieldset:nth-of-type(5) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-tiles~="6"] .tk-q form > fieldset:nth-of-type(6) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-tiles~="7"] .tk-q form > fieldset:nth-of-type(7) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-tiles~="8"] .tk-q form > fieldset:nth-of-type(8) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-tiles~="9"] .tk-q form > fieldset:nth-of-type(9) :is([class*="-options"], [class*="-radios"]),
.tk-app[data-tk-tiles~="10"] .tk-q form > fieldset:nth-of-type(10) :is([class*="-options"], [class*="-radios"]) {
    grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
}

.tk-app[data-tk-tiles~="1"] .tk-q form > fieldset:nth-of-type(1) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-tiles~="2"] .tk-q form > fieldset:nth-of-type(2) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-tiles~="3"] .tk-q form > fieldset:nth-of-type(3) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-tiles~="4"] .tk-q form > fieldset:nth-of-type(4) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-tiles~="5"] .tk-q form > fieldset:nth-of-type(5) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-tiles~="6"] .tk-q form > fieldset:nth-of-type(6) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-tiles~="7"] .tk-q form > fieldset:nth-of-type(7) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-tiles~="8"] .tk-q form > fieldset:nth-of-type(8) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-tiles~="9"] .tk-q form > fieldset:nth-of-type(9) :is([class*="-options"], [class*="-radios"]) label,
.tk-app[data-tk-tiles~="10"] .tk-q form > fieldset:nth-of-type(10) :is([class*="-options"], [class*="-radios"]) label {
    flex-direction: column;
    justify-content: center;
    gap: 6px;
    padding: 12px 8px 10px;
    text-align: center;
}

.tk-app[data-tk-tiles~="1"] .tk-q form > fieldset:nth-of-type(1) .tk-ic,
.tk-app[data-tk-tiles~="2"] .tk-q form > fieldset:nth-of-type(2) .tk-ic,
.tk-app[data-tk-tiles~="3"] .tk-q form > fieldset:nth-of-type(3) .tk-ic,
.tk-app[data-tk-tiles~="4"] .tk-q form > fieldset:nth-of-type(4) .tk-ic,
.tk-app[data-tk-tiles~="5"] .tk-q form > fieldset:nth-of-type(5) .tk-ic,
.tk-app[data-tk-tiles~="6"] .tk-q form > fieldset:nth-of-type(6) .tk-ic,
.tk-app[data-tk-tiles~="7"] .tk-q form > fieldset:nth-of-type(7) .tk-ic,
.tk-app[data-tk-tiles~="8"] .tk-q form > fieldset:nth-of-type(8) .tk-ic,
.tk-app[data-tk-tiles~="9"] .tk-q form > fieldset:nth-of-type(9) .tk-ic,
.tk-app[data-tk-tiles~="10"] .tk-q form > fieldset:nth-of-type(10) .tk-ic { font-size: 26px; }

.tk-app[data-tk-tiles~="1"] .tk-q form > fieldset:nth-of-type(1) input:checked + label::after,
.tk-app[data-tk-tiles~="2"] .tk-q form > fieldset:nth-of-type(2) input:checked + label::after,
.tk-app[data-tk-tiles~="3"] .tk-q form > fieldset:nth-of-type(3) input:checked + label::after,
.tk-app[data-tk-tiles~="4"] .tk-q form > fieldset:nth-of-type(4) input:checked + label::after,
.tk-app[data-tk-tiles~="5"] .tk-q form > fieldset:nth-of-type(5) input:checked + label::after,
.tk-app[data-tk-tiles~="6"] .tk-q form > fieldset:nth-of-type(6) input:checked + label::after,
.tk-app[data-tk-tiles~="7"] .tk-q form > fieldset:nth-of-type(7) input:checked + label::after,
.tk-app[data-tk-tiles~="8"] .tk-q form > fieldset:nth-of-type(8) input:checked + label::after,
.tk-app[data-tk-tiles~="9"] .tk-q form > fieldset:nth-of-type(9) input:checked + label::after,
.tk-app[data-tk-tiles~="10"] .tk-q form > fieldset:nth-of-type(10) input:checked + label::after {
    top: 6px;
    right: 8px;
    margin-top: 0;
}

/* A row label with a sub-line span (vitamin-d's "0–25°" + cities): the span
   takes the shrink, so the short lead text never breaks mid-number. */
.tk-app[data-tk-rows~="1"] .tk-q form > fieldset:nth-of-type(1) :is([class*="-options"], [class*="-radios"]) label > span:not(.tk-ic),
.tk-app[data-tk-rows~="2"] .tk-q form > fieldset:nth-of-type(2) :is([class*="-options"], [class*="-radios"]) label > span:not(.tk-ic),
.tk-app[data-tk-rows~="3"] .tk-q form > fieldset:nth-of-type(3) :is([class*="-options"], [class*="-radios"]) label > span:not(.tk-ic),
.tk-app[data-tk-rows~="4"] .tk-q form > fieldset:nth-of-type(4) :is([class*="-options"], [class*="-radios"]) label > span:not(.tk-ic),
.tk-app[data-tk-rows~="5"] .tk-q form > fieldset:nth-of-type(5) :is([class*="-options"], [class*="-radios"]) label > span:not(.tk-ic),
.tk-app[data-tk-rows~="6"] .tk-q form > fieldset:nth-of-type(6) :is([class*="-options"], [class*="-radios"]) label > span:not(.tk-ic),
.tk-app[data-tk-rows~="7"] .tk-q form > fieldset:nth-of-type(7) :is([class*="-options"], [class*="-radios"]) label > span:not(.tk-ic),
.tk-app[data-tk-rows~="8"] .tk-q form > fieldset:nth-of-type(8) :is([class*="-options"], [class*="-radios"]) label > span:not(.tk-ic),
.tk-app[data-tk-rows~="9"] .tk-q form > fieldset:nth-of-type(9) :is([class*="-options"], [class*="-radios"]) label > span:not(.tk-ic),
.tk-app[data-tk-rows~="10"] .tk-q form > fieldset:nth-of-type(10) :is([class*="-options"], [class*="-radios"]) label > span:not(.tk-ic) {
    flex: 1 1 0;
    min-width: 0;
}

/* A month strip (vitamin-d-sun-check): twelve short words, no icons. */
.tk-app .tk-q [class*="-months"] { grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 6px; }
.tk-app .tk-q [class*="-months"] label { padding: 10px 4px; }
.tk-app .tk-q [class*="-months"] input:checked + label::after { content: none; }

/* --------------------------------------------------------------- selects */
.tk-q select {
    min-height: 48px;
    padding: 10px 40px 10px 14px;
    border: 2px solid var(--tk-line);
    border-radius: 14px;
    background: #fffdf9 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236f665a' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 14px center;
    color: var(--tk-ink);
    font: 700 16px/1.2 var(--font-ui, system-ui, sans-serif);
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
    transition: border-color .2s;
}

.tk-q select:focus { border-color: var(--hub-ink); }
.tk-q select:focus-visible { outline: 3px solid color-mix(in srgb, var(--hub-ink) 35%, transparent); outline-offset: 1px; }
.tk-q [class*="-inline"]:has(> select) {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 0 0 12px;
}
.tk-q [class*="-inline"]:has(> select) label { margin: 0; font-size: 14px; font-weight: 700; color: var(--tk-ink-2); }

/* ------------------------------------------------- number/text/time inputs */
/* Side-by-side typed questions (life-in-weeks' age + list, leave-time's
   pairs, a photo's width + height) share a row; a lone field takes it all. */
.tk-q :is([class*="-numbers"], [class*="-pair"]) {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px 18px;
    align-items: start;
}

.tk-q :is([class*="-numbers"], [class*="-pair"]) > fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }

/* A row whose only field the tool has hidden (growth-check's second weight). */
.tk-q form > div:not(:has(> :not([hidden]))) { display: none; }

/* The question a typed field answers reads like a legend, numbered with them. */
.tk-q form label:is(:has(+ input:is([type="number"], [type="text"], [type="time"])), :has(+ [class*="-inline"] > input)):not(fieldset label):not([class*="-photo"] label) {
    display: block;
    margin: 0 0 10px;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: -.01em;
    color: var(--tk-ink);
}

.tk-q form label:is(:has(+ input:is([type="number"], [type="text"], [type="time"])), :has(+ [class*="-inline"] > input)):not(fieldset label):not([class*="-photo"] label)::before {
    counter-increment: tkq;
    content: counter(tkq);
    display: inline-grid;
    place-items: center;
    width: 22px;
    height: 22px;
    margin: 0 10px 0 0;
    border-radius: 99px;
    background: var(--tk-ink);
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    vertical-align: 2px;
}

.tk-app[data-tk-numbered] .tk-q form label::before { content: none; }
.tk-q form label strong { font-weight: inherit; }

/* Labels inside a table of fields (migraine-weather's 2x2, a photo's size)
   stay small: the legend above is the question. */
.tk-q :is(fieldset, [class*="-photo"]) label:has(+ input:is([type="number"], [type="text"])) {
    display: block;
    margin: 0 0 6px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.3;
    color: var(--tk-ink-2);
}

.tk-q input:is([type="number"], [type="text"], [type="time"]) {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    min-height: 52px;
    margin: 0;
    padding: 10px 16px;
    border: 2px solid var(--tk-line);
    border-radius: 14px;
    background: #fffdf9;
    color: var(--tk-ink);
    font: 700 19px/1.2 var(--font-ui, system-ui, sans-serif);
    font-variant-numeric: tabular-nums;
    box-shadow: none;
    transition: border-color .2s, background-color .2s, box-shadow .2s;
}

.tk-q input:is([type="number"], [type="text"], [type="time"])::placeholder { color: var(--tk-ink-3); font-weight: 600; opacity: 1; }

/* Steppers off: the field is a big tap target you type into. */
.tk-q input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
.tk-q input[type="number"]::-webkit-inner-spin-button,
.tk-q input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.tk-q input[type="time"]::-webkit-calendar-picker-indicator { opacity: .55; cursor: pointer; }

@media (hover: hover) {
    .tk-q input:is([type="number"], [type="text"], [type="time"]):hover { border-color: color-mix(in srgb, var(--hub-ink) 35%, var(--tk-line)); }
}

.tk-q input:is([type="number"], [type="text"], [type="time"]):focus {
    border-color: var(--hub-ink);
    background: #fff;
    box-shadow: 0 0 0 4px color-mix(in srgb, var(--hub-ink) 16%, transparent);
    outline: none;
}

.tk-q input:is([type="number"], [type="text"], [type="time"]):focus-visible { outline: 3px solid color-mix(in srgb, var(--hub-ink) 35%, transparent); outline-offset: 1px; }

/* A unit written after the field (leave-time's "min") sits inside it, right. */
.tk-q [class*="-inline"]:has(> input) {
    position: relative;
    display: block;
}

.tk-q [class*="-inline"]:has(> input) > input { padding-right: 58px; }

.tk-q [class*="-inline"] > [class*="-unit"] {
    position: absolute;
    top: 50%;
    right: 16px;
    transform: translateY(-50%);
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    color: var(--tk-ink-3);
    pointer-events: none;
}

.tk-q [class*="-hint"] { display: block; }

/* ------------------------------------------------------------- photo picker */
.tk-q label:has(> input[type="file"]) {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 132px;
    margin: 0;
    padding: 22px 18px 20px;
    border: 2px dashed color-mix(in srgb, var(--hub-ink) 40%, var(--tk-line));
    border-radius: 18px;
    background: color-mix(in srgb, var(--hub-tint) 45%, #fffdf9);
    color: var(--tk-ink);
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background-color .2s, transform .25s var(--tk-spring);
}

.tk-q label:has(> input[type="file"])::before {
    content: "\1F4F7";
    font-size: 34px;
    line-height: 1;
    transition: transform .35s var(--tk-spring);
}

.tk-q label:has(> input[type="file"]) > input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.tk-q label:has(> input[type="file"]) > span:first-of-type { font-size: 16px; font-weight: 800; }
.tk-q label:has(> input[type="file"]) > span + span { font-size: 13px; font-weight: 600; color: var(--tk-ink-2); }

@media (hover: hover) {
    .tk-q label:has(> input[type="file"]):hover { border-color: var(--hub-ink); transform: translateY(-2px); }
    .tk-q label:has(> input[type="file"]):hover::before { transform: scale(1.12) rotate(-6deg); }
}

.tk-q label:has(> input[type="file"]).is-over,
.tk-q label:has(> input[type="file"]:focus-visible) {
    border-style: solid;
    border-color: var(--hub-ink);
    background: var(--hub-tint);
}

.tk-q label:has(> input[type="file"]:focus-visible) { outline: 3px solid color-mix(in srgb, var(--hub-ink) 35%, transparent); outline-offset: 2px; }

.tk-q [class*="-photo"] > [class*="-or"] {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 16px 0 10px;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--tk-ink-3);
}

.tk-q [class*="-photo"] > [class*="-or"]::before,
.tk-q [class*="-photo"] > [class*="-or"]::after { content: ""; flex: 1; border-top: 1px dashed var(--tk-line); }

/* ----------------------------------------------------------- colour picker */
.tk-q label:has(> input[type="color"]) {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 8px 16px 8px 8px;
    border: 2px solid var(--tk-line);
    border-radius: 99px;
    background: #fffdf9;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.tk-q input[type="color"] {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    cursor: pointer;
}

.tk-q input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.tk-q input[type="color"]::-webkit-color-swatch { border: 3px solid #fff; border-radius: 50%; box-shadow: 0 0 0 1px var(--tk-line); }

/* ------------------------------------------------------------ result panel */
.tk-r { --tk-head: var(--hub-tint); --tk-head-ink: var(--hub-ink); }

.tk-rh {
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    min-height: 78px;
    padding: 14px 110px 0 var(--tk-pad);
    background: var(--tk-head);
    transition: background-color .4s;
}

.tk-note {
    font: 700 21px/1 var(--font-note, 'Caveat', cursive);
    color: var(--tk-head-ink);
    transform: rotate(-5deg);
    transform-origin: left bottom;
    margin-bottom: 4px;
}

.tk-mascot {
    position: absolute;
    right: 14px;
    top: 10px;
    width: 84px;
    filter: drop-shadow(3px 0 0 #fff) drop-shadow(-3px 0 0 #fff) drop-shadow(0 3px 0 #fff) drop-shadow(0 -3px 0 #fff) drop-shadow(0 10px 14px rgba(70, 45, 20, .18));
    z-index: 3;
    pointer-events: none;
}

.tk-mascot svg { display: block; width: 100%; height: auto; }
.tk-mascot.is-wiggle { animation: tk-wiggle .6s var(--tk-spring); }

@keyframes tk-wiggle {
    30% { transform: rotate(-8deg) translateY(-6px); }
    60% { transform: rotate(6deg); }
}

/* The tool's own result node, restyled into the panel. Its label and headline
   carry the header tint down so header + answer read as one block. */
.tk-r > [aria-live] {
    margin: 0;
    padding: 0 0 6px;
    background: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.tk-r > [aria-live] > * { margin-inline: var(--tk-pad); }

.tk-r > [aria-live] > [class*="-result-label"],
.tk-r > [aria-live] > [class*="-result-headline"] {
    margin-inline: 0;
    padding-inline: var(--tk-pad);
    background: var(--tk-head);
    transition: background-color .4s;
}

.tk-r > [aria-live] > [class*="-result-label"] {
    margin-top: 0;
    margin-bottom: 0;
    padding-top: 10px;
    padding-right: 104px;
    font-size: 11.5px;
    font-weight: 800;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: var(--tk-head-ink);
}

.tk-r > [aria-live] > [class*="-result-headline"] {
    margin-top: 0;
    margin-bottom: 18px;
    padding-top: 6px;
    padding-bottom: 20px;
    font-family: var(--font-ui, system-ui, sans-serif);
    font-size: clamp(34px, 2.2vw + 18px, 54px);
    font-weight: 800;
    line-height: 1.02;
    letter-spacing: -.045em;
    color: var(--tk-ink);
    text-wrap: balance;
}

.tk-r[data-tk-len="m"] > [aria-live] > [class*="-result-headline"] { font-size: clamp(28px, 1.4vw + 16px, 36px); line-height: 1.08; letter-spacing: -.035em; }
.tk-r[data-tk-len="l"] > [aria-live] > [class*="-result-headline"] { font-size: clamp(23px, .8vw + 15px, 27px); line-height: 1.18; letter-spacing: -.025em; }

.tk-r > [aria-live] [class*="-result-headline"] [class*="-days"] { font-variant-numeric: tabular-nums; }

.tk-r > [aria-live] > [class*="-result-body"] { font-size: 15px; line-height: 1.65; }

/* No result painted yet (JS off or still loading). */
.tk-r > [aria-live]:empty { display: none; }

/* --------------------------------------------------- A: our app's sticker */
.tk-match {
    position: absolute;
    right: 104px;
    top: 14px;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 3;
    transform: rotate(-6deg);
    animation: tk-pop .45s var(--tk-spring);
}

.tk-match img {
    width: 46px;
    height: 46px;
    border-radius: 12px;
    box-shadow: 0 0 0 3px #fff, 0 6px 14px rgba(70, 45, 20, .18);
}

.tk-match span { font: 700 19px/1 var(--font-note, 'Caveat', cursive); color: var(--tk-head-ink); }
.tk-match[hidden] { display: none; }

@keyframes tk-pop { from { transform: rotate(-6deg) scale(.4); opacity: 0; } }

.tk-app[data-tk="A"] .tk-r > [aria-live] > [class*="-result-headline"] { padding-right: var(--tk-pad); }

/* ---------------------------------------------------- C: verdict tones */
.tk-app[data-tone="ok"] .tk-r    { --tk-head: var(--hub-tint); --tk-head-ink: var(--hub-ink); }
.tk-app[data-tone="watch"] .tk-r { --tk-head: #fdf0cf; --tk-head-ink: #9a6500; }
.tk-app[data-tone="alert"] .tk-r { --tk-head: #fde1da; --tk-head-ink: #b3321c; }

.tk-badge {
    position: relative;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-bottom: 4px;
    padding: 6px 12px 6px 10px;
    border-radius: 99px;
    background: #fff;
    color: var(--tk-head-ink);
    font-size: 12.5px;
    font-weight: 800;
    white-space: nowrap;
    box-shadow: 0 1px 0 rgba(70, 45, 20, .08);
}

.tk-badge::before {
    content: "";
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: currentColor;
}

.tk-app[data-tone="alert"] .tk-badge::before { animation: tk-pulse 1.6s ease-in-out infinite; }
@keyframes tk-pulse { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, currentColor 22%, transparent); } }
.tk-badge[hidden] { display: none; }
.tk-app[data-tk="C"] .tk-badge:not([hidden]) ~ .tk-note,
.tk-app[data-tk="C"] .tk-note:has(~ .tk-badge:not([hidden])) { display: none; }

/* -------------------------------------------------- B: check-day strip */
.tk-viz { margin: 0 var(--tk-pad) 4px; padding-top: 14px; border-top: 1px dashed var(--tk-line); }
.tk-viz[hidden] { display: none; }

.tk-viz-dates { margin: 0 0 10px; font-size: 14px; font-weight: 600; color: var(--tk-ink-2); }
.tk-viz-dates strong { color: var(--tk-ink); font-weight: 800; }

.tk-cal {
    display: grid;
    grid-template-columns: repeat(14, minmax(0, 1fr));
    gap: 4px;
}

.tk-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 46px;
    border-radius: 9px;
    background: var(--tk-soft);
    color: var(--tk-ink-3);
    font-size: 11px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    transition: background-color .3s, color .3s, transform .3s var(--tk-spring);
}

.tk-day small { font-size: 9px; font-weight: 600; opacity: .8; }
.tk-day.is-window { background: var(--hub-tint); color: color-mix(in srgb, var(--hub-ink) 75%, #000); }
.tk-day.is-first { background: var(--hub-ink); color: #fff; transform: translateY(-3px); }
.tk-day.is-today { outline: 2px solid var(--tk-ink); outline-offset: -2px; color: var(--tk-ink); }

.tk-cal-legend {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--tk-ink-3);
}

/* ------------------------------------------------------------- actions */
.tk-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 12px var(--tk-pad) 0;
    padding: 14px 0 20px;
    border-top: 1px dashed var(--tk-line);
}

.tk-copy {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 40px;
    padding: 10px 16px;
    border: 0;
    border-radius: 99px;
    background: var(--tk-ink);
    color: #fff;
    font: 700 13px/1 var(--font-ui, system-ui, sans-serif);
    cursor: pointer;
    transition: transform .2s var(--tk-spring), background-color .2s;
}

.tk-copy:hover { background: color-mix(in srgb, var(--tk-ink) 85%, var(--hub-ink)); }
.tk-copy:active { transform: scale(.96); }
.tk-copy:focus-visible { outline: 3px solid var(--hub-ink); outline-offset: 2px; }

.tk-toast {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--hub-ink);
    opacity: 0;
    transition: opacity .2s;
}

.tk-toast.is-on { opacity: 1; }

/* -------------------------------------------------------------- mobile */
@media (max-width: 959px) {
    .tk-app { gap: 16px; }
}

@media (max-width: 640px) {
    .tk-app { --tk-pad: 16px; }
    .tk-q { padding-top: 14px; }
    .tk-q :is([class*="-options"], [class*="-radios"]) { grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 8px; }
    .tk-q [class*="-options-stack"],
    .tk-q fieldset:has(input[type="checkbox"]) :is([class*="-options"], [class*="-radios"]) { grid-template-columns: 1fr; }
    .tk-q [class*="-options-stack"] label,
    .tk-q fieldset:has(input[type="checkbox"]) :is([class*="-options"], [class*="-radios"]) label { padding: 12px 40px 12px 14px; }
    .tk-q :is([class*="-options"], [class*="-radios"]) label { flex: initial; padding: 12px 8px 10px; font-size: 13px; }
    .tk-ic { font-size: 26px; }
    .tk-rh { min-height: 70px; padding-right: 96px; }
    .tk-mascot { width: 74px; }
    .tk-day { height: 38px; font-size: 10px; border-radius: 7px; }
    .tk-cal { gap: 3px; }
    .tk-match { right: 90px; }
}

@media (prefers-reduced-motion: reduce) {
    .tk-app *,
    .tk-app *::before,
    .tk-app *::after { animation: none !important; transition: none !important; }
}

/* Until the tool's first paint the result node is empty; showing the actions
   then would make them jump down when the answer arrives (a load-time shift). */
.tk-r:not([data-tk-len]) .tk-actions,
.tk-r:not([data-tk-len]) .tk-viz { display: none; }

/* ======================================================= D / E / F extras */

/* Stat chips three to a row even in the narrow result column. */
@media (min-width: 641px) {
    .tk-app:is([data-tk="D"], [data-tk="E"], [data-tk="F"]) .tk-r > [aria-live] > [class*="-stats"] > li { flex-basis: 96px; }
}

/* life-in-weeks: the week grid under both columns, as a big card. */
.tk-app > .lw-gridwrap {
    padding: 26px var(--tk-pad) 20px;
    border-radius: 22px;
    background: var(--tk-card);
    box-shadow: 0 1px 0 var(--rule, #ebe2d2), 0 14px 30px rgba(70, 45, 20, .07);
}
.tk-app > .lw-gridwrap > .lw-grid { max-width: none; }

/* concert-sign-check: the phone is the answer. Wide screens put it left,
   large and sticky, with the reading on the right; phones stack it. */
.tk-r > [aria-live] > .cs-preview { margin-top: 4px; margin-bottom: 16px; }
.tk-r > [aria-live] > .cs-preview .cs-phone { padding: 12px; border-radius: 30px; }

@media (min-width: 960px) {
    .tk-r > [aria-live]:has(> .cs-preview) {
        display: grid;
        grid-template-columns: minmax(0, 1.45fr) minmax(0, 1fr);
        column-gap: 28px;
        align-items: start;
    }
    .tk-r > [aria-live]:has(> .cs-preview) > * { grid-column: 2; }
    .tk-r > [aria-live]:has(> .cs-preview) > [class*="-result-label"],
    .tk-r > [aria-live]:has(> .cs-preview) > [class*="-result-headline"] { grid-column: 1 / -1; }
    .tk-r > [aria-live]:has(> .cs-preview) > .cs-preview {
        grid-column: 1;
        grid-row: 3 / span 12;
        position: sticky;
        top: 96px;
        margin-right: 0;
        margin-bottom: 18px;
    }
}

/* Its three stats read as a list (beside the phone on wide screens). */
.tk-r > [aria-live]:has(> .cs-preview) > .cs-stats { gap: 6px; }
.tk-r > [aria-live]:has(> .cs-preview) > .cs-stats > li {
    flex: 1 1 100%;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

/* Full-width answers keep a reading measure for their prose. */
.tk-app[data-tk-wide] .tk-r > [aria-live] > :is(p, blockquote, [class*="-note"]):not([class*="-result-label"], [class*="-result-headline"]) { max-width: 76ch; }
