/* ------------------------------------------------------------------
   114tools — design system
   Neutral ink palette, one blue accent, 4px spacing scale.
   ------------------------------------------------------------------ */

:root {
  color-scheme: light;
  --bg: #fbfbfa;
  --surface: #ffffff;
  --surface-2: #f5f5f4;
  --line: #e7e5e4;
  --line-strong: #d6d3d1;
  --text: #1c1917;
  --text-2: #44403c;
  --muted: #78716c;
  --accent: #1d4ed8;
  --accent-soft: #eef2ff;
  --ink: #1c1917;
  --on-ink: #fafaf9;
  --ok: #15803d;
  --warn: #b45309;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(28, 25, 23, .05);
  --shadow: 0 1px 2px rgba(28, 25, 23, .05), 0 12px 32px -16px rgba(28, 25, 23, .18);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  --max: 1080px;
  --narrow: 760px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0b0b0c;
    --surface: #151517;
    --surface-2: #1c1c1f;
    --line: #2a2a2e;
    --line-strong: #3f3f46;
    --text: #f5f5f4;
    --text-2: #d6d3d1;
    --muted: #a1a1aa;
    --accent: #7aa2ff;
    --accent-soft: #16213d;
    --ink: #f5f5f4;
    --on-ink: #141416;
    --ok: #4ade80;
    --warn: #fbbf24;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 16px 40px -20px rgba(0, 0, 0, .8);
  }
}

* { box-sizing: border-box; }

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

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

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

a { color: var(--text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
p a, .article a { color: var(--accent); }

h1, h2, h3, h4 { margin: 0; line-height: 1.25; letter-spacing: -0.015em; font-weight: 650; }
h1 { font-size: clamp(28px, 4vw, 38px); }
h2 { font-size: 22px; }
h3 { font-size: 17px; }

p { margin: 0 0 14px; }
ul, ol { margin: 0 0 14px; padding-left: 22px; }
li { margin: 4px 0; }

hr { border: 0; border-top: 1px solid var(--line); margin: 32px 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip {
  position: absolute; left: -9999px;
  background: var(--ink); color: var(--on-ink);
  padding: 10px 16px; border-radius: var(--radius-sm); z-index: 100;
}
.skip:focus { left: 12px; top: 12px; }

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

.site-header {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  border-bottom: 1px solid var(--line);
  backdrop-filter: saturate(140%) blur(10px);
}
.header-inner {
  max-width: var(--max); margin: 0 auto;
  padding: 0 20px; height: 60px;
  display: flex; align-items: center; gap: 20px;
}
.brand {
  display: inline-flex; align-items: center; gap: 9px;
  font-weight: 680; font-size: 16px; letter-spacing: -0.02em;
  color: var(--text);
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 7px;
  background: var(--ink); color: var(--on-ink);
  display: grid; place-items: center;
  font-size: 9.5px; font-weight: 700; letter-spacing: -0.03em;
}
.header-nav { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.header-nav a {
  font-size: 14px; color: var(--muted);
  padding: 7px 11px; border-radius: var(--radius-sm);
}
.header-nav a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.header-nav a[aria-current="page"] { color: var(--text); background: var(--surface-2); }

/* ---------- layout ---------- */

.container { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.narrow { max-width: var(--narrow); margin: 0 auto; }
main { padding: 32px 0 64px; }

.breadcrumb {
  font-size: 13px; color: var(--muted);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
  margin-bottom: 18px;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb span.sep { opacity: .5; }

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

.hero { padding: 40px 0 8px; max-width: 820px; }
.hero h1 { margin-bottom: 12px; }
.hero .lede { font-size: 17px; color: var(--muted); margin-bottom: 24px; }

.search-wrap { position: relative; max-width: 520px; }
.search-wrap svg {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--muted); pointer-events: none;
}
#q {
  width: 100%; height: 46px;
  padding: 0 14px 0 40px;
  font: inherit; font-size: 15px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: 999px;
  box-shadow: var(--shadow-sm);
}
#q::placeholder { color: var(--muted); }
#q:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }

.trust {
  display: flex; flex-wrap: wrap; gap: 8px 18px;
  margin: 22px 0 0; padding: 0; list-style: none;
  font-size: 13px; color: var(--muted);
}
.trust li { display: inline-flex; align-items: center; gap: 6px; }
.trust svg { width: 14px; height: 14px; color: var(--ok); }

/* ---------- category sections + cards ---------- */

.cat-section { margin-top: 44px; }
.cat-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px; margin-bottom: 14px;
}
.cat-head h2 { font-size: 19px; }
.cat-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.cat-head a { font-size: 13px; color: var(--accent); white-space: nowrap; }

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.card {
  display: flex; gap: 12px; align-items: flex-start;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, transform .15s ease, box-shadow .15s ease;
}
.card:hover {
  text-decoration: none;
  border-color: var(--line-strong);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}
.card-ico {
  flex: none; width: 36px; height: 36px; border-radius: 9px;
  display: grid; place-items: center;
  background: var(--surface-2); color: var(--text-2);
}
.card-ico svg { width: 18px; height: 18px; }
.card h2, .card h3 { font-size: 14.5px; font-weight: 620; margin: 0 0 2px; }
.card p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.45; }

.no-match { padding: 48px 0; text-align: center; color: var(--muted); }

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

.page-head { max-width: 820px; margin-bottom: 24px; }
.page-head h1 { margin-bottom: 8px; }
.lede { color: var(--muted); font-size: 16.5px; margin: 0; }

.tool {
  max-width: 820px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  padding: 22px;
  margin-bottom: 36px;
}

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

.field { display: grid; gap: 6px; }
.field > label {
  font-size: 12.5px; font-weight: 600; color: var(--text-2);
  letter-spacing: .01em;
}
.field .hint { font-size: 12px; color: var(--muted); margin: 0; }

input[type="number"], input[type="text"], input[type="date"], input[type="time"],
input[type="datetime-local"], select, textarea {
  width: 100%; font: inherit; font-size: 15px;
  color: var(--text); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  padding: 9px 12px; min-height: 42px;
  transition: border-color .12s ease, box-shadow .12s ease;
}
textarea { min-height: 150px; resize: vertical; line-height: 1.55; font-size: 14.5px; }
select { appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378716c' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 11px center; background-size: 15px;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="range"] { width: 100%; accent-color: var(--accent); padding: 0; min-height: 28px; }
input[type="color"] {
  width: 52px; height: 42px; padding: 3px; border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong); background: var(--surface); cursor: pointer;
}
input[type="file"] {
  width: 100%; font-size: 13.5px; color: var(--muted);
  border: 1.5px dashed var(--line-strong); border-radius: var(--radius-sm);
  padding: 18px 14px; background: var(--surface-2); cursor: pointer;
}
input[type="file"]::file-selector-button {
  font: inherit; font-size: 13px; font-weight: 600;
  border: 1px solid var(--line-strong); border-radius: 6px;
  background: var(--surface); color: var(--text);
  padding: 7px 12px; margin-right: 12px; cursor: pointer;
}

.check { display: flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text-2); cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--accent); margin: 0; }

.range-line { display: flex; align-items: center; gap: 12px; }
.range-line output {
  min-width: 54px; text-align: right; font-variant-numeric: tabular-nums;
  font-size: 13.5px; color: var(--muted);
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 42px; padding: 0 18px;
  font: inherit; font-size: 14px; font-weight: 600;
  color: var(--on-ink); background: var(--ink);
  border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; transition: opacity .12s ease;
}
.btn:hover { opacity: .88; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-ghost {
  color: var(--text); background: var(--surface);
  border-color: var(--line-strong);
}
.btn-sm { height: 32px; padding: 0 11px; font-size: 12.5px; font-weight: 600; }

/* ---------- results ---------- */

.results { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); display: grid; gap: 14px; }
.results:empty { display: none; }

.result-main {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
}
.result-main .k {
  font-size: 12.5px; font-weight: 600; color: var(--muted);
  letter-spacing: 0; text-transform: none;
}
.result-main .v {
  font-size: clamp(28px, 5vw, 40px); font-weight: 680; letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums; line-height: 1.15; margin-top: 4px;
  overflow-wrap: anywhere;
}
.result-main .s { font-size: 13px; color: var(--muted); margin-top: 4px; }

.result-list { display: grid; gap: 0; }
.result-row {
  display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  padding: 11px 0; border-bottom: 1px solid var(--line);
}
.result-row:last-child { border-bottom: 0; }
.result-row .k { color: var(--muted); font-size: 14px; }
.result-row .v { font-weight: 620; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; text-align: right; }

.swatch { width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--line-strong); display: inline-block; vertical-align: -5px; margin-right: 8px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--line); }
table.data th {
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  text-transform: uppercase; letter-spacing: .06em; background: var(--surface-2);
  white-space: nowrap;
}
table.data td { font-variant-numeric: tabular-nums; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.num, table.data th.num { text-align: right; }

.output { display: grid; gap: 8px; }
.output-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.output-head .k { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.output textarea {
  min-height: 120px; font-family: var(--mono); font-size: 13px; line-height: 1.6;
  background: var(--surface-2);
}

.note { font-size: 13px; color: var(--muted); }
.note.warn { color: var(--warn); }

/* ---------- article ---------- */

.article { max-width: var(--narrow); }
.article h2 { font-size: 20px; margin: 36px 0 12px; }
.article h3 { font-size: 16px; margin: 22px 0 8px; }
.article p, .article li { color: var(--text-2); }
.article code {
  font-family: var(--mono); font-size: 13.5px;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 5px; padding: 1px 5px;
}
.article pre {
  font-family: var(--mono); font-size: 13px; line-height: 1.6;
  background: var(--surface-2); border: 1px solid var(--line);
  border-radius: var(--radius-sm); padding: 14px 16px; overflow-x: auto;
}
.article pre code { background: none; border: 0; padding: 0; }

.faq { margin-top: 36px; }
.faq details {
  border-bottom: 1px solid var(--line); padding: 14px 0;
}
.faq details:first-of-type { border-top: 1px solid var(--line); }
.faq summary {
  cursor: pointer; font-weight: 600; font-size: 15px;
  list-style: none; display: flex; justify-content: space-between; gap: 16px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after { content: "+"; color: var(--muted); font-weight: 400; font-size: 18px; line-height: 1; }
.faq details[open] summary::after { content: "−"; }
.faq details p { margin: 10px 0 0; color: var(--muted); font-size: 14.5px; }

.examples { display: grid; gap: 10px; margin: 8px 0 4px; }
.example {
  border-left: 2px solid var(--line-strong); padding: 2px 0 2px 14px;
  font-size: 14.5px; color: var(--text-2);
}
.example b { color: var(--text); }

.related { margin-top: 44px; }
.related h2 { font-size: 17px; margin-bottom: 12px; }

/* ---------- category page ---------- */

.cat-hero { max-width: var(--narrow); margin-bottom: 28px; }
.cat-hero h1 { margin-bottom: 10px; }
.cat-hero p { color: var(--muted); }
.cat-intro { margin-top: 44px; }

#tool { min-height: 200px; }

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

.site-footer {
  border-top: 1px solid var(--line);
  padding: 36px 0 48px; margin-top: 24px;
  font-size: 13px; color: var(--muted);
}
.footer-inner { max-width: var(--max); margin: 0 auto; padding: 0 20px; }
.footer-cols { display: flex; flex-wrap: wrap; gap: 40px; justify-content: space-between; margin-bottom: 24px; }
.footer-cols h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 10px; }
.footer-cols ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 6px; }
.footer-cols a { color: var(--text-2); font-size: 13.5px; }
.footer-cols a:hover { color: var(--text); }
.footer-legal { border-top: 1px solid var(--line); padding-top: 18px; display: flex; flex-wrap: wrap; gap: 10px 20px; justify-content: space-between; font-size: 12.5px; }

/* ---------- toast ---------- */

#toast {
  position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 12px);
  background: var(--ink); color: var(--on-ink);
  font-size: 13px; font-weight: 500;
  padding: 9px 16px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease;
  z-index: 100;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

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

.stack { display: grid; gap: 14px; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.preview-frame {
  border: 1px solid var(--line); border-radius: var(--radius);
  background:
    repeating-conic-gradient(var(--surface-2) 0% 25%, transparent 0% 50%) 50% / 16px 16px;
  display: grid; place-items: center; padding: 16px; min-height: 160px;
}
.preview-frame[hidden] { display: none; }
.preview-frame img { max-height: 320px; border-radius: 4px; }
.preview-frame canvas {
  max-width: 100%; max-height: 340px; width: auto; height: auto;
  border-radius: 4px; background: #fff;
}

.file-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.file-list li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: var(--surface); font-size: 13.5px;
}
.file-list .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-list .size { color: var(--muted); font-size: 12px; }

@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .header-inner { height: 56px; }
  .header-nav a { padding: 6px 8px; }
  .tool-form .row { grid-template-columns: 1fr; }
  .card { padding: 12px; gap: 10px; }
  .card p { display: none; }
  .tool { padding: 16px; border-radius: 14px; }
  main { padding-top: 24px; }
  .hero { padding-top: 24px; }
  .trust { flex-direction: column; align-items: flex-start; gap: 6px; }
  .footer-cols { gap: 24px; }
}

@media (max-width: 560px) {
  .grid { grid-template-columns: 1fr; }
  .card p { display: block; }
}

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