:root {
  --bg: #f7f8fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-soft: #dbeafe;
  --warn-bg: #fff7ed;
  --warn-border: #fed7aa;
  --warn-text: #9a3412;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans JP", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.nw-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.nw-header-inner,
.nw-main,
.nw-footer {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px;
}

.nw-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

h1, h2 { margin: 0 0 8px; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.05rem; }

.lead { margin: 0; color: var(--muted); }

.lang-switch { display: inline-flex; gap: 8px; }
.lang-switch button {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
}
.lang-switch button.active {
  background: var(--primary-soft);
  border-color: #93c5fd;
  color: #1d4ed8;
}

.nw-main { padding-top: 20px; }

.ad-slot {
  background: #fff;
  border: 1px dashed #cbd5e1;
  color: var(--muted);
  text-align: center;
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 14px;
}

.usage-link {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
}
.usage-link a {
  color: #1d4ed8;
  text-decoration: none;
}
.usage-link a:hover { text-decoration: underline; }

.nw-donate {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 16px;
}
.nw-donate-text { margin: 0 0 8px; color: var(--muted); }
.nw-donate-links { display: flex; gap: 10px; flex-wrap: wrap; }
.nw-donate-links a {
  text-decoration: none;
  border: 1px solid #bfdbfe;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 6px 10px;
  border-radius: 8px;
  font-weight: 600;
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.card,
.faq {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
}

.muted { color: var(--muted); margin: 0; }
.note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.dropzone {
  display: grid;
  place-items: center;
  text-align: center;
  padding: 24px 10px;
  border: 2px dashed #bfdbfe;
  border-radius: 12px;
  background: #f8fbff;
  margin: 10px 0;
  cursor: pointer;
}
.dropzone.is-drag { border-color: #60a5fa; background: #eff6ff; }
.dropzone input { display: none; }
.dropzone span { color: var(--muted); font-size: 0.92rem; }

.row { display: flex; gap: 10px; align-items: center; }
.row.compact { margin-top: 8px; }
.row.spread { justify-content: space-between; }
.row.two { align-items: flex-end; }
.row.two > .field { flex: 1; }
.action-row { align-items: stretch; }

.field { display: grid; gap: 6px; margin-top: 10px; }
.field input, .field select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.95rem;
  background: #fff;
}
.check-line {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.btn {
  border: 1px solid #93c5fd;
  background: #2563eb;
  color: #fff;
  border-radius: 8px;
  padding: 8px 12px;
  font-weight: 600;
  cursor: pointer;
}
.btn.ghost {
  background: #fff;
  color: #1d4ed8;
}
.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.item-list { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.item-list li {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 8px;
  align-items: center;
}
.item-list img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--border);
}
.actions { display: flex; gap: 4px; }
.actions button {
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 6px;
  padding: 4px 8px;
}

.estimate {
  margin: 12px 0 0;
  border: 1px solid var(--border);
  background: #f9fafb;
  color: var(--muted);
  border-radius: 10px;
  padding: 10px;
  font-size: 0.92rem;
}
.estimate strong { color: var(--text); }
.estimate.warn {
  border-color: var(--warn-border);
  background: var(--warn-bg);
  color: var(--warn-text);
}
.estimate ul {
  margin: 6px 0 0 18px;
  padding: 0;
}

.preview-card { margin-bottom: 16px; }
.preview-card canvas {
  width: 100%;
  max-height: 70vh;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: repeating-conic-gradient(#f3f4f6 0% 25%, #fff 0% 50%) 50% / 20px 20px;
}
.status { margin: 10px 0 0; color: var(--muted); }

.faq {
  margin: 18px 0;
}
.faq details {
  border-top: 1px solid var(--border);
  padding: 10px 0;
}
.faq details:first-of-type { border-top: 0; }
.faq summary {
  cursor: pointer;
  font-weight: 600;
}
.faq p {
  margin: 8px 0 0;
  color: var(--muted);
}

.nw-links {
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
  margin: 16px 0 4px;
}
.nw-links a,
.nw-footer a { color: #1d4ed8; text-decoration: none; }
.nw-links a:hover,
.nw-footer a:hover { text-decoration: underline; }

.nw-footer {
  text-align: center;
  color: var(--muted);
  font-size: 0.92rem;
}
.nw-footer p { margin: 4px 0; }

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
summary:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

[data-lang-mode="en"] [data-hide-en],
[data-lang-mode="ja"] [data-hide-ja] {
  display: none;
}

@media (max-width: 860px) {
  .tool-grid { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .nw-header-inner {
    display: grid;
  }
  .lang-switch {
    justify-content: flex-start;
  }
  .row,
  .row.two,
  .action-row,
  .nw-donate-links {
    display: grid;
    grid-template-columns: 1fr;
  }
  .btn,
  .actions button {
    width: 100%;
  }
  .item-list li {
    grid-template-columns: 48px 1fr;
  }
  .item-list .actions {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
  }
}
