:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --ink: #1a1d23;
  --ink2: #3d434f;
  --muted: #6b7280;
  --line: #d9dde3;
  --line2: #eceef1;
  --calc-bg: #f5f7f9;
  --acc: #1f5fbf;
  --acc-ink: #ffffff;
  --acc-soft: #eaf1fb;
  --img: #d9480f;
  --img-soft: rgba(217, 72, 15, 0.1);
  --good: #2b7a3d;
  --bad: #b42318;
  --bad-soft: #fdf0ef;
  --part: #8a5a00;
  --part-soft: #fdf6e3;
  --mirror: #b0306a;
  --hot: #d9480f;
  --sh: 214;
  --ss: 32%;
  --l0: 62%;
  --lr: 30%;
  --r: 6px;
  --mono: ui-monospace, 'SF Mono', Consolas, 'Liberation Mono', monospace;
  --math: 'Cambria Math', 'STIX Two Math', Cambria, Georgia, 'Times New Roman', serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --bg: #111418; --panel: #181c22; --ink: #e6e8eb; --ink2: #c4c9d1; --muted: #9aa1ac; --line: #2c323b; --line2: #20252c; --calc-bg: #1d2229;
    --acc: #6ea8ff; --acc-ink: #0e1116; --acc-soft: #1b2636; --img: #ff8a50; --img-soft: rgba(255, 138, 80, 0.13);
    --good: #6cc285; --bad: #ff7b72; --bad-soft: #2a1a1a; --part: #e3b341; --part-soft: #2a2415; --mirror: #f06aa4; --hot: #ff8a50;
    --ss: 22%; --l0: 26%; --lr: 30%; color-scheme: dark;
  }
}
:root[data-theme='dark'] {
  --bg: #111418; --panel: #181c22; --ink: #e6e8eb; --ink2: #c4c9d1; --muted: #9aa1ac; --line: #2c323b; --line2: #20252c; --calc-bg: #1d2229;
  --acc: #6ea8ff; --acc-ink: #0e1116; --acc-soft: #1b2636; --img: #ff8a50; --img-soft: rgba(255, 138, 80, 0.13);
  --good: #6cc285; --bad: #ff7b72; --bad-soft: #2a1a1a; --part: #e3b341; --part-soft: #2a2415; --mirror: #f06aa4; --hot: #ff8a50;
  --ss: 22%; --l0: 26%; --lr: 30%; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.55 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif; }
a { color: var(--acc); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: var(--mono); font-size: 0.86em; background: var(--line2); padding: 1px 4px; border-radius: 3px; }
var { font-family: var(--math); font-style: italic; }
h1, h2, h3 { line-height: 1.25; }
.muted { color: var(--muted); }
.small { font-size: 0.87em; }
.wrap { max-width: none; margin: 0; padding: 0 24px; }
@media (max-width: 600px) { .wrap { padding: 0 14px; } }

/* ---------------------------------------------------------------- header */
.site-head { background: var(--panel); border-bottom: 1px solid var(--line); }
.site-head .wrap { display: flex; align-items: center; gap: 22px; height: 56px; }
.logo { display: flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 650; font-size: 16px; white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo svg { width: 22px; height: 22px; flex: none; }
.logo .tld { color: var(--muted); font-weight: 400; }
.nav { display: flex; gap: 18px; font-size: 14px; }
.nav a { color: var(--ink2); }
.nav a:hover { color: var(--acc); text-decoration: none; }
.head-search { flex: 1; max-width: 340px; margin-left: auto; }
.theme-btn { flex: none; width: 34px; height: 34px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.theme-btn:hover { color: var(--ink); }
.theme-btn svg { width: 16px; height: 16px; }
@media (max-width: 980px) { .nav { display: none; } }
@media (max-width: 560px) { .logo .word { display: none; } }

.search { position: relative; }
.search input { width: 100%; height: 34px; border-radius: var(--r); border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 0 10px 0 32px; font: inherit; font-size: 14px; outline: none; }
.search input:focus { border-color: var(--acc); box-shadow: 0 0 0 2px var(--acc-soft); }
.search .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; color: var(--muted); pointer-events: none; }
.search kbd { display: none; }
.search-results { position: absolute; top: calc(100% + 4px); left: 0; right: 0; min-width: 280px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12); padding: 4px; z-index: 30; }
.search-results a { display: block; padding: 7px 9px; border-radius: 4px; color: var(--ink); font-size: 14px; }
.search-results a span { display: block; color: var(--muted); font-size: 12.5px; }
.search-results a.sel, .search-results a:hover { background: var(--acc-soft); text-decoration: none; }

/* ---------------------------------------------------------------- page */
.crumbs { font-size: 13px; color: var(--muted); margin: 20px 0 6px; }
.crumbs a { color: var(--muted); }
.page-title { font-size: clamp(24px, 3vw, 30px); font-weight: 650; margin: 0 0 6px; }
.lead { color: var(--ink2); margin: 0 0 18px; max-width: 720px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; min-width: 0; }
.panel h2 { font-size: 15px; font-weight: 650; margin: 0 0 10px; }
.panel-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.panel-head h2 { margin: 0 auto 0 0; }
h3.sec { font-size: 13px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin: 18px 0 8px; }

/* ---------------------------------------------------------------- calculator layout */
.calc { display: grid; gap: 14px; grid-template-columns: minmax(320px, 420px) minmax(0, 1fr); grid-template-areas: 'in fig' 'in res' 'steps steps'; grid-template-rows: auto 1fr auto; align-items: start; }
.calc .inputs { grid-area: in; }
.calc .figure { grid-area: fig; }
.calc .results { grid-area: res; }
.calc .steps { grid-area: steps; }
@media (max-width: 860px) { .calc { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'in' 'fig' 'res' 'steps'; } }

details.howto { background: var(--acc-soft); border: 1px solid color-mix(in srgb, var(--acc) 22%, var(--line)); border-radius: var(--r); padding: 9px 12px; margin-bottom: 14px; font-size: 14px; }
details.howto summary { cursor: pointer; font-weight: 650; color: var(--ink); }
details.howto ol { margin: 8px 0 0; padding-left: 20px; color: var(--ink2); }
details.howto li { margin: 2px 0; }
details.howto .tip { margin: 8px 0 0; color: var(--muted); font-size: 13px; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 12px; }
.tb { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
select { font: inherit; font-size: 13.5px; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); height: 32px; padding: 0 6px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.seg button { font: inherit; font-size: 13px; border: 0; background: var(--panel); color: var(--muted); padding: 0 10px; height: 30px; cursor: pointer; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button.on { background: var(--acc-soft); color: var(--acc); font-weight: 600; }

.param { margin-bottom: 12px; }
.param label { font-size: 14px; color: var(--ink2); display: block; margin-bottom: 4px; }
.param-row { display: flex; gap: 10px; align-items: center; }
.param-in { width: 80px; height: 34px; font: inherit; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--ink); padding: 0 8px; }
.pname { font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.chip { font: inherit; font-size: 12.5px; border: 1px solid var(--line); background: var(--panel); color: var(--ink2); border-radius: var(--r); padding: 2px 8px; cursor: pointer; }
.chip.on, .chip:hover { border-color: var(--acc); color: var(--acc); }

.grp { font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; margin: 14px 0 4px; }
.fields > .grp:first-child { margin-top: 0; }
.adv { display: none; }
.show-adv .adv { display: contents; }
.field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); align-items: center; gap: 1px 10px; padding: 3px 6px; margin: 0 -6px; border-radius: 4px; }
.field label { font-size: 14px; color: var(--ink2); cursor: pointer; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.field .sym { font-family: var(--math); font-style: italic; color: var(--muted); margin-left: 2px; }
.box { position: relative; display: flex; align-items: center; border: 1px solid var(--line); border-radius: var(--r); background: var(--calc-bg); height: 36px; }
.box:focus-within { border-color: var(--acc); box-shadow: 0 0 0 2px var(--acc-soft); background: var(--panel); }
.box input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; color: var(--ink); padding: 0 4px 0 10px; outline: none; height: 100%; font-variant-numeric: tabular-nums; }
.box .u { font-size: 13px; color: var(--muted); padding-right: 8px; white-space: nowrap; }
.box .clr { display: none; border: 0; background: none; color: var(--muted); font-size: 17px; line-height: 1; padding: 0 8px 2px 0; cursor: pointer; }
.box .clr:hover { color: var(--ink); }
.field.given .clr, .field.err .clr { display: block; }
.field .sub { grid-column: 2; font-size: 12px; color: var(--muted); line-height: 1.3; }
.field .sub:empty { display: none; }
.field.given .box { background: var(--panel); border-color: var(--acc); box-shadow: inset 3px 0 0 var(--acc); }
.field.given input { font-weight: 600; }
.field.err .box { border-color: var(--bad); background: var(--bad-soft); box-shadow: none; }
.field.err .sub { color: var(--bad); }
.field.out .box { opacity: 0.85; }
.field.hot { background: var(--line2); }
.field.flash { animation: flash 1.4s ease-out; }
@keyframes flash { 0% { background: var(--part-soft); } 100% { background: transparent; } }

.legend { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); margin-top: 12px; }
.lg { display: inline-block; width: 12px; height: 12px; border-radius: 2px; border: 1px solid var(--line); margin-left: 8px; }
.lg:first-child { margin-left: 0; }
.lg-in { background: var(--panel); border-color: var(--acc); box-shadow: inset 3px 0 0 var(--acc); }
.lg-calc { background: var(--calc-bg); }
.lg-img { background: var(--img-soft); border-color: var(--img); }
.linkbtn { font: inherit; font-size: 13.5px; background: none; border: 0; color: var(--acc); cursor: pointer; padding: 0; }
.linkbtn:hover { text-decoration: underline; }
.act-more { margin-top: 8px; }

.status { margin: 12px 0 0; padding: 9px 12px; border-radius: var(--r); font-size: 14px; background: var(--line2); color: var(--ink2); border-left: 3px solid var(--line); }
.status.good { border-left-color: var(--good); }
.status.bad { background: var(--bad-soft); color: var(--bad); border-left-color: var(--bad); }
.status.part { background: var(--part-soft); color: var(--part); border-left-color: var(--part); }
.actions, .row-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.row-actions { margin-top: 8px; }
.btn { font: inherit; font-size: 13.5px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: var(--r); height: 34px; padding: 0 12px; cursor: pointer; }
.btn:hover { border-color: var(--muted); }
.btn.small { height: 30px; font-size: 13px; padding: 0 10px; }
.btn.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink2); margin-top: 10px; cursor: pointer; }
.check[hidden] { display: none; }
.check input { width: 16px; height: 16px; accent-color: var(--acc); }

/* ---------------------------------------------------------------- figure */
.figure { padding: 8px; }
.dg-wrap { touch-action: none; user-select: none; -webkit-user-select: none; display: flex; justify-content: center; }
.is3d .dg-wrap { cursor: grab; }
.tf-wrap { cursor: crosshair; }
.dg-wrap.dragging { cursor: grabbing; }
.dg-wrap.placeholder { opacity: 0.5; }
.dg { width: 100%; height: auto; max-height: min(66vh, 680px); display: block; overflow: visible; }
@media (max-width: 860px) { .dg { max-height: 340px; } }
.fig-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; padding: 4px 8px 2px; font-size: 12.5px; color: var(--muted); }
.fig-foot .legend { margin: 0; }
.solbar { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px 8px; font-size: 13.5px; color: var(--part); }
.solbar button { font: inherit; font-size: 13px; border: 1px solid var(--line); background: var(--panel); color: var(--ink2); border-radius: var(--r); padding: 2px 10px; cursor: pointer; }
.solbar button.on { background: var(--acc); color: var(--acc-ink); border-color: var(--acc); }

.dg .shape { fill: color-mix(in srgb, var(--acc) 9%, transparent); stroke: var(--acc); stroke-width: 1.8; stroke-linejoin: round; }
.dg .shape.bad { fill: var(--bad-soft); stroke: var(--bad); }
.dg .shape.hl { fill: color-mix(in srgb, var(--acc) 30%, transparent); }
.dg .outline { fill: none; stroke: transparent; stroke-width: 5; stroke-linejoin: round; }
.dg .edge { fill: none; stroke: var(--ink2); stroke-width: 1.5; }
.dg .edge.strong { stroke: var(--acc); stroke-width: 2.6; stroke-linecap: round; }
.dg .aux { fill: none; stroke: var(--muted); stroke-width: 1.2; stroke-dasharray: 5 4; }
.dg .aux.thin { stroke-width: 1; opacity: 0.7; }
.dg .faint { fill: none; stroke: var(--line); stroke-width: 1.4; stroke-dasharray: 3 4; }
.dg .ring { fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-dasharray: 4 3; }
.dg .hole { fill: var(--panel); stroke: var(--acc); stroke-width: 1.8; }
.dg .ghost { opacity: 0; transition: opacity 0.12s; }
.dg .ghost.hot { opacity: 1; }
.dg .ang { fill: none; stroke: var(--ink2); stroke-width: 1.2; }
.dg .dim path { fill: none; stroke: var(--muted); stroke-width: 1; }
.dg .dim .ext { stroke-width: 0.8; opacity: 0.7; }
.dg .lbl { font: 13px system-ui, sans-serif; fill: var(--ink); paint-order: stroke; stroke: var(--panel); stroke-width: 4px; stroke-linejoin: round; }
.dg .lbl.small { font-size: 11px; }
.dg .lbl.tick, .dg .tick { font: 10.5px system-ui, sans-serif; fill: var(--muted); }
.dg .lbl.vnum { font-size: 11.5px; font-weight: 650; fill: var(--acc); }
.dg .lbl.strongl { font-weight: 650; fill: var(--acc); }
.dg .dot { fill: var(--ink2); }
.dg .dot.mid { fill: var(--acc); }
.dg .dot.faintdot { fill: var(--muted); opacity: 0.6; }
.dg .grid { stroke: var(--line2); stroke-width: 1; }
.dg .axis, .dg .axisline { stroke: var(--muted); stroke-width: 1.1; }
.dg .handle { cursor: grab; }
.dg .handle .hit { fill: transparent; }
.dg .handle .knob { fill: var(--acc); stroke: var(--panel); stroke-width: 2; }
.dg .handle:hover .knob, .dg .handle.hot .knob { r: 8.5; }
.dg .hot:not(.handle):not(text) { stroke: var(--hot) !important; }
.dg .shape.hot { fill: color-mix(in srgb, var(--hot) 14%, transparent); }
.dg .outline.hot { stroke: var(--hot); }
.dg .edge.hot, .dg .aux.hot { stroke-width: 2.6; stroke-dasharray: none; }
.dg .dim.hot path { stroke-width: 2; }
.dg text.hot { fill: var(--hot); font-weight: 650; }
.dg .dot.hot { fill: var(--hot); }
/* transformations */
.dg .tf-shape.orig { fill: color-mix(in srgb, var(--acc) 10%, transparent); stroke: var(--acc); stroke-width: 2; }
.dg .tf-shape.img { fill: var(--img-soft); stroke: var(--img); stroke-width: 2; }
.dg .tf-shape.mid, .dg .tf-line.mid { fill: none; stroke: var(--muted); stroke-width: 1.3; stroke-dasharray: 5 4; }
.dg .tf-line.orig { stroke: var(--acc); stroke-width: 2; }
.dg .tf-line.img { stroke: var(--img); stroke-width: 2; }
.dg .dot.tf-dot.orig { fill: var(--acc); }
.dg .dot.tf-dot.img { fill: var(--img); }
.dg .dot.tf-dot.mid { fill: var(--muted); }
.dg .dot.center { fill: var(--ink); }
.dg .tf-lbl { font-weight: 650; }
.dg .tf-lbl.orig { fill: var(--acc); }
.dg .tf-lbl.img { fill: var(--img); }
.dg .tf-lbl.mid { fill: var(--muted); font-weight: 400; }
.dg .mirror { fill: none; stroke: var(--mirror); stroke-width: 1.6; stroke-dasharray: 7 5; }
.dg .mirror.faded { opacity: 0.4; }
.dg .ray { fill: none; stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 4; }
/* 3D */
.d3 .f3 { fill: hsl(var(--sh) var(--ss) calc(var(--l0) + var(--l) * var(--lr))); stroke: hsl(var(--sh) var(--ss) calc(var(--l0) + var(--l) * var(--lr))); stroke-width: 0.6; stroke-linejoin: round; }
.d3 .e3 { fill: none; stroke: var(--ink); stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.d3 .e3h { fill: none; stroke: var(--ink2); stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.4; }
.d3 .dim3 { fill: none; stroke: var(--ink2); stroke-width: 1.3; }
.d3 .aux3 { fill: none; stroke: var(--ink2); stroke-width: 1.1; stroke-dasharray: 3 4; opacity: 0.8; }
.d3 .aux3.strong { stroke: var(--ink); stroke-width: 1.4; opacity: 1; }
.d3 .dim3.hot, .d3 .aux3.hot { stroke-width: 2.6; opacity: 1; stroke-dasharray: none; }

/* ---------------------------------------------------------------- results & working */
.restable { width: 100%; border-collapse: collapse; font-size: 14.5px; }
.restable th, .restable td { text-align: left; padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line2); vertical-align: top; }
.restable tr:last-child th, .restable tr:last-child td { border-bottom: 0; }
.restable th { font-weight: 400; color: var(--ink2); width: 32%; }
.restable th .sym { font-family: var(--math); font-style: italic; color: var(--muted); }
.restable td.v { font-weight: 650; font-size: 15.5px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.restable td.n { color: var(--muted); font-size: 13px; }
.restable td.c { text-align: right; width: 1%; }
.restable tr[data-k]:hover { background: var(--line2); }
.restable.coords th { width: auto; font-size: 12.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); font-weight: 600; }
.restable.coords td { font-variant-numeric: tabular-nums; }
.restable.facts { margin-top: 12px; }
.plab { font-weight: 650; color: var(--acc); }
.plab.im { color: var(--img); }
.cp { font: 12px system-ui, sans-serif; color: var(--muted); background: none; border: 1px solid var(--line); border-radius: 4px; padding: 1px 7px; cursor: pointer; }
.cp:hover { color: var(--ink); border-color: var(--muted); }
.classify { margin: 12px 0 0; font-size: 14px; }
.warn { color: var(--part); font-size: 14px; }
details.sides { margin-top: 10px; font-size: 14px; }
details.sides summary { cursor: pointer; color: var(--acc); }

.given-line { margin: 0 0 10px; font-size: 14.5px; }
.steplist { margin: 0; padding-left: 22px; display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 0 28px; }
.steplist > li { padding: 8px 0 10px; border-bottom: 1px solid var(--line2); font-size: 14.5px; min-width: 0; overflow-wrap: anywhere; }
.steplist > li::marker { color: var(--muted); font-size: 13px; }
.st-t { color: var(--muted); font-size: 13px; }
.st-f { font-family: var(--math); font-size: 16px; }
.st-s { color: var(--muted); font-family: var(--math); }
.st-r { font-family: var(--math); }
.st-r strong { font-family: system-ui, sans-serif; font-size: 14.5px; }
.steps .st-s:not(:has(var)) { font-family: inherit; font-size: 13.5px; }
.subs { margin: 6px 0 0; padding-left: 16px; font-size: 14px; font-variant-numeric: tabular-nums; }
table.shoe, table.vtable { border-collapse: collapse; width: 100%; font-size: 14px; }
table.shoe td, table.shoe th { border-bottom: 1px solid var(--line2); padding: 5px 8px 5px 0; text-align: left; }
table.shoe tfoot td { font-weight: 650; border-bottom: 0; }
table.vtable th { font-size: 12px; color: var(--muted); font-weight: 600; text-align: left; padding: 0 4px 4px; }
table.vtable td { padding: 2px 3px; }
table.vtable td:first-child { width: 28px; color: var(--muted); font-size: 13px; text-align: center; }
table.vtable td.plab { color: var(--acc); font-weight: 650; }
table.vtable input { width: 100%; height: 32px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--ink); font: inherit; padding: 0 8px; }
table.vtable input:focus { outline: none; border-color: var(--acc); }
table.vtable input.bad { border-color: var(--bad); }
table.vtable tr.hot td:first-child { color: var(--hot); font-weight: 650; }
table.vtable .clr { border: 0; background: none; color: var(--muted); font-size: 17px; cursor: pointer; }
table.vtable .clr:disabled { opacity: 0.3; cursor: default; }
.paste { margin-top: 10px; display: grid; gap: 8px; }
.paste textarea, .mean-in { width: 100%; font: 14px var(--mono); border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--ink); padding: 9px; resize: vertical; }
.mean-in:focus, .paste textarea:focus { outline: none; border-color: var(--acc); }
.biglabel { display: block; font-size: 14px; color: var(--ink2); margin-bottom: 4px; }
.hint { font-size: 13px; color: var(--muted); margin: 6px 0 0; }

/* transformation cards */
.ops { display: grid; gap: 10px; }
.opcard { border: 1px solid var(--line); border-radius: var(--r); padding: 10px; background: var(--calc-bg); }
.ophead { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.opnum { width: 22px; height: 22px; border-radius: 50%; background: var(--img); color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center; flex: none; }
.optype { flex: 1; font-weight: 600; }
.opbtns { display: flex; gap: 2px; }
.ib { width: 28px; height: 28px; border: 1px solid transparent; background: none; color: var(--muted); border-radius: var(--r); cursor: pointer; font-size: 15px; }
.ib:hover { border-color: var(--line); color: var(--ink); background: var(--panel); }
.opbody { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.opf { display: grid; gap: 2px; font-size: 12.5px; color: var(--muted); min-width: 0; }
.opf:has(select) { grid-column: 1 / -1; }
.opf input, .opf select { width: 100%; height: 32px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--ink); font: inherit; font-size: 14px; padding: 0 8px; }
.opf input:focus { outline: none; border-color: var(--acc); }
.opf input.bad { border-color: var(--bad); }
.oprule { margin-top: 8px; font-family: var(--math); font-size: 14.5px; color: var(--ink2); }

/* ---------------------------------------------------------------- article content */
.content { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 36px; margin: 34px 0 10px; }
@media (max-width: 900px) { .content { grid-template-columns: minmax(0, 1fr); } }
.content article { max-width: 740px; }
.content h2 { font-size: 20px; font-weight: 650; margin: 26px 0 8px; }
.content h2:first-child { margin-top: 0; }
.content p { color: var(--ink2); }
.ftable { width: 100%; border-collapse: collapse; font-size: 15px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.ftable td { padding: 8px 12px; border-bottom: 1px solid var(--line2); vertical-align: top; }
.ftable td:first-child { color: var(--muted); width: 36%; font-size: 14px; }
.ftable td:last-child { font-family: var(--math); }
.faq details { border-bottom: 1px solid var(--line); padding: 10px 0; }
.faq summary { cursor: pointer; font-weight: 600; }
.faq details p { margin: 8px 0 2px; }
.side h3 { font-size: 14px; font-weight: 650; margin: 0 0 8px; }
.rel { list-style: none; margin: 0; padding: 0; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.rel li + li { border-top: 1px solid var(--line2); }
.rel a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; color: var(--ink); }
.rel a:hover { background: var(--line2); text-decoration: none; }
.rel img { width: 48px; height: 36px; flex: none; }
.rel strong { display: block; font-size: 14px; font-weight: 600; }
.rel span span { font-size: 12.5px; color: var(--muted); }

/* ---------------------------------------------------------------- home */
.home-head { padding: 34px 0 10px; display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px 40px; align-items: end; }
@media (max-width: 800px) { .home-head { grid-template-columns: minmax(0, 1fr); } }
.home-head h1 { font-size: clamp(26px, 3.4vw, 34px); font-weight: 650; margin: 0 0 8px; }
.home-head p { margin: 0; color: var(--ink2); max-width: 640px; font-size: 16px; }
.hero-search input { height: 40px; font-size: 15px; }
.cat { margin: 28px 0; }
.cat h2 { font-size: 18px; font-weight: 650; margin: 0 0 10px; padding-bottom: 8px; border-bottom: 1px solid var(--line); }
.cat h2 small { font-weight: 400; color: var(--muted); font-size: 14px; margin-left: 6px; }
.dir { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 8px; }
.tile { display: flex; gap: 12px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 12px; color: var(--ink); }
.tile:hover { text-decoration: none; border-color: var(--acc); }
.tile img { width: 64px; height: 48px; flex: none; }
.tile strong { display: block; font-size: 15px; font-weight: 600; }
.tile span span { display: block; font-size: 13px; color: var(--muted); line-height: 1.4; }
.tile[hidden], .cat[hidden] { display: none; }

/* ---------------------------------------------------------------- footer & misc */
.site-foot { border-top: 1px solid var(--line); margin-top: 50px; padding: 22px 0 36px; color: var(--muted); font-size: 13.5px; background: var(--panel); }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 10px 22px; justify-content: space-between; }
.site-foot nav { display: flex; gap: 18px; flex-wrap: wrap; }
.site-foot a { color: var(--muted); }
.prose { max-width: 700px; margin: 30px auto; }
.prose p, .prose li { color: var(--ink2); }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translate(-50%, 16px); background: var(--ink); color: var(--bg); padding: 9px 14px; border-radius: var(--r); font-size: 14px; opacity: 0; pointer-events: none; transition: opacity 0.18s, transform 0.18s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { padding: 12px; border-radius: var(--r); background: var(--part-soft); }

/* ---------------------------------------------------------------- graphing calculator */
:root { --gx-minor: #eef0f3; --gx-major: #d8dce2; --gx-axis: #4b5260; --gx-dark: 0; }
@media (prefers-color-scheme: dark) { :root:not([data-theme='light']) { --gx-minor: #1d2229; --gx-major: #2b313a; --gx-axis: #9aa1ac; --gx-dark: 1; } }
:root[data-theme='dark'] { --gx-minor: #1d2229; --gx-major: #2b313a; --gx-axis: #9aa1ac; --gx-dark: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.graph-top { margin: 16px 0 8px; }
.grapher { height: calc(100vh - 56px - 32px); min-height: 480px; margin-bottom: 8px; }
.home-title { font-size: clamp(22px, 2.6vw, 28px); font-weight: 650; margin: 0 0 8px; }
.gx { position: relative; display: grid; grid-template-columns: 380px minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) auto; height: 100%; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.gx-side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); }
.gx-bar { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 8px; border-bottom: 1px solid var(--line); background: var(--calc-bg); }
.gx-sp { flex: 1; }
.gbtn { font: inherit; font-size: 13px; height: 30px; padding: 0 10px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--ink); cursor: pointer; white-space: nowrap; }
.gbtn:hover { border-color: var(--muted); }
.gbtn.primary { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.gsel { font: inherit; font-size: 13px; height: 30px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--ink); max-width: 130px; }
.gsel.small { height: 26px; font-size: 12.5px; max-width: 150px; }
.gx-help { flex: none; max-height: 48%; overflow: auto; padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 13px; }
.gx-help p { margin: 4px 0 8px; color: var(--ink2); }
.gx-help ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.gx-help li { display: flex; gap: 8px; align-items: baseline; }
.gx-help li span { color: var(--muted); font-size: 12.5px; }
.gx-ex { border: 0; background: none; padding: 0; cursor: pointer; flex: none; }
.gx-ex code { background: var(--acc-soft); color: var(--acc); }
.gx-ex:hover code { text-decoration: underline; }
.gx-rows { flex: 1; overflow: auto; min-height: 0; }
.gx-row { display: grid; grid-template-columns: 26px 24px minmax(0, 1fr) 30px; align-items: start; gap: 0 4px; padding: 5px 4px 5px 0; border-bottom: 1px solid var(--line2); border-left: 3px solid transparent; }
.gx-row.sel { border-left-color: var(--acc); background: color-mix(in srgb, var(--acc-soft) 60%, transparent); }
.gx-num { font-size: 11px; color: var(--muted); text-align: center; padding-top: 10px; }
.gx-sw { width: 18px; height: 18px; margin-top: 8px; border-radius: 50%; border: 2px solid var(--c); background: var(--c); cursor: pointer; padding: 0; }
.gx-sw.ghost { border-color: var(--line); background: none; cursor: default; }
.gx-row.off .gx-sw { background: transparent; }
.gx-row.off .gx-in { color: var(--muted); }
.gx-body { min-width: 0; }
.gx-in { width: 100%; height: 34px; border: 0; background: transparent; color: var(--ink); font: 16px var(--math); padding: 0 4px; outline: none; }
.gx-in::placeholder { font-family: system-ui, sans-serif; font-size: 13.5px; color: var(--muted); }
.gx-del { width: 26px; height: 26px; margin-top: 4px; border: 0; background: none; color: var(--muted); font-size: 18px; cursor: pointer; border-radius: var(--r); opacity: 0; }
.gx-row:hover .gx-del, .gx-row.sel .gx-del, .gx-del:focus { opacity: 1; }
.gx-del:hover { background: var(--line2); color: var(--ink); }
.gx-info { font-size: 12.5px; padding: 0 4px; }
.gx-info:empty { display: none; }
.gx-info > * { margin-bottom: 4px; }
.gx-err { color: var(--bad); }
.gx-val { font-family: var(--math); font-size: 15px; color: var(--ink2); }
.gx-chip { font: inherit; font-size: 12px; height: 24px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--acc); cursor: pointer; }
.gx-chip:hover { border-color: var(--acc); }
.gx-acts { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.gx-check { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; color: var(--ink2); cursor: pointer; }
.gx-check input { accent-color: var(--acc); }
.gx-coords { display: flex; flex-wrap: wrap; gap: 2px 10px; font-variant-numeric: tabular-nums; color: var(--ink2); }
.gx-coords b { margin-right: 2px; }
.gx-rule { color: var(--ink2); }
.gx-fit { font-size: 13px; }
.gx-eq { font-family: var(--math); font-size: 15px; color: var(--ink); }
.gx-slider { display: grid; grid-template-columns: 26px 44px minmax(0, 1fr) 44px; gap: 6px; align-items: center; }
.gx-slider input[type=range] { width: 100%; accent-color: var(--acc); }
.gx-smin, .gx-smax, .gx-dom input { height: 24px; width: 100%; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--ink); font-size: 12px; text-align: center; padding: 0 2px; }
.gx-play { width: 26px; height: 24px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--ink2); cursor: pointer; font-size: 10px; }
.gx-dom { display: flex; align-items: center; gap: 6px; font-family: var(--math); color: var(--ink2); }
.gx-dom input { width: 56px; }
.gx-tf { border: 1px solid var(--line); border-radius: var(--r); padding: 8px; background: var(--calc-bg); margin-top: 4px; }
.gx-tfgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 6px; }
.gx-tfgrid label { display: grid; gap: 2px; font-size: 11.5px; color: var(--muted); }
.gx-tfgrid label.wide { grid-column: 1 / -1; }
.gx-tfgrid input, .gx-tfgrid select { height: 28px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--ink); font: inherit; font-size: 13px; padding: 0 6px; width: 100%; }
.gx-tf .gx-rule { font-family: var(--math); margin-bottom: 6px; }
.gx-plot { position: relative; min-width: 0; min-height: 0; }
.gx-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }
.gx-zoom { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 4px; }
.gx-zoom button { width: 32px; height: 32px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--ink); font-size: 17px; cursor: pointer; line-height: 1; }
.gx-zoom button:hover { border-color: var(--muted); }
.gx-tip { position: absolute; pointer-events: none; background: var(--ink); color: var(--panel); font-size: 12.5px; padding: 3px 8px; border-radius: 4px; white-space: nowrap; font-variant-numeric: tabular-nums; z-index: 2; }
@media (max-width: 860px) {
  .grapher { height: auto; min-height: 0; }
  .gx { grid-template-columns: minmax(0, 1fr); grid-template-rows: 56vh auto; height: auto; }
  .gx-plot { order: -1; border-bottom: 1px solid var(--line); }
  .gx-side { border-right: 0; }
  .gx-rows { max-height: 60vh; }
  .gx-bar { flex-wrap: wrap; }
}

/* grapher: pretty math, editing, tables, keypad, popovers */
.gbtn.icon { width: 30px; padding: 0; font-size: 15px; }
.gx-pretty { min-height: 34px; padding: 6px 4px; font: 16px/1.35 var(--math); color: var(--ink); cursor: text; overflow-x: auto; white-space: nowrap; border-radius: 4px; outline: none; }
.gx-pretty:focus-visible { box-shadow: 0 0 0 2px var(--acc-soft); }
.gx-row:not(.editing) .gx-in { display: none; }
.gx-row.editing .gx-pretty { display: none; }
.gx-pretty i, .gx-eq i, .gx-err i { font-style: italic; }
.gx-pretty sup, .gx-eq sup { font-size: 0.72em; }
.gx-pretty sub, .gx-err sub, .gx-eq sub { font-size: 0.72em; }
.m-fn { font-style: normal; }
.m-frac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; font-size: 0.9em; margin: 0 2px; }
.m-num { border-bottom: 1px solid currentColor; padding: 0 3px 1px; }
.m-den { padding: 1px 3px 0; }
.m-rad { white-space: nowrap; }
.m-rad-in { border-top: 1px solid currentColor; padding: 0 2px; margin-left: 1px; }
.m-big { display: inline-flex; flex-direction: column; align-items: center; vertical-align: middle; line-height: 1; margin-right: 3px; }
.m-big .m-sym { font-size: 1.35em; }
.m-big .m-hi, .m-big .m-lo { font-size: 0.62em; }
.m-note { font-family: system-ui, sans-serif; font-size: 14px; color: var(--ink2); white-space: normal; }
.m-str { font-family: system-ui, sans-serif; font-size: 0.85em; color: var(--ink2); }
.gx-rbtns { display: flex; flex-direction: column; align-items: center; }
.gx-style { width: 26px; height: 24px; border: 0; background: none; color: var(--muted); font-size: 13px; cursor: pointer; border-radius: var(--r); opacity: 0; }
.gx-row:hover .gx-style, .gx-row.sel .gx-style, .gx-style:focus { opacity: 1; }
.gx-style:hover { background: var(--line2); color: var(--ink); }
.gx-slider { grid-template-columns: 26px 44px minmax(0, 1fr) 44px 38px; }
.gx-sstep { height: 24px; width: 100%; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--muted); font-size: 11px; text-align: center; }
.gx-table { overflow-x: auto; padding: 4px 0; }
.gx-table table { border-collapse: collapse; font-size: 13.5px; }
.gx-table th, .gx-table td { border: 1px solid var(--line); padding: 0; min-width: 64px; }
.gx-table th { background: var(--calc-bg); position: relative; }
.gx-table input { width: 100%; min-width: 64px; height: 28px; border: 0; background: transparent; color: var(--ink); font: 14px var(--math); padding: 0 6px; outline: none; }
.gx-table input:focus { background: var(--acc-soft); }
.gx-table th input { font-weight: 600; }
.gx-table td.calc { color: var(--muted); padding: 0 6px; font: 14px var(--math); }
.gx-table td:last-child, .gx-table th.addc { border: 0; min-width: 0; background: none; }
.gx-coladd { width: 26px; height: 26px; border: 1px dashed var(--line); background: none; color: var(--muted); border-radius: 4px; cursor: pointer; }
.gx-coldel { position: absolute; top: 1px; right: 1px; width: 16px; height: 16px; border: 0; background: none; color: var(--muted); font-size: 12px; cursor: pointer; opacity: 0; }
.gx-table th:hover .gx-coldel { opacity: 1; }
.gx-pop, .gx-settings { position: absolute; z-index: 20; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16); padding: 8px; display: grid; gap: 8px; min-width: 180px; font-size: 13px; }
.gx-settings { top: 10px; right: 52px; width: 250px; }
.gx-settings[hidden], .gx-pop[hidden] { display: none; }
.gx-pop-h { font-weight: 650; font-size: 13px; }
.gx-mi { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--ink); font: inherit; font-size: 13.5px; padding: 6px 8px; border-radius: 4px; cursor: pointer; }
.gx-mi:hover { background: var(--line2); }
.gx-mi.danger { color: var(--bad); }
.gx-colors { display: grid; grid-template-columns: repeat(5, 26px); gap: 6px; }
.gx-cbtn { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--panel); background: var(--c); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.gx-cbtn.on { box-shadow: 0 0 0 2px var(--ink); }
.gx-rng { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 6px; color: var(--ink2); }
.gx-rng input { accent-color: var(--acc); }
.gx-range4 { display: grid; gap: 6px; font-family: var(--math); }
.gx-range4 div { display: grid; grid-template-columns: 1fr auto 1fr; gap: 6px; align-items: center; }
.gx-range4 span { white-space: nowrap; color: var(--ink2); }
.gx-range4 input { height: 26px; width: 100%; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--ink); font-size: 12.5px; text-align: center; }
.gx-kp { grid-column: 1 / -1; border-top: 1px solid var(--line); background: var(--calc-bg); padding: 6px 8px 8px; }
.gx-kp[hidden] { display: none; }
.kp-tabs { display: flex; gap: 4px; margin-bottom: 6px; }
.kp-tabs button { font: inherit; font-size: 12.5px; border: 1px solid transparent; background: none; color: var(--muted); padding: 3px 10px; border-radius: var(--r); cursor: pointer; }
.kp-tabs button.on { background: var(--panel); border-color: var(--line); color: var(--ink); font-weight: 600; }
.kp-grid { display: grid; gap: 4px; }
.kp-row { display: flex; gap: 4px; }
.kp { flex: 1 1 0; min-width: 0; height: 38px; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); color: var(--ink); font: 16px var(--math); cursor: pointer; padding: 0 2px; white-space: nowrap; overflow: hidden; }
.kp:hover { border-color: var(--muted); }
.kp:active { background: var(--acc-soft); }
.kp.fn { font: 13px system-ui, sans-serif; }
.kp.op { background: var(--line2); }
.kp.act { background: var(--line2); font-family: system-ui, sans-serif; font-size: 14px; }
.kp.enter { background: var(--acc); border-color: var(--acc); color: var(--acc-ink); }
.kp.wide { flex-grow: 3; }
.kp sup, .kp sub { font-size: 0.65em; }
.gx.kp-on .gx-rows { padding-bottom: 8px; }
@media (max-width: 860px) {
  .gx { grid-template-rows: 56vh auto auto; }
  .gx-kp { position: sticky; bottom: 0; z-index: 5; }
  .kp { height: 42px; font-size: 15px; }
  .gx-style, .gx-del { opacity: 1; }
}

/* grapher: autocomplete, fixes, folders, quick add */
.gx-hint { display: none; font-size: 12px; color: var(--muted); padding: 0 4px 4px; }
.gx-hint b { font-weight: 600; color: var(--ink2); font-family: var(--math); }
.gx-new:focus-within .gx-hint { display: block; }
.gx-ac { position: absolute; z-index: 30; min-width: 230px; max-width: 320px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16); padding: 4px; }
.gx-ac[hidden] { display: none; }
.gx-aci { display: flex; justify-content: space-between; gap: 12px; padding: 5px 8px; border-radius: 4px; cursor: pointer; font-size: 13.5px; }
.gx-aci b { font-family: var(--mono); font-weight: 600; color: var(--ink); }
.gx-aci span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.gx-aci.on, .gx-aci:hover { background: var(--acc-soft); }
.gx-achint { font-size: 11px; color: var(--muted); padding: 4px 8px 2px; border-top: 1px solid var(--line2); margin-top: 2px; }
.gx-fix { height: auto; min-height: 24px; padding: 2px 8px; margin: 2px 0; background: var(--part-soft); border-color: color-mix(in srgb, var(--part) 35%, var(--line)); color: var(--ink); }
.gx-fixm { font-family: var(--math); font-size: 14px; }
.gx-fixm i { font-style: italic; }
.gx-folder { background: var(--calc-bg); grid-template-columns: 26px 24px minmax(0, 1fr) 30px; }
.gx-fold { width: 22px; height: 22px; margin: 6px 0 0 3px; border: 0; background: none; color: var(--ink2); cursor: pointer; font-size: 13px; }
.gx-sw.folder-sw { border-radius: 4px; }
.gx-ftitle { width: 100%; height: 34px; border: 0; background: transparent; color: var(--ink); font: 600 14px system-ui, sans-serif; padding: 0 4px; outline: none; }
.gx-row.in-folder { padding-left: 16px; }
.gx-row.fold-hide { display: none; }
.gx-menu { border-top: 1px solid var(--line2); padding-top: 6px; display: grid; }
.gx-pop > .gx-menu:first-child { border-top: 0; padding-top: 0; }
.gx-quick { flex: none; display: flex; flex-wrap: wrap; align-items: center; gap: 4px; padding: 6px 8px; border-top: 1px solid var(--line); background: var(--calc-bg); font-size: 12px; color: var(--muted); }
.gx-quick button { font: inherit; font-size: 12.5px; border: 1px solid var(--line); background: var(--panel); color: var(--ink2); border-radius: 99px; padding: 2px 9px; cursor: pointer; }
.gx-quick button:hover { border-color: var(--acc); color: var(--acc); }
.logo img { width: 30px; height: 30px; border-radius: 6px; flex: none; }

/* ---------------------------------------------------------------- the vault */
/* Set by the inline <head> script when this browser has unlocked the private
   home page: the real page is hidden before it can paint, then src/vault.js
   appends the #vault iframe. See src/vault.js for the whole mechanism. */
html[data-vault='on'] body > *:not(#vault):not(#vault-prompt) { display: none !important; }
html[data-vault='on'], html[data-vault='on'] body { height: 100%; margin: 0; overflow: hidden; background: var(--bg); }
#vault { position: fixed; inset: 0; width: 100%; height: 100%; border: 0; display: block; z-index: 2147483647; background: var(--bg); }
