/* Token & Prompt Calculator: builds on /styles.css tokens and /tools/shared/learn.css */

/* Hero */
.tk-hero { padding-bottom: clamp(88px, 10vw, 140px); }
.tk-back { margin-bottom: 28px; }
.tk-meta { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 28px; }
.tk-meta .chip { background: rgba(255, 255, 255, .85); }

/* Section shells */
.tk { background: var(--bg-2); padding: clamp(56px, 7vw, 100px) 0 clamp(64px, 8vw, 110px); scroll-margin-top: 64px; }
.tk-prices { padding: clamp(56px, 7vw, 96px) 0; }
.tk-head h2 { margin-top: 14px; font-size: clamp(28px, 3.2vw, 44px); max-width: 20ch; }
.tk-head > p:not(.mono) { margin-top: 16px; max-width: 36em; color: var(--text); }
.tk-head--step { margin-top: clamp(40px, 5vw, 64px); margin-bottom: 20px; }
.tk-head--wide { margin-bottom: 28px; }
.tk-card { background: #fff; border: 1px solid var(--line); padding: clamp(18px, 2.4vw, 32px); min-width: 0; }
.tk-card h3 { margin-top: 10px; font-size: clamp(22px, 2vw, 28px); }
.tk-sub { margin-top: 8px; font-size: 15.5px; color: var(--text); max-width: 46em; }
.tk-fine { margin-top: 14px; font-size: 15px; line-height: 1.5; color: var(--soft); }
.tk-fine a, .tk-means a, .lx-why__body a, .lx-myth a, .tk-prices a { color: var(--blue); text-decoration: underline; text-underline-offset: 3px; }
.tk-print-head { display: none; }

/* Controls */
.tk-btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; font-size: 15px; font-weight: 500; color: var(--ink); background: #fff; box-shadow: inset 0 0 0 1px #c9ccd2; transition: box-shadow .2s ease, color .2s ease, transform .2s var(--ease); }
.tk-btn:hover { box-shadow: inset 0 0 0 1px var(--blue); color: var(--blue); }
.tk-btn:active { transform: scale(.98); }
.tk-btn--sm { margin-top: 10px; font-size: 14px; }
.tk-btn:focus-visible, .tk-chip:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.tk-toggle { display: flex; align-items: center; gap: 14px; min-height: 44px; cursor: pointer; }
.tk-toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tk-toggle__ui { flex: none; position: relative; width: 46px; height: 26px; background: #c9ccd2; transition: background-color .25s var(--ease); }
.tk-toggle__ui::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; background: #fff; transition: transform .25s var(--ease); }
.tk-toggle input:checked + .tk-toggle__ui { background: var(--blue); }
.tk-toggle input:checked + .tk-toggle__ui::after { transform: translateX(20px); }
.tk-toggle input:focus-visible + .tk-toggle__ui { outline: 2px solid var(--blue); outline-offset: 3px; }
.tk-toggle b { display: block; font-weight: 500; font-size: 16px; }
.tk-toggle small { display: block; font-size: 15px; color: var(--soft); line-height: 1.4; }
.tk-toggle--line { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }

/* Prompt parts */
.tk-bar { margin-top: 24px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 14px 20px; padding: 14px 18px; background: #fff; border: 1px solid var(--line); }
.tk-bar .tk-toggle { flex: 1 1 280px; }
.tk-bar__btns { display: flex; gap: 8px; flex-wrap: wrap; }
.tk-parts { margin-top: 14px; display: grid; gap: 12px; }
.tk-part { background: #fff; border: 1px solid var(--line); border-left: 3px solid var(--c); padding: 14px clamp(14px, 2vw, 20px) 14px; }
.tk-part[hidden] { display: none; }
.tk-part__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px; }
.tk-part__head label { display: inline-flex; align-items: center; gap: 10px; font-weight: 500; font-size: 16px; }
.tk-part__head label i { width: 10px; height: 10px; background: var(--c); flex: none; }
.tk-part__meta { margin-left: auto; font-family: var(--mono); font-size: 12px; letter-spacing: .04em; color: var(--soft); font-variant-numeric: tabular-nums; }
.tk-sample { padding: 2px 6px; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--blue); border: 1px solid #b9c6ff; }
.tk-sample[hidden] { display: none; }
.tk-part textarea { display: block; width: 100%; margin-top: 10px; padding: 10px 12px; min-height: 96px; font-family: var(--mono); font-size: 15px; line-height: 1.5; color: var(--ink); background: #fff; border: 1px solid #c9ccd2; border-radius: 0; resize: vertical; transition: border-color .2s ease, box-shadow .2s ease; }
.tk-part--main textarea { min-height: 220px; }
.tk-part textarea:hover { border-color: #9aa0aa; }
.tk-part textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.tk-part textarea::placeholder { color: #8a8f98; }
.tk-part__foot { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 4px 16px; }
.tk-part__foot small { font-size: 15px; color: var(--soft); line-height: 1.4; flex: 1 1 220px; }
.tk-cache { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; cursor: pointer; }
.tk-cache input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tk-check { flex: none; position: relative; width: 20px; height: 20px; border: 1.5px solid #9aa0aa; background: #fff; transition: background-color .2s ease, border-color .2s ease; }
.tk-cache input:checked + .tk-check { background: var(--blue); border-color: var(--blue); }
.tk-cache input:checked + .tk-check::after { content: ""; position: absolute; left: 5px; top: 1px; width: 6px; height: 11px; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.tk-cache input:focus-visible + .tk-check { outline: 2px solid var(--blue); outline-offset: 2px; }
.tk-inputs > .lx-why { margin-top: 12px; }

/* Answer and volume */
.tk-field { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.tk-field--row { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.tk-label { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); }
.tk-val { font-size: 13px; color: var(--blue); text-transform: none; letter-spacing: 0; }
.tk-field input[type="range"] { width: 100%; height: 44px; accent-color: var(--blue); cursor: pointer; }
.tk-field input[type="number"], .tk-best select, .tk-focus select { width: 100%; min-height: 44px; padding: 0 12px; font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 1px solid #c9ccd2; border-radius: 0; }
.tk-best select, .tk-focus select { appearance: none; -webkit-appearance: none; padding-right: 34px; background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 6l4 4 4-4' fill='none' stroke='%230d2463' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 10px center / 14px; }
.tk-field input:focus, .tk-best select:focus, .tk-focus select:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 1px var(--blue); }
.tk-field small { font-size: 15px; color: var(--soft); line-height: 1.4; }
.tk-field--row input[type="number"] { max-width: 220px; }
.tk-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.tk-chip { min-height: 44px; padding: 0 12px; font-family: var(--mono); font-size: 12px; letter-spacing: .04em; text-transform: uppercase; color: var(--navy); border: 1px solid var(--line); background: var(--bg-2); transition: border-color .2s ease, color .2s ease; }
.tk-chip:hover { border-color: var(--blue); color: var(--blue); }
.tk-inline { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 12px; align-items: center; margin-top: 4px; }
.tk-volume .lx-why { margin-top: 14px; }

/* Layout */
.tk-layout { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); gap: clamp(28px, 4vw, 56px); align-items: start; }
.tk-summary { position: sticky; top: 88px; }

/* Summary card */
.tk-totals { border-top: 3px solid var(--blue); }
.tk-totals > .mono { color: var(--navy); }
.tk-kpis { margin-top: 14px; display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--line); }
.tk-kpi { padding: 12px 0; border-bottom: 1px solid var(--line); }
.tk-kpi--main { grid-column: 1 / -1; }
.tk-kpi dt { color: var(--soft); font-size: 12px; }
.tk-kpi dd { margin-top: 4px; font-size: 24px; font-weight: 500; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.tk-kpi--main dd { display: flex; align-items: baseline; gap: 10px; font-size: clamp(40px, 4vw, 54px); line-height: 1.05; color: var(--blue); }
.tk-kpi--main small { font-family: var(--mono); font-size: 13px; letter-spacing: .04em; color: var(--soft); }
.tk-size { margin-top: 18px; }
.tk-size > .mono, .tk-mix > .mono { color: var(--soft); font-size: 12px; }
.tk-size .lx-rail { padding-top: 30px; }
.tk-mix { margin-top: 20px; }
.tk-mix__l2 { margin-top: 12px; }
.tk-stack { margin-top: 8px; display: flex; height: 16px; background: var(--bg-2); overflow: hidden; }
.tk-stack span { display: block; height: 100%; background: var(--c); transition: width .6s var(--ease); }
.tk-stack span + span { box-shadow: inset 2px 0 0 #fff; }
.tk-stack span.is-out, .tk-legend i.is-out { background: repeating-linear-gradient(45deg, #b3261e 0 3px, #f2b8b5 3px 5px); }
.tk-legend { margin-top: 12px; display: grid; gap: 6px; }
.tk-legend li { display: grid; grid-template-columns: 12px minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; font-size: 15px; }
.tk-legend i { width: 12px; height: 12px; background: var(--c); }
.tk-legend span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tk-legend b { font-weight: 500; font-variant-numeric: tabular-nums; color: var(--navy); }
.tk-legend em { grid-column: 2 / -1; font-style: normal; font-size: 14px; color: var(--soft); }
.tk-best { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); display: grid; gap: 8px; }
.tk-best > label { color: var(--soft); font-size: 12px; }
.tk-best__out { margin-top: 6px; }
.tk-best__k { display: flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: #1a7f4b; }
.tk-ok { font-weight: 700; }
.tk-best__name { margin-top: 6px; font-size: 21px; font-weight: 500; letter-spacing: -.01em; }
.tk-best__name small { display: block; font-size: 14px; font-weight: 400; color: var(--soft); letter-spacing: 0; }
.tk-best__nums { margin-top: 10px; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tk-best__nums dt { font-size: 11px; color: var(--soft); }
.tk-best__nums dd { margin-top: 2px; font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--navy); overflow-wrap: anywhere; }
.tk-best__nums div:first-child dd { color: var(--blue); }

/* Status flags: colour plus icon plus text */
.tk-flag { position: relative; display: block; margin-top: 12px; padding: 10px 14px 10px 38px; font-size: 15px; background: var(--bg-2); border-left: 3px solid #c9ccd2; }
.tk-flag > span { position: absolute; left: 14px; top: 10px; font-weight: 700; width: 1em; text-align: center; }
.tk-flag.is-ok { border-color: #1a7f4b; background: #eef7f1; } .tk-flag.is-ok > span { color: #1a7f4b; }
.tk-flag.is-warn { border-color: #a15c00; background: #fff6e8; } .tk-flag.is-warn > span { color: #a15c00; }

/* What this means */
.tk-means { margin-top: clamp(32px, 4vw, 48px); border-left: 3px solid var(--blue); }
.tk-means__head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.tk-means__body { margin-top: 14px; display: grid; gap: 10px; max-width: 62em; }
.tk-means__body p { color: var(--text); }
.tk-means__body b { color: var(--ink); font-weight: 600; }
.tk-means__body .tk-lead { font-size: clamp(18px, 1.6vw, 22px); color: var(--ink); letter-spacing: -.01em; }
.tk-means .tk-flag { margin-top: 2px; }
.lx-actions a.lx-act { text-decoration: none; }

/* Results */
.tk-results { margin-top: 24px; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.tk-models { grid-column: 1 / -1; }
.tk-scroll { margin-top: 16px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tk-scroll:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.tk-table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.tk-table th, .tk-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tk-table thead th { font-family: var(--mono); font-size: 12px; font-weight: 400; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); border-bottom-color: #c9ccd2; white-space: nowrap; }
.tk-table tbody th { font-weight: 500; }
.tk-table th small { display: block; font-size: 13px; color: var(--soft); font-weight: 400; }
.tk-table .r { text-align: right; white-space: nowrap; }
.tk-table .n { width: 2.5em; font-family: var(--mono); font-size: 12px; color: var(--soft); }
.tk-table td.tier { color: var(--text); font-size: 14px; }
.tk-tier-sm, .tk-sm { display: none; }
.tk-table tr.is-best { background: #eef7f1; box-shadow: inset 3px 0 0 #1a7f4b; }
.tk-table tr.is-below th, .tk-table tr.is-below td { color: var(--soft); }
.tk-tag { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; margin-right: 6px; padding: 2px 6px; font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: .06em; text-transform: uppercase; background: #1a7f4b; color: #fff; }
.tk-tag--muted { background: var(--bg-2); color: var(--soft); border: 1px solid var(--line); }
.tk-tag--warn { background: #fff6e8; color: #8a4f00; border: 1px solid #e8c48a; }
.tk-mcell b { font-weight: 500; color: var(--ink); }
.tk-mbar { display: block; margin: 6px 0 0 auto; width: 120px; max-width: 100%; height: 4px; background: var(--bg-2); }
.tk-mbar span { display: block; height: 100%; margin-left: auto; background: var(--blue); transition: width .6s var(--ease); }
.tk-models .tk-table { min-width: 0; }

/* Savings */
.tk-save { border-top: 3px solid var(--navy); }
.tk-focus { margin-top: 14px; display: grid; gap: 6px; }
.tk-focus .mono { font-size: 12px; color: var(--soft); }
.tk-levers { margin-top: 14px; display: grid; }
.tk-lever { padding: 14px 0; border-top: 1px solid var(--line); }
.tk-lever__top { display: flex; justify-content: space-between; gap: 6px 12px; align-items: baseline; flex-wrap: wrap; }
.tk-lever h4 { font-size: 17px; font-weight: 500; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tk-state { font-family: var(--mono); font-size: 11px; font-weight: 400; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); }
.tk-lever.is-on .tk-state { color: #1a7f4b; }
.tk-lever__save b { font-size: 20px; font-weight: 500; color: var(--navy); font-variant-numeric: tabular-nums; }
.tk-lever.is-on .tk-lever__save b { color: var(--blue); }
.tk-lever__save span { font-size: 13px; color: var(--soft); margin-left: 4px; }
.tk-lever__bar { margin-top: 8px; height: 4px; background: var(--bg-2); }
.tk-lever__bar span { display: block; height: 100%; background: #7f9bff; transition: width .6s var(--ease); }
.tk-lever.is-on .tk-lever__bar span { background: var(--blue); }
.tk-lever > p { margin-top: 8px; font-size: 15px; color: var(--text); }
.tk-lever--sum p { margin-top: 0; }
.tk-lever--sum b { color: var(--ink); font-weight: 600; }

/* How we count */
.tk-rtable td.rule { font-size: 15px; color: var(--text); }
.tk-rtable tbody th { min-width: 8em; }
.tk-rtable tfoot th, .tk-rtable tfoot td { border-bottom: 0; border-top: 1px solid #c9ccd2; }
.tk-pieces { margin-top: 16px; border-top: 1px solid var(--line); }
.tk-pieces summary { display: flex; align-items: center; gap: 10px; min-height: 44px; cursor: pointer; list-style: none; font-family: var(--mono); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--blue); }
.tk-pieces summary::-webkit-details-marker { display: none; }
.tk-pieces summary::before { content: "+"; display: grid; place-items: center; width: 16px; height: 16px; border: 1px solid currentColor; font-size: 12px; line-height: 1; transition: transform .3s var(--ease); }
.tk-pieces[open] summary::before { transform: rotate(45deg); }
.tk-pieces summary:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.tk-pieces__out { margin-top: 12px; padding: 12px; white-space: pre-wrap; background: var(--bg-2); font-family: var(--mono); font-size: 14px; line-height: 1.9; overflow-wrap: anywhere; max-height: 360px; overflow-y: auto; }
.tk-pc { padding: 2px 0; }
.tk-pc--0 { background: #dfe5ff; } .tk-pc--1 { background: #c3cdff; } .tk-pc--2 { background: #eef0f4; } .tk-pc--3 { background: #ffe1c2; }
.tk-pc--br { color: var(--soft); }
.tk-pc-more { display: block; margin-top: 8px; color: var(--soft); font-size: 13px; }

/* After results */
.tk-after { margin-top: clamp(32px, 4vw, 48px); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 20px; }
.tk-after .lx-myth { grid-column: 1 / -1; }
.tk-cross { position: relative; display: grid; gap: 6px; padding: 18px 56px 18px 20px; background: var(--navy); color: #fff; transition: background-color .25s ease; }
.tk-cross:hover { background: var(--blue); }
.tk-cross .mono { font-size: 11px; color: #9fb0ff; }
.tk-cross b { font-size: 20px; font-weight: 500; letter-spacing: -.01em; }
.tk-cross > span:not(.mono) { font-size: 15px; color: #d7deff; }
.tk-cross .ar { position: absolute; right: 20px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: currentColor; stroke-width: 1.6; }

/* Prices */
.tk-notes { display: grid; gap: 6px; font-size: 15px; color: var(--text); max-width: 62em; }
.tk-notes b { color: var(--ink); font-weight: 500; }
.tk-disclaimer { margin-top: 18px; padding: 14px 18px; font-size: 15px; color: var(--text); border-left: 3px solid var(--navy); background: var(--bg-2); max-width: 62em; }

/* Responsive */
@media (max-width: 1020px) {
  .tk-layout, .tk-results { grid-template-columns: minmax(0, 1fr); }
  .tk-summary { position: static; }
}
@media (max-width: 640px) {
  .tk-after { grid-template-columns: minmax(0, 1fr); }
  .tk-inline { grid-template-columns: minmax(0, 1fr); }
  .tk-inline input { max-width: 200px; }
  .tk-means__head .lx-actions { width: 100%; }
  .tk-table th, .tk-table td { padding: 10px 6px; }
  .tk-models th.tier, .tk-models td.tier, .tk-models .n { display: none; }
  .tk-tier-sm, .tk-sm { display: inline; }
  .tk-lg { display: none; }
  .tk-models thead { display: none; }
  .tk-models tbody tr { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 12px; padding: 12px 10px; border-bottom: 1px solid var(--line); }
  .tk-models tbody th, .tk-models tbody td, .tk-models td.r { padding: 0; border: 0; text-align: left; }
  .tk-models tbody th { grid-column: 1 / -1; }
  .tk-models td.tk-k1::before, .tk-models td.tk-mcell::before { display: block; font-family: var(--mono); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; color: var(--soft); }
  .tk-models td.tk-k1::before { content: "Per 1k calls"; }
  .tk-models td.tk-mcell::before { content: "Per month"; }
  .tk-models .tk-mbar { margin: 6px 0 0; }
  .tk-models .tk-mbar span { margin-left: 0; }
  .tk-mbar { width: 72px; }
  .tk-part__meta { margin-left: 0; width: 100%; }
  .tk-rtable thead { display: none; }
  .tk-rtable tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
  .tk-rtable tfoot tr { border-bottom: 0; border-top: 1px solid #c9ccd2; }
  .tk-rtable th, .tk-rtable td, .tk-rtable tfoot th, .tk-rtable tfoot td { padding: 0; border: 0; }
  .tk-rtable tbody th { min-width: 0; }
  .tk-rtable td.rule { grid-column: 1 / -1; grid-row: 2; }
  .tk-best__nums { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .tk-best__nums div:first-child { grid-column: 1 / -1; }
  .tk-best__nums div:first-child dd { font-size: 26px; }
  .tk-cross { padding-right: 48px; }
}
@media (max-width: 360px) {
  .tk-bar { padding: 12px; }
  .tk-bar__btns { width: 100%; }
  .tk-bar__btns .tk-btn { flex: 1 1 0; }
  .tk-kpi--main dd { font-size: 36px; }
  .lx-act { padding: 0 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .tk-stack span, .tk-lever__bar span, .tk-mbar span, .tk-toggle__ui, .tk-toggle__ui::after, .tk-pieces summary::before { transition: none; }
}

/* Print */
@media print {
  .tk-hero, .tk-bar, .tk-chips, .tk-cache, .tk-btn, .lx-why, .tk-pieces, .tk-cross, .lx-actions, .lx-guide, .cta, .nav, .foot, .tk-after .lx-note { display: none !important; }
  .tk { background: #fff; padding: 0; }
  .tk-print-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
  .tk-layout, .tk-results, .tk-after { grid-template-columns: 1fr; }
  .tk-summary { position: static; }
  .tk-part textarea { min-height: 0; max-height: 14em; overflow: hidden; resize: none; font-size: 11px; }
  .tk-card, .tk-part { break-inside: avoid; }
}
.tk .lx-why summary { min-height: 44px; }
