/* GetRuler — light glass UI
   Motion rules: transform/opacity only, custom ease-out curves, < 300 ms for UI,
   no animation on keyboard-driven or high-frequency actions. */

:root {
  --bg: #f2f4f9;
  --ink: #0f1324;
  --ink-2: #434a61;
  --ink-3: #6b7290;
  --hairline: rgba(17, 22, 40, 0.08);
  --hairline-2: rgba(17, 22, 40, 0.14);
  --accent: #3452ff;
  --accent-ink: #2238d8;
  --accent-soft: rgba(52, 82, 255, 0.1);
  --ok: #0e9f5a;
  --info: #3452ff;
  --warn: #d97800;

  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.8);
  --glass-border: rgba(255, 255, 255, 0.85);
  --blur: blur(20px) saturate(170%);
  --shadow-sm: 0 1px 2px rgba(20, 28, 60, 0.06);
  --shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 0 0 1px rgba(17, 22, 40, 0.04),
    0 14px 34px -16px rgba(24, 34, 84, 0.24), 0 2px 6px -2px rgba(24, 34, 84, 0.08);
  --shadow-lg: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 0 0 1px rgba(17, 22, 40, 0.05),
    0 40px 90px -30px rgba(20, 28, 70, 0.4);

  --r-sm: 10px;
  --r: 16px;
  --r-lg: 24px;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --ease-drawer: cubic-bezier(0.32, 0.72, 0, 1);

  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI Variable Text", "Segoe UI", Inter, Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --header-h: 60px;
  --gutter: clamp(16px, 4vw, 32px);
  --maxw: 1160px;

  color-scheme: light;
  interpolate-size: allow-keywords;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scroll-padding-top: calc(var(--header-h) + 16px); }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: clip;
  min-height: 100svh;
}
img, svg, canvas { display: block; }
a { color: var(--accent-ink); text-underline-offset: 3px; text-decoration-thickness: 1px; }
button, input, select { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.skip {
  position: absolute; left: 12px; top: -48px; z-index: 100;
  padding: 10px 14px; border-radius: 10px; background: var(--ink); color: #fff; text-decoration: none;
}
.skip:focus { top: 12px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Backdrop: soft color fields + crisp orbs (they make the glass read) ---------- */
.backdrop {
  position: fixed; inset: 0; z-index: -2; pointer-events: none;
  background:
    radial-gradient(60vmax 45vmax at 0% -10%, #dde5ff 0%, transparent 62%),
    radial-gradient(50vmax 40vmax at 105% 0%, #fbe4ef 0%, transparent 58%),
    radial-gradient(60vmax 50vmax at 85% 110%, #dcf5ee 0%, transparent 62%),
    var(--bg);
}
.orbs { position: absolute; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; opacity: 0.6; }
.orb-1 { width: 360px; height: 360px; left: -90px; top: 120px; background: linear-gradient(135deg, #8fa3ff, #c9b6ff); }
.orb-2 { width: 230px; height: 230px; right: 9%; top: 40px; background: linear-gradient(160deg, #ffb6cf, #ffd9a6); opacity: 0.55; }
.orb-3 { width: 180px; height: 180px; left: 46%; top: 210px; background: linear-gradient(135deg, #95e6d6, #9ec8ff); opacity: 0.5; }
.orb-4 { width: 120px; height: 120px; left: 28%; top: 90px; background: linear-gradient(135deg, #ffe29a, #ffb38a); opacity: 0.45; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: var(--gutter); }

.glass, .panel {
  background: var(--glass);
  -webkit-backdrop-filter: var(--blur);
  backdrop-filter: var(--blur);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}
.panel { border-radius: var(--r-lg); }

/* ---------- Header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40; height: var(--header-h);
  background: rgba(247, 248, 252, 0.6);
  -webkit-backdrop-filter: blur(18px) saturate(180%);
  backdrop-filter: blur(18px) saturate(180%);
  border-bottom: 1px solid rgba(17, 22, 40, 0.06);
  box-shadow: inset 0 -1px 0 rgba(255, 255, 255, 0.6);
}
.header-inner { height: 100%; display: flex; align-items: center; gap: 12px; max-width: var(--maxw); margin: 0 auto; padding: 0 var(--gutter); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 720; letter-spacing: -0.02em; font-size: 17px; flex: none; }
.brand-mark { width: 30px; height: 30px; }
.nav {
  display: flex; gap: 2px; flex: 1; justify-content: center; min-width: 0;
  overflow-x: auto; scrollbar-width: none; -webkit-mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 12px, #000 calc(100% - 12px), transparent);
  padding-inline: 8px;
}
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex: none; padding: 7px 12px; border-radius: 999px; color: var(--ink-2); text-decoration: none;
  font-size: 14.5px; font-weight: 560; white-space: nowrap;
  transition: background-color 160ms ease, color 160ms ease;
}
.nav a[aria-current="page"], .nav a[aria-current="true"] { color: var(--ink); background: rgba(255, 255, 255, 0.85); box-shadow: 0 0 0 1px rgba(17, 22, 40, 0.06), 0 2px 6px -2px rgba(24, 34, 84, 0.18); }

.cal-pill {
  flex: none; display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 13px 0 11px;
  border-radius: 999px; border: 1px solid var(--hairline); background: rgba(255, 255, 255, 0.78);
  font-size: 13.5px; font-weight: 620; cursor: pointer; box-shadow: var(--shadow-sm);
  transition: transform 160ms var(--ease-out), background-color 160ms ease;
}
.cal-pill:active { transform: scale(0.97); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); box-shadow: 0 0 0 3px rgba(217, 120, 0, 0.18); flex: none; }
[data-state="ok"] .dot { background: var(--ok); box-shadow: 0 0 0 3px rgba(14, 159, 90, 0.18); }
[data-state="info"] .dot { background: var(--info); box-shadow: 0 0 0 3px rgba(52, 82, 255, 0.18); }

@media (hover: hover) and (pointer: fine) {
  .nav a:hover { background: rgba(17, 22, 40, 0.05); color: var(--ink); }
  .nav a[aria-current="page"]:hover { background: rgba(255, 255, 255, 0.95); }
  .cal-pill:hover { background: #fff; }
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 38px; padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--hairline); background: rgba(255, 255, 255, 0.72);
  color: var(--ink); font-size: 14px; font-weight: 620; line-height: 1; cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-sm); text-decoration: none; user-select: none;
  transition: transform 160ms var(--ease-out), background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}
.btn svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn:active:not(:disabled) { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn[aria-pressed="true"] { background: var(--accent-soft); border-color: rgba(52, 82, 255, 0.28); color: var(--accent-ink); }
.btn-primary {
  background: linear-gradient(180deg, #4a66ff, #2f48ef); color: #fff; border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), 0 8px 18px -8px rgba(52, 82, 255, 0.7);
}
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn-icon { width: 38px; padding: 0; }
.btn-sm { height: 32px; padding: 0 11px; font-size: 13px; border-radius: 10px; }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { background: #fff; border-color: var(--hairline-2); }
  .btn-primary:hover:not(:disabled) { background: linear-gradient(180deg, #5873ff, #3550f5); border-color: transparent; }
  .btn-ghost:hover:not(:disabled) { background: rgba(17, 22, 40, 0.05); border-color: transparent; }
  .btn[aria-pressed="true"]:hover { background: rgba(52, 82, 255, 0.14); }
}

/* ---------- Segmented control (clip-path overlay technique) ---------- */
.seg {
  position: relative; display: inline-grid; padding: 3px; border-radius: 12px;
  background: rgba(17, 22, 40, 0.055); box-shadow: inset 0 0 0 1px rgba(17, 22, 40, 0.04);
}
.seg-track { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; }
.seg-item {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 14px;
  border: 0; background: none; border-radius: 9px; font-size: 13.5px; font-weight: 620; color: var(--ink-2);
  cursor: pointer; white-space: nowrap;
}
.seg-item svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.seg-active {
  position: absolute; inset: 0; padding: 3px; pointer-events: none;
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--ink); border-radius: 12px;
  transition: clip-path 240ms var(--ease-out);
}
.seg-active .seg-item { color: #fff; }
.seg.is-instant .seg-active { transition: none; }
/* Before JS measures the control, style the checked option directly (no flash). */
.seg:not(.is-ready) .seg-active { visibility: hidden; }
.seg:not(.is-ready) .seg-track .seg-item[aria-checked="true"] { background: var(--ink); color: #fff; }

/* ---------- Tool: hero + ruler ---------- */
.tool { position: relative; isolation: isolate; --ruler-t: 136px; --lane: 46px; padding-bottom: 8px; }
.tool[data-units="cm"], .tool[data-units="in"] { --ruler-t: 108px; }
.tool-head { padding-top: clamp(20px, 4vw, 40px); }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; padding: 0; list-style: none; font-size: 13px; color: var(--ink-3); }
.crumbs li + li::before { content: "/"; margin-right: 6px; opacity: 0.5; }
.crumbs a { color: var(--ink-3); text-decoration: none; }
.crumbs a:hover { color: var(--ink); }
h1 {
  margin: 0; font-size: clamp(32px, 4.6vw, 52px); line-height: 1.04; letter-spacing: -0.038em; font-weight: 760;
  text-wrap: balance;
}
.h1-accent {
  background: linear-gradient(100deg, #3452ff 10%, #8b5cf6 70%, #d946ef);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.lede { margin: 14px 0 0; max-width: 64ch; font-size: clamp(16px, 1.6vw, 18px); color: var(--ink-2); text-wrap: pretty; }

.ruler-area { margin-top: clamp(20px, 3vw, 32px); }
.ruler {
  position: relative; height: var(--ruler-t); width: 100%;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.46) 48%, rgba(255, 255, 255, 0.64)),
    linear-gradient(90deg, rgba(210, 222, 255, 0.25), rgba(255, 255, 255, 0) 40%, rgba(230, 215, 255, 0.25));
  -webkit-backdrop-filter: blur(14px) saturate(170%);
  backdrop-filter: blur(14px) saturate(170%);
  border-block: 1px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 1px 0 rgba(17, 22, 40, 0.07), 0 -1px 0 rgba(17, 22, 40, 0.05), 0 22px 44px -26px rgba(28, 38, 94, 0.45),
    inset 0 1px 0 #fff, inset 0 -1px 0 rgba(255, 255, 255, 0.7);
  touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: crosshair; overflow: hidden;
}
.ruler::after { /* acrylic sheen */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(104deg, transparent 30%, rgba(255, 255, 255, 0.5) 42%, transparent 52%);
  opacity: 0.55;
}
.ruler-canvas { position: absolute; inset: 0; width: 100%; height: 100%; z-index: 1; }
.ruler-range {
  position: absolute; left: 0; top: 0; height: 100%; z-index: 0;
  background: linear-gradient(180deg, rgba(52, 82, 255, 0.07), rgba(52, 82, 255, 0.15) 50%, rgba(52, 82, 255, 0.07));
  will-change: transform;
}
.handle {
  position: absolute; left: 0; top: 0; z-index: 2; width: 44px; height: 100%; margin-left: -22px;
  display: grid; place-items: center; cursor: ew-resize; touch-action: none; outline: none; will-change: transform;
}
.handle.is-off { visibility: hidden; }
.handle-line { position: absolute; left: 50%; top: 0; bottom: 0; width: 1px; margin-left: -0.5px; background: var(--accent); box-shadow: 0 0 0 1px rgba(52, 82, 255, 0.12); }
.handle-knob {
  position: relative; width: 18px; height: 36px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.92); border: 1.5px solid var(--accent);
  box-shadow: 0 6px 14px -6px rgba(52, 82, 255, 0.7), 0 0 0 4px rgba(255, 255, 255, 0.5);
  transition: transform 160ms var(--ease-out), box-shadow 160ms ease;
}
.handle-knob::before { /* grip */
  content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 12px; transform: translate(-50%, -50%);
  background: linear-gradient(90deg, var(--accent) 0 1.5px, transparent 1.5px 4.5px, var(--accent) 4.5px 6px);
  opacity: 0.6;
}
.handle.is-active .handle-knob { transform: scale(1.08); }
.handle:focus-visible .handle-knob { box-shadow: 0 0 0 4px rgba(52, 82, 255, 0.28), 0 6px 14px -6px rgba(52, 82, 255, 0.7); }
.ruler.is-dragging, .ruler.is-dragging .handle { cursor: grabbing; }

.ruler-lane { position: relative; height: var(--lane); }
.lane-pill {
  position: absolute; left: 0; top: 8px; display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 11px; border-radius: 999px; white-space: nowrap;
  background: var(--ink); color: rgba(255, 255, 255, 0.72); font-size: 12.5px; font-weight: 560;
  font-variant-numeric: tabular-nums; box-shadow: 0 8px 18px -8px rgba(15, 19, 36, 0.6);
  will-change: transform; transition: opacity 160ms ease;
}
.lane-pill b { color: #fff; font-weight: 700; }
.lane-pill i { font-style: normal; }
.lane-pill::before { content: ""; position: absolute; left: 50%; top: -4px; width: 8px; height: 8px; margin-left: -4px; background: var(--ink); transform: rotate(45deg); border-radius: 2px; }
.pill-sep { width: 3px; height: 3px; border-radius: 50%; background: rgba(255, 255, 255, 0.4); margin: 0 4px; }
.lane-pill.is-hidden { opacity: 0; }

/* Controls panel */
.tool-controls { margin-top: 4px; }
.controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 18px 32px; padding: 20px 22px; align-items: center; }
.readout-label { font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); }
.readout-main {
  display: flex; align-items: baseline; gap: 8px; margin-top: 2px; white-space: nowrap;
  font-size: clamp(40px, 5.4vw, 60px); font-weight: 740; letter-spacing: -0.04em; line-height: 1.05;
  font-variant-numeric: tabular-nums;
}
.readout-main .unit { font-size: 0.42em; font-weight: 650; letter-spacing: -0.01em; color: var(--ink-3); }
.readout-sub { margin-top: 4px; font-size: 14.5px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.frac { display: inline-flex; align-items: center; font-size: 0.62em; letter-spacing: 0; margin-left: 0.06em; }
.frac sup, .frac sub { font-size: 0.78em; line-height: 1; vertical-align: 0; position: relative; }
.frac sup { top: -0.42em; }
.frac sub { top: 0.32em; }
.frac-slash { margin: 0 0.04em; opacity: 0.7; }
.frac-gap { display: inline-block; width: 0.12em; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; }
.toolbar-group { display: flex; gap: 6px; align-items: center; }
.extend { display: flex; align-items: center; gap: 6px; padding: 3px; border-radius: 12px; background: rgba(17, 22, 40, 0.045); }
.extend-text { min-width: 74px; text-align: center; font-size: 13px; font-weight: 620; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.extend .btn { height: 32px; width: 32px; border-radius: 9px; }

.controls-foot { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding-top: 14px; border-top: 1px solid var(--hairline); }
.kbd-hints { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 12.5px; color: var(--ink-3); }
kbd {
  display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 5px; margin-right: 4px;
  font: 600 11px/1 var(--mono); color: var(--ink-2); background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--hairline-2); border-bottom-width: 2px; border-radius: 6px;
}

.callout { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 14px; padding: 12px 14px 12px 12px; border-radius: 16px; background: rgba(255, 246, 232, 0.75); border: 1px solid rgba(217, 120, 0, 0.18); }
.callout[data-state="info"] { background: rgba(236, 240, 255, 0.8); border-color: rgba(52, 82, 255, 0.18); }
.callout[data-state="ok"] { background: rgba(232, 248, 239, 0.75); border-color: rgba(14, 159, 90, 0.18); }
.callout-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.8); flex: none; }
.callout-icon svg { width: 18px; height: 18px; fill: none; stroke: var(--warn); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.callout[data-state="info"] .callout-icon svg { stroke: var(--info); }
.callout[data-state="ok"] .callout-icon svg { stroke: var(--ok); }
.callout .btn { margin-left: auto; }
.callout-body { flex: 1 1 150px; min-width: 0; font-size: 13.5px; line-height: 1.45; color: var(--ink-2); }
.callout-body strong { display: block; color: var(--ink); font-size: 14px; }

/* Vertical orientation */
:root[data-orient="v"] .tool {
  --ruler-t: 124px; --lane: 58px;
  display: grid; grid-template-columns: var(--ruler-t) var(--lane) minmax(0, 1fr); grid-template-rows: auto 1fr;
  min-height: calc(100svh - var(--header-h)); padding-bottom: 0;
}
:root[data-orient="v"] .tool[data-units="cm"], :root[data-orient="v"] .tool[data-units="in"] { --ruler-t: 96px; }
:root[data-orient="v"] .ruler-area {
  grid-column: 1 / 3; grid-row: 1 / 3; align-self: start; margin: 0;
  position: sticky; top: var(--header-h); height: calc(100svh - var(--header-h));
  display: grid; grid-template-columns: var(--ruler-t) var(--lane);
}
:root[data-orient="v"] .ruler { height: 100%; width: var(--ruler-t); border-block: 0; border-inline: 1px solid rgba(255, 255, 255, 0.95); touch-action: pan-x;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0.46) 48%, rgba(255, 255, 255, 0.64)); }
:root[data-orient="v"] .ruler::after { background: linear-gradient(194deg, transparent 30%, rgba(255, 255, 255, 0.5) 42%, transparent 52%); }
:root[data-orient="v"] .ruler-range { width: 100%; height: 0; background: linear-gradient(90deg, rgba(52, 82, 255, 0.07), rgba(52, 82, 255, 0.15) 50%, rgba(52, 82, 255, 0.07)); }
:root[data-orient="v"] .handle { width: 100%; height: 44px; margin: -22px 0 0; cursor: ns-resize; }
:root[data-orient="v"] .handle-line { left: 0; right: 0; top: 50%; bottom: auto; width: auto; height: 1px; margin: -0.5px 0 0; }
:root[data-orient="v"] .handle-knob { width: 36px; height: 18px; }
:root[data-orient="v"] .handle-knob::before { width: 12px; height: 6px; background: linear-gradient(180deg, var(--accent) 0 1.5px, transparent 1.5px 4.5px, var(--accent) 4.5px 6px); }
:root[data-orient="v"] .ruler-lane { height: 100%; width: var(--lane); }
:root[data-orient="v"] .lane-pill { left: 6px; top: 0; flex-direction: column; gap: 0; padding: 7px 6px; border-radius: 12px; min-width: 46px; line-height: 1.15; }
:root[data-orient="v"] .lane-pill i { font-size: 10.5px; }
:root[data-orient="v"] .lane-pill::before { left: -4px; top: 50%; margin: -4px 0 0; }
:root[data-orient="v"] .tool .tool-head { grid-column: 3; grid-row: 1; margin: 0; max-width: 760px; padding: 24px var(--gutter) 0 12px; }
:root[data-orient="v"] .tool .tool-controls { grid-column: 3; grid-row: 2; margin: 0; max-width: 760px; padding: 16px var(--gutter) 24px 12px; }
:root[data-orient="v"] .tool .controls { grid-template-columns: 1fr; }
:root[data-orient="v"] .tool .toolbar { justify-content: flex-start; }
:root[data-orient="v"] .orbs .orb-1 { left: -120px; top: 40%; }
@media (max-width: 560px) {
  :root[data-orient="v"] .tool { --ruler-t: 106px; --lane: 54px; }
  :root[data-orient="v"] .tool[data-units="cm"], :root[data-orient="v"] .tool[data-units="in"] { --ruler-t: 84px; }
  :root[data-orient="v"] .tool h1 { font-size: 25px; }
  :root[data-orient="v"] .tool .lede { font-size: 14.5px; }
  :root[data-orient="v"] .tool .tool-head { padding: 16px 14px 0 4px; }
  :root[data-orient="v"] .tool .tool-controls { padding: 12px 12px 20px 4px; }
  :root[data-orient="v"] .tool .controls { padding: 16px 14px; }
  :root[data-orient="v"] .tool .btn-label { display: none; }
  :root[data-orient="v"] .tool .toolbar .btn:not(.btn-icon) { width: 38px; padding: 0; }
}

/* Focus mode: the ruler meets the edge of the screen */
.tool.is-focus {
  position: fixed; inset: 0; z-index: 60; overflow: auto; min-height: 0; height: 100dvh;
  background: radial-gradient(60vmax 45vmax at 0% -10%, #dde5ff 0%, transparent 62%), radial-gradient(60vmax 50vmax at 85% 110%, #dcf5ee 0%, transparent 62%), var(--bg);
}
.tool.is-focus .tool-head, .tool.is-focus .callout { display: none; }
:root[data-orient="h"] .tool.is-focus .ruler-area { margin-top: 0; }
:root[data-orient="v"] .tool.is-focus { grid-template-rows: 1fr; }
:root[data-orient="v"] .tool.is-focus .ruler-area { top: 0; height: 100dvh; }
:root[data-orient="v"] .tool.is-focus .tool-controls { grid-row: 1; align-self: center; }
body.has-focus { overflow: hidden; }
.tool:fullscreen { width: 100vw; height: 100vh; }
.tool::backdrop { background: var(--bg); }

/* ---------- Content ---------- */
.content { display: grid; gap: 20px; padding-block: 28px 64px; }
.section { padding: clamp(22px, 3.4vw, 40px); }
.section > :first-child { margin-top: 0; }
.section > :last-child { margin-bottom: 0; }
h2 { font-size: clamp(23px, 2.6vw, 30px); line-height: 1.15; letter-spacing: -0.028em; font-weight: 730; margin: 0 0 14px; text-wrap: balance; }
h3 { font-size: 18px; line-height: 1.3; letter-spacing: -0.015em; font-weight: 680; margin: 26px 0 8px; }
.section p, .section li { color: var(--ink-2); max-width: 74ch; }
.section p { margin: 0 0 14px; }
.section strong { color: var(--ink); font-weight: 650; }
.section ul, .section ol { padding-left: 20px; margin: 0 0 14px; }
.section li { margin: 6px 0; }
.section li::marker { color: var(--ink-3); }
.eyebrow { display: inline-block; margin-bottom: 8px; font-size: 12px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-ink); }

.steps { counter-reset: s; list-style: none; padding: 0 !important; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.steps li { counter-increment: s; margin: 0; padding: 16px 16px 16px 54px; position: relative; border-radius: var(--r); background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(17, 22, 40, 0.06); max-width: none; }
.steps li::before {
  content: counter(s); position: absolute; left: 14px; top: 14px; width: 28px; height: 28px; border-radius: 9px;
  display: grid; place-items: center; font-weight: 750; font-size: 14px; color: #fff;
  background: linear-gradient(180deg, #4a66ff, #2f48ef);
}
.steps strong { display: block; margin-bottom: 2px; }

.split { display: grid; gap: 28px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }

.table-wrap { overflow-x: auto; border-radius: var(--r); border: 1px solid rgba(17, 22, 40, 0.07); background: rgba(255, 255, 255, 0.55); margin: 8px 0 16px; }
table { width: 100%; border-collapse: collapse; font-size: 14.5px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid rgba(17, 22, 40, 0.06); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 680; background: rgba(255, 255, 255, 0.6); }
tbody tr:last-child td { border-bottom: 0; }
td:first-child { color: var(--ink); font-weight: 600; }
td { color: var(--ink-2); }
caption { caption-side: top; text-align: left; padding: 12px 14px 4px; font-weight: 650; color: var(--ink); }
.cols-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.link-card {
  display: block; padding: 18px; border-radius: var(--r); text-decoration: none; color: var(--ink);
  background: rgba(255, 255, 255, 0.62); border: 1px solid rgba(255, 255, 255, 0.9); box-shadow: var(--shadow);
  transition: transform 200ms var(--ease-out), background-color 200ms ease;
}
.link-card:active { transform: scale(0.98); }
.link-card-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; margin-bottom: 12px; background: var(--accent-soft); color: var(--accent-ink); }
.link-card-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.link-card strong { display: block; font-size: 16px; letter-spacing: -0.01em; }
.link-card span { display: block; margin-top: 4px; font-size: 14px; color: var(--ink-2); line-height: 1.45; }
@media (hover: hover) and (pointer: fine) {
  .link-card:hover { transform: translateY(-2px); background: rgba(255, 255, 255, 0.85); }
}

/* FAQ */
.faq { display: grid; gap: 8px; }
.faq details { border-radius: var(--r); background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(17, 22, 40, 0.06); }
.faq summary {
  list-style: none; cursor: pointer; padding: 15px 52px 15px 18px; position: relative;
  font-weight: 650; color: var(--ink); letter-spacing: -0.01em;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: ""; position: absolute; right: 18px; top: 50%; width: 12px; height: 12px; margin-top: -6px;
  background: linear-gradient(var(--ink-3), var(--ink-3)) center / 12px 1.8px no-repeat, linear-gradient(var(--ink-3), var(--ink-3)) center / 1.8px 12px no-repeat;
  transition: transform 220ms var(--ease-out);
}
.faq details[open] summary::after { transform: rotate(45deg); }
.faq details > div { padding: 0 18px 16px; }
.faq details > div p:last-child { margin-bottom: 0; }
.faq details::details-content { block-size: 0; overflow: clip; transition: block-size 260ms var(--ease-out), content-visibility 260ms allow-discrete; }
.faq details[open]::details-content { block-size: auto; }

/* ---------- Actual size ---------- */
.as-wrap { padding-block: 24px 8px; }
.as-layout { display: grid; gap: 16px; grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
.as-picker { padding: 14px; position: sticky; top: calc(var(--header-h) + 12px); max-height: calc(100svh - var(--header-h) - 24px); display: flex; flex-direction: column; }
.search { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.75); border: 1px solid var(--hairline); }
.search svg { width: 16px; height: 16px; fill: none; stroke: var(--ink-3); stroke-width: 2; stroke-linecap: round; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 14.5px; }
.as-list { overflow-y: auto; margin-top: 10px; padding-right: 2px; overscroll-behavior: contain; }
.as-group + .as-group { margin-top: 10px; }
.as-group h3 { margin: 6px 8px 4px; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); font-weight: 700; }
.as-item {
  display: flex; width: 100%; align-items: baseline; justify-content: space-between; gap: 10px;
  padding: 8px 10px; border: 0; border-radius: 10px; background: none; text-align: left; cursor: pointer;
  font-size: 14px; color: var(--ink); transition: background-color 140ms ease;
}
.as-item small { color: var(--ink-3); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.as-item[aria-pressed="true"] { background: var(--ink); color: #fff; }
.as-item[aria-pressed="true"] small { color: rgba(255, 255, 255, 0.6); }
@media (hover: hover) and (pointer: fine) { .as-item:hover:not([aria-pressed="true"]) { background: rgba(17, 22, 40, 0.05); } }

.as-main { padding: 0; overflow: hidden; }
.as-info { display: flex; flex-wrap: wrap; gap: 10px 20px; align-items: flex-start; justify-content: space-between; padding: 20px 22px 16px; border-bottom: 1px solid var(--hairline); }
.as-info h2 { margin: 0; font-size: 24px; }
.as-dims { margin: 4px 0 0; color: var(--ink-2); font-size: 14.5px; font-variant-numeric: tabular-nums; }
.as-note { margin: 6px 0 0; color: var(--ink-3); font-size: 13px; max-width: 70ch; }
.as-stage {
  position: relative; overflow: auto; min-height: 340px; padding: 56px 120px 40px 24px;
  background-image: radial-gradient(rgba(17, 22, 40, 0.09) 1px, transparent 1px); background-size: 16px 16px;
}
.as-figure { position: relative; display: inline-block; width: var(--w); height: var(--h); }
.as-svg { overflow: visible; filter: drop-shadow(0 10px 18px rgba(24, 34, 84, 0.18)) drop-shadow(0 1px 2px rgba(24, 34, 84, 0.12)); }
.dim { position: absolute; color: var(--accent-ink); font-size: 12px; font-weight: 650; font-variant-numeric: tabular-nums; white-space: nowrap; pointer-events: none; }
.dim-w { left: 0; right: 0; top: -26px; height: 10px; border-inline: 1px solid var(--accent); }
.dim-w::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; height: 1px; background: var(--accent); }
.dim-w > span { position: absolute; left: 50%; top: -14px; transform: translateX(-50%); padding: 0 6px; }
.dim-h { top: 0; bottom: 0; right: -26px; width: 10px; border-block: 1px solid var(--accent); }
.dim-h::before { content: ""; position: absolute; top: 0; bottom: 0; left: 50%; width: 1px; background: var(--accent); }
.dim-h > span { position: absolute; top: 50%; left: 18px; transform: translateY(-50%); }
.as-fit { margin: 0; padding: 10px 22px; font-size: 13px; color: var(--ink-2); background: rgba(236, 240, 255, 0.7); border-top: 1px solid var(--hairline); }
.as-custom { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; padding: 16px 22px 20px; border-top: 1px solid var(--hairline); }
.as-custom-title { width: 100%; margin: 0; font-size: 14px; font-weight: 680; }
.field { display: grid; gap: 4px; font-size: 12px; font-weight: 650; color: var(--ink-3); }
.input, .select {
  height: 38px; padding: 0 12px; border-radius: 11px; border: 1px solid var(--hairline-2); background: rgba(255, 255, 255, 0.85);
  font-size: 15px; color: var(--ink); outline: none; min-width: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
.input:focus, .select:focus { border-color: rgba(52, 82, 255, 0.6); box-shadow: 0 0 0 4px rgba(52, 82, 255, 0.14); }
.input[aria-invalid="true"] { border-color: rgba(217, 120, 0, 0.7); }
.input-num { width: 96px; font-variant-numeric: tabular-nums; }
.select { padding-right: 30px; appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b7290' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; background-size: 15px; }

/* ---------- Converter ---------- */
.conv { padding: clamp(18px, 3vw, 28px); display: grid; gap: 18px; }
.conv-input { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.conv-input .input { height: 54px; font-size: 26px; font-weight: 700; width: min(260px, 100%); letter-spacing: -0.02em; }
.conv-input .select { height: 54px; font-size: 17px; font-weight: 620; }
.conv-results { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.conv-cell { padding: 14px 16px; border-radius: var(--r); background: rgba(255, 255, 255, 0.62); border: 1px solid rgba(17, 22, 40, 0.06); min-width: 0; }
.conv-cell.is-primary { background: var(--ink); border-color: var(--ink); }
.conv-cell.is-primary .conv-num { color: #fff; }
.conv-cell.is-primary .conv-unit { color: rgba(255, 255, 255, 0.6); }
.conv-num { display: block; font-size: 24px; font-weight: 720; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.conv-unit { display: block; margin-top: 2px; font-size: 13px; color: var(--ink-3); }
.conv-track { position: relative; height: 56px; border-radius: 12px; background: rgba(255, 255, 255, 0.5); border: 1px dashed rgba(17, 22, 40, 0.14); overflow: hidden; }
.conv-bar {
  position: absolute; left: 0; top: 14px; height: 28px; border-radius: 0 8px 8px 0; display: flex; align-items: center; justify-content: flex-end; padding-right: 8px;
  background: linear-gradient(90deg, rgba(52, 82, 255, 0.85), rgba(139, 92, 246, 0.85)); color: #fff; font-size: 12px; font-weight: 700; white-space: nowrap;
  border-left: 2px solid var(--ink);
}
.conv-note { margin: 0; font-size: 13.5px; color: var(--ink-3); }

/* ---------- Ring sizer ---------- */
.ring-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); align-items: start; }
.ring-main { padding: 0 0 18px; overflow: hidden; display: grid; gap: 16px; }
.ring-stage {
  position: relative; height: 300px; display: grid; place-items: center; touch-action: none; cursor: crosshair;
  background-image: radial-gradient(rgba(17, 22, 40, 0.09) 1px, transparent 1px); background-size: 16px 16px;
  border-bottom: 1px solid var(--hairline);
}
.ring-circle {
  position: relative; border-radius: 50%; border: 1.5px solid var(--accent);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0 35%, rgba(52, 82, 255, 0.1) 100%);
  box-shadow: 0 0 0 6px rgba(52, 82, 255, 0.08), 0 14px 30px -14px rgba(52, 82, 255, 0.55);
}
.ring-circle::before, .ring-circle::after { content: ""; position: absolute; left: 50%; top: 50%; background: rgba(52, 82, 255, 0.55); }
.ring-circle::before { width: 14px; height: 1px; margin: -0.5px 0 0 -7px; }
.ring-circle::after { width: 1px; height: 14px; margin: -7px 0 0 -0.5px; }
.ring-handle {
  position: absolute; right: -15px; top: 50%; width: 30px; height: 30px; margin-top: -15px; border-radius: 50%;
  display: grid; place-items: center; background: var(--accent); border: 2px solid #fff; cursor: ew-resize; outline: none;
  box-shadow: 0 6px 14px -4px rgba(52, 82, 255, 0.7); transition: transform 160ms var(--ease-out);
}
.ring-handle svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.ring-handle:focus-visible { box-shadow: 0 0 0 4px rgba(52, 82, 255, 0.3); }
.ring-stage.is-dragging .ring-handle { transform: scale(1.1); }
.ring-chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.ring-side { padding: 20px 22px; display: grid; gap: 16px; }
.ring-big { display: flex; align-items: baseline; gap: 10px; font-size: clamp(52px, 7vw, 76px); font-weight: 760; letter-spacing: -0.045em; line-height: 1; font-variant-numeric: tabular-nums; }
.ring-big-label { font-size: 0.34em; font-weight: 700; letter-spacing: 0; color: var(--ink-3); }
.ring-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.ring-grid > div { padding: 10px 12px; border-radius: 12px; background: rgba(255, 255, 255, 0.62); border: 1px solid rgba(17, 22, 40, 0.06); }
.ring-grid .span-2 { grid-column: 1 / -1; }
.ring-grid dt { font-size: 12px; font-weight: 650; color: var(--ink-3); }
.ring-grid dd { margin: 2px 0 0; font-size: 18px; font-weight: 700; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; }
.ring-form { display: grid; gap: 10px; padding-top: 14px; border-top: 1px solid var(--hairline); }
.ring-form .seg { justify-self: start; }
.ring-form-row { display: flex; gap: 8px; }
@media (max-width: 860px) { .ring-layout { grid-template-columns: 1fr; } .ring-stage { height: 240px; } }

/* ---------- Printable ruler ---------- */
.pr-controls { padding-top: 22px; }
.pr-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 14px 16px; }
.pr-tip { display: flex; align-items: center; gap: 8px; margin: 0; flex: 1 1 260px; font-size: 14px; color: var(--ink-2); }
.pr-tip svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.pr-preview { position: relative; margin-top: 16px; overflow: hidden; }
.pr-sheet {
  position: absolute; left: 50%; top: 0; translate: -50% 0; transform-origin: top center;
  width: 210mm; height: 297mm; padding: 12mm; background: #fff; color: #111; overflow: hidden;
  display: flex; flex-direction: column; gap: 4.5mm; border-radius: 4px;
  box-shadow: 0 30px 70px -30px rgba(20, 28, 70, 0.45), 0 0 0 1px rgba(17, 22, 40, 0.06);
  font-family: Arial, Helvetica, sans-serif;
}
.pr-sheet[data-paper="letter"] { width: 215.9mm; height: 279.4mm; }
.pr-svg { flex: none; overflow: visible; }
.pr-sheet-head { display: flex; flex-direction: column; gap: 1mm; font-size: 3.6mm; }
.pr-sheet-head span { font-size: 2.8mm; color: #444; }
.pr-label { margin-top: 1mm; font-size: 2.8mm; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: #444; }
.pr-sheet-foot { margin-top: auto; font-size: 2.6mm; color: #666; }
@media print {
  .backdrop, .content, .pr-head, .pr-controls, .orbs, .zoom-note, .skip { display: none !important; }
  html, body { background: #fff !important; }
  main, .pr-section, .pr-section > .container { margin: 0 !important; padding: 0 !important; max-width: none !important; }
  .pr-preview { height: auto !important; margin: 0; overflow: visible; }
  .pr-sheet { position: static; translate: none; transform: none !important; box-shadow: none; border-radius: 0; break-after: avoid; }
}

/* ---------- Answers, converters, chips ---------- */
.answer { padding: clamp(18px, 3vw, 28px); display: grid; gap: 16px; }
.answer-main { font-size: clamp(30px, 5vw, 52px); font-weight: 740; letter-spacing: -0.035em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.answer-main span { color: var(--ink-3); font-weight: 650; }
.answer-sub { font-size: 16px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.answer-bar { display: grid; gap: 8px; }
.answer-bar .conv-note { margin: 0; }
.pager { display: flex; justify-content: space-between; gap: 8px; }
.chip-grid, .chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
a.chip { display: inline-flex; align-items: center; text-decoration: none; color: var(--ink); }
.chip-row { margin: 4px 0 8px; }

/* ---------- Diagrams ---------- */
.diagram { display: block; width: 100%; height: auto; max-height: 420px; margin: 14px 0 4px; }
.diagram-narrow { max-width: 340px; margin-inline: auto; }
.figure { margin: 0; }
.figure figcaption { margin-top: 6px; text-align: center; font-size: 13px; color: var(--ink-3); }

/* ---------- Calculators ---------- */
.calc-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
.calc-form, .calc-out { padding: 20px 22px; display: grid; gap: 14px; }
.field-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.calc-form .select { max-width: 100%; }
.calc-out .conv-note { margin: 0; }
.screen-stage { display: grid; place-items: center; min-height: 140px; padding: 12px; border-radius: 14px; background: rgba(255, 255, 255, 0.5); border: 1px dashed rgba(17, 22, 40, 0.12); overflow: hidden; }
.screen-outline {
  display: grid; place-items: center; border-radius: 6px; border: 3px solid #1f2430; color: rgba(255, 255, 255, 0.7); font-weight: 700;
  background: linear-gradient(135deg, #1e2a5a, #3452ff 60%, #8b5cf6); box-shadow: 0 14px 30px -14px rgba(30, 42, 90, 0.6);
}
.phones-row { display: flex; flex-wrap: nowrap; align-items: flex-end; gap: 22px; padding: 18px 4px 10px; overflow-x: auto; }
.phone-fig { margin: 0; display: grid; gap: 8px; justify-items: center; }
.phone-fig svg { filter: drop-shadow(0 12px 22px rgba(24, 34, 84, 0.25)); }
.phone-fig figcaption { display: grid; text-align: center; font-size: 13px; }
.phone-fig figcaption a { font-weight: 650; text-decoration: none; color: var(--ink); }
.phone-fig figcaption span { color: var(--ink-3); font-variant-numeric: tabular-nums; }
@media (max-width: 860px) { .calc-layout { grid-template-columns: 1fr; } }

/* ---------- Protractor ---------- */
.prot-panel { padding: 18px 20px; display: grid; gap: 14px; }
.prot-bar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.prot-stage { overflow: hidden; }
.prot-svg { display: block; margin: 0 auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.p-face { fill: rgba(255, 255, 255, 0.55); stroke: rgba(52, 82, 255, 0.35); stroke-width: 1.5; }
.p-tick { stroke: rgba(16, 19, 36, 0.55); stroke-width: 1; }
.p-major { stroke: rgba(16, 19, 36, 0.9); stroke-width: 1.4; }
.p-label { font: 600 11px var(--font); fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
.p-inner { font-size: 9.5px; fill: var(--ink-3); }
.p-center { fill: var(--accent); }
.p-arm { stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.p-arc { fill: rgba(52, 82, 255, 0.14); stroke: rgba(52, 82, 255, 0.5); stroke-width: 1; }
.p-knob { fill: #fff; stroke: var(--accent); stroke-width: 2.5; cursor: grab; outline: none; }
.p-knob:focus-visible { stroke-width: 4; }
.p-value { font: 750 15px var(--font); fill: var(--accent-ink); text-anchor: middle; dominant-baseline: central; }

/* ---------- Measure in a photo ---------- */
.m-layout { display: grid; gap: 16px; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.m-main { padding: 14px; display: grid; gap: 12px; }
.m-drop {
  display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 14px; cursor: pointer;
  border: 1.5px dashed rgba(52, 82, 255, 0.4); background: rgba(236, 240, 255, 0.5); font-size: 14.5px; color: var(--ink-2);
  transition: background-color 160ms ease, border-color 160ms ease;
}
.m-drop .link-card-icon { margin: 0; }
.m-drop.is-over { background: rgba(52, 82, 255, 0.12); border-color: var(--accent); }
.m-drop.has-image { padding: 10px 14px; }
.m-drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.m-stage { position: relative; line-height: 0; border-radius: 10px; overflow: hidden; background: #fff; }
.m-stage img { width: 100%; height: auto; display: block; user-select: none; -webkit-user-drag: none; }
.m-svg { position: absolute; inset: 0; width: 100%; height: 100%; cursor: crosshair; touch-action: none; }
.m-line { stroke: #3452ff; stroke-width: 2.5; vector-effect: non-scaling-stroke; }
.m-scale { stroke: #f59e0b; stroke-dasharray: 6 4; }
.m-angle { stroke: #8b5cf6; }
.m-pending { stroke-dasharray: 4 4; opacity: 0.6; }
.m-dot { fill: #fff; stroke: #0f1324; stroke-width: 2; vector-effect: non-scaling-stroke; cursor: grab; }
.m-label { font-family: var(--font); font-weight: 700; fill: #fff; stroke: #0f1324; stroke-width: 3px; paint-order: stroke; text-anchor: middle; }
.m-side { padding: 18px; display: grid; gap: 12px; position: sticky; top: calc(var(--header-h) + 12px); }
.m-side .seg { width: 100%; }
.m-scale-form, .m-side form { display: grid; gap: 8px; }
.m-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.m-list li { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.65); font-size: 14px; }
.m-list li strong { font-variant-numeric: tabular-nums; }
.m-list .m-empty { color: var(--ink-3); justify-content: center; }
@media (max-width: 900px) { .m-layout { grid-template-columns: 1fr; } .m-side { position: static; } }

/* ---------- Calibration dialog ---------- */
.cal-dialog {
  width: min(680px, calc(100vw - 20px)); max-width: none; max-height: calc(100dvh - 20px);
  margin: max(10px, 5vh) auto auto; padding: 0; border: 1px solid var(--glass-border); border-radius: 26px;
  background: rgba(249, 250, 254, 0.86); -webkit-backdrop-filter: blur(26px) saturate(180%); backdrop-filter: blur(26px) saturate(180%);
  box-shadow: var(--shadow-lg); color: var(--ink); overflow: auto; overscroll-behavior: contain;
  opacity: 0; transform: translateY(8px) scale(0.97);
  transition: opacity 150ms ease-out, transform 150ms var(--ease-out), overlay 150ms allow-discrete, display 150ms allow-discrete;
}
.cal-dialog[open] { opacity: 1; transform: none; transition-duration: 220ms; }
@starting-style { .cal-dialog[open] { opacity: 0; transform: translateY(8px) scale(0.97); } }
.cal-dialog::backdrop { background: rgba(20, 26, 50, 0); transition: background-color 150ms ease, overlay 150ms allow-discrete, display 150ms allow-discrete; }
.cal-dialog[open]::backdrop { background: rgba(20, 26, 50, 0.28); }
@starting-style { .cal-dialog[open]::backdrop { background: rgba(20, 26, 50, 0); } }
.cal-form { display: grid; gap: 16px; padding: 22px; margin: 0; }
.cal-head { display: flex; align-items: flex-start; gap: 12px; }
.cal-head h2 { margin: 0; font-size: 22px; }
.cal-head p { margin: 4px 0 0; color: var(--ink-2); font-size: 14.5px; }
.cal-head .btn { margin-left: auto; flex: none; }
.cal-dialog .seg { width: 100%; }
.cal-hint { margin: 0; font-size: 14px; color: var(--ink-2); }
.cal-stage {
  position: relative; padding: 20px; border-radius: 18px; touch-action: none; cursor: crosshair; overflow: hidden;
  background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(17, 22, 40, 0.06);
  background-image: linear-gradient(rgba(17, 22, 40, 0.05) 1px, transparent 1px), linear-gradient(90deg, rgba(17, 22, 40, 0.05) 1px, transparent 1px);
  background-size: 20px 20px; background-position: 19px 19px;
}
.cal-card {
  position: relative; border: 1.5px dashed var(--accent);
  background: linear-gradient(135deg, rgba(84, 104, 255, 0.16), rgba(139, 92, 246, 0.14));
}
.cal-card-chip { position: absolute; left: 10%; top: 36%; width: 12.8%; height: 16%; border-radius: 12%; background: linear-gradient(135deg, #fbe7a7, #c9952d); opacity: 0.8; }
.cal-card.is-portrait .cal-card-chip { left: 36%; top: 10%; width: 16%; height: 12.8%; }
.cal-coin { position: relative; border-radius: 50%; border: 1.5px dashed var(--accent); background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.9), rgba(52, 82, 255, 0.12)); }
.cal-handle {
  position: absolute; right: -15px; bottom: -15px; width: 30px; height: 30px; border-radius: 50%; padding: 0;
  border: 2px solid #fff; background: var(--accent); box-shadow: 0 6px 14px -4px rgba(52, 82, 255, 0.7); cursor: nwse-resize;
  display: grid; place-items: center;
  transition: transform 160ms var(--ease-out);
}
.cal-handle svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.cal-coin .cal-handle { right: -15px; bottom: auto; top: 50%; margin-top: -15px; cursor: ew-resize; }
.cal-stage.is-dragging .cal-handle { transform: scale(1.1); }
.cal-fine { display: flex; align-items: center; gap: 10px; }
.cal-value { min-width: 108px; text-align: right; font-size: 13px; font-weight: 650; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.range { flex: 1; min-width: 0; height: 28px; background: none; -webkit-appearance: none; appearance: none; }
.range::-webkit-slider-runnable-track { height: 6px; border-radius: 999px; background: rgba(17, 22, 40, 0.1); }
.range::-moz-range-track { height: 6px; border-radius: 999px; background: rgba(17, 22, 40, 0.1); }
.range::-webkit-slider-thumb { -webkit-appearance: none; width: 22px; height: 22px; margin-top: -8px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); box-shadow: 0 4px 10px -3px rgba(52, 82, 255, 0.6); }
.range::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: #fff; border: 2px solid var(--accent); }
.diag-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.diag-row .input { width: 110px; height: 44px; font-size: 20px; font-weight: 700; }
.chip { height: 32px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--hairline-2); background: rgba(255, 255, 255, 0.75); font-size: 13px; font-weight: 620; cursor: pointer; transition: transform 160ms var(--ease-out), background-color 160ms ease; }
.chip:active { transform: scale(0.96); }
@media (hover: hover) and (pointer: fine) { .chip:hover { background: #fff; } }
.cal-bar-wrap { padding: 18px 0 6px; }
.cal-bar { height: 10px; border-radius: 0 6px 6px 0; background: linear-gradient(90deg, #3452ff, #8b5cf6); border-left: 2px solid var(--ink); }
.cal-bar-label { margin-top: 6px; font-size: 12.5px; color: var(--ink-3); }
.cal-foot { display: flex; align-items: center; gap: 8px; padding-top: 4px; }
.cal-foot .spacer { flex: 1; }
.cal-tips { margin: 0; padding: 0 0 0 18px; font-size: 13px; color: var(--ink-3); }

/* ---------- Toast ---------- */
.toaster { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); z-index: 90; width: max-content; max-width: calc(100vw - 24px); transform: translateX(-50%); pointer-events: none; }
.toast {
  position: absolute; left: 50%; bottom: 0; translate: -50% 0;
  display: flex; align-items: center; gap: 10px; width: max-content; max-width: calc(100vw - 24px);
  padding: 10px 16px 10px 12px; border-radius: 14px; background: rgba(15, 19, 36, 0.92); color: #fff;
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  font-size: 14px; font-weight: 560; box-shadow: 0 16px 40px -12px rgba(15, 19, 36, 0.5);
  transition: transform 400ms ease, opacity 400ms ease;
}
@starting-style { .toast { transform: translateY(calc(100% + 24px)); opacity: 0; } }
.toast.is-leaving { transform: translateY(8px) scale(0.98); opacity: 0; transition-duration: 200ms; }
.toast-icon { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: rgba(255, 255, 255, 0.12); flex: none; }
.toast-icon svg { width: 14px; height: 14px; fill: none; stroke: #7ee2a8; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }
.toast-info .toast-icon svg { stroke: #9db0ff; }
.toast-warn .toast-icon svg { stroke: #ffc46b; }

.zoom-note {
  position: fixed; left: 12px; right: 12px; top: calc(var(--header-h) + 8px); z-index: 45; margin: 0 auto; max-width: 520px;
  padding: 10px 14px; border-radius: 14px; font-size: 14px; text-align: center; color: var(--ink);
  background: rgba(255, 246, 232, 0.92); border: 1px solid rgba(217, 120, 0, 0.25); box-shadow: var(--shadow);
}

/* ---------- Cookie consent ---------- */
.consent {
  position: fixed; left: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 80; width: min(420px, calc(100vw - 32px));
  display: grid; gap: 12px; padding: 16px; border-radius: 18px;
  background: rgba(255, 255, 255, 0.86); -webkit-backdrop-filter: blur(20px) saturate(170%); backdrop-filter: blur(20px) saturate(170%);
  border: 1px solid var(--glass-border); box-shadow: var(--shadow-lg);
  transition: opacity 300ms var(--ease-out), transform 300ms var(--ease-out);
}
@starting-style { .consent { opacity: 0; transform: translateY(12px); } }
.consent.is-leaving { opacity: 0; transform: translateY(8px); transition-duration: 200ms; }
.consent p { margin: 0; font-size: 14px; line-height: 1.5; color: var(--ink-2); }
.consent strong { color: var(--ink); }
.consent-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media print { .consent { display: none !important; } }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid rgba(17, 22, 40, 0.06); background: rgba(255, 255, 255, 0.4); -webkit-backdrop-filter: blur(16px); backdrop-filter: blur(16px); }
.footer-inner { display: grid; gap: 28px; grid-template-columns: 1.3fr repeat(4, 1fr); padding-block: 40px; }
.footer-inner p { margin: 10px 0 0; color: var(--ink-3); font-size: 14px; max-width: 42ch; }
.footer-col h2 { font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-3); margin: 4px 0 10px; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.footer-col a { color: var(--ink-2); text-decoration: none; font-size: 14.5px; }
.footer-col a:hover { color: var(--ink); text-decoration: underline; }
.footer-bottom { padding-block: 0 28px; font-size: 13px; color: var(--ink-3); }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .as-layout { grid-template-columns: 1fr; }
  .as-picker { position: static; max-height: none; }
  .as-list { max-height: 260px; }
}
@media (max-width: 1040px) {
  .controls { grid-template-columns: 1fr; }
  .toolbar { justify-content: flex-start; }
}
@media (max-width: 760px) {
  .footer-inner { grid-template-columns: 1fr 1fr; }
  .footer-inner > :first-child { grid-column: 1 / -1; }
}
@media (max-width: 560px) {
  :root { --header-h: 56px; }
  .brand-name { display: none; }
  .nav { justify-content: flex-start; }
  .nav a { padding: 7px 10px; font-size: 14px; }
  .cal-pill { padding: 0 11px 0 10px; }
  .as-stage { padding: 52px 96px 32px 16px; }
  .cal-form { padding: 16px; gap: 14px; }
  .cal-stage { padding: 16px; }
  .btn-label-opt { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0ms !important; animation-duration: 0ms !important; scroll-behavior: auto !important; }
  .cal-dialog, .cal-dialog[open], .toast { transition: opacity 150ms ease !important; transform: none !important; }
}

@media print {
  .site-header, .site-footer, .tool, .toaster { display: none !important; }
  .panel { box-shadow: none; background: #fff; }
}
