/* Shared look for every tool sub-site: the same tokens, top bar and type as the homepage
   (site.css), tuned for dense output. Light and dark follow the visitor's system setting.
   Variable names are the tools' API: --fg is the accent, --soft the body text, --faint muted. */
:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --input: #ffffff;
  --navy: #0b1220;
  --soft: #121826;
  --faint: #5f6b7e;
  --border: #e3e7ee;
  --fg: #2563eb;
  --fg-dim: #7b8799;
  --hl: #1d4ed8;
  --accent-soft: #e8efff;
  --on-accent: #ffffff;
  --hover: rgba(15, 23, 42, .035);
  --sev-critical: #dc2626;
  --sev-high: #ea580c;
  --sev-medium: #b45309;
  --sev-low: #0284c7;
  --sev-info: #64748b;
  --sev-ok: #16a34a;
  --sans: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b0f17;
    --panel: #111827;
    --input: #0b0f17;
    --navy: #060a12;
    --soft: #e5e9f0;
    --faint: #93a0b4;
    --border: #1f2937;
    --fg: #60a5fa;
    --fg-dim: #7c8aa0;
    --hl: #93c5fd;
    --accent-soft: #14213a;
    --on-accent: #0b1220;
    --hover: rgba(255, 255, 255, .03);
    --sev-critical: #f87171;
    --sev-high: #fb923c;
    --sev-medium: #fbbf24;
    --sev-low: #38bdf8;
    --sev-info: #94a3b8;
    --sev-ok: #22c55e;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--soft); }
body {
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
  font: 15px/1.6 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--fg); text-decoration: none; }
a:hover { color: var(--hl); text-decoration: underline; text-underline-offset: 3px; }
::selection { background: var(--accent-soft); }

/* ---- top bar (matches the homepage) and tool strip ---------------------------------- */
.bar { background: var(--navy); color: #e5e9f0; }
.bar-in, .toolstrip-in, .foot-in { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.bar-in { display: flex; align-items: center; gap: 20px; height: 56px; }
.bar .brand { display: flex; align-items: center; gap: 10px; color: #fff; font: 600 .95rem var(--mono); white-space: nowrap; }
.bar .brand:hover { text-decoration: none; }
.bar .dot { width: 10px; height: 10px; border-radius: 50%; background: #22c55e; box-shadow: 0 0 0 4px rgba(34, 197, 94, .2); flex: none; }
.bar-nav { display: flex; gap: 18px; margin-left: auto; font-size: .9rem; }
.bar-nav a { color: #b6c0d0; }
.bar-nav a:hover { color: #fff; text-decoration: none; }
.toolstrip { background: var(--panel); border-bottom: 1px solid var(--border); }
.toolstrip-in { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.toolstrip-in::-webkit-scrollbar { display: none; }
.toolstrip a { padding: 10px 12px 9px; color: var(--faint); font-size: .88rem; white-space: nowrap; border-bottom: 2px solid transparent; }
.toolstrip a:hover { color: var(--soft); text-decoration: none; }
.toolstrip a[aria-current="page"] { color: var(--soft); font-weight: 600; border-bottom-color: var(--fg); }

.foot { margin-top: auto; border-top: 1px solid var(--border); font-size: .82rem; color: var(--faint); }
.foot-in { display: flex; flex-direction: column; gap: 4px; padding-top: 16px; padding-bottom: 24px; }
.foot .credits { font-size: .95em; }

main.wrap { width: 100%; max-width: 1100px; margin: 0 auto; padding: 28px 16px 48px; }
h1 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -.015em; color: var(--soft); margin: 0 0 .4rem; font-weight: 700; }
h1 + .lede { margin-top: 0; }
h2 { font-size: 1.1rem; color: var(--soft); margin: 1.8rem 0 .7rem; font-weight: 650; }
h3 { font-size: .98rem; color: var(--soft); margin: 1.1rem 0 .4rem; font-weight: 600; }
.lede { color: var(--faint); margin: 0 0 1.4rem; max-width: 80ch; font-size: 1.02rem; }

/* ---- panels & forms ----------------------------------------------------------------- */
.panel { border: 1px solid var(--border); background: var(--panel); border-radius: 12px; padding: 18px; margin: 0 0 16px; }
.panel > :first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }
.panel-title { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; margin: 0 0 .6rem; color: var(--soft); font-weight: 600; }

label { display: block; color: var(--soft); margin: 0 0 .4rem; font-size: .9em; font-weight: 500; }
input[type="text"], input[type="url"], input[type="search"], input[type="number"], input[type="date"],
input[type="datetime-local"], input:not([type]), textarea, select {
  width: 100%; padding: 10px 12px;
  background: var(--input); color: var(--soft); border: 1px solid var(--border); border-radius: 8px;
  font: .95em var(--mono); caret-color: var(--fg);
}
select { font-family: var(--sans); }
textarea { min-height: 7rem; resize: vertical; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--fg); outline-offset: 0; border-color: transparent; }
input::placeholder, textarea::placeholder { color: var(--faint); opacity: .7; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--fg); }

.field { margin: 0 0 12px; }
.inline { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.inline > input, .inline > select { flex: 1 1 260px; width: auto; }
.grid2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.grid3 { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }

button, .btn {
  display: inline-flex; align-items: center; gap: .4em; justify-content: center;
  padding: 8px 14px; background: var(--panel); color: var(--soft);
  border: 1px solid var(--border); border-radius: 8px; font: 600 .9em var(--sans); cursor: pointer; white-space: nowrap;
}
button:hover, .btn:hover { border-color: var(--fg); color: var(--fg); text-decoration: none; }
button.primary, .btn.primary { background: var(--soft); color: var(--bg); border-color: var(--soft); }
button.primary:hover, .btn.primary:hover { background: var(--fg); border-color: var(--fg); color: var(--on-accent); }
button:disabled { opacity: .55; cursor: progress; }
button.small, .btn.small { padding: 4px 10px; font-size: .8em; }
button.link { border: 0; padding: 0; background: none; color: var(--fg); font-weight: 500; }
button.link:hover { text-decoration: underline; }
:focus-visible { outline: 2px solid var(--fg); outline-offset: 2px; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 12px; }
.chip { padding: 3px 12px; border: 1px solid var(--border); border-radius: 999px; color: var(--faint); background: var(--panel); cursor: pointer; font-size: .85em; font-weight: 500; }
.chip:hover { color: var(--soft); border-color: var(--fg-dim); }
.chip[aria-pressed="true"], .chip.on, .chip[aria-selected="true"] { color: var(--on-accent); background: var(--fg); border-color: var(--fg); }

/* ---- data display ------------------------------------------------------------------- */
.kv { display: grid; grid-template-columns: minmax(120px, max-content) 1fr; gap: 5px 18px; margin: 0; font-size: .93em; }
.kv dt { color: var(--faint); }
.kv dd { margin: 0; word-break: break-word; color: var(--soft); }
table.data { width: 100%; border-collapse: collapse; font-size: .9em; }
table.data th, table.data td { text-align: left; padding: 7px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
table.data th { color: var(--faint); font-weight: 600; font-size: .92em; white-space: nowrap; }
table.data td { word-break: break-word; }
table.data tr:hover td { background: var(--hover); }
.table-wrap { overflow-x: auto; }
pre, code { font-family: var(--mono); font-size: .92em; }
pre.code {
  margin: 0; padding: 12px; background: var(--input); border: 1px solid var(--border); border-radius: 8px;
  overflow: auto; white-space: pre-wrap; word-break: break-all; max-height: 420px; color: var(--soft); font-size: .84em;
}
.out-box { padding: 10px 12px; min-height: 2.6em; background: var(--input); border: 1px solid var(--border); border-radius: 8px; word-break: break-all; white-space: pre-wrap; color: var(--soft); font-family: var(--mono); font-size: .9em; }

.muted { color: var(--faint); }
.dim { color: var(--fg-dim); }
.hl { color: var(--fg); }
.fg { color: var(--fg); }
.err { color: var(--sev-critical); }
.ok { color: var(--sev-ok); }
.small { font-size: .84em; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.hidden { display: none !important; }

.badge { display: inline-block; padding: 1px 8px; font-size: .72em; font-weight: 700; border-radius: 999px; border: 1px solid currentColor; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; }
.sev-critical { color: var(--sev-critical); }
.sev-high { color: var(--sev-high); }
.sev-medium { color: var(--sev-medium); }
.sev-low { color: var(--sev-low); }
.sev-info { color: var(--sev-info); }
.sev-ok, .sev-benign { color: var(--sev-ok); }

.note { border-left: 3px solid var(--fg); background: var(--accent-soft); border-radius: 0 8px 8px 0; padding: 8px 14px; color: var(--soft); margin: 0 0 14px; font-size: .9em; }
.note.warn { border-color: var(--sev-medium); background: color-mix(in srgb, var(--sev-medium) 10%, transparent); }
.note.bad { border-color: var(--sev-critical); background: color-mix(in srgb, var(--sev-critical) 10%, transparent); }

.spinner::after {
  content: ""; display: inline-block; width: .8em; height: .8em; margin-left: .5em; vertical-align: -.1em;
  border: 2px solid var(--border); border-top-color: var(--fg); border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

details { border: 1px solid var(--border); border-radius: 10px; margin: 0 0 8px; background: var(--panel); }
details > summary { cursor: pointer; padding: 10px 14px; color: var(--soft); list-style: none; display: flex; gap: .6rem; align-items: baseline; flex-wrap: wrap; }
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "›"; color: var(--faint); display: inline-block; width: .6em; transition: transform .15s; }
details[open] > summary::before { transform: rotate(90deg); }
details > .body { padding: 4px 14px 14px; }

.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--soft); color: var(--bg); padding: 8px 16px; border-radius: 8px; font-weight: 600; z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .18); animation: fade 1.6s forwards;
}
@keyframes fade { 0%, 75% { opacity: 1 } 100% { opacity: 0 } }

@media (max-width: 600px) {
  body { font-size: 14.5px; }
  main.wrap { padding: 20px 16px 36px; }
  h1 { font-size: 1.45rem; }
  .bar-nav a:not(:first-child) { display: none; }
  .panel { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .spinner::after { animation-duration: 2s; }
  details > summary::before { transition: none; }
}
@media print {
  body { background: #fff; color: #000; }
  .bar, .toolstrip, .foot, .no-print, button { display: none !important; }
}
