/* Tool kit (tools-a): shared work-area parts for the tool pages: fields, affix inputs, segmented tabs,
   switches, notes, summary rows, guidance, related. Loaded after tool-frame.css, before the per-tool file. */

.tk-hero-meta { font: 400 13px/1.5 var(--font-sans); color: var(--parchment-3); margin: 20px 0 0; }

/* Layout */
.tk-grid { display: grid; gap: 24px; align-items: start; }
@media (min-width: 1024px) { .tk-grid { grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 32px; } .tk-side { position: sticky; top: calc(var(--header-h) + 24px); } }
.tk-stack { display: grid; gap: 24px; }
.tk-stack .tf-panel-title, .tk-side .tf-panel-title { margin-bottom: 28px; }

/* Fields */
.tk-field { display: grid; gap: 10px; margin-top: 24px; }
.tk-field:first-of-type { margin-top: 0; }
.tk-label, .tk-field label { font: 500 13px/1.3 var(--font-sans); color: var(--ink-2); margin: 0; }
.tk-field small { font: 400 13px/1.5 var(--font-sans); color: var(--ink-2); }
.tk-two { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 24px; }
.tk-two .tk-field { margin-top: 0; }
@media (max-width: 520px) { .tk-two { grid-template-columns: 1fr; } }

.tk-affix { display: flex; align-items: center; min-height: 48px; border: 1px solid var(--hair-strong); border-radius: var(--r-chip); background: var(--paper-2); transition: border-color .2s var(--ease), box-shadow .2s var(--ease); }
.tk-affix:focus-within { border-color: var(--ink); box-shadow: 0 0 0 3px var(--kesef-soft); }
.tk-affix span { padding: 0 14px; font: 400 15px/1 var(--font-sans); color: var(--ink-2); white-space: nowrap; }
.tk-affix span:first-child { padding-right: 0; }
.tk-affix span:last-child { padding-left: 0; }
.tf-work .tk-affix input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="file"]) { flex: 1; min-width: 0; width: 100%; border: 0; background: transparent; padding: 0 14px; font-size: 18px; box-shadow: none; }
.tf-work .tk-affix input:focus { box-shadow: none; outline: none; }
.tk-affix span:first-child + input { padding-left: 6px; }

/* Segmented: the JS toggles .active + aria-selected on .scenario-tab */
.tf-work .ks-seg { width: fit-content; max-width: 100%; }
.tf-work .ks-seg .scenario-tab { min-height: 44px; padding: 0 20px; border: 0; border-radius: var(--r-pill); background: transparent; color: var(--ink-2); font: 500 14px/1 var(--font-sans); cursor: pointer; box-shadow: none; }
.tf-work .ks-seg .scenario-tab.active { background: var(--ink); color: var(--paper-2); }

/* Notes */
.tk-note { margin-top: 24px; padding: 18px 20px; border-left: 2px solid var(--ink); background: var(--paper); border-radius: 0 var(--r-chip) var(--r-chip) 0; }
.tk-note-title { font: 500 14px/1.3 var(--font-sans); color: var(--ink); margin: 0 0 6px; }
.tk-note p:last-child { font: 400 14px/1.6 var(--font-sans); color: var(--ink-2); margin: 0; }

/* Toggle rows + switch */
.tk-toggle { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 24px; padding-top: 22px; border-top: 1px solid var(--hair); }
.tk-toggle label { display: grid; gap: 4px; cursor: pointer; }
.tf-work .tk-toggle-label { font: 500 15px/1.3 var(--font-sans); color: var(--ink); }
.tk-toggle-hint { font: 400 13px/1.4 var(--font-sans); color: var(--ink-2); }
.tf-work .switch { position: relative; display: inline-block; width: 48px; height: 28px; flex: none; }
.tf-work .switch input { position: absolute; inset: -8px; width: calc(100% + 16px); height: calc(100% + 16px); opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.tf-work .switch .slider { position: absolute; inset: 0; border-radius: var(--r-pill); background: var(--paper-3); border: 1px solid var(--hair-strong); transition: background .25s var(--ease); }
.tf-work .switch .slider::before { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: var(--r-pill); background: var(--paper-2); box-shadow: 0 1px 2px rgba(18, 17, 14, .25); transition: transform .25s var(--ease); }
.tf-work .switch input:checked + .slider { background: var(--ink); border-color: var(--ink); }
.tf-work .switch input:checked + .slider::before { transform: translateX(20px); }
.tf-work .switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--kesef-soft); outline: 2px solid var(--ink); outline-offset: 2px; }

/* Summary panel */
.tk-metric--lead { padding-bottom: 24px; border-bottom: 1px solid var(--hair); }
.tk-metric .tf-result { margin: 10px 0 8px; }
.tk-hint { font: 400 13px/1.4 var(--font-sans); color: var(--ink-2); margin: 0; }

.tk-progress { margin-top: 24px; }
.tk-progress-head { display: flex; justify-content: space-between; font: 400 13px/1.3 var(--font-sans); color: var(--ink-2); margin-bottom: 10px; }
.tf-work .progress-bar-container { height: 6px; border-radius: var(--r-pill); background: var(--paper-3); overflow: hidden; }
.tf-work .progress-bar { height: 100%; border-radius: var(--r-pill); background: var(--ink); transition: width .6s var(--ease); }
.tf-work .progress-bar.over { background: var(--up); }

.tk-rows { margin: 24px 0 0; }
.tk-rows > div { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 14px 0; border-bottom: 1px solid var(--hair); }
.tk-rows dt { font: 400 15px/1.4 var(--font-sans); color: var(--ink-2); display: grid; gap: 2px; }
.tk-rows dd { margin: 0; font: 400 17px/1.2 var(--font-sans); color: var(--ink); font-variant-numeric: tabular-nums; text-align: right; }
.tk-rows .tk-neg { color: var(--down); }
.tk-rows .tk-rows-total { border-bottom: 0; padding-top: 18px; }
.tk-rows .tk-rows-total dt { color: var(--ink); font-weight: 500; }
.tk-rows .tk-rows-total dd { font: 300 30px/1 var(--font-sans); letter-spacing: -0.02em; }

.tk-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 28px; }
.tk-actions .ks-btn--ink { flex: 1 1 100%; }
.tk-actions .ks-btn--ghost { flex: 1 1 calc(50% - 5px); padding: 0 16px; }
.tk-reset { min-height: 44px; padding: 0 4px; border: 0; background: none; color: var(--ink-2); font: 500 14px/1 var(--font-sans); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }
.tk-reset:hover { color: var(--ink); }

/* Guidance */
.tk-guide { background: var(--paper); padding: 0 0 clamp(72px, 9vw, 112px); }
.tk-guide-title { margin: 0 0 clamp(32px, 4vw, 56px); padding-top: clamp(56px, 7vw, 96px); border-top: 1px solid var(--hair); }
.tk-guide-grid { display: grid; gap: 40px; }
@media (min-width: 900px) { .tk-guide-grid { grid-template-columns: repeat(3, 1fr); gap: 48px; } }
.tk-guide .ks-h3 { margin-bottom: 18px; }
.tk-guide ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.tk-guide li { font: 400 15.5px/1.6 var(--font-sans); color: var(--ink-2); }
.tk-guide li strong { color: var(--ink); font-weight: 500; }

/* Hero notes under the live summary */
.tk-hero-note { font: 400 12.5px/1.5 var(--font-sans); color: var(--parchment-3); margin: 10px 0 0; max-width: 40em; }

/* Toolbar above the work grid */
.tk-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px 24px; margin-bottom: 24px; }
.tk-toolbar-text { font: 400 15px/1.4 var(--font-sans); color: var(--ink-2); margin: 0; }
.tk-toolbar-actions { display: flex; gap: 8px; }

/* Range rows */
.tk-range-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.tk-range-head output { font: 300 32px/1 var(--font-sans); letter-spacing: -0.02em; color: var(--ink); font-variant-numeric: tabular-nums; }
.tk-field .ks-range { margin-top: 2px; }

/* Info tip: a small circled i with a hover/focus bubble from data-tip */
.tip { position: relative; display: inline-grid; place-items: center; width: 16px; height: 16px; margin-left: 4px; vertical-align: -3px; border-radius: var(--r-pill); border: 1px solid var(--hair-strong); color: var(--ink-2); cursor: help; }
.tip::before { content: 'i'; font: italic 500 10px/1 var(--font-display); }
.tip::after { content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 10px); transform: translate(-50%, 4px); width: max-content; max-width: 260px; padding: 10px 12px; border-radius: var(--r-chip); background: var(--ink); color: var(--paper-2); font: 400 13px/1.45 var(--font-sans); text-align: left; white-space: normal; display: none; pointer-events: none; z-index: 5; }
.tip:hover::after, .tip:focus-visible::after { display: block; transform: translate(-50%, 0); }
@media (max-width: 600px) { .tip::after { left: 0; max-width: 220px; } .tip:hover::after, .tip:focus-visible::after { transform: translate(-30%, 0); } }

/* Choice cards (risk profiles, scenarios): the JS toggles .active */
.tk-choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tf-work .tk-choice { display: grid; gap: 6px; justify-items: start; text-align: left; padding: 16px 18px; min-height: 96px; border: 1px solid var(--hair-strong); border-radius: var(--r-chip); background: var(--paper-2); color: var(--ink); cursor: pointer; transition: border-color .2s var(--ease), background .2s var(--ease); box-shadow: none; }
.tf-work .tk-choice:hover { border-color: var(--ink); }
.tk-choice-name { font: 500 15px/1.2 var(--font-sans); }
.tk-choice-fig { font: 300 28px/1 var(--font-sans); letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.tk-choice-sub { font: 400 13px/1.3 var(--font-sans); color: var(--ink-2); }
.tf-work .tk-choice.active { background: var(--ink); border-color: var(--ink); color: var(--paper-2); }
.tk-choice.active .tk-choice-sub { color: rgba(251, 250, 246, .68); }

/* Two-column guidance */
@media (min-width: 900px) { .tk-guide-grid--2 { grid-template-columns: repeat(2, 1fr); } }
.tk-guide .ks-disclaimer { margin-top: 48px; }

/* Segmented groups outside .scenario-tab (JS toggles .active) */
.ks-seg > button.active { background: var(--ink); color: var(--paper-2); }
.tf-panel-title + .tk-two { margin-top: 0; }

/* Chip buttons (presets, templates, what-ifs) */
.tk-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tf-work .chip-btn { display: inline-flex; align-items: center; min-height: 44px; padding: 0 14px; border: 1px solid var(--hair-strong); border-radius: var(--r-chip); background: var(--paper-2); color: var(--ink); font: 400 14px/1.2 var(--font-sans); cursor: pointer; box-shadow: none; transition: border-color .2s var(--ease), background .2s var(--ease); }
.tf-work .chip-btn:hover { border-color: var(--ink); background: var(--paper); }
.tf-work .chip-btn:active { transform: scale(.98); }

/* Switch written as <label class="switch">text<input><span class="slider"></label> */
.tf-work label.switch { width: auto; height: auto; min-height: 44px; display: flex; align-items: center; justify-content: space-between; gap: 16px; font: 500 15px/1.3 var(--font-sans); color: var(--ink); cursor: pointer; }
.tf-work label.switch input { inset: 0; width: 100%; height: 100%; }
.tf-work label.switch .slider { position: relative; inset: auto; width: 48px; height: 28px; flex: none; }

/* Inline title row with a side action */
.tk-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.tk-reset { white-space: nowrap; }
.tf-work .ks-seg > button { min-height: 44px; }
.tf-work .ks-btn--sm { --bh: 44px; }
.tf-work .ks-range { height: 44px; }

/* Keep grid columns from growing past the viewport on small screens */
.tf-hero-grid > *, .tk-grid > *, .tk-stack > * { min-width: 0; }
@media (max-width: 1023px) { .tk-grid { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 380px) { .tf-figure { font-size: 44px; } .tf-panel { padding: 20px; } .tk-actions .ks-btn--ghost { flex-basis: 100%; } }
@media (max-width: 400px) { .tf-work .ks-seg .scenario-tab { padding: 0 13px; } }
