:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1c2330;
  --muted: #5b6576;
  --border: #dde1e7;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-soft: #e8efff;
  --danger: #c62828;
  --ok: #1b7f3b;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151b;
    --surface: #1a1f27;
    --surface-2: #222833;
    --text: #e6e9ef;
    --muted: #9aa4b5;
    --border: #2f3744;
    --accent: #5b8cff;
    --accent-hover: #7aa2ff;
    --accent-soft: #1f2a44;
    --danger: #ff6b6b;
    --ok: #4ade80;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
  line-height: 1.75;
  font-size: 16px;
}
a { color: var(--accent); }
a:hover { color: var(--accent-hover); }

/* ---------- header / footer ---------- */
.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}
.site-header .inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.logo {
  font-weight: 800;
  font-size: 1.15rem;
  text-decoration: none;
  color: var(--text);
  white-space: nowrap;
}
.logo span { color: var(--accent); }
.global-nav {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}
.global-nav::-webkit-scrollbar { display: none; }
.global-nav a {
  padding: 6px 10px;
  border-radius: 6px;
  text-decoration: none;
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
}
.global-nav a:hover { background: var(--surface-2); color: var(--text); }
.global-nav a.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  font-size: 0.9rem;
  color: var(--muted);
}
.site-footer .inner { max-width: 1200px; margin: 0 auto; padding: 24px 16px; }
.site-footer ul { list-style: none; padding: 0; margin: 0 0 12px; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.site-footer a { color: var(--muted); }

/* ---------- layout ---------- */
.layout {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 24px;
}
@media (min-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr) 300px; }
  .sidebar .sticky { position: sticky; top: 72px; }
}
.breadcrumb { font-size: 0.85rem; color: var(--muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--muted); }
h1 { font-size: 1.6rem; line-height: 1.4; margin: 4px 0 8px; }
.lead { color: var(--muted); margin: 0 0 16px; }

/* ---------- tool card ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.field-label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 600;
  font-size: 0.9rem;
  margin: 0 0 6px;
}
.field-label .count { font-weight: 400; color: var(--muted); font-size: 0.8rem; }
textarea {
  width: 100%;
  min-height: 160px;
  resize: vertical;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.6;
}
textarea:focus, select:focus, input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea[readonly] { background: var(--surface); }

.options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  align-items: center;
  margin: 12px 0;
  font-size: 0.9rem;
}
.options label { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
select {
  padding: 5px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}

.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 9px 16px;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-hover); }
.btn.small { padding: 4px 10px; font-size: 0.8rem; }
.btn:disabled { opacity: 0.5; cursor: default; }

.error {
  color: var(--danger);
  font-size: 0.88rem;
  min-height: 1.4em;
  margin: 4px 0;
}
.notice { color: var(--ok); font-size: 0.88rem; }

.result-list { display: grid; gap: 10px; margin-top: 8px; }
.result-row {
  display: grid;
  grid-template-columns: 80px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.result-row .name { font-weight: 700; font-size: 0.85rem; }
.result-row code { font-family: var(--mono); font-size: 13px; word-break: break-all; }

pre.json {
  margin: 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
  min-height: 60px;
}
.jwt-grid { display: grid; gap: 16px; margin-top: 12px; }
.claims { font-size: 0.9rem; margin: 8px 0 0; }
.claims td { padding: 2px 12px 2px 0; vertical-align: top; }
.claims .expired { color: var(--danger); font-weight: 700; }
.claims .valid { color: var(--ok); font-weight: 700; }

/* ---------- tool grid on top page ---------- */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 12px;
}
.tool-card {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: border-color .15s, transform .15s;
}
.tool-card:hover { border-color: var(--accent); transform: translateY(-2px); color: var(--text); }
.tool-card strong { display: block; font-size: 1.02rem; margin-bottom: 4px; }
.tool-card span { color: var(--muted); font-size: 0.88rem; }

/* ---------- article ---------- */
.article { margin-top: 32px; }
.article h2 {
  font-size: 1.25rem;
  border-left: 4px solid var(--accent);
  padding-left: 10px;
  margin: 32px 0 12px;
}
.article h3 { font-size: 1.05rem; margin: 20px 0 8px; }
.article table { border-collapse: collapse; width: 100%; font-size: 0.9rem; margin: 8px 0 16px; }
.article th, .article td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.article th { background: var(--surface-2); }
.article code {
  font-family: var(--mono);
  background: var(--surface-2);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.88em;
}
.faq details {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 14px;
  margin-bottom: 8px;
}
.faq summary { font-weight: 600; cursor: pointer; }
.faq details p { margin: 8px 0 0; }

.related { margin-top: 32px; }

/* ---------- ads / affiliate ---------- */
.ad-slot { margin: 20px 0; text-align: center; min-height: 0; }
.ad-slot:empty { display: none; }
.ad-label, .pr-label {
  display: block;
  font-size: 0.7rem;
  color: var(--muted);
  text-align: left;
  margin-bottom: 2px;
  letter-spacing: .05em;
}
.ad-placeholder {
  border: 2px dashed var(--border);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
}
.sidebar .ad-placeholder { min-height: 600px; }
.aff-slot { margin: 20px 0; }
.aff-slot:empty { display: none; }
.aff-slot img { max-width: 100%; height: auto; }
.aff-card {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.aff-card:hover { border-color: var(--accent); color: var(--text); }
.aff-card img { max-width: 100%; height: auto; display: block; margin-bottom: 8px; border-radius: 6px; }
.aff-card strong { display: block; }
.aff-card span { color: var(--muted); font-size: 0.88rem; }
.aff-card em { font-style: normal; color: var(--accent); font-weight: 700; font-size: 0.9rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 100;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

@media (max-width: 600px) {
  .article td code { word-break: break-all; }
  h1 { font-size: 1.35rem; }
}
.options label { max-width: 100%; white-space: nowrap; }
.options select { max-width: 100%; min-width: 0; flex: 1 1 auto; }

/* ---------- 1行入力 / UNIX時間・UUID ---------- */
.text-input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--text);
  font-family: var(--mono);
  font-size: 15px;
}
.options input[type="number"] {
  width: 6em;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}
.now-box {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
}
.now-box .now-value { font-family: var(--mono); font-size: 1.4rem; font-weight: 700; }
.now-box .now-sub { color: var(--muted); font-size: 0.85rem; }
.result-list.wide .result-row { grid-template-columns: 120px minmax(0, 1fr) auto; }
@media (max-width: 560px) {
  .result-list.wide .result-row { grid-template-columns: minmax(0, 1fr) auto; }
  .result-list.wide .result-row .name { grid-column: 1 / -1; }
}

/* ---------- QRコード / 正規表現 / 文字数 / 色 ---------- */
.qr-preview { display: flex; justify-content: center; margin: 12px 0 4px; }
.qr-preview canvas { max-width: 100%; height: auto; image-rendering: pixelated; border: 1px solid var(--border); border-radius: 8px; }
.options input[type="color"] { width: 40px; height: 28px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: none; cursor: pointer; }

.regex-row { display: flex; align-items: center; gap: 6px; }
.regex-row .text-input { flex: 1 1 auto; min-width: 0; }
.regex-row .regex-flags { flex: 0 0 5em; }
.regex-slash { font-family: var(--mono); color: var(--muted); font-size: 1.2rem; }
.regex-result {
  margin: 0 0 8px;
  padding: 12px;
  min-height: 3em;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-all;
}
.regex-result mark { background: #fde68a; color: #111; border-radius: 3px; padding: 0 1px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.stat { padding: 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); text-align: center; }
.stat-value { font-family: var(--mono); font-size: 1.5rem; font-weight: 700; line-height: 1.2; }
.stat-value small { font-size: 0.75rem; font-weight: 400; }
.stat-label { color: var(--muted); font-size: 0.8rem; }
@media (max-width: 560px) { .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.color-row { display: flex; gap: 8px; align-items: stretch; }
.color-row input[type="color"] { flex: 0 0 52px; height: auto; min-height: 44px; padding: 0; border: 1px solid var(--border); border-radius: 8px; background: none; cursor: pointer; }
.color-row .text-input { flex: 1 1 auto; min-width: 0; }
.color-swatch { display: grid; grid-template-columns: 1fr 1fr; margin: 12px 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.color-swatch span { padding: 18px 12px; text-align: center; font-weight: 700; font-size: 1.1rem; color: var(--swatch, #2563eb); }
.color-swatch .on-white { background: #fff; }
.color-swatch .on-black { background: #000; }
