/* ═══════════════════════════════════════════
   SELF-HOSTED FONTS (Poppins + JetBrains Mono)
   Subsets are split by unicode-range so the browser only fetches the
   weights & ranges needed for the current locale (e.g. a Turkish user
   only downloads latin-ext, not latin; a Russian user's Cyrillic text
   falls back to the system UI font since Poppins has no Cyrillic glyphs).
   font-display: swap keeps text visible during the woff2 fetch.
   ═══════════════════════════════════════════ */

/* ─── Poppins — Latin Extended (Czech, Hungarian, Polish, Romanian,
   Turkish, Vietnamese, etc.) ─── */
@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/poppins-400-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/fonts/poppins-500-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/fonts/poppins-600-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/fonts/poppins-700-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ─── Poppins — Latin (English + most Western European) ─── */
@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 400;
    font-display: swap;
    src: url('/fonts/poppins-400-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 500;
    font-display: swap;
    src: url('/fonts/poppins-500-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 600;
    font-display: swap;
    src: url('/fonts/poppins-600-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Poppins';
    font-style: normal;
    font-weight: 700;
    font-display: swap;
    src: url('/fonts/poppins-700-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ─── JetBrains Mono — Latin only (used for digits/dimensions) ───
   Single variable-font file covers weights 500-700. */
@font-face {
    font-family: 'JetBrains Mono';
    font-style: normal;
    font-weight: 500 700;
    font-display: swap;
    src: url('/fonts/jetbrains-mono-latin.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f1f3f5;
    --ruler-paper: #f4e37a;
    --ruler-paper-edge: #e8d560;
    --ruler-shade: #c8a82a;
    --ruler-ink: #0f1114;
    --ink: #1a1d23;
    --ink-2: #3d434d;
    --ink-3: #6b727f;
    --ink-4: #9ea4ae;
    --line: #e4e7ec;
    --line-2: #eef0f3;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-soft: #eff4ff;
    --accent: #0ea5e9;
    --accent-soft: #e0f2fe;
    --protractor-face: #fafbfc;
    --protractor-stroke: #1a1d23;
    --ok: #16a34a;
    --ok-soft: #ecfdf5;
    --ok-border: #bbf7d0;
    --warn: #d97706;
    --warn-soft: #fffbeb;
    --warn-border: #fde68a;
    --shadow-xs: 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-sm: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(16, 24, 40, 0.06), 0 2px 4px -2px rgba(16, 24, 40, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(16, 24, 40, 0.08), 0 4px 6px -4px rgba(16, 24, 40, 0.06);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --sans: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
    --header-h: 58px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    background: var(--bg);
    color: var(--ink);
    font-family: var(--sans);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    overflow-x: hidden;
    font-size: 15px;
    line-height: 1.55;
}

/* HEADER / NAVIGATION */
header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 30;
    height: var(--header-h);
}

.nav {
    max-width: 1240px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    gap: 18px;
}

.nav-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    flex: 1;
}

.brand-h1 {
    margin: 0;
    padding: 0;
    font-weight: 600;
    font-size: 17px;
    letter-spacing: -0.01em;
    color: var(--ink);
    text-decoration: none;
    white-space: nowrap;
    line-height: 1;
}

/* Long-form content pages (privacy, terms, contact) */
.content-page {
    max-width: 780px;
    margin: 0 auto;
}

.content-page h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
    margin: 28px 0 10px;
}

.content-page h2:first-child {
    margin-top: 0;
}

.content-page p {
    font-size: 15px;
    line-height: 1.7;
    color: var(--ink-2);
    margin-bottom: 14px;
}

.content-page ul {
    padding-left: 22px;
    color: var(--ink-2);
    font-size: 15px;
    line-height: 1.7;
    margin-bottom: 14px;
}

.content-page ul li {
    margin-bottom: 4px;
}

.content-page a {
    color: var(--primary);
    text-decoration: none;
}

.content-page a:hover {
    text-decoration: underline;
}

/* 404 */
.error-page {
    max-width: 640px;
    margin: 0 auto;
    text-align: center;
    padding: 40px 20px 60px;
}

.error-page .error-code {
    font-family: var(--mono);
    font-size: clamp(80px, 14vw, 140px);
    font-weight: 600;
    line-height: 1;
    background: linear-gradient(135deg, var(--primary) 0%, #60a5fa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.error-page p {
    color: var(--ink-3);
    font-size: 15px;
    margin-bottom: 28px;
}

.error-page .error-actions {
    margin-bottom: 36px;
}

.error-lang-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 6px;
    max-width: 560px;
    margin: 14px auto 0;
}

.error-lang-grid a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    color: var(--ink-2);
    font-size: 13.5px;
    text-decoration: none;
    background: var(--surface);
    transition: all 0.15s ease;
}

.error-lang-grid a:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}

.error-lang-heading {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-4);
    margin-bottom: 6px;
}

.brand-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
    flex-shrink: 0;
}

.brand-icon svg {
    width: 18px;
    height: 18px;
    color: #fff;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 6px;
    position: relative;
}

/* BUTTONS */
.btn {
    appearance: none;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-family: var(--sans);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--ink-2);
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    gap: 7px;
    transition: all 0.15s ease;
    white-space: nowrap;
    line-height: 1;
}

.btn:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn svg {
    width: 16px;
    height: 16px;
}

.btn-outline {
    background: var(--surface);
    border-color: var(--line);
    color: var(--ink-2);
}

.btn-outline:hover {
    background: var(--surface-2);
    border-color: var(--ink-4);
    color: var(--ink);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
    box-shadow: var(--shadow-xs);
}

.btn-primary:hover {
    background: var(--primary-hover);
    color: #fff;
    border-color: var(--primary-hover);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-fs {
    font-size: 14.5px;
    font-weight: 600;
    padding: 12px 20px;
    border-radius: 10px;
    letter-spacing: -0.005em;
    box-shadow: 0 2px 6px rgba(37, 99, 235, 0.28), var(--shadow-xs);
}

.btn-fs svg {
    width: 18px;
    height: 18px;
}

.btn-fs:hover {
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.36);
    transform: translateY(-1px);
}

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    justify-content: center;
}

/* Language dropdown */
.lang-menu {
    position: absolute;
    top: calc(100% + 6px);
    /* Anchor to the end side of the nav (right in LTR, left in RTL)
       so the dropdown never gets clipped off-screen. */
    inset-inline-end: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 180px;
    display: none;
    z-index: 60;
    max-height: 340px;
    overflow-y: auto;
}

.lang-menu.open {
    display: block;
}

.lang-menu a {
    display: block;
    padding: 8px 12px;
    border-radius: 6px;
    color: var(--ink-2);
    font-size: 13.5px;
    text-decoration: none;
}

.lang-menu a:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.hamburger {
    display: inline-flex;
}

/* Mobile drawer */
.mobile-drawer {
    position: fixed;
    inset: 0;
    background: rgba(26, 29, 35, 0.5);
    backdrop-filter: blur(4px);
    z-index: 80;
    display: none;
    animation: fadeIn 0.2s ease;
}

.mobile-drawer.open {
    display: block;
}

.mobile-drawer-panel {
    position: absolute;
    top: 0;
    /* Slide in from the start side — left in LTR, right in RTL. */
    inset-inline-start: 0;
    width: min(320px, 85vw);
    height: 100%;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    padding: 22px 22px 28px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    animation: drawerIn 0.25s ease;
}

@keyframes drawerIn {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
}

/* In RTL the panel is anchored to the right, so the slide-in must come
   from the right (positive X) instead of the left (negative X). */
[dir="rtl"] .mobile-drawer-panel {
    animation-name: drawerInRtl;
}

@keyframes drawerInRtl {
    from { transform: translateX(100%); }
    to   { transform: translateX(0); }
}

.mobile-drawer-panel .drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}

.mobile-drawer-panel .drawer-head strong {
    font-size: 14px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--ink-4);
}

.mobile-drawer-panel a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    color: var(--ink);
    font-size: 14.5px;
    font-weight: 500;
    border-radius: var(--radius-sm);
    text-decoration: none;
}

.mobile-drawer-panel a:hover {
    background: var(--surface-2);
}

.mobile-drawer-panel a.active {
    background: var(--primary-soft);
    color: var(--primary);
}

.mobile-drawer-panel a svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--ink-3);
}

.mobile-drawer-panel a.active svg {
    color: var(--primary);
}

/* SEGMENTED CONTROL */
.seg {
    display: inline-flex;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 3px;
    position: relative;
}

.seg button {
    background: transparent;
    border: none;
    cursor: pointer;
    font-family: var(--sans);
    font-weight: 500;
    font-size: 13px;
    padding: 7px 14px;
    border-radius: 6px;
    color: var(--ink-3);
    transition: color 0.15s ease;
    position: relative;
    z-index: 1;
    min-width: 60px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    line-height: 1;
}

.seg button:hover {
    color: var(--ink-2);
}

.seg button.active {
    color: var(--ink);
}

.seg .seg-thumb {
    position: absolute;
    top: 3px;
    bottom: 3px;
    left: 3px;
    background: var(--surface);
    border-radius: 6px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), width 0.25s;
    z-index: 0;
}

/* MAIN LAYOUT */
main {
    max-width: 1240px;
    margin: 0 auto;
    padding: 28px 24px 64px;
}

.ruler-section {
    margin-bottom: 36px;
}

.ruler-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

.toolbar-left,
.toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* RULER STAGE */
.ruler-stage {
    background: var(--ruler-paper);
    border: 1px solid var(--ruler-shade);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s ease;
}

.ruler-stage::before {
    display: none;
}

.ruler-stage.horizontal {
    padding: 22px 14px 18px;
}

.ruler-stage.horizontal #ruler-canvas {
    width: 100%;
    height: 120px;
    display: block;
}

.ruler-stage.vertical {
    padding: 14px 22px 14px 18px;
    width: max-content;
    max-width: 100%;
}

.ruler-stage.vertical #ruler-canvas {
    width: 120px;
    min-height: 620px;
    height: 620px;
    display: block;
}

.ruler-stage:fullscreen {
    background: var(--ruler-paper);
    border-radius: 0;
    padding: 0;
    border: none;
    box-shadow: none;
}

.ruler-stage:fullscreen #ruler-canvas {
    width: 100vw !important;
    height: 100vh !important;
}

.fs-exit {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: var(--shadow-md);
}

.fs-exit svg {
    width: 18px;
    height: 18px;
}

.ruler-stage:fullscreen .fs-exit {
    display: flex;
}

/* FULLSCREEN MEASURE BOX */
.measure-box {
    position: absolute;
    display: none;
    background: rgba(37, 99, 235, 0.12);
    border: 2px solid #2563eb;
    box-sizing: border-box;
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
    z-index: 8;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.6) inset,
        0 4px 14px rgba(37, 99, 235, 0.22);
}

.ruler-stage:fullscreen .measure-box {
    display: block;
}

.measure-label {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #2563eb;
    color: #fff;
    font-family: var(--mono);
    font-size: 13px;
    font-weight: 600;
    padding: 5px 11px;
    border-radius: 6px;
    white-space: nowrap;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.4);
    letter-spacing: 0.02em;
}

.measure-handle {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #fff;
    border: 2px solid #2563eb;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(16, 24, 40, 0.25);
    touch-action: none;
    z-index: 2;
}

.measure-handle::before {
    content: '';
    position: absolute;
    inset: -12px;
}

.measure-handle.h-nw { top: -9px; left: -9px; cursor: nwse-resize; }
.measure-handle.h-n  { top: -9px; left: 50%; margin-left: -7px; cursor: ns-resize; }
.measure-handle.h-ne { top: -9px; right: -9px; cursor: nesw-resize; }
.measure-handle.h-e  { top: 50%; right: -9px; margin-top: -7px; cursor: ew-resize; }
.measure-handle.h-se { bottom: -9px; right: -9px; cursor: nwse-resize; }
.measure-handle.h-s  { bottom: -9px; left: 50%; margin-left: -7px; cursor: ns-resize; }
.measure-handle.h-sw { bottom: -9px; left: -9px; cursor: nesw-resize; }
.measure-handle.h-w  { top: 50%; left: -9px; margin-top: -7px; cursor: ew-resize; }

@media (max-width: 640px) {
    .measure-handle { width: 18px; height: 18px; }
    .measure-handle.h-nw { top: -11px; left: -11px; }
    .measure-handle.h-n  { top: -11px; margin-left: -9px; }
    .measure-handle.h-ne { top: -11px; right: -11px; }
    .measure-handle.h-e  { right: -11px; margin-top: -9px; }
    .measure-handle.h-se { bottom: -11px; right: -11px; }
    .measure-handle.h-s  { bottom: -11px; margin-left: -9px; }
    .measure-handle.h-sw { bottom: -11px; left: -11px; }
    .measure-handle.h-w  { left: -11px; margin-top: -9px; }
}

.stage-hint {
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-family: var(--mono);
    font-size: 10.5px;
    color: #3a2f08;
    letter-spacing: 0.04em;
    pointer-events: none;
    background: rgba(255, 253, 235, 0.75);
    backdrop-filter: blur(4px);
    padding: 3px 8px;
    border-radius: 5px;
    border: 1px solid var(--ruler-shade);
}

/* Status bar */
.status-bar {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 10px;
    border-radius: 999px;
    font-size: 12.5px;
    font-weight: 500;
    background: var(--surface);
    border: 1px solid var(--line);
    color: var(--ink-2);
}

.status-chip .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ink-4);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50%      { opacity: 1; }
}

.status-chip.ok {
    background: var(--ok-soft);
    border-color: var(--ok-border);
    color: #14532d;
}

.status-chip.ok .dot {
    background: var(--ok);
    animation: none;
}

.status-chip.warn {
    background: var(--warn-soft);
    border-color: var(--warn-border);
    color: #78350f;
}

.status-chip.warn .dot {
    background: var(--warn);
    animation: none;
}

.status-meta {
    font-family: var(--mono);
    font-size: 11.5px;
    color: var(--ink-4);
    letter-spacing: 0.02em;
}

.quick-cal {
    margin-top: 14px;
    background: var(--warn-soft);
    border: 1px solid var(--warn-border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: none;
}

.quick-cal.show {
    display: block;
    animation: slideDown 0.25s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.quick-cal h3 {
    font-size: 15px;
    font-weight: 600;
    color: #78350f;
    margin-bottom: 4px;
}

.quick-cal p {
    color: #92400e;
    font-size: 13px;
    margin-bottom: 12px;
}

.quick-cal-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.input-group {
    display: inline-flex;
    align-items: center;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 2px 2px 2px 12px;
    gap: 8px;
    height: 38px;
}

.input-group input {
    appearance: none;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--sans);
    font-size: 14px;
    font-weight: 500;
    width: 84px;
    padding: 0;
    color: var(--ink);
}

.input-group .unit-tag {
    font-size: 12.5px;
    color: var(--ink-3);
    padding-right: 10px;
}

/* HERO & ARTICLES */
.hero {
    max-width: 780px;
    margin: 0 auto;
    text-align: center;
    padding: 32px 0 8px;
}

.hero h1 {
    font-size: clamp(30px, 4.5vw, 44px);
    line-height: 1.15;
    font-weight: 600;
    letter-spacing: -0.02em;
    color: var(--ink);
    margin-bottom: 14px;
}

.hero p {
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink-3);
    max-width: 620px;
    margin: 0 auto;
}

.articles {
    margin-top: 56px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 28px;
    box-shadow: var(--shadow-xs);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-sm);
}

.card.wide {
    grid-column: 1 / -1;
}

.card h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--ink);
    margin-bottom: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card h2 .h2-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.card h2 .h2-icon svg {
    width: 16px;
    height: 16px;
}

.card h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    margin: 20px 0 6px;
}

.card p {
    font-size: 14.5px;
    line-height: 1.65;
    color: var(--ink-2);
    margin-bottom: 10px;
}

.card p:last-child {
    margin-bottom: 0;
}

.card p strong,
.card li strong {
    color: var(--ink);
    font-weight: 600;
}

.card ul,
.card ol {
    padding-left: 18px;
    color: var(--ink-2);
    font-size: 14.5px;
    line-height: 1.65;
    margin-bottom: 10px;
}

.card li {
    margin-bottom: 3px;
}

.steps {
    list-style: none;
    padding: 0;
    counter-reset: step;
    margin-top: 12px;
}

.steps li {
    counter-increment: step;
    padding-left: 40px;
    position: relative;
    margin-bottom: 14px;
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--ink-2);
}

.steps li::before {
    content: counter(step);
    position: absolute;
    left: 0;
    top: -1px;
    font-family: var(--mono);
    font-size: 12px;
    color: var(--primary);
    background: var(--primary-soft);
    width: 26px;
    height: 26px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.device-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 14px 0 6px;
}

.device-chip {
    font-size: 12.5px;
    padding: 4px 10px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 999px;
    color: var(--ink-2);
    font-weight: 500;
}

.card a.inline-link,
.card p a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 1px solid transparent;
    transition: border-color 0.15s ease;
}

.card a.inline-link:hover,
.card p a:hover {
    border-bottom-color: var(--primary);
}

/* MODAL */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(26, 29, 35, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 100;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}

.modal-backdrop.open {
    display: flex;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal {
    background: var(--surface);
    border-radius: var(--radius-lg);
    max-width: 580px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--line);
    overflow: hidden;
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { transform: translateY(12px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--line-2);
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    color: var(--ink-3);
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.modal-body {
    padding: 18px 24px 22px;
}

.method {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    margin-bottom: 10px;
    overflow: hidden;
}

.method summary {
    padding: 13px 16px;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 500;
    font-size: 14px;
    color: var(--ink);
}

.method summary::-webkit-details-marker {
    display: none;
}

.method summary::after {
    content: '';
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--ink-3);
    border-bottom: 2px solid var(--ink-3);
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    margin-right: 6px;
    margin-top: -2px;
}

.method[open] summary::after {
    transform: rotate(-135deg);
    margin-top: 4px;
}

.method summary:hover {
    background: var(--surface-2);
}

.method .method-label {
    font-family: var(--mono);
    font-size: 10.5px;
    color: var(--primary);
    margin-right: 10px;
    letter-spacing: 0.06em;
    background: var(--primary-soft);
    padding: 3px 8px;
    border-radius: 4px;
}

.method-body {
    padding: 14px 16px 16px;
    border-top: 1px solid var(--line-2);
}

.method-body p {
    font-size: 13.5px;
    color: var(--ink-2);
    margin-bottom: 12px;
    line-height: 1.55;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.field label {
    font-size: 12.5px;
    color: var(--ink-3);
    font-weight: 500;
}

.field select,
.field input[type="number"] {
    appearance: none;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 9px 12px;
    font-family: var(--sans);
    font-size: 14px;
    color: var(--ink);
    width: 100%;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field select:focus,
.field input[type="number"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.accuracy {
    font-size: 12.5px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    margin-top: 6px;
    display: none;
    align-items: center;
    gap: 6px;
    font-weight: 500;
}

.accuracy.excellent {
    background: var(--ok-soft);
    color: #14532d;
    border: 1px solid var(--ok-border);
}

.accuracy.good {
    background: var(--warn-soft);
    color: #78350f;
    border: 1px solid var(--warn-border);
}

.accuracy.show {
    display: flex;
}

/* CREDIT CARD SIZER */
.sizer-scroll {
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    background: var(--surface-2);
    border: 1px dashed var(--ink-4);
    border-radius: var(--radius);
    padding: 22px;
    margin: 8px 0 12px;
    position: relative;
}

.sizer-scroll-hint {
    font-size: 12px;
    color: var(--ink-3);
    margin-bottom: 14px;
    text-align: center;
}

.scroll-arrow {
    display: none;
    position: absolute;
    top: 50%;
    right: 6px;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    align-items: center;
    justify-content: center;
    animation: hpulse 1.4s ease-in-out infinite;
    pointer-events: none;
    z-index: 2;
}

.sizer-scroll.can-scroll .scroll-arrow {
    display: flex;
}

.scroll-arrow svg {
    width: 14px;
    height: 14px;
}

@keyframes hpulse {
    0%, 100% { transform: translateY(-50%) translateX(0); opacity: 0.7; }
    50%      { transform: translateY(-50%) translateX(3px); opacity: 1; }
}

.sizer-inner {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: max-content;
}

#card-sizer {
    background: linear-gradient(135deg, #1e40af 0%, #2563eb 50%, #3b82f6 100%);
    border-radius: 8px;
    color: rgba(255, 255, 255, 0.95);
    font-family: var(--sans);
    font-size: 11px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10px 12px;
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.25);
    position: relative;
    overflow: hidden;
    transition: width 0.08s linear, height 0.08s linear;
    flex-shrink: 0;
}

.card-orient-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0 12px;
    flex-wrap: wrap;
}

.card-orient-label {
    font-size: 12.5px;
    color: var(--ink-3);
    font-weight: 500;
}

#card-sizer::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 12px;
    width: 24px;
    height: 18px;
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    border-radius: 3px;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.1);
}

#card-sizer .card-num {
    font-family: var(--mono);
    font-size: 10px;
    letter-spacing: 0.06em;
    margin-top: auto;
}

#card-sizer .card-name {
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    font-size: 9.5px;
    opacity: 0.95;
    margin-top: 2px;
}

#phys-ruler-canvas {
    display: block;
    height: 70px;
    flex-shrink: 0;
    background: var(--ruler-paper);
    border: 1px solid var(--ruler-shade);
    border-radius: 6px;
}

.slider-wrap {
    margin: 14px 0;
}

.slider-wrap input[type="range"] {
    width: 100%;
    appearance: none;
    background: transparent;
    height: 24px;
}

.slider-wrap input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: var(--line);
    border-radius: 4px;
}

.slider-wrap input[type="range"]::-moz-range-track {
    height: 4px;
    background: var(--line);
    border-radius: 4px;
}

.slider-wrap input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border: 2px solid #fff;
    border-radius: 50%;
    margin-top: -8px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.slider-wrap input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.ppi-readout {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-family: var(--mono);
    font-size: 12.5px;
    color: var(--ink-3);
    margin-bottom: 4px;
}

.ppi-readout strong {
    color: var(--ink);
    font-weight: 600;
    font-size: 14px;
}

.method-footer {
    text-align: right;
    margin-top: 10px;
}

/* SHARE SECTION */
.share-section {
    margin-top: 56px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 32px 28px;
    text-align: center;
}

.share-section h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--ink);
    letter-spacing: -0.01em;
    margin-bottom: 6px;
}

.share-section p {
    color: var(--ink-3);
    font-size: 14px;
    margin-bottom: 22px;
}

.share-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.share-btn {
    appearance: none;
    border: none;
    background: none;
    cursor: pointer;
    padding: 0;
    line-height: 0;
    border-radius: 50%;
    transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.share-btn:hover {
    transform: translateY(-2px) scale(1.05);
    filter: brightness(1.08);
    box-shadow: var(--shadow-sm);
}

.share-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 3px;
}

.share-btn svg {
    display: block;
    width: 44px;
    height: 44px;
}

.share-btn.copy-link {
    width: 44px;
    height: 44px;
    background: var(--ink);
    color: #fff;
}

.share-btn.copy-link svg {
    width: 18px;
    height: 18px;
}

.share-btn.copy-link.copied {
    background: var(--ok);
}

/* FOOTER */
footer {
    border-top: 1px solid var(--line);
    background: var(--surface);
    margin-top: 48px;
}

.footer-inner {
    max-width: 1240px;
    margin: 0 auto;
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
}

.footer-copy {
    font-size: 13px;
    color: var(--ink-3);
    font-weight: 500;
}

.footer-links {
    display: flex;
    gap: 22px;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    font-size: 13px;
    color: var(--ink-3);
    text-decoration: none;
}

.footer-links a:hover {
    color: var(--ink);
    text-decoration: underline;
}

/* TOAST */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(12px);
    background: var(--ink);
    color: #fff;
    padding: 10px 18px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: all 0.25s ease;
    z-index: 200;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast svg {
    width: 16px;
    height: 16px;
    color: #4ade80;
}

/* RESPONSIVE */
@media (max-width: 860px) {
    .articles { grid-template-columns: 1fr; }
    .hero { padding: 28px 8px 0; }
}

@media (max-width: 640px) {
    main { padding: 20px 16px 48px; }
    .nav { padding: 0 16px; }
    .card { padding: 22px; }
    .card h2 { font-size: 20px; }
    .ruler-toolbar { gap: 10px; }
    .toolbar-left,
    .toolbar-right { width: 100%; justify-content: space-between; }
    .ruler-stage.horizontal { padding: 18px 10px 14px; }
    .ruler-stage.horizontal #ruler-canvas { height: 100px; }
    .ruler-stage.vertical { padding: 10px 18px; }
    .ruler-stage.vertical #ruler-canvas {
        min-height: 620px;
        height: 620px;
        width: 100px;
    }
    .seg button { padding: 7px 10px; min-width: 0; font-size: 12.5px; }
    .btn { padding: 8px 12px; font-size: 13px; }
    .sizer-scroll { padding: 16px; }
    .share-section { padding: 24px 18px; }
    .share-btn svg { width: 38px; height: 38px; }
    .share-btn.copy-link { width: 38px; height: 38px; }
}

@media (max-width: 420px) {
    .btn:not(.btn-fs) .btn-text { display: none; }
    .btn:not(.no-shrink):not(.btn-fs) {
        padding: 0;
        width: 38px;
        height: 38px;
        justify-content: center;
    }
    .btn-fs { padding: 10px 14px; font-size: 13.5px; }
    .modal-body { padding: 14px 16px 18px; }
}

/* ═══════════════════════════════════════════
   ONLINE PROTRACTOR PAGE
   ═══════════════════════════════════════════ */
.proto-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 20px;
    margin-bottom: 32px;
}

.proto-stage {
    position: relative;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
    min-height: 520px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#camera-feed,
#image-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: none;
    z-index: 0;
}

#camera-feed { object-fit: cover; }

#image-overlay {
    object-fit: contain;
    background: var(--surface-2);
}

.proto-stage.camera-on #camera-feed,
.proto-stage.image-on #image-overlay { display: block; }

.proto-stage.camera-on .proto-svg,
.proto-stage.image-on .proto-svg {
    opacity: 0.82;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 0.8));
}

.proto-svg {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    max-width: 640px;
    touch-action: none;
    cursor: crosshair;
    user-select: none;
    -webkit-user-select: none;
}

.proto-svg .face-fill { fill: var(--protractor-face); fill-opacity: 0.7; }
.proto-stage.camera-on .proto-svg .face-fill,
.proto-stage.image-on .proto-svg .face-fill { fill-opacity: 0.08; }
.proto-svg .face-stroke { stroke: var(--protractor-stroke); stroke-width: 1.5; fill: none; }
.proto-svg .base-line { stroke: var(--protractor-stroke); stroke-width: 1.5; }
.proto-svg .tick-minor { stroke: var(--ink-3); stroke-width: 0.6; }
.proto-svg .tick-medium { stroke: var(--ink-2); stroke-width: 0.8; }
.proto-svg .tick-major { stroke: var(--ink); stroke-width: 1.2; }
.proto-svg .tick-number {
    font-family: var(--sans);
    font-weight: 500;
    font-size: 10px;
    fill: var(--ink);
}
.proto-svg .center-dot { fill: var(--ink); }
.proto-svg .pointer-line {
    stroke-width: 2.2;
    stroke-linecap: round;
    pointer-events: none;
}
.proto-svg .pointer-line-a { stroke: var(--primary); }
.proto-svg .pointer-line-b { stroke: var(--accent); }

.proto-svg .pointer-handle {
    stroke: #fff;
    stroke-width: 2;
    cursor: grab;
}
.proto-svg .pointer-handle-a { fill: var(--primary); }
.proto-svg .pointer-handle-b { fill: var(--accent); }
.proto-svg .pointer-handle:active { cursor: grabbing; }
.proto-svg .arc {
    fill: var(--accent);
    fill-opacity: 0.22;
    stroke: var(--accent);
    stroke-width: 1.5;
    pointer-events: none;
}
.proto-svg .arc-other {
    fill: #ef4444;
    fill-opacity: 0.12;
    stroke: #ef4444;
    stroke-width: 1.2;
    pointer-events: none;
}
.proto-svg .angle-label-bg { fill: var(--primary); }
.proto-svg .angle-label-bg-other { fill: #ef4444; }
.proto-svg .angle-label-text {
    fill: #fff;
    font-family: var(--mono);
    font-weight: 700;
    font-size: 14px;
    text-anchor: middle;
    dominant-baseline: middle;
    pointer-events: none;
}

.proto-controls {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.readout-card {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    border-radius: var(--radius);
    padding: 18px 20px;
    color: #fff;
    text-align: center;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.readout-card .label {
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.85;
    margin-bottom: 4px;
}

.readout-card .value {
    font-family: var(--mono);
    font-size: 40px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.01em;
}

.readout-other {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-sm);
    color: #dc2626;
}

.readout-other .label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    opacity: 0.85;
}

.readout-other .value {
    font-family: var(--mono);
    font-size: 16px;
    font-weight: 700;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.control-group label {
    font-size: 12px;
    color: var(--ink-3);
    font-weight: 500;
    letter-spacing: 0.02em;
}

.angle-input-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.angle-input {
    appearance: none;
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: var(--mono);
    font-size: 16px;
    font-weight: 600;
    color: var(--ink);
    outline: none;
    min-width: 0;
}

.angle-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.angle-input-unit {
    color: var(--ink-3);
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 600;
}

/* Segmented control in the protractor panel fills the full width */
.proto-controls .seg {
    display: flex;
    width: 100%;
}

.proto-controls .seg button {
    flex: 1;
    min-width: 0;
    font-size: 12.5px;
    padding: 8px 10px;
    justify-content: center;
}

.toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    gap: 10px;
}

.toggle-row .toggle-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.toggle-row .toggle-label strong {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink);
}

.toggle-row .toggle-label span {
    font-size: 11.5px;
    color: var(--ink-3);
    line-height: 1.4;
}

.toggle-row.disabled { opacity: 0.55; }
.toggle-row.disabled .switch { pointer-events: none; }

.switch {
    position: relative;
    flex-shrink: 0;
    width: 40px;
    height: 22px;
    background: var(--ink-4);
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease;
}

.switch.on { background: var(--primary); }
.switch.on::after { transform: translateX(18px); }

.control-actions {
    display: flex;
    gap: 8px;
}

.control-actions .btn {
    flex: 1;
    justify-content: center;
}

@media (max-width: 860px) {
    .proto-wrap {
        grid-template-columns: 1fr;
        padding: 14px;
    }
    .proto-stage { min-height: 380px; }
    .readout-card { padding: 14px 16px; }
    .readout-card .value { font-size: 32px; }
}

/* ═══════════════════════════════════════════
   PPI CALCULATOR PAGE
   ═══════════════════════════════════════════ */
.btn-lg {
    padding: 12px 20px;
    font-size: 14.5px;
    font-weight: 600;
    border-radius: 10px;
}

.detected-title {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-4);
    text-align: center;
    margin-bottom: 14px;
}

.info-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
    margin-bottom: 20px;
}

.info-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 22px 24px;
    box-shadow: var(--shadow-xs);
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-width: 0;
}

.info-card .info-label {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-card .info-label svg {
    width: 14px;
    height: 14px;
    color: var(--ink-4);
}

.info-card .info-value {
    font-family: var(--mono);
    font-size: 26px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
    line-height: 1.1;
    word-break: break-word;
}

.info-card .info-sub {
    font-size: 12.5px;
    color: var(--ink-3);
    font-weight: 500;
}

.note {
    background: var(--warn-soft);
    border: 1px solid var(--warn-border);
    color: #854d0e;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 500;
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 24px;
    line-height: 1.5;
}

.note svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--warn);
    margin-top: 1px;
}

.calc-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
    margin-bottom: 36px;
}

.calc-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.calc-header {
    padding: 18px 24px 14px;
    border-bottom: 1px solid var(--line-2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.calc-header .header-icon {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: var(--primary-soft);
    color: var(--primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.calc-header .header-icon svg { width: 18px; height: 18px; }

.calc-header h2 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--ink);
}

.calc-body { padding: 22px 24px 26px; }

/* Form styles scoped to calc-card so they don't clash with the ruler's
   .field / .input-group used in the calibration modal. */
.calc-card .field { margin-bottom: 16px; }

.calc-card .field-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--ink-2);
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}

.calc-card .field-label .field-hint {
    font-size: 11.5px;
    font-weight: 500;
    color: var(--ink-4);
    font-style: italic;
}

.calc-card .input-group {
    display: flex;
    position: relative;
    align-items: center;
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    height: auto;
    gap: 0;
}

.calc-card .input-group input {
    appearance: none;
    -webkit-appearance: none;
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 11px 56px 11px 14px;
    font-family: var(--mono);
    font-size: 15px;
    font-weight: 600;
    color: var(--ink);
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.calc-card .input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.calc-card .input-group input::-webkit-outer-spin-button,
.calc-card .input-group input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.calc-card .input-group input[type=number] { -moz-appearance: textfield; }

.calc-card .input-group .input-unit {
    position: absolute;
    right: 14px;
    font-family: var(--mono);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--ink-4);
    pointer-events: none;
    letter-spacing: 0.02em;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 4px;
}

.form-actions .btn { flex: 1; justify-content: center; }
.form-actions .btn.no-shrink { flex: 0 0 auto; }

.result-hero {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    padding: 26px 24px;
    color: #fff;
    text-align: center;
    margin: -22px -24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.result-hero .result-label {
    font-size: 11.5px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.85;
    margin-bottom: 6px;
}

.result-hero .result-value {
    font-family: var(--mono);
    font-size: 52px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: -0.02em;
}

.result-hero .result-value .unit {
    font-size: 18px;
    font-weight: 600;
    opacity: 0.8;
    margin-left: 4px;
}

.result-list {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.result-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    gap: 10px;
}

.result-row .row-label { color: var(--ink-3); font-weight: 500; }

.result-row .row-value {
    font-family: var(--mono);
    font-weight: 700;
    color: var(--ink);
    text-align: right;
}

.result-interp {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    line-height: 1.5;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.result-interp.level-low { background: #fff7ed; border: 1px solid #fed7aa; color: #9a3412; }
.result-interp.level-mid { background: var(--primary-soft); border: 1px solid #bfdbfe; color: #1e40af; }
.result-interp.level-high { background: var(--ok-soft); border: 1px solid #bbf7d0; color: #166534; }

.result-interp svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.result-interp strong { font-weight: 600; }

@media (max-width: 860px) {
    .calc-grid { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    .info-row { grid-template-columns: 1fr; gap: 10px; }
    .info-card { padding: 18px 20px; }
    .info-card .info-value { font-size: 22px; }
    .result-hero .result-value { font-size: 42px; }
}

/* ═══════════════════════════════════════════
   SCREEN RESOLUTION PAGE
   ═══════════════════════════════════════════ */
.resolution-hero {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 55%, #4f46e5 100%);
    border-radius: var(--radius-lg);
    padding: 44px 24px 48px;
    color: #fff;
    text-align: center;
    margin-bottom: 24px;
    box-shadow: 0 10px 30px -8px rgba(37, 99, 235, 0.35);
    position: relative;
    overflow: hidden;
}

.resolution-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    background: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.1), transparent 50%);
    pointer-events: none;
}

.resolution-hero .hero-label {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    opacity: 0.85;
    margin-bottom: 14px;
    position: relative;
}

.resolution-hero .hero-value {
    font-family: var(--mono);
    font-size: 68px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1;
    position: relative;
    margin-bottom: 6px;
}

.resolution-hero .hero-value .unit {
    font-size: 22px;
    font-weight: 500;
    opacity: 0.8;
    margin-left: 10px;
    letter-spacing: 0.05em;
}

.resolution-hero .hero-sub {
    font-size: 14px;
    font-weight: 500;
    opacity: 0.85;
    position: relative;
}

/* Grid of small info cards. The base .info-card rule (shared with the PPI
   page) is reused; we only override padding, hover and add the card-*
   selectors specific to this layout. */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
    margin-bottom: 40px;
}

.info-grid .info-card {
    padding: 18px 20px;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.info-grid .info-card:hover {
    box-shadow: var(--shadow-sm);
}

.info-grid .info-card .card-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
    display: flex;
    align-items: center;
    gap: 6px;
}

.info-grid .info-card .card-label svg {
    width: 13px;
    height: 13px;
    color: var(--ink-4);
}

.info-grid .info-card .card-value {
    font-family: var(--mono);
    font-size: 22px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: -0.01em;
    line-height: 1.15;
    word-break: break-word;
}

.info-grid .info-card .card-sub {
    font-size: 12px;
    color: var(--ink-3);
    font-weight: 500;
}

/* Popular-resolutions list inside an article card */
.card ul.mono-list {
    padding-left: 0;
    list-style: none;
}

.card ul.mono-list li {
    font-family: var(--mono);
    font-size: 13.5px;
    font-weight: 500;
    padding: 10px 14px;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: 10px;
    border: 1px solid var(--line-2);
}

.card ul.mono-list li .res-badge {
    font-family: var(--sans);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary);
    flex-shrink: 0;
    letter-spacing: 0.02em;
}

.res-diagram {
    margin: 24px 0 8px;
    padding: 28px;
    background: linear-gradient(180deg, var(--surface-2) 0%, #fff 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    text-align: center;
}

.res-diagram svg {
    max-width: 100%;
    height: auto;
}

.res-diagram .caption {
    font-size: 13px;
    color: var(--ink-3);
    margin-top: 12px;
    font-weight: 500;
}

@media (max-width: 860px) {
    .resolution-hero { padding: 34px 18px 38px; }
    .resolution-hero .hero-value { font-size: 48px; }
    .resolution-hero .hero-value .unit { font-size: 16px; margin-left: 6px; }
}

@media (max-width: 640px) {
    .info-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
    .info-grid .info-card { padding: 14px 16px; }
    .info-grid .info-card .card-value { font-size: 18px; }
    .resolution-hero .hero-value { font-size: 38px; }
}

@media (max-width: 420px) {
    .info-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════
   FULLSCREEN RULER PAGE
   ═══════════════════════════════════════════ */
.fs-hero-section {
    max-width: 780px;
    margin: 0 auto 36px;
}

.fs-hero-card {
    background: linear-gradient(180deg, var(--primary-soft) 0%, var(--surface) 100%);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 48px 32px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}

.fs-hero-icon {
    width: 72px;
    height: 72px;
    border-radius: 20px;
    margin: 0 auto 20px;
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

.fs-hero-icon svg { width: 36px; height: 36px; color: #fff; }

.fs-hero-card h2 {
    font-size: 26px;
    font-weight: 600;
    letter-spacing: -0.015em;
    color: var(--ink);
    margin-bottom: 10px;
}

.fs-hero-card p {
    font-size: 15px;
    color: var(--ink-3);
    max-width: 520px;
    margin: 0 auto 28px;
    line-height: 1.6;
}

.btn-fs-huge {
    font-size: 17px;
    font-weight: 600;
    padding: 18px 32px;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(37, 99, 235, 0.32), var(--shadow-sm);
    gap: 10px;
}

.btn-fs-huge svg { width: 22px; height: 22px; }

.btn-fs-huge:hover {
    box-shadow: 0 10px 28px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.fs-hero-status {
    margin-top: 22px;
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
}

.fs-hero-actions {
    margin-top: 14px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

.fs-hero-actions .btn { justify-content: center; }

/* Fullscreen stage — hidden unless activated */
.fs-stage { display: none; }

.fs-stage.active {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: var(--ruler-paper);
}

body.fs-active { overflow: hidden; }

.fs-stage canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Floating settings panel inside fullscreen */
.fs-panel {
    position: absolute;
    bottom: 20px;
    right: 20px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow-lg);
    min-width: 260px;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    z-index: 10;
}

.fs-panel-title {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-4);
}

.fs-panel-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.fs-panel-label {
    font-size: 12px;
    color: var(--ink-3);
    font-weight: 500;
}

/* Make the seg inside the fullscreen panel fill the row */
.fs-panel .seg {
    display: flex;
    width: 100%;
}

.fs-panel .seg button {
    flex: 1;
    min-width: 0;
    padding: 7px 10px;
    font-size: 12.5px;
    justify-content: center;
}

.fs-ppi-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fs-ppi-controls input[type="number"] {
    width: 88px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    padding: 8px 10px;
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    outline: none;
    flex-shrink: 0;
}

.fs-ppi-controls input[type="number"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.fs-ppi-controls input[type="range"] {
    flex: 1;
    appearance: none;
    background: transparent;
    height: 24px;
    min-width: 0;
}

.fs-ppi-controls input[type="range"]::-webkit-slider-runnable-track {
    height: 4px;
    background: var(--line);
    border-radius: 4px;
}

.fs-ppi-controls input[type="range"]::-moz-range-track {
    height: 4px;
    background: var(--line);
    border-radius: 4px;
}

.fs-ppi-controls input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: var(--primary);
    border: 2px solid #fff;
    border-radius: 50%;
    margin-top: -7px;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.fs-ppi-controls input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: var(--primary);
    border: 2px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.fs-panel-footer .btn {
    font-size: 12.5px;
    padding: 8px 12px;
    width: 100%;
    justify-content: center;
}

/* Exit button in the top-right of fullscreen */
.fs-exit-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--ink);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    box-shadow: var(--shadow-md);
}

.fs-exit-btn svg { width: 20px; height: 20px; }

.fs-exit-btn:hover { background: #000; }

@media (max-width: 640px) {
    .fs-hero-card { padding: 36px 22px; }
    .fs-hero-card h2 { font-size: 22px; }
    .btn-fs-huge { font-size: 15px; padding: 14px 22px; }

    .fs-panel {
        left: 16px;
        right: 16px;
        bottom: 16px;
        max-width: none;
        min-width: 0;
    }
    .fs-exit-btn { top: 14px; right: 14px; width: 40px; height: 40px; }
}

/* ═══════════════════════════════════════════
   PRINTABLE RULER PAGE
   ═══════════════════════════════════════════ */
.pr-wrap {
    max-width: 900px;
    margin: 0 auto 36px;
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
    align-items: start;
}

.pr-preview-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    text-align: center;
}

.pr-preview-label {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-4);
    margin-bottom: 14px;
}

.pr-preview-frame {
    display: inline-block;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow:
        0 1px 3px rgba(16, 24, 40, 0.08),
        0 8px 24px -8px rgba(16, 24, 40, 0.18);
    padding: 0;
    border-radius: 4px;
    max-width: 100%;
    overflow: hidden;
}

.pr-preview-frame canvas {
    display: block;
    max-width: 100%;
    height: auto;
}

.pr-controls {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 22px;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 18px;
    position: sticky;
    top: calc(var(--header-h) + 16px);
}

.pr-control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.pr-control-label {
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--ink-3);
}

.pr-controls .seg {
    display: flex;
    width: 100%;
}

.pr-controls .seg button {
    flex: 1;
    min-width: 0;
    padding: 9px 10px;
    font-size: 13px;
    justify-content: center;
}

.pr-download-btn {
    font-size: 15px;
    font-weight: 600;
    padding: 14px 18px;
    border-radius: 10px;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.24);
}

.pr-download-btn svg { width: 18px; height: 18px; }

.pr-tip {
    background: var(--warn-soft);
    border: 1px solid var(--warn-border);
    border-radius: var(--radius-sm);
    padding: 12px 14px;
    font-size: 12.5px;
    line-height: 1.5;
    color: #78350f;
}

.pr-tip strong { color: #78350f; font-weight: 600; }

@media (max-width: 860px) {
    .pr-wrap {
        grid-template-columns: 1fr;
    }
    .pr-controls {
        position: static;
    }
}

@media (max-width: 640px) {
    .pr-preview-card { padding: 16px; }
    .pr-controls { padding: 18px; }
}
