/* PrintableRuler: visual identity
   ink navy #14213d · ruler yellow #ffc23d · paper white · link blue #1f4fd1 */
:root {
  --ink: #14213d;
  --ink-2: #334155;
  --muted: #5b6577;
  --line: #e3e7ee;
  --line-2: #cfd6e2;
  --paper: #ffffff;
  --bg: #f6f7f9;
  --yellow: #ffc23d;
  --yellow-2: #ffb000;
  --yellow-soft: #fff4d6;
  --link: #1f4fd1;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(20 33 61 / .06), 0 8px 24px rgb(20 33 61 / .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body { margin: 0; font: 16px/1.6 var(--font); color: var(--ink); background: var(--bg); }
img, svg { max-width: 100%; }
a { color: var(--link); text-underline-offset: 2px; }
a:hover { text-decoration-thickness: 2px; }
h1, h2, h3 { line-height: 1.2; letter-spacing: -0.015em; }
:focus-visible { outline: 3px solid var(--yellow-2); outline-offset: 2px; border-radius: 4px; }

.wrap { width: 100%; max-width: 1180px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 720px) { .wrap { padding: 0 24px; } }

.skip { position: absolute; left: -999px; top: 8px; background: var(--ink); color: #fff; padding: 8px 12px; z-index: 100; border-radius: 6px; }
.skip:focus { left: 8px; }

/* Header */
.site-header { position: sticky; top: 0; z-index: 40; background: rgb(255 255 255 / .94); backdrop-filter: saturate(1.4) blur(8px); border-bottom: 1px solid var(--line); }
.header-row { display: flex; align-items: center; justify-content: space-between; height: 60px; gap: 16px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; flex-shrink: 0; }
.brand-mark { width: 34px; height: 34px; display: block; }
.brand-word { font-size: 1.15rem; letter-spacing: -0.02em; white-space: nowrap; }
.brand-word span { font-weight: 500; }
.brand-word b { font-weight: 800; }
.brand-word i { font-style: normal; color: #8a94a6; font-weight: 500; }
.nav-desktop { display: none; gap: 4px; }
.nav-desktop a, .nav-mobile nav a { color: var(--ink-2); text-decoration: none; font-weight: 550; font-size: .94rem; padding: 8px 10px; border-radius: 8px; }
.nav-desktop a:hover, .nav-mobile nav a:hover { background: var(--bg); color: var(--ink); }
.nav-desktop a[aria-current="page"], .nav-mobile nav a[aria-current="page"] { color: var(--ink); background: var(--yellow-soft); }
.nav-mobile summary { list-style: none; cursor: pointer; width: 44px; height: 44px; display: grid; place-content: center; gap: 5px; border-radius: 10px; }
.nav-mobile summary::-webkit-details-marker { display: none; }
.nav-mobile summary span { display: block; width: 22px; height: 2px; background: var(--ink); border-radius: 2px; }
.nav-mobile[open] summary { background: var(--bg); }
.nav-mobile nav { position: absolute; left: 0; right: 0; top: 60px; background: #fff; border-bottom: 1px solid var(--line); box-shadow: var(--shadow); padding: 8px 16px 16px; display: grid; }
.nav-mobile nav a { padding: 12px 10px; font-size: 1rem; }
@media (min-width: 1000px) { .nav-desktop { display: flex; } .nav-mobile { display: none; } }

/* Hero */
.hero { padding: 28px 16px 16px; }
.hero h1 { font-size: clamp(1.6rem, 4.6vw, 2.5rem); margin: 0 0 8px; font-weight: 800; }
.hero .lede { margin: 0; max-width: 72ch; color: var(--ink-2); font-size: 1.04rem; }
.hero--plain { padding-bottom: 0; }
@media (min-width: 720px) { .hero { padding: 40px 24px 20px; } }

/* Buttons and fields */
.btn { --b: var(--ink); display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 10px; border: 2px solid transparent; font: 650 1rem var(--font); cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .05s; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn-primary { background: var(--yellow); color: var(--ink); border-color: var(--yellow); }
.btn-primary:hover { background: var(--yellow-2); border-color: var(--yellow-2); }
.btn-secondary { background: #fff; color: var(--ink); border-color: var(--ink); }
.btn-secondary:hover { background: var(--ink); color: #fff; }
.btn-ghost { background: transparent; color: var(--ink-2); border-color: var(--line-2); }
.btn-ghost:hover { border-color: var(--ink); color: var(--ink); }
.btn-sm { min-height: 38px; padding: 0 12px; font-size: .92rem; }
.btn[disabled] { opacity: .6; cursor: progress; }
.linklike { background: none; border: 0; padding: 0; color: var(--link); font: inherit; text-decoration: underline; cursor: pointer; }

.field { display: grid; gap: 6px; font-weight: 600; font-size: .9rem; color: var(--ink-2); }
.field.inline { display: inline-grid; margin-right: 8px; }
select, input[type="number"], input[type="text"] { font: 500 1rem var(--font); color: var(--ink); background: #fff; border: 1.5px solid var(--line-2); border-radius: 10px; min-height: 46px; padding: 0 12px; width: 100%; }
select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2314213d' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
select:hover, input:hover { border-color: var(--ink-2); }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: .92rem; color: var(--ink-2); min-height: 40px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); }

/* Tool shell */
.tool { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow); }
.print-tool { display: grid; gap: 0; }
.tool-controls { display: grid; gap: 14px; padding: 18px; border-bottom: 1px solid var(--line); align-content: start; }
.tool-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 4px; }
.tool-note { margin: 0; font-size: .88rem; color: var(--ink-2); background: var(--yellow-soft); border-radius: 10px; padding: 10px 12px; line-height: 1.5; }
.tool-preview { background: #e9ecf1; padding: 16px; display: grid; justify-items: center; align-content: start; border-radius: 0 0 16px 16px; }
.sheet { width: 100%; max-width: 640px; aspect-ratio: 215.9 / 279.4; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .12), 0 10px 30px rgb(20 33 61 / .14); border-radius: 2px; }
.sheet[data-paper="a4"] { aspect-ratio: 210 / 297; }
.sheet[data-paper="legal"] { aspect-ratio: 215.9 / 355.6; }
.sheet[data-paper="a3"] { aspect-ratio: 297 / 420; }
.sheet svg { display: block; width: 100%; height: 100%; }
.sheet-caption { margin: 10px 0 0; font-size: .85rem; color: var(--muted); text-align: center; }
@media (min-width: 900px) {
  .print-tool { grid-template-columns: 360px 1fr; }
  .tool-controls { border-bottom: 0; border-right: 1px solid var(--line); padding: 22px; position: sticky; top: 76px; }
  .tool-preview { padding: 28px; border-radius: 0 16px 16px 0; }
}

/* Screen ruler */
.screen-tool { padding: 14px; display: grid; gap: 12px; }
.screen-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.seg { display: inline-flex; background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.seg button { border: 0; background: transparent; font: 600 .9rem var(--font); color: var(--ink-2); padding: 8px 12px; border-radius: 8px; cursor: pointer; min-height: 38px; }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / .12); }
.cal-state { font-size: .86rem; color: var(--muted); }
.cal-state.ok { color: #0f7a3b; font-weight: 600; }
.cal-panel { border: 1px dashed var(--line-2); border-radius: 12px; padding: 14px; display: grid; gap: 12px; background: #fbfcfd; }
.cal-panel > * { min-width: 0; }
.cal-panel p { margin: 0; color: var(--ink-2); font-size: .94rem; }
.cal-stage { min-height: 80px; overflow-x: auto; padding: 6px 0; }
.cal-card { background: linear-gradient(135deg, #2f5fd8, #14213d); color: #fff; border-radius: 4%/6%; display: flex; flex-direction: column; justify-content: space-between; padding: 10px; font-size: .78rem; box-sizing: border-box; }
.cal-card .chip { width: 26px; height: 20px; border-radius: 4px; background: var(--yellow); }
.cal-coin { border-radius: 50%; background: radial-gradient(circle at 35% 35%, #f3f4f6, #9ca3af); border: 1px solid #6b7280; }
.cal-slider { display: flex; align-items: center; gap: 8px; }
.cal-slider input { flex: 1; accent-color: var(--ink); min-width: 0; }
.cal-slider output { font: 600 .9rem var(--mono); min-width: 84px; text-align: right; }
.cal-actions { display: flex; gap: 8px; }
.screen-stage { overflow: hidden; border-radius: 10px; }
.screen-ruler { position: relative; height: 132px; background: var(--yellow-soft); border: 1px solid #e9cf86; border-radius: 6px; touch-action: none; cursor: crosshair; user-select: none; }
.screen-ruler svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.screen-tool.vertical .screen-stage { display: flex; justify-content: center; }
.screen-tool.vertical .screen-ruler { width: 150px; height: min(78vh, 900px); }
.marker { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px solid #c81e1e; pointer-events: none; }
.marker span { position: absolute; top: 50%; left: -14px; transform: translateY(-50%); width: 26px; height: 26px; border-radius: 50%; background: #c81e1e; color: #fff; font: 700 .8rem var(--font); display: grid; place-items: center; }
.marker-a { border-color: #1f4fd1; }
.marker-a span { background: #1f4fd1; left: 3px; }
.marker-b span { left: -29px; }
.vertical .marker { left: 0; right: 0; top: auto; bottom: auto; height: 0; width: auto; border-left: 0; border-top: 2px solid #c81e1e; }
.vertical .marker-a { border-color: #1f4fd1; }
.vertical .marker span { top: -29px; left: 50%; transform: translateX(-50%); }
.vertical .marker-a span { top: 3px; left: 50%; }
.readout { margin: 0; font-size: 1.05rem; }
.readout strong { font-family: var(--mono); }

/* Help tooltips */
.field-head { display: flex; align-items: center; gap: 6px; }
.field-head label { font-weight: 600; }
.check-row { display: flex; align-items: center; gap: 6px; }
.tool-tips { margin: 0; font-size: .86rem; color: var(--ink-2); line-height: 1.9; }
.tip { position: relative; width: 22px; height: 22px; flex: 0 0 22px; border-radius: 50%; border: 1.5px solid var(--line-2); background: #fff; color: var(--ink-2); font: 700 .78rem/1 var(--font); cursor: help; padding: 0; display: inline-grid; place-items: center; vertical-align: middle; }
.tip:hover, .tip:focus-visible, .tip[aria-expanded="true"] { border-color: var(--ink); color: var(--ink); background: var(--yellow-soft); }
.tip-text { display: none; position: absolute; z-index: 30; top: calc(100% + 8px); left: 50%; width: max-content; max-width: min(280px, 86vw); transform: translateX(calc(-50% + var(--tip-shift, 0px))); background: var(--ink); color: #fff; font: 500 .84rem/1.45 var(--font); text-align: left; padding: 9px 11px; border-radius: 8px; box-shadow: var(--shadow); white-space: normal; cursor: auto; }
.tip:hover .tip-text, .tip:focus-visible .tip-text, .tip[aria-expanded="true"] .tip-text { display: block; }
.tip-demo { display: inline-grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line-2); font-size: .75rem; font-weight: 700; background: #fff; }

/* How-to guides */
.howto-jump { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 18px; }
.howto-jump a { background: #fff; border: 1px solid var(--line-2); border-radius: 999px; padding: 6px 12px; font-size: .9rem; font-weight: 600; color: var(--ink); text-decoration: none; }
.howto-jump a:hover { border-color: var(--ink); background: var(--yellow-soft); }
.guide { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; scroll-margin-top: 80px; }
.guide summary { cursor: pointer; padding: 14px 44px 14px 16px; font-weight: 700; list-style: none; position: relative; }
.guide summary::-webkit-details-marker { display: none; }
.guide summary::after { content: "+"; position: absolute; right: 16px; top: 10px; font-size: 1.4rem; color: var(--muted); }
.guide[open] summary::after { content: "–"; }
.guide > div { padding: 0 16px 8px; }
.guide .steps li { background: var(--bg); }

/* Online protractor */
.angle-tool { padding: 14px; display: grid; gap: 12px; }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ag-stage { position: relative; width: 100%; aspect-ratio: 16 / 10; max-height: 75vh; margin: 0 auto; background: #fbfcfd linear-gradient(#eef1f5 1px, transparent 1px) 0 0 / 24px 24px, linear-gradient(90deg, #eef1f5 1px, transparent 1px) 0 0 / 24px 24px; border: 1px solid var(--line); border-radius: 10px; touch-action: none; overflow: hidden; user-select: none; }
.ag-stage.has-photo { background: #000; }
.ag-stage img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.ag-stage svg { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; }
@media (max-width: 600px) { .ag-stage { aspect-ratio: 1 / 1; } }

/* Running total, trainer */
.total-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.trainer { padding: 16px; display: grid; gap: 12px; }
.rt-stage { background: #fff; border-radius: 10px; overflow: hidden; }
.rt-q { margin: 0; }
.rt-options { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.rt-options .is-right { background: #dcfce7; border-color: #15803d; color: #14532d; }
.rt-options .is-wrong { background: #fee2e2; border-color: #b91c1c; color: #7f1d1d; }
.trainer #rt-next { justify-self: start; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.diagram { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin: 1em 0; }
.diagram svg { display: block; width: 100%; height: auto; }

/* Converter */
.converter { padding: 18px; }
.conv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.converter .readout { margin-top: 14px; color: var(--ink-2); }

/* Ads: fixed reserved height so nothing below them moves when they load */
.ad-slot { margin: 24px auto; text-align: center; min-height: 280px; display: grid; align-content: start; }
.ad-slot--afterTool { min-height: 120px; }
.ad-slot--sidebar { min-height: 600px; position: sticky; top: 80px; }
.ad-label { font-size: .7rem; letter-spacing: .08em; text-transform: uppercase; color: #8a94a6; margin-bottom: 4px; }
@media (min-width: 720px) { .ad-slot--afterTool { min-height: 100px; } .ad-slot--inContent { min-height: 250px; } }

/* Content */
.content-grid > *, .print-tool > *, .screen-tool > * { min-width: 0; }
.content-grid { display: grid; gap: 32px; padding-top: 28px; padding-bottom: 16px; }
@media (min-width: 1100px) { .content-grid.with-sidebar { grid-template-columns: minmax(0, 1fr) 300px; } }
.prose { max-width: 760px; }
.prose h2 { font-size: 1.5rem; margin: 2.2em 0 .5em; }
.prose h2:first-child { margin-top: .3em; }
.prose h3 { font-size: 1.15rem; margin: 1.6em 0 .4em; }
.prose p, .prose li { color: #283449; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: .3em 0; }
.prose table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: .95rem; display: block; overflow-x: auto; }
.prose th, .prose td { text-align: left; padding: 8px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.prose th { background: var(--bg); font-weight: 700; }
.prose td.num, .prose th.num { text-align: right; font-family: var(--mono); }
.callout { border-left: 4px solid var(--yellow); background: var(--yellow-soft); padding: 12px 16px; border-radius: 0 10px 10px 0; margin: 1.2em 0; }
.callout p { margin: .3em 0; }
.steps { counter-reset: s; list-style: none; padding: 0 !important; display: grid; gap: 12px; }
.steps li { counter-increment: s; position: relative; padding: 12px 14px 12px 54px; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin: 0; }
.steps li::before { content: counter(s); position: absolute; left: 14px; top: 12px; width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; font-weight: 700; display: grid; place-items: center; font-size: .9rem; }
.usecases { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; padding: 0 !important; list-style: none; }
.usecases li { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin: 0; }
.usecases b { display: block; color: var(--ink); }
.faq { margin-top: 2.5em; }
.faq details { background: #fff; border: 1px solid var(--line); border-radius: 12px; margin: 10px 0; }
.faq summary { cursor: pointer; padding: 14px 16px; font-weight: 650; list-style: none; position: relative; padding-right: 44px; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; position: absolute; right: 16px; top: 10px; font-size: 1.4rem; color: var(--muted); }
.faq details[open] summary::after { content: "–"; }
.faq details > div { padding: 0 16px 14px; }
.faq details > div p { margin: .4em 0; }
.updated { color: var(--muted); font-size: .85rem; margin-top: 2em; }

/* Related tool cards */
.related { padding-top: 12px; padding-bottom: 40px; }
.related h2 { font-size: 1.3rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.card { display: flex; gap: 12px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px; text-decoration: none; color: var(--ink); transition: border-color .15s, box-shadow .15s; }
.card:hover { border-color: var(--ink); box-shadow: var(--shadow); }
.card-icon { flex: 0 0 40px; height: 40px; border-radius: 10px; background: var(--yellow-soft); display: grid; place-items: center; }
.card-icon svg { width: 24px; height: 24px; fill: none; stroke: var(--ink); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.card b { display: block; }
.card small { color: var(--muted); font-size: .86rem; line-height: 1.4; display: block; margin-top: 2px; }

/* Footer */
.site-footer { background: var(--ink); color: #c9d2e3; margin-top: 24px; }
.site-footer a { color: #fff; text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }
.site-footer .brand { color: #fff; }
.site-footer .brand-word i { color: #8a99b8; }
.footer-grid { display: grid; gap: 28px; padding-top: 40px; padding-bottom: 24px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.footer-about { grid-column: 1 / -1; max-width: 460px; }
.footer-about p { font-size: .92rem; }
@media (min-width: 900px) { .footer-grid { grid-template-columns: 1.6fr 1fr 1fr 1fr; } .footer-about { grid-column: auto; } }
.site-footer h2 { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--yellow); margin: 0 0 10px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: .94rem; }
.footer-bottom { border-top: 1px solid rgb(255 255 255 / .12); padding-top: 16px; padding-bottom: 28px; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; font-size: .84rem; }
.footer-bottom p { margin: 0; }
.site-footer .linklike { color: #fff; }

#print-root { display: none; }

/* Printing: on tool pages only the generated sheet is printed, at physical size. */
@media print {
  body.tool-print > *:not(#print-root) { display: none !important; }
  body.tool-print { margin: 0; background: #fff; }
  body.tool-print #print-root { display: block !important; }
  #print-root svg { display: block; }
  .site-header, .site-footer, .ad-slot, .related, .tool, .skip { display: none !important; }
  body { background: #fff; }
}
