/* ============================================================
   Nilon Tools — design system
   Light/dark theming via CSS variables on [data-theme]
   ============================================================ */

:root {
    --bg: #f6f7fb;
    --bg-alt: #eef0f7;
    --card: #ffffff;
    --card-hover: #fafbff;
    --text: #1a2036;
    --text-muted: #5b647d;
    --border: #e3e6ef;
    --primary: #5b5bf0;
    --primary-hover: #4646d8;
    --primary-soft: #ecebfe;
    --accent: #0ea5e9;
    --success: #16a34a;
    --success-soft: #dcfce7;
    --warning: #d97706;
    --warning-soft: #fef3c7;
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --shadow: 0 1px 3px rgba(26, 32, 54, .06), 0 4px 14px rgba(26, 32, 54, .06);
    --shadow-lg: 0 4px 10px rgba(26, 32, 54, .08), 0 12px 32px rgba(26, 32, 54, .12);
    --radius: 12px;
    --radius-lg: 16px;
    --header-bg: rgba(255, 255, 255, .92);
    --hero-grad: linear-gradient(135deg, #5b5bf0 0%, #7c3aed 55%, #0ea5e9 120%);
    --code-bg: #f1f3f9;
    color-scheme: light;
}

[data-theme="dark"] {
    --bg: #0f1222;
    --bg-alt: #171b30;
    --card: #1b2038;
    --card-hover: #20264366;
    --text: #e7e9f4;
    --text-muted: #9aa3c0;
    --border: #2a3050;
    --primary: #7c7cf7;
    --primary-hover: #9b9bfa;
    --primary-soft: #262b52;
    --accent: #38bdf8;
    --success: #4ade80;
    --success-soft: #14321f;
    --warning: #fbbf24;
    --warning-soft: #33270e;
    --danger: #f87171;
    --danger-soft: #3b1515;
    --shadow: 0 1px 3px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .25);
    --shadow-lg: 0 4px 10px rgba(0, 0, 0, .35), 0 12px 32px rgba(0, 0, 0, .4);
    --header-bg: rgba(15, 18, 34, .92);
    --code-bg: #12152a;
    color-scheme: dark;
}

/* ---------------- reset & base ---------------- */

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.65;
    color: var(--text);
    background: var(--bg);
    transition: background-color .25s, color .25s;
}

img { max-width: 100%; height: auto; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .6em; }
h1 { font-size: 2rem; }
h2 { font-size: 1.45rem; margin-top: 1.6em; }
h3 { font-size: 1.15rem; margin-top: 1.4em; }
p { margin: 0 0 1em; }
code, pre { font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Consolas, Menlo, monospace; font-size: .9em; }
pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.container { max-width: 1200px; margin: 0 auto; padding: 0 20px; }

.skip-link {
    position: absolute; left: -9999px; top: 0; z-index: 200;
    background: var(--primary); color: #fff; padding: 8px 16px; border-radius: 0 0 8px 0;
}
.skip-link:focus { left: 0; }

/* ---------------- header ---------------- */

.site-header {
    position: sticky; top: 0; z-index: 100;
    background: var(--header-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}

.header-top-inner { display: flex; align-items: center; gap: 18px; height: 62px; }

.site-logo { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.25rem; color: var(--text); flex-shrink: 0; }
.site-logo:hover { text-decoration: none; }
.logo-mark {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--hero-grad); color: #fff; font-weight: 900; font-size: 1.1rem;
}

.header-search { position: relative; flex: 1; max-width: 460px; display: flex; align-items: center; }
.search-ico { position: absolute; left: 12px; color: var(--text-muted); pointer-events: none; }
.header-search input, .mobile-search input {
    width: 100%; padding: 9px 14px 9px 38px;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--bg-alt); color: var(--text); font-size: .95rem;
}
.mobile-search input { padding-left: 14px; }
.header-search input:focus, .mobile-search input:focus { border-color: var(--primary); background: var(--card); }

.search-results {
    position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 120;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); max-height: 380px; overflow-y: auto; padding: 6px;
}
.search-results a {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px;
    border-radius: 8px; color: var(--text); font-size: .93rem;
}
.search-results a:hover, .search-results a.active { background: var(--primary-soft); text-decoration: none; }
.search-results .sr-cat { margin-left: auto; font-size: .75rem; color: var(--text-muted); white-space: nowrap; }
.search-results .sr-none { padding: 12px; color: var(--text-muted); font-size: .9rem; }

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

.theme-toggle {
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 10px;
    border: 1px solid var(--border); background: var(--card); color: var(--text);
    cursor: pointer; transition: border-color .15s;
}
.theme-toggle:hover { border-color: var(--primary); }
[data-theme="light"] .ico-moon { display: none; }
[data-theme="dark"] .ico-sun { display: none; }

.nav-burger { display: none; flex-direction: column; justify-content: center; gap: 5px; width: 40px; height: 40px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); cursor: pointer; padding: 0 9px; }
.nav-burger span { display: block; height: 2px; border-radius: 2px; background: var(--text); transition: transform .2s, opacity .2s; }
.nav-burger[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.nav-burger[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-burger[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

/* category nav + dropdowns */
.cat-nav { border-top: 1px solid var(--border); }
.cat-nav-inner { display: flex; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
.cat-nav-inner::-webkit-scrollbar { display: none; }
.nav-item { position: relative; flex-shrink: 0; }
.nav-item > a {
    display: flex; align-items: center; gap: 5px;
    padding: 10px 13px; font-size: .88rem; font-weight: 600; color: var(--text-muted); white-space: nowrap;
}
.nav-item > a:hover { color: var(--primary); text-decoration: none; }
.nav-dropdown {
    position: absolute; top: 100%; left: 0; z-index: 110; min-width: 260px;
    background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-lg); padding: 8px;
    opacity: 0; visibility: hidden; transform: translateY(6px);
    transition: opacity .15s, transform .15s, visibility .15s;
}
.nav-item:hover .nav-dropdown, .nav-item:focus-within .nav-dropdown { opacity: 1; visibility: visible; transform: translateY(0); }
.nav-dropdown a { display: flex; align-items: center; gap: 9px; padding: 8px 11px; border-radius: 8px; color: var(--text); font-size: .9rem; }
.nav-dropdown a:hover { background: var(--primary-soft); text-decoration: none; }
.dd-ico { width: 20px; text-align: center; flex-shrink: 0; }

/* mobile nav */
.mobile-nav { border-top: 1px solid var(--border); background: var(--card); max-height: calc(100vh - 62px); overflow-y: auto; padding: 12px 16px 24px; }
.mobile-search { position: relative; margin-bottom: 10px; }
.m-cat { border-bottom: 1px solid var(--border); }
.m-cat-toggle {
    display: flex; justify-content: space-between; align-items: center; width: 100%;
    background: none; border: 0; color: var(--text); font-size: 1rem; font-weight: 600;
    padding: 13px 4px; cursor: pointer;
}
.m-cat-toggle svg { transition: transform .2s; }
.m-cat-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
.m-cat-tools { padding: 0 4px 12px; display: flex; flex-direction: column; gap: 2px; }
.m-cat-tools a { padding: 7px 10px; border-radius: 8px; color: var(--text-muted); font-size: .93rem; }
.m-cat-tools a:hover { background: var(--primary-soft); color: var(--primary); text-decoration: none; }
.m-cat-all { font-weight: 600; color: var(--primary) !important; }

/* ---------------- hero ---------------- */

.hero { background: var(--hero-grad); color: #fff; padding: 64px 0 72px; text-align: center; }
.hero h1 { font-size: clamp(1.7rem, 4.5vw, 2.7rem); font-weight: 800; margin-bottom: .4em; }
.hero-accent { display: block; background: linear-gradient(90deg, #fbbf24, #f472b6, #a78bfa); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; color: transparent; }
.hero-image { display: block; margin: 0 auto .6em; max-width: 100%; width: auto; object-fit: contain; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.hero p { font-size: clamp(1rem, 2vw, 1.15rem); opacity: .92; max-width: 640px; margin: 0 auto 1.8em; }
.hero-search { position: relative; max-width: 560px; margin: 0 auto; }
.hero-search input {
    width: 100%; padding: 16px 22px; font-size: 1.05rem;
    border: 0; border-radius: 14px; box-shadow: var(--shadow-lg);
    background: #fff; color: #1a2036;
}
.hero-search .search-results { text-align: left; }
.hero-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 26px; }
.hero-badges span { background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25); padding: 6px 14px; border-radius: 999px; font-size: .85rem; }

/* ---------------- cards & grids ---------------- */

.section { padding: 48px 0; }
.section-alt { background: var(--bg-alt); }
.section-title { text-align: center; font-size: 1.7rem; margin-bottom: 8px; }
.section-sub { text-align: center; color: var(--text-muted); max-width: 560px; margin: 0 auto 34px; }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); gap: 18px; }

.cat-card, .tool-card {
    display: block; background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 22px; color: var(--text);
    box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s, border-color .15s;
}
.cat-card:hover, .tool-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--primary); text-decoration: none; }
.card-ico {
    display: inline-flex; align-items: center; justify-content: center;
    width: 46px; height: 46px; font-size: 1.4rem; border-radius: 12px;
    background: var(--primary-soft); margin-bottom: 14px;
}
.cat-card h3, .tool-card h3 { margin: 0 0 6px; font-size: 1.05rem; }
.cat-card p, .tool-card p { margin: 0; color: var(--text-muted); font-size: .9rem; line-height: 1.5; }
.cat-card .card-count { display: inline-block; margin-top: 12px; font-size: .8rem; font-weight: 600; color: var(--primary); }

/* ---------------- breadcrumbs ---------------- */

.breadcrumbs { padding: 16px 0 0; font-size: .85rem; color: var(--text-muted); }
.breadcrumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; }
.breadcrumbs li + li::before { content: "›"; margin-right: 6px; color: var(--text-muted); }
.breadcrumbs a { color: var(--text-muted); }
.breadcrumbs a:hover { color: var(--primary); }
.breadcrumbs [aria-current] { color: var(--text); font-weight: 600; }

/* ---------------- tool page layout ---------------- */

.page-head { padding: 10px 0 4px; }
.page-head h1 { margin-bottom: 6px; }
.page-head .page-lead { color: var(--text-muted); max-width: 760px; }

.tool-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; align-items: start; padding-bottom: 48px; }
.tool-main { min-width: 0; }
.tool-aside { display: flex; flex-direction: column; gap: 20px; position: sticky; top: 90px; }

.tool-panel {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 24px;
}

.related-box { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow); }
.related-box h2 { font-size: 1rem; margin: 0 0 12px; }
.related-box a { display: flex; gap: 10px; align-items: center; padding: 8px 10px; margin: 0 -10px; border-radius: 8px; color: var(--text); font-size: .92rem; }
.related-box a:hover { background: var(--primary-soft); text-decoration: none; }

.seo-content { max-width: 800px; padding: 8px 0 24px; }
.seo-content h2 { font-size: 1.4rem; }
.seo-content ul, .seo-content ol { padding-left: 22px; }
.seo-content li { margin-bottom: .35em; }

/* FAQ */
.faq-list { max-width: 800px; }
.faq-item { border: 1px solid var(--border); border-radius: var(--radius); background: var(--card); margin-bottom: 10px; }
.faq-item summary { cursor: pointer; font-weight: 600; padding: 14px 18px; list-style: none; display: flex; justify-content: space-between; gap: 10px; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; font-size: 1.2rem; color: var(--primary); font-weight: 700; }
.faq-item[open] summary::after { content: "–"; }
.faq-item .faq-a { padding: 0 18px 14px; color: var(--text-muted); }

/* ---------------- forms & tool widgets ---------------- */

.nt-input, textarea.nt-input, select.nt-input {
    width: 100%; padding: 11px 14px; font-size: .95rem; font-family: inherit;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--bg-alt); color: var(--text);
    transition: border-color .15s;
}
.nt-input:focus { border-color: var(--primary); outline: none; background: var(--card); }
textarea.nt-input { min-height: 190px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Consolas, Menlo, monospace; line-height: 1.55; }
textarea.nt-input.nt-prose { font-family: inherit; }
select.nt-input { cursor: pointer; }
input[type="color"].nt-color { width: 46px; height: 40px; padding: 3px; border: 1px solid var(--border); border-radius: 8px; background: var(--card); cursor: pointer; }
input[type="range"].nt-range { width: 100%; accent-color: var(--primary); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--primary); width: 16px; height: 16px; }

.field { margin-bottom: 16px; }
.field > label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 6px; }
.field-row { display: flex; flex-wrap: wrap; gap: 14px; align-items: end; }
.field-row .field { flex: 1; min-width: 140px; margin-bottom: 0; }
.check-row { display: flex; flex-wrap: wrap; gap: 14px 22px; margin: 12px 0; }
.check-row label { display: inline-flex; align-items: center; gap: 7px; font-size: .93rem; cursor: pointer; }

.io-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.io-grid .io-label { font-weight: 600; font-size: .9rem; margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 11px 22px; font-size: .95rem; font-weight: 600; font-family: inherit;
    border: 0; border-radius: 10px; cursor: pointer;
    background: var(--primary); color: #fff;
    transition: background .15s, transform .1s;
}
.btn:hover { background: var(--primary-hover); text-decoration: none; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-secondary { background: var(--bg-alt); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-sm { padding: 6px 13px; font-size: .84rem; border-radius: 8px; }
.btn-danger { background: var(--danger); }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 16px 0 4px; }

.result-box {
    margin-top: 18px; padding: 16px 18px;
    background: var(--code-bg); border: 1px solid var(--border); border-radius: var(--radius);
    font-family: ui-monospace, SFMono-Regular, Consolas, Menlo, monospace; font-size: .92rem;
    white-space: pre-wrap; word-break: break-word; position: relative; min-height: 30px;
}
.result-plain { font-family: inherit; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-top: 18px; }
.stat-card { background: var(--bg-alt); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; text-align: center; }
.stat-card .stat-val { font-size: 1.5rem; font-weight: 800; color: var(--primary); line-height: 1.2; }
.stat-card .stat-label { font-size: .78rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }

.alert { padding: 12px 16px; border-radius: 10px; margin: 14px 0; font-size: .93rem; }
.alert-error { background: var(--danger-soft); color: var(--danger); border: 1px solid var(--danger); }
.alert-success { background: var(--success-soft); color: var(--success); border: 1px solid var(--success); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border: 1px solid var(--warning); }

.dropzone {
    display: block; /* labels are inline by default — an inline border fragments per text line */
    border: 2px dashed var(--border); border-radius: var(--radius-lg);
    padding: 40px 20px; text-align: center; cursor: pointer;
    color: var(--text-muted); transition: border-color .15s, background .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--primary); background: var(--primary-soft); }
.dropzone .dz-ico { font-size: 2.2rem; display: block; margin-bottom: 8px; }
.dropzone input[type="file"] { display: none; }
.file-list { margin: 14px 0 0; padding: 0; list-style: none; display: flex; flex-direction: column; gap: 8px; }
.file-list li { display: flex; align-items: center; gap: 10px; background: var(--bg-alt); border: 1px solid var(--border); border-radius: 10px; padding: 9px 13px; font-size: .9rem; }
.file-list .fl-size { color: var(--text-muted); font-size: .8rem; }
.file-list .fl-remove { margin-left: auto; background: none; border: 0; color: var(--danger); cursor: pointer; font-size: 1rem; }

.preview-box {
    display: flex; align-items: center; justify-content: center;
    min-height: 180px; border-radius: var(--radius); border: 1px solid var(--border);
    background:
        linear-gradient(45deg, rgba(128,128,128,.12) 25%, transparent 25%, transparent 75%, rgba(128,128,128,.12) 75%),
        linear-gradient(45deg, rgba(128,128,128,.12) 25%, transparent 25%, transparent 75%, rgba(128,128,128,.12) 75%);
    background-size: 20px 20px; background-position: 0 0, 10px 10px;
    padding: 24px; margin: 14px 0;
}

.nt-table { width: 100%; border-collapse: collapse; font-size: .92rem; margin: 14px 0; }
.nt-table th, .nt-table td { padding: 9px 12px; border: 1px solid var(--border); text-align: left; }
.nt-table th { background: var(--bg-alt); font-weight: 600; }
.nt-table tr:nth-child(even) td { background: var(--bg-alt); }

.tabs { display: flex; gap: 6px; border-bottom: 2px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs button {
    background: none; border: 0; padding: 9px 16px; font: inherit; font-weight: 600; font-size: .92rem;
    color: var(--text-muted); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -2px; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }

.copy-feedback { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(80px); z-index: 300; background: var(--text); color: var(--bg); padding: 10px 22px; border-radius: 999px; font-size: .9rem; font-weight: 600; box-shadow: var(--shadow-lg); transition: transform .25s; }
.copy-feedback.show { transform: translateX(-50%) translateY(0); }

/* ---------------- ads ---------------- */

.ad-slot { display: flex; justify-content: center; padding: 10px 16px; overflow: hidden; }

/* ---------------- footer ---------------- */

.site-footer { background: var(--bg-alt); border-top: 1px solid var(--border); margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 36px; padding: 44px 20px 30px; }
.footer-brand { display: flex; align-items: center; gap: 9px; font-weight: 800; font-size: 1.15rem; margin-bottom: 12px; }
.footer-about p { color: var(--text-muted); font-size: .92rem; max-width: 380px; }
.footer-heading { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); margin: 4px 0 14px; }
.footer-col ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.footer-col a { color: var(--text); font-size: .93rem; }
.footer-col a:hover { color: var(--primary); }
.footer-bottom { border-top: 1px solid var(--border); padding: 16px 0; }
.footer-bottom p { margin: 0; font-size: .85rem; color: var(--text-muted); text-align: center; }

/* ---------------- misc pages ---------------- */

.prose { max-width: 800px; padding: 8px 0 40px; }
.prose h2 { font-size: 1.35rem; }

.error-page { text-align: center; padding: 70px 20px; }
.error-page .err-code { font-size: 5rem; font-weight: 900; background: var(--hero-grad); -webkit-background-clip: text; background-clip: text; color: transparent; line-height: 1; }

.sitemap-cols { columns: 3; column-gap: 36px; padding-bottom: 40px; }
.sitemap-cols section { break-inside: avoid; margin-bottom: 22px; }
.sitemap-cols h2 { font-size: 1.05rem; margin: 0 0 8px; }
.sitemap-cols ul { list-style: none; margin: 0; padding: 0; }
.sitemap-cols li { padding: 3px 0; }

/* ---------------- responsive ---------------- */

@media (max-width: 1000px) {
    .tool-layout { grid-template-columns: 1fr; }
    .tool-aside { position: static; }
    .footer-grid { grid-template-columns: 1fr 1fr; }
    .sitemap-cols { columns: 2; }
}

@media (max-width: 760px) {
    .cat-nav { display: none; }
    .nav-burger { display: flex; }
    .header-search { display: none; }
    .io-grid { grid-template-columns: 1fr; }
    .hero { padding: 44px 0 52px; }
    .section { padding: 34px 0; }
    h1 { font-size: 1.55rem; }
    .footer-grid { grid-template-columns: 1fr; gap: 26px; }
    .sitemap-cols { columns: 1; }
    .tool-panel { padding: 18px 16px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}
