/* RulerGrid P0-P2 polish: preserve the existing blue editorial theme while
   giving every tool, guide and result a predictable rhythm. */
:root { --ruler-font: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Palatino, serif; --content-max: 1240px; }
/* The RulerGrid editorial face is a product decision, not a component hint.
   Keep legacy tool styles from silently reintroducing a second font. */
body.ruler-product-body, body.ruler-product-body * { font-family: var(--ruler-font) !important; }
body.ruler-product-body { letter-spacing: .006em; }
.tool-app-intro { margin-bottom: 28px; }
.tool-app-intro h1 { max-width: 980px; font-size: clamp(34px, 4.4vw, 56px); line-height: 1.06; }
.tool-app-intro > div > p:last-child { max-width: 760px; line-height: 1.65; }
.tool-workspace { width: 100%; max-width: none; }
.tool-workbench.has-visual { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px; align-items: stretch; }
.tool-workbench.has-visual .tool-form-area, .tool-workbench.has-visual .tool-visual-panel { min-height: 520px; }
.tool-workbench.has-visual .tool-form-area { display: flex; flex-direction: column; padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: color-mix(in srgb, var(--panel) 92%, var(--accent-soft)); }
.tool-workbench.has-visual .tool-visual-panel { display: flex; flex-direction: column; justify-content: center; padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.tool-workbench.has-visual .tool-form-area > .tool-result { margin-top: auto; }
.tool-form { gap: 18px; }
.tool-field { gap: 8px; }
.tool-field span { color: var(--ink); font-size: 13px; }
.tool-field input, .tool-field select { min-height: 48px; padding: 12px 14px; border-radius: 11px; background: color-mix(in srgb, var(--bg) 88%, var(--panel)); }
.tool-field input:focus, .tool-field select:focus { outline: 3px solid color-mix(in srgb, var(--accent) 24%, transparent); outline-offset: 1px; border-color: var(--accent); }
.tool-form .primary-button { min-height: 48px; }
.tool-result { margin-top: 22px; padding: 18px; min-height: 70px; border: 1px solid color-mix(in srgb, var(--accent) 10%, var(--line)); border-radius: 13px; }
/* Keep the summary banner visually separate from the result-card row. */
.tool-form-area > .advanced-results + .tool-result,
.tool-form-area > .circle-results + .tool-result,
.tool-form-area > [data-screen-results] + .tool-result,
.tool-form-area > [data-ring-results] + .tool-result,
.tool-form-area > [data-fraction-results] + .tool-result,
.tool-form-area > [data-pd-results] + .tool-result,
.tool-form-area > [data-digital-results] + .tool-result,
.tool-form-area > [data-architectural-results] + .tool-result {
    margin-top: 28px !important;
}
.tool-formula { margin-top: 14px; line-height: 1.65; }
.tool-utility-actions { display: flex; gap: 9px; flex-wrap: wrap; margin-top: 16px; }
.tool-utility-actions .secondary-button { min-height: 40px; padding: 8px 12px; }
.tool-utility-actions .icon-svg { width: 16px; height: 16px; }
.tool-copy-toast { min-height: 22px; margin-top: 8px; color: var(--success); font-size: 12px; opacity: 0; transition: opacity .18s ease; }
.tool-copy-toast.is-visible { opacity: 1; }
.result-card { position: relative; padding-right: 44px; }
.result-copy { position: absolute; top: 12px; right: 12px; display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--muted); cursor: pointer; }
.result-copy:hover, .result-copy.is-copied { color: var(--accent); border-color: var(--accent); background: var(--accent-soft); }
.result-copy svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tool-unit-shortcuts { display: flex; gap: 6px; flex-wrap: wrap; margin: 5px 0 7px; }
.tool-unit-shortcuts button { min-height: 32px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); color: var(--muted); cursor: pointer; font-size: 12px; }
.tool-unit-shortcuts button[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 700; }
.editorial-page { max-width: 1060px; padding-top: 54px; }
.editorial-hero { max-width: 900px; margin-bottom: 42px; }
.editorial-hero h1 { max-width: 900px; margin: 0 0 17px; font-size: clamp(38px, 5vw, 62px); line-height: 1.04; letter-spacing: -.045em; }
.editorial-hero > p:not(.eyebrow) { max-width: 780px; margin: 0; color: var(--muted); font-size: 17px; line-height: 1.72; }
.guide-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 24px; }
.guide-actions .icon-svg { width: 17px; height: 17px; }
.guide-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.guide-card { position: relative; display: flex; min-height: 210px; flex-direction: column; align-items: flex-start; padding: 25px; border: 1px solid var(--line); border-radius: 17px; background: var(--panel); color: var(--ink); text-decoration: none; box-shadow: 0 12px 28px rgba(31,52,95,.05); transition: border-color .18s ease, box-shadow .18s ease, background .18s ease; }
.guide-card:hover { border-color: var(--accent); background: color-mix(in srgb, var(--panel) 92%, var(--accent-soft)); box-shadow: 0 16px 32px rgba(31,52,95,.09); }
.guide-card .guide-icon { display: grid; place-items: center; width: 46px; height: 46px; margin-bottom: 18px; border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line)); border-radius: 13px; background: linear-gradient(145deg, var(--accent-soft), var(--panel)); color: var(--accent); transition: transform .18s ease, background .18s ease, color .18s ease, border-color .18s ease; }
.guide-card .guide-icon .icon-svg { width: 23px; height: 23px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.guide-card:hover .guide-icon, .guide-card:focus-visible .guide-icon { transform: translateY(-2px); border-color: var(--accent); background: var(--accent); color: #fff; }
.guide-card .eyebrow { margin-bottom: 7px; }
.guide-card h2 { max-width: 460px; margin: 0 0 9px; font-size: 23px; line-height: 1.16; letter-spacing: -.025em; }
.guide-card p { max-width: 470px; margin: 0; color: var(--muted); line-height: 1.62; }
.guide-card > b { position: absolute; right: 22px; bottom: 20px; display: grid; place-items: center; width: 30px; height: 30px; color: var(--accent); }
.guide-card > b .icon-svg { width: 21px; height: 21px; }
.guide-faq { max-width: none; margin-top: 58px; padding-top: 30px; }
.guide-faq h2 { font-size: 32px; }
.guide-detail-hero { max-width: 950px; }
.guide-article { max-width: 900px; padding: 30px 0; border-top: 1px solid var(--line); }
.guide-article section { margin: 0 0 42px; }
.guide-article section:last-child { margin-bottom: 0; }
.guide-article h2 { margin: 0 0 10px; font-size: 29px; line-height: 1.18; }
.guide-article section > p:last-child { margin: 0; color: var(--muted); font-size: 16px; line-height: 1.85; }
.guide-article-rich { max-width: 980px; }
.guide-article-rich > section { padding: 24px 0; border-bottom: 1px solid var(--line); }
.guide-article-rich > section:first-child { padding-top: 0; }
.guide-article-rich h2 { max-width: 760px; }
.guide-answer { padding: 24px 26px !important; border: 1px solid color-mix(in srgb, var(--accent) 22%, var(--line)) !important; border-radius: 16px; background: color-mix(in srgb, var(--accent-soft) 58%, var(--panel)); }
.guide-answer p:last-child { color: var(--ink) !important; }
.guide-steps ol { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; counter-reset: guide-step; }
.guide-steps li { display: grid; grid-template-columns: 32px minmax(0, 1fr); align-items: start; gap: 12px; color: var(--muted); line-height: 1.7; }
.guide-step-number { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--accent); color: #fff; font-size: 13px; font-weight: 700; }
.guide-mistakes ul { display: grid; gap: 9px; margin: 0; padding-left: 22px; color: var(--muted); line-height: 1.7; }
.guide-example { background: color-mix(in srgb, var(--panel) 78%, var(--accent-soft)); }
.guide-example .guide-audit-note { margin-top: 14px !important; padding-top: 14px; border-top: 1px dashed var(--line); font-size: 14px !important; }
.guide-context { background: var(--panel); }
.guide-sources > p:last-of-type { margin-bottom: 17px; }
.guide-sources ul { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.guide-sources li { display: grid; gap: 3px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.guide-sources a { color: var(--ink); font-weight: 700; text-decoration: underline; text-decoration-color: color-mix(in srgb, var(--accent) 50%, transparent); text-underline-offset: 3px; }
.guide-sources li span { color: var(--muted); font-size: 14px; line-height: 1.55; }
.guide-next { margin-top: 48px; padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: var(--accent-soft); }
.guide-next h2 { margin: 0 0 8px; font-size: 26px; }
.guide-next p:not(.eyebrow) { max-width: 720px; margin: 0 0 20px; color: var(--muted); line-height: 1.7; }
.guide-related { display: grid; gap: 18px; margin-top: 48px; padding-top: 30px; border-top: 1px solid var(--line); }
.guide-related h2 { margin: 0; font-size: 28px; }
.guide-related-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.guide-related-card { display: flex; min-height: 66px; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 700; transition: border-color .18s ease, transform .18s ease; }
.guide-related-card:hover, .guide-related-card:focus-visible { border-color: var(--accent); transform: translateY(-2px); }
.guide-related-card .icon-svg { flex: 0 0 auto; width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.faq-page-list { margin-top: 0; }
.ruler-footer { max-width: var(--content-max); border-top: 1px solid var(--line); }
.ruler-footer .footer-links { display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.ruler-footer a { color: var(--muted); }
.ruler-footer a:hover { color: var(--accent); }
.calibration-methods { flex-wrap: wrap; }
.calibration-methods button { min-height: 40px; }
html[data-theme="dark"] .guide-card, html[data-theme="dark"] .tool-workbench.has-visual .tool-form-area, html[data-theme="dark"] .tool-workbench.has-visual .tool-visual-panel, html[data-theme="dark"] .result-copy { background: var(--panel); }
html[data-theme="dark"] .guide-next, html[data-theme="dark"] .guide-answer { background: var(--accent-soft); }

/* Keep the verification panel in document flow. The ruler canvas still fills
   the first viewport, but the extra trust content must push the SEO intro
   down instead of covering it. */
body.ruler-product-body.ruler-home-page .ruler-product-app {
    height: auto;
    min-height: calc(100vh - var(--ruler-nav-height));
}

body.ruler-product-body.ruler-home-page .ruler-product-app > .product-stage {
    height: calc(100vh - var(--ruler-nav-height));
}

/* Guide detail pages use a readable editorial measure with visible breathing
   room around each answer, example and troubleshooting block. */
body.ruler-product-body.info-page .editorial-page {
    width: min(100% - 48px, 1060px);
    max-width: 1060px;
    margin-inline: auto;
    padding-inline: 0;
}

body.ruler-product-body.info-page .guide-detail-hero {
    margin-bottom: 48px;
}

body.ruler-product-body.info-page .guide-article-rich,
body.ruler-product-body.info-page .guide-faq,
body.ruler-product-body.info-page .guide-related,
body.ruler-product-body.info-page .guide-next {
    width: min(100%, 940px);
    max-width: 940px;
    margin-inline: auto;
}

body.ruler-product-body.info-page .guide-article-rich {
    padding-top: 36px;
}

body.ruler-product-body.info-page .guide-article-rich > section {
    margin: 0 0 24px;
    padding: 28px 30px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: color-mix(in srgb, var(--panel) 92%, var(--bg));
}

body.ruler-product-body.info-page .guide-article-rich > section:first-child {
    padding-top: 28px;
}

body.ruler-product-body.info-page .guide-article-rich > section:last-child {
    margin-bottom: 0;
}

body.ruler-product-body.info-page .guide-article-rich > .guide-answer,
body.ruler-product-body.info-page .guide-article-rich > .guide-example,
body.ruler-product-body.info-page .guide-article-rich > .guide-context {
    background: color-mix(in srgb, var(--accent-soft) 48%, var(--panel));
}

/* Every action arrow is an outline icon. Explicit fill/stroke values prevent
   a generic SVG rule from turning the path into a giant black shape. */
body.ruler-product-body .guide-actions .icon-svg,
body.ruler-product-body .guide-next .icon-svg,
body.ruler-product-body .guide-related-card .icon-svg,
body.ruler-product-body .guide-card > b .icon-svg {
    display: block;
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    fill: none !important;
    stroke: currentColor !important;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

body.ruler-product-body .guide-actions a,
body.ruler-product-body .guide-next a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

@media (max-width: 820px) { .tool-workbench.has-visual { grid-template-columns: 1fr; } .tool-workbench.has-visual .tool-form-area, .tool-workbench.has-visual .tool-visual-panel { min-height: 0; } .tool-workbench.has-visual .tool-visual-panel { min-height: 360px; } }
@media (max-width: 900px) { .guide-related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) {
    body.ruler-product-body.ruler-home-page .ruler-product-app {
        min-height: calc(100vh - 60px);
    }

    body.ruler-product-body.ruler-home-page .ruler-product-app > .product-stage {
        height: calc(100vh - 60px);
    }
}

@media (max-width: 650px) {
    .tool-app-intro { margin-bottom: 20px; }
    .tool-app-intro h1 { font-size: 36px; }
    .tool-workbench.has-visual .tool-form-area, .tool-workbench.has-visual .tool-visual-panel { padding: 17px; border-radius: 14px; }
    .guide-grid { grid-template-columns: 1fr; gap: 12px; }
    .editorial-page { padding-top: 30px; }
    .editorial-hero { margin-bottom: 28px; }
    .editorial-hero h1 { font-size: 40px; }
    .editorial-hero > p:not(.eyebrow) { font-size: 16px; }
    .guide-card { min-height: 190px; padding: 20px; }
    .guide-card h2 { font-size: 21px; }
    .guide-article h2 { font-size: 25px; }
    .guide-article section > p:last-child { font-size: 15px; line-height: 1.75; }
    body.ruler-product-body.info-page .editorial-page { width: min(100% - 32px, 1060px); }
    body.ruler-product-body.info-page .guide-detail-hero { margin-bottom: 32px; }
    body.ruler-product-body.info-page .guide-article-rich { padding-top: 24px; }
    body.ruler-product-body.info-page .guide-article-rich > section { margin-bottom: 18px; padding: 21px 20px; border-radius: 14px; }
    .guide-answer { padding: 20px !important; }
    .guide-related-grid { grid-template-columns: 1fr; }
    .guide-next { padding: 21px; }
    .ruler-footer .footer-links { justify-content: flex-start; margin-top: 16px; }
}
@media (max-width: 420px) { .tool-utility-actions .secondary-button { flex: 1 1 100%; justify-content: center; } .calibration-methods { gap: 0; } .calibration-methods button { padding-left: 7px; padding-right: 7px; font-size: 11px; } }
@media print { .tool-utility-actions, .tool-copy-toast, .ruler-product-header, .ruler-footer, .guide-actions { display: none !important; } }

/* Trust layer for the calibrated ruler: show the two physical checks only
   after a saved calibration, and keep the measurement log compact on mobile. */
.calibration-verification,
.measurement-history {
    margin: 14px 0 0;
    padding: 16px 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: color-mix(in srgb, var(--accent-soft) 42%, var(--panel));
}

.calibration-verification[hidden],
.measurement-history[hidden] {
    display: none;
}

.calibration-verification-head,
.measurement-history-head {
    display: flex;
    align-items: start;
    justify-content: space-between;
    gap: 18px;
}

.calibration-verification h2,
.measurement-history h2 {
    margin: 0;
    font-size: 19px;
    line-height: 1.2;
}

.calibration-verification-head > span {
    color: var(--muted);
    font-size: 12px;
    text-align: right;
}

.calibration-verification-intro,
.calibration-verification-note {
    margin: 10px 0 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.55;
}

.verification-lines {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

.verification-line-row {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    color: var(--ink);
    font-size: 12px;
    font-weight: 700;
}

.verification-line-scroll {
    min-width: 0;
    overflow-x: auto;
    padding: 6px 0;
}

.verification-line-scroll i {
    display: block;
    min-width: 40px;
    height: 4px;
    border-radius: 99px;
    background: var(--accent);
}

.measurement-history {
    background: var(--panel);
}

.measurement-history .text-button {
    margin: 0;
    padding: 2px 0;
    color: var(--accent);
}

.measurement-history ol {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 14px 0 0;
    padding: 0;
    list-style: none;
}

.measurement-history li {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
    min-width: 0;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: color-mix(in srgb, var(--panel) 78%, var(--bg));
    font-size: 12px;
}

.measurement-history li strong {
    overflow: hidden;
    color: var(--ink);
    text-overflow: ellipsis;
    white-space: nowrap;
}

.measurement-history li span {
    flex: 0 0 auto;
    color: var(--muted);
    font-size: 11px;
}

.tool-guides {
    margin-top: 48px;
}

.tool-guides .section-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}

.tool-guides h2 {
    margin: 0;
    font-size: clamp(24px, 3vw, 32px);
}

.text-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent);
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

.tool-guide-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.tool-guide-card {
    position: relative;
    display: flex;
    min-height: 170px;
    flex-direction: column;
    gap: 8px;
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    color: var(--ink);
    text-decoration: none;
    box-shadow: 0 10px 24px rgba(31, 52, 95, .04);
}

.tool-guide-card:hover,
.tool-guide-card:focus-visible {
    border-color: var(--accent);
    box-shadow: 0 14px 28px rgba(49, 94, 251, .1);
}

.tool-guide-card strong {
    font-size: 18px;
    line-height: 1.22;
}

.tool-guide-card > span:not(.tool-card-category) {
    color: var(--muted);
    font-size: 13px;
    line-height: 1.5;
}

.tool-guide-card > b {
    display: grid;
    width: 28px;
    height: 28px;
    margin-top: auto;
    place-items: center;
    color: var(--accent);
}

@media (max-width: 760px) {
    .tool-guide-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 560px) {
    .calibration-verification,
    .measurement-history {
        padding: 14px;
    }

    .calibration-verification-head > span {
        max-width: 42%;
    }

    .measurement-history ol {
        grid-template-columns: 1fr;
    }

    .tool-guides .section-heading {
        align-items: start;
        flex-direction: column;
    }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
