*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  --nf-bg0: #f5f3ff;
  --nf-bg1: #ede9fe;
  --nf-surface: #ffffff;
  --nf-line: #e2e8f0;
  --nf-text: #0f172a;
  --nf-muted: #64748b;
  --nf-accent: #7c3aed;
  --nf-accent-deep: #6d28d9;
  --nf-accent-soft: #f5f3ff;
  --nf-radius: 14px;
  --nf-shadow: 0 10px 40px -14px rgba(15, 23, 42, 0.2);
  --nf-font: 'Noto Sans JP', 'Segoe UI', 'Hiragino Sans', sans-serif;
}

body.nf-page-body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--nf-font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--nf-text);
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(167, 139, 250, 0.35), transparent),
    linear-gradient(180deg, var(--nf-bg0) 0%, var(--nf-bg1) 35%, #f8fafc 100%);
}

#pctrouble-site {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.nf-page-main {
  flex: 1 0 auto;
}

.nf-app {
  max-width: 1100px;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 1.75rem) clamp(1rem, 3vw, 1.5rem) 2.5rem;
}

.nf-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

.nf-topbar__brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.nf-topbar__brand h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 700;
}

.nf-topbar__brand p {
  margin: 0.15rem 0 0;
  font-size: 0.875rem;
  color: var(--nf-muted);
}

.nf-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: 12px;
  background: linear-gradient(135deg, #a78bfa, #7c3aed);
  color: #fff;
  box-shadow: var(--nf-shadow);
}

.nf-logo svg {
  width: 1.65rem;
  height: 1.65rem;
}

.nf-privacy-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: #fff;
  border: 1px solid var(--nf-line);
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--nf-muted);
}

.nf-privacy-badge svg {
  width: 1rem;
  height: 1rem;
  color: #16a34a;
}

.nf-topbar__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-left: auto;
}

.nf-disclaimer {
  margin: 0 0 1rem;
  padding: 0.65rem 0.85rem;
  border-radius: var(--nf-radius);
  background: var(--nf-accent-soft);
  border: 1px solid #ddd6fe;
  font-size: 0.875rem;
  color: #5b21b6;
}

.nf-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 10px;
  font-size: 0.9375rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.nf-btn--primary {
  background: var(--nf-accent);
  color: #fff;
}

.nf-btn--primary:hover:not(:disabled) {
  background: var(--nf-accent-deep);
}

.nf-btn--outline {
  background: #fff;
  border-color: var(--nf-line);
  color: var(--nf-text);
}

.nf-btn--ghost {
  background: transparent;
  border-color: var(--nf-line);
  color: var(--nf-muted);
}

.nf-btn--sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8125rem;
}

.nf-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.nf-card {
  background: var(--nf-surface);
  border: 1px solid var(--nf-line);
  border-radius: var(--nf-radius);
  box-shadow: var(--nf-shadow);
}

.nf-drop-wrap--over .nf-idle {
  border-color: var(--nf-accent);
  background: var(--nf-accent-soft);
}

.nf-drop-hint {
  padding: 2.5rem 1.5rem;
  text-align: center;
}

.nf-drop-hint__icon {
  display: inline-flex;
  color: var(--nf-accent);
}

.nf-drop-hint__icon svg {
  width: 3rem;
  height: 3rem;
}

.nf-drop-hint__title {
  margin: 0.75rem 0 0.35rem;
  font-size: 1.125rem;
  font-weight: 700;
}

.nf-drop-hint__sub {
  margin: 0;
  font-size: 0.875rem;
  color: var(--nf-muted);
}

.nf-test-samples {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem 0.5rem;
  margin-top: 1rem;
  padding-top: 0.85rem;
  border-top: 1px dashed var(--nf-line);
}

.nf-test-samples__label {
  font-size: 0.75rem;
  color: var(--nf-muted);
  margin-right: 0.15rem;
}

.nf-test-samples__btn {
  font-size: 0.75rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--nf-line);
  border-radius: 999px;
  background: #fff;
  color: var(--nf-accent-deep);
  cursor: pointer;
}

.nf-test-samples__btn:hover {
  border-color: var(--nf-accent);
  background: var(--nf-accent-soft);
}

.nf-workspace {
  display: grid;
  gap: 1.25rem;
  margin-top: 1rem;
}

@media (min-width: 900px) {
  .nf-workspace {
    /* 右の二値化プレビューが intrinsic 幅で左列を潰さないよう minmax を固定 */
    grid-template-columns: minmax(320px, 1.15fr) minmax(260px, 1fr);
    align-items: start;
  }

  .nf-workspace__col--stage {
    min-width: 320px;
  }

  .nf-workspace__col--controls {
    min-width: 0;
    overflow: hidden;
  }
}

.nf-section-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  font-weight: 700;
}

.nf-section-note {
  margin: 0 0 0.65rem;
  font-size: 0.8125rem;
  color: var(--nf-muted);
}

.nf-stage {
  position: relative;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--nf-line);
  background: #1e293b;
}

.nf-stage__canvas,
.nf-stage__overlay {
  display: block;
  width: 100%;
  height: auto;
  max-height: 480px;
}

.nf-stage__overlay {
  position: absolute;
  inset: 0;
  cursor: crosshair;
  touch-action: none;
}

.nf-preview-label {
  display: block;
  font-size: 0.75rem;
  color: var(--nf-muted);
  margin-bottom: 0.35rem;
}

.nf-preview-row {
  max-width: 100%;
  overflow: hidden;
}

.nf-mask-preview {
  display: block;
  max-width: 100%;
  width: auto;
  height: auto;
  max-height: 72px;
  border: 1px solid var(--nf-line);
  border-radius: 8px;
  image-rendering: pixelated;
  background: #fff;
}

.nf-field {
  display: block;
  margin-bottom: 0.75rem;
}

.nf-field__label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.nf-field__hint {
  font-weight: 400;
  font-size: 0.75rem;
  color: #94a3b8;
}

.nf-field--full {
  width: 100%;
}

.nf-input,
.nf-select {
  width: 100%;
  max-width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--nf-line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9375rem;
}

.nf-check-row {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
}

.nf-check {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
}

.nf-engine-note {
  margin: 0 0 0.75rem;
  font-size: 0.8125rem;
  color: var(--nf-muted);
}

.nf-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.nf-progress {
  margin-top: 0.75rem;
}

.nf-progress__text {
  margin: 0 0 0.35rem;
  font-size: 0.8125rem;
  color: var(--nf-muted);
}

.nf-progress__track {
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.nf-progress__bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #a78bfa, #7c3aed);
  transition: width 0.2s ease;
}

.nf-log-panel {
  margin-top: 0.75rem;
  border: 1px solid var(--nf-line);
  border-radius: var(--nf-radius);
  background: #f8fafc;
  overflow: hidden;
}

.nf-log-panel--stage {
  margin-top: 1rem;
}

.nf-log-panel--stage .nf-log {
  max-height: 14rem;
}

.nf-log-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.65rem;
  border-bottom: 1px solid var(--nf-line);
  background: #fff;
}

.nf-log-panel__actions {
  display: flex;
  gap: 0.35rem;
}

.nf-log-panel__title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--nf-muted);
  letter-spacing: 0.02em;
}

.nf-log-clear,
.nf-log-copy {
  font-size: 0.6875rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--nf-line);
  border-radius: 6px;
  background: #fff;
  color: var(--nf-muted);
  cursor: pointer;
}

.nf-log-clear:hover,
.nf-log-copy:hover {
  border-color: var(--nf-accent);
  color: var(--nf-accent);
}

.nf-log {
  margin: 0;
  max-height: 10rem;
  overflow: auto;
  padding: 0.5rem 0.65rem;
  font-family: ui-monospace, 'Cascadia Code', 'Consolas', monospace;
  font-size: 0.6875rem;
  line-height: 1.45;
  color: #334155;
  white-space: pre-wrap;
  word-break: break-all;
}

.nf-log--placeholder {
  color: #94a3b8;
  font-style: italic;
}

.nf-results {
  margin-top: 1.25rem;
  padding: 1rem 1.15rem;
}

.nf-results-guide {
  margin: 0 0 0.85rem;
  font-size: 0.8125rem;
  line-height: 1.5;
  color: var(--nf-muted);
}

.nf-result-trust {
  margin-bottom: 0.85rem;
  padding: 0.65rem 0.85rem;
  border: 1px solid #c7d2fe;
  border-radius: 10px;
  background: #f8fafc;
}

.nf-result-trust__label {
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.6rem;
  font-size: 0.8125rem;
}

.nf-result-trust__badge {
  padding: 0.15rem 0.45rem;
  border-radius: 6px;
  font-weight: 600;
  background: #e0e7ff;
  color: #312e81;
}

.nf-trust--amb-very .nf-result-trust__amb,
.nf-trust--amb-close .nf-result-trust__amb {
  color: #b45309;
  font-weight: 600;
}

.nf-trust--amb-clear .nf-result-trust__amb {
  color: #047857;
  font-weight: 600;
}

.nf-result-trust__gap {
  color: #4338ca;
}

.nf-result-trust__hint {
  margin: 0.35rem 0 0;
  font-size: 0.75rem;
  color: var(--nf-muted);
}

.nf-trust--abs-low .nf-result-trust__badge {
  background: #fee2e2;
  color: #991b1b;
}

.nf-category-banner {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  background: linear-gradient(135deg, #eef2ff 0%, #f8fafc 100%);
}

.nf-category-banner__main {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.35rem 0.5rem;
}

.nf-category-banner__label {
  font-size: 0.8125rem;
  color: var(--nf-muted);
}

.nf-category-banner__value {
  font-size: 1.125rem;
  color: #312e81;
}

.nf-category-banner__pct {
  font-size: 0.8125rem;
  color: var(--nf-muted);
}

.nf-category-banner__tie {
  font-size: 0.75rem;
  color: #4338ca;
}

.nf-category-banner__hint {
  margin: 0.35rem 0 0.5rem;
  font-size: 0.8125rem;
  color: var(--nf-muted);
}

.nf-category-banner__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.nf-category-chip {
  padding: 0.25rem 0.55rem;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  font-size: 0.75rem;
  font-family: inherit;
  line-height: 1.3;
  background: #e2e8f0;
  color: #475569;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.nf-category-chip:hover:not(.nf-category-chip--active) {
  background: #cbd5e1;
  border-color: #94a3b8;
}

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

.nf-category-chip--active {
  border-color: var(--nf-accent);
  background: var(--nf-accent);
  color: #fff;
  font-weight: 600;
}

.nf-result-extended {
  margin: 0.5rem 0 0;
  font-size: 0.8125rem;
  color: var(--nf-muted);
}

.nf-result-extended--busy {
  color: #4338ca;
}

.nf-result-card__tier {
  font-size: 0.6875rem;
  font-weight: 600;
  color: #4338ca;
}

.nf-result-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.nf-result-card {
  display: flex;
  gap: 0.75rem;
  padding: 0.85rem;
  border: 1px solid var(--nf-line);
  border-radius: 12px;
  background: #fafafa;
}

.nf-result-card__rank {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: var(--nf-accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.9375rem;
}

.nf-result-card__title {
  margin: 0;
  font-size: 1rem;
}

.nf-result-card__weight {
  font-weight: 500;
  color: var(--nf-muted);
  font-size: 0.875rem;
}

.nf-result-card__score {
  margin: 0.2rem 0;
  font-size: 0.8125rem;
  color: var(--nf-muted);
}

.nf-result-card__gap {
  margin: 0.15rem 0 0.25rem;
  font-size: 0.75rem;
  color: #4338ca;
}

.nf-result-diff-wrap {
  margin: 0.35rem 0 0.5rem;
}

.nf-result-diff__label {
  margin: 0 0 0.25rem;
  font-size: 0.6875rem;
  color: var(--nf-muted);
}

.nf-result-diff {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--nf-line);
  border-radius: 6px;
  background: #fff;
}

.nf-result-diff__loading {
  font-size: 0.6875rem;
  color: var(--nf-muted);
}

.nf-result-diff__loading[hidden],
.nf-result-diff[hidden] {
  display: none;
}

.nf-result-card__sample {
  margin: 0.35rem 0;
  font-size: 1.35rem;
  line-height: 1.3;
}

.nf-result-card__links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
  font-size: 0.8125rem;
}

.nf-result-card__links a {
  color: var(--nf-accent-deep);
}

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

.nf-footer {
  margin-top: 2rem;
}

.nf-ad-slot {
  min-height: 48px;
}
