/* Tools (calculators): used on /tools/ and inside lessons through {% tool ... %} */
.tools-hero { position: relative; max-width: 980px; margin: 0 auto; padding: 56px 0 8px; }
.tools-hero .hero-glow { height: 400px; inset: -60px calc(50% - 50vw) auto calc(50% - 50vw); -webkit-mask-image: linear-gradient(to bottom, #000 45%, transparent); mask-image: linear-gradient(to bottom, #000 45%, transparent); }
.tools-hero h1 { margin: 6px 0 14px; font-size: clamp(2.3rem, 5.5vw, 3.6rem); }
.tools-hero h1 em { font-style: italic; color: var(--accent-strong); font-weight: 500; }
.tools-hero .kicker { margin: 0; }
.tools-points { display: flex; flex-wrap: wrap; gap: 8px; list-style: none; margin: 18px 0 0; padding: 0; }
.tools-points li { padding: 5px 14px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: .85rem; font-weight: 600; }
.tools-section { max-width: 980px; margin: 0 auto; padding-top: 38px; }
.tools-heading { margin: 0 0 14px; font-size: 1.35rem; }
.tools-sub { margin: -8px 0 16px; color: var(--muted); font-size: .95rem; }
.tools-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); }
.tool-card { position: relative; display: flex; flex-direction: column; gap: 8px; min-height: 230px; padding: 24px; overflow: hidden; isolation: isolate; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); color: var(--text); text-decoration: none; box-shadow: var(--shadow); transition: transform .25s, border-color .25s, box-shadow .25s; }
.tool-card::before { content: ""; position: absolute; inset: 0; z-index: -1; background: radial-gradient(120% 90% at 90% 0%, color-mix(in srgb, var(--accent) 20%, transparent), transparent 60%); }
a.tool-card:hover { transform: translateY(-4px); border-color: var(--accent); box-shadow: var(--shadow-lg); }
.tool-glyph { position: absolute; top: 4px; right: 14px; z-index: -1; font-family: var(--serif); font-size: 5.5rem; font-weight: 600; line-height: 1; color: color-mix(in srgb, var(--accent) 20%, transparent); transition: transform .5s cubic-bezier(.3, .7, .2, 1); transform-origin: top right; }
a.tool-card:hover .tool-glyph { transform: scale(1.15) rotate(-4deg); }
.tool-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.tool-tags span { padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.tool-tags .tag-soon { border-color: transparent; background: var(--accent-soft); color: var(--accent-strong); }
.tool-card h3 { margin: auto 0 0; font-size: 1.3rem; position: relative; }
.tool-card p { margin: 0; font-size: .93rem; }
.tool-open { margin-top: 6px; color: var(--accent-strong); font-weight: 700; font-size: .92rem; }
.tool-card.is-planned { box-shadow: none; border-style: dashed; background: transparent; }
.tool-card.is-planned::before { opacity: .45; }
.tool-card.is-planned h3, .tool-card.is-planned p { color: var(--muted); }
.tools-foot { max-width: 980px; margin: 44px auto 0; color: var(--muted); font-size: .85rem; }
.tools-page { max-width: 980px; margin: 0 auto; padding-top: 28px; }
.tools-lead { color: var(--muted); max-width: 62ch; font-size: 1.1rem; }
.tools-back { margin: 0 0 6px; font-size: .92rem; }

.tool { margin: 28px 0; padding: 20px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); font-size: .95rem; line-height: 1.5; }
.tool-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 16px; margin-bottom: 14px; }
.tool-title { margin: 0; font-size: 1.15rem; }
.tool-currency { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; font-weight: 600; }
.tool select, .tool input { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 9px 11px; min-width: 0; }
.tool input { width: 100%; }
.tool select { max-width: 220px; }
.tool select:focus, .tool input:focus { border-color: var(--accent); outline: 2px solid var(--accent-soft); }
.tool-form { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.tool-form label { display: block; }
.tool-label { display: block; margin-bottom: 4px; color: var(--ink); font-weight: 600; font-size: .88rem; }
.tool-label em { color: var(--muted); font-style: normal; font-weight: 500; }
.tool-form small { display: block; margin-top: 4px; color: var(--muted); font-size: .78rem; line-height: 1.35; }
.tool-out { margin-top: 20px; }
.tool-error { margin: 0; padding: 10px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.tool-summary { margin: 0 0 14px; color: var(--ink); font-size: 1.02rem; }
.tool-figures { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); margin: 0 0 18px; }
.tool-figures > div { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.tool-figures dt { color: var(--muted); font-size: .78rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; }
.tool-figures dd { margin: 2px 0 0; color: var(--ink); font-family: var(--serif); font-size: 1.25rem; font-weight: 600; overflow-wrap: anywhere; }
.tool-chart { position: relative; }
.chart-svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart-grid { stroke: var(--line); stroke-width: 1; }
.chart-label { fill: var(--muted); font-size: 11px; font-family: var(--sans); }
.chart-area { fill: var(--accent); opacity: .16; }
.chart-balance { fill: none; stroke: var(--accent); stroke-width: 2.5; stroke-linejoin: round; }
.chart-put { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 5 4; }
.chart-cursor { stroke: var(--muted); stroke-width: 1; }
.chart-dot { fill: var(--accent); stroke: var(--surface); stroke-width: 2; }
.chart-tip { margin-top: 6px; min-height: 1.5em; color: var(--ink); font-size: .85rem; font-weight: 600; }
.chart-tip[hidden] { display: block; visibility: hidden; }
.tool-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 4px 0 12px; color: var(--muted); font-size: .82rem; }
.tool-legend .key::before { content: ""; display: inline-block; width: 18px; height: 0; margin-right: 7px; vertical-align: middle; border-top: 3px solid var(--accent); }
.tool-legend .key-put::before { border-top: 2px dashed var(--muted); }
.tool-table summary { cursor: pointer; color: var(--accent-strong); font-weight: 600; }
.tool-table > div { max-height: 320px; overflow: auto; margin-top: 10px; }
.tool-table table { width: 100%; margin: 0; font-size: .85rem; }
.tool-table th, .tool-table td { padding: 6px 10px; text-align: right; white-space: nowrap; }
.tool-table th:first-child, .tool-table td:first-child { text-align: left; }
.tool-note { margin: 16px 0 0; color: var(--muted); font-size: .8rem; }
.tool-missing { color: var(--muted); font-style: italic; }

/* Calculators with a bar instead of a chart (budget, net worth, emergency fund) and grouped inputs */
.tool-group { grid-column: 1 / -1; margin: 6px 0 -2px; color: var(--ink); font-size: .82rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; }
.tool-bar-box { margin: 0 0 18px; }
.tool-bar { display: flex; height: 16px; overflow: hidden; border-radius: 999px; background: var(--line); }
.bar-part { display: block; height: 100%; min-width: 3px; }
.part-1 { background: color-mix(in srgb, var(--ink) 80%, var(--surface)); }
.part-2 { background: var(--muted); }
.part-3 { background: var(--accent); }
.part-4 { background: color-mix(in srgb, var(--accent) 25%, var(--surface)); }
.bar-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 8px; color: var(--muted); font-size: .85rem; }
.bar-legend i { display: inline-block; width: 12px; height: 12px; margin-right: 6px; border-radius: 3px; vertical-align: -1px; }
.tool-form input[type="number"] { min-height: 40px; }
.tool-table summary { padding-block: 8px; }
