/* Quilting Calculators: warm quilt-studio look. System fonts only. */
:root {
  --linen: #faf6ee;
  --linen2: #f2ead9;
  --paper: #fffdf8;
  --ink: #2a2622;
  --muted: #5d554c;
  --line: #e0d4bd;
  --indigo: #2c3e6b;
  --indigo-d: #1f2d51;
  --rust: #b5482e;
  --rust-d: #8f3822;
  --mustard: #d9a43b;
  --sage: #7d9a7e;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --r: 14px;
  --shadow: 0 2px 10px rgba(42, 38, 34, 0.09);
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--linen);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
  overflow-x: hidden;
}

img, svg { max-width: 100%; }
[hidden] { display: none !important; }

a { color: var(--indigo); text-underline-offset: 2px; }
a:hover { color: var(--rust-d); }

:focus-visible {
  outline: 3px solid var(--rust);
  outline-offset: 2px;
  border-radius: 4px;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.skip {
  position: absolute;
  left: 8px;
  top: -60px;
  background: var(--indigo);
  color: #fff;
  padding: 10px 14px;
  border-radius: 8px;
  z-index: 100;
}
.skip:focus { top: 8px; }

.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }
main.wrap { padding-bottom: 40px; min-width: 0; }

/* ---------- header ---------- */
.site-head { background: var(--paper); border-bottom: 1px solid var(--line); }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); min-height: 44px; }
.brand .mark { width: 40px; height: 40px; flex: none; }
.brand-name { font: 700 1.25rem/1.1 var(--serif); letter-spacing: 0.01em; }

.nav-wide { display: none; }
.nav-wide a {
  color: var(--ink);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
}
.nav-wide a:hover { background: var(--linen2); }
.nav-wide a[aria-current="page"] { background: var(--indigo); color: #fff; }

.menu { position: relative; }
.menu summary {
  list-style: none;
  cursor: pointer;
  min-height: 44px;
  min-width: 44px;
  padding: 9px 16px;
  border: 1.5px solid var(--indigo);
  border-radius: 10px;
  color: var(--indigo);
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  background: var(--paper);
}
.menu summary::-webkit-details-marker { display: none; }
.menu[open] summary { background: var(--indigo); color: #fff; }
.menu nav {
  position: absolute;
  right: 0;
  top: 52px;
  z-index: 50;
  width: min(86vw, 340px);
  max-height: 75vh;
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: 0 8px 28px rgba(42, 38, 34, 0.22);
  padding: 8px 12px 14px;
}
.menu nav a { display: block; padding: 10px 6px; min-height: 44px; color: var(--ink); text-decoration: none; font-weight: 600; }
.menu nav a:hover, .menu nav a[aria-current="page"] { color: var(--indigo); text-decoration: underline; }
.menu-h { font: 700 0.8rem/1 var(--sans); text-transform: uppercase; letter-spacing: 0.08em; color: var(--rust-d); margin: 12px 6px 2px; }
.menu nav ul { list-style: none; margin: 0; padding: 0; }

.patch-strip {
  height: 12px;
  position: relative;
  background: repeating-linear-gradient(90deg, var(--indigo) 0 28px, var(--mustard) 28px 56px, var(--rust) 56px 84px, var(--sage) 84px 112px);
}
.patch-strip::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  border-top: 2px dashed rgba(250, 246, 238, 0.75);
}

/* ---------- typography ---------- */
h1, h2, h3 { font-family: var(--serif); color: var(--indigo-d); line-height: 1.2; }
h1 { font-size: 1.9rem; margin: 0.4em 0 0.35em; }
h2 { font-size: 1.45rem; margin: 1.6em 0 0.5em; padding-top: 0.2em; }
h3 { font-size: 1.1rem; margin: 1.2em 0 0.3em; }
p, ul, ol { margin: 0 0 1em; }
.lede { font-size: 1.1rem; color: #3d362f; max-width: 62ch; margin-bottom: 1.2em; }
section > p, section > ul, section > ol, section > h3 { max-width: 70ch; }
code { font-family: var(--mono); background: var(--linen2); padding: 1px 5px; border-radius: 4px; font-size: 0.92em; }
.reviewed { color: var(--muted); font-size: 0.92rem; margin-top: 0.8em; }

.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; padding: 0; margin: 14px 0 0; font-size: 0.92rem; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--line); }
.crumbs a { display: inline-block; padding: 8px 0; }

ol.steps, ol.plain { padding-left: 1.5em; max-width: 70ch; }
ol.steps li, ol.plain li { margin-bottom: 0.5em; padding-left: 0.2em; }
ol.steps li::marker { color: var(--rust); font-weight: 700; }

/* ---------- tool swatch ---------- */
.tool {
  position: relative;
  background: #fffefb;
  border: 1px solid var(--line);
  border-radius: var(--r);
  box-shadow: var(--shadow);
  padding: 20px 18px;
  margin: 0 0 20px;
  min-height: 140px;
}
.tool::before {
  content: "";
  position: absolute;
  inset: 6px;
  border: 1.5px dashed rgba(181, 72, 46, 0.35);
  border-radius: 9px;
  pointer-events: none;
}
.tool > * { position: relative; }
.tool-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.tool-title { font: 700 1.1rem/1.2 var(--serif); color: var(--indigo-d); margin: 0; }

.fields { display: grid; grid-template-columns: 1fr; gap: 12px 14px; }
.field { min-width: 0; }
.field label, .lbl { display: block; font-weight: 700; font-size: 0.93rem; margin-bottom: 4px; color: var(--ink); }
.inwrap { display: flex; align-items: center; gap: 8px; }
input.txt, select.sel {
  width: 100%;
  min-height: 48px;
  padding: 8px 12px;
  font: 1.1rem var(--sans);
  color: var(--ink);
  background: #fff;
  border: 1.5px solid #b9ab8f;
  border-radius: 10px;
}
select.sel { appearance: auto; }
input.txt:focus-visible, select.sel:focus-visible { border-color: var(--indigo); }
input.txt[aria-invalid="true"] { border-color: var(--rust); background: #fff6f3; }
.suffix { color: var(--muted); font-weight: 600; min-width: 2.2em; }
.hint { margin: 4px 0 0; font-size: 0.85rem; color: var(--muted); min-height: 1.2em; }
.hint.err { color: var(--rust-d); font-weight: 600; }

.seg { display: inline-flex; border: 1.5px solid var(--indigo); border-radius: 10px; overflow: hidden; background: #fff; }
.seg button {
  min-height: 44px;
  min-width: 56px;
  padding: 6px 14px;
  border: 0;
  background: transparent;
  color: var(--indigo);
  font: 700 0.95rem var(--sans);
  cursor: pointer;
}
.seg button + button { border-left: 1.5px solid var(--indigo); }
.seg button[aria-pressed="true"] { background: var(--indigo); color: #fff; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chipbtn {
  min-height: 44px;
  padding: 6px 14px;
  border: 1.5px solid var(--indigo);
  border-radius: 22px;
  background: #fff;
  color: var(--indigo);
  font: 600 0.92rem var(--sans);
  cursor: pointer;
}
.chipbtn[aria-pressed="true"] { background: var(--mustard); border-color: #8a6516; color: var(--ink); }

.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-weight: 600; cursor: pointer; }
.check input { width: 22px; height: 22px; accent-color: var(--indigo); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 8px 18px;
  border-radius: 10px;
  border: 1.5px solid var(--indigo);
  background: var(--indigo);
  color: #fff;
  font: 700 0.95rem var(--sans);
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { background: var(--indigo-d); color: #fff; }
.btn.ghost { background: #fff; color: var(--indigo); }
.btn.ghost:hover { background: var(--linen2); color: var(--indigo-d); }
.btn.danger { border-color: var(--rust); color: var(--rust-d); background: #fff; }
.btnrow, .actions, .tool-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 14px; }
.status { color: var(--muted); font-size: 0.9rem; }

/* ---------- results ---------- */
.result {
  margin-top: 16px;
  padding: 14px 16px;
  background: var(--linen);
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 90px;
}
.res-label { font: 700 0.8rem var(--sans); text-transform: uppercase; letter-spacing: 0.07em; color: var(--rust-d); margin: 0 0 2px; }
.big { font: 700 2.1rem/1.1 var(--serif); color: var(--indigo-d); margin: 2px 0; overflow-wrap: anywhere; }
.big.dash { color: var(--muted); }
.sub { color: var(--muted); margin: 0 0 10px; font-size: 0.97rem; }
.res-row { padding: 10px 0; border-top: 1px dashed var(--line); }
.res-row:first-child { border-top: 0; padding-top: 0; }
.formula {
  font: 0.88rem/1.5 var(--mono);
  background: #f4ecda;
  border-left: 4px solid var(--mustard);
  border-radius: 0 8px 8px 0;
  padding: 8px 12px;
  margin: 8px 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  color: #2f2a24;
}
.note { font-size: 0.93rem; color: var(--muted); margin: 8px 0 0; }
.callout { background: #fff6e0; border: 1px solid var(--mustard); border-radius: 10px; padding: 10px 12px; margin: 10px 0; font-size: 0.95rem; }
.callout.warn { background: #fdeee9; border-color: var(--rust); color: #5e2312; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 6px 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }
.lookup-list { list-style: none; margin: 8px 0; padding: 0; }
.lookup-list li { padding: 8px 0; border-top: 1px dashed var(--line); }
.lookup-list li:first-child { border-top: 0; }
.diagram { margin: 12px 0 4px; max-width: 360px; }
.diagram svg { width: 100%; height: auto; display: block; }
.diagram text { font: 11px var(--sans); }

/* ---------- tables ---------- */
.tablewrap { overflow-x: auto; max-width: 100%; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); margin: 12px 0 18px; }
.tablewrap.tall { max-height: 70vh; overflow: auto; }
.tablewrap:focus-visible { outline-offset: 0; }
table { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 0.95rem; }
caption { text-align: left; font-weight: 700; padding: 8px 12px; position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
th, td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
thead th { background: #ece3cf; color: var(--ink); border-bottom: 2px solid var(--indigo); white-space: nowrap; position: sticky; top: 0; z-index: 2; }
tbody tr:nth-child(odd) { --rowbg: #fffdf8; }
tbody tr:nth-child(even) { --rowbg: #f6f0e3; }
tbody tr { background: var(--rowbg); }
tbody th[scope="row"] { position: sticky; left: 0; background: var(--rowbg); z-index: 1; font-weight: 700; white-space: nowrap; box-shadow: 1px 0 0 var(--line); }
thead th:first-child { left: 0; z-index: 3; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
tr.hl { --rowbg: #fbe9b7; outline: 2px solid var(--mustard); outline-offset: -2px; }
tr.pick { --rowbg: #dde6f6; }
.cmp td, .cmp th { white-space: nowrap; }
.chart-table td { white-space: nowrap; }
.chart-table td:last-child { white-space: normal; min-width: 11em; }

/* ---------- hero, picker, cards ---------- */
.hero { display: grid; grid-template-columns: 1fr; gap: 6px 32px; align-items: start; }
.hero .tool { margin-top: 4px; }
.hero-tool h2 { margin-top: 18px; }
.more summary { cursor: pointer; color: var(--indigo); font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.more .formula { margin-top: 0; }
.picker ul { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; padding: 0; margin: 4px 0 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 16px;
  border: 1.5px solid var(--indigo);
  border-radius: 22px;
  background: var(--paper);
  color: var(--indigo);
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
}
.chip:hover { background: var(--indigo); color: #fff; }

.craft-grid { display: grid; gap: 18px; }
.craft h3 { margin: 0 0 8px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  min-height: 92px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-top: 6px solid var(--tab, var(--indigo));
  border-radius: 12px;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: var(--ink);
}
.card:hover { box-shadow: 0 4px 16px rgba(42, 38, 34, 0.18); }
.card strong { font: 700 1.05rem var(--serif); color: var(--indigo-d); }
.card span { color: var(--muted); font-size: 0.93rem; }
.craft[data-craft="quilting"] { --tab: var(--indigo); }
.craft[data-craft="crochetknitting"] { --tab: var(--rust); }
.craft[data-craft="crossstitch"] { --tab: var(--sage); }

/* ---------- faq, related ---------- */
.qa { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 4px 16px 6px; margin-bottom: 10px; max-width: 76ch; }
.qa h3 { margin: 0.7em 0 0.3em; font-size: 1.05rem; }
.qa p { margin-bottom: 0.7em; }
.relgrid { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 10px; }
.relgrid a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 8px 16px;
  background: var(--paper);
  border: 1.5px solid var(--sage);
  border-radius: 10px;
  font-weight: 700;
  text-decoration: none;
}
.relgrid a:hover { background: var(--sage); color: var(--ink); }
.backline { color: var(--muted); }

/* ---------- row counter ---------- */
.counters { display: grid; gap: 16px; grid-template-columns: 1fr; }
.ctr { position: relative; border: 1px solid var(--line); border-radius: 12px; background: #fff; padding: 14px; }
.ctr:focus-within { border-color: var(--indigo); box-shadow: 0 0 0 2px rgba(44, 62, 107, 0.25); }
.ctr-top { display: flex; gap: 8px; align-items: center; }
.ctr-top input.txt { font-weight: 700; }
.ctr-count { font: 700 4rem/1 var(--serif); text-align: center; color: var(--indigo-d); margin: 10px 0 4px; font-variant-numeric: tabular-nums; }
.ctr-info { text-align: center; color: var(--muted); font-size: 0.93rem; margin: 0 0 10px; min-height: 2.8em; }
.banner { background: var(--mustard); color: var(--ink); font-weight: 700; text-align: center; padding: 8px 10px; border-radius: 10px; margin-bottom: 10px; }
.ctr-btns { display: grid; gap: 10px; grid-template-columns: 1fr; }
.ctr-plus, .ctr-minus {
  min-height: 72px;
  font: 700 2.4rem/1 var(--sans);
  border-radius: 14px;
  border: 0;
  cursor: pointer;
  color: #fff;
  touch-action: manipulation;
}
.ctr-plus { background: var(--indigo); min-height: 88px; }
.ctr-plus:active { background: var(--indigo-d); }
.ctr-minus { background: var(--rust); min-height: 64px; }
.ctr-minus:active { background: var(--rust-d); }
.ctr-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-top: 12px; }
.ctr-tools .field { flex: 1 1 130px; }
.page-tools { margin-top: 16px; display: grid; gap: 4px; }

footer.site-foot { background: var(--paper); border-top: 0; margin-top: 30px; }
.site-foot .wrap { padding-top: 18px; padding-bottom: 28px; }
.foot-tag { font: 700 1.05rem var(--serif); color: var(--indigo-d); }
.foot-links { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-bottom: 12px; }
.foot-links a { display: inline-block; padding: 10px 0; }
.disclaimer { color: var(--muted); font-size: 0.88rem; max-width: 80ch; }

noscript .noscript { background: #fff6e0; padding: 10px; border-radius: 8px; }

/* ---------- wider screens ---------- */
@media (min-width: 480px) {
  .fields.two { grid-template-columns: 1fr 1fr; }
  .ctr-btns { grid-template-columns: 2fr 1fr; }
}

@media (min-width: 700px) {
  .fields.three { grid-template-columns: repeat(3, 1fr); }
  .counters { grid-template-columns: 1fr 1fr; }
  .craft-grid { grid-template-columns: 1fr; }
}

@media (min-width: 900px) {
  h1 { font-size: 2.4rem; }
  .menu { display: none; }
  .nav-wide { display: flex; flex-wrap: wrap; gap: 2px; padding-bottom: 8px; }
  .head-row { padding-bottom: 2px; }
  .hero { grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 6px 36px; }
  .hero-copy { padding-top: 24px; }
}

/* ---------- print ---------- */
@media print {
  body { background: #fff; color: #000; font-size: 11pt; }
  .site-head, .site-foot, .skip, .crumbs, .no-print, .actions, .tool-actions, .btnrow, .picker, .related, .faq, .backline, button, .menu, nav { display: none !important; }
  .tool { box-shadow: none; border: 1px solid #000; break-inside: avoid; }
  .tool::before { display: none; }
  .tablewrap, .tablewrap.tall { overflow: visible; max-height: none; border: 1px solid #000; }
  thead th, tbody th[scope="row"] { position: static; }
  tbody tr { background: #fff !important; }
  table { font-size: 9.5pt; }
  th, td { padding: 3px 6px; border-bottom: 1px solid #999; }
  a { color: #000; text-decoration: none; }
  h1 { font-size: 20pt; }
  body[data-print="chart"] main > *:not(.print-chart):not(h1) { display: none !important; }
  body[data-print="result"] main > *:not(.has-tool):not(.print-keep):not(h1) { display: none !important; }
  body[data-print="result"] main > .print-keep { display: block !important; }
  .hero { display: block; }
  .hero-copy .lede { display: none; }
  .formula { background: #fff; border: 1px solid #999; }
  .result { background: #fff; }
  section { break-inside: avoid; }
}
