/* ==========================================================================
   WebTools design system — precompiled, zero build step.
   Signature: category "spine" system. Every card, heading and tool page
   carries its category hue via the --cat custom property.
   Mobile-first: designed at 375px, scales up at 640 / 768 / 1024.
   ========================================================================== */

:root {
    --paper: #F5F6F8;
    --surface: #FFFFFF;
    --ink: #171A21;
    --ink-soft: #5A6072;
    --line: #E3E5EB;
    --brand: #171A21;
    --cat: #3B82F6;                 /* overridden per category */
    --radius: 14px;
    --shadow: 0 1px 2px rgba(20,22,28,.06), 0 6px 20px rgba(20,22,28,.05);
    --font-display: 'Bricolage Grotesque', system-ui, sans-serif;
    --font-body: 'Inter', system-ui, -apple-system, sans-serif;
}

.dark {
    --paper: #101218;
    --surface: #181B23;
    --ink: #EDEFF4;
    --ink-soft: #9AA1B2;
    --line: #262A35;
    --brand: #EDEFF4;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: var(--font-body);
    font-size: 16px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--paper);
    min-height: 100vh;
    min-height: 100dvh; /* iOS Safari 100vh quirk */
}
img { max-width: 100%; height: auto; }
a { color: inherit; }

.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 0 16px; }

.skip-link {
    position: absolute; left: -9999px; top: 0;
    background: var(--ink); color: var(--paper); padding: 10px 16px; z-index: 100;
}
.skip-link:focus { left: 0; }

/* ---------- Header & Mobile Responsive Navigation ---------- */
.site-header { background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 50; }
.header-inner { display: flex; align-items: center; gap: 10px; min-height: 56px; }
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font-family: var(--font-display); font-weight: 800; font-size: 19px; white-space: nowrap; }
.brand-mark { color: var(--cat); font-size: 22px; line-height: 1; }
.header-search { flex: 1; min-width: 0; }
.header-search input {
    width: 100%; min-height: 44px; padding: 0 14px;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--paper); color: var(--ink); font-size: 15px;
}
.header-search input:focus { outline: 2px solid var(--cat); outline-offset: 1px; }

.header-actions-desktop { display: flex; align-items: center; gap: 8px; }

.theme-toggle {
    min-width: 44px; min-height: 44px; border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); color: var(--ink); cursor: pointer; font-size: 17px;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.theme-icon-dark { display: none; }
.dark .theme-icon-dark { display: inline; }
.dark .theme-icon-light { display: none; }

.nav-burger {
    display: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px;
    background: var(--surface); color: var(--ink); cursor: pointer; flex-shrink: 0;
    align-items: center; justify-content: center; flex-direction: column; gap: 4px; padding: 0;
}
.nav-burger span { display: block; width: 18px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform .2s ease, opacity .2s ease; }
body.nav-open .nav-burger span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
body.nav-open .nav-burger span:nth-child(2) { opacity: 0; }
body.nav-open .nav-burger span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

.mobile-nav-drawer {
    display: none; background: var(--surface); border-top: 1px solid var(--line);
    padding: 12px 16px 16px; box-shadow: 0 10px 20px rgba(0,0,0,0.08);
}
body.nav-open .mobile-nav-drawer { display: block; }
.mobile-nav-link {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px;
    text-decoration: none; font-size: 14.5px; font-weight: 600; color: var(--ink);
    border-radius: 8px; background: var(--paper); border: 1px solid var(--line);
}
.mobile-nav-link:hover { background: color-mix(in srgb, var(--cat) 10%, var(--surface)); color: var(--cat); }

@media (max-width: 991px) {
    .header-actions-desktop { display: none !important; }
    .nav-burger { display: flex !important; }
}

/* Category nav — horizontal scroll on mobile, no squeezing */
.cat-nav { border-top: 1px solid var(--line); background: var(--surface); }
.cat-nav-inner { display: flex; gap: 4px; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.cat-nav-inner::-webkit-scrollbar { display: none; }
.cat-link {
    display: flex; align-items: center; min-height: 44px; padding: 0 14px;
    text-decoration: none; font-size: 14px; font-weight: 500; color: var(--ink-soft);
    border-bottom: 3px solid transparent; white-space: nowrap;
}
.cat-link:hover, .cat-link.active { color: var(--ink); border-bottom-color: var(--cat); }

/* ---------- Hero ---------- */
.hero { padding: 20px 0 12px; }
.hero-title {
    font-family: var(--font-display); font-weight: 800;
    font-size: clamp(30px, 7vw, 52px); line-height: 1.05; letter-spacing: -0.02em;
}
.hero-accent {
    background: linear-gradient(90deg, #8B5CF6, #F43F5E, #F59E0B, #10B981, #06B6D4, #3B82F6, #EC4899);
    -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { margin-top: 8px; color: var(--ink-soft); max-width: 560px; }

/* ---------- Sections & tool grid ---------- */
.section-title {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--font-display); font-weight: 700; font-size: 20px;
    margin: 16px 0 12px;
}
.section-spine { width: 5px; height: 22px; border-radius: 3px; background: var(--cat); }

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

.tool-card {
    display: flex; gap: 12px; align-items: flex-start;
    background: var(--surface); border: 1px solid var(--line);
    border-left: 5px solid var(--cat);
    border-radius: var(--radius); padding: 14px;
    text-decoration: none; box-shadow: var(--shadow);
    transition: transform .12s ease, border-color .12s ease;
    min-height: 44px;
}
.tool-card:active { transform: scale(.985); }
.tool-chip {
    flex: none; width: 40px; height: 40px; border-radius: 10px;
    display: grid; place-items: center;
    font-family: var(--font-display); font-weight: 800; font-size: 17px;
    color: var(--cat); background: color-mix(in srgb, var(--cat) 14%, transparent);
}
.tool-name { display: block; font-weight: 600; font-size: 15px; }
.tool-desc { display: block; color: var(--ink-soft); font-size: 13.5px; margin-top: 2px; }

/* ---------- Tool page ---------- */
.tool-page { padding-bottom: 96px; } /* room for sticky button */
.tool-ribbon { height: 5px; border-radius: 3px; background: var(--cat); margin: 16px 0 20px; }
.crumbs { font-size: 13px; color: var(--ink-soft); margin-bottom: 8px; }
.crumbs a { color: inherit; }
.tool-header h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(24px, 5vw, 36px); letter-spacing: -0.01em; }
.tool-lede { color: var(--ink-soft); margin-top: 6px; }

.tool-layout { display: grid; grid-template-columns: 1fr; gap: 20px; margin-top: 20px; }
.tool-main { min-width: 0; }

.tool-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }

.upload-zone {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    border: 2px dashed color-mix(in srgb, var(--cat) 45%, var(--line));
    border-radius: var(--radius); padding: 32px 16px; text-align: center;
    cursor: pointer; background: color-mix(in srgb, var(--cat) 4%, transparent);
}
.upload-zone input[type=file] { position: absolute; width: 1px; height: 1px; opacity: 0; }
.upload-zone:focus-within { outline: 2px solid var(--cat); outline-offset: 2px; }
.upload-icon { font-size: 30px; color: var(--cat); }
.upload-text small { color: var(--ink-soft); }

.field-row { display: grid; grid-template-columns: 1fr; gap: 14px; margin-top: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.field select, .field input[type=text], .field input[type=url], .field input[type=email],
.field input[type=number], .field input[type=password], .field input[type=search], .field textarea {
    min-height: 44px; padding: 10px 12px; font-size: 16px; /* 16px prevents iOS zoom */
    border: 1px solid var(--line); border-radius: 10px;
    background: var(--paper); color: var(--ink); font-family: inherit;
}
.field textarea { resize: vertical; }
.field :is(select, input, textarea):focus { outline: 2px solid var(--cat); outline-offset: 1px; }
.field input[type=range] { min-height: 44px; accent-color: var(--cat); }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; }
.check input { width: 20px; height: 20px; accent-color: var(--cat); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px; padding: 0 20px;
    border: 1px solid var(--line); border-radius: 999px;
    background: var(--surface); color: var(--ink);
    font: 600 15px var(--font-body); text-decoration: none; cursor: pointer;
}
.btn-primary { background: var(--cat); border-color: var(--cat); color: #fff; }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: 13.5px; }
.btn-download { background: var(--cat); border-color: var(--cat); color: #fff; width: 100%; }
.btn:focus-visible { outline: 2px solid var(--cat); outline-offset: 2px; }
.btn:disabled { opacity: .6; cursor: wait; }

/* Sticky bottom action on mobile tool pages */
.btn-sticky {
    position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 40;
    width: auto; box-shadow: 0 8px 24px rgba(0,0,0,.22);
}

/* Loading state — spinner replaces label */
.btn-spinner {
    display: none; width: 18px; height: 18px; border-radius: 50%;
    border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff;
    animation: spin .7s linear infinite;
}
.btn.is-loading .btn-spinner { display: inline-block; }
.btn.is-loading .btn-label { opacity: .75; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- Alerts / results ---------- */
.alert { border-radius: var(--radius); padding: 14px 16px; margin: 14px 0; font-size: 14.5px; }
.alert-error { background: color-mix(in srgb, #F43F5E 12%, var(--surface)); border: 1px solid color-mix(in srgb, #F43F5E 40%, var(--line)); }
.alert-success { background: color-mix(in srgb, #10B981 12%, var(--surface)); border: 1px solid color-mix(in srgb, #10B981 40%, var(--line)); }
.result-block .btn-download { margin: 10px 0 6px; }
.fineprint { font-size: 12.5px; color: var(--ink-soft); }
.text-error { color: #E11D48; }
.empty-state { text-align: center; padding: 48px 16px; color: var(--ink-soft); }
.empty-state .btn { margin-top: 14px; }
.ad-zone:empty { display: none; }
.ad-zone { margin: 16px 0; text-align: center; }

/* ---------- Content pages ---------- */
.content-page { padding: 28px 0 48px; max-width: 720px; }
.content-page h1 { font-family: var(--font-display); font-weight: 800; font-size: clamp(26px, 5vw, 38px); margin-bottom: 16px; }
.prose h2 { font-family: var(--font-display); font-size: 20px; margin: 22px 0 8px; }
.prose p { margin: 10px 0; }
.prose a { color: var(--cat); }

/* ---------- Footer ---------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 48px; background: var(--surface); }
.footer-inner { display: flex; flex-direction: column; gap: 10px; padding: 20px 16px; font-size: 13.5px; color: var(--ink-soft); }
.footer-inner nav { display: flex; flex-wrap: wrap; gap: 16px; }
.footer-inner a { min-height: 44px; display: inline-flex; align-items: center; text-decoration: none; }

/* ---------- Cookie banner ---------- */
.cookie-banner {
    position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 60;
    display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
    background: var(--ink); color: var(--paper);
    border-radius: var(--radius); padding: 14px 16px; font-size: 13.5px;
    box-shadow: 0 12px 32px rgba(0,0,0,.3);
}
.cookie-banner a { color: inherit; }
.cookie-banner .btn { background: var(--paper); color: var(--ink); border: none; }

/* ---------- Installer & admin ---------- */
.install-body { display: grid; place-items: start center; padding: 32px 16px; }
.install-card {
    width: 100%; max-width: 520px; background: var(--surface);
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 26px; box-shadow: var(--shadow);
}
.install-brand { font-family: var(--font-display); font-weight: 800; font-size: 22px; margin-bottom: 16px; }
.install-steps { display: flex; gap: 6px; list-style: none; margin-bottom: 20px; font-size: 12.5px; color: var(--ink-soft); flex-wrap: wrap; }
.install-steps li { padding: 4px 10px; border-radius: 999px; background: var(--paper); }
.install-steps li.done { background: color-mix(in srgb, #10B981 16%, var(--paper)); color: var(--ink); }
.install-form { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.install-card .btn { margin-top: 14px; margin-right: 8px; }
.install-done { font-size: 18px; font-weight: 700; color: #10B981; }
.req-list { list-style: none; display: flex; flex-direction: column; gap: 8px; font-size: 14.5px; }
.req-list .ok { color: #10B981; }
.req-list .warn { color: #F59E0B; }
.req-list .fail { color: #E11D48; font-weight: 600; }

.admin-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.admin-nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.admin-nav a { display: flex; align-items: center; min-height: 44px; padding: 0 12px; text-decoration: none; font-size: 14px; color: var(--ink-soft); white-space: nowrap; }
.admin-nav a:hover { color: var(--ink); }
.admin-main { padding: 24px 16px 48px; }
.admin-main h1 { font-family: var(--font-display); font-size: 26px; margin-bottom: 16px; }
.admin-main h2 { font-family: var(--font-display); font-size: 18px; margin: 26px 0 10px; }
.admin-form { display: flex; flex-direction: column; gap: 14px; max-width: 640px; }
.stat-row { display: grid; grid-template-columns: 1fr; gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.stat-num { display: block; font-family: var(--font-display); font-weight: 800; font-size: 28px; }
.stat-label { color: var(--ink-soft); font-size: 13px; }
/* ==========================================================================
   Breakpoints — scale up from 375
   ========================================================================== */
@media (min-width: 640px) {
    .tool-grid { grid-template-columns: repeat(2, 1fr); }
    .stat-row { grid-template-columns: repeat(3, 1fr); }
    .footer-inner { flex-direction: row; justify-content: space-between; align-items: center; }
    .btn-sticky { position: static; box-shadow: none; margin-top: 18px; }
    .tool-page { padding-bottom: 24px; }
    .field-row { grid-template-columns: 1fr 1fr; }
}
@media (min-width: 1024px) {
    .tool-grid { grid-template-columns: repeat(3, 1fr); }
    .tool-layout { grid-template-columns: minmax(0, 1fr) 300px; }
    .hero { padding: 24px 0 16px; }
}

/* ---------- Client-side tool components ---------- */
.io-area { width: 100%; min-height: 160px; padding: 12px; font: 15px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
    border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink); resize: vertical; }
.io-area:focus { outline: 2px solid var(--cat); outline-offset: 1px; }
.btn-group { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 14px 0; }
.chip { background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.chip b { display: block; font-family: var(--font-display); font-size: 20px; color: var(--cat); }
.chip span { font-size: 12.5px; color: var(--ink-soft); }
.out-box { position: relative; margin-top: 14px; }
.out-box .btn-copy { position: absolute; top: 8px; right: 8px; }
.result-line { font-family: var(--font-display); font-weight: 800; font-size: 24px; color: var(--cat); margin: 12px 0; overflow-wrap: anywhere; }
.serp-card { border: 1px solid var(--line); border-radius: 10px; padding: 14px; background: #fff; color: #202124; margin-top: 14px; }
@media (min-width: 640px) { .chip-row { grid-template-columns: repeat(4, 1fr); } }

/* ---------- Responsive Tables & Container Overflows ---------- */
.table-responsive, .admin-table-wrapper, .table-container {
    width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    margin-top: 14px;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    scrollbar-width: thin;
}
.table-responsive::-webkit-scrollbar, .admin-table-wrapper::-webkit-scrollbar {
    height: 5px;
}
.table-responsive::-webkit-scrollbar-thumb, .admin-table-wrapper::-webkit-scrollbar-thumb {
    background: #8B5CF6;
    border-radius: 4px;
}
.admin-table, table.data-table, .table-responsive table {
    width: 100%;
    min-width: 650px;
    border-collapse: collapse;
    background: var(--surface);
    font-size: 14px;
}
.admin-table th, .admin-table td, table.data-table th, table.data-table td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}
.admin-table th, table.data-table th {
    background: var(--paper);
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--ink-soft);
    white-space: nowrap;
}

/* Global Pagination Styling & SVG Constraint */
nav[role="navigation"] svg,
.pagination svg,
.pagination-container svg {
    width: 16px !important;
    height: 16px !important;
    max-width: 16px !important;
    max-height: 16px !important;
    display: inline-block !important;
    vertical-align: middle;
}

/* Global Pagination Styling */
ul.pagination {
    display: flex !important;
    list-style: none !important;
    padding: 0 !important;
    margin: 18px 0 0 0 !important;
    gap: 6px !important;
    align-items: center !important;
    justify-content: flex-start !important;
    flex-wrap: wrap !important;
}

ul.pagination li.page-item {
    margin: 0 !important;
}

ul.pagination li.page-item .page-link,
ul.pagination li.page-item span.page-link {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 36px !important;
    height: 36px !important;
    padding: 0 12px !important;
    border-radius: 8px !important;
    border: 1px solid var(--line) !important;
    background: var(--surface) !important;
    color: var(--ink) !important;
    font-size: 13px !important;
    font-weight: 600 !important;
    text-decoration: none !important;
    transition: all 0.15s ease !important;
}

ul.pagination li.page-item.active .page-link,
ul.pagination li.page-item.active span.page-link {
    background: #8B5CF6 !important;
    color: #ffffff !important;
    border-color: #8B5CF6 !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 6px rgba(139, 92, 246, 0.3) !important;
}

ul.pagination li.page-item:not(.active):not(.disabled) .page-link:hover {
    background: var(--paper) !important;
    border-color: #8B5CF6 !important;
    color: #8B5CF6 !important;
}

ul.pagination li.page-item.disabled .page-link {
    opacity: 0.45 !important;
    cursor: not-allowed !important;
    background: var(--paper) !important;
}




