:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-2: #f1f5f9;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-soft: #eef2ff;
  --ok: #15803d;
  --err: #b91c1c;
  --warn: #a16207;
  --add-bg: #dcfce7;
  --del-bg: #fee2e2;
  --mark: #fde68a;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, 'Liberation Mono', monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b1120;
    --surface: #111827;
    --surface-2: #1e293b;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --border: #273449;
    --accent: #818cf8;
    --accent-text: #0b1120;
    --accent-soft: #1e1b4b;
    --ok: #4ade80;
    --err: #f87171;
    --warn: #facc15;
    --add-bg: #14532d;
    --del-bg: #7f1d1d;
    --mark: #854d0e;
    color-scheme: dark;
  }
}
*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}
a {
  color: var(--accent);
}
img {
  max-width: 100%;
}
h1,
h2,
h3 {
  line-height: 1.25;
}
h1 {
  font-size: clamp(1.7rem, 4vw, 2.3rem);
  margin: 0.3em 0 0.2em;
}
h2 {
  font-size: 1.35rem;
  margin: 1.8em 0 0.6em;
}
code {
  font-family: var(--mono);
  font-size: 0.9em;
  background: var(--surface-2);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
}
.muted {
  color: var(--muted);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 16px;
  top: 8px;
  background: var(--surface);
  padding: 8px;
  z-index: 10;
}

/* header / footer */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 5;
}
.header-inner {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 58px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text);
  text-decoration: none;
  flex-shrink: 0;
}
.main-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.main-nav a {
  color: var(--muted);
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  white-space: nowrap;
  font-size: 0.93rem;
}
.main-nav a:hover {
  background: var(--surface-2);
  color: var(--text);
}
.site-footer {
  margin-top: 64px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 32px 0 16px;
}
.footer-inner {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 24px;
}
.footer-inner nav {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.footer-inner nav a {
  color: var(--muted);
  text-decoration: none;
}
.footer-inner nav a:hover {
  color: var(--accent);
}
.copyright {
  font-size: 0.85rem;
  margin-top: 24px;
}
@media (max-width: 720px) {
  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }
  .footer-inner > div:first-child {
    grid-column: 1 / -1;
  }
}

/* home */
.hero {
  text-align: center;
  padding: 40px 0 16px;
}
.hero .lead {
  max-width: 720px;
  margin: 0 auto;
}
.search input {
  width: 100%;
  max-width: 560px;
  margin-top: 20px;
  padding: 14px 18px;
  font-size: 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
}
.search input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.badges {
  list-style: none;
  padding: 0;
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.92rem;
}
.cat-block h2 a {
  color: var(--text);
  text-decoration: none;
}
.count {
  font-size: 0.8rem;
  color: var(--muted);
  background: var(--surface-2);
  border-radius: 999px;
  padding: 2px 8px;
  vertical-align: middle;
}
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.card {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover {
  border-color: var(--accent);
  transform: translateY(-1px);
}
.card h3 {
  font-size: 1rem;
  margin: 0 0 4px;
}
.card p {
  margin: 0;
  font-size: 0.88rem;
  color: var(--muted);
}
.lead {
  font-size: 1.08rem;
  color: var(--muted);
  margin-top: 0;
}

/* tool layout */
.tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 32px;
  margin-top: 8px;
}
@media (max-width: 1000px) {
  .tool-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .tool-side {
    display: none;
  }
}
.tool-side {
  padding-top: 56px;
}
.tool-side .ad {
  position: sticky;
  top: 80px;
}
.side-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 16px;
}
.side-box a {
  text-decoration: none;
}
.crumbs ol {
  list-style: none;
  padding: 0;
  margin: 16px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.88rem;
  color: var(--muted);
}
.crumbs li + li::before {
  content: '›';
  margin-right: 6px;
}
.crumbs a {
  color: var(--muted);
}
.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.privacy-note {
  font-size: 0.88rem;
  color: var(--muted);
  margin: 8px 0 0;
}

/* form controls */
.tool label {
  font-size: 0.9rem;
  font-weight: 600;
}
.tool textarea,
.tool input[type='text'],
.tool input[type='number'],
.tool input[type='search'],
.tool input[type='datetime-local'],
.tool select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
.tool textarea {
  width: 100%;
  min-height: 200px;
  font-family: var(--mono);
  font-size: 0.9rem;
  line-height: 1.5;
  resize: vertical;
  tab-size: 2;
}
.tool textarea.short {
  min-height: 110px;
}
.tool input[type='text'].wide {
  width: 100%;
  font-family: var(--mono);
}
.tool textarea:focus,
.tool input:focus,
.tool select:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}
.row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin: 10px 0;
}
.row label.check {
  font-weight: 400;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 760px) {
  .cols {
    grid-template-columns: 1fr;
  }
}
.btn {
  font: inherit;
  font-size: 0.93rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
}
.btn:hover {
  border-color: var(--accent);
}
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}
.btn.small {
  padding: 4px 10px;
  font-size: 0.85rem;
}
.spacer {
  flex: 1;
}
.msg {
  min-height: 1.4em;
  font-size: 0.92rem;
  margin: 6px 0;
}
.msg.ok {
  color: var(--ok);
}
.msg.err {
  color: var(--err);
}
.msg.warn {
  color: var(--warn);
}
.out-box {
  font-family: var(--mono);
  font-size: 0.9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  max-height: 480px;
}
.kv {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.kv th,
.kv td {
  text-align: left;
  border-bottom: 1px solid var(--border);
  padding: 8px 6px;
  vertical-align: top;
}
.kv th {
  width: 34%;
  color: var(--muted);
  font-weight: 600;
}
.kv td {
  font-family: var(--mono);
  word-break: break-all;
}
.kv td .btn {
  font-family: inherit;
  margin-left: 8px;
}
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  margin: 12px 0;
}
.stat {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.stat b {
  display: block;
  font-size: 1.4rem;
}
.stat span {
  font-size: 0.82rem;
  color: var(--muted);
}
mark {
  background: var(--mark);
  color: inherit;
  border-radius: 2px;
}
.diff {
  font-family: var(--mono);
  font-size: 0.86rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: auto;
  max-height: 560px;
}
.diff div {
  white-space: pre-wrap;
  word-break: break-word;
  padding: 0 8px;
  display: grid;
  grid-template-columns: 3.2em 3.2em 1.2em 1fr;
}
.diff .n {
  color: var(--muted);
  text-align: right;
  padding-right: 6px;
  user-select: none;
}
.diff .add {
  background: var(--add-bg);
}
.diff .del {
  background: var(--del-bg);
}
.swatch {
  width: 100%;
  height: 90px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.preview-img {
  max-height: 220px;
  border-radius: 8px;
  border: 1px solid var(--border);
}
.drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
}
.drop.over {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* article */
.content {
  max-width: 780px;
}
.content p,
.content li {
  color: var(--text);
}
.steps li {
  margin-bottom: 6px;
}
.faq details {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 8px;
}
.faq summary {
  cursor: pointer;
  font-weight: 600;
  padding: 12px 14px;
}
.faq details > div {
  padding: 0 14px 4px;
}
.content table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.93rem;
}
.content th,
.content td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
  overflow-wrap: anywhere;
}
.content th {
  background: var(--surface-2);
}
.related {
  margin-top: 16px;
}

/* ads: reserve space so the page does not jump (CLS) */
.ad {
  margin: 24px 0;
  min-height: 280px;
  text-align: center;
}
.ad-sidebar {
  min-height: 600px;
  margin-top: 0;
}
.ad-label {
  display: block;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
}

#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.92rem;
  opacity: 0;
  pointer-events: none;
  transition: 0.2s;
  z-index: 20;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}
.page {
  max-width: 780px;
}
