/* =============================================================
   a4size.uk — Complete Stylesheet
   -------------------------------------------------------------
   Sections:
     1.  Reset & Base
     2.  CSS Variables (Light + Dark)
     3.  Typography
     4.  Layout & Container
     5.  Header (logo, search, actions)
     6.  Unit Dropdown (Header)
     7.  Category Navigation
     8.  Breadcrumb
     9.  Homepage
    10.  Tool Cards
    11.  Size Cards & Grids
    12.  Size Hero (detail page)
    13.  Change Unit dropdown
    14.  Content Sections
    15.  Tables (30+ unit rows)
    16.  Related Categories
    17.  FAQ
    18.  SVG Diagrams
    19.  Compare Tool
    20.  Converter Tool
    21.  Blog (list + single post)
    22.  Legal Pages
    23.  Ad Slots
    24.  Footer
    25.  Buttons
    26.  Error Page
    27.  Responsive
    28.  Print
   ============================================================= */


/* =============================================================
   1. RESET & BASE
   ============================================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
    background: #ffffff;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: #111827;
    background: #ffffff;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
    max-width: 100%;
}

img, svg {
    max-width: 100%;
    display: block;
}

button {
    font-family: inherit;
    cursor: pointer;
}


/* =============================================================
   2. CSS VARIABLES
   ============================================================= */
:root {
    --text:        #111827;
    --text-mid:    #4b5563;
    --text-light:  #6b7280;
    --bg:          #ffffff;
    --card-bg:     #ffffff;
    --border:      #e5e7eb;
    --border-dark: #d1d5db;
    --blue:        #2563eb;
    --blue-hover:  #1d4ed8;
    --red:         #ef4444;
    --green:       #10b981;
    --orange:      #f59e0b;
    --gutter:      20px;
    --radius:      6px;
    --radius-lg:   10px;
}

html[data-theme="dark"] {
    --text:        #f3f4f6;
    --text-mid:    #d1d5db;
    --text-light:  #9ca3af;
    --bg:          #0f172a;
    --card-bg:     #1e293b;
    --border:      #334155;
    --border-dark: #475569;
}

body {
    background: var(--bg);
    color: var(--text);
}


/* =============================================================
   3. TYPOGRAPHY
   ============================================================= */
h1, h2, h3, h4 {
    font-weight: 700;
    color: var(--text);
    line-height: 1.25;
    letter-spacing: -0.02em;
}
h1 { font-size: 2rem; }
h2 { font-size: 1.25rem; margin-bottom: 12px; }
h3 { font-size: 1.05rem; margin-bottom: 10px; }
h4 { font-size: 1rem; }
p  { color: var(--text-mid); margin-bottom: 12px; }
p:last-child { margin-bottom: 0; }
a  { color: var(--text); text-decoration: none; }
a:hover { text-decoration: none; }
ul, ol { padding-left: 22px; color: var(--text-mid); }
li { margin-bottom: 6px; }
strong { color: var(--text); font-weight: 600; }
code {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.88em;
}


/* =============================================================
   4. LAYOUT & CONTAINER
   ============================================================= */
.container {
    width: 100%;
    margin: 0 auto;
    padding: 0 var(--gutter);
    max-width: 1280px;
    position: relative;
    z-index: 1;
}

main {
    min-height: 60vh;
    padding-bottom: 40px;
    position: relative;
    z-index: 1;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--blue);
    color: #fff;
    padding: 10px 16px;
    z-index: 999;
}
.skip-link:focus { left: 0; color: #fff; }

.visually-hidden {
    position: absolute !important;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


/* =============================================================
   5. HEADER
   ============================================================= */
.site-header {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 1000;
    overflow: visible !important;
}

.header-inner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px var(--gutter);
    max-width: 1280px;
    margin: 0 auto;
    min-height: 60px;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
    flex-shrink: 0;
    letter-spacing: -0.02em;
}
.logo svg { color: var(--text); }

.header-search {
    position: relative;
    flex: 1;
    max-width: 300px;
    margin-left: auto;
    display: flex;
    align-items: center;
}
.header-search > svg {
    position: absolute;
    left: 14px;
    color: var(--text-light);
    pointer-events: none;
}
.header-search input {
    width: 100%;
    padding: 8px 14px 8px 36px;
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    outline: none;
    transition: border-color 0.15s;
}
.header-search input:focus { border-color: var(--text); }

.search-results {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
    max-height: 320px;
    overflow-y: auto;
    z-index: 9999;
    display: none;
}
.search-results.is-open { display: block; }
.search-results a {
    display: block;
    padding: 10px 14px;
    color: var(--text);
    font-size: 0.9rem;
    border-bottom: 1px solid var(--border);
}
.search-results a:last-child { border-bottom: 0; }
.search-results a:hover { background: var(--border); }
.search-results .sr-empty {
    padding: 10px 14px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.header-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 12px;
    font-size: 0.82rem;
    font-family: inherit;
    font-weight: 500;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 20px;
    color: var(--text);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
    text-decoration: none;
}
.header-btn:hover {
    background: var(--card-bg);
    text-decoration: none;
}
.header-icon { padding: 7px 9px; }


/* =============================================================
   6. UNIT DROPDOWN (Header)
   ============================================================= */
.unit-dropdown { position: relative; }

.unit-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    max-height: 420px;
    overflow-y: auto;
    padding: 6px;
    z-index: 9999;
    animation: unitFadeIn 0.15s ease;
}

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

.unit-option {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    background: transparent;
    border: 0;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.1s, color 0.1s;
    position: relative;
}
.unit-option:hover { background: var(--border); }
.unit-option.is-active {
    background: var(--text);
    color: var(--bg);
    font-weight: 600;
}
.unit-option.is-active::before {
    content: "✓";
    position: absolute;
    right: 12px;
    font-size: 0.75rem;
}

.unit-menu::-webkit-scrollbar { width: 6px; }
.unit-menu::-webkit-scrollbar-track { background: transparent; }
.unit-menu::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 3px;
}
.unit-menu::-webkit-scrollbar-thumb:hover { background: var(--text-light); }


/* =============================================================
   7. CATEGORY NAVIGATION
   ============================================================= */
.cat-nav {
    border-top: 1px solid var(--border);
    background: var(--bg);
    position: relative;
    z-index: 200;
    overflow: visible;
}

.cat-nav-inner {
    display: flex;
    gap: 6px;
    padding: 10px var(--gutter);
    max-width: 1280px;
    margin: 0 auto;
    overflow-x: auto;
    scrollbar-width: none;
    align-items: center;
    position: relative;
}
.cat-nav-inner::-webkit-scrollbar { display: none; }

.cat-tab {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    white-space: nowrap;
    transition: all 0.15s;
    flex-shrink: 0;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
}
.cat-tab:hover { background: var(--card-bg); text-decoration: none; }
.cat-tab.is-active { border-color: var(--text); font-weight: 600; }

/* More dropdown */
.cat-more-menu {
    position: fixed;
    top: 0;
    left: 0;
    background-color: #ffffff;
    color: #111827;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.25),
        0 8px 20px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(0, 0, 0, 0.03);
    padding: 8px;
    max-height: 70vh;
    overflow-y: auto;
    z-index: 2147483647;
    min-width: 240px;
    width: 260px;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.15s ease, transform 0.15s ease;
    pointer-events: none;
}
.cat-more-menu.is-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}
.cat-more-menu[hidden] { display: none; }

.cat-more-menu a {
    display: block;
    padding: 10px 14px;
    font-size: 0.88rem;
    font-weight: 500;
    color: #111827;
    background-color: transparent;
    border-radius: 6px;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.1s, color 0.1s;
    cursor: pointer;
}
.cat-more-menu a:hover,
.cat-more-menu a:focus {
    background-color: #f3f4f6;
    color: #111827;
    outline: none;
    text-decoration: none;
}
.cat-more-menu a.is-active {
    background-color: #111827;
    color: #ffffff;
    font-weight: 600;
}
.cat-more-menu::-webkit-scrollbar { width: 6px; }
.cat-more-menu::-webkit-scrollbar-track { background: transparent; }
.cat-more-menu::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
.cat-more-menu::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

html[data-theme="dark"] .cat-more-menu {
    background-color: #1e293b;
    color: #f3f4f6;
    border-color: #334155;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 8px 20px rgba(0, 0, 0, 0.4),
        0 0 0 1px rgba(255, 255, 255, 0.05);
}
html[data-theme="dark"] .cat-more-menu a { color: #f3f4f6; }
html[data-theme="dark"] .cat-more-menu a:hover,
html[data-theme="dark"] .cat-more-menu a:focus {
    background-color: #334155;
    color: #f3f4f6;
}
html[data-theme="dark"] .cat-more-menu a.is-active {
    background-color: #f3f4f6;
    color: #111827;
}
html[data-theme="dark"] .cat-more-menu::-webkit-scrollbar-thumb {
    background: #475569;
}


/* =============================================================
   8. BREADCRUMB
   ============================================================= */
.breadcrumb {
    padding: 16px 0 4px;
    font-size: 0.82rem;
    color: var(--text-light);
}
.breadcrumb ol {
    list-style: none;
    padding: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.breadcrumb li + li::before {
    content: "/";
    margin-right: 6px;
    color: var(--text-light);
}
.breadcrumb a { color: var(--text-light); }
.breadcrumb a:hover { color: var(--text); }

.size-label-top {
    font-size: 0.8rem;
    color: var(--text-light);
    margin: 16px 0 8px;
}


/* =============================================================
   9. HOMEPAGE
   ============================================================= */
.intro-text {
    font-size: 1rem;
    color: var(--text-mid);
    padding: 20px 0 8px;
    max-width: 720px;
    line-height: 1.6;
}

.category-section {
    margin: 24px 0;
    position: relative;
    z-index: 1;
}

.category-title {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.92rem;
    font-weight: 500;
    margin-bottom: 10px;
}
.category-title a {
    color: var(--text-mid);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.category-title a:hover { color: var(--text); }
.category-title .arrow { color: var(--text-light); font-size: 0.85rem; }

.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}


/* =============================================================
   10. TOOL CARDS (Popular Tools)
   ============================================================= */
.popular-tools {
    margin: 32px 0;
}

.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 16px;
    margin-top: 12px;
}

.tool-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.15s;
}
.tool-card:hover {
    border-color: var(--blue);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
    text-decoration: none;
}
.tool-icon {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--blue);
    line-height: 1;
}
.tool-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}
.tool-desc {
    font-size: 0.82rem;
    color: var(--text-light);
}


/* =============================================================
   11. SIZE CARDS & GRIDS
   ============================================================= */
.home-grid,
.sizes-grid,
.sizes-grid-4 {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    align-items: stretch;
    width: 100%;
}

.size-card {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    aspect-ratio: 1 / 0.7;
    padding: 8px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    transition: all 0.15s;
    overflow: hidden;
    min-width: 0;
    width: 100%;
    box-sizing: border-box;
    min-height: 60px;
}
.size-card:hover {
    border-color: var(--text);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
    text-decoration: none;
}

.size-name {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1.1;
    letter-spacing: -0.03em;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.size-dim {
    font-size: 0.68rem;
    color: var(--text-light);
    margin-top: 4px;
    line-height: 1.3;
}

.size-unit { color: var(--text-light); }

.size-card-viewall {
    justify-content: center;
    align-items: center;
    text-align: center;
    background: var(--card-bg);
}
.viewall-text {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}
.viewall-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border: 1.5px solid var(--text-light);
    border-radius: 50%;
    font-size: 0.8rem;
    color: var(--text-light);
    line-height: 1;
    transition: all 0.15s;
}
.size-card-viewall:hover .viewall-arrow {
    border-color: var(--text);
    color: var(--text);
}


/* =============================================================
   12. SIZE HERO (detail page)
   ============================================================= */
.cat-h1 {
    font-size: 2rem;
    margin: 20px 0 24px;
}

.size-hero { margin: 12px 0 24px; }

.size-hero-row {
    display: flex;
    gap: 24px;
    align-items: flex-start;
    margin-top: 16px;
    flex-wrap: wrap;
}

.size-visual {
    width: 100px;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 16px;
    flex-shrink: 0;
}
.size-visual-box {
    width: 100%;
    height: 100%;
    background: var(--bg);
    border: 1.5px solid var(--text);
}

.size-hero-info { flex: 1; min-width: 200px; }

.size-hero-dim {
    font-size: 1.15rem;
    color: var(--text);
    font-weight: 500;
    margin-bottom: 12px;
}

.size-hero-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.8rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text);
    font-family: inherit;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
}
.btn-ghost:hover {
    background: var(--card-bg);
    text-decoration: none;
}


/* =============================================================
   13. CHANGE UNIT DROPDOWN
   ============================================================= */
.change-unit-wrap {
    position: relative;
    display: inline-block;
}
.change-unit-wrap .btn-ghost { gap: 6px; }

.change-unit-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.15);
    min-width: 220px;
    max-height: 420px;
    overflow-y: auto;
    padding: 6px;
    z-index: 9999;
    animation: unitFadeIn 0.15s ease;
}
.change-unit-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    background: transparent;
    border: 0;
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text);
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.1s, color 0.1s;
    position: relative;
}
.change-unit-menu button:hover { background: var(--border); }
.change-unit-menu button.is-active {
    background: var(--text);
    color: var(--bg);
    font-weight: 600;
}
.change-unit-menu button.is-active::before {
    content: "✓";
    position: absolute;
    right: 12px;
    font-size: 0.75rem;
}
.change-unit-menu::-webkit-scrollbar { width: 6px; }
.change-unit-menu::-webkit-scrollbar-track { background: transparent; }
.change-unit-menu::-webkit-scrollbar-thumb {
    background: var(--border-dark);
    border-radius: 3px;
}


/* =============================================================
   14. CONTENT SECTIONS
   ============================================================= */
.content-section { margin: 40px 0; }

.info-block {
    margin: 32px 0;
    padding: 20px 0;
    border-top: 1px solid var(--border);
}
.info-block h2 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-light);
    margin-bottom: 12px;
    font-weight: 600;
}
.info-block p {
    font-size: 0.9rem;
    line-height: 1.7;
    max-width: 900px;
    color: var(--text-mid);
}


/* =============================================================
   15. TABLES (30+ unit rows)
   ============================================================= */
.table-block {
    margin: 32px 0;
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
}

.table-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    padding: 14px 16px 0;
    margin: 0;
}

.sizes-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}
.sizes-table th,
.sizes-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.sizes-table th {
    font-weight: 500;
    font-size: 0.82rem;
    color: var(--text-light);
}
.sizes-table tr:last-child td { border-bottom: 0; }
.sizes-table a {
    color: var(--text);
    font-weight: 500;
}
.sizes-table a:hover { color: var(--blue); }
.sizes-table-units td:first-child { color: var(--text-light); }

/* Unit group header */
.unit-group-header td {
    background: var(--card-bg);
    border-top: 2px solid var(--border);
    border-bottom: 1px solid var(--border);
    font-size: 0.72rem !important;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-light) !important;
    font-weight: 700;
    padding: 12px 16px !important;
}
.unit-group-header td:first-child { color: var(--text-light) !important; }


/* =============================================================
   16. RELATED CATEGORIES
   ============================================================= */
.related-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.related-cat {
    display: inline-flex;
    align-items: center;
    padding: 8px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text);
    text-decoration: none;
    transition: all 0.15s;
}
.related-cat:hover {
    border-color: var(--text);
    background: var(--bg);
    text-decoration: none;
}


/* =============================================================
   17. FAQ
   ============================================================= */
.faq-section { margin: 40px 0; }

.faq-item {
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
}
.faq-item:first-of-type { border-top: 1px solid var(--border); }

.faq-item summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--text);
    list-style: none;
    padding: 4px 24px 4px 0;
    position: relative;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: "";
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%) rotate(45deg);
    width: 8px;
    height: 8px;
    border-right: 1.5px solid var(--text-light);
    border-bottom: 1.5px solid var(--text-light);
    transition: transform 0.2s;
}
.faq-item[open] summary::after {
    transform: translateY(-50%) rotate(-135deg);
}
.faq-item p {
    margin-top: 10px;
    font-size: 0.88rem;
    color: var(--text-mid);
    line-height: 1.65;
}


/* =============================================================
   18. SVG DIAGRAMS
   ============================================================= */
.svg-nest {
    display: flex;
    justify-content: center;
    margin: 24px 0;
    padding: 20px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    max-width: 500px;
}
.svg-nest svg {
    width: 100%;
    max-width: 420px;
    height: auto;
    display: block;
}
.svg-nest rect { stroke: var(--text); fill: none; }
.svg-nest text {
    fill: var(--text);
    font-size: 11px;
    font-family: inherit;
    font-weight: 500;
}

.category-diagram {
    display: flex;
    justify-content: center;
    margin: 24px 0 32px;
    padding: 24px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.category-diagram svg {
    width: 100%;
    max-width: 520px;
    height: auto;
    display: block;
}


/* =============================================================
   19. COMPARE TOOL
   ============================================================= */
.compare-unit-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin: 8px 0 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.compare-unit-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-mid);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

.compare-unit-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.unit-pill {
    padding: 6px 14px;
    font-size: 0.82rem;
    font-family: inherit;
    font-weight: 500;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}
.unit-pill:hover {
    border-color: var(--text);
    background: var(--card-bg);
}
.unit-pill.is-active {
    background: var(--text);
    color: var(--bg);
    border-color: var(--text);
    font-weight: 600;
}

.compare-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    margin: 24px 0 32px;
    align-items: start;
}

.compare-form {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.compare-label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-mid);
    margin-top: 10px;
}

.compare-select {
    width: 100%;
    padding: 10px 14px;
    font-size: 0.9rem;
    font-family: inherit;
    color: var(--text);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    outline: none;
    transition: border-color 0.15s;
}
.compare-select:focus { border-color: var(--text); }

.compare-visual {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    overflow: hidden;
}
.compare-box {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    border: 2px solid var(--text);
    border-radius: 2px;
    transition: all 0.3s ease;
}
.compare-box-a {
    background: rgba(37, 99, 235, 0.12);
    border-color: #2563eb;
}
.compare-box-b {
    background: rgba(239, 68, 68, 0.12);
    border-color: #ef4444;
}
.compare-box-label {
    position: absolute;
    top: 4px;
    left: 6px;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text);
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 3px;
    white-space: nowrap;
    z-index: 2;
}

.compare-summary {
    margin: 32px 0;
    padding: 24px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.compare-summary-title {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text);
}
.compare-summary-text {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text-mid);
    margin: 0;
}


/* =============================================================
   20. CONVERTER TOOL
   ============================================================= */
.converter-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 24px;
    margin: 24px 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.converter-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.converter-row label {
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-mid);
}
.converter-row input,
.converter-row select {
    padding: 10px 12px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s;
}
.converter-row input:focus,
.converter-row select:focus {
    border-color: var(--blue);
}

.converter-buttons {
    grid-column: 1 / -1;
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.btn-primary {
    padding: 10px 20px;
    background: var(--blue);
    color: #fff;
    border: 0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary:hover { background: var(--blue-hover); }

.converter-results { margin: 24px 0; }
.converter-results h2 { margin-bottom: 12px; }

.converter-formula {
    font-size: 0.82rem;
    color: var(--text-light);
    margin-top: 12px;
    padding: 10px 14px;
    background: var(--card-bg);
    border-radius: 6px;
}

.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
    margin-top: 12px;
}
.preset-btn {
    padding: 10px 14px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: all 0.15s;
    text-decoration: none;
    display: block;
}
.preset-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
    text-decoration: none;
}
.preset-btn.is-active {
    border-color: var(--blue);
    background: rgba(37, 99, 235, 0.08);
    color: var(--blue);
}
.preset-dim {
    display: block;
    font-size: 0.72rem;
    color: var(--text-light);
    font-weight: 400;
    margin-top: 4px;
}

.converter-results table tr[data-unit-row] { display: table-row; }
.converter-results table td:first-child {
    color: var(--text-light);
    white-space: nowrap;
}
.converter-results table td:last-child {
    color: var(--text);
    font-weight: 500;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
}


/* =============================================================
   21. BLOG
   ============================================================= */

/* Listing */
.blog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin: 24px 0 40px;
}

.blog-card {
    display: flex;
    flex-direction: column;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    text-decoration: none;
    color: var(--text);
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}
.blog-card:hover {
    transform: translateY(-3px);
    border-color: var(--text-light);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
    text-decoration: none;
}

.blog-card-diagram {
    aspect-ratio: 4 / 3;
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    overflow: hidden;
}
.blog-card-diagram svg {
    width: 100%;
    height: 100%;
    max-height: 220px;
}

.blog-card-body {
    padding: 18px 20px 20px;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.blog-cat {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--blue);
    margin-bottom: 8px;
}
.blog-card-body h3 {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 8px;
    color: var(--text);
}
.blog-card-body p {
    font-size: 0.88rem;
    line-height: 1.55;
    color: var(--text-mid);
    flex: 1;
    margin-bottom: 12px;
}
.blog-card-meta {
    font-size: 0.72rem;
    color: var(--text-light);
    font-weight: 500;
}

/* Single post */
.blog-post {
    max-width: 720px;
    margin: 0 auto;
    padding: 16px 0 60px;
    font-size: 1.0625rem;
    line-height: 1.7;
    color: var(--text-mid);
}

.blog-post-header {
    margin-bottom: 32px;
    text-align: center;
}

.blog-post-meta {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 16px;
    font-weight: 500;
    letter-spacing: 0.02em;
}
.blog-post-meta .blog-cat {
    color: var(--blue);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.72rem;
    margin: 0;
}
.blog-post-meta .dot {
    color: var(--text-light);
    opacity: 0.5;
}

.blog-post-title {
    font-size: 2.25rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.025em;
    margin: 0 0 16px;
    color: var(--text);
}

.blog-post-excerpt {
    font-size: 1.125rem;
    line-height: 1.55;
    color: var(--text-mid);
    margin: 0 auto;
    max-width: 620px;
    font-weight: 400;
}

.blog-post-diagram {
    margin: 40px 0;
    padding: 32px 24px;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.blog-post-diagram svg {
    width: 100%;
    max-width: 520px;
    height: auto;
    display: block;
}

.blog-post-content {
    font-size: 1.0625rem;
    line-height: 1.75;
    color: var(--text-mid);
}
.blog-post-content > *:first-child { margin-top: 0; }
.blog-post-content > *:last-child  { margin-bottom: 0; }

.blog-post-content p {
    margin: 0 0 20px;
    color: var(--text-mid);
    font-size: 1.0625rem;
    line-height: 1.75;
}
.blog-post-content h2 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: -0.015em;
    margin: 48px 0 16px;
    color: var(--text);
    scroll-margin-top: 80px;
}
.blog-post-content h3 {
    font-size: 1.1875rem;
    font-weight: 600;
    line-height: 1.4;
    margin: 32px 0 12px;
    color: var(--text);
    scroll-margin-top: 80px;
}
.blog-post-content h4 {
    font-size: 1.05rem;
    font-weight: 600;
    margin: 24px 0 10px;
    color: var(--text);
}
.blog-post-content ul,
.blog-post-content ol {
    margin: 0 0 22px;
    padding-left: 26px;
    color: var(--text-mid);
}
.blog-post-content li {
    margin-bottom: 10px;
    line-height: 1.7;
}
.blog-post-content li strong {
    color: var(--text);
    font-weight: 600;
}
.blog-post-content strong {
    color: var(--text);
    font-weight: 600;
}
.blog-post-content em {
    font-style: italic;
    color: var(--text-mid);
}
.blog-post-content a {
    color: var(--blue);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
    transition: opacity 0.15s;
}
.blog-post-content a:hover { opacity: 0.75; }
.blog-post-content blockquote {
    margin: 24px 0;
    padding: 4px 0 4px 20px;
    border-left: 3px solid var(--blue);
    color: var(--text-mid);
    font-style: italic;
}
.blog-post-content hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 40px 0;
}
.blog-post-content img,
.blog-post-content svg {
    margin: 24px auto;
    border-radius: 8px;
    max-width: 100%;
    height: auto;
}
.blog-post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 24px 0;
    font-size: 0.95rem;
}
.blog-post-content table th,
.blog-post-content table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}
.blog-post-content table th {
    color: var(--text);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.blog-post-footer {
    margin-top: 56px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.blog-post-footer p {
    font-size: 0.82rem;
    color: var(--text-light);
    margin: 0;
    line-height: 1.5;
    max-width: 70%;
}
.blog-post-footer p strong {
    color: var(--text-mid);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    display: block;
    margin-bottom: 4px;
}
.blog-post-footer .btn {
    padding: 10px 20px;
    font-size: 0.85rem;
    background: var(--text);
    color: var(--bg);
    border: 1px solid var(--text);
    border-radius: 6px;
    font-weight: 500;
    transition: opacity 0.15s;
    flex-shrink: 0;
}
.blog-post-footer .btn:hover {
    opacity: 0.85;
    text-decoration: none;
    color: var(--bg);
}


/* =============================================================
   22. LEGAL PAGES
   ============================================================= */
.legal-page {
    max-width: 820px;
    margin: 0 auto;
    padding: 8px 0 48px;
}
.legal-content h2 {
    font-size: 1.5rem;
    margin: 28px 0 12px;
}
.legal-content h3 {
    font-size: 1.05rem;
    margin: 22px 0 8px;
    color: var(--text);
    font-weight: 600;
}
.legal-content p {
    font-size: 0.95rem;
    line-height: 1.75;
    color: var(--text-mid);
    margin-bottom: 12px;
}
.legal-content ul {
    padding-left: 22px;
    margin: 10px 0 16px;
}
.legal-content li {
    font-size: 0.93rem;
    line-height: 1.7;
    color: var(--text-mid);
    margin-bottom: 6px;
}
.legal-content a {
    color: var(--blue);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.legal-content strong { color: var(--text); font-weight: 600; }
.legal-content em {
    color: var(--text-light);
    font-style: normal;
    font-size: 0.85rem;
}


/* =============================================================
   23. AD SLOTS
   ============================================================= */
.ad-slot {
    margin: 32px auto;
    width: 100%;
    max-width: 100%;
    text-align: center;
    min-height: 100px;
    overflow: hidden;
}
.ad-slot[data-label]::before {
    content: attr(data-label);
    display: block;
    font-size: 0.68rem;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-bottom: 6px;
}
.ad-slot ins.adsbygoogle {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    min-height: 100px !important;
}


/* =============================================================
   24. FOOTER
   ============================================================= */
.site-footer {
    margin-top: 60px;
    padding: 24px 0;
    border-top: 1px solid var(--border);
    font-size: 0.8rem;
    color: var(--text-light);
    background: var(--bg);
}
.footer-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
    padding: 0 var(--gutter);
    max-width: 1280px;
    margin: 0 auto;
}
.footer-left {
    display: flex;
    gap: 16px;
    align-items: center;
    flex-wrap: wrap;
}
.footer-left a { color: var(--text-light); }
.footer-left a:hover { color: var(--text); }
.footer-right {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.footer-right a {
    color: var(--text-light);
    font-size: 0.78rem;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
}
.footer-right a.is-active {
    color: var(--text);
    font-weight: 700;
}
.footer-right a:hover { color: var(--text); }


/* =============================================================
   25. BUTTONS
   ============================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    padding: 10px 18px;
    background: var(--text);
    color: var(--bg);
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    text-decoration: none;
    transition: opacity 0.15s;
}
.btn:hover {
    opacity: 0.9;
    text-decoration: none;
    color: var(--bg);
}


/* =============================================================
   26. ERROR PAGE
   ============================================================= */
.error-page {
    text-align: center;
    padding: 60px 20px;
}
.error-page h1 {
    font-size: 4rem;
    color: var(--text);
    margin: 0 0 12px;
    line-height: 1;
}
.error-page p {
    font-size: 1.05rem;
    color: var(--text-mid);
    margin-bottom: 24px;
}


/* =============================================================
   27. RESPONSIVE
   ============================================================= */

@media (max-width: 1280px) {
    .home-grid,
    .sizes-grid,
    .sizes-grid-4 {
        grid-template-columns: repeat(5, minmax(0, 1fr));
        gap: 7px;
    }
    .size-card { min-height: 58px; padding: 7px; }
}

@media (max-width: 1024px) {
    .home-grid,
    .sizes-grid,
    .sizes-grid-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
        gap: 7px;
    }
    .size-card { min-height: 58px; padding: 7px; }
}

@media (max-width: 860px) {
    .home-grid,
    .sizes-grid,
    .sizes-grid-4 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 6px;
    }
    .size-card { min-height: 55px; padding: 7px; }
}

@media (max-width: 768px) {
    .blog-post { font-size: 1rem; padding: 8px 0 40px; }
    .blog-post-title { font-size: 1.75rem; }
    .blog-post-excerpt { font-size: 1.05rem; }
    .blog-post-diagram { padding: 20px 14px; margin: 28px 0; }
    .blog-post-content { font-size: 1rem; }
    .blog-post-content h2 { font-size: 1.3rem; margin: 36px 0 12px; }
    .blog-post-content h3 { font-size: 1.1rem; margin: 28px 0 10px; }
    .blog-post-footer {
        flex-direction: column;
        align-items: stretch;
        text-align: left;
    }
    .blog-post-footer p { max-width: 100%; }
    .blog-post-footer .btn {
        text-align: center;
        justify-content: center;
    }
    .converter-card { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
    :root { --gutter: 14px; }

    .header-inner {
        flex-wrap: wrap;
        padding: 10px var(--gutter);
    }
    .logo { font-size: 0.95rem; }
    .header-search {
        flex: 1;
        max-width: none;
        order: 3;
        width: 100%;
        margin-top: 4px;
        margin-left: 0;
    }
    .header-actions {
        order: 2;
        gap: 4px;
        margin-left: auto;
    }
    .header-btn span { display: none; }
    .header-btn { padding: 7px 9px; }

    .home-grid,
    .sizes-grid,
    .sizes-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 6px;
    }
    .size-card { padding: 7px; min-height: 55px; }

    .cat-h1 { font-size: 1.5rem; }
    .cat-h1.blog-post-title { font-size: 1.5rem; }

    .footer-inner { flex-direction: column; align-items: flex-start; }

    .sizes-table th,
    .sizes-table td {
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .size-visual { width: 90px; height: 120px; }
    .size-hero-dim { font-size: 1rem; }

    /* Compare */
    .compare-grid { grid-template-columns: 1fr; gap: 20px; }
    .compare-unit-row { gap: 8px; }
    .compare-unit-label {
        width: 100%;
        margin-bottom: 4px;
    }
    .unit-pill { padding: 6px 10px; font-size: 0.75rem; }
    .compare-summary { padding: 18px; }
    .compare-summary-text { font-size: 0.88rem; }

    /* Blog grid stacks */
    .blog-grid { grid-template-columns: 1fr; gap: 18px; }

    /* Legal */
    .legal-content h2 { font-size: 1.25rem; }
    .legal-content h3 { font-size: 1rem; }

    /* Fixed bottom-sheet for unit dropdowns on mobile */
    .unit-menu,
    .change-unit-menu {
        position: fixed;
        top: auto;
        bottom: 20px;
        left: 14px;
        right: 14px;
        width: auto;
        max-width: none;
        min-width: 0;
        max-height: 60vh;
    }
}

@media (max-width: 480px) {
    .home-grid,
    .sizes-grid,
    .sizes-grid-4 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px;
    }
    .size-card { padding: 6px; min-height: 50px; }
    .tool-grid { grid-template-columns: 1fr; }
    .preset-grid { grid-template-columns: 1fr 1fr; }

    .converter-card { padding: 16px; }
    .converter-buttons {
        flex-direction: column;
    }
    .converter-buttons button {
        width: 100%;
        justify-content: center;
    }
}


/* =============================================================
   28. PRINT
   ============================================================= */
@media print {
    .site-header,
    .site-footer,
    .ad-slot,
    .cat-nav,
    .header-search,
    .compare-unit-row,
    .size-hero-actions,
    .converter-buttons,
    .preset-grid {
        display: none !important;
    }
    body {
        background: #fff;
        color: #000;
    }
    .container { padding: 0; max-width: 100%; }
    .table-block {
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }
    .sizes-table th,
    .sizes-table td {
        border-bottom: 1px solid #ccc;
    }
    a { color: #000; text-decoration: none; }
}