/* ================================
   AS Tools — tools.axen.jp
   1. テーマ / ベース
   2. ヘッダー・フッター
   3. ホーム
   4. ツールページ
   5. ツール部品（13ツール共通）
   6. レスポンシブ
   ================================ */

/* 1. テーマ / ベース */
:root {
  color-scheme: light;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #fbfcfe;
  --text: #101828;
  --muted: #5b6575;
  --line: #e2e6ee;
  --line-strong: #c9d1de;
  --accent: #4f46e5;
  --accent-strong: #3f37c9;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --brand-2: #0ea5a4;
  --ok-bg: #ecfdf3;
  --ok-line: #12b76a;
  --ok-ink: #067647;
  --err-bg: #fef3f2;
  --err-line: #f04438;
  --err-ink: #b42318;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-lg: 0 18px 40px -22px rgba(16, 24, 40, 0.28);
  --radius: 14px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0a0e15;
  --surface: #111826;
  --surface-2: #151d2c;
  --text: #e8edf6;
  --muted: #9aa6b8;
  --line: #223047;
  --line-strong: #2f405c;
  --accent: #8b8cf7;
  --accent-strong: #a5a6ff;
  --accent-ink: #0e1020;
  --accent-soft: #1a2140;
  --brand-2: #2dd4bf;
  --ok-bg: #06281b;
  --ok-line: #12b76a;
  --ok-ink: #6ce9a6;
  --err-bg: #2c1210;
  --err-line: #f97066;
  --err-ink: #fda29b;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 20px 44px -24px rgba(0, 0, 0, 0.8);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", Meiryo, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-strong); }
img, svg { max-width: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }

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

.skip-link {
  position: absolute;
  left: 12px;
  top: -60px;
  z-index: 100;
  background: var(--accent);
  color: var(--accent-ink);
  padding: 8px 16px;
  border-radius: 8px;
  text-decoration: none;
  transition: top 0.15s;
}
.skip-link:focus { top: 12px; }

.wrap { width: min(1120px, calc(100% - 40px)); margin-inline: auto; }

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 10px 22px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  text-decoration: none;
}
.button:hover { background: var(--accent-strong); color: var(--accent-ink); }

/* 2. ヘッダー・フッター */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(12px);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 66px; }

.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand:hover { color: var(--text); }
.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(145deg, var(--accent), var(--brand-2));
  color: #fff;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.brand-mark.is-small { width: 26px; height: 26px; border-radius: 8px; font-size: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-name { font-size: 17px; font-weight: 700; letter-spacing: 0.01em; }
.brand-sub { color: var(--muted); font-size: 11px; letter-spacing: 0.04em; }

.site-nav { display: flex; align-items: center; gap: 6px; }
.site-nav a {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 14px;
  text-decoration: none;
}
.site-nav a:hover { color: var(--text); background: var(--surface); }
.site-nav a[aria-current="page"] { color: var(--text); font-weight: 700; }

.theme-toggle {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  margin-left: 4px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.theme-toggle:hover { border-color: var(--line-strong); }
.theme-toggle svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.theme-toggle .icon-moon { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
:root[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

.site-footer { margin-top: 72px; border-top: 1px solid var(--line); background: var(--surface); }
.footer-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 24px; padding: 36px 0 20px; }
.footer-brand { display: flex; align-items: center; gap: 8px; margin: 0 0 8px; font-weight: 700; }
.footer-note { margin: 0; color: var(--muted); font-size: 13px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 18px; align-content: flex-start; font-size: 13px; }
.footer-links a { color: var(--muted); text-decoration: none; }
.footer-links a:hover { color: var(--text); }
.footer-bottom {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 0 28px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}
.footer-bottom p { margin: 0; }
.footer-bottom a { color: inherit; }

/* 3. ホーム */
.hero { position: relative; overflow: hidden; padding: 72px 0 40px; }
.hero::before {
  content: "";
  position: absolute;
  inset: -20% 20% auto -10%;
  height: 460px;
  background: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%);
  pointer-events: none;
}
.hero > .wrap { position: relative; }
.hero h1 {
  margin: 0 0 18px;
  font-size: clamp(34px, 5.6vw, 56px);
  line-height: 1.18;
  letter-spacing: -0.02em;
}
.hero .lead { max-width: 660px; margin: 0; color: var(--muted); font-size: 16px; }

.search {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 560px;
  margin: 30px 0 0;
  padding: 6px 8px 6px 44px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-icon { position: absolute; left: 15px; width: 19px; height: 19px; fill: none; stroke: var(--muted); stroke-width: 1.8; stroke-linecap: round; }
.search input {
  flex: 1;
  min-width: 0;
  height: 42px;
  border: 0;
  background: transparent;
  font-size: 15px;
}
.search input:focus { outline: none; }
.search input::-webkit-search-cancel-button { cursor: pointer; }
.search kbd {
  flex: none;
  margin-right: 8px;
  padding: 1px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--muted);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0 0; }
.chip {
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip[aria-pressed="true"] { border-color: transparent; background: var(--text); color: var(--bg); font-weight: 700; }

.tools-section { padding-top: 26px; }
.tools-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.tools-head h2 { margin: 0; font-size: 15px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.result-count { margin: 0; color: var(--muted); font-size: 13px; font-family: "SFMono-Regular", Consolas, monospace; }

.tool-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.tool-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 208px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}
.tool-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.tool-card-top { display: flex; align-items: center; justify-content: space-between; }
.tool-index { color: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; font-size: 12px; }
.tool-cat {
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}
.tool-name { font-size: 18px; font-weight: 700; line-height: 1.4; }
.tool-lead { color: var(--muted); font-size: 13px; line-height: 1.75; }
.tool-more { margin-top: auto; color: var(--accent); font-size: 13px; font-weight: 700; }

.empty { grid-column: 1 / -1; margin: 0; padding: 40px 0; color: var(--muted); text-align: center; }

.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-top: 64px; }
.feature { padding: 22px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.feature h2 { margin: 0 0 8px; font-size: 16px; }
.feature p { margin: 0; color: var(--muted); font-size: 13px; }

.closing {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 18px;
  padding: 26px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.closing h2 { margin: 0 0 6px; font-size: 17px; }
.closing p { max-width: 720px; margin: 0; color: var(--muted); font-size: 13px; }

/* 4. ツールページ */
.tool-hero { padding: 40px 0 30px; border-bottom: 1px solid var(--line); }
.breadcrumb { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; color: var(--muted); font-size: 12px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }
.tool-hero h1 { margin: 0 0 12px; font-size: clamp(28px, 4vw, 42px); line-height: 1.25; letter-spacing: -0.01em; }
.tool-hero .lead { max-width: 720px; margin: 0; color: var(--muted); }

.article { max-width: 900px; padding-top: 36px; }
.article h2 {
  margin: 46px 0 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
  font-size: 21px;
  line-height: 1.4;
}
.article h3 { margin: 26px 0 8px; font-size: 16px; }
.article p { margin: 0 0 14px; }
.article ul, .article ol { margin: 0 0 16px; padding-left: 1.4em; }
.article li { margin-bottom: 6px; }
.article code {
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--surface);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.92em;
}

.related { margin-top: 64px; }
.related-title { margin: 0 0 14px; font-size: 15px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.related-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.related-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-decoration: none;
}
.related-card:hover { border-color: var(--accent); color: var(--text); }
.related-cat { color: var(--muted); font-size: 11px; }
.related-name { font-size: 14px; font-weight: 700; }
.related-lead { display: none; }
.back-link { display: inline-block; margin-top: 22px; font-size: 14px; }

.notfound { padding: 90px 0 40px; max-width: 640px; }
.notfound h1 { margin: 0 0 12px; font-size: clamp(28px, 4vw, 40px); }
.notfound p { color: var(--muted); }

/* 5. ツール部品 */
.tool-panel {
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.tool-field { margin: 0 0 20px; }
.tool-field > label { display: block; margin-bottom: 6px; font-size: 14px; font-weight: 700; }
.tool-field textarea,
.tool-field input[type="text"],
.tool-field input[type="number"],
.tool-field input[type="datetime-local"],
.tool-field input[type="file"],
.tool-field select {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
}
.tool-field textarea { font-family: "SFMono-Regular", Consolas, monospace; font-size: 13.5px; line-height: 1.7; resize: vertical; }
.tool-field input[type="file"] { padding: 8px; }
.tool-field select { max-width: 360px; }
.tool-field input[type="range"] { width: 100%; max-width: 360px; accent-color: var(--accent); }
.tool-field input[type="color"] { width: 100%; max-width: 320px; min-height: 48px; padding: 4px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface-2); }
.tool-field textarea:focus,
.tool-field input:focus,
.tool-field select:focus { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 0; }
.field-hint { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.tool-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }

.tool-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.tool-button {
  min-height: 46px;
  padding: 10px 20px;
  border: 1px solid var(--accent);
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 700;
  cursor: pointer;
}
.tool-button:hover:not(:disabled) { background: var(--accent-strong); border-color: var(--accent-strong); }
.tool-button.is-secondary { background: var(--surface); color: var(--accent); border-color: var(--line-strong); }
.tool-button.is-secondary:hover:not(:disabled) { background: var(--accent-soft); border-color: var(--accent); }
.tool-button:disabled { opacity: 0.5; cursor: not-allowed; }

.tool-status { margin: 16px 0 0; font-weight: 700; font-size: 14px; }
.tool-status:empty { display: none; }
.tool-status.is-success { padding: 10px 14px; border-left: 4px solid var(--ok-line); border-radius: 6px; background: var(--ok-bg); color: var(--ok-ink); }
.tool-status.is-error { padding: 10px 14px; border-left: 4px solid var(--err-line); border-radius: 6px; background: var(--err-bg); color: var(--err-ink); }
.tool-meta { margin: 10px 0 0; color: var(--muted); font-size: 13px; }
.tool-meta:empty { display: none; }

.tool-note { padding: 16px 20px; border-left: 4px solid var(--accent); border-radius: 6px; background: var(--accent-soft); }
.tool-note p { margin: 0; font-size: 14px; }

.tool-preview { display: flex; justify-content: center; margin: 22px 0 0; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-2); }
.tool-preview canvas, .tool-preview img { max-width: 100%; height: auto; }
.tool-swatch { min-height: 120px; }

.tool-counts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 18px; }
.tool-counts > div { padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.tool-counts dt { color: var(--muted); font-size: 12px; }
.tool-counts dd { margin: 2px 0 0; color: var(--text); font-size: 20px; font-weight: 700; line-height: 1.3; }

.tool-options { display: flex; flex-wrap: wrap; gap: 10px 22px; margin: 0 0 20px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); }
.tool-options label { display: flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 400; }
.tool-options input { width: 19px; height: 19px; margin: 0; accent-color: var(--accent); }

.tool-code {
  display: block;
  margin: 14px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 18px;
  letter-spacing: 0.04em;
  word-break: break-all;
}

.tool-result {
  margin: 14px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 13.5px;
  line-height: 1.8;
  white-space: pre-line;
  word-break: break-all;
}
.tool-result:empty { display: none; }

.tool-block + .tool-block { margin-top: 26px; padding-top: 26px; border-top: 1px solid var(--line); }
.tool-block h3 { margin: 0 0 14px; font-size: 17px; }

.tool-steps { margin: 0 0 20px; padding-left: 1.4em; }

/* 6. レスポンシブ */
@media (max-width: 960px) {
  .tool-cards, .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .related-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  .wrap { width: calc(100% - 28px); }
  .hero { padding: 48px 0 22px; }
  .hero .lead { font-size: 15px; }
  .search kbd { display: none; }
  .tool-cards, .features, .related-grid, .tool-row { grid-template-columns: 1fr; }
  .tool-card { min-height: 0; }
  .tool-panel { padding: 20px 16px; }
  .tool-actions .tool-button { flex: 1 1 100%; }
  .brand-sub { display: none; }
  .site-nav a { padding: 8px; font-size: 13px; }
  .article h2 { margin-top: 36px; font-size: 19px; }
  .footer-inner { padding-top: 28px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .tool-card { transition: none; }
  .tool-card:hover { transform: none; }
}
