/* onlinerulerfree.com — shared styles */
:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #efece4;
  --text: #1d1d1b;
  --muted: #5c5a54;
  --line: #d9d4c7;
  --accent: #d9480f;
  --accent-ink: #ffffff;
  --ruler: #ffd84d;
  --ruler-ink: #1d1d1b;
  --guide: #e03131;
  --focus: #1971c2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 16px rgba(0,0,0,.06);
  --max: 1080px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #16171a;
  --surface: #1f2125;
  --surface-2: #2a2d32;
  --text: #ecebe6;
  --muted: #a5a39b;
  --line: #3a3d44;
  --accent: #ff8a3d;
  --accent-ink: #16171a;
  --ruler: #2b2e34;
  --ruler-ink: #ffe066;
  --guide: #ff6b6b;
  --focus: #74c0fc;
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16171a;
    --surface: #1f2125;
    --surface-2: #2a2d32;
    --text: #ecebe6;
    --muted: #a5a39b;
    --line: #3a3d44;
    --accent: #ff8a3d;
    --accent-ink: #16171a;
    --ruler: #2b2e34;
    --ruler-ink: #ffe066;
    --guide: #ff6b6b;
    --focus: #74c0fc;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 16px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 8px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }

/* Header */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.site-header .wrap { display: flex; align-items: center; gap: 16px; min-height: 56px; flex-wrap: wrap; }
.brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 800; letter-spacing: -.01em; color: var(--text); text-decoration: none; font-size: 18px;
}
.brand svg { width: 28px; height: 28px; flex: none; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; margin-left: auto; }
.nav a {
  color: var(--muted); text-decoration: none; padding: 6px 10px; border-radius: 8px; font-size: 15px; font-weight: 500;
}
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }
.site-header .nav-toggle { display: none; margin-left: auto; }
@media (max-width: 760px) {
  .site-header .nav-toggle { display: inline-flex; }
  .nav { display: none; width: 100%; padding-bottom: 10px; margin-left: 0; }
  .nav.open { display: flex; }
}

.wrap { max-width: var(--max); margin: 0 auto; padding: 0 16px; }

/* Buttons and controls */
.btn, button.btn, select.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 38px; padding: 6px 12px;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn[aria-pressed="true"], .btn.on { background: var(--text); color: var(--bg); border-color: var(--text); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.05); }
.btn kbd { font: 11px/1 ui-monospace, monospace; opacity: .6; border: 1px solid currentColor; border-radius: 4px; padding: 2px 4px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.seg .btn { border: 0; border-radius: 0; }
.seg .btn + .btn { border-left: 1px solid var(--line); }
input[type="number"], input[type="text"], select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; min-height: 38px;
}
label { font-weight: 600; font-size: 14px; }

/* Tool area */
.tool {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
}
.toolbar {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px 16px; border-bottom: 1px solid var(--line);
}
.toolbar .spacer { flex: 1; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: #fff3bf; color: #5c4400;
}
.badge.ok { background: #d3f9d8; color: #1b5e20; }
:root[data-theme="dark"] .badge { background: #4a3b00; color: #ffe8a1; }
:root[data-theme="dark"] .badge.ok { background: #13361a; color: #b2f2bb; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge { background: #4a3b00; color: #ffe8a1; }
  :root:not([data-theme="light"]) .badge.ok { background: #13361a; color: #b2f2bb; }
}

.stage {
  position: relative; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  height: clamp(300px, 52vh, 560px);
  background:
    linear-gradient(var(--surface), var(--surface));
}
.stage.vertical { height: max(520px, 80vh); }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.readout {
  position: absolute; right: 16px; top: 98px; z-index: 3;
  font: 600 14px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 8px; padding: 6px 10px; pointer-events: none;
  text-align: right;
}
.readout strong { font-size: 22px; color: var(--accent); display: block; }
.hint {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2;
  max-width: 440px; text-align: center; color: var(--muted); font-size: 14px; pointer-events: none; padding: 0 16px;
}
.stage.vertical .hint { left: 60%; }
.stage:fullscreen { height: 100vh; background: var(--surface); }

/* Modal */
dialog {
  border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text);
  width: min(720px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(0,0,0,.45); }
.dlg-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.dlg-head h2 { margin: 0; font-size: 18px; }
.dlg-head .btn { margin-left: auto; }
.dlg-body { padding: 16px 18px 20px; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 14px; }
.tab-panel[hidden] { display: none; }
.calib-card-wrap { padding: 10px 0; overflow: hidden; }
.calib-card {
  position: relative; border-radius: 3.18mm; /* overwritten in px by JS */
  background: linear-gradient(135deg, #3b5bdb, #7048e8); color: #fff;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.4);
}
.calib-card .chip { position: absolute; left: 12%; top: 34%; width: 14%; height: 20%; border-radius: 6px; background: linear-gradient(135deg,#ffe066,#f59f00); }
.calib-card span { position: absolute; left: 10%; bottom: 12%; font: 600 13px ui-monospace, monospace; letter-spacing: .1em; opacity: .9; }
.calib-coin { border-radius: 50%; background: radial-gradient(circle at 35% 35%, #e9ecef, #868e96); margin: 10px 0; box-shadow: inset 0 0 0 2px rgba(0,0,0,.25); }
.slider-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 10px 0; }
.slider-row input[type="range"] { flex: 1; min-width: 180px; accent-color: var(--accent); }
.muted { color: var(--muted); }
.small { font-size: 14px; }

/* Content */
main.content { padding: 28px 0 48px; }
.content h1 { font-size: clamp(28px, 4vw, 40px); line-height: 1.15; letter-spacing: -.02em; margin: 0 0 10px; }
.content h2 { font-size: clamp(22px, 2.6vw, 28px); line-height: 1.25; margin: 40px 0 10px; letter-spacing: -.01em; }
.content h3 { font-size: 19px; margin: 24px 0 6px; }
.lede { font-size: 18px; color: var(--muted); max-width: 760px; margin-top: 0; }
.content p, .content li { max-width: 780px; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
a.card { color: inherit; text-decoration: none; display: block; }
a.card:hover { border-color: var(--accent); }
a.card .go { color: var(--accent); font-weight: 600; font-size: 14px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; max-width: 780px; background: var(--surface); font-size: 15px; }
th, td { padding: 8px 10px; border: 1px solid var(--line); text-align: left; }
th { background: var(--surface-2); }
details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 16px; margin: 10px 0; max-width: 820px; }
details summary { font-weight: 700; cursor: pointer; }
details p { margin-bottom: 0; }
.steps { counter-reset: s; list-style: none; padding: 0; }
.steps li { counter-increment: s; position: relative; padding-left: 40px; margin: 12px 0; }
.steps li::before {
  content: counter(s); position: absolute; left: 0; top: 0;
  width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-weight: 700; font-size: 14px;
}
.converter { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.converter div { display: flex; flex-direction: column; gap: 4px; }
.converter input { width: 140px; }
.ad-slot { margin: 24px auto; text-align: center; min-height: 0; }
.breadcrumb { font-size: 14px; color: var(--muted); margin-bottom: 8px; }
.breadcrumb a { color: var(--muted); }

/* Footer */
.site-footer { border-top: 1px solid var(--line); background: var(--surface); padding: 28px 0; font-size: 14px; color: var(--muted); }
.site-footer .cols { display: grid; gap: 20px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.site-footer h3 { font-size: 14px; color: var(--text); margin: 0 0 8px; }
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin: 4px 0; }
.site-footer a { color: var(--muted); }

/* Print generator */
.gen-controls { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); align-items: end; margin: 16px 0; }
.gen-controls > div { display: flex; flex-direction: column; gap: 4px; }
.preview {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; overflow: auto; max-height: 70vh;
}
.preview svg { background: #fff; box-shadow: var(--shadow); display: block; margin: 0 auto; width: 100%; height: auto; max-width: 680px; }
.print-area { display: none; }
@media print {
  @page { margin: 0; }
  body { background: #fff !important; }
  body > *:not(.print-area) { display: none !important; }
  .print-area { display: block !important; }
  .print-area svg { display: block; page-break-after: always; break-after: page; }
}

@media (max-width: 600px) {
  .toolbar { padding: 8px 12px; gap: 6px; }
  .toolbar .btn { min-height: 34px; padding: 4px 9px; font-size: 13px; }
  .toolbar .badge, .toolbar [data-calibrate] { order: -1; }
  .toolbar .spacer { display: none; }
  .btn kbd, .btn .lbl { display: none; }
  .readout { font-size: 12px; right: 8px; }
  .readout strong { font-size: 18px; }
}
@media (pointer: coarse) { #btnCross { display: none; } }
.theme-btn svg { width: 18px; height: 18px; }

/* Ring sizer, protractor, screen size */
.ring-tool { display: grid; gap: 20px; grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr); align-items: center; padding: 20px 16px; max-width: var(--max); margin: 0 auto; }
@media (max-width: 720px) { .ring-tool { grid-template-columns: 1fr; } }
.ring-pad { display: grid; place-items: center; min-height: 260px; background: var(--surface-2); border-radius: var(--radius); }
.ring-circle { border-radius: 50%; border: 2px solid var(--accent); background: radial-gradient(circle, rgba(217,72,15,.08), rgba(217,72,15,.18)); position: relative; }
.ring-circle::after { content: ""; position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px; border-radius: 50%; background: var(--accent); }
.ring-out { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.ring-out div { background: var(--surface-2); border-radius: 8px; padding: 8px 12px; }
.ring-out strong { display: block; font-size: 24px; line-height: 1.2; }
.prot-stage { position: relative; height: clamp(300px, 55vh, 520px); touch-action: none; user-select: none; }
.prot-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.prot-out { padding: 10px 16px; display: flex; gap: 14px; align-items: baseline; flex-wrap: wrap; }
.prot-out strong { font-size: 30px; color: var(--accent); }
.screen-table th { width: 40%; }
.check-box { display: inline-block; border: 2px solid var(--accent); vertical-align: middle; }
.stage.vertical .readout { right: auto; left: 50%; transform: translateX(-50%); top: 16px; }
.gen-controls > div[hidden] { display: none; }
.stage.vertical .readout { top: auto; bottom: 16px; }
