/* ==========================================================================
   UtilityStation — design system (static CSS, no CDN)
   ========================================================================== */

:root {
  --bg: #f7f8fb;
  --panel: #ffffff;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --brand: #4f46e5;
  --brand-ink: #3730a3;
  --brand-soft: #eef2ff;
  --ok: #047857;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #b91c1c;
  --danger-soft: #fef2f2;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 10px 28px -14px rgba(15, 23, 42, .22);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --max: 1180px;
}

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

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--ink-2);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  color: var(--ink);
  line-height: 1.25;
  margin: 0 0 .5rem;
  font-weight: 800;
  letter-spacing: -.015em;
}
h1 { font-size: 1.85rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .85rem; }
a { color: var(--brand-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
img, svg { max-width: 100%; }
hr { border: 0; border-top: 1px solid var(--line); margin: 1.5rem 0; }
code, kbd, samp, pre { font-family: var(--mono); font-size: .875em; }
code { background: #f1f5f9; padding: .12em .38em; border-radius: 5px; color: #1e293b; }
pre { background: #0f172a; color: #e2e8f0; padding: 1rem; border-radius: var(--radius-sm); overflow: auto; }
pre code { background: none; color: inherit; padding: 0; }
ul, ol { padding-left: 1.35rem; margin: 0 0 .9rem; }
li { margin-bottom: .3rem; }
table { border-collapse: collapse; width: 100%; }
strong { color: var(--ink); }
[hidden] { display: none !important; }

/* ---------- layout ---------- */
.container { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.container-narrow { max-width: 820px; }
main { flex: 1 0 auto; }
.stack > * + * { margin-top: 1rem; }
.stack-lg > * + * { margin-top: 1.75rem; }

/* ---------- header ---------- */
.site-header {
  position: sticky; top: 0; z-index: 40;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-header .container {
  display: flex; align-items: center; justify-content: space-between;
  gap: 14px; min-height: 62px;
}
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.06rem; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 9px; background: linear-gradient(140deg, #6366f1, #4338ca);
  color: #fff; font: 700 12px/1 var(--mono);
}
.brand-badge {
  font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px;
  background: var(--ok-soft); color: var(--ok); border: 1px solid #a7f3d0;
}
.header-nav { display: flex; align-items: center; gap: 16px; }
.header-nav a { font-size: 13.5px; font-weight: 600; color: var(--muted); }
.header-nav a:hover { color: var(--brand); text-decoration: none; }

/* ---------- language switch ---------- */
.lang-switch { display: inline-flex; padding: 2px; gap: 1px; background: #f1f5f9; border: 1px solid var(--line); border-radius: 9px; }
.lang-switch button {
  border: 0; background: transparent; cursor: pointer;
  font: 700 11.5px/1 var(--font); letter-spacing: .04em;
  color: var(--muted); padding: 6px 9px; border-radius: 7px;
}
.lang-switch button:hover { color: var(--ink); }
.lang-switch button[aria-pressed="true"] { background: #fff; color: var(--brand); box-shadow: 0 1px 3px rgba(15, 23, 42, .12); }

/* ---------- hero ---------- */
.hero { padding: 2.5rem 0 1rem; }
.hero h1 { font-size: 2.15rem; margin-bottom: .5rem; }
.hero .lede { font-size: 1.02rem; color: var(--muted); max-width: 62ch; margin-bottom: 1.35rem; }
.hero-search { position: relative; max-width: 560px; }
.hero-search .input { padding-left: 40px; height: 46px; font-size: 15px; }
.hero-search .search-icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 9px 16px; border-radius: var(--radius-sm);
  border: 1px solid transparent; font: 700 13.5px/1.35 var(--font);
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { text-decoration: none; }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(79, 70, 229, .35); }
.btn-primary:hover:not(:disabled) { background: var(--brand-ink); }
.btn-secondary { background: #fff; color: var(--ink-2); border-color: var(--line-strong); }
.btn-secondary:hover:not(:disabled) { background: #f8fafc; border-color: var(--brand); color: var(--brand-ink); }
.btn-ghost { background: transparent; color: var(--brand-ink); }
.btn-ghost:hover:not(:disabled) { background: var(--brand-soft); }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fee2e2; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.label { font-size: 11.5px; font-weight: 700; letter-spacing: .045em; text-transform: uppercase; color: var(--muted); }
.input, .select, .textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm); background: #fff; color: var(--ink);
  font: 400 14px/1.45 var(--font); min-height: 40px;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(79, 70, 229, .16);
}
.input::placeholder, .textarea::placeholder { color: #94a3b8; }
.input:disabled, .textarea:disabled, .select:disabled { background: #f8fafc; color: var(--muted); }
.textarea { min-height: 132px; resize: vertical; line-height: 1.55; }
.textarea-mono, .input-mono { font-family: var(--mono); font-size: 13px; }
.hint { font-size: 12px; color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: 13.5px; color: var(--ink-2); cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--brand); }
input[type="range"] { width: 100%; accent-color: var(--brand); }
input[type="color"] { width: 52px; height: 38px; padding: 2px; border: 1px solid var(--line-strong); border-radius: 8px; background: #fff; cursor: pointer; }

/* ---------- grid helpers ---------- */
.grid { display: grid; gap: 14px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.spacer { flex: 1 1 auto; }

/* ---------- panels ---------- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.4rem;
}
.card-flat { box-shadow: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 1rem; }
.card-head h2, .card-head h3 { margin: 0; }

.out {
  background: var(--brand-soft); border: 1px solid #c7d2fe;
  border-radius: var(--radius-sm); padding: 12px 14px;
  font-family: var(--mono); font-size: 14px; color: var(--brand-ink);
  word-break: break-word; white-space: pre-wrap;
}
.out-lg { font-size: 1.35rem; font-weight: 700; }
.out:empty { display: none; }

.alert { border-radius: var(--radius-sm); padding: 11px 14px; font-size: 13.5px; border: 1px solid; }
.alert-info { background: var(--brand-soft); border-color: #c7d2fe; color: var(--brand-ink); }
.alert-ok { background: var(--ok-soft); border-color: #a7f3d0; color: var(--ok); }
.alert-warn { background: var(--warn-soft); border-color: #fde68a; color: var(--warn); }
.alert-danger { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 11px; font-weight: 700; background: var(--brand-soft);
  color: var(--brand-ink); border: 1px solid #c7d2fe;
}
.badge-ok { background: var(--ok-soft); color: var(--ok); border-color: #a7f3d0; }
.badge-muted { background: #f1f5f9; color: var(--muted); border-color: var(--line); }
.badge-mono { font-family: var(--mono); }

/* ---------- tool grid ---------- */
.tool-grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(255px, 1fr)); }
.tool-card {
  display: flex; flex-direction: column; gap: 8px;
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 16px; color: inherit;
  transition: border-color .16s, box-shadow .16s, transform .16s;
}
.tool-card:hover { text-decoration: none; border-color: #a5b4fc; box-shadow: var(--shadow); transform: translateY(-1px); }
.tc-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.tc-icon { font-size: 20px; line-height: 1; }
.tc-id { font: 700 11px/1 var(--mono); color: #94a3b8; }
.tool-card h3 { margin: 0; font-size: .96rem; color: var(--ink); }
.tool-card:hover h3 { color: var(--brand-ink); }
.tool-card p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

.cat-bar { display: flex; flex-wrap: wrap; gap: 8px; margin: 1.25rem 0 1.5rem; }
.cat-pill {
  border: 1px solid var(--line); background: #fff; color: var(--ink-2);
  border-radius: 999px; padding: 6px 13px; font: 600 12.5px/1.3 var(--font); cursor: pointer;
}
.cat-pill:hover { border-color: #a5b4fc; color: var(--brand-ink); }
.cat-pill.active { background: var(--brand); border-color: var(--brand); color: #fff; }

.category-block { margin-bottom: 2rem; }
.category-block h2 { display: flex; align-items: center; gap: 9px; font-size: 1.02rem; }
.category-block h2::before { content: ""; width: 4px; height: 17px; border-radius: 2px; background: var(--brand); }

/* ---------- tool page ---------- */
.tool-head { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 1.2rem; }
.tool-head .ti { font-size: 26px; line-height: 1.2; }
.tool-head h1 { font-size: 1.6rem; margin-bottom: .2rem; }
.tool-head p { margin: 0; color: var(--muted); font-size: .94rem; }
.breadcrumb { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); padding: 14px 0 4px; flex-wrap: wrap; }
.breadcrumb a { color: var(--muted); font-weight: 600; }
.breadcrumb a:hover { color: var(--brand); text-decoration: none; }
.breadcrumb .sep { color: #cbd5e1; }

.ad-slot { margin: 1.5rem 0; text-align: center; min-height: 96px; }
.ad-slot .ad-label { font-size: 10px; letter-spacing: .1em; text-transform: uppercase; color: #94a3b8; margin-bottom: 4px; }
.ad-slot ins { display: block; }

.prose { color: var(--ink-2); font-size: .945rem; }
.prose h2 { font-size: 1.15rem; margin-top: 1.5rem; }
.prose h3 { font-size: 1rem; margin-top: 1.25rem; }
.prose > :first-child { margin-top: 0; }

.faq details {
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; background: #fff; margin-bottom: 9px;
}
.faq details[open] { border-color: #c7d2fe; }
.faq summary { cursor: pointer; font-weight: 700; color: var(--ink); font-size: .94rem; }
.faq summary::marker { color: var(--brand); }
.faq details p { margin: .6rem 0 0; font-size: .9rem; color: var(--muted); }

.related { display: grid; gap: 11px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.related a {
  display: block; border: 1px solid var(--line); border-radius: var(--radius-sm);
  padding: 12px 14px; background: #fff; color: inherit;
}
.related a:hover { border-color: #a5b4fc; text-decoration: none; }
.related .rt { display: flex; align-items: center; gap: 7px; font-weight: 700; font-size: .875rem; color: var(--ink); margin-bottom: 3px; }
.related p { margin: 0; font-size: 12px; color: var(--muted); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius-sm); }
.table { font-size: 13px; background: #fff; }
.table th, .table td { padding: 8px 11px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th { background: #f8fafc; font-weight: 700; color: var(--ink); font-size: 11.5px; letter-spacing: .03em; text-transform: uppercase; }
.table tr:last-child td { border-bottom: 0; }
.table td.n { font-family: var(--mono); text-align: right; }

/* ---------- footer ---------- */
.site-footer { border-top: 1px solid var(--line); background: #fff; margin-top: 3rem; padding: 2rem 0 1.5rem; font-size: 12.5px; color: var(--muted); }
.footer-grid { display: grid; gap: 1.5rem; grid-template-columns: 1.5fr 1fr 1fr; }
.footer-grid h4 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #94a3b8; margin-bottom: .6rem; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer-grid li { margin-bottom: .35rem; }
.footer-grid a { color: var(--ink-2); }
.footer-bottom { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 10px; margin-top: 1.5rem; padding-top: 1.1rem; border-top: 1px solid var(--line); font-size: 12px; }

/* ---------- consent ---------- */
.consent {
  position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 90;
  max-width: 640px; margin: 0 auto; background: #fff;
  border: 1px solid var(--line-strong); border-radius: var(--radius);
  box-shadow: 0 18px 48px -12px rgba(15, 23, 42, .32);
  padding: 15px 17px; font-size: 13px;
}
.consent p { margin: 0 0 .8rem; color: var(--ink-2); }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  z-index: 100; background: #0f172a; color: #f8fafc;
  font: 600 13px/1.4 var(--font); padding: 10px 18px; border-radius: 999px;
  box-shadow: 0 14px 34px -8px rgba(15, 23, 42, .5);
  animation: toast-in .18s ease-out;
  pointer-events: none;
}
.toast.is-out { opacity: 0; transition: opacity .4s; }
@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, 8px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- data table scroll on mobile ---------- */
.scroll-x { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* ---------- misc ---------- */
.hidden { display: none !important; }
.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; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; padding: 3px 9px; border-radius: 999px; background: #f1f5f9; color: var(--ink-2); }
.swatch { width: 100%; height: 64px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.canvas-wrap { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 12px; background: #fff; display: flex; justify-content: center; overflow: auto; }
.canvas-wrap canvas, .canvas-wrap img { max-width: 100%; height: auto; }

/* ---------- responsive ---------- */
@media (max-width: 860px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  body { font-size: 14.5px; }
  .hero h1 { font-size: 1.7rem; }
  h1 { font-size: 1.55rem; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .header-nav { display: none; }
  .card { padding: 1.1rem; }
  .tool-head h1 { font-size: 1.35rem; }
  .footer-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- print ---------- */
@media print {
  .site-header, .site-footer, .ad-slot, .consent, .cat-bar, .related { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border-color: #cbd5e1; }
}
