/* Tools · "Blueprint workshop": cyanotype blue, white drafting lines, safety-orange actions, Barlow type */
.t-tools {
  --bp: #12497f; --bp-dark: #0d3a66; --bp-light: #1b5c99; --white: #f2f7ff; --dim: #a8c3e3; --orange: #ffa94d;
  --bg: var(--bp); --surface: #165591; --surface-2: #1d64a8; --text: var(--white); --muted: var(--dim); --line: rgba(242, 247, 255, .28);
  --primary: var(--orange); --primary-ink: #2a1600; --accent: #7fd1ff; --accent-ink: #062033; --good: #8ef0b3; --bad: #ff9a9a;
  --radius: 4px; --radius-sm: 3px; --btn-radius: 3px;
  --font-body: 'Barlow', 'Lexend', system-ui, sans-serif; --font-head: 'Barlow', 'Lexend', sans-serif; --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
  --top-bg: rgba(13, 58, 102, .92); --top-border: 1px solid rgba(242, 247, 255, .25);
  --input-bg: rgba(5, 30, 60, .45); --input-border: 1px solid rgba(242, 247, 255, .4);
  --stage-bg: var(--bp); --stage-head-bg: var(--bp-dark);
  --plot-bg: #0f4174; --plot-grid: rgba(242, 247, 255, .16); --plot-grid2: rgba(242, 247, 255, .06); --plot-axis: rgba(242, 247, 255, .85); --plot-label: rgba(242, 247, 255, .8); --plot-tip: rgba(13, 58, 102, .95);
  background-color: var(--bp);
  background-image: linear-gradient(rgba(242, 247, 255, .09) 1px, transparent 1px), linear-gradient(90deg, rgba(242, 247, 255, .09) 1px, transparent 1px), linear-gradient(rgba(242, 247, 255, .04) 1px, transparent 1px), linear-gradient(90deg, rgba(242, 247, 255, .04) 1px, transparent 1px);
  background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
}
.t-tools h1, .t-tools h2, .t-tools h3 { font-weight: 600; letter-spacing: .01em; }
.t-tools .mu-mark { background: transparent; border: 1.5px solid var(--white); color: var(--orange); border-radius: 3px; }
.t-tools .btn-ghost { color: var(--white); border-color: rgba(242, 247, 255, .5); }
.t-tools .btn-primary { font-weight: 700; }
.t-tools .panel { background: rgba(13, 58, 102, .55); border: 1px solid rgba(242, 247, 255, .35); border-radius: 4px; }
.t-tools .seg { background: rgba(5, 30, 60, .35); border-color: var(--line); }
.t-tools .seg-btn { color: var(--dim); }
.t-tools .seg-btn.on { background: var(--orange); color: var(--primary-ink); }
.t-tools .chip { background: transparent; color: var(--white); border-color: var(--line); }
.t-tools .chip.on { background: var(--orange); color: var(--primary-ink); }
.t-tools .tbl th { background: rgba(5, 30, 60, .4); }
.t-tools .tbl th, .t-tools .tbl td { border-color: rgba(242, 247, 255, .25); }
.t-tools .note { background: rgba(255, 169, 77, .1); border-left-color: var(--orange); }
.t-tools .sel option { color: #000; }
.t-tools .stat { background: rgba(5, 30, 60, .35); }
.t-tools .mu-foot { border-top-color: rgba(242, 247, 255, .25); }
.t-tools .bit { background: rgba(5, 30, 60, .4); border-color: var(--line); color: var(--white); }
.t-tools .bit.on { background: var(--orange); color: var(--primary-ink); border-color: var(--orange); }
.t-tools .mat { color: var(--white); }
.t-tools .mx-out { background: rgba(5, 30, 60, .35); border-color: var(--line); }
.t-tools .mx-bracket { border-color: var(--white); }

.tools-layout { display: grid; grid-template-columns: 270px 1fr; gap: 1.6rem; padding-top: 1.6rem; align-items: start; }
.tool-nav { position: sticky; top: 72px; max-height: calc(100vh - 90px); overflow: auto; padding-right: .3rem; }
.tool-nav h1 { font-size: 2.4rem; margin: 0; }
.tool-nav h1::after { content: ''; display: block; width: 60px; height: 3px; background: var(--orange); margin-top: .3rem; }
.tool-nav .muted { margin: .4rem 0 .8rem; }
.tool-nav h4 { margin: 1rem 0 .3rem; font-size: .82rem; color: var(--orange); letter-spacing: .06em; font-weight: 600; }
.tool-nav a { display: flex; gap: .55rem; align-items: center; padding: .38rem .5rem; color: var(--white); text-decoration: none; border-radius: 3px; border-left: 2px solid transparent; font-size: .97rem; }
.tool-nav a:hover { background: rgba(242, 247, 255, .08); }
.tool-nav a[aria-current="page"] { background: rgba(255, 169, 77, .16); border-left-color: var(--orange); }
.tool-main { min-height: 70vh; }
.tool-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; border-bottom: 1px dashed rgba(242, 247, 255, .4); padding-bottom: .6rem; margin-bottom: 1.1rem; }
.tool-head h2 { margin: 0; font-size: clamp(1.7rem, 3.4vw, 2.3rem); }
.tool-head p { margin: 0; color: var(--dim); }
.out-big { font-family: var(--font-mono); font-size: clamp(1.4rem, 3.6vw, 2.2rem); color: var(--orange); font-weight: 600; word-break: break-all; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: .3rem 1rem; }
.kv dt { color: var(--dim); } .kv dd { margin: 0; font-family: var(--font-mono); word-break: break-word; }
.tools-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; }

/* calculator */
.calc { max-width: 560px; }
.calc-screen { background: #08294a; border: 1px solid rgba(242, 247, 255, .45); border-radius: 4px; padding: .7rem .9rem; margin-bottom: .7rem; }
.calc-screen input { width: 100%; background: none; border: 0; color: var(--white); font-family: var(--font-mono); font-size: 1.35rem; outline: none; }
.calc-res { text-align: right; font-family: var(--font-mono); font-size: 2rem; color: var(--orange); min-height: 1.4em; word-break: break-all; }
.calc-keys { display: grid; grid-template-columns: repeat(6, 1fr); gap: .4rem; }
.calc-keys button { padding: .7rem 0; border-radius: 3px; border: 1px solid rgba(242, 247, 255, .35); background: rgba(5, 30, 60, .35); color: var(--white); font-family: var(--font-body); font-size: 1.05rem; font-weight: 600; }
.calc-keys button:hover { background: rgba(242, 247, 255, .12); }
.calc-keys .num { background: rgba(242, 247, 255, .1); font-size: 1.2rem; }
.calc-keys .op { color: var(--orange); font-size: 1.25rem; }
.calc-keys .eq { background: var(--orange); color: var(--primary-ink); grid-column: span 2; }
.calc-keys .fn { font-size: .92rem; color: var(--accent); }
.hist { max-height: 300px; overflow: auto; font-family: var(--font-mono); font-size: .92rem; }
.hist button { display: block; width: 100%; text-align: right; background: none; border: 0; border-bottom: 1px dashed rgba(242, 247, 255, .2); color: var(--white); padding: .35rem .2rem; }
.hist button small { display: block; color: var(--dim); }
.donut text { font-family: var(--font-body); }
.spinner-wrap { position: relative; width: min(380px, 100%); margin: 0 auto; }
.spinner-wrap::after { content: '▼'; position: absolute; top: -6px; left: 50%; transform: translateX(-50%); color: var(--orange); font-size: 1.8rem; }
.dice { font-size: 3.4rem; letter-spacing: .1em; }

@media (max-width: 900px) { .tools-layout { grid-template-columns: 1fr; } .tool-nav { position: static; max-height: none; } .tool-nav nav { display: flex; flex-wrap: wrap; gap: .3rem; } .tool-nav h4 { width: 100%; } .tool-nav a { border: 1px solid var(--line); } }

/* ---------- tool components ---------- */
.t-tools .small { font-size: .88rem; }
.t-tools .panel h3 { margin: 0 0 .6rem; font-size: 1.25rem; }
.t-tools .panel h4 { margin: 0 0 .4rem; }
.tool-body { display: grid; gap: 1rem; }
.tool-body > .grid2, .tool-tab > .grid2 { gap: 1rem; }
.tool-tab { display: grid; gap: 1rem; margin-top: .2rem; }
.tool-seg { flex-wrap: wrap; }
.tools-grid > .wide, .panel.wide { grid-column: 1 / -1; }
.stack { display: grid; gap: 1rem; }
.mini-out { margin-top: .7rem; }
.mini-out .out-big { font-size: clamp(1.3rem, 3vw, 1.8rem); margin: .2rem 0; }
.t-tools mark { background: var(--orange); color: var(--primary-ink); padding: 0 .15em; border-radius: 2px; }
.t-tools .steps li::before { background: var(--orange); color: var(--primary-ink); }
.t-tools .steps li { line-height: 1.7; }
.t-tools .frac { vertical-align: middle; }
.rec { text-decoration: overline; text-decoration-thickness: 2px; }
.ovl { text-decoration: overline; text-decoration-thickness: 3px; }
.cur-bar { gap: .5rem; }
.numsys { margin-top: 1.2rem; }
.numsys .seg { font-size: .85rem; }
.tn-ico { width: 1.5em; text-align: center; flex: none; }
.legend { list-style: none; padding: 0; margin: .6rem 0 0; display: grid; gap: .3rem; text-align: left; }
.legend i { display: inline-block; width: .8rem; height: .8rem; border-radius: 2px; margin-right: .45rem; vertical-align: -1px; }
.hl-row td, .hl-row th { background: rgba(255, 169, 77, .18); }
.known { background: rgba(255, 169, 77, .18); font-weight: 700; }

/* calculator */
.calc-layout { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); gap: 1.4rem; align-items: start; }
.calc-side { display: grid; gap: 1rem; }
.calc-bar { margin-bottom: .6rem; min-height: 2.2rem; }
.calc-bar .mono { color: var(--accent); }
.calc-res.dim { opacity: .55; }
.calc-res.err { color: var(--bad); font-size: 1rem; font-family: var(--font-body); }
.calc-keys button:active { transform: translateY(1px); }
.calc-keys button:focus-visible { outline: 2px solid var(--orange); outline-offset: 1px; }
@media (max-width: 1100px) { .calc-layout { grid-template-columns: 1fr; } }

/* fractions, solver, triangle */
.frac-row .inp { width: 9rem; font-family: var(--font-mono); font-size: 1.2rem; }
.frac-row .sel { font-size: 1.2rem; }
.recipe-out { line-height: 1.9; padding: .5rem .2rem; }
.sim-grid { display: grid; gap: .5rem; margin: .9rem 0; }
.sim-row { gap: .4rem; }
.sim-row .mono { min-width: 2.4rem; }
.tri-in { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .6rem; }
.tri-in .inp { width: 100%; }
.tri-svg { width: 100%; height: auto; display: block; }
.tri-shape { fill: rgba(255, 169, 77, .16); stroke: var(--white); stroke-width: 2; stroke-linejoin: round; }
.tri-v { fill: var(--orange); font-weight: 700; font-size: 16px; }
.tri-s { fill: var(--white); font-size: 12px; }

/* numbers */
.ladder { border-collapse: collapse; font-family: var(--font-mono); }
.ladder th { padding: .15rem .5rem; color: var(--orange); text-align: right; border-right: 2px solid var(--white); }
.ladder td { padding: .15rem .7rem; border-bottom: 1px solid rgba(242, 247, 255, .4); }
.factors { line-height: 1.8; word-break: break-word; max-height: 260px; overflow: auto; }
.words-out { display: grid; gap: .9rem; margin-top: .8rem; }
.words-out small { color: var(--orange); font-weight: 600; }
.words-out p { margin: .15rem 0; font-size: 1.12rem; }
.words-out .mono { color: var(--dim); font-size: 1rem; }
.rand-out { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: 1rem; }
.rand-out span { font-family: var(--font-mono); font-size: 1.5rem; font-weight: 600; padding: .35rem .8rem; border: 1px solid var(--line); border-radius: 3px; background: rgba(5, 30, 60, .35); }
.dice { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; min-height: 4.4rem; }
.dice span { line-height: 1; }
.dice .die { display: inline-grid; place-items: center; width: 3.6rem; height: 3.6rem; font-size: 1.6rem; font-weight: 700; border: 2px solid var(--white); border-radius: 10px; background: rgba(5, 30, 60, .4); }
.dice b { font-size: 2rem; margin-left: .5rem; color: var(--orange); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 180px; margin-top: .8rem; overflow-x: auto; padding-bottom: 2.2rem; }
.bar { flex: 1 0 26px; height: 100%; position: relative; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; }
.bar i { display: block; width: 100%; background: var(--orange); border-radius: 2px 2px 0 0; min-height: 1px; }
.bar b { position: absolute; bottom: calc(-1.2rem); font-size: .72rem; color: var(--dim); font-weight: 500; }
.bar small { position: absolute; bottom: -2.2rem; font-size: .8rem; font-weight: 700; }
.coin-face { min-height: 6.6rem; display: grid; place-items: center; }
.coin { display: grid; place-items: center; width: 6rem; height: 6rem; border-radius: 50%; font-weight: 700; color: #3b2600; background: radial-gradient(circle at 35% 30%, #ffe2a8, #ffa94d 60%, #c46a12); box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .35); animation: coinflip .5s ease; }
.coin.t { background: radial-gradient(circle at 35% 30%, #f3f6fb, #b9c4d4 60%, #6f7f96); color: #1d2733; }
@keyframes coinflip { from { transform: rotateY(540deg) scale(.6); } to { transform: none; } }
.seq { word-break: break-all; letter-spacing: .08em; color: var(--dim); }
.spinner-wrap svg { width: 100%; height: auto; display: block; }
.spinner-wrap .hub { fill: var(--bp-dark); stroke: var(--white); stroke-width: 3; }
.ttables { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .8rem; }
.ttable { border: 1px solid rgba(242, 247, 255, .4); border-radius: 4px; padding: .7rem .9rem; background: rgba(13, 58, 102, .55); }
.ttable h4 { margin: 0 0 .4rem; color: var(--orange); }
.ttable div { display: flex; justify-content: space-between; font-family: var(--font-mono); border-bottom: 1px dashed rgba(242, 247, 255, .18); padding: .12rem 0; }
.tbl.num td, .tbl.num th { text-align: right; font-family: var(--font-mono); }
.tbl.num td:first-child, .tbl.num th:first-child { text-align: left; }

/* measure */
.unit-cats { margin-bottom: .2rem; }
.unit-cats .chip[aria-selected="true"] { background: var(--orange); color: var(--primary-ink); border-color: var(--orange); }
.conv-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto minmax(0, 1.4fr); gap: .6rem; align-items: center; }
.conv-row .inp { font-size: 1.3rem; }
@media (max-width: 700px) { .conv-row { grid-template-columns: 1fr auto; } .conv-row .inp { grid-column: 1 / -1; } }
.shape-pick h4 { margin: .3rem 0; color: var(--orange); font-size: .9rem; font-weight: 600; }
.shape-pick .chips { margin-bottom: .4rem; }
.shape-svg { width: min(260px, 100%); height: auto; display: block; margin: 0 auto .6rem; fill: rgba(255, 169, 77, .16); stroke: var(--white); stroke-width: 1.6; stroke-linejoin: round; }
.shape-svg .dash, .shape-svg ellipse.dash { fill: none; stroke: var(--orange); stroke-dasharray: 4 3; }
.shape-svg text { fill: var(--orange); stroke: none; font-size: 11px; font-weight: 700; font-family: var(--font-body); }
.ans-row { border-bottom: 1px dashed rgba(242, 247, 255, .3); padding: .4rem 0 .6rem; }
.ans-row small { color: var(--dim); }
.ans-row .out-big { font-size: clamp(1.25rem, 3vw, 1.7rem); margin: .1rem 0; }
.ans-row p.muted { margin: 0; }
.t-tools input[type="date"], .t-tools input[type="time"] { color-scheme: dark; }

/* money and study */
.bb-rows, .subs { display: grid; gap: .45rem; margin-bottom: .6rem; }
.bb-row, .sub-row { gap: .4rem; flex-wrap: nowrap; overflow-x: auto; }
.hbars { display: grid; gap: .35rem; margin-top: .8rem; }
.hbars div { display: grid; grid-template-columns: 8rem 1fr 3.6rem; gap: .5rem; align-items: center; font-size: .92rem; }
.hbars span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbars i { display: block; height: .9rem; background: var(--orange); border-radius: 2px; }
.hbars b { font-family: var(--font-mono); text-align: right; font-weight: 600; }

/* print: black on white */
@media print {
  body.t-tools.mu-printing .mu-print-root, body.t-tools.mu-printing .mu-print-root * { color: #000 !important; background: transparent !important; border-color: #888 !important; box-shadow: none !important; }
  body.t-tools .ttables { grid-template-columns: repeat(3, 1fr); }
  body.t-tools .ttable { break-inside: avoid; }
}
#tool-title:focus { outline: none; }
