/* Multitool base stylesheet — light/dark, mobile-first, self-hosted (strict CSP). */

:root {
    --bg: #f6f8fb;
    --surface: #ffffff;
    --text: #1a2233;
    --muted: #5b6676;
    --border: #e3e8ef;
    --primary: #0d6efd;
    --primary-ink: #ffffff;
    --accent: #0aa06e;
    --radius: 12px;
    --shadow: 0 1px 3px rgba(16, 24, 40, 0.06), 0 1px 2px rgba(16, 24, 40, 0.04);
    --maxw: 1080px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f141b;
        --surface: #161d27;
        --text: #e7ecf3;
        --muted: #9aa7b8;
        --border: #26303d;
        --primary: #4c9dff;
        --primary-ink: #06111f;
        --shadow: none;
    }
}

:root[data-theme="dark"] {
    --bg: #0f141b;
    --surface: #161d27;
    --text: #e7ecf3;
    --muted: #9aa7b8;
    --border: #26303d;
    --primary: #4c9dff;
    --primary-ink: #06111f;
    --shadow: none;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 16px; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); margin: 0.6em 0 0.3em; }
h2 { font-size: 1.35rem; margin: 1.4em 0 0.5em; }

/* Header */
.site-header { background: var(--surface); border-bottom: 1px solid var(--border); }
.site-header__inner { display: flex; align-items: center; gap: 16px; padding: 12px 16px; }
.site-header__logo { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); }
.site-header__mark { font-size: 1.4rem; }
.site-search { flex: 1; display: flex; max-width: 480px; }
.site-search input { flex: 1; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px 0 0 8px; background: var(--bg); color: var(--text); }
.site-search button { padding: 0 14px; border: 1px solid var(--border); border-left: 0; border-radius: 0 8px 8px 0; background: var(--surface); cursor: pointer; }
.theme-toggle { border: 1px solid var(--border); background: var(--surface); border-radius: 8px; width: 40px; height: 40px; cursor: pointer; font-size: 1.1rem; }

/* Nav */
.site-nav { background: var(--surface); border-bottom: 1px solid var(--border); overflow-x: auto; }
.site-nav__inner { display: flex; gap: 4px; padding: 6px 16px; }
.site-nav__link { white-space: nowrap; padding: 8px 12px; border-radius: 8px; color: var(--muted); font-size: 0.92rem; }
.site-nav__link:hover { background: var(--bg); color: var(--text); text-decoration: none; }

/* Hero */
.hero { padding: 28px 0 8px; }
.hero__lead { color: var(--muted); max-width: 60ch; }

/* Grids */
.category-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin: 18px 0; }
.category-card { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); }
.category-card:hover { border-color: var(--primary); text-decoration: none; }
.category-card i { font-size: 1.5rem; color: var(--primary); }

.tool-section { margin: 26px 0; }
.tool-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.tool-card { display: flex; flex-direction: column; gap: 4px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); }
.tool-card:hover { border-color: var(--primary); text-decoration: none; transform: translateY(-1px); }
.tool-card i { color: var(--primary); font-size: 1.2rem; }
.tool-card__name { font-weight: 600; }
.tool-card__desc { color: var(--muted); font-size: 0.88rem; }
.tool-card.is-hidden { display: none; }

/* Cards / tool app */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.tool { margin: 18px 0; }
.tool__lead { color: var(--muted); }
.tool__app { margin: 16px 0; }
.prose { max-width: 72ch; }
.prose code { background: var(--bg); padding: 1px 5px; border-radius: 5px; }

/* Forms */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 0.9rem; font-weight: 600; margin-bottom: 5px; }
.field input, .field select { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font-size: 1rem; }
.field--split { display: grid; grid-template-columns: 2fr 1fr; gap: 12px; }
.tool-filter { margin: 14px 0; }
.tool-filter input { width: 100%; max-width: 420px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); }

.btn { display: inline-block; padding: 10px 16px; border-radius: 8px; border: 1px solid transparent; font-weight: 600; cursor: pointer; font-size: 1rem; }
.btn--primary { background: var(--primary); color: var(--primary-ink); }
.btn--primary:hover { filter: brightness(1.05); text-decoration: none; }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn--block { display: block; width: 100%; }

/* Result */
.result { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.result__headline { display: flex; align-items: baseline; justify-content: space-between; }
.result__value { font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.result__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 14px 0; }
.result__grid dt { color: var(--muted); font-size: 0.85rem; }
.result__grid dd { margin: 2px 0 0; font-weight: 600; }

/* Breadcrumb */
.breadcrumb ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 12px 0; color: var(--muted); font-size: 0.88rem; }
.breadcrumb li:not(:last-child)::after { content: "/"; margin-left: 6px; color: var(--border); }

/* FAQ */
.tool__faq details { border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; margin-bottom: 8px; background: var(--surface); }
.tool__faq summary { font-weight: 600; cursor: pointer; }

/* Ads (reserved space, zero CLS) */
.ad-zone { display: block; margin: 16px 0; background: var(--bg); border: 1px dashed var(--border); border-radius: 8px; }
.ad-zone--sticky_mobile { position: sticky; bottom: 0; }

/* Footer */
.site-footer { margin-top: 40px; background: var(--surface); border-top: 1px solid var(--border); }
.site-footer__inner { padding: 24px 16px; display: flex; flex-direction: column; gap: 8px; align-items: center; text-align: center; }
.site-footer__links { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.site-footer__copy { color: var(--muted); font-size: 0.85rem; }

/* Admin / auth */
.admin__topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
.admin__brand { font-weight: 700; color: var(--text); }
.admin__user { display: flex; align-items: center; gap: 12px; }
.admin__body { padding: 20px 16px; }
.admin__hint { color: var(--muted); }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.stat-card { padding: 18px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-card__num { display: block; font-size: 1.8rem; font-weight: 700; }
.stat-card__label { color: var(--muted); font-size: 0.85rem; }

.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth__card { width: 100%; max-width: 360px; }
.alert { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.alert--error { background: #fdecea; color: #a12b21; border: 1px solid #f5c2bd; }

.error-page__inner { padding: 60px 0; text-align: center; }
.error-page__inner h1 { font-size: 4rem; margin: 0; }
.error-page__detail { text-align: left; overflow: auto; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.empty-state { color: var(--muted); }

/* Tables + programmatic-SEO pages */
.table-wrap { overflow-x: auto; }
.pseo__table table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.pseo__table th, .pseo__table td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.pseo__table th { color: var(--muted); font-size: 0.85rem; }
.pseo__chart canvas { display: block; width: 100%; margin: 8px 0; }
.pseo__reco ul { padding-left: 18px; }
.pseo__reco li { margin: 6px 0; }
.pseo__siblings ul { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.pseo__siblings a { display: inline-block; padding: 6px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); }
.pseo__cta { margin: 20px 0; }

/* Embed / widget mode */
body.embed { background: var(--surface); }
body.embed .breadcrumb, body.embed .tool__intro, body.embed .tool__howto,
body.embed .tool__faq, body.embed .related-tools, body.embed .ad-zone { display: none !important; }
body.embed main.container { padding: 12px; }
.embed__attrib { text-align: center; font-size: 0.8rem; padding: 8px; margin: 0; }
.widget-list { display: grid; gap: 16px; margin: 18px 0; }
.widget-item__label { display: block; font-size: 0.85rem; font-weight: 600; margin: 10px 0 4px; }
.widget-item__code { width: 100%; font-family: ui-monospace, "SF Mono", monospace; font-size: 0.8rem; padding: 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); resize: vertical; }

@media print {
    .site-header, .site-nav, .site-footer, .ad-zone, .tool-form, [data-print] { display: none !important; }
}
