:root {
  --navy: #17324d;
  --navy-strong: #0c2238;
  --coral: #d94b64;
  --coral-dark: #b93650;
  --paper: #ffffff;
  --canvas: #f4f7f9;
  --soft: #eef3f6;
  --line: #ccd7df;
  --line-strong: #9daeba;
  --muted: #596b78;
  --green: #18794e;
  --code-bg: #17212b;
  --code-line: #2a3a47;
  --code-text: #e7edf2;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body.img2grid-page {
  margin: 0;
  color: var(--navy-strong);
  background: var(--paper);
  font-family: "Noto Sans JP", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.75;
}
body.img2grid-page button,
body.img2grid-page input,
body.img2grid-page select,
body.img2grid-page textarea { font: inherit; }
body.img2grid-page a { color: inherit; }
body.img2grid-page h1,
body.img2grid-page h2,
body.img2grid-page h3,
body.img2grid-page p { margin-top: 0; }
body.img2grid-page h1,
body.img2grid-page h2,
body.img2grid-page h3 { letter-spacing: 0; }

.skip-link {
  position: fixed;
  top: -60px;
  left: 16px;
  z-index: 100;
  padding: 8px 12px;
  color: #fff;
  background: var(--navy);
}
.skip-link:focus { top: 8px; }

.sakura-header {
  position: sticky;
  top: 0;
  z-index: 40;
  min-height: 62px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.header-inner {
  display: grid;
  grid-template-columns: minmax(230px, auto) 1fr auto;
  gap: 28px;
  align-items: center;
  width: min(1180px, calc(100% - 40px));
  min-height: 62px;
  margin: 0 auto;
}
.sakura-brand,
.footer-brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  width: max-content;
  color: var(--navy-strong);
  font-size: 18px;
  font-weight: 800;
  text-decoration: none;
}
.brand-copy { display: grid; gap: 0; line-height: 1.2; }
.brand-copy strong { font-size: 16px; }
.brand-copy small { color: var(--muted); font-size: 10px; font-weight: 600; }
.brand-glyph {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: #fff;
  background: var(--coral);
  border-radius: 4px;
  font-family: Consolas, monospace;
  font-weight: 800;
}
.brand-wiki { margin-left: 4px; color: var(--coral-dark); }
.desktop-nav {
  display: flex;
  gap: 3px;
  justify-content: center;
  width: max-content;
  margin: 0 auto;
  padding: 4px;
  background: var(--soft);
  border: 1px solid #dfe7ec;
  border-radius: 999px;
}
.desktop-nav a {
  padding: 5px 11px;
  color: #425665;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}
.desktop-nav a:hover { color: var(--coral-dark); background: #fff; }
.language-switcher { position: relative; justify-self: end; }
.language-switcher summary {
  display: flex;
  gap: 7px;
  align-items: center;
  min-height: 34px;
  padding: 5px 10px;
  color: #425665;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.language-switcher summary::-webkit-details-marker { display: none; }
.language-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  display: grid;
  width: 170px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: 0 14px 34px rgba(23, 50, 77, 0.18);
}
.language-menu a {
  display: flex;
  justify-content: space-between;
  padding: 7px 9px;
  border-radius: 4px;
  color: #425665;
  font-size: 13px;
  text-decoration: none;
}
.language-menu a:hover,
.language-menu a[aria-current="page"] { color: var(--coral-dark); background: #fff0f3; }
.header-action {
  padding: 7px 12px;
  color: #fff !important;
  background: var(--navy);
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.content-width { width: min(1180px, calc(100% - 40px)); margin: 0 auto; }
.reading-width { width: min(820px, calc(100% - 40px)); margin: 0 auto; }
.home-intro,
.tool-intro {
  padding: 56px 0 24px;
  background: linear-gradient(180deg, #f1f5f7 0%, #fff 100%);
  border-bottom: 1px solid #e8eef2;
}
.tool-intro { padding-top: 36px; }
.eyebrow,
.editor-kicker {
  margin-bottom: 8px;
  color: var(--coral-dark) !important;
  font-family: Consolas, "Noto Sans JP", monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}
.home-intro h1,
.tool-intro h1 {
  max-width: 950px;
  margin-bottom: 14px;
  color: var(--navy-strong);
  font-size: 42px;
  line-height: 1.3;
}
.tool-intro h1 { font-size: 36px; }
.hero-lead {
  max-width: 820px;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 18px;
}
.trust-row { display: flex; flex-wrap: wrap; gap: 8px 22px; color: #3b5363; font-size: 13px; font-weight: 700; }
.trust-row span::before { content: "✓"; margin-right: 6px; color: var(--green); }
.breadcrumb { display: flex; gap: 8px; margin-bottom: 18px; color: var(--muted); font-size: 13px; }
.breadcrumb a { color: var(--navy); }

.editor-section { padding: 28px 20px 48px; background: var(--canvas); }
.editor-shell {
  width: min(1320px, 100%);
  margin: 0 auto;
  overflow: hidden;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  box-shadow: 0 12px 30px rgba(30, 52, 68, 0.1);
}
.editor-topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: center;
  min-height: 74px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.editor-topbar h2 { margin-bottom: 0; font-size: 21px; line-height: 1.35; }
.editor-kicker { margin-bottom: 2px; }
.privacy-note { color: var(--muted); font-size: 12px; white-space: nowrap; }
.privacy-note span { margin-right: 6px; color: var(--green); font-size: 9px; }
.mode-tabs {
  display: flex;
  gap: 0;
  padding: 0 14px;
  overflow-x: auto;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
}
.mode-tabs button {
  min-width: max-content;
  padding: 11px 15px 9px;
  color: #536674;
  background: transparent;
  border: 0;
  border-bottom: 3px solid transparent;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.mode-tabs button:hover { color: var(--navy); }
.mode-tabs button.active { color: var(--coral-dark); border-bottom-color: var(--coral); }
.mode-tabs button:focus-visible,
.editor-actions button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
a:focus-visible { outline: 3px solid rgba(217, 75, 100, 0.35); outline-offset: 2px; }

.settings-panel { min-height: 76px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.settings-row { display: flex; flex-wrap: wrap; gap: 12px 18px; align-items: end; }
.settings-row[hidden] { display: none; }
.settings-row label { display: grid; gap: 4px; color: #4b5e6b; font-size: 12px; font-weight: 700; }
.settings-row .wide-field { min-width: 240px; flex: 1; }
.settings-row input[type="text"],
.settings-row input[type="number"],
.settings-row select {
  min-height: 36px;
  padding: 6px 9px;
  color: var(--navy-strong);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
}
.settings-row input[type="number"] { width: 90px; }
.settings-row .check-field { display: flex; flex-direction: row; gap: 6px; align-items: center; min-height: 36px; }
.check-field input { width: 16px; height: 16px; accent-color: var(--coral-dark); }
.settings-help { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.stats-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  padding: 8px 18px;
  color: #516574;
  background: #fafcfd;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.stats-strip strong { color: var(--navy-strong); font-variant-numeric: tabular-nums; }

.editor-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); background: var(--code-bg); }
.editor-section[data-mode="diff"] .editor-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.editor-pane { min-width: 0; border-right: 1px solid #3d4b57; }
.editor-pane:last-child { border-right: 0; }
.editor-pane[hidden] { display: none; }
.pane-title {
  display: flex;
  justify-content: space-between;
  min-height: 36px;
  padding: 7px 12px;
  color: #cbd6de;
  background: #23313d;
  border-bottom: 1px solid #3d4b57;
  font-size: 12px;
  font-weight: 700;
}
.pane-title span:last-child { color: #93a7b5; font-weight: 500; }
.textarea-wrap { position: relative; display: grid; grid-template-columns: 42px 1fr; height: 350px; background: var(--code-bg); }
.line-numbers {
  height: 100%;
  margin: 0;
  padding: 14px 9px;
  overflow: hidden;
  color: #718695;
  background: #121b23;
  border-right: 1px solid var(--code-line);
  font: 13px/1.65 Consolas, "Noto Sans Mono CJK JP", monospace;
  text-align: right;
  user-select: none;
}
.textarea-wrap textarea,
.diff-output {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 14px;
  resize: none;
  overflow: auto;
  color: var(--code-text);
  background: var(--code-bg);
  border: 0;
  border-radius: 0;
  outline: 0;
  font: 14px/1.65 Consolas, "Noto Sans Mono CJK JP", monospace;
  tab-size: 4;
  white-space: pre;
}
.textarea-wrap textarea::placeholder { color: #6e818f; }
.diff-output { grid-column: 1 / -1; white-space: pre-wrap; }
.diff-output[hidden] { display: none; }
.diff-result .line-numbers { display: none; }
.diff-output span { display: block; min-height: 23px; padding: 0 8px; }
.diff-added { color: #c8f3d9; background: rgba(38, 137, 84, 0.26); }
.diff-removed { color: #ffd7da; background: rgba(195, 55, 67, 0.28); }
.diff-same { color: #b9c7d1; }

.editor-actions { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--line); }
.editor-actions button {
  min-height: 36px;
  padding: 6px 12px;
  color: var(--navy);
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 4px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}
.editor-actions button:hover { background: var(--soft); }
.editor-actions .primary-command { color: #fff; background: var(--coral-dark); border-color: var(--coral-dark); }
.editor-actions .primary-command:hover { background: #9f2f45; }
.editor-message { min-height: 28px; margin: 0; padding: 0 18px 8px; color: var(--muted); font-size: 12px; }
.editor-message[data-type="success"] { color: var(--green); }
.editor-message[data-type="error"] { color: #b4232d; }

.content-band { padding: 68px 0; border-top: 1px solid #edf1f3; }
.soft-band { background: #f7f9fa; }
.tool-directory { background: #fff; }
.section-heading { margin-bottom: 28px; }
.section-heading h2,
.reading-width > h2 { margin-bottom: 14px; color: var(--navy-strong); font-size: 28px; line-height: 1.45; }
.section-heading p,
.reading-width > p { color: var(--muted); }
.reading-width > p { margin-bottom: 16px; }
.tool-link-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.tool-link {
  display: grid;
  grid-template-columns: 40px 1fr auto;
  gap: 12px;
  align-items: center;
  min-height: 94px;
  padding: 14px;
  color: var(--navy-strong);
  border: 1px solid var(--line);
  border-radius: 6px;
  text-decoration: none;
}
.tool-link:hover { border-color: var(--coral); box-shadow: 0 6px 18px rgba(32, 52, 67, 0.08); }
.tool-icon { display: grid; width: 38px; height: 38px; place-items: center; color: var(--coral-dark); background: #fff0f3; border-radius: 4px; font-family: Consolas, monospace; font-weight: 800; }
.tool-link strong { display: block; font-size: 15px; }
.tool-link small { display: block; margin-top: 2px; color: var(--muted); font-size: 12px; line-height: 1.5; }
.tool-arrow { color: var(--coral-dark); }
.step-list { padding: 0; list-style: none; counter-reset: steps; }
.step-list li { position: relative; min-height: 62px; padding: 8px 0 14px 54px; counter-increment: steps; }
.step-list li::before { content: counter(steps); position: absolute; top: 5px; left: 0; display: grid; width: 36px; height: 36px; place-items: center; color: #fff; background: var(--navy); border-radius: 4px; font-weight: 800; }
.step-list strong { display: block; margin-bottom: 2px; }
.step-list span { color: var(--muted); }
.table-wrap { margin: 24px 0; overflow-x: auto; border: 1px solid var(--line); border-radius: 4px; }
table { width: 100%; min-width: 620px; border-collapse: collapse; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--navy-strong); background: var(--soft); font-size: 13px; }
td { color: #485d6c; font-size: 14px; }
tbody tr:last-child td { border-bottom: 0; }
.content-note { margin: 24px 0; padding: 15px 17px; background: #fff8e8; border-left: 4px solid #d79419; }
.content-note strong { display: block; margin-bottom: 4px; }
.content-note p { margin: 0; color: #665225; }
.faq-band { background: #f5f7f8; }
.faq-list { border-top: 1px solid var(--line); }
.faq-list details { border-bottom: 1px solid var(--line); }
.faq-list summary { padding: 17px 4px; color: var(--navy-strong); font-weight: 800; cursor: pointer; }
.faq-list details p { padding: 0 4px 18px; color: var(--muted); }

.legal-page .legal-static-page { padding: 56px 20px 80px; background: var(--canvas); }
.legal-static-wrap { width: min(860px, 100%); margin: 0 auto; }
.legal-static-header { margin-bottom: 28px; }
.legal-static-header h1 { margin-bottom: 12px; font-size: 36px; }
.legal-static-header p,
.legal-static-panel p,
.legal-static-panel li { color: var(--muted); }
.legal-static-panel { padding: 28px; background: #fff; border: 1px solid var(--line); border-radius: 6px; }
.legal-static-panel h2 { margin: 30px 0 10px; font-size: 22px; }
.legal-static-panel h2:first-child { margin-top: 0; }
.legal-static-meta { font-size: 13px; }
.error-page { padding: 100px 20px; text-align: center; }
.error-page h1 { font-size: 64px; }
.error-page a { display: inline-block; padding: 9px 16px; color: #fff; background: var(--coral-dark); border-radius: 4px; text-decoration: none; }

.sakura-footer { padding: 38px 20px; color: #d6e0e8; background: var(--navy-strong); }
.footer-inner { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 36px 80px; width: min(1180px, 100%); margin: 0 auto; }
.footer-brand { color: #fff; }
.footer-inner p { max-width: 650px; margin: 8px 0 0; color: #aebdca; font-size: 13px; }
.footer-email { display: inline-block; margin-top: 12px; color: #fff; font-size: 13px; }
.footer-columns { display: grid; grid-template-columns: repeat(2, minmax(130px, 1fr)); gap: 42px; }
.footer-columns > div { display: grid; align-content: start; gap: 7px; }
.footer-columns .footer-column-title { margin: 0 0 4px; color: #fff; font-size: 12px; font-weight: 800; text-transform: uppercase; }
.footer-inner nav a { color: #d6e0e8; font-size: 13px; text-decoration: none; }
.footer-inner nav a:hover { color: #fff; text-decoration: underline; }
.footer-inner .copyright { grid-column: 1 / -1; padding-top: 20px; border-top: 1px solid #34495a; }

@media (max-width: 980px) {
  .header-inner { grid-template-columns: 1fr auto; }
  .desktop-nav { display: none; }
  .brand-copy small { display: none; }
  .editor-section[data-mode="diff"] .editor-grid { grid-template-columns: 1fr; }
  .editor-section[data-mode="diff"] .editor-pane { border-right: 0; border-bottom: 1px solid #3d4b57; }
  .editor-section[data-mode="diff"] .textarea-wrap { height: 260px; }
  .tool-link-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 680px) {
  body.img2grid-page { font-size: 15px; }
  .header-inner { width: calc(100% - 24px); }
  .sakura-brand { font-size: 16px; }
  .brand-glyph { width: 28px; height: 28px; }
  .header-action { display: none; }
  .home-intro, .tool-intro { padding: 32px 0 18px; }
  .content-width, .reading-width { width: calc(100% - 28px); }
  .home-intro h1, .tool-intro h1 { font-size: 29px; }
  .hero-lead { font-size: 16px; }
  .editor-section { padding: 16px 8px 36px; }
  .editor-topbar { align-items: flex-start; padding: 12px; }
  .editor-topbar h2 { font-size: 17px; }
  .privacy-note { display: none; }
  .mode-tabs { padding: 0 5px; }
  .mode-tabs button { padding: 10px; font-size: 12px; }
  .settings-panel { min-height: 104px; padding: 10px; }
  .settings-row { gap: 8px 12px; }
  .settings-row .wide-field { min-width: 100%; }
  .stats-strip { gap: 4px 13px; padding: 7px 10px; }
  .stats-strip span:nth-child(5) { display: none; }
  .editor-grid, .editor-section[data-mode="diff"] .editor-grid { grid-template-columns: 1fr; }
  .editor-pane { border-right: 0; border-bottom: 1px solid #3d4b57; }
  .textarea-wrap, .editor-section[data-mode="diff"] .textarea-wrap { height: 260px; }
  .editor-actions { padding: 10px; }
  .editor-actions button { flex: 1 1 auto; }
  .editor-actions .primary-command { flex-basis: 100%; }
  .content-band { padding: 48px 0; }
  .section-heading h2, .reading-width > h2 { font-size: 23px; }
  .tool-link-grid { grid-template-columns: 1fr; }
  .tool-link { min-height: 82px; }
  .legal-static-header h1 { font-size: 29px; }
  .legal-static-panel { padding: 20px 16px; }
  .footer-inner { grid-template-columns: 1fr; }
  .footer-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; }
  .footer-inner .copyright { grid-column: 1; }
}

@media (max-width: 430px) {
  .header-inner { width: calc(100% - 16px); gap: 8px; }
  .sakura-brand { gap: 7px; font-size: 14px; }
  .brand-copy strong { font-size: 14px; }
  .language-switcher summary { padding-inline: 8px; }
  .language-switcher summary span:last-child { max-width: 78px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .language-menu { position: fixed; top: 58px; right: 8px; width: min(220px, calc(100vw - 16px)); }
}
